Overview
Comment:Cleanup repository after cvs2git conversion.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: af3953deaeb5f526026f3dc493e5869172b7f9bf13c9bdd384186b411162c755
User & Date: jeff@gridfinity.com on 2021-03-01 11:39:42
Other Links: manifest | tags
Context
2021-03-01
11:40:23
Add .gitignore check-in: 626e590b61 user: jeff@gridfinity.com tags: master, trunk
11:39:42
Cleanup repository after cvs2git conversion. check-in: af3953deae user: jeff@gridfinity.com tags: master, trunk
2015-08-11
22:55:00
5-port R for new stoichimetric form - integral only Leaf check-in: 2145ae2fe9 user: gawthrop@users.sourceforge.net tags: 5.0.2015.08.11, origin/master, trunk
Changes

Added .old_cvsroot/checkoutlist version [db1d2d9b69].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
#	[<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'
syncmail

Added .old_cvsroot/commitinfo version [85654ac9a8].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list 
# of files to check.  A non-zero exit of the filter program will 
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Added .old_cvsroot/config version [28e7a42550].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no

# Set `PreservePermissions' to `yes' to save file status information
# in the repository.
#PreservePermissions=no

# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no

Added .old_cvsroot/cvswrappers version [9d41597c29].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
#  wildcard	[option value][option value]...
#
#  where option is one of
#  -f		from cvs filter		value: path to filter
#  -t		to cvs filter		value: path to filter
#  -m		update methodology	value: MERGE or COPY
#  -k		expansion mode		value: b, o, kkv, &c
#
#  and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'

Added .old_cvsroot/editinfo version [dfa5fb459c].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "editinfo" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Added .old_cvsroot/loginfo version [7508d75767].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "loginfo" file controls where "cvs commit" log information
# is sent.  The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT.  If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter.  The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators.  The format
# characters are:
#
#   s = file name
#   V = old version number (pre-checkin)
#   v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog

# Lines to mail changes
CVSROOT $CVSROOT/CVSROOT/syncmail %{sVv} gawthrop@users.sourceforge.net
DEFAULT $CVSROOT/CVSROOT/syncmail %{sVv} mtt-checkins@lists.sourceforge.net

Added .old_cvsroot/modules version [84b74e5335].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Three different line formats are valid:
#	key	-a    aliases...
#	key [options] directory
#	key [options] directory files...
#
# Where "options" are composed of:
#	-i prog		Run "prog" on "cvs commit" from top-level of module.
#	-o prog		Run "prog" on "cvs checkout" of module.
#	-e prog		Run "prog" on "cvs export" of module.
#	-t prog		Run "prog" on "cvs rtag" of module.
#	-u prog		Run "prog" on "cvs update" of module.
#	-d dir		Place module in directory "dir" instead of module name.
#	-l		Top-level directory only -- do not recurse.
#
# NOTE:  If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias.  An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module.  This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.

Added .old_cvsroot/notify version [2a5259e3c5].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent.  The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT.  If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"

Added .old_cvsroot/rcsinfo version [c276b88ba1].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT.  For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Added .old_cvsroot/syncmail version [2c972f2c68].












































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/python

# Copyright (c) 2002, 2003, Barry Warsaw, Fred Drake, and contributors
# All rights reserved.
# See the accompanying LICENSE file for details.

# Compatibility: Python 2.2.3, tied to the version of Python on SourceForge's
# authenticated CVS server.

"""Complicated notification for CVS checkins.

This script is used to provide email notifications of changes to the CVS
repository.  These email changes will include context diffs of the changes.
Really big diffs will be trimmed.

This script is run from a CVS loginfo file (see $CVSROOT/CVSROOT/loginfo).  To
set this up, create a loginfo entry that looks something like this:

    mymodule /path/to/this/script %%s some-email-addr@your.domain

In this example, whenever a checkin that matches `mymodule' is made, this
script is invoked, which will generate the diff containing email, and send it
to some-email-addr@your.domain.

    Note: This module used to also do repository synchronizations via
    rsync-over-ssh, but since the repository has been moved to SourceForge,
    this is no longer necessary.  The syncing functionality has been ripped
    out in the 3.0, which simplifies it considerably.  Access the 2.x versions
    to refer to this functionality.  Because of this, the script is misnamed.

It no longer makes sense to run this script from the command line.  Doing so
will only print out this usage information.

Usage:

    %(PROGRAM)s [options] <%%S> email-addr [email-addr ...]

Where options are:

    --cvsroot=<path>
        Use <path> as the environment variable CVSROOT.  Otherwise this
        variable must exist in the environment.

    --context=#
    -C #
        Include # lines of context around lines that differ (default: 2).

    -c
        Produce a context diff (default).

    -m hostname
    --mailhost hostname
        The hostname of an available SMTP server.  The default is
        'localhost'.

    -u
        Produce a unified diff (smaller).

    -S TEXT
    --subject-prefix=TEXT
        Prepend TEXT to the email subject line.

    -R ADDR
    --reply-to=ADDR
      Add a "Reply-To: ADDR" header to the email message.

    --quiet / -q
        Don't print as much status to stdout.

    --fromhost=hostname
    -f hostname
        The hostname that email messages appear to be coming from.  The From:
        header of the outgoing message will look like user@hostname.  By
        default, hostname is the machine's fully qualified domain name.

    --help / -h
        Print this text.

The rest of the command line arguments are:

    <%%S>
        CVS %%s loginfo expansion.  When invoked by CVS, this will be a single
        string containing the directory the checkin is being made in, relative
        to $CVSROOT, followed by the list of files that are changing.  If the
        %%s in the loginfo file is %%{sVv}, context diffs for each of the
        modified files are included in any email messages that are generated.

    email-addrs
        At least one email address.
"""
__version__ = '1.2'

import os
import sys
import re
import time
import string
import getopt
import smtplib
import pwd
import socket

try:
    from socket import getfqdn
except ImportError:
    def getfqdn():
        # Python 1.5.2 :(
        hostname = socket.gethostname()
        byaddr = socket.gethostbyaddr(socket.gethostbyname(hostname))
        aliases = byaddr[1]
        aliases.insert(0, byaddr[0])
        aliases.insert(0, hostname)
        for fqdn in aliases:
            if '.' in fqdn:
                break
        else:
            fqdn = 'localhost.localdomain'
        return fqdn


from cStringIO import StringIO

# Which SMTP server to do we connect to?
MAILHOST = 'localhost'
MAILPORT = 25

# Diff trimming stuff
DIFF_HEAD_LINES = 20
DIFF_TAIL_LINES = 20
DIFF_TRUNCATE_IF_LARGER = 1000

COMMASPACE = ', '

PROGRAM = sys.argv[0]

BINARY_EXPLANATION_LINES = [
    "(This appears to be a binary file; contents omitted.)\n"
    ]

NOVERSION = "Couldn't generate diff; no version number found for file: %s"
BACKSLASH = "Couldn't generate diff: backslash in filespec's filename: %s"



def usage(code, msg=''):
    print __doc__ % globals()
    if msg:
        print msg
    sys.exit(code)



def calculate_diff(entry, contextlines):
    file = entry.name
    oldrev = entry.revision
    newrev = entry.new_revision

    # Make sure we can find a CVS version number
    if oldrev is None and newrev is None:
        return NOVERSION % file

    if string.find(file, "'") <> -1:
        # Those crazy users put single-quotes in their file names!  Now we
        # have to escape everything that is meaningful inside double-quotes.
        filestr = string.replace(file, '\\', '\\\\')
        filestr = string.replace(filestr, '`', '\`')
        filestr = string.replace(filestr, '"', '\"')
        filestr = string.replace(filestr, '$', '\$')
        # and quote it with double-quotes.
        filestr = '"' + filestr + '"'
    else:
        # quote it with single-quotes.
        filestr = "'" + file + "'"
    if oldrev is None:
        # File is being added.
        try:
            if os.path.exists(file):
                fp = open(file)
            else:
                update_cmd = "cvs -fn update -r %s -p %s" % (newrev, filestr)
                fp = os.popen(update_cmd)
            lines = fp.readlines()
            fp.close()
            # Is this a binary file?  Let's look at the first few
            # lines to figure it out:
            for line in lines[:5]:
                for c in string.rstrip(line):
                    if c in string.whitespace:
                        continue
                    if c < ' ' or c > chr(127):
                        lines = BINARY_EXPLANATION_LINES[:]
                        break
            lines.insert(0, '--- NEW FILE: %s ---\n' % file)
        except IOError, e:
            lines = ['***** Error reading new file: ',
                     str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()]
    elif newrev is None:
        lines = ['--- %s DELETED ---\n' % file]
    else:
        # File has been changed.
        # This /has/ to happen in the background, otherwise we'll run into CVS
        # lock contention.  What a crock.
        if contextlines > 0:
            difftype = "-C " + str(contextlines)
        else:
            difftype = "-u"
        diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s %s" \
                  % (difftype, oldrev, newrev, filestr)
        fp = os.popen(diffcmd)
        lines = fp.readlines()
        # ignore the error code, it always seems to be 1 :(
        fp.close()
    if len(lines) > DIFF_TRUNCATE_IF_LARGER:
        removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES
        del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES]
        lines.insert(DIFF_HEAD_LINES,
                     '[...%d lines suppressed...]\n' % removedlines)
    return string.join(lines, '')



rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]')

def quotename(name):
    if name and rfc822_specials_re.search(name):
        return '"%s"' % string.replace(name, '"', '\\"')
    else:
        return name



def blast_mail(subject, people, entries, contextlines, fromhost, replyto):
    # cannot wait for child process or that will cause parent to retain cvs
    # lock for too long.  Urg!
    if not os.fork():
        # in the child
        # give up the lock you cvs thang!
        time.sleep(2)
        # Create the smtp connection to the localhost
        conn = smtplib.SMTP()
        conn.connect(MAILHOST, MAILPORT)
        user = pwd.getpwuid(os.getuid())[0]
        name = string.split(pwd.getpwuid(os.getuid())[4], ',')[0]
        domain = fromhost or getfqdn()
        address = '%s@%s' % (user, domain)
        s = StringIO()
        sys.stdout = s
        datestamp = time.strftime('%a, %d %b %Y %H:%M:%S +0000',
                                  time.gmtime(time.time()))
        try:
            vars = {'address' : address,
                    'name'    : quotename(name),
                    'people'  : string.join(people, COMMASPACE),
                    'subject' : subject,
                    'version' : __version__,
                    'date'    : datestamp,
                    }
            print '''\
From: %(name)s <%(address)s>
To: %(people)s''' % vars
            if replyto:
                print 'Reply-To: %s' % replyto
            print '''\
Subject: %(subject)s
Date: %(date)s
X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail>
''' % vars
            s.write(sys.stdin.read())
            # append the diffs if available
            print
            for entry in entries:
                print calculate_diff(entry, contextlines)
        finally:
            sys.stdout = sys.__stdout__
        resp = conn.sendmail(address, people, s.getvalue())
        conn.close()
        os._exit(0)



class CVSEntry:
    def __init__(self, name, revision, timestamp, conflict, options, tagdate):
        self.name = name
        self.revision = revision
        self.timestamp = timestamp
        self.conflict = conflict
        self.options = options
        self.tagdate = tagdate

def get_entry(prefix, mapping, line, filename):
    line = string.strip(line)
    parts = string.split(line, "/")
    _, name, revision, timestamp, options, tagdate = parts
    key = namekey(prefix, name)
    try:
        entry = mapping[key]
    except KeyError:
        if revision == "0":
            revision = None
        if string.find(timestamp, "+") != -1:
            timestamp, conflict = tuple(string.split(timestamp, "+"))
        else:
            conflict = None
        entry = CVSEntry(key, revision, timestamp, conflict,
                         options, tagdate)
        mapping[key] = entry
    return entry

def namekey(prefix, name):
    if prefix:
        return os.path.join(prefix, name)
    else:
        return name

def load_change_info(prefix=None):
    if prefix is not None:
        entries_fn = os.path.join(prefix, "CVS", "Entries")
    else:
        entries_fn = os.path.join("CVS", "Entries")
    entries_log_fn = entries_fn + ".Log"
    mapping = {}
    f = open(entries_fn)
    while 1:
        line = f.readline()
        if not line:
            break
##        if string.strip(line) == "D":
##            continue
        # we could recurse down subdirs, except the Entries.Log files
        # we need haven't been written to the subdirs yet, so it
        # doesn't do us any good
##        if line[0] == "D":
##            name = string.split(line, "/")[1]
##            dirname = namekey(prefix, name)
##            if os.path.isdir(dirname):
##                m = load_change_info(dirname)
##                mapping.update(m)
        if line[0] == "/":
            # normal file
            get_entry(prefix, mapping, line, entries_fn)
        # else: bogus Entries line
    f.close()
    if os.path.isfile(entries_log_fn):
        f = open(entries_log_fn)
        while 1:
            line = f.readline()
            if not line:
                break
            if line[1:2] != ' ':
                # really old version of CVS
                break
            entry = get_entry(prefix, mapping, line[2:], entries_log_fn)
            parts = string.split(line, "/")[1:]
            if line[0] == "A":
                # adding a file
                entry.new_revision = parts[1]
            elif line[0] == "R":
                # removing a file
                entry.new_revision = None
        f.close()
    for entry in mapping.values():
        if not hasattr(entry, "new_revision"):
            print 'confused about file', entry.name, '-- ignoring'
            del mapping[entry.name]
    return mapping

def load_branch_name():
    tag_fn = os.path.join("CVS", "Tag")
    if os.path.isfile(tag_fn):
        f = open(tag_fn)
        line = string.strip(f.readline())
        f.close()
        if line[:1] == "T":
            return line[1:]
    return None

# scan args for options
def main():
    # XXX Should really move all the options to an object, just to
    # avoid threading so many positional args through everything.
    try:
        opts, args = getopt.getopt(
            sys.argv[1:], 'hC:cuS:R:qf:m:',
            ['fromhost=', 'context=', 'cvsroot=', 'mailhost=',
             'subject-prefix=', 'reply-to=',
             'help', 'quiet'])
    except getopt.error, msg:
        usage(1, msg)

    # parse the options
    contextlines = 2
    verbose = 1
    subject_prefix = ""
    replyto = None
    fromhost = None
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage(0)
        elif opt == '--cvsroot':
            os.environ['CVSROOT'] = arg
        elif opt in ('-C', '--context'):
            contextlines = int(arg)
        elif opt == '-c':
            if contextlines <= 0:
                contextlines = 2
        elif opt == '-u':
            contextlines = 0
        elif opt in ('-S', '--subject-prefix'):
            subject_prefix = arg
        elif opt in ('-R', '--reply-to'):
            replyto = arg
        elif opt in ('-q', '--quiet'):
            verbose = 0
        elif opt in ('-f', '--fromhost'):
            fromhost = arg
        elif opt in ('-m', '--mailhost'):
            global MAILHOST
            MAILHOST = arg

    # What follows is the specification containing the files that were
    # modified.  The argument actually must be split, with the first component
    # containing the directory the checkin is being made in, relative to
    # $CVSROOT, followed by the list of files that are changing.
    if not args:
        usage(1, 'No CVS module specified')
    changes = load_change_info()
    branch = load_branch_name()
    subject = subject_prefix + args[0]
    specs = string.split(args[0])
    del args[0]

    # The remaining args should be the email addresses
    if not args:
        usage(1, 'No recipients specified')

    # Now do the mail command
    people = args

    if specs[-3:] == ['-', 'Imported', 'sources']:
        print 'Not sending email for imported sources.'
        return

    if verbose:
##        print 'Python version', sys.version
##        os.system("type python1.6; type python2;"
##                  " type python2.0; type python2.1; type python2.2;"
##                  " type rcsdiff; type rlog")
        print 'Mailing %s...' % string.join(people, COMMASPACE)
        print 'Generating notification message...'
    blast_mail(subject, people, changes.values(),
               contextlines, fromhost, replyto)
    if verbose:
        print 'Generating notification message... done.'



if __name__ == '__main__':
    main()
    sys.exit(0)

Added .old_cvsroot/taginfo version [364dad5373].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4->  file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Added .old_cvsroot/verifymsg version [cbc796537d].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "verifymsg" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Added .old_mttroot_cvsroot/checkoutlist version [db1d2d9b69].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
#	[<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'
syncmail

Added .old_mttroot_cvsroot/commitinfo version [85654ac9a8].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list 
# of files to check.  A non-zero exit of the filter program will 
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Added .old_mttroot_cvsroot/config version [28e7a42550].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no

# Set `PreservePermissions' to `yes' to save file status information
# in the repository.
#PreservePermissions=no

# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no

Added .old_mttroot_cvsroot/cvswrappers version [9d41597c29].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
#  wildcard	[option value][option value]...
#
#  where option is one of
#  -f		from cvs filter		value: path to filter
#  -t		to cvs filter		value: path to filter
#  -m		update methodology	value: MERGE or COPY
#  -k		expansion mode		value: b, o, kkv, &c
#
#  and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'

Added .old_mttroot_cvsroot/editinfo version [dfa5fb459c].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "editinfo" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Added .old_mttroot_cvsroot/loginfo version [f5255d5add].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "loginfo" file controls where "cvs commit" log information
# is sent.  The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT.  If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter.  The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators.  The format
# characters are:
#
#   s = file name
#   V = old version number (pre-checkin)
#   v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog

# Lines to mail changes
CVSROOT $CVSROOT/CVSROOT/syncmail %{sVv} mtt@gawthrop.net
DEFAULT $CVSROOT/CVSROOT/syncmail %{sVv} mtt-cvs@lists.sourceforge.net

Added .old_mttroot_cvsroot/modules version [84b74e5335].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Three different line formats are valid:
#	key	-a    aliases...
#	key [options] directory
#	key [options] directory files...
#
# Where "options" are composed of:
#	-i prog		Run "prog" on "cvs commit" from top-level of module.
#	-o prog		Run "prog" on "cvs checkout" of module.
#	-e prog		Run "prog" on "cvs export" of module.
#	-t prog		Run "prog" on "cvs rtag" of module.
#	-u prog		Run "prog" on "cvs update" of module.
#	-d dir		Place module in directory "dir" instead of module name.
#	-l		Top-level directory only -- do not recurse.
#
# NOTE:  If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias.  An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module.  This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.

Added .old_mttroot_cvsroot/notify version [2a5259e3c5].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent.  The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT.  If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"

Added .old_mttroot_cvsroot/rcsinfo version [c276b88ba1].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT.  For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Added .old_mttroot_cvsroot/syncmail version [2c972f2c68].












































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/python

# Copyright (c) 2002, 2003, Barry Warsaw, Fred Drake, and contributors
# All rights reserved.
# See the accompanying LICENSE file for details.

# Compatibility: Python 2.2.3, tied to the version of Python on SourceForge's
# authenticated CVS server.

"""Complicated notification for CVS checkins.

This script is used to provide email notifications of changes to the CVS
repository.  These email changes will include context diffs of the changes.
Really big diffs will be trimmed.

This script is run from a CVS loginfo file (see $CVSROOT/CVSROOT/loginfo).  To
set this up, create a loginfo entry that looks something like this:

    mymodule /path/to/this/script %%s some-email-addr@your.domain

In this example, whenever a checkin that matches `mymodule' is made, this
script is invoked, which will generate the diff containing email, and send it
to some-email-addr@your.domain.

    Note: This module used to also do repository synchronizations via
    rsync-over-ssh, but since the repository has been moved to SourceForge,
    this is no longer necessary.  The syncing functionality has been ripped
    out in the 3.0, which simplifies it considerably.  Access the 2.x versions
    to refer to this functionality.  Because of this, the script is misnamed.

It no longer makes sense to run this script from the command line.  Doing so
will only print out this usage information.

Usage:

    %(PROGRAM)s [options] <%%S> email-addr [email-addr ...]

Where options are:

    --cvsroot=<path>
        Use <path> as the environment variable CVSROOT.  Otherwise this
        variable must exist in the environment.

    --context=#
    -C #
        Include # lines of context around lines that differ (default: 2).

    -c
        Produce a context diff (default).

    -m hostname
    --mailhost hostname
        The hostname of an available SMTP server.  The default is
        'localhost'.

    -u
        Produce a unified diff (smaller).

    -S TEXT
    --subject-prefix=TEXT
        Prepend TEXT to the email subject line.

    -R ADDR
    --reply-to=ADDR
      Add a "Reply-To: ADDR" header to the email message.

    --quiet / -q
        Don't print as much status to stdout.

    --fromhost=hostname
    -f hostname
        The hostname that email messages appear to be coming from.  The From:
        header of the outgoing message will look like user@hostname.  By
        default, hostname is the machine's fully qualified domain name.

    --help / -h
        Print this text.

The rest of the command line arguments are:

    <%%S>
        CVS %%s loginfo expansion.  When invoked by CVS, this will be a single
        string containing the directory the checkin is being made in, relative
        to $CVSROOT, followed by the list of files that are changing.  If the
        %%s in the loginfo file is %%{sVv}, context diffs for each of the
        modified files are included in any email messages that are generated.

    email-addrs
        At least one email address.
"""
__version__ = '1.2'

import os
import sys
import re
import time
import string
import getopt
import smtplib
import pwd
import socket

try:
    from socket import getfqdn
except ImportError:
    def getfqdn():
        # Python 1.5.2 :(
        hostname = socket.gethostname()
        byaddr = socket.gethostbyaddr(socket.gethostbyname(hostname))
        aliases = byaddr[1]
        aliases.insert(0, byaddr[0])
        aliases.insert(0, hostname)
        for fqdn in aliases:
            if '.' in fqdn:
                break
        else:
            fqdn = 'localhost.localdomain'
        return fqdn


from cStringIO import StringIO

# Which SMTP server to do we connect to?
MAILHOST = 'localhost'
MAILPORT = 25

# Diff trimming stuff
DIFF_HEAD_LINES = 20
DIFF_TAIL_LINES = 20
DIFF_TRUNCATE_IF_LARGER = 1000

COMMASPACE = ', '

PROGRAM = sys.argv[0]

BINARY_EXPLANATION_LINES = [
    "(This appears to be a binary file; contents omitted.)\n"
    ]

NOVERSION = "Couldn't generate diff; no version number found for file: %s"
BACKSLASH = "Couldn't generate diff: backslash in filespec's filename: %s"



def usage(code, msg=''):
    print __doc__ % globals()
    if msg:
        print msg
    sys.exit(code)



def calculate_diff(entry, contextlines):
    file = entry.name
    oldrev = entry.revision
    newrev = entry.new_revision

    # Make sure we can find a CVS version number
    if oldrev is None and newrev is None:
        return NOVERSION % file

    if string.find(file, "'") <> -1:
        # Those crazy users put single-quotes in their file names!  Now we
        # have to escape everything that is meaningful inside double-quotes.
        filestr = string.replace(file, '\\', '\\\\')
        filestr = string.replace(filestr, '`', '\`')
        filestr = string.replace(filestr, '"', '\"')
        filestr = string.replace(filestr, '$', '\$')
        # and quote it with double-quotes.
        filestr = '"' + filestr + '"'
    else:
        # quote it with single-quotes.
        filestr = "'" + file + "'"
    if oldrev is None:
        # File is being added.
        try:
            if os.path.exists(file):
                fp = open(file)
            else:
                update_cmd = "cvs -fn update -r %s -p %s" % (newrev, filestr)
                fp = os.popen(update_cmd)
            lines = fp.readlines()
            fp.close()
            # Is this a binary file?  Let's look at the first few
            # lines to figure it out:
            for line in lines[:5]:
                for c in string.rstrip(line):
                    if c in string.whitespace:
                        continue
                    if c < ' ' or c > chr(127):
                        lines = BINARY_EXPLANATION_LINES[:]
                        break
            lines.insert(0, '--- NEW FILE: %s ---\n' % file)
        except IOError, e:
            lines = ['***** Error reading new file: ',
                     str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()]
    elif newrev is None:
        lines = ['--- %s DELETED ---\n' % file]
    else:
        # File has been changed.
        # This /has/ to happen in the background, otherwise we'll run into CVS
        # lock contention.  What a crock.
        if contextlines > 0:
            difftype = "-C " + str(contextlines)
        else:
            difftype = "-u"
        diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s %s" \
                  % (difftype, oldrev, newrev, filestr)
        fp = os.popen(diffcmd)
        lines = fp.readlines()
        # ignore the error code, it always seems to be 1 :(
        fp.close()
    if len(lines) > DIFF_TRUNCATE_IF_LARGER:
        removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES
        del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES]
        lines.insert(DIFF_HEAD_LINES,
                     '[...%d lines suppressed...]\n' % removedlines)
    return string.join(lines, '')



rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]')

def quotename(name):
    if name and rfc822_specials_re.search(name):
        return '"%s"' % string.replace(name, '"', '\\"')
    else:
        return name



def blast_mail(subject, people, entries, contextlines, fromhost, replyto):
    # cannot wait for child process or that will cause parent to retain cvs
    # lock for too long.  Urg!
    if not os.fork():
        # in the child
        # give up the lock you cvs thang!
        time.sleep(2)
        # Create the smtp connection to the localhost
        conn = smtplib.SMTP()
        conn.connect(MAILHOST, MAILPORT)
        user = pwd.getpwuid(os.getuid())[0]
        name = string.split(pwd.getpwuid(os.getuid())[4], ',')[0]
        domain = fromhost or getfqdn()
        address = '%s@%s' % (user, domain)
        s = StringIO()
        sys.stdout = s
        datestamp = time.strftime('%a, %d %b %Y %H:%M:%S +0000',
                                  time.gmtime(time.time()))
        try:
            vars = {'address' : address,
                    'name'    : quotename(name),
                    'people'  : string.join(people, COMMASPACE),
                    'subject' : subject,
                    'version' : __version__,
                    'date'    : datestamp,
                    }
            print '''\
From: %(name)s <%(address)s>
To: %(people)s''' % vars
            if replyto:
                print 'Reply-To: %s' % replyto
            print '''\
Subject: %(subject)s
Date: %(date)s
X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail>
''' % vars
            s.write(sys.stdin.read())
            # append the diffs if available
            print
            for entry in entries:
                print calculate_diff(entry, contextlines)
        finally:
            sys.stdout = sys.__stdout__
        resp = conn.sendmail(address, people, s.getvalue())
        conn.close()
        os._exit(0)



class CVSEntry:
    def __init__(self, name, revision, timestamp, conflict, options, tagdate):
        self.name = name
        self.revision = revision
        self.timestamp = timestamp
        self.conflict = conflict
        self.options = options
        self.tagdate = tagdate

def get_entry(prefix, mapping, line, filename):
    line = string.strip(line)
    parts = string.split(line, "/")
    _, name, revision, timestamp, options, tagdate = parts
    key = namekey(prefix, name)
    try:
        entry = mapping[key]
    except KeyError:
        if revision == "0":
            revision = None
        if string.find(timestamp, "+") != -1:
            timestamp, conflict = tuple(string.split(timestamp, "+"))
        else:
            conflict = None
        entry = CVSEntry(key, revision, timestamp, conflict,
                         options, tagdate)
        mapping[key] = entry
    return entry

def namekey(prefix, name):
    if prefix:
        return os.path.join(prefix, name)
    else:
        return name

def load_change_info(prefix=None):
    if prefix is not None:
        entries_fn = os.path.join(prefix, "CVS", "Entries")
    else:
        entries_fn = os.path.join("CVS", "Entries")
    entries_log_fn = entries_fn + ".Log"
    mapping = {}
    f = open(entries_fn)
    while 1:
        line = f.readline()
        if not line:
            break
##        if string.strip(line) == "D":
##            continue
        # we could recurse down subdirs, except the Entries.Log files
        # we need haven't been written to the subdirs yet, so it
        # doesn't do us any good
##        if line[0] == "D":
##            name = string.split(line, "/")[1]
##            dirname = namekey(prefix, name)
##            if os.path.isdir(dirname):
##                m = load_change_info(dirname)
##                mapping.update(m)
        if line[0] == "/":
            # normal file
            get_entry(prefix, mapping, line, entries_fn)
        # else: bogus Entries line
    f.close()
    if os.path.isfile(entries_log_fn):
        f = open(entries_log_fn)
        while 1:
            line = f.readline()
            if not line:
                break
            if line[1:2] != ' ':
                # really old version of CVS
                break
            entry = get_entry(prefix, mapping, line[2:], entries_log_fn)
            parts = string.split(line, "/")[1:]
            if line[0] == "A":
                # adding a file
                entry.new_revision = parts[1]
            elif line[0] == "R":
                # removing a file
                entry.new_revision = None
        f.close()
    for entry in mapping.values():
        if not hasattr(entry, "new_revision"):
            print 'confused about file', entry.name, '-- ignoring'
            del mapping[entry.name]
    return mapping

def load_branch_name():
    tag_fn = os.path.join("CVS", "Tag")
    if os.path.isfile(tag_fn):
        f = open(tag_fn)
        line = string.strip(f.readline())
        f.close()
        if line[:1] == "T":
            return line[1:]
    return None

# scan args for options
def main():
    # XXX Should really move all the options to an object, just to
    # avoid threading so many positional args through everything.
    try:
        opts, args = getopt.getopt(
            sys.argv[1:], 'hC:cuS:R:qf:m:',
            ['fromhost=', 'context=', 'cvsroot=', 'mailhost=',
             'subject-prefix=', 'reply-to=',
             'help', 'quiet'])
    except getopt.error, msg:
        usage(1, msg)

    # parse the options
    contextlines = 2
    verbose = 1
    subject_prefix = ""
    replyto = None
    fromhost = None
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage(0)
        elif opt == '--cvsroot':
            os.environ['CVSROOT'] = arg
        elif opt in ('-C', '--context'):
            contextlines = int(arg)
        elif opt == '-c':
            if contextlines <= 0:
                contextlines = 2
        elif opt == '-u':
            contextlines = 0
        elif opt in ('-S', '--subject-prefix'):
            subject_prefix = arg
        elif opt in ('-R', '--reply-to'):
            replyto = arg
        elif opt in ('-q', '--quiet'):
            verbose = 0
        elif opt in ('-f', '--fromhost'):
            fromhost = arg
        elif opt in ('-m', '--mailhost'):
            global MAILHOST
            MAILHOST = arg

    # What follows is the specification containing the files that were
    # modified.  The argument actually must be split, with the first component
    # containing the directory the checkin is being made in, relative to
    # $CVSROOT, followed by the list of files that are changing.
    if not args:
        usage(1, 'No CVS module specified')
    changes = load_change_info()
    branch = load_branch_name()
    subject = subject_prefix + args[0]
    specs = string.split(args[0])
    del args[0]

    # The remaining args should be the email addresses
    if not args:
        usage(1, 'No recipients specified')

    # Now do the mail command
    people = args

    if specs[-3:] == ['-', 'Imported', 'sources']:
        print 'Not sending email for imported sources.'
        return

    if verbose:
##        print 'Python version', sys.version
##        os.system("type python1.6; type python2;"
##                  " type python2.0; type python2.1; type python2.2;"
##                  " type rcsdiff; type rlog")
        print 'Mailing %s...' % string.join(people, COMMASPACE)
        print 'Generating notification message...'
    blast_mail(subject, people, changes.values(),
               contextlines, fromhost, replyto)
    if verbose:
        print 'Generating notification message... done.'



if __name__ == '__main__':
    main()
    sys.exit(0)

Added .old_mttroot_cvsroot/taginfo version [364dad5373].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4->  file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Added .old_mttroot_cvsroot/verifymsg version [cbc796537d].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# The "verifymsg" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Deleted CVSROOT/checkoutlist version [db1d2d9b69].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
#	[<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'
syncmail

Deleted CVSROOT/commitinfo version [85654ac9a8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list 
# of files to check.  A non-zero exit of the filter program will 
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Deleted CVSROOT/config version [28e7a42550].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no

# Set `PreservePermissions' to `yes' to save file status information
# in the repository.
#PreservePermissions=no

# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no

Deleted CVSROOT/cvswrappers version [9d41597c29].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
#  wildcard	[option value][option value]...
#
#  where option is one of
#  -f		from cvs filter		value: path to filter
#  -t		to cvs filter		value: path to filter
#  -m		update methodology	value: MERGE or COPY
#  -k		expansion mode		value: b, o, kkv, &c
#
#  and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'

Deleted CVSROOT/editinfo version [dfa5fb459c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "editinfo" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Deleted CVSROOT/loginfo version [7508d75767].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "loginfo" file controls where "cvs commit" log information
# is sent.  The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT.  If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter.  The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators.  The format
# characters are:
#
#   s = file name
#   V = old version number (pre-checkin)
#   v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog

# Lines to mail changes
CVSROOT $CVSROOT/CVSROOT/syncmail %{sVv} gawthrop@users.sourceforge.net
DEFAULT $CVSROOT/CVSROOT/syncmail %{sVv} mtt-checkins@lists.sourceforge.net

Deleted CVSROOT/modules version [84b74e5335].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Three different line formats are valid:
#	key	-a    aliases...
#	key [options] directory
#	key [options] directory files...
#
# Where "options" are composed of:
#	-i prog		Run "prog" on "cvs commit" from top-level of module.
#	-o prog		Run "prog" on "cvs checkout" of module.
#	-e prog		Run "prog" on "cvs export" of module.
#	-t prog		Run "prog" on "cvs rtag" of module.
#	-u prog		Run "prog" on "cvs update" of module.
#	-d dir		Place module in directory "dir" instead of module name.
#	-l		Top-level directory only -- do not recurse.
#
# NOTE:  If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias.  An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module.  This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.

Deleted CVSROOT/notify version [2a5259e3c5].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent.  The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT.  If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"

Deleted CVSROOT/rcsinfo version [c276b88ba1].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT.  For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Deleted CVSROOT/syncmail version [2c972f2c68].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459











































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/python

# Copyright (c) 2002, 2003, Barry Warsaw, Fred Drake, and contributors
# All rights reserved.
# See the accompanying LICENSE file for details.

# Compatibility: Python 2.2.3, tied to the version of Python on SourceForge's
# authenticated CVS server.

"""Complicated notification for CVS checkins.

This script is used to provide email notifications of changes to the CVS
repository.  These email changes will include context diffs of the changes.
Really big diffs will be trimmed.

This script is run from a CVS loginfo file (see $CVSROOT/CVSROOT/loginfo).  To
set this up, create a loginfo entry that looks something like this:

    mymodule /path/to/this/script %%s some-email-addr@your.domain

In this example, whenever a checkin that matches `mymodule' is made, this
script is invoked, which will generate the diff containing email, and send it
to some-email-addr@your.domain.

    Note: This module used to also do repository synchronizations via
    rsync-over-ssh, but since the repository has been moved to SourceForge,
    this is no longer necessary.  The syncing functionality has been ripped
    out in the 3.0, which simplifies it considerably.  Access the 2.x versions
    to refer to this functionality.  Because of this, the script is misnamed.

It no longer makes sense to run this script from the command line.  Doing so
will only print out this usage information.

Usage:

    %(PROGRAM)s [options] <%%S> email-addr [email-addr ...]

Where options are:

    --cvsroot=<path>
        Use <path> as the environment variable CVSROOT.  Otherwise this
        variable must exist in the environment.

    --context=#
    -C #
        Include # lines of context around lines that differ (default: 2).

    -c
        Produce a context diff (default).

    -m hostname
    --mailhost hostname
        The hostname of an available SMTP server.  The default is
        'localhost'.

    -u
        Produce a unified diff (smaller).

    -S TEXT
    --subject-prefix=TEXT
        Prepend TEXT to the email subject line.

    -R ADDR
    --reply-to=ADDR
      Add a "Reply-To: ADDR" header to the email message.

    --quiet / -q
        Don't print as much status to stdout.

    --fromhost=hostname
    -f hostname
        The hostname that email messages appear to be coming from.  The From:
        header of the outgoing message will look like user@hostname.  By
        default, hostname is the machine's fully qualified domain name.

    --help / -h
        Print this text.

The rest of the command line arguments are:

    <%%S>
        CVS %%s loginfo expansion.  When invoked by CVS, this will be a single
        string containing the directory the checkin is being made in, relative
        to $CVSROOT, followed by the list of files that are changing.  If the
        %%s in the loginfo file is %%{sVv}, context diffs for each of the
        modified files are included in any email messages that are generated.

    email-addrs
        At least one email address.
"""
__version__ = '1.2'

import os
import sys
import re
import time
import string
import getopt
import smtplib
import pwd
import socket

try:
    from socket import getfqdn
except ImportError:
    def getfqdn():
        # Python 1.5.2 :(
        hostname = socket.gethostname()
        byaddr = socket.gethostbyaddr(socket.gethostbyname(hostname))
        aliases = byaddr[1]
        aliases.insert(0, byaddr[0])
        aliases.insert(0, hostname)
        for fqdn in aliases:
            if '.' in fqdn:
                break
        else:
            fqdn = 'localhost.localdomain'
        return fqdn


from cStringIO import StringIO

# Which SMTP server to do we connect to?
MAILHOST = 'localhost'
MAILPORT = 25

# Diff trimming stuff
DIFF_HEAD_LINES = 20
DIFF_TAIL_LINES = 20
DIFF_TRUNCATE_IF_LARGER = 1000

COMMASPACE = ', '

PROGRAM = sys.argv[0]

BINARY_EXPLANATION_LINES = [
    "(This appears to be a binary file; contents omitted.)\n"
    ]

NOVERSION = "Couldn't generate diff; no version number found for file: %s"
BACKSLASH = "Couldn't generate diff: backslash in filespec's filename: %s"



def usage(code, msg=''):
    print __doc__ % globals()
    if msg:
        print msg
    sys.exit(code)



def calculate_diff(entry, contextlines):
    file = entry.name
    oldrev = entry.revision
    newrev = entry.new_revision

    # Make sure we can find a CVS version number
    if oldrev is None and newrev is None:
        return NOVERSION % file

    if string.find(file, "'") <> -1:
        # Those crazy users put single-quotes in their file names!  Now we
        # have to escape everything that is meaningful inside double-quotes.
        filestr = string.replace(file, '\\', '\\\\')
        filestr = string.replace(filestr, '`', '\`')
        filestr = string.replace(filestr, '"', '\"')
        filestr = string.replace(filestr, '$', '\$')
        # and quote it with double-quotes.
        filestr = '"' + filestr + '"'
    else:
        # quote it with single-quotes.
        filestr = "'" + file + "'"
    if oldrev is None:
        # File is being added.
        try:
            if os.path.exists(file):
                fp = open(file)
            else:
                update_cmd = "cvs -fn update -r %s -p %s" % (newrev, filestr)
                fp = os.popen(update_cmd)
            lines = fp.readlines()
            fp.close()
            # Is this a binary file?  Let's look at the first few
            # lines to figure it out:
            for line in lines[:5]:
                for c in string.rstrip(line):
                    if c in string.whitespace:
                        continue
                    if c < ' ' or c > chr(127):
                        lines = BINARY_EXPLANATION_LINES[:]
                        break
            lines.insert(0, '--- NEW FILE: %s ---\n' % file)
        except IOError, e:
            lines = ['***** Error reading new file: ',
                     str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()]
    elif newrev is None:
        lines = ['--- %s DELETED ---\n' % file]
    else:
        # File has been changed.
        # This /has/ to happen in the background, otherwise we'll run into CVS
        # lock contention.  What a crock.
        if contextlines > 0:
            difftype = "-C " + str(contextlines)
        else:
            difftype = "-u"
        diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s %s" \
                  % (difftype, oldrev, newrev, filestr)
        fp = os.popen(diffcmd)
        lines = fp.readlines()
        # ignore the error code, it always seems to be 1 :(
        fp.close()
    if len(lines) > DIFF_TRUNCATE_IF_LARGER:
        removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES
        del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES]
        lines.insert(DIFF_HEAD_LINES,
                     '[...%d lines suppressed...]\n' % removedlines)
    return string.join(lines, '')



rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]')

def quotename(name):
    if name and rfc822_specials_re.search(name):
        return '"%s"' % string.replace(name, '"', '\\"')
    else:
        return name



def blast_mail(subject, people, entries, contextlines, fromhost, replyto):
    # cannot wait for child process or that will cause parent to retain cvs
    # lock for too long.  Urg!
    if not os.fork():
        # in the child
        # give up the lock you cvs thang!
        time.sleep(2)
        # Create the smtp connection to the localhost
        conn = smtplib.SMTP()
        conn.connect(MAILHOST, MAILPORT)
        user = pwd.getpwuid(os.getuid())[0]
        name = string.split(pwd.getpwuid(os.getuid())[4], ',')[0]
        domain = fromhost or getfqdn()
        address = '%s@%s' % (user, domain)
        s = StringIO()
        sys.stdout = s
        datestamp = time.strftime('%a, %d %b %Y %H:%M:%S +0000',
                                  time.gmtime(time.time()))
        try:
            vars = {'address' : address,
                    'name'    : quotename(name),
                    'people'  : string.join(people, COMMASPACE),
                    'subject' : subject,
                    'version' : __version__,
                    'date'    : datestamp,
                    }
            print '''\
From: %(name)s <%(address)s>
To: %(people)s''' % vars
            if replyto:
                print 'Reply-To: %s' % replyto
            print '''\
Subject: %(subject)s
Date: %(date)s
X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail>
''' % vars
            s.write(sys.stdin.read())
            # append the diffs if available
            print
            for entry in entries:
                print calculate_diff(entry, contextlines)
        finally:
            sys.stdout = sys.__stdout__
        resp = conn.sendmail(address, people, s.getvalue())
        conn.close()
        os._exit(0)



class CVSEntry:
    def __init__(self, name, revision, timestamp, conflict, options, tagdate):
        self.name = name
        self.revision = revision
        self.timestamp = timestamp
        self.conflict = conflict
        self.options = options
        self.tagdate = tagdate

def get_entry(prefix, mapping, line, filename):
    line = string.strip(line)
    parts = string.split(line, "/")
    _, name, revision, timestamp, options, tagdate = parts
    key = namekey(prefix, name)
    try:
        entry = mapping[key]
    except KeyError:
        if revision == "0":
            revision = None
        if string.find(timestamp, "+") != -1:
            timestamp, conflict = tuple(string.split(timestamp, "+"))
        else:
            conflict = None
        entry = CVSEntry(key, revision, timestamp, conflict,
                         options, tagdate)
        mapping[key] = entry
    return entry

def namekey(prefix, name):
    if prefix:
        return os.path.join(prefix, name)
    else:
        return name

def load_change_info(prefix=None):
    if prefix is not None:
        entries_fn = os.path.join(prefix, "CVS", "Entries")
    else:
        entries_fn = os.path.join("CVS", "Entries")
    entries_log_fn = entries_fn + ".Log"
    mapping = {}
    f = open(entries_fn)
    while 1:
        line = f.readline()
        if not line:
            break
##        if string.strip(line) == "D":
##            continue
        # we could recurse down subdirs, except the Entries.Log files
        # we need haven't been written to the subdirs yet, so it
        # doesn't do us any good
##        if line[0] == "D":
##            name = string.split(line, "/")[1]
##            dirname = namekey(prefix, name)
##            if os.path.isdir(dirname):
##                m = load_change_info(dirname)
##                mapping.update(m)
        if line[0] == "/":
            # normal file
            get_entry(prefix, mapping, line, entries_fn)
        # else: bogus Entries line
    f.close()
    if os.path.isfile(entries_log_fn):
        f = open(entries_log_fn)
        while 1:
            line = f.readline()
            if not line:
                break
            if line[1:2] != ' ':
                # really old version of CVS
                break
            entry = get_entry(prefix, mapping, line[2:], entries_log_fn)
            parts = string.split(line, "/")[1:]
            if line[0] == "A":
                # adding a file
                entry.new_revision = parts[1]
            elif line[0] == "R":
                # removing a file
                entry.new_revision = None
        f.close()
    for entry in mapping.values():
        if not hasattr(entry, "new_revision"):
            print 'confused about file', entry.name, '-- ignoring'
            del mapping[entry.name]
    return mapping

def load_branch_name():
    tag_fn = os.path.join("CVS", "Tag")
    if os.path.isfile(tag_fn):
        f = open(tag_fn)
        line = string.strip(f.readline())
        f.close()
        if line[:1] == "T":
            return line[1:]
    return None

# scan args for options
def main():
    # XXX Should really move all the options to an object, just to
    # avoid threading so many positional args through everything.
    try:
        opts, args = getopt.getopt(
            sys.argv[1:], 'hC:cuS:R:qf:m:',
            ['fromhost=', 'context=', 'cvsroot=', 'mailhost=',
             'subject-prefix=', 'reply-to=',
             'help', 'quiet'])
    except getopt.error, msg:
        usage(1, msg)

    # parse the options
    contextlines = 2
    verbose = 1
    subject_prefix = ""
    replyto = None
    fromhost = None
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage(0)
        elif opt == '--cvsroot':
            os.environ['CVSROOT'] = arg
        elif opt in ('-C', '--context'):
            contextlines = int(arg)
        elif opt == '-c':
            if contextlines <= 0:
                contextlines = 2
        elif opt == '-u':
            contextlines = 0
        elif opt in ('-S', '--subject-prefix'):
            subject_prefix = arg
        elif opt in ('-R', '--reply-to'):
            replyto = arg
        elif opt in ('-q', '--quiet'):
            verbose = 0
        elif opt in ('-f', '--fromhost'):
            fromhost = arg
        elif opt in ('-m', '--mailhost'):
            global MAILHOST
            MAILHOST = arg

    # What follows is the specification containing the files that were
    # modified.  The argument actually must be split, with the first component
    # containing the directory the checkin is being made in, relative to
    # $CVSROOT, followed by the list of files that are changing.
    if not args:
        usage(1, 'No CVS module specified')
    changes = load_change_info()
    branch = load_branch_name()
    subject = subject_prefix + args[0]
    specs = string.split(args[0])
    del args[0]

    # The remaining args should be the email addresses
    if not args:
        usage(1, 'No recipients specified')

    # Now do the mail command
    people = args

    if specs[-3:] == ['-', 'Imported', 'sources']:
        print 'Not sending email for imported sources.'
        return

    if verbose:
##        print 'Python version', sys.version
##        os.system("type python1.6; type python2;"
##                  " type python2.0; type python2.1; type python2.2;"
##                  " type rcsdiff; type rlog")
        print 'Mailing %s...' % string.join(people, COMMASPACE)
        print 'Generating notification message...'
    blast_mail(subject, people, changes.values(),
               contextlines, fromhost, replyto)
    if verbose:
        print 'Generating notification message... done.'



if __name__ == '__main__':
    main()
    sys.exit(0)

Deleted CVSROOT/taginfo version [364dad5373].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4->  file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Deleted CVSROOT/verifymsg version [cbc796537d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "verifymsg" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Added gino/AUTHORS version [8194ff1aef].


1
+
Peter J. Gawthrop (peter@gawthrop.net)

Added gino/COPYING version [b34d81c876].




















































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
                    GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                          675 Mass Ave, Cambridge, MA 02139, USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 19yy  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) 19yy name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

Added gino/INSTALL version [45c34bc6d3].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
=======================================================================
Prerequisites

Octave and ginsh must be installed before installing gino


=======================================================================
Simple system installation

$ tar xzf gino-<ver>.tar.gz
$ cd gino-<ver>
$ make clean
$ make 

As superuser
# make install

Added gino/Makefile version [9715ccae4b].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Makefile for gino library

all: g_funs

g_funs:
	./create_gino.sh

clean:
	rm -rf g_funs

install: g_funs
	cp -rf ../gino /usr/share/octave/site/m



Added gino/README version [8fb7e2da1f].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Gino is a symbolic toolbox for octave (www.octave.org) using ginsh -
the shell interface to ginac (www.ginac.de).

ginsh.m provides a low-level octave interface to ginsh. All of the
ginsh functions are implemented by octave functions of the form
g_fun(arglist).

All in and out arguments of the toolbox functions are octave strings
containing valid ginsh expressions. Where appropriate, these can be
turned into matlab scalars, matrices and lists using octave's eval
function. Spurious output is avoided by setting
default_eval_print_flag=0.

This provides a clear division between symbolic expressions (always
contained in strings) and octave expressions. It also allows the
powerful octave string machinery to be used to manipulate symbolic
expressions.

gino_examples.m contains some introductory examples.

P.J.Gawthrop. 19th December 2002.


Added gino/create_gino.sh version [df77946783].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
## Creates gino functions by querying ginsh
# Copyright (C) 2002 by Peter J. Gawthrop

prefix="g_"			# Prefix function names by this
subdir=${prefix}funs		# Where the generated functions live
ginsh="/usr/bin/ginsh"		# Location of ginsh

create_fun() {
    funname=${prefix}$1
    filename=${funname}.m

    ## Creates an octave function
    echo Creating ${subdir}/${filename}

    ## Find usage string

    usage=`echo "?$1" | ginsh | head -1`

    ## The octave function
    cat<<EOF > ${subdir}/${filename}
function res = ${funname} (arg1,arg2,arg3)

  ## usage:  res = ${prefix}${usage}

  ## Generated by create_gino.sh on `date`
  ## DO NOT EDIT ME

  if nargin<1
    arg1 = "";
  endif

  if nargin<2
    arg2 = "";
  endif

  if nargin<3
    arg3 = "";
  endif

  res = gino("$1", arg1, arg2, arg3);

endfunction
EOF
}

create_readme() {
    cat > ${subdir}/README <<EOF
These files were generated automatically by create_gino.sh
on `date`.

DO NOT EDIT THEM
EOF
}

## Find available ops
ops=`echo "??" | ginsh | gawk '{if(i++==1) {gsub(",",""); print $0}}'`

## Does ginsh exist?
if [ -x "${ginsh}" ]; then
    echo $ginsh exists - ok
else
    echo $ginsh does not exist, exiting
    exit
fi

## Create the corresponding octave funs.
mkdir -p ${subdir}
create_readme;
for op in ${ops}; do
    create_fun ${op}
done

Added gino/g2o_pol.m version [7d7c3065b2].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function o_pol = g2o_pol (g_pol, object)

  ## usage:  o_pol = g2o_pol (g_pol)
  ##
  ## Converts a ginsh polynomial to an octave polynomial
  ## Both o_pol and g_pol are strings
  ## o_pol can be an argument to eval

  if nargin<1
    error("usage:  o_pol = g2o_pol (g_pol)");
  endif
  
  if nargin<2
    object="s";
  endif
  
  g_pol = g_expand(g_pol);
  n = g_degree(g_pol, object);
  n = eval([n,";"]);
  o_pol = "";
  for i=n:-1:0
    pol_i = g_coeff(g_pol,object,int2str(i));
    o_pol = sprintf("%s %s", o_pol, pol_i);
  endfor
  o_pol = sprintf("[%s ];", o_pol);

endfunction

Added gino/gino.m version [7b8fb38fbb].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function res = gino (op,arg1,arg2,arg3)

  ## Gino is the octave interface to ginsh - the GiNaC shell interface.
  ## The simplest way to use gino is via the octave functions  go_fun.
  ## where "fun" is a ginsh function - type gino("??") for a list.
  ## usage:  res = gino (op,arg1,arg2,arg3)
  ## 
  ## Please set default_eval_print_flag = 0
  ##
  ## Part of the gino (ginsh-octave) toolbox
  ## Copyright (C) 2002 by Peter J. Gawthrop

  if nargin<1
    error("usage: gino(op,[arg1,arg2,arg3])p");
  elseif (nargin==1)||(length(arg1)==0)
    go_in = sprintf("%s", op);
  elseif (nargin==2)||(length(arg2)==0)
    go_in = sprintf("%s(%s)", op, arg1);
  elseif (nargin==3)||(length(arg3)==0)
    go_in = sprintf("%s(%s,%s)", op, arg1, arg2);
  elseif (nargin==4)
    go_in = sprintf("%s(%s,%s,%s)", op, arg1, arg2, arg3);
  else
    error("usage: gino(op,[arg1,arg2,arg3]");
  endif

  res = ginsh(go_in);

endfunction

Added gino/gino_examples.m version [faa058f3c8].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Simple example of creating an octave polynomial symbolically
P = g2o_pol("s^2*(s+a)*(s+b)^3") # Create symbolic polynomial in octave form
a = 1; b = 2;			# Give a and b numerical values
p = eval(P)			# Create numerical polynomial
roots(p)			# Use p in any appropriate octave
				# function

## More complicated example of symbolic linearisation

## ODE dx/dt = f(x,u); y = g(x,u)
f_1 = "x_2 - beta*tanh(u_1)";
f_2 = "-x_1 + x_2^2 + u_1";
g_1   = "x_1";
f = go_list(f_1,f_2)
g = go_list(g_1)

## Linearise via symbolic differentiation
[A,B,C,D] = go_lin(f,g)

## Find the transfer function

I = "[[1,0],[0,1]]";		# Unit matrix
## Create G as a string: C(sI-A)^-1B + D
G_str = sprintf("%s*((s*%s-%s)^(-1))*%s + %s", C,I,A,B,D)

## Find G itself
G = g_evalm(G_str);		

## Substitute steady-state values
G = g_subs(G, "{u_1,x_1,x_2}", "{0,0,0}")

## Extract the (only) matrix element
G = g_op(G,"0")

## Find numerator and denominator
a = g2o_pol(g_denom(G))
b = g2o_pol(g_numer(G))

## Evaluate numerically
beta = 0.5;
b = eval(b)
a = eval(a)

Added gino/ginsh.m version [4824a91cb3].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function go_out = ginsh (go_in)

  ## usage:  go_out = ginsh (go_in)
  ##         go_out, go_in strings containing valid ginsh code
  ## Interface to ginsh to provide symbolic manipulation within octave
  ## Part of the gino (ginsh-octave) toolbox

  ## Copyright (C) 2002 by Peter J. Gawthrop

  ##   This program is free software; you can redistribute it and/or modify
  ##    it under the terms of the GNU General Public License as published by
  ##    the Free Software Foundation; either version 2 of the License, or
  ##    (at your option) any later version.
  
  ##    This program is distributed in the hope that it will be useful,
  ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
  ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ##    GNU General Public License for more details.
  
  ##    You should have received a copy of the GNU General Public License
  ##    along with this program; if not, write to the Free Software
  ##    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
  command = sprintf("echo '%s;' | ginsh ", go_in); # sh command
  go_out = system(command);	# execute it
  
  if (length(go_out)>0)		# Strip trailing NL
    go_out = substr(go_out,1,length(go_out)-1);
  endif
endfunction

Added gino/go_append.m version [7b74ee52c4].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function new_list = go_append (list,element)

  ## usage:  new_list = go_append (list,element)
  ##
  ## Appends element to list to give new list
  ## This is missing from ginsh
  ## Copyright (C) 2002 by Peter J. Gawthrop

  new_list = deblank(list);	# Remove trailing blanks
  new_list = new_list(1:length(new_list)-1); # Zap final }
  if (g_nops(list)=="0")
    new_list = sprintf("%s%s}", new_list, element);
  else
    new_list = sprintf("%s,%s}", new_list, element);
  endif
  

endfunction

Added gino/go_diff.m version [5fae555e6a].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [dfdx_l, dfdx_m] = go_diff (f,x)

  ## usage:  [dfdx_l dfdx_m] = go_diff (f,x)
  ##
  ## dfdx_l is a list with ith element df/dx
  ## dfdx_m the corresponing matrix (in ginsh form)
  ## f may itself be a list
  ## The elements of x must be symbols

  N = eval(g_nops(f));
  M = eval(g_nops(x));

  dfdx = "{}";

  ## Find derivatives of f for each x_i and append to list
  for j = 1:M
    dfdx = go_append(dfdx, g_diff(f,g_op(x,int2str(j-1))));
  endfor

  ## Convert to matrix and transpose
  dfdx_m = g_transpose(go_lst_to_matrix(dfdx));

  ## And back to a list
  dfdx_l = go_matrix_to_lst(dfdx_m);

endfunction

Added gino/go_gmatrix2mmatrix.m version [1074e04ce6].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
function M_m = go_gmatrix2mmatrix (M-g)

  ## usage:  M_m = go_gmatrix2mmatrix (M-g)
  ##
  ## Converts a ginsh format matrix to a matlab format matrix

  M_m = strrep(M_g,"],[","];[");

endfunction

Added gino/go_lin.m version [eb13e9d447].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D] = go_lin (f,g)

  ## usage:  [A,B,C,D] = go_lin (f,g)
  ##
  ## 

  n_x = eval(g_nops(f));		# Number of states
  n_y = eval(g_nops(g));		# Number of outputs

  n_u = n_y;

  ## Create symbolic state list
  x = "{}";
  for i=1:n_x
    x = go_append(x,sprintf("x_%i", i));
  endfor


  ## Create symbolic input list
  u = "{}";
  for i=1:n_u
    u = go_append(u,sprintf("u_%i", i));
  endfor
		  
  [A_l,A] = go_diff(f,x);
  [B_l,B] = go_diff(f,u);
  [C_l,C] = go_diff(g,x);
  [D_l,D] = go_diff(g,u);

endfunction

Added gino/go_list.m version [e679433787].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function list = go_list (exp0,exp1,exp2,exp3,exp4,exp5,exp6,exp7,exp8,exp9)

  ## usage:  list = go_list
  ## (exp0[,exp1,exp2,exp3,exp4,exp5,exp6,exp7,exp8,exp9])
  ## Creates a list containing the expressions in the argument list
  ## 

  ## Copyright (C) 2002 by Peter J. Gawthrop
  if nargin>10
    error("Only 10  expressions allowed in argument list");
  endif

  N = nargin;

  list=exp0;
  for i=1:N-1
    exp = eval(sprintf("exp%i;",i));
    list=sprintf("%s, %s", list, exp);
  endfor

  list = sprintf("{%s}", list);

endfunction

Added gino/go_lst_to_matrix.m version [8142b99b12].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function M = go_lst_to_matrix (L)

  ## usage:  M = go_lst_to_matrix (L)
  ##
  ## Converts a list to a matrix
  ## Assumes list contains equal-length lists as elements
  ## Not in ginsh
  ## Copyright (C) 2002 by Peter J. Gawthrop

  n = eval(g_nops(L));
  m = eval(g_nops(g_op(L,"0")));

  M = "";
  for i = 1:n
    M = sprintf("%s[",M);
    m_i = g_op(L,int2str(i-1));
    if (eval(g_nops(m_i))!=m)
      error("All list elements must be lists of same length");
    endif
    
    for j = 1:m
      m_ij = g_op(m_i,int2str(j-1));
      if j>1 
	jsep = ", ";
      else
	jsep = "";
      endif
      M = sprintf("%s%s%s", M, jsep, m_ij);
    endfor
    if i<n 
      isep=", ";
    else
      isep="";
    endif
    
    M = sprintf("%s]%s", M, isep);
  endfor

  M = sprintf("[%s]",M);
  
endfunction

Added gino/go_matrix_to_lst.m version [a29229a6df].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
function L = go_matrix_to_lst (M)

  ## usage:  L = go_matrix_to_lst (M)
  ##
  ## Converts matrix to list (in ginsh format)

  L = strrep(strrep(M,"[","{"), "]","}");

endfunction

Added mtt/Makefile version [92a793815c].




















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/make -f

# Destinations compliant with Filesystem Hierarchy Standard (FHS) 2.1
# DESTDIR prefix required by Debian build process
CONFDIR=$(DESTDIR)/etc
PROGDIR=$(DESTDIR)/usr/bin
INSTDIR=$(DESTDIR)/usr/share/mtt

# DOCPATH and INFOPATH required by doc/Makefile
DOCDIR=$(DESTDIR)/usr/share/doc/mtt
INFODIR=$(DESTDIR)/usr/share/info

# XFIG Libraries directory
XFIGDIR=$(DESTDIR)/usr/share/xfig/Libraries

configure: configure-stamp
configure-stamp:
	@touch configure-stamp

build: configure mtt.sh xmtt.sh build-stamp

build-cc:
	@cd cc ; make -s build

build-doc:
	@cd doc ; make -s all

build-stamp:
	@touch build-stamp

clean:
	@touch clean.sh
	@-chmod a+x clean.sh
	@./clean.sh
	@rm -f clean.sh

clean-cc:
	@touch clean-cc.sh
	@-chmod a+x clean-cc.sh
	@./clean-cc.sh
	@rm -f clean-cc.sh

clean-conf:
	@touch clean-conf.sh
	@-chmod a+x clean-conf.sh
	@./clean-conf.sh
	@rm -f clean-conf.sh

clean-doc:
	@touch clean-doc.sh
	@-chmod a+x clean-doc.sh
	@./clean-doc.sh
	@rm -f clean-doc.sh
	@cd doc ; make -s clean

clean-xfig:
	@touch clean-xfig.sh
	@-chmod a+x clean-xfig.sh
	@./clean-xfig.sh
	@rm -f clean-xfig.sh

distclean: clean clean-cc clean-conf clean-doc clean-xfig
	@-rm -f build-stamp configure-stamp config.log mtt.sh xmtt.sh

install: build clean.sh clean-conf.sh
	@install -d $(INSTDIR) $(CONFDIR) $(PROGDIR)
	@cp -a   bin cc doc lib $(INSTDIR)
	@cat bin/mttrc | grep -v 'MTT_LIB/xfig' |\
	sed 's|$$1|/usr/share/mtt|' > $(CONFDIR)/mtt.conf
	@install mtt.sh  $(PROGDIR)/mtt
	@install xmtt.sh $(PROGDIR)/xmtt

install-cc: build-cc clean-cc.sh
	@install -d $(INSTDIR)/bin/trans
	@install cc/parse_m2cc.exe $(INSTDIR)/bin/trans

install-doc: build-doc clean-doc.sh
	@install -d $(DOCDIR) $(INFODIR)
	@cd doc ; DOCPATH=$(DOCDIR) INFOPATH=$(INFODIR) make -s install-doc
	@cd doc ; install Makefile mtt.info* mtt.pdf mtt.ps.gz $(DOCDIR)
	@install doc/mtt.info* $(INFODIR)

install-xfig: clean-xfig.sh
	@install -d $(XFIGDIR)
	@cp -a   lib/xfig $(XFIGDIR)/MTT_Bond_Graph

.PHONY: FORCE

clean.sh: FORCE
	@echo '#! /bin/sh'						>>clean.sh
	@echo '# This file is auto-generated - do not edit'		>>clean.sh
	@echo 'rm -f  $(PROGDIR)/mtt $(PROGDIR)/xmtt'			>>clean.sh
	@echo 'rm -fr $(INSTDIR)'					>>clean.sh

clean-cc.sh: FORCE
	@echo '#! /bin/sh'						>>clean-cc.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-cc.sh
	@echo 'rm -f  $(INSTDIR)/bin/trans/parse_m2cc.exe'		>>clean-cc.sh

clean-conf.sh: FORCE
	@echo '#! /bin/sh'						>>clean-conf.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-conf.sh
	@echo 'rm -f  $(CONFDIR)/mtt.conf'				>>clean-conf.sh

clean-doc.sh: FORCE
	@echo '#! /bin/sh'						>>clean-doc.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-doc.sh
	@echo 'rm -fr $(DOCDIR)'					>>clean-doc.sh
	@echo 'rm -f  $(INFODIR)/mtt.info*'				>>clean-doc.sh

clean-xfig.sh: FORCE
	@echo '#! /bin/sh'						>>clean-xfig.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-xfig.sh
	@echo 'rm -f  $(XFIGDIR)/MTT_Bond_Graph'			>>clean-xfig.sh

mtt.sh.tmp:
	@echo '#! /bin/sh'						> mtt.sh.tmp
	@echo '# This file is auto-generated - do not edit'		>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo 'mtt_config_file=$(CONFDIR)/mtt.conf'			>>mtt.sh.tmp
	@echo 'mtt_program_dir=$(PROGDIR)'				>>mtt.sh.tmp
	@echo 'mtt_install_dir=$(INSTDIR)'				>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo '# get site-specific settings'				>>mtt.sh.tmp
	@echo 'if [ -r $${mtt_config_file} ]; then'			>>mtt.sh.tmp
	@echo '   . $${mtt_config_file} $${mtt_install_dir} >/dev/null'	>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo 'elif [ -r $${mtt_install_dir}/bin/mttrc ]; then'		>>mtt.sh.tmp
	@echo '   . $${mtt_install_dir}/bin/mttrc $${mtt_install_dir}'	>>mtt.sh.tmp
	@echo 'fi'							>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo '# get user-specific settings'				>>mtt.sh.tmp
	@echo 'if [ -r $${HOME}/.mttrc ]; then'				>>mtt.sh.tmp
	@echo '   . $${HOME}/.mttrc'					>>mtt.sh.tmp
	@echo 'fi'							>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo '# get directory-specific settings'			>>mtt.sh.tmp
	@echo 'if [ -r ./.mttrc ]; then'				>>mtt.sh.tmp
	@echo '   . ./.mttrc'						>>mtt.sh.tmp
	@echo 'fi'							>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp

mtt.sh: mtt.sh.tmp
	@cat mtt.sh.tmp bin/mtt						> mtt.sh

xmtt.sh: mtt.sh.tmp
	@cat mtt.sh.tmp bin/xmtt					> xmtt.sh

Added mtt/bin/capitalise_initial version [b5ca98d45c].







1
2
3
4
5
6
+
+
+
+
+
+
#! /bin/sh

phrase="$*"
initial=$(echo $phrase | sed 's/\(.\).*/\1/')
Initial=$(echo $initial | tr [a-z] [A-Z])
echo $phrase | sed s/$initial/$Initial/

Added mtt/bin/check_integration version [a5d2ce5a34].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Check if obsolete method of specifiying integration method in use.
if [ -f "$1_simpar.txt" ]; then
  method_line=`grep -i METHOD  $1_simpar.txt`
  if [ -n "`echo $method_line | grep -i euler`" ]; then
     echo "$1_simpar.txt contains Euler method - please use mtt -i euler in future"
     mtt_switches="$mtt_switches -i euler";
  elif [ -n "`echo $method_line | grep -i implicit`" ]; then
     echo "$1_simpar.txt contains Implicit method - please use mtt -i implicit in future"
     mtt_switches="$mtt_switches -i implicit";
  fi
fi

echo Invoking mtt $mtt_switches $1 $2 $3 $4

mtt $mtt_switches $1 $2 $3 $4

Added mtt/bin/mtt version [d8412334b4].
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt
# This is the main shell script for MTT

# P.J.Gawthrop Oct 1989, Dec 1989, 1990, 1991, Oct 1993, Dec 1993, Jan 1994, Dec 95, Nov 1996.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997,1998,1999
# Copyright (C) 2000 by Peter J. Gawthrop
# Copyright (C) 2001 by Peter J. Gawthrop


###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.419  2014/04/18 02:02:08  gawthrop
## Added sum.tex representation -- this was in a very old MTT and
## summerises the structure.
##
## Revision 1.418  2013/07/19 05:40:26  gawthrop
## Added -nas (No alphabetic sort) switch in help options
##
## Revision 1.417  2008/07/22 17:37:01  geraint
## Fixed case of MTT_EXAMPLES
##
## Revision 1.416  2006/09/27 13:03:20  geraint
## Fixed fr.view and enabled commands to directly build ??fr.m
##
## Revision 1.415  2006/02/09 23:58:24  geraint
## rtxi: builds but does not yet work.
##
## Revision 1.414  2005/11/18 17:23:19  geraint
## rtxi.
##
## Revision 1.413  2005/11/16 00:43:15  geraint
## rtxi
##
## Revision 1.412  2005/09/29 13:46:25  gawthrop
## Converts labg.fig -> ps/eps correctly (using fig2ps)
##
## Revision 1.411  2005/03/15 15:03:28  gawthrop
## Now works for Hierarchical systems
##
## Revision 1.410  2005/03/15 13:35:50  gawthrop
## Pretty abg figure in reports.
##
## Revision 1.409  2005/03/15 12:03:17  gawthrop
## New labg.fig rep - pretty LaTeX figures.
##
## Revision 1.408  2005/02/18 16:59:02  gawthrop
## Don't check files when using -s
##
## Revision 1.407  2005/02/17 18:36:38  geraint
## Removed a bash-ism: replaced [[ conditional ]] with [ conditional ]
##
## Revision 1.406  2005/01/06 15:36:06  geraint
## Tidied output of options.
##
## Revision 1.405  2005/01/06 12:47:53  geraint
## Fixed generation of sese.r with -make-sort option.
##
## Revision 1.404  2004/09/10 21:05:15  geraint
## Ensure that the system exists before proceeding.
## This should stop me from copying my home directory to MTT_work.
##
## Revision 1.403  2004/09/07 20:38:44  geraint
## Applies CRs before creating sese.make to avoid Circular dependencies.
##
## Revision 1.402  2004/09/03 08:35:27  geraint
## Copies Perl CRs to an mtt subdirectory (=> mtt:: workspace).
##
## Revision 1.401  2004/09/02 22:04:06  geraint
## Passes ${use_reduce} to mtt_make_sympar so that it can decide
## if to issue warnings about Reduce reserved words
##
## Revision 1.400  2004/08/31 01:29:48  geraint
## CRs are applied to sorted equation files during production.
##
## Revision 1.399  2004/08/29 16:09:49  geraint
## Added option -no-reduce
##
## Code sorting can now be used with Reduce (via sese.r) so that existing CRs
## work with sorted code (using -make-sort or -sort), or without by using
## -no-reduce; this option implies -make-sort.
##
## Revision 1.398  2004/08/29 14:39:23  geraint
## Added rule to create dae from sorted equations (sese) if sorting is requested.
##
## Revision 1.397  2004/08/29 13:17:30  geraint
## Added rules to use sae (sorted algebraic equations) instead
## of ae if sorted equations are being used.
##
## Converted temporary variable names to lowercase in sorted
## sympar.h to match code output from mtt_r2m.
##
## Revision 1.396  2004/08/29 02:59:30  geraint
## Added -make-sort option and rules to generate simulation using sesx and sesy.
##
## Revision 1.395  2004/08/28 23:48:06  geraint
## Removed dependency of ae.r on cse.r if -ae is not specified as an option.
## This prevents an implicit -A and thus removes a dependency on cse
## (and hence Reduce) for sorted systems.
##
## Revision 1.394  2004/08/28 22:14:12  geraint
## Removed -ibg option: now the default method.
##
## Revision 1.393  2004/08/26 16:20:17  geraint
## Creates postscript files of either dia or fig bond graphs.
##
## Revision 1.392  2004/08/26 12:50:12  geraint
## Replaced some implicit rules with explicit tests and patterns.
## Better than having make search through every possible implicit rule.
##
## Revision 1.391  2004/08/26 00:07:06  geraint
## Added rule to create cbg.dia.
##
## Revision 1.390  2004/08/13 09:49:13  geraint
## Only use one level of MTT_work to prevent MTT from repeatedly copying or creating the same files.
##
## Revision 1.389  2004/08/13 01:32:03  geraint
## Use ibg.m by default for both Xfig and Dia models.
##
## Revision 1.388  2004/08/11 08:18:07  geraint
## Ignores diy make files if the file ${rep}_rep.make.ignore exists, thus allowing user-defined makefiles to use the default MTT rules for languages which they do not override. See odes_rep.make and odeso_rep.make for an example of its use.
##
## Revision 1.387  2004/08/11 07:44:18  geraint
## Included cmp.m as a prerequisite for abg.m
##
## Revision 1.386  2004/08/05 00:02:57  geraint
## Uses lbl2cmp_txt2m.pl to generate _cmp.m.
##
## Revision 1.385  2004/08/02 20:25:47  geraint
## abg.m requires lbl.txt to allow units to be checked.
##
## Revision 1.384  2004/08/01 20:13:30  geraint
## ibg2abg transformation does not require lbl.txt (directly)
##
## Revision 1.383  2004/08/01 19:50:07  geraint
## Moved rules for ibg.m and abg.m so that -ibg can be used with dia models.
## Need to create cmp.m files before this combination will work.
##
## Revision 1.382  2003/09/23 20:53:49  geraint
## Updated version number (5.0).
##
## Revision 1.381  2003/08/10 18:56:55  gawthrop
## Explicitly generate eps files
##
## Revision 1.380  2003/08/06 14:44:51  gawthrop
## Don't include -q or -u in long file names via ${__ARGS}
##
## Revision 1.379  2003/08/06 10:33:42  gawthrop
## User now warned not to use -c which is unsupported.
##
## Revision 1.378  2003/08/04 09:15:09  gawthrop
## -ss switch reinstated
##
## Revision 1.377  2003/06/11 15:48:02  gawthrop
## Copies (aliased) subsystems first.
## Include switches in .ps file names.
##
## Revision 1.376  2003/05/09 09:46:35  gawthrop
## Fixed html output of figures
##
## Revision 1.375  2003/05/08 18:42:52  gawthrop
## Generate pdf from ps (using hyperref package for links etc)
##
## Revision 1.374  2003/04/17 20:57:27  geraint
## Added -sort option to allow direct generation of ode2odes.m using sese.m
## instead of ode/csex.
##
## "mtt -sort rc odeso view" works without Reduce installed!!!
##
## Revision 1.373  2003/04/17 20:07:32  geraint
## Added rule to create _sese.m
##
## Revision 1.372  2003/03/24 12:03:36  gawthrop
## Added -I switch to sese transformation
##
## Revision 1.371  2003/03/13 15:47:35  gawthrop
## Added sese rep.
##
## Revision 1.370  2003/02/11 20:04:08  geraint
## Reverted to line-by-line optimisation as default and added caution to
## description of -optg.
##
## Global optimisation has been observed to create assignments using
## uninitialised temporary variables.
##
## Revision 1.369  2003/02/06 20:28:40  geraint
## Added -ibg switch to aid testing during development of ibg2abg.m
##
## Revision 1.368  2002/12/12 17:18:41  geraint
## Fixed [ 647664 ] Namespace clash: LANG
## Prepended MTT_ to SYS, OPTS and LANG environment variables.
##
## Revision 1.367  2002/12/09 00:14:08  geraint
## Hierarchical dia and mixed dia/fig bond graphs now working.
##
## Revision 1.366  2002/12/06 21:56:21  geraint
## Cosmetic change: removed commented-out lines.
##
## Revision 1.365  2002/12/06 12:45:25  gawthrop
## Simplified rule for sub.sh: both fig and dia go via cmp.txt now.
##
## Revision 1.364  2002/12/03 23:28:44  geraint
## Added dependencies for bond graphs built with dia.
##
## Revision 1.363  2002/11/30 13:39:50  gawthrop
## Split abg2lbl_fig2txt into two parts:
##   abg2cmp_fig2txt
##   cmp2lbl_txt
## and incorporated into mtt
##
## Revision 1.362  2002/09/19 08:12:53  gawthrop
## Merged version after documentation update
##
## Revision 1.361  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.360.2.3  2002/09/16 07:59:26  geraint
## Changed default optimisation to global.
##
## Revision 1.360.2.2  2002/09/04 10:44:59  geraint
## Added option to specify number of tmp variables declared (-ntmpvar <N>).
##
## Revision 1.360.2.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.360  2002/08/20 15:51:16  gawthrop
## Update to work with ident DIY rep
##
## Revision 1.359  2002/08/07 14:27:14  geraint
## Changes to make "-i dassl" work again.
##
## Revision 1.358  2002/08/07 11:04:40  geraint
## Now updates timestamp on lbl.txt after processing in make. This eliminates the delay where MTT spends a long period of time uselessly recursing through the model on subsequent passes if the label file is older than the bondgraph.
##
## Revision 1.357  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.356  2002/06/17 13:14:50  geraint
## Fixed some rules to reduce number of implicit rule searches.
##
## Revision 1.355  2002/06/10 23:18:44  geraint
## Adjusted cr.h comment delimiters to be C compliant.
##
## Revision 1.354  2002/06/10 10:43:19  gawthrop
## ode2odes now prerequisite for sim.m and ssim.m
##
## Revision 1.353  2002/05/28 18:08:38  geraint
## Fixed [ 547294 ] CRs are not sought from MTT_CRS.
##
## Revision 1.352  2002/05/24 11:04:10  geraint
## Removed unnecessary message about *.log file not existing when -D option is used.
##
## Revision 1.351  2002/05/23 17:08:20  geraint
## `mtt sys sfun zip` now produces an input block and an interface block for MTT models.
## Models can be embedded within larger Simulink models by the 2 ports.
## The user must edit 2 code blocks in <sys>_sfun_interface.c before compiling with mex.
##
## Revision 1.350  2002/05/21 08:45:36  gawthrop
## DIY reps: no longer skips rep if file exists already.
## Avoids problems in rep.txt when options change
##
## Revision 1.349  2002/05/20 10:29:59  gawthrop
## -oct now forces an m target language to be oct
## (if the rep is an the list: "ae input logic numpar simpar state")
##
## Revision 1.348  2002/05/20 08:50:12  geraint
## Cleans _sfun_ae.mexglx.
##
## Revision 1.347  2002/05/20 07:12:05  gawthrop
## Trying to get oct files generated with -oct
##
## Revision 1.346  2002/05/17 11:15:38  gawthrop
## Messages about copying when using -dr now only appear in verbose (-v) mode.
##
## Revision 1.345  2002/05/15 14:22:25  geraint
## Code for Simulink S-function target written direct to sfun.cc instead of
## calling .mexglx files. This eliminates the sfun dependency on Octave
## ColumnVectors. sys_sfun.cc should build directly on a MS Windows machine
## (can't test this yet).
##
## added sfun.zip target to create source code to export.
##
## Revision 1.344  2002/05/11 01:14:17  geraint
## Fix for [ 553218 ] simpar.oct and simpar.m different.
## Translation added between ColumnVector in base .cc and Octave_map in .oct.
##
## Revision 1.343  2002/05/10 14:07:16  geraint
## Preserve .cc files.
##
## Revision 1.342  2002/05/10 13:24:58  geraint
## Added initial support for building Simulink S-functions.
## Rates do not update properly yet.
## Inertial switches do not work yet.
## Implicit integration not supported yet.
##
## build with: mtt -i euler MotorGenerator sfun mexglx.
##
## Revision 1.341  2002/05/09 15:40:22  gawthrop
## -dr touches copied files to redo timestamp
##
## Revision 1.340  2002/05/08 22:13:47  geraint
## Removed redundant path from mtt_*.cc targets in mexglx build line.
##
## Revision 1.339  2002/05/08 21:32:26  geraint
## Tidied up $1_ode2odes_*.* targets and renamed dummies as *.stamp.
##
## Revision 1.338  2002/05/08 16:03:32  geraint
## Added mex support for ode2odes: mtt sys ode2odes mexglx.
## This mex stuff seems to require octave2.1-headers.
##
## Revision 1.337  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.336  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.335  2002/05/01 17:30:55  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
## if necessary.
##
## Revision 1.334  2002/05/01 14:10:22  gawthrop
## Added -dr foo (reads from dir foo) option
##
## Revision 1.333  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.332  2002/04/26 23:19:00  geraint
## Fixed path to info files for "mtt info".
##
## Revision 1.331  2002/04/19 09:24:29  gawthrop
## 2 changes to ode2odes_out generation: only compiles the specified c
## file; outside the computation=c clause
##
## Revision 1.330  2002/04/17 10:03:12  geraint
## Marked .sg as a major representation.
##
## Revision 1.329  2002/04/16 14:58:00  gawthrop
## mtt copy does NOT now copy the CVS directory
## $directory --> ${directory}  (just to be tidy)
##
## Revision 1.328  2002/02/19 16:27:05  geraint
## Changes to make MTT work out of the box with Debian.
##
## Revision 1.327  2001/11/15 02:56:17  geraint
## Added DASSL as an option for solution of algebraic equations (-ae dassl).
## Requires octave-2.1.35.
##
## Revision 1.326  2001/10/26 01:01:47  geraint
## fixcc when rdae_is_dae (-cr).
##
## Revision 1.325  2001/10/11 03:15:55  geraint
## Fixed make dependencies for c++ simulation code
## - re-simulation no longer required for different output format.
##
## Revision 1.324  2001/10/05 23:39:43  geraint
## Made odes.dat2 .PRECIOUS to prevent deletion when simulation receives ^C.
##
## Revision 1.323  2001/08/08 02:14:59  geraint
## Rationalisation of solver code, beginning with algebraic solvers.
##
## Revision 1.322  2001/08/01 04:06:07  geraint
## Added -i dassl for -cc and -oct.
##
## Revision 1.321  2001/07/27 23:43:34  geraint
## Added -cc to usage options (required for use with xmtt).
##
## Revision 1.320  2001/07/27 23:38:38  geraint
## Changed comment below (# SUMMARY) - fixes xmtt.
##
## Revision 1.319  2001/07/27 23:29:10  geraint
## *** empty log message ***
##
## Revision 1.318  2001/07/24 04:17:30  gawthrop
## Removed all " from # SUMMARY lines - messes up xmtt
##
## Revision 1.317  2001/07/24 00:55:17  gawthrop
## Resolved clashes -- marked with ## >>>
##
## Revision 1.316  2001/07/22 19:24:03  geraint
## Multiple '-v' increases verbosity.
##
## Revision 1.315  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.314  2001/07/13 04:19:03  gawthrop
## Now loads _subs.r with _cr.r file when using -cr option
##
## Revision 1.313  2001/06/13 14:53:59  gawthrop
## MTT now gas the double-colon option in the abg.fig file
## eg R:r:a^2+3*b
##
## Revision 1.312  2001/06/11 19:43:49  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.311  2001/05/26 18:36:43  gawthrop
## Further modifications. Now works on rcPPP
##  -- next jobs:
##     add identification to ppp_nlin_sim
##     create real-time ppp_nlin_run
##
## Revision 1.310  2001/05/08 08:30:12  gawthrop
## Added line to reverse the x^y --> pow(x,y) in default  _simp file to
## prettyfy LaTeX
##
## Revision 1.309.2.3  2001/07/13 04:02:31  geraint
## Implemented numerical algebraic solution for _ode2odes.oct.
##
## Revision 1.309.2.2  2001/06/05 03:20:39  geraint
## added -ae option to select algebraic equation solution method.
##
## Revision 1.309.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.309  2001/04/28 03:15:03  geraint
## Fixed comment (interfered with "mtt help representations").
##
## Revision 1.308  2001/04/25 22:17:45  geraint
## Fixed icd.txt2 dependency.
##
## Revision 1.307  2001/04/15 21:15:41  geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.305  2001/04/11 09:44:26  gawthrop
## Fixed cc and c problems to do with pow(x,y) and integers
## mtt/lib/reduce/fix_c.r is included in rdae2dae and cse2smx_lang for
## -c, -cc and -oct options
##
## Revision 1.304  2001/04/11 07:35:22  gawthrop
## Now uses system_cr.h in place of system.h in .c rep -
##   compatible with older code
##
## Revision 1.303  2001/04/10 12:54:50  gawthrop
## Minor fixes for sensitivity versions
##
## Revision 1.302  2001/04/06 05:24:30  geraint
## -stdin for .cc reps.
##
## Revision 1.301  2001/04/05 03:46:12  geraint
## Added mtt_prepend.sh, -p preserves time attribute of base file
## - eliminates error in dependencies due to update of ese.r by modpar.r.
##
## Revision 1.300  2001/04/04 10:06:49  gawthrop
## New ssim (sensitiveity simulation) rep
##
## Revision 1.299  2001/04/03 14:49:42  gawthrop
## Revised to incorporate new ssim (sensitivity simulation)
## representation (m only just now).
##
## Revision 1.298  2001/04/02 17:36:20  gawthrop
## Resolved $sys name clash when using -s
##
## Revision 1.297  2001/03/29 19:20:45  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.296  2001/03/27 01:07:34  geraint
## Improved determination of Octave version for ode2odes.exe creation.
## Removed FORCE check_update of .txts.
##
## Revision 1.295  2001/03/23 11:21:29  gawthrop
## Show -pdf oprion in help list
##
## Revision 1.294  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.293.2.8  2001/03/19 01:35:31  geraint
## Reverted forced update check to main branch form, ready for merge.
##
## Revision 1.293.2.7  2001/03/17 09:51:06  geraint
## Implemented Runge-Kutta IV fixed-step method (-i rk4).
##
## Revision 1.293.2.6  2001/03/03 06:50:38  geraint
## Added summary lines for ode2odes.
##
## Revision 1.293.2.5  2001/03/03 00:27:14  geraint
## Fixed ar options to work with GNU ar. Allow mtt to create dependencies for mtt_%.cc when making mtt_%.oct.
##
## Revision 1.293.2.4  2001/03/02 00:45:21  geraint
## Separated Euler and Implicit methods in .cc code and dependencies.
##
## Revision 1.293.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.293.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.293.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.293  2001/02/06 04:39:08  geraint
## Added _standalone.exe representation.
##
## Revision 1.292  2001/02/05 17:27:40  gawthrop
## Make sure _def.r exists before creating _state.txt
##
## Revision 1.291  2000/12/27 14:50:40  peterg
## This is the first CVS version (4.9).
## Commented out code now deleted
##
## Revision 1.290  2000/12/05 09:59:37  peterg
## Generates $1_cr.h - allows inclusion of c functions for crs
##
## Revision 1.289  2000/12/05 09:01:52  peterg
## Changed == to =
##
## Revision 1.288  2000/12/01 17:59:01  peterg
## Added .PRECIOUS: %.cc to hang on to cc files - thanks Geraint
##
## Revision 1.287  2000/12/01 16:04:24  peterg
## More partitioning achieved -- now needs the connections to be properly
## sorted in cbg2ese_r
##
## Revision 1.286  2000/12/01 14:18:44  peterg
## -partition now partially works up to cse.m
##   but need to think about indexing, struc files etc for subsystems.
##
## Revision 1.285  2000/11/27 11:51:21  peterg
## Fixed a few pdf /fig bugs
##
## Revision 1.284  2000/11/27 10:33:35  peterg
## -pdf option now coerces ps-->pdf
##
## Revision 1.283  2000/11/24 15:11:50  peterg
## -pdf switch for simple displays
##
## Revision 1.282  2000/11/24 14:53:53  peterg
## Added lagrange rep : lde.r and lde.tex
##
## Revision 1.281  2000/11/16 13:51:15  peterg
## Added units stuff
##
## Revision 1.280  2000/11/10 14:45:16  peterg
## Finished up changes to incorporate Geraint's cc stuff
##
## Revision 1.279  2000/11/08 09:51:52  peterg
## Started incorporating Geraints CC/oct conversions
##
## Revision 1.278  2000/11/07 16:39:21  peterg
## *** empty log message ***
##
## Revision 1.277  2000/10/17 09:54:07  peterg
## logic rep sorted out
##
## Revision 1.276  2000/10/15 09:30:31  peterg
## *** empty log message ***
##
## Revision 1.275  2000/10/12 18:38:47  peterg
## New method of sympar generation implemented - uses mtt_make_sympar
## Check/update of numpar.txt is forced.
##
## Revision 1.274  2000/10/12 15:11:54  peterg
## Added the update function for numpar only
##
## Revision 1.273  2000/10/10 21:00:27  peterg
## More changes for new code gneration
##
## Revision 1.272  2000/10/06 16:20:00  peterg
## added ode_write rule
##
## Revision 1.271  2000/10/03 12:14:25  peterg
## Version 4.8
##
## Revision 1.270  2000/10/03 12:13:51  peterg
## Corrected MTT_LIB paths
##
## Revision 1.269  2000/09/30 14:12:03  peterg
## Fixed bug with no-parameter systems - changed mtt_txt2m and mtt_m2p
##
## Revision 1.268  2000/09/27 16:15:55  peterg
## Now sh (as opposed to bash) compatible -  fixed dat22dat again
##
## Revision 1.267  2000/09/21 10:08:30  peterg
## Version 4.7.1 - bug in odes.dat representation fixed in dat22dat
##
## Revision 1.266  2000/09/19 07:47:38  peterg
## fig2dev back to eps - ps produces a4 style output.
##
## Revision 1.265  2000/09/19 07:45:28  peterg
## Version 4.7
##
## Revision 1.264  2000/09/15 08:37:27  peterg
## Fixed bug using -sub in cbg view
##
## Revision 1.263  2000/09/15 07:33:35  peterg
## Replace fig2dev language eps by ps to avoid version problem.
##
## Revision 1.262  2000/09/14 17:16:33  peterg
## Fixes some outstanding bugs:
##   perpendicular strokes in cbg.fig
##   proper display of hierachical cbg file (-sub and -viewlevel)
##
## Revision 1.261  2000/09/14 12:43:46  peterg
## view of ps s files now uses -sub and -viewlevel options
##
## Revision 1.260  2000/09/14 09:59:08  peterg
## Added -viewlevel switch
##
## Revision 1.259  2000/09/11 08:21:27  peterg
## Introduced MML - but for _tf rep only.
##
## Revision 1.258  2000/09/11 08:17:28  peterg
## Extended _simp.r to incude default switches
##
## Revision 1.257  2000/09/02 15:53:53  peterg
## Now does partitioning up to dae.view
##
## Revision 1.256  2000/09/02 14:24:06  peterg
## -sub switch introduced - works up to dae.r
##
## Revision 1.255  2000/08/30 11:43:04  peterg
## Put in the -opt switch for code optimisation
##
## Revision 1.254  2000/08/29 09:59:47  peterg
## Version 4.5 -- includes code optimisation using the "Scope" package in reduce
##
## Revision 1.253  2000/08/24 08:53:35  peterg
## New makesubs to create a .subs.r file with output switches to simplify output.
##
## Revision 1.252  2000/08/09 10:31:17  peterg
## Use -d option to find if its a book-style report
##
## Revision 1.251  2000/08/04 10:54:33  peterg
## Rationalised call to gcc using -lp2c to access p2c lib.
##
## Revision 1.250  2000/08/01 19:29:27  peterg
## Explcit zero of input in the simulations
##
## Revision 1.249  2000/08/01 12:28:02  peterg
## VERSION 4.4
##    euler now works
##    stepfactor applies to both int. algorithms
##
## Revision 1.248  2000/07/20 07:46:07  peterg
## Version 4.3
##
## Revision 1.247  2000/07/13 07:21:12  peterg
## Interface to Octave Control Systems Toolbox (OCST) - mtt2sys.m
##
## Revision 1.246  2000/05/21 18:00:11  peterg
## Make manual if not already done.
## Released 4.2 version
## (Train Durham -- Glasgow).
##
## Revision 1.245  2000/05/19 17:50:10  peterg
## Changes to state rep - now has parameter
##
## Revision 1.244  2000/05/19 14:19:46  peterg
## Added library path for representations
##
## Revision 1.243  2000/05/19 11:36:36  peterg
## Added logic rep.
##
## Revision 1.242  2000/05/18 20:12:02  peterg
## Version 4.2
##
## Revision 1.241  2000/05/16 11:42:14  peterg
## Addded /usr/lib/libp2c.a  to gcc
##
## Revision 1.240  2000/05/10 09:38:58  peterg
## Added Make to list of copied files.
##
## Revision 1.239  2000/04/11 18:08:33  peterg
## Fixed cse.tex bug
##
## Revision 1.238  2000/04/10 10:06:41  peterg
## Sorted out implicit rules for p2oct conversion
##
## Revision 1.237  2000/04/07 19:10:24  peterg
## New smxa and smxax reps
##
## Revision 1.236  2000/04/06 10:55:36  peterg
## Removed debug lines
##
## Revision 1.235  2000/04/06 10:52:53  peterg
## Replace $PWD with `pwd` for sh compatibility
##
## Revision 1.234  2000/04/04 16:14:08  peterg
## Sorted mtt help
##
## Revision 1.233  2000/03/16 10:16:11  peterg
## Clean no longer zaps the abg.m files
##
## Revision 1.232  2000/03/16 09:43:35  peterg
## Put in $mtt_switches in mtt comand line when creating _state.txt and
## _input.txt
##
## Revision 1.231  2000/03/15 21:24:23  peterg
## Version 4.1:
##   Fixed problems with -abg mode
##   Old-style SS lbl no longer supported
##
## Revision 1.230  2000/03/15 20:31:06  peterg
## Replaced lbl2cr by abg2cr_m2txt
##
## Revision 1.229  2000/03/15 19:39:40  peterg
## Replaced sub creation cmp2sub_m2sh by abg2sub_m2sh
##
## Revision 1.228  2000/03/07 10:54:14  peterg
## Added  $1_lbl.txt to sympar.txt
##
## Revision 1.227  2000/02/16 15:05:46  peterg
## Replaced spurious 8spaces by tab
##
## Revision 1.226  2000/02/10 18:51:31  peterg
## Included OFF exp; in subs.r default
##
## Revision 1.225  2000/02/10 15:03:10  peterg
## Put subs.r file into the m-code generation -- allows the off exp;
## switch for simpler expresions.
##
## Revision 1.224  2000/02/08 10:27:04  peterg
## Removed obselete .h stuff
##
## Revision 1.223  2000/02/08 09:55:00  peterg
## Added .oct language for ode
## -- octave loadable builtin
##
## Revision 1.222  1999/12/23 10:03:42  peterg
## Added $1_sympars.txt to numpar.m target
##
## Revision 1.221  1999/12/22 05:15:51  peterg
## Set to version 4.0.
##
## Revision 1.220  1999/12/17 03:17:57  peterg
## reps_made is now $1_reps_made - stops clash between two reps per directory
##
## Revision 1.219  1999/12/14 00:36:50  peterg
## Changed $source to $stdin and added to mtt_m2p arg list
##
## Revision 1.218  1999/12/03 00:04:50  peterg
## Version to eric.
## -stdin switch added
##
## Revision 1.217  1999/11/16 22:15:55  peterg
## Changed compcopy to test for abg, not lbl file
##
## Revision 1.216  1999/11/16 05:53:21  peterg
## Added sensitivity (-s) switch
##
## Revision 1.215  1999/11/15 22:45:31  peterg
## Reorganised integration method using -i switch
## Introduced -r (reset) switch
##
## Revision 1.214  1999/11/14 21:27:11  peterg
## *** empty log message ***
##
## Revision 1.213  1999/09/02 23:24:40  peterg
## Now explicitly generates executable _ode2odes.out file
## Which takes command line arguments
##
## Revision 1.212  1999/08/18 06:20:32  peterg
## Put -u back again .....
##
## Revision 1.211  1999/08/17 04:10:38  peterg
## Removed the -u switch from cp - it doesnt work on non GNU cps
##
## Revision 1.210  1999/08/02 12:52:12  peterg
## Removed redundant .p copying.
##
## Revision 1.209  1999/07/27 03:50:13  peterg
## Fixed odeo.p bug.
## Fixed compound object bug in fig.
##
## Revision 1.208  1999/07/20 23:43:05  peterg
## V 3.8 ( to Eric)
##
## Revision 1.207  1999/04/02 07:17:37  peterg
## Upped version to 3.6 -- the new implicit solver with switches
##
## Revision 1.206  1999/04/02 06:28:54  peterg
## New implicit method - solves numerical prob with ISW
##
## Revision 1.205  1999/03/15 23:27:43  peterg
## Modified generation of odes.dat2 data
##
## Revision 1.204  1999/03/15 05:53:33  peterg
## Put in user-defined representations
##
## Revision 1.203  1999/03/08 03:51:12  peterg
## Version 3.5 for Linux Red Hat 5.2 (Newcastle)
##
## Revision 1.202  1999/02/17 01:59:20  peterg
## Now handles html copy correctely (ie mv directory to ..)
## Fixed path probs with html
##
## Revision 1.201  1999/02/16 03:50:09  peterg
## Removed explicit _smx targets
##
## Revision 1.200  1998/12/03 17:11:03  peterg
## Added -dc (derivative causality) switch.
##
## Revision 1.199  1998/12/03 16:53:50  peterg
## Now completes causality using component, not bond, status.
##
## Revision 1.198  1998/11/20 16:12:30  peterg
## Now copies aliased systems BEFORE generating rgb etc.
##
## Revision 1.197  1998/11/20 09:00:45  peterg
## Number of changes to underlying tools
##
## Revision 1.196  1998/11/10 11:55:40  peterg
## Added $info_switch to abg2cbg invocation
##
## Revision 1.195  1998/10/28 13:58:57  peterg
## Added $1_sympars.txt prerequisite to _tf.m target
##
## Revision 1.194  1998/10/20 09:00:43  peterg
## Added a few summary lines - to help with xmtt
##
## Revision 1.193  1998/10/01 16:11:42  peterg
## Implicit integration now handles switches
##
## Revision 1.192  1998/09/29 20:09:46  peterg
## Fixed nyfr and nifr plotting bug
##
## Revision 1.191  1998/09/02 12:05:39  peterg
## Added INPUT to simpar
## Revision 1.190  1998/09/02 11:48:51  peterg
## VERSION 3.2 (Swansea)
## abg data structure now uses explicti port and subsystem lists so that
## processing is in predetermined order.
##
## Revision 1.189  1998/08/31 10:49:15  peterg
## Minor changes to -abg operation
##
## Revision 1.188  1998/08/27 08:33:21  peterg
## New reduce integration methods - euler/Implicit only
##
## Revision 1.187  1998/08/25 20:06:56  peterg
## New data structure for abg.m and cbg.m
##
## Revision 1.186  1998/08/18 10:49:05  peterg
## VERSION 3.1 release
##
## Revision 1.185  1998/08/18 09:21:14  peterg
## Removed "" from default simpar file.
##
## Revision 1.184  1998/08/18 09:08:26  peterg
## Now grabs components (specified in lbl file as alias) at the rbg stage
## - this makes sure that they are there when needed.
##
## Revision 1.183  1998/08/18 08:48:43  peterg
## Sorted out problem with ifeq ($REPTYPE,data) block - added else.
##
## Revision 1.182  1998/08/17 15:48:39  peterg
## Replaced SVD solver with LUD solver
##
## Revision 1.181  1998/08/15 13:45:28  peterg
## Added new integration methods in Pascal/c version
## Revised the various translations appropriately
##
## Revision 1.180  1998/08/12 14:15:13  peterg
## Implicit integration - c implemetation now included.
##
## Revision 1.179  1998/08/12 12:29:18  peterg
## Put back some of the args stuff -- needed for plots.
##
## Revision 1.178  1998/08/11 13:38:35  peterg
## Zapped the obsolete args stuff
##
## Revision 1.177  1998/07/30 17:32:44  peterg
## VERSION 3.0
##
## Revision 1.176  1998/07/27 20:25:15  peterg
## Sorted out new mtt_r2m
##
## Revision 1.175  1998/07/27 18:49:09  peterg
## Fixed the frequency stuff
##
## Revision 1.174  1998/07/27 07:10:10  peterg
## Removed dummy global stuff.
##
## Revision 1.173  1998/07/26 14:38:20  peterg
## *** empty log message ***
##
## Revision 1.172  1998/07/26 11:13:38  peterg
## Fixed name classes with globs - ide is that all @strong{MTT} variables
## start with @strong{MTT}
##
## Revision 1.171  1998/07/25 20:37:22  peterg
## Removes -s (switches) option -- they are now assumed to be present
## I still need to shift the old switch
##
## Revision 1.170  1998/07/25 19:16:22  peterg
## Sorted out sympar + switch variables - new sympars rep combines both
##
## Revision 1.169  1998/07/25 16:35:12  peterg
## Incorporated mtt_p2c (uses p2c)
##
## Revision 1.168  1998/07/25 09:44:25  peterg
## Uses Pascal as step on the way to c code -- MUCH nicer!
## State and input now use the simple default - no steady states
##
## Revision 1.167  1998/07/24 17:10:34  peterg
## *** empty log message ***
##
## Revision 1.166  1998/07/22 08:37:30  peterg
## Implicit integration now the default - for octave anyway.
##
## Revision 1.165  1998/07/19 16:00:22  peterg
## Added smx representation
##
## Revision 1.164  1998/07/17 19:45:58  peterg
## Component aliases implemented.
##
## Revision 1.163  1998/07/17 08:27:33  peterg
## Added find target
##
## Revision 1.162  1998/07/16 16:14:27  peterg
## Now stops if a transformation forces error.
##
## Revision 1.161  1998/07/08 11:21:32  peterg
## Added -I switch
##
## Revision 1.160  1998/07/04 11:38:51  peterg
## Version 3.0-- (Seascale)
##
## Revision 1.159  1998/07/04 11:37:43  peterg
## Aliases implemented for parameters + lots of associated goodies
## New-style lbl files - no more SS nonsense.
##
## Revision 1.158  1998/07/03 09:06:39  peterg
## Alias implemented for ports
##
## Revision 1.157  1998/07/01 10:22:11  peterg
## Moved tidy stuff to end of preamble -- needed to make muti-plot copy
## correctely
## Now copies ps file with arguments to WD
##
## Revision 1.156  1998/06/26 14:19:43  peterg
## Copy hidden files (eg .octaverc) in tidy mode
##
## Revision 1.155  1998/06/24 07:43:42  peterg
## Version 2.91 -- includes implicit integration (octave)
##
## Revision 1.154  1998/06/17 14:14:09  peterg
## Removed struc.txt prerequisite for simpar.txt - switch version
##
## Revision 1.153  1998/05/28 09:36:38  peterg
## --version and --versions switch
##
## Revision 1.152  1998/05/24 15:43:10  peterg
## Added symbolic solution of alg. equations (-A)
##
## Revision 1.151  1998/05/23 16:18:37  peterg
## ordinary differential equation.m files generated with the new ode2lang
## method.
##
## Revision 1.150  1998/05/19 19:47:37  peterg
## Updated the odesso representation to use simpar file.
##
## Revision 1.149  1998/05/14 15:16:13  peterg
## Sorted out Differential-Algebraic Equation simulation
## Added LSODE methode to ordinary differential equation simulation
##
## Revision 1.148  1998/05/12 14:42:07  peterg
## Added ese_tidy and new method for organising ese files -
## Each subsystem has an array of variables - effort, flow and state for
## each bond
##
## Revision 1.147  1998/04/15 18:41:47  peterg
## Fixed various probs with multiple systems in one directory
##
## Revision 1.146  1998/04/04 11:00:20  peterg
## Modified various parts to allow coercing directions at ports
##
## Revision 1.145  1998/04/03 11:17:44  peterg
## VERSION 2.9
##
## Revision 1.144  1998/03/27 13:32:25  peterg
## Removed sympar prerequisites from ss reps.
##
## Revision 1.143  1998/03/22 21:14:03  peterg
## Added obspar.r representation
## Help now case insensitive
##
## Revision 1.142  1998/03/20 15:09:26  peterg
## Changed order of prerequisites for _dae.r to put _rdae.r first.
##
## Revision 1.141  1998/03/11 10:45:19  peterg
## Added rclean - recursive clean
##
## Revision 1.140  1998/03/09 10:23:30  peterg
## PS view now runs as a background process.
##
## Revision 1.139  1998/03/07 16:04:23  peterg
## Added some more txt view reps: input, lbl, numpar, state
##
## Revision 1.138  1998/03/07 15:23:40  peterg
## Uses sort_sympar to uniquely produce the sympar list.
##
## Revision 1.137  1998/03/07 14:04:17  peterg
## dae creation split into 2 parts:
## 1. create a raw (ie without constitutive relationship) dae (rdae)
## 2. add the raw dae to the crs to get the dae.
## reduce has less work to do with this approach
##
## Revision 1.136  1998/03/04 16:34:19  peterg
## New local (_cr.r) and generic (.cr) CR structure.
## CR and lbl now have view mode.
## CRS in abg_tex.
##
## Revision 1.135  1998/02/25 22:09:48  peterg
## Added simpar representation.
##
## Revision 1.134  1998/02/25 15:28:34  peterg
## Added state.m rep.
##
## Revision 1.133  1998/02/24 22:35:33  peterg
## Added -p (preserve) switch to cp in tidy mode.
##
## Revision 1.132  1998/02/24 22:33:23  peterg
## new state reresentation included
##
## Revision 1.131  1998/02/23 16:21:21  peterg
## Just do model name in summary line of lbl file
##
## Revision 1.130  1998/02/19 13:40:24  peterg
## Removed prerequisit from sspar.r target.
##
## Revision 1.129  1998/02/12 08:18:42  peterg
## VERSION 2.8 (St. Annes)
##
## Revision 1.128  1998/02/12 07:48:04  peterg
## Tidy mode copies all files (containing .) to work dir -- this makes
## sure that files such a .c .constitutive relationship go across.
##
## Revision 1.127  1998/02/11 19:36:29  peterg
## Only displays one level of cbg file now.
##
## Revision 1.126  1998/02/11 19:26:03  peterg
## Added verbose (-v) mode.
##
## Revision 1.125  1998/02/11 11:36:28  peterg
## Updated version control mode - make it untidy.
## cp --> cp -u after tidy-mode .
##
## Revision 1.124  1998/02/10 13:03:36  peterg
## Now includes controller transfer function (ctf).
##
## Revision 1.123  1998/02/09 13:51:04  peterg
## Fixed directory string bug.
##
## Revision 1.122  1998/02/06 15:02:26  peterg
## New default sspar -- sets all states to zero.
##
## Revision 1.121  1998/02/06 14:36:51  peterg
## Report on copying back from MTT_work
##
## Revision 1.120  1998/02/05 16:06:53  peterg
## Removed debugging lines.
## Auto parts in books.
##
## Revision 1.119  1998/02/05 15:04:25  peterg
## Fixed problem with book in tidy mode.
##
## Revision 1.118  1998/02/05 12:00:11  peterg
## Tidy mode now default.
## It seems to work ok but not for book type documents.
##
## Revision 1.117  1998/02/04 16:50:50  peterg
## Introduced the tidy (-t and -T) options
##
## Revision 1.116  1998/02/04 11:00:04  peterg
## Added view of subsystems.
##
## Revision 1.115  1998/01/29 19:37:31  peterg
## Fixed spurious call to X server bug
##
## Revision 1.114  1998/01/23 13:38:07  peterg
## VERSION 2.7
##
## Revision 1.113  1998/01/23 13:27:13  peterg
## Added state-feedback control representations:
## smc,smo,ssk,ssl
##
## Revision 1.112  1998/01/21 09:24:46  peterg
## Removed 'touch $1_rep.txt' -- perhaps best to do this by hand if
## necessary. As it is, it cuased probs wene reediting the _rep.txt file.
##
## Revision 1.111  1998/01/16 14:56:59  peterg
## Argument now correctely recognised as a string beginning with -
## (rather than containing -)
##
# Revision 1.110  1998/01/06  13:59:30  peterg
# Added rename function.
#
# Revision 1.109  1998/01/06  09:20:02  peterg
# Made LATEX2HTML an environment variable.
#
# Revision 1.108  1997/12/19  08:48:55  peterg
# Lille modifications - bicausal algebraic loops supported
#
## Revision 1.107  1997/12/11 10:59:50  peterg
## This is version 2.6
##
# Revision 1.106  1997/12/11  10:59:07  peterg
# Added debug -D switch + echos directory when -d switch used.
#
# Revision 1.105  1997/12/11  09:04:47  peterg
# Reduced default rep.txt file to just abg.txt -- this is to document
# components which may not be causally complete
#
# Revision 1.104  1997/12/07  21:05:10  peterg
# Removed a debbugging echo
#
## Revision 1.103  1997/12/07 20:10:36  peterg
## Fixed bugs with reprots and distinguish between book, article and
## section reports.
##
## Revision 1.102  1997/12/07 12:14:43  peterg
## Hnadles book, article and section reports seperately
##
## Revision 1.101  1997/12/06 18:54:53  peterg
## Now tidies up after itself.
## Major modifications to do a rep on a directory -- creates a book with
## each example as a chapter.
##
## Revision 1.100  1997/12/06 12:14:39  peterg
## Put a conditional around the PS data rep to check for set arguments.
##
## Revision 1.99  1997/12/04 22:06:53  peterg
## Added view arguments for graph plotting
##
## Revision 1.98  1997/12/04 10:58:15  peterg
## Tidied up switches
##
## Revision 1.97  1997/12/04 10:44:33  peterg
## Changed $cc to $CC
##
## Revision 1.96  1997/12/04 10:40:26  peterg
## Added -p switch - print enviromment variables
##
## Revision 1.95  1997/12/04 10:05:02  peterg
## Compiler now symbolocic $cc
##
# Revision 1.94  1997/11/20  11:23:16  peterg
# Changed gcc to cc
#
## Revision 1.93  1997/09/18 16:57:28  peterg
## _sympar.txt now has a second column - the system type from whence the
## parameter (in the first column) came.
## Done on the train Glasgow-Warrington !
##
## Revision 1.92  1997/09/11 17:08:46  peterg
## Added spreadsheet version of odeso
##
## Revision 1.91  1997/09/11 08:21:08  peterg
## copy utility split into two:
## copy: copies examples (copies the entire directory)
## compcopy: (just used internally) copies components.
##
## Revision 1.90  1997/08/30 19:35:39  peterg
## Added date to mtt line
##
## Revision 1.89  1997/08/26 15:20:25  peterg
## Added explicit evaluation of report representations
## Version now 2.5++
##
## Revision 1.88  1997/08/25 07:51:47  peterg
## Version 2.5.
##
## Revision 1.87  1997/07/27 13:11:11  peterg
## Added path checking code -- mtt_check_vars
##
# Revision 1.86  1997/06/29  19:05:51  peterg
# Seascale changes -- mainly to new rep format.
#
## Revision 1.85  1997/06/27 12:14:49  peterg
## Upped version to 2.4++
##
# Revision 1.84  1997/06/13  14:08:23  peterg
# Changed default rep.txt
#
# Revision 1.83  1997/06/13  09:18:28  peterg
# Removed all params.m
#
# Revision 1.82  1997/06/13  08:59:03  peterg
# Set to version 2.4
#
## Revision 1.81  1997/05/22 10:11:04  peterg
## Fixed dat2gdat bug (with parameters)
##
## Revision 1.80  1997/05/22 07:38:27  peterg
## Added command line info to .doc files (makedoc)
##
## Revision 1.79  1997/05/19 16:44:12  peterg
## Many changes to get rep.html mode working properly.
##
# Revision 1.78  1997/05/19  13:17:50  peterg
# Explicit inclusion of mtt.sty in .doc files -- latex2html prefers this
#
# Revision 1.77  1997/05/19  11:29:37  peterg
# Added desc.tex and abg.tex descriptions.
#
# Revision 1.76  1997/05/15  09:43:46  peterg
# New version of _input.txt for -s option
#
# Revision 1.75  1997/05/15  09:15:54  peterg
# Included switch.c in dependancy list for _input.c (when -s switch set)
#
# Revision 1.74  1997/05/13  16:58:02  peterg
# Added -s switch to get mtt to search for (Bond Graph) switches
#
## Revision 1.73  1997/05/09 09:18:45  peterg
## Put ./ in front of a.out (again)
##
# Revision 1.72  1997/05/06  13:54:21  peterg
# Changed gcc arguments for the ode simulation -- all files now included
# in the _odes.c file
#
# Revision 1.71  1997/05/03  15:50:18  peterg
# c functions not included in gcc arg list -- they are now included in
# the main prog.
#
# Revision 1.70  1997/05/03  14:17:13  peterg
# Now copies c utilities (eg dsvdcmp.c) from $MTTPATH/trans/c.
#
# Revision 1.69  1997/05/03  13:58:35  peterg
# Implicit integration for sm representation added.
#
# Revision 1.68  1997/05/01  08:39:20  peterg
# params.c and params.m not used any more.
# _numpar.txt is the common base from which _numpar.c and numpar.m is
# generated.
#
# Revision 1.67  1997/04/23  07:26:49  peterg
# Added -o switch -- ode and dae are the same
# Added switches to default menu
#
# Revision 1.66  1997/04/16  09:46:01  peterg
# More informative copy message
#
# Revision 1.65  1997/04/15  15:16:12  peterg
# Added structure (_struc) files.
# Fixed prob with dvi2ps conversion -- removed .doc extension.
#
# Revision 1.64  1997/04/09  09:26:44  peterg
# Added crcopy feature to pull crs from library -- similar to copy
# feature.
#
# Revision 1.63  1997/03/22  17:09:11  peterg
# Fixed bug in recursive cr.txt generation.
# Fixed bug in recursive sympar.txt generation.
#
# Revision 1.62  1997/03/20  17:48:50  peterg
# Better _input.c file default.
#
# Revision 1.61  1997/03/20  16:53:01  peterg
# Generates c files using include statements.
#
# Revision 1.60  1997/03/20  10:25:41  peterg
# Generates a compehensive default params file.
#
# Revision 1.59  1997/03/19  10:14:04  peterg
# Now produces a stripped acausal bond graph.
#
# Revision 1.58  1997/03/18  17:58:12  peterg
# Generates label files containing all variables in fig file.
# Generates sympar file for all levels in system.
# Generates txt version of sympar file.
#
# Revision 1.57  1997/03/10  09:24:58  peterg
# a.out now deleted in the clean operation
#
# Revision 1.56  1997/03/05  08:24:09  peterg
# Delete a.out after it has run.
#
# Revision 1.55  1997/02/24  19:31:10  peterg
# Removed numpar.m requirement from .m files
#
## Revision 1.54  1997/02/09 20:33:13  peterg
## Replaced a.out with ./a.out
##
## Revision 1.53  1997/02/09 20:30:04  peterg
## Copied from tweedledum.
##
# Revision 1.54  1997/02/07  13:33:03  peterg
# Added ; to _input.c file - bug fix.
#
# Revision 1.53  1997/02/07  13:25:04  peterg
# Version 2.3
#
# Revision 1.52  1997/01/21  22:55:59  peterg
# Minor bug fixes
#
## Revision 1.51  1997/01/21 13:16:40  peterg
## Included transformations to language c for:
## ode
## params
## numpar
##
## Revision 1.50  1996/12/21 19:46:52  peterg
## Set to 2.2++
## Changed \* --> \\* in rbg_fig2m.awk
##
## Revision 1.49  1996/12/19 19:55:22  peterg
## Version 2.2 -- Linux.
##
## Revision 1.48  1996/12/07 21:33:52  peterg
## Changed _input file to give unit step on ALL inputs
##
## Revision 1.47  1996/12/07 20:50:16  peterg
## *** empty log message ***
##
## Revision 1.46  1996/12/05 10:48:51  peterg
## Put sympar in clean list.
## sympar now sucks in params.r file
##
## Revision 1.45  1996/12/05 10:41:39  peterg
## Saved many changes over past 2 weeks.
##
# Revision 1.44  1996/11/12  16:04:25  peterg
# Really VERSION 2.1
#
# Revision 1.43  1996/11/12  08:52:57  peterg
# Fixed bug in test arg to if - missing "".
#
# Revision 1.42  1996/11/11  17:23:03  peterg
# Added numpar.m requirement to all .m targets
#
## Revision 1.41  1996/11/11 17:18:32  peterg
## VERSION 2.1
##
## Revision 1.40  1996/11/09 21:17:38  peterg
## Fixed bug with copying at level 0.
##
## Revision 1.39  1996/11/09 20:22:54  peterg
## VERSION 2.0
##
## Revision 1.38  1996/11/09 20:17:34  peterg
## Fixed bug with null ARGS argument
## Put in new lib paths.
##
## Revision 1.37  1996/11/09 18:47:46  peterg
## Added new copy command (using find).
## More documaentation stuff.
##
# Revision 1.36  1996/11/03  21:19:02  peterg
# Recursice generation of Constitutive Relationship files.
#
## Revision 1.35  1996/11/02 10:19:19  peterg
## Constitutive Relationship generation from lbl file
##
## Revision 1.34  1996/11/01 13:34:35  peterg
## -q (quiet) switch added
##
## Revision 1.33  1996/11/01 12:34:45  peterg
## Added browser - mtt_help
##
## Revision 1.32  1996/10/31 20:48:41  peterg
## Revised html generation.
## Stopped deletion of rep.txt file.
##
# Revision 1.31  1996/10/20  19:23:54  peterg
# Automatic generation of sub-system abg.m files.
#
## Revision 1.30  1996/10/01 14:08:05  peterg
## Replaced $() by ``
## Replaced make with gmake
##
# Revision 1.29  1996/10/01  11:04:05  peter
# Changed name of html document.
#
## Revision 1.28  1996/09/13 18:44:11  peter
## Added params dependencies.
##
## Revision 1.27  1996/09/12 19:24:56  peter
## New numpar/params setup.
##
## Revision 1.26  1996/09/10 17:04:47  peter
## Added impulse response (ir) representation.
##
## Revision 1.25  1996/08/30 20:03:45  peter
## Removed dependencies from vc
##
## Revision 1.24  1996/08/30 18:37:17  peter
## inor changes.
##
## Revision 1.23  1996/08/30 11:10:37  peter
## More files in clean up.
##
## Revision 1.22  1996/08/30 10:07:51  peter
## Removed impicit creation of abg.fig file.
##
## Revision 1.21  1996/08/22 12:19:51  peter
## Added various document viewers.
##
## Revision 1.20  1996/08/20 08:24:53  peter
## Now with version control.
##
## Revision 1.19  1996/08/19 15:33:22  peter
## Included new state matric (sm) rep.
## Generate step response (sr) from sm.
##
## Revision 1.18  1996/08/19 13:30:54  peter
## New CLEAN target.
##
## Revision 1.17  1996/08/19 06:48:14  peter
## Explicit figure editing.
##
## Revision 1.16  1996/08/18 19:58:36  peter
## Report generation included.
##
## Revision 1.15  1996/08/18 12:01:01  peter
## Unified format of time responses.
##
## Revision 1.14  1996/08/16 14:52:24  peter
## Added two alternative view options - dview and pview.
##
## Revision 1.13  1996/08/16 08:24:31  peter
## Correctly chooses how to make a ps file using $REPTYPE.
##
## Revision 1.12  1996/08/15 16:47:47  peter
## DAE solution (experimental) included.
##
## Revision 1.11  1996/08/15 11:55:30  peter
## Checks for changed argument.
## Handles frequency response.
##
## Revision 1.10  1996/08/15 07:44:24  peter
## Now handles generic transformations using %.
##
## Revision 1.9  1996/08/14 09:16:08  peter
## Step response now goes through  m, dat and gdat conversions
##
## Revision 1.8  1996/08/12 20:19:52  peter
## Arguments now passed via $1_args.m file
##
## Revision 1.7  1996/08/11 19:49:27  peter
## Parameter passing (via $4) added.
##
## Revision 1.6  1996/08/11 10:40:56  peter
## Added new numpar stuff.
## Added step response.
##
## Revision 1.5  1996/08/10 14:13:47  peter
## Added impulse and frequency response stuff.
##
## Revision 1.4  1996/08/10 09:19:48  peter
## Put in help, info and warranty stuff.
##
## Revision 1.3  1996/08/09 15:13:13  peter
## Generic viewing of any representation via ps files implemented.
##
## Revision 1.2  1996/08/05 19:50:55  peter
## Put in fig.fig target.
##
## Revision 1.1  1996/08/04 17:29:42  peter
## Initial revision
##
###############################################################

set_oct() {
## Sets ${m} to oct if such a rep is supported
    m=m
    supported_reps="ae input logic numpar simpar state"
    for supported_rep in ${supported_reps}; do
	if [ "${rep}" = "${supported_rep}" ]; then
          m=oct	    
	fi
    done
}

#Check $MTTPATH has been set
mtt_check_var "$MTTPATH" "MTTPATH"

#Version
version='5.0'

# MTT recursion level is zero unless explicitly set
level=0

#Computation mode is octave by default
computation=octave

#By default, Reduce is used if available
if [ -n "$SYMBOLIC" ]; then
    use_reduce='yes'
else
    use_reduce='no'
fi

#By default, the dae and ode representations are different
dae_is_ode=0

#By default, the ode and cse reps are different
ode_is_cse=0

# By default, don't look for BG switches
switches=0

#By default, don't print the environment variables
print='';

# By default, make it tidy
tidy=tidy;

# Default not verbose
verbose=' -s'
verbosity=0

# Default integration method
integration_method=implicit;

# Default algebraic equation solver
algebraic_solver=noAlgebraicSolver;

# Default no info
info_switch=''

# Default use m, not oct files
m='m';

# Default use ps files
ps=ps
eps=eps
psview=$PSVIEW

# Default declare 500 temporary variables
num_tmp_var=500

# Default no equation sorting
do_sort=''
sort_method=''

#Initialise list of switches
mtt_switches='';

#Initialise read dirs
read_dirs=''

#Initialise view_level
viewlevel=0

#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-q )
                mtt_switches="$mtt_switches $1";
		quiet=quiet;;  
	-r )
                mtt_switches="$mtt_switches $1";
		reset=reset;;  

	-p )
                mtt_switches="$mtt_switches $1";
		print='-p';;
	-c )
	        echo "-c is obsolete. Please use -cc instead"
                fixcc='-fixcc'
                mtt_switches="$mtt_switches $1";
                matrix_smxa="-matrix";
		computation=c ;;
	-cc )
                fixcc='-fixcc'
                mtt_switches="$mtt_switches $1";
                matrix_smxa="-matrix";
		computation=cc ;;
	-cr )
                mtt_switches="$mtt_switches $1";
		rdae_is_dae=1 ;
                cr_first='-cr';;
	-o )
                mtt_switches="$mtt_switches $1";
		dae_is_ode=1 ;;
	-nocr )
                mtt_switches="$mtt_switches $1";
		rdae_is_dae=1 ;;
	-no-reduce )
                mtt_switches="$mtt_switches $1";
                use_reduce='no';
                do_sort='-sort';
                sort_method='make';
                rdae_is_dae=1 ;
                cr_first='-cr';
                Solve='';
                num_tmp_var=0 ;
                integration_method="euler" ;;
	-i )
                mtt_switches="$mtt_switches $1";
                shift;
                case $1 in
		    dassl)
			integration_method=dassl;
			mtt_switches="$mtt_switches dassl";
			;;
		    euler)
			integration_method=euler;
                        mtt_switches="$mtt_switches euler";
			;;
		    implicit)
			integration_method=implicit;
                        mtt_switches="$mtt_switches implicit";
			;;
		    rk4)
			integration_method=rk4;
			mtt_switches="$mtt_switches rk4";
			;;
		    *)
			echo $1 is an unknown integration method - use dassl, euler, rk4 or implicit;
                        exit;;
		esac;;
	-ae )
                mtt_switches="$mtt_switches $1";
		case $2 in
		    dassl)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=Dassl_Solver;
			shift;
			;;
		    fsolve | hybrd)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=Hybrd_Solver;
			shift;
			;;
		    hooke)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=HJ_Solver;
			shift;
			;;
		    reduce)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=Reduce_Solver;			
			Solve='-A';
			shift;
			;;
		    *)
			echo $1 is an unknown solver - use hybrd, hooke or reduce;
			exit;;
	        esac;;
	-s )
                sensitivity_switch='-s';
                mtt_switches="$mtt_switches $1";
		sensitivity=sensitivity ;;
	-make-sort )
		mtt_switches="$mtt_switches $1";
		do_sort='-sort';
		sort_method="make";
		num_tmp_var=0 ;;
	-sort )
                mtt_switches="$mtt_switches $1";
		do_sort='-sort';
		sort_method="seqn";
		integration_method="sorted_euler";;
	-ss )
                mtt_switches="$mtt_switches $1";
		steadystate_computation=yes ;;
	-d )
		directory=$2; cd $directory; shift ;;
	-dc )
		mtt_switches="$mtt_switches $1";
		causality_switch='-derivative' ;;
	-S )
		directory=$2;  shift;;
	-D )
                mtt_switches="$mtt_switches $1";
		debug=debug ;;
	-v )
                mtt_switches="$mtt_switches $1";
		info_switch='-I';
                Verbose='verbose';
		verbosity=`expr $verbosity + 1`;
		if [ $verbosity -ge 1 ]; then verbose=' -w '; fi;
		if [ $verbosity -ge 2 ]; then set -x; fi;
		if [ $verbosity -ge 3 ]; then verbose_make=' -d '; fi;
		;;
	-I )
                mtt_switches="$mtt_switches $1";
		info_switch='-I' ;;
	-t )
		tidy=tidy ;;
	-trace )
                mtt_switches="$mtt_switches $1";
		trace='-n' ;;
	-T )
		tidy=tidy;
                verytidy=verytidy ;;
	-u )
		tidy=untidy ;
                mtt_switches="$mtt_switches $1";
                ;;
	-l )
                mtt_switches="$mtt_switches $1 $2";
		level=$2; shift ;;
	-A )
                mtt_switches="$mtt_switches $1";
                Solve='-A';;
	-abg )
                mtt_switches="$mtt_switches $1";
                start_at_abg='yes';;
	-stdin )
                mtt_switches="$mtt_switches $1";
                stdin=stdin;;
	-sub )  mtt_switches="$mtt_switches $1 $2";
                sub='-sub'; 
                subsystem="_"$2;
                shift;;
	-oct )
                fixcc='-fixcc'
                mtt_switches="$mtt_switches $1";
                using_oct=yes;
                ;;
	-opt | -optl )
		mtt_switches="$mtt_switches $1";
                optimise='-optimise_local';;
	-optg )
		mtt_switches="$mtt_switches $1";
                optimise='-optimise_global';;
        -ntmpvar )
		num_tmp_var=$2;
		mtt_switches="$mtt_switches $1 $2";
		shift;;
	-partition ) mtt_switches="$mtt_switches $1";
                     partition='-partition';
                ;;
	-pdf )   mtt_switches="$mtt_switches $1";
                 ## ps=pdf; 
                 ## eps=pdf;
                 ## pdf='-pdf';
                 psview=$PDFVIEW;
                ;;
	-dr )   mtt_switches="$mtt_switches $1"; shift
                mtt_switches="$mtt_switches $1"; read_dir=$1
	        if [ -d "${read_dir}" ]; then
		    read_dirs="${read_dirs} ${read_dir}"
		else
		    echo "${read_dir} does not exist - ignoring"
		fi
                ;;
	-nas )  no_alpha_sort="no_alpha_sort";
                mtt_switches="$mtt_switches $1";
                ;;
	-viewlevel )  mtt_switches="$mtt_switches $1 $2";
                      viewlevel=$2;
                      shift;;
        --version)                
                  echo 'MTT version' $version; exit;;
        --versions)                
                mtt_versions; exit;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

## Create switches string for adding to file names.
  MTT_SWITCHES=`echo ${mtt_switches} | sed 's/ //g' | sed 's/^-u-q//'`

#Print header if not in quiet (-q) mode.
if [ "$quiet" != "quiet" ]; then
  echo
  echo 'MTT (Model Transformation Tools) version' $version
  echo '($Date$)'
  echo 'This is free software with ABSOLUTELY NO WARRANTY.'
  echo 'Type `mtt warranty'\' 'for details.'
  echo
  # Print current directory if in -d mode
  if [ -n "$directory" ]; then
    echo Using directory $directory
    echo
  fi
fi

#Print what's going on if in verbose mode
if [ -n "$Verbose" ]; then
    echo  Starting  mtt  $mtt_switches  $1 $2 $3 $4 at level $level 
    echo  "        " current wd `pwd`
fi

#Check the principle paths
mtt_check_vars $print

# Exit if just printing paths
if [ "$print" != "" ]; then
  exit
fi

if [ -z "$1" ]; then
  if [ -z "$print" ]; then
      cat <<EOF
Usage:
	mtt help		-- mtt on-line help
	mtt find component	-- find location of a compound component
	mtt info		-- info-based manual
	mtt info topic
	mtt hinfo		-- hypertext manual
	mtt manual		-- pdf manual
	mtt warranty
	mtt clean		-- cleans up intermediate files
	mtt rclean		-- recursively cleans up intermediate files
	mtt Clean		-- cleans up all generated files
	mtt <system_name> clean
	mtt copy <system_name> <path_name>
	mtt rename <old_name> <new_name>
	mtt <system_name> <representation> vc 
	mtt <system_name> <representation> <language>
	mtt <system_name> <representation> <language> <parameters>

Options:
	-A		solve algebraic equations symbolically
	-abg		start at abg.m representation
	-ae <method>	algebraic equation solver: reduce|hybrd|dassl|hooke
	-cc		C++ code generation
	-cr		use cr before resolving equations
	-D		debug -- leave log files etc
	-d <dir>	use directory <dir>
	-dc		maximise derivative (not integral) causality
	-dr <dir>	use files contained in <dir>
	-I		prints more information
	-i <method>	integration method: implicit|euler|rk4|dassl
        -nas            no alphabetic sort (of components)
	-o		ode is same as dae
	-oct		use oct files in place of m files where appropriate
	-opt		optimise code generation (equivalent to -optl)
	-optl		locally optimise code generation (line-by-line)
	-ntmpvar <N>	declare <N> temporary variables (default=$num_tmp_var)
	-p		print environment variables
	-partition	partition hierachical system
	-pdf		generate pdf in place of ps
	-q		quiet mode -- suppress MTT banner
	-r		reset time stamp on representation
	-s		generate sensitivity BG (use mtt -s sSys rep lang)
	-ss		use steady-state info to initialise simulations
	-stdin		read input data from standard input for  simulations
	-sub <subsys>	operate on subsystem <subsys>
	-t		tidy mode (default)
	-trace		just indicate what mtt will do - but do not do it
	-u		untidy mode (leaves files in current dir)
	-v		verbose mode (multiple uses increment the verbosity)
	--version	print version and exit
	--versions	print version of mtt and components and exit
	-viewlevel <N>	view <N> levels of hierachy

Experimental options:
	-optg		globally optimise code generation (full vector)
	-make-sort	use sorted equations (sese, generated by make)
	-no-reduce	try not to use symbolic algebra
	-sort		use sorted equations (sese, generated by seqn)

Deprecated options:
	-c		c-code generation

EOF
    exit
  fi
fi


if [ "$1" = "info" ]  && [ "$3" = "" ]; then
  (cd $MTT_DOC ; make --silent mtt.info)
  echo "Invoking info in xterm"
  xterm -e info -f $MTT_DOC/mtt.info $2
  exit
fi

if [ "$1" = "help" ]; then
  mtt_help $2 $3
  exit
fi

if [ "$1" = "hinfo" ] && [$2 = ""]; then
   mtt_check_var "$HTMLVIEW" HTMLVIEW
  (cd $MTT_DOC/; make --silent mtt.html) 
   echo Invoking $HTMLVIEW
   (cd $MTT_DOC; $HTMLVIEW file://$MTT_DOC/mtt.html)&
   exit
fi

if [ "$1" = "manual" ] && [$2 = ""]; then
  mtt_check_var "$PDFVIEW" PDFVIEW
  (cd $MTT_DOC/; make --silent mtt.pdf) 
  echo Invoking $PDFVIEW 
  $PDFVIEW  $MTT_DOC/mtt.pdf &
  exit
fi

if [ $1 = "find" ]&& [$3 = ""]; then
    mtt_find $MTT_COMPONENTS $2
    find_status=$?
  if [ $find_status = "1" ]; then
    echo Component $2 not found - is MTT_COMPONENTS set correctly?
  fi
    exit $find_status
fi

if [ "$1" = "warranty" ] && [$2 = ""]; then
  cat << EOF
Copyright (C) 1989, 1990, 1991, 1992, 1993, 
              1994, 1995, 1996, 1997, 1998, 1999 Peter J. Gawthrop
This is free software with ABSOLUTELY NO WARRANTY.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

EOF
  exit
fi

# Start at abg representation
if [ -n "$start_at_abg" ]; then
  if [ -f "$1_abg.m" ]; then
    if [ "$quiet" != "quiet" ]; then
        echo Starting from $1_abg.m
    fi
  else
    echo $1_abg.m does not exist
    exit
  fi
fi

# Clean up 
if [ "$1" = "clean" ]; then
  echo Removing intermediate files in `pwd`
  rm -fr MTT_work
  exit
fi

# Recursively clean up
if [ "$1" = "rclean" ]; then
  echo 'Removing intermediate files recursively'
  dir2paths '.' | gawk '{print "mtt -q -d " $1 " clean " $2}' | sh
  exit
fi

# The big clean up
if [ "$1" = "Clean" ] && [ "$2" = "" ]; then
  echo 'Removing all generated files for all systems'
  rm -f *.log  mtt_info.txt warning.txt
  rm -f *_abg.ps *_args.*  *_cr.txt *_abg.tex
  rm -f *_sabg.fig *_sabg.ps *_head.fig *_bnd.fig 
  rm -f *_labg.fig *_lcbg.fig
  rm -f *_sympar.r *_sympar.c *_sympar.h *_sympar.txt? *_sympar.tex
  rm -f *_rbg.* *_cmp.* *_fig.fig *_*cbg.* *_ese.* *_def.* *_alias.*
  rm -f *_sub.* *_type.sh
  rm -f *_dae*.* *_cse.* *_ode.*
  rm -f *_obs.* *_rfe.* *_ss.*
  rm -f *_dm.* *_csm.*  *_tf.* *_sr*.* *_ir*.* *_*fr.*
  rm -f *_numpar.c *_input.m *_input.c *_switch.c *_switch.txt
  rm -f *_sm.* *_can.*
  rm -f *_struc.* *_sympar.txt *_sympar.c *_sympar.h *_sympar.m
  rm -f *_odes.c *_odes.dat *_odes.gdat *_odes.m *_odes.ps *_odes.sg
  rm -f *_odeso.dat *_odeso.gdat *_odeso.sdat *_odeso.m *_odeso.ps
  rm -f *_*.doc *_*.idx *_*.ind *_*.ilg *_*.dvi *_*.aux *_*.lof *_*.toc
  rm -f *_rep.tex
  rm -f  *_unique_raw_list *_raw_list
  rm -f mtt_error.txt mtt_info.txt *_ode2odes.out 
  rm -f *_*_write.r *_simpar.m *_simpar.p
  rm -f *_cseo.oct *_input.oct *_simpar.oct *_smxax.oct
  rm -f *_csex.oct *_numpar.oct *_smxa.oct *_state.oct 
  rm -f *_ode.oct *_odeo.oct
  rm -f *_cseo.mexglx *_input.mexglx *_simpar.mexglx *_smxax.mexglx
  rm -f *_csex.mexglx *_numpar.mexglx *_smxa.mexglx *_state.mexglx 
  rm -f *_ode.mexglx *_odeo.mexglx
  rm -f *_sfun.mexglx *_sfun_*.mexglx
  rm -f *_cseo.cc *_input.cc *_simpar.cc *_smxax.cc
  rm -f *_csex.cc *_numpar.cc *_smxa.cc *_state.cc 
  rm -f *_ode.cc *_odeo.cc
  rm -f *_logic.m *_logic.cc *_logic.oct
  rm -f *_state.m *_state.cc *_state.oct
  rm -f *_ode2odes.* *.dat2 MTT.core
  rm -f *_modpar.txt *_modpar.r
  rm -f *_ICD.txt *_ICD.c *_ICD.cc *_ICD.m
  rm -f *_ae.r *_ae.m *_ae.cc *_ae.oct
  rm -f *_sese.r *_sese.m
  rm -f *_sese.make *_sesx.* *_sesy.* _sae.*
  rm -fR *_rep MTT_work
  exit
fi

# Clean up named system
if [ "$2" = "Clean" ] && [ "$3" = "" ]; then
  echo 'Removing all generated files for system ' $1
  rm -f *.log  mtt_info.txt warning.txt
  rm -f $1_abg.ps $1_args.*  $1_cr.txt $1_abg.tex
  rm -f $1_sabg.fig $1_sabg.ps $1_head.fig $1_bnd.fig 
  rm -f $1_labg.fig $1_lcbg.fig
  rm -f $1_sympar.r $1_sympar.c $1_sympar.h $1_sympar.txt? $1_sympar.tex
  rm -f $1_rbg.* $1_cmp.* $1_fig.fig $1*_*cbg.* $1*_ese.* $1_def.* $1_alias.*
  rm -f $1_sub.* $1_type.sh
  rm -f $1_dae*.* $1_cse.* $1_ode.*  $1_obs.* $1_rfe.* $1_ss.*
  rm -f $1_dm.* $1_csm.* $1_tf.* $1_sr*.* $1_ir*.* $1_*fr.*
  rm -f  $1_numpar.m $1_numpar.c $1_input.m $1_input.c $1_switch.c $1_switch.txt
  rm -f $1_sm*.* $1_can.*
  rm -f $1_struc.* $1_sympar.txt $1_sympar.c $1_sympar.h $1_sympar.m
  rm -f $1_odes.c $1_odes.dat $1_odes.gdat $1_odes.sdat $1_odes.m $1_odes.ps $1_odes.sg
  rm -f $1_odeso.dat $1_odeso.gdat $1_odeso.m $1_odeso.ps
  rm -f $1_*.doc $1_*.idx $1_*.ind $1_*.ilg $1_*.dvi $1_*.aux $1_*.lof $1_*.toc
  rm -f $1_rep.tex
  rm -f $1_unique_raw_list $1_raw_list
  rm -f mtt_error.txt mtt_info.txt $1_ode2odes.out 
  rm -f $1_*_write.r $1_simpar.m $1_simpar.p
  rm -f $1_cseo.oct $1_input.oct $1_simpar.oct $1_smxax.oct
  rm -f $1_csex.oct $1_numpar.oct $1_smxa.oct $1_state.oct 
  rm -f $1_ode.oct $1_odeo.oct
  rm -f $1_cseo.mexglx $1_input.mexglx $1_simpar.mexglx $1_smxax.mexglx
  rm -f $1_csex.mexglx $1_numpar.mexglx $1_smxa.mexglx $1_state.mexglx 
  rm -f $1_ode.mexglx $1_odeo.mexglx
  rm -f $1_sfun.mexglx $1_sfun_*.mexglx
  rm -f $1_cseo.cc $1_input.cc $1_simpar.cc $1_smxax.cc
  rm -f $1_csex.cc $1_numpar.cc $1_smxa.cc $1_state.cc 
  rm -f $1_ode.cc $1_odeo.cc
  rm -f $1_logic.m $1_logic.cc $1_logic.oct 
  rm -f $1_state.m $1_state.cc $1_state.oct
  rm -f $1_ode2odes.* $1.dat2
  rm -f $1_modpar.txt $1_modpar.r
  rm -f $1_ICD.txt $1_ICD.c $1_ICD.cc $1_ICD.m
  rm -f $1_ae.r $1_ae.m $1_ae.cc $1_ae.oct
  rm -f $1_sese.r $1_sese.m
  rm -f $1_sese.make $1_sesx.* $1_sesy.* $1_sae.*
  rm -fR $1_rep MTT_work
  exit
fi

if [ "$2" = "rep" ]; then
     documenttype=article
      # See if we are making a book -- ie representation rep on a directory
     isMTT_work=`pwd | grep 'MTT_work'`
      if [ -n "$isMTT_work" ]; then
	dotdot='../'
      fi  

     #isdirectory=`file $dotdot$1 | gawk '{print $2}' | grep directory`
     if [ -d "$dotdot$1" ]; then
	documenttype=book
     fi
else
     documenttype=section
fi

case $2 in
    nyfr)
	NyquistStyle='True'
	;;
    nifr)
	NyquistStyle='True'
	;;
    *)
esac

#SUMMARY abg*	acausal bond graph (fig)
#SUMMARY abg*	acausal bond graph (dia)
#SUMMARY abg*	acausal bond graph (ps)
#SUMMARY abg*	acausal bond graph (view)
# Invoke explicit requests for modification
if [ "$2" = "abg" ] && [ "$3" = "fig" ]; then
  mtt_check_var "$FIG" FIG
  echo Editing $1_$2.$3
  ($FIG $1_$2.$3; cp $1_abg.fig $1_$1_abg.fig) &
  exit
fi

# Rename a system
if [ "$1" = "rename" ]; then
  mtt_rename_all $2 $3
  exit
fi

# Copy systems from the example library
if [ "$1" = "copy" ]; then
   #set up source and destination dirs
    source=$3
    if [ -z "$source" ]; then
      source=$MTT_EXAMPLES
    fi
    destination=$4
    if [ -z "${destination}" ]; then
      destination=$2
    fi      
# check that its not here already
  file_exists=`ls ${destination}/$2_abg.fig 2> /dev/null`
  if [ -n "$file_exists" ]; then
    if [ "$quiet" != "quiet" ]; then    
      echo System $2 exists already - no action taken
    fi
  else
    source=$3
    if [ -z "$source" ]; then
      source=$MTT_EXAMPLES
    fi
    destination=$4
    if [ -z "${destination}" ]; then
      destination=$2
    fi    
echo Copying system $2 from $source into directory ${destination}
    find $source -name "$2" -exec cp -fr {} . \;
    rm -rf ${destination}/CVS
  fi
  exit
fi

# Copy components from the library
if [ "$1" = "compcopy" ]; then

   #Pull out the base name (we may have a library as well)
   name=`basename $2`

   #set up source and destination dirs
    source=$3
    if [ -z "$source" ]; then
      source=$MTT_COMPONENTS
    fi
    destination=$4
    if [ -z "${destination}" ]; then
      destination='.'
    fi   

  # check that its not here already
  file_exists=`ls ${destination}/"$name"_abg.fig 2> /dev/null`
  if [ -n "$file_exists" ]; then
    if [ "$quiet" != "quiet" ]; then    
      echo Component $name exists already - no action taken
    fi
  else
    if [ $source = "." ]; then
      cp -u *_*.* ${destination}
    else
      comp_path=`mtt_find $source $2 path_only`
      n_found=`echo $comp_path | wc | gawk '{print $2}'`

      if [ "$n_found" = "1" ]; then
         echo Copying $2 from $comp_path to ${destination}
         cp $comp_path/*_*.* ${destination}
         exit 0
      elif [ "$n_found" = "0" ]; then
	if [ "$quiet" != "quiet" ]; then    
           echo Component $2 not found - is MTT_COMPONENTS set correctly?
        fi
         exit 1
      elif [ "$n_found" > "1" ]; then
         echo "Multiple versions of $2 found (see below) - use a more explicit alias"
         mtt -q find $2
         exit 2
      fi
    fi
  fi
  exit
fi

# Copy CRs from the library
if [ "$1" = "crcopy" ]; then
  # check that its not here already (or a _cr.r version)
  file_exists=`ls $2.cr $2_cr.r 2> /dev/null`
  if [ -n "$file_exists" ]; then
    if [ "$quiet" != "quiet" ]; then    
      echo $2.cr or $2_cr.r exists already - no action taken
    fi
  else
    path_name=$3
    if [ -z "$path_name" ]; then
	path_name=""
	for path in `echo $MTT_CRS | sed 's/:/ /g'`; do
	    path_name="$path_name $path/r"
	done
    fi
    echo Copying CR $2 to here from $3
    find $path_name -name "$2.cr" -exec cp {} . \;
  fi
  exit
fi


# Version control
VC=''

if [ "$3" = "vc" ]; then
  tidy=untidy;
  if [ -n "$4" ]; then
    log_message=$4
  else
    log_message="No Message"
  fi
  case $2 in
	abg )
		VC='ok'
		VCext='fig' ;;
	lbl )
		VC='ok'
		VCext='txt' ;;
	desc )
		VC='ok'
		VCext='tex' ;;
	simp )
		VC='ok'
		VCext='r' ;;
	rep )
		VC='ok'
		VCext='txt' ;;
	numpar )
		VC='ok'
		VCext='txt' ;;
	input )
		VC='ok'
		VCext='txt' ;;
	state )
		VC='ok'
		VCext='txt' ;;
	odes )
		VC='ok'
		VCext='h' ;;
	sspar )
		VC='ok'
		VCext='r' ;;
	*)
		echo Version control is not appropriate for representation $2
		exit  ;;
  esac
fi

# Classify the representation - needed for conversion route to postscript
PLOTTYPE='single';
case $2 in
	abg )
		REPTYPE='bg' ;;
	labg )
		REPTYPE='lbg' ;;
	sabg )
		REPTYPE='bg' ;;
	cbg )
		REPTYPE='bg' ;;
	input )
		REPTYPE='txt' ;;
	numpar )
		REPTYPE='txt' ;;
	state )
		REPTYPE='txt' ;;
	simpar )
		REPTYPE='txt' ;;
	obspar )
		REPTYPE='txt' ;;
	odes)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	odeso)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	sms)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	smso)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	odess)
		REPTYPE='data' ;;
	odesso)
		REPTYPE='data' ;;
	daes)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	daeso)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	ir)
		REPTYPE='data' ;;
	iro)
		REPTYPE='data' ;;
	sr)
		REPTYPE='data' ;;
	sro)
		REPTYPE='data' ;;
	fr)
		REPTYPE='data' ;;
	lmfr)
		REPTYPE='data' ;;
	lpfr)
		REPTYPE='data' ;;
	nyfr)
		REPTYPE='data' ;;
	nifr)
		REPTYPE='data' ;;
	*)
		REPTYPE='tex' ;;
esac


## Set up the main arguments
sys=$1
rep=$2
lang=$3

## Make ps pdf if -pdf set
if [ "$lang" = "ps" ]; then
  lang=$ps
fi


# Create some strings
Subsystem=$1$subsystem;

Subsystem_=$Subsystem"_"
Subsystem_ese=$Subsystem"_ese"
Subsystem_def=$Subsystem"_def"
Subsystem_rdae=$Subsystem"_rdae"
Subsystem_dae=$Subsystem"_dae"
Subsystem_subs=$Subsystem"_subs"
Subsystem_cr=$Subsystem"_cr"
Subsystem_cbg=$Subsystem"_cbg"


## Create the make target name
if [ -z "${using_oct}" ]; then
  target=${sys}_${rep}.${lang}    
else
  set_oct;
  if [ "${lang}" = "m" ]; then
    target=${sys}_${rep}.${m}
  else
    target=${sys}_${rep}.${lang}
  fi
fi 

##echo $target
##target=${sys}_${rep}.${lang}

## Arguments
ARGS=$4; _ARGS=-$4; __ARGS=`echo $_ARGS | tr ',' '-'`
__ARGS="${MTT_SWITCHES}${__ARGS}"
__ARGS=`echo ${__ARGS} | sed -e 's/-q//g' -e 's/-u//g'`

# Save up the argument list in a file; but only if argument has changed
#DIFF doesn't like empty files - so put a blank if empty
#if [ -z "$ARGS" ]; then
#  ARGS=' ';
#  _ARGS='';
#fi

#cat > $1_args.new <<EOF
#$ARGS
##EOF

#DIFF=`diff -bq $1_args.m $1_args.new 2>/dev/null`

#if [ -n "$DIFF" ]; then
#  mv $1_args.new $1_args.m
#fi

## If in MTT_work, then copy from -dr read dirs
this_dir=`basename $PWD`
if [ "${this_dir}" = "MTT_work" ]; then
  # Copy from read dirs to MTT_work
  for dir in ${read_dirs}; do
     if [ -n "$Verbose" ]; then
       echo Copying ${dir}/*
       cp --force ${dir}/* .
     else
       cp --force ${dir}/* . 2> /dev/null
     fi
    read_files=`echo ${dir}/*`
    for read_file in ${read_files}; do
     read_file_name=`basename ${read_file}`
     touch ${read_file_name}
    done
   done
fi

# Tidy mode - operate in the directory MTT-work
if [ "$tidy" = "tidy" ] && [ "$level" = "0" ]; then
    # make sure that a system exists in this directory
    if [ "${sys}_${rep}.${lang}" != "${sys}_abg.dia" ] && [ "${sys}_${rep}.${lang}" != "${sys}_abg.fig" ]; then
	nabgs=`ls ${sys}_abg.* 2>/dev/null | wc -l`
	if [ $nabgs -eq 0 ]&&[ -z "$sensitivity" ]; then
	    echo "MTT Error: System $sys does not exist"
	    exit -1;
	fi
    fi
   mkdir -p MTT_work
   valid_files=`ls | grep -v '^MTT'`
   ##cp -p -u  Makefile Make *.* .* MTT_work  2>/dev/null
   cp -p -u -R --force ${valid_files} MTT_work  2>/dev/null

   # Go to MTT_work
   cd MTT_work

   if [ -f ".octaverc" ]; then
     touch .octaverc
   else
     echo Copying .octaverc 
     cp $MTT_LIB/octave/.octaverc .
   fi

   if [ -f "useful-functions.hh" ]; then
     touch useful-functions.hh
   else
     echo Copying useful-functions.hh
     cp $MTT_CC/include/useful-functions.hh .
   fi

   if [ -z "$directory" ]; then
     Directory=''
   else
     Directory=$directory/MTT_work
   fi

     mtt -u -q  $mtt_switches -S "$Directory"  $1 $2 $3 $4
     mtt_status=$?

   # Exit on failure
   if [ "$mtt_status" != "0" ]; then
     echo Exiting MTT with error $mtt_status
     exit 1
   fi

  # Copy back from working directory
   if [ "$3" != "view" ] && [ "$3" != "hview" ] && [ -z "$reset" ]; then
      if [ "$3" = "html" ]; then
	  echo Moving $1_$2
          mv $1_$2 ..
      else
        if [ "$PLOTTYPE" = "multiple" -a -f $1_$2__ARGS.$ps ]; then
          echo Copying  $1_$2$__ARGS.$ps
          cp  $1_$2$__ARGS.$ps ..
        else
	    if [ -f $1$subsystem"_"$2.$lang ]; then
		echo Copying  $1$subsystem"_"$2.$lang
		cp  -p -u $1$subsystem"_"$2.$lang ..
	    fi
        fi
      fi
    fi

   # Remove the MTT_work directory if very tidy
   if [ "$verytidy" = "verytidy" ]; then
    echo Removing all working files
    rm -rf ../MTT_work
  fi
exit
fi 

# User defined representations
## Copy from library if not already here

## .make versions
if [ -f "$MTT_REP/$2_rep.make" ]; then
  if [ -f "$2_rep.make" ]; then
    echo Using $2_rep.make
  else
    echo Copying $2_rep.make from $MTT_REP
    cp $MTT_REP/$2_rep.make .
  fi
fi

if [ -f "$2_rep.make" ]; then
   if [ -n "$4" ]; then
      filename=$1_$2-$4.$3
   else
      filename=$1_$2.$3
   fi

   #if [ -f "$filename" ]; then
   #   echo $filename exists
   #else
   if [ ! -f "$2_rep.make.ignore" ]; then
       if [ -n "$Verbose" ]; then
	   echo make -s -f $2_rep.make "MTT_SYS=$1" "MTT_LANG=$3" "MTT_ARG=$4" "MTT_OPTS=$mtt_switches" 
       fi
       make -s -f $2_rep.make "MTT_SYS=$1" "MTT_LANG=$3" "MTT_ARG=$4" "MTT_OPTS=$mtt_switches"
       if [ -n "$4" ]; then
	   echo Copying  $1_$2$__ARGS.$ps
	   cp  $1_$2$__ARGS.$ps ..
       fi
   #fi
       exit
   fi
fi

## Check for pre version 4.0 integration method specification.
if [ $level = "0" ]; then
  if [ -f "$1_simpar.txt" ]; then
    method_line=`grep -i METHOD  $1_simpar.txt`
    if [ -n "`echo $method_line | grep -i euler`" ]; then
      echo Obsolete $1_simpar.txt contains: $method_line
      echo "    please use mtt -i euler in future"
      mtt_switches="$mtt_switches -i euler";
    elif [ -n "`echo $method_line | grep -i implicit`" ]; then
      echo Obsolete $1_simpar.txt contains: $method_line
      echo "    please use mtt -i implicit in future"
      mtt_switches="$mtt_switches -i implicit";
    fi
  fi
fi

if [ -n "$reset" ]; then
  if [ -f "$1_$2.$3" ]; then
    echo Resetting time stamp on $1_$2.$3
    touch $1_$2.$3
  else
    echo $1_$2.$3 does not exist - no action taken
  fi
  exit;    
fi


if [ -n "$sensitivity" ]; then
  sys_s=`echo $1 | cut -c 2-`
  sys_abg=${sys_s}_abg
fi

## Check octave version
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) define_octave_dev="";;			# stable 
    1) define_octave_dev="-DOCTAVE_DEV";;	# development
    *) define_octave_dev="-DOCTAVE_DEV";;
esac

################################
# This is the main mtt programme
################################

#echo Target is $target, Subsystem is $Subsystem, options are $mtt_switches
##<<<<<<< mtt
##$MAKE  -S ${trace} ${verbose}  -f  -  ${target} << EOF
##=======
##$MAKE -S $verbose $verbose_make -f  -  $target << EOF
##>>>>>>> 1.316
$MAKE -S ${trace} $verbose $verbose_make -f  -  $target << EOF

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files
$1_%.oct:  $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Creating $1_\$*.oct; $MKOCTFILE ${MTT_CXXINCS} -DCODEGENTARGET=OCTAVEDLD $1_\$*.cc

## pdf files from ps (new version)
$1_%.pdf:  $1_%.ps
	echo Creating $1_\$*.pdf; ps2pdf  $1_\$*.ps $1_\$*.pdf

## eps from ps (NB ps files are actually eps anyway)
$1_%.eps:  $1_%.ps
	echo Creating $1_\$*.eps; cp  $1_\$*.ps $1_\$*.eps

.PRECIOUS: mtt_%.oct
.PRECIOUS: $1_%.oct
mtt_%.oct: mtt_%.cc
	echo Compiling \$<
	${MKOCTFILE} ${MTT_CXXINCS} -DCODEGENTARGET=OCTAVEDLD $define_octave_dev \$<

## .mex files
$1_%.mexglx: $1_%.cc $1_def.h $1_sympar.h $1_cr.h mtt_kpathsea.cc mtt_matlab_octave.cc mtt_matlab_octave.hh
	echo Creating $1_\$*.mexglx
	${MTT_CXX} -shared -o $1_\$*.mexglx $1_\$*.cc \
	${MTT_MATLAB_FLAGS} -DCODEGENTARGET=MATLABMEX \
	${MTT_CXXINCS} ${MTT_CXXLIBS} ${MTT_CXXFLAGS} mtt_kpathsea.cc mtt_matlab_octave.cc

## .cc files
.PRECIOUS: %.cc # Don't let mtt delete them
.PRECIOUS: $1_%.cc # Don't let mtt delete them
$1_%.cc:  $1_%.m
	mtt_m2cc.sh  $1 \$* cc cat 

mtt_%.cc:: ${MTT_LIB}/cc/mtt_%.cc
	cp ${MTT_LIB}/cc/mtt_\$*.cc mtt_\$*.cc

mtt_%.hh:: ${MTT_LIB}/cc/mtt_%.hh
	cp ${MTT_LIB}/cc/mtt_\$*.hh mtt_\$*.hh

## .o files
.PRECIOUS: $1_%.o
$1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Compiling $1_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE

.PRECIOUS: mtt_%.o
mtt_%.o: mtt_%.cc
	echo Compiling mtt_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE $define_octave_dev

# Copy aliased subsystems
$1_aliased_subsystems_copied: 
	lbl2component $1 | sh || exit 1 # Grab specified components now
	touch $1_aliased_subsystems_copied

# Generates code to write reduce code
$1_ode_write.r: $1_def.m
	def2write_r  $1 $2 $computation

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")
$1_abg.fig: $sys_abg.fig
	abg2sensitivity_fig $sys_s
else # Either find the sensitivity model or fetch the model and create sensitivity model
$1_abg.fig:
	mtt -q -u $mtt_switches compcopy $1 || abg2sensitivity_fig $sys_s
endif
endif

ifneq ("$sensitivity","sensitivity")
ifneq ("$level","0")
# If level>0, try and get subsystem files; creating if necessary
ifneq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_abg.fig:
	mtt -q -u $mtt_switches compcopy $1
else
$1_abg.fig:
endif
endif
endif

# Create an arg file if it doesn't exist
$1_args.m:
	touch $1_args.m

#Create list of components
ifeq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_cmp.txt: $1_abg.dia
	abg2cmp_dia2txt $1
else
$1_cmp.txt: $1_abg.fig
	abg2cmp_fig2txt $1
endif

#Create skeleton files (with titles) if not already there
#SUMMARY lbl*	label file (txt)
#SUMMARY lbl	label file (txt)
#SUMMARY lbl*	label file (view)
#SUMMARY lbl	label file (view)
#SUMMARY lbl*	label file (tex)
#SUMMARY lbl	label file (tex)
$1_lbl.txt: $1_cmp.txt
	cmp2lbl_txt $1 $sensitivity
	touch $1_lbl.txt

$1_lbl.tex: $1_lbl.txt
	lbl_txt2tex $1

#SUMMARY alias  name aliases for each subsystem (txt)
$1_alias.txt: $1_lbl.txt
	lbl2alias_txt2txt $1

#SUMMARY modpar  name modulated parameters for each subsystem (txt)
$1_modpar.txt: $1_lbl.txt
	lbl2modpar_txt $1

#SUMMARY modpar  name modulated parameters for each subsystem (r)
$1_modpar.r: $1_modpar.txt $1_struc.txt
	modpar_txt2r $1

#SUMMARY alias  name aliases for each subsystem (m)
$1_alias.m: $1_alias.txt
	alias_txt2m $1

##SUMMARY icd	interface definition for system (c)
##SUMMARY icd	interface definition for system (cc)
##SUMMARY icd	interface definition for system (m)
##SUMMARY icd	interface definition for system (txt)

$1_ICD.c: $1_ICD.txt
	ICD_txt2lang.sh $1 c

$1_ICD.cc: $1_ICD.txt
	ICD_txt2lang.sh $1 cc

$1_ICD.m: $1_ICD.txt
	ICD_txt2lang.sh $1 m

$1_ICD.txt: $1_icd.txt2
	icd2ICD_txt22txt.sh $1

$1_icd.txt2: $1_ese.r
	touch $1_icd.txt2

#SUMMARY icd	interface definitions for each subsystem (m)
$1_icd.m: $1_icd.txt
	icd_txt2m.sh $1

#SUMMARY icd	interface definitions for each subsystem (txt)
$1_icd.txt: $1_lbl.txt
	lbl2icd_txt2txt.sh $1

#SUMMARY cr	constitutive relationship for each subsystem (txt)
$1_cr.txt: $1_abg.m $1_sub.sh
	abg2cr_m2txt $1

	if [ "$level" = "0" ]; then \
	  mv $1_cr.txt MTT_cr.txt; \
	else \
	  cat $1_cr.txt >> MTT_cr.txt; \
	fi

	sh $1_sub.sh "rm -f " '_cr.txt' # Remove the txt.cr files
	sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' cr txt' #Create new ones

	if [ "$level" = "0" ]; then \
	  sort -u MTT_cr.txt> $1_cr.txt; \
	fi

#SUMMARY cr	constitutive relationship for each subsystem (r)
$1_cr.r: $1_cr.txt
	cr_txt2r $1

#SUMMARY cr	constitutive relationship header (c)
$1_cr.h: 
	echo Creating $1_cr.h
	echo "/* CR headers for system $1 */" > $1_cr.h

# Cheat a bit and use the top level cr file for the subsystem as well
ifneq ($sub,)
$Subsystem_cr.r: $1_cr.r
	echo Creating $Subsystem_cr.r "(copying $1_cr.r)"
	cp $1_cr.r $Subsystem_cr.r
endif
#SUMMARY cr	constitutive relationship for each subsystem (tex)
#SUMMARY cr	constitutive relationship for each subsystem (view)
$1_cr.tex: $1_cr.r
	txt2tex $1 cr r

#SUMMARY sympar	symbolic parameters (txt)
#SUMMARY sympar*	symbolic parameters (view)
$1_sympar.txt: $1_type.sh $1_abg.m $1_aliased.txt
	mtt_make_sympar $1 ${use_reduce}

#SUMMARY sympar	symbolic parameters (r)
$1_sympar.r: $1_sympar.txt
	sympar_txt2r $1
$1_sympar.m: $1_sympar.txt
	sympar_txt2m $1
ifneq ($sort_method,make)
$1_sympar.h: $1_sympar.txt
	sympar_txt2h.sh $1 $num_tmp_var
else
$1_sympar.h: $1_sympar.txt $1_sese.make
	sympar_txt2h.sh $1 $num_tmp_var
	declaration="static double" \
	make -f $1_sese.make declare_tmpvars |\
	tr [A-Z] [a-z] >> \$@
endif

#SUMMARY sympar	symbolic parameters (c)
# txt to c sympar conversion
$1_sympar.c: $1_sympar.txt
	sympar_txt2c $1

#SUMMARY sympar	symbolic parameters (tex)
# txt to tex (LaTeX) sympar conversion
$1_sympar.tex: $1_sympar.txt
	sympar_txt2tex $1

#SUMMARY logic	Dynamic switch logic (tex)
#SUMMARY logic	Dynamic switch logic (view)
$1_logic.tex: $1_logic.txt
	txt2tex $1 logic txt


#SUMMARY switch	Dynamic switch information (txt)
$1_switch.txt: $1_struc.txt
	struc2switch_txt $1
#$1_switchopen.m: $1_switch.txt $1_sympars.txt $1_logic.txt
#	switch_txt2m $1

#SUMMARY sympars sympar + dynamic switch information (txt)
$1_sympars.txt: $1_sympar.txt $1_switch.txt
	   echo Creating $1_sympars.txt
	   cat $1_sympar.txt $1_switch.txt > $1_sympars.txt

#SUMMARY simp	simplification information (r)
$1_simp.r:
	echo Creating $1_simp.r
	( \
	echo "%% Reduce commands to simplify output for system $1 ($1_simp.r)"; \
	cat $MTTPATH/trans/m/rcs_header.txt; \
	    echo 'ON ALLFAC; %Multiplicative factors'; \
	    echo 'OFF DIV; %Polynomial division'; \
	    echo 'OFF FACTOR; %Factorise polynomials'; \
	    echo 'OFF LIST; %Each term on a new line'; \
	    echo 'FOR ALL x,y LET pow(x,y) = x^y; %Readable pow function'; \
	echo 'END;'; \
	)> $1_simp.r

#SUMMARY subs  algebraic substitution (r)
$Subsystem_subs.r: 
	mtt $mtt_switches -q -u $1 sympar txt; 
	makesubs $Subsystem;

#SUMMARY obspar  GPC observability function parameters (r)
$1_obspar.r:
	echo Creating $1_obspar.r
	( \
	echo "%% Reduce  GPC observability function parameters for system $1 ($1_obspar.r)"; \
	cat $MTTPATH/trans/m/rcs_header.txt; \
	echo 'MTTGPCNy := 5;'; \
	echo 'MTTGPCNu := 0;'; \
	echo 'Matrix MTTdU(5,1);'; \
	echo 'MTTdU(1,1) := MTTdU1;'; \
	echo 'MTTdU(2,1) := MTTdU2;'; \
	echo 'MTTdU(3,1) := MTTdU3;'; \
	echo 'MTTdU(4,1) := MTTdU4;'; \
	echo 'MTTdU(5,1) := MTTdU5;'; \
	echo 'Matrix MTTUU(1,5);'; \
	echo 'MTTUU(1,1) := MTTu1;'; \
	echo 'MTTUU(1,2) := MTTu11;'; \
	echo 'MTTUU(1,3) := MTTu12;'; \
	echo 'MTTUU(1,4) := MTTu13;'; \
	echo 'MTTUU(1,5) := MTTu14;'; \
	echo 'END;'; \
	)> $1_obspar.r

#SUMMARY simpar	simulation information (txt)
$1_simpar.txt:
	echo Creating $1_simpar.txt
	( \
	echo '# -*-octave-*- Put Emacs into octave-mode'; \
	echo "# Simulation parameters for system $1 ($1_simpar.txt)"; \
	echo "# Generated by MTT on" `date`.; \
	cat $MTTPATH/trans/rcs_header.sh; \
	echo ;\
	echo 'FIRST        = 0.0;       # First time in simulation output'; \
	echo 'DT          = 0.1;        # Print interval'; \
	echo 'LAST        = 10.0;       # Last time in simulation'; \
	echo 'STEPFACTOR  = 1;          # Integration steps per print interval'; \
	echo 'WMIN        = -1;         # Minimum frequency = 10^WMIN'; \
	echo 'WMAX        = 2;          # Maximum frequency = 10^WMAX'; \
	echo 'WSTEPS      = 100;        # Number of frequency steps'; \
	echo 'INPUT       = 1;          # Index of the input'; \
	)> $1_simpar.txt

#SUMMARY simpar	simulation information (m)
$1_simpar.m: $1_simpar.txt $1_def.r $1_sympar.txt
	mtt_txt2m $1 simpar


#SUMMARY numpar	numerical parameter declaration -- default (txt) 
$1_numpar.txt : $1_sympar.txt $1_def.r
ifeq ($target,$1_numpar.txt)
	mtt_update $1 numpar update
else
	mtt_update $1 numpar
endif

#SUMMARY state	numerical state declaration  -- default (txt)
ifeq ($steadystate_computation,yes)
$1_state.txt : $1_struc.txt $1_sympar.txt $1_def.r $1_ss.r
else
$1_state.txt : $1_struc.txt $1_sympar.txt $1_def.r
endif

ifeq ($target,$1_state.txt)
	mtt_update $1 state update
else
	mtt_update $1 state
endif

#SUMMARY input	numerical state declaration  -- default (txt)
$1_input.txt : $1_struc.txt $1_sympar.txt
ifeq ($target,$1_input.txt)
	mtt_update $1 input update
else
	mtt_update $1 input
endif

#SUMMARY logic	Dynamic switch logic (txt)
$1_logic.txt : $1_def.r $1_struc.txt $1_sympar.txt
ifeq ($target,$1_logic.txt)
	mtt_update $1 logic update
else
	mtt_update $1 logic
endif

# Dummy target
FORCE:

ifeq ($use_reduce,yes)
$1_ode2odes_common_%.stamp: $1_ae.% $1_input.% $1_logic.% $1_numpar.% $1_simpar.% $1_state.%
	touch \$@
$1_ode2odes_common.o: $1_ae.o $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o
	@echo "Creating $1_ode2odes_common.o"
	ar -cr \$@ \$^
else
$1_ode2odes_common_%.stamp: $1_sae.% $1_input.% $1_logic.% $1_numpar.% $1_simpar.% $1_state.%
	touch \$@
$1_ode2odes_common.o: $1_sae.o $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o
	@echo "Creating $1_ode2odes_common.o"
	ar -cr \$@ \$^
endif

ifeq ($use_reduce,yes)
$1_ode2odes_euler_%.stamp $1_ode2odes_rk4_%.stamp: $1_ode.% $1_odeo.%
	touch \$@
$1_ode2odes_euler.o $1_ode2odes_rk4.o: $1_ode.o $1_odeo.o mtt_euler.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
else
$1_ode2odes_euler_%.stamp $1_ode2odes_rk4_%.stamp: $1_sesx.% $1_sesy.%
	touch \$@
$1_ode2odes_euler.o $1_ode2odes_rk4.o: $1_sesx.o $1_sesy.o mtt_euler.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
endif

ifeq ($use_reduce,yes)
$1_ode2odes_implicit_%.stamp: $1_cseo.% $1_csex.% $1_smxa.% $1_smxax.%
	touch \$@
$1_ode2odes_implicit.o: $1_cseo.o $1_csex.o $1_smxa.o $1_smxax.o mtt_implicit.o
	@echo "Creating $1_ode2odes_implicit.o"
	ar -cr \$@ \$^
endif				# no alternative

ifeq ($use_reduce,yes)
$1_ode2odes_dassl_oct.stamp: $1_ode.oct $1_odeo.oct mtt_dassl.oct
	touch \$@
$1_ode2odes_dassl_o.stamp: $1_ode.o $1_odeo.o mtt_dassl.o
	touch \$@
$1_ode2odes_dassl_%.stamp: $1_ode.% $1_odeo.%
	touch \$@
$1_ode2odes_dassl.o: $1_ode.o $1_odeo.o mtt_dassl.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
else
$1_ode2odes_dassl_oct.stamp: $1_sesx.oct $1_sesy.oct mtt_dassl.oct
	touch \$@
$1_ode2odes_dassl_o.stamp: $1_sesx.o $1_sesy.o mtt_dassl.o
	touch \$@
$1_ode2odes_dassl_%.stamp: $1_sesx.% $1_sesy.%
	touch \$@
$1_ode2odes_dassl.o: $1_sesx.o $1_sesy.o mtt_dassl.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
endif

$1_ode2odes_${algebraic_solver}.cc:	mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.hh mtt_${algebraic_solver}.cc

$1_ode2odes_${algebraic_solver}.o:	mtt_Solver.o  mtt_AlgebraicSolver.o  mtt_${algebraic_solver}.o
	@echo "Creating $1_ode2odes_${algebraic_solver}.o"
	ar -cr \$@ \$^

#SUMMARY numpar	numerical parameter declaration (m) 
$1_numpar.m:  $1_numpar.txt $1_sympars.txt
	mtt_txt2m $1 numpar

#SUMMARY numpar	numerical parameter declaration (c) 
#SUMMARY numpar	numerical parameter declaration (view) 
$1_numpar.c:  $1_numpar.txt $1_sympar.c
	txt2c $1 numpar



#SUMMARY logic	logic input declaration (m) 
$1_logic.m:  $1_logic.txt $1_switch.txt
	mtt_txt2m $1 logic

#SUMMARY state	state declaration  -- default (txt)
#$1_state.txt: 
#	mtt $mtt_switches $1 struc txt; 
#	mtt $mtt_switches $1 ss r; 
#	struc2state_txt2txt $1

#SUMMARY state	state declaration (m) 
$1_state.m:  $1_state.txt $1_sympars.txt
	mtt_txt2m $1 state

#SUMMARY desc Verbal description of system (tex)
$1_desc.tex:
	makedesc $1


#SUMMARY params	symbolic parameter setting (r)
 $1_params.r: 
	echo Creating $1_params.r
	( \
	echo "%% Parameter file for system $1 ($1_params.r)"; \
	echo "%% This file provides symbolic parameters for simplification";\
	cat $MTTPATH/trans/m/rcs_header.txt; \
	echo 'END;'; \
	)> $1_params.r


#SUMMARY sspar	steady-state definition (r)
$1_sspar.r: 
	struc2sspar_txt2r $1

#SUMMARY sspar	steady-state parameters (tex)
#SUMMARY sspar	steady-state parameters (view)
$1_sspar.tex: $1_sspar.r
	txt2tex $1 sspar r

#SUMMARY rep*	report (txt)
#SUMMARY rep	report (tex)
#SUMMARY rep*	report (view)
#SUMMARY rep*	report (html)


ifeq ($documenttype,book)
$1_rep.txt:
	dir2rep $1 $dotdot;
else
$1_rep.txt:
	makerep_txt $1;
endif

#SUMMARY rbg	raw bond graph (m)
#Raw bond graph: fig file to mfile
$1_rbg.m: $1_abg.fig  $1_lbl.txt
	rbg_fig2m $1 $no_alpha_sort

$1_cmp.m: $1_lbl.txt $1_cmp.txt
	lbl2cmp_txt2m.pl --sys=$1 --$debug

$1_fig.fig: $1_rbg.m

#SUMMARY sabg	stripped acausal bond graph (fig)
#SUMMARY sabg	stripped acausal bond graph (ps)
#SUMMARY sabg	stripped acausal bond graph (view)
$1_sabg.fig: $1_rbg.m

#SUMMARY labg	latex-ready acausal bond graph (fig)
$1_labg.fig: $1_rbg.m
$1_labg.tex: $1_labg.fig
	fig2dev -L pstex_t -p $1_labg.eps $1_labg.fig $1_labg.tex
	fig2dev -L pstex $1_labg.fig $1_labg.eps
	cp -v $1_labg.eps ..

#Subsystem creation commands
#SUMMARY sub Executable subsystem list (sh)
ifeq ($start_at_abg,yes)
$1_sub.sh: $1_abg.m
	abg2sub_m2sh $1
else
$1_sub.sh: $1_cmp.txt $1_aliased_subsystems_copied
	cmp2sub_txt2sh $1
endif

#SUMMARY sub LaTeX subsystem list (tex)
#SUMMARY sub subsystem list (ps)
#SUMMARY sub subsystem list (view)
$1_sub.tex: $1_sub.sh
ifeq ($documenttype,section)
	sub_sh2tex $1
else
	sub_sh2tex -l $1
endif

#SUMMARY abg	acausal bond graph (m)
#Raw bond graph to acausal bond graph: mfile

ifneq ($start_at_abg,yes)
$1_abg.m: $1_ibg.m $1_cmp.m $1_lbl.txt $1_alias.m $1_sub.sh $1_icd.m
	@echo "Creating \$@"
	(sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' abg m null  || exit 1') || exit 1
	ibg2abg_m $info_switch $1
endif

ifeq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_ibg.m: $1_abg.dia $1_alias.m
	abg2ibg_dia2m $1
else
$1_ibg.m: $1_abg.fig $1_rbg.m
	@echo "Creating \$@"
	rbg2ibg_m $info_switch $1
endif

$1_connections.dat: $1_abg.m
	abg2connections_m2dat $1

#SUMMARY cbg*	causal bond graph (m)
#Acausal bond graph to causal bond graph: mfile
$1_cbg.m: $1_abg.m
	abg2cbg_m  $info_switch $causality_switch $1

$1_type.sh: $1_cbg.m
	touch $1_type.sh

#SUMMARY cbg*	causal bond graph (fig)
#SUMMARY cbg*	causal bond graph (dia)
#SUMMARY cbg*	causal bond graph (ps)
#SUMMARY cbg*	causal bond graph (view)
#Causal bond graph: mfile to fig conversion
$1_cbg.fig: $1_cbg.m  $1_fig.fig $1_type.sh
	sh $1_type.sh 'echo cbg_m2fig ' ' ' ' ' | sh

$1_cbg.dia: $1_cbg.m
	@sh $1_type.sh 'cbg_m2dia ' ' ' ' '

#SUMMARY ese	elementary system equations (r)
#SUMMARY def	definitions - system orders etc. (r)
#SUMMARY def	definitions - system orders etc. (m)
#SUMMARY def	definitions - system orders etc. (h)
#SUMMARY struc*	structure - list of inputs, outputs and states (txt)
#SUMMARY struc	structure - list of inputs, outputs and states (tex)
#SUMMARY struc*	structure - list of inputs, outputs and states (view)
#SUMMARY sum	structure summary - matrix of inputs, outputs and states (tex)
#SUMMARY sum*	structure summary - matrix of inputs, outputs and states (view)
#Elementary system equations + definitions
${sys}_ese.r: ${sys}_cbg.m
	   cbg2ese_m2r $partition $info_switch $Subsystem; #ese_tidy $1

ifeq ($sort_method,seqn)
${sys}_sese.m: ${sys}_def.r ${sys}_sese.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sese m
${sys}_sese.r: ${sys}_cbg.m ${sys}_struc.m
	echo Creating \$@
	cbg2sese_m2r $info_switch $Subsystem
endif

ifeq ($sort_method,make)
${sys}_sesx.m: ${sys}_def.r ${sys}_sesx.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sesx m
${sys}_sesy.m: ${sys}_def.r ${sys}_sesy.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sesy m
${sys}_sae.m: ${sys}_def.r ${sys}_sae.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sae m

${sys}_sese.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTdX MTTy > \$@
	echo 'END;' >> \$@
${sys}_sesx.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTdX > \$@
${sys}_sesy.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTy  > \$@
${sys}_sae.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTyz > \$@

${sys}_sese.make: ${sys}_ese.txt
	echo Creating \$@
	ese_txt2make.pl --sys=${sys} --infile=${sys}_ese.txt --outfile=\$@ --$debug

${sys}_ese.txt: ${sys}_ese.r ${sys}_cr.txt perl_crs.stamp
	echo Creating \$@
	ese_r2txt.pl < \$< |\
	apply_crs ${sys} > \$@

perl_crs.stamp:
	echo Copying CRs from ${MTT_LIB}/cr/perl
	mkdir -p mtt
	cp ${MTT_LIB}/cr/perl/*.pm mtt/
	touch \$@
endif

$1_def.r: $1_ese.r
	touch $1_def.r
$1_struc.txt: $1_ese.r
	touch $1_struc.txt
$1_aliased.txt: $1_ese.r
	touch $1_aliased.txt
$1_struc.tex: $1_struc.txt
	struc_txt2tex $1
$1_sum.tex: $1_struc.txt
	struc2sum_txt2tex $1
$1_struc.m: $1_struc.txt 
	struc_txt2m $1
$1_def.m: $1_def.r
	def_r2m $1; matlab_tidy $1_def.m;
$1_def.h: $1_def.m $1_sympar.txt
	def_m2h.sh $1

#SUMMARY rdae	raw differential-algebraic equations (r)
#SUMMARY dae	differential-algebraic equations (r)
#SUMMARY dae*	differential-algebraic equations (m)
#SUMMARY dae	differential-algebraic equations (tex)
#SUMMARY dae*	differential-algebraic equations (view)
#SUMMARY dae	differential-algebraic equations (ps)
#Differential-algebraic equations

ifeq ($do_sort,)
${sys}_rdae.r: ${sys}_ese.r ${sys}_def.r $1_modpar.r ${Subsystem}_cr.r ${Subsystem}_subs.r
else
${sys}_rdae.r: ${sys}_sese.r ${sys}_def.r $1_modpar.r ${Subsystem}_cr.r ${Subsystem}_subs.r
endif
ifneq ($partition,)
	echo Doing subsystems
	mtt_make_subsystems  ${sys} rdae r
endif
	mtt_prepend.sh -p $1_modpar.r $1_ese.r # Add modulated parameters to start
	ese2rdae_r ${cr_first} ${fixcc} ${do_sort} ${Subsystem}
	tidy ${Subsystem}_rdae.r

${sys}_dae.r: ${Subsystem}_rdae.r ${Subsystem}_def.r ${Subsystem}_subs.r ${Subsystem}_cr.r
ifneq ($partition,)
	echo Doing subsystems
	mtt_make_subsystems  ${sys} dae r
endif
ifeq ($rdae_is_dae,1)
	echo Copying $1_rdae.r to $1_dae.r
	cp $1_rdae.r  $1_dae.r
else
	rdae2dae_r ${fixcc} ${Subsystem}; tidy ${Subsystem}_dae.r
endif

$1_dae.m: $1_def.r $1_dae.r  $1_sympars.txt
	dae_r2m $1; matlab_tidy $1_dae.m; matlab_tidy $1_daeo.m
$1_dae.c: $1_def.r $1_dae.r  $1_sympar.r
	dae_r2c $1; c_tidy $1_dae.c
$1_dae.tex: $1_dae.r $1_simp.r
	dae_r2tex $partition $1; latex_tidy $1_dae.tex

#SUMMARY ae	algebraic equations - unknown inputs (r)
#SUMMARY ae	algebraic equations - unknown inputs (m)
#SUMMARY ae	algebraic equations - unknown inputs (cc)

ifeq ($algebraic_solver,noAlgebraicSolver)
$1_ae.r:
else
$1_ae.r: $1_cse.r
endif
	touch \$@

$1_ae.m: $1_ae.r
	mtt_r2m $1 ae

#SUMMARY cse	constrained-state equations (r)
#SUMMARY cse*	constrained-state equations (m)
#SUMMARY cse*	constrained-state equations (oct)
#SUMMARY cse	constrained-state equations (tex)
#SUMMARY cse*	constrained-state equations (view)
#SUMMARY cse	constrained-state equations (ps)
#Constrained-state equations
${sys}_cse.r: ${Subsystem}_dae.r ${Subsystem}_dae.r ${Subsystem}_def.r ${Subsystem}_subs.r 
ifneq ($partition,)
	echo Doing subsystems
	mtt_make_subsystems  ${sys} cse r
endif
	dae2cse_r $fixcc $optimise $Solve ${Subsystem}; tidy ${Subsystem}_cse.r #$1_subs.r
$1_csex.r: $1_cse.r
	touch $1_csex.r
$1_cseo.r: $1_cse.r
	touch $1_cseo.r

#$1_cse.m: $1_def.r $1_cse.r $1_sympar.r  $1_subs.r 
#	cse_r2m $1; matlab_tidy $1_cse.m
${sys}_cse.m: ${Subsystem}_def.r ${Subsystem}_cse.r ${sys}_sympars.txt
ifneq ($partition,)
	echo Doing subsystems
	mtt_cp_subrep ${sys} sympars txt
	mtt_make_subsystems  ${sys} cse m
endif
	mtt_r2m ${Subsystem} cse;#  matlab_tidy $1_cse.m; matlab_tidy $1_cseo.m; 

${sys}_cseo.m: ${Subsystem}_def.r ${Subsystem}_cseo.r ${sys}_sympars.txt
ifneq ($partition,)
	echo Doing subsystems
	mtt_cp_subrep ${sys} sympars txt
	mtt_make_subsystems  ${sys} cseo m
endif
	mtt_r2m ${Subsystem} cseo

${sys}_csex.m: ${Subsystem}_def.r ${Subsystem}_csex.r ${sys}_sympars.txt
ifneq ($partition,)
	echo Doing subsystems
	mtt_cp_subrep ${sys} sympars txt
	mtt_make_subsystems  ${sys} csex m
endif
	mtt_r2m ${Subsystem} csex

$1_cse.tex: $1_cse.r  $1_sympar.r $1_simp.r
	cse_r2tex $1 $2; latex_tidy $1_cse.tex


#SUMMARY scse	sensitivity constrained-state equations (r)
#SUMMARY scse	sensitivity constrained-state equations (tex)
#SUMMARY scse	sensitivity constrained-state equations (ps)

$1_scse.r: $1_cse.r $1_def.r 
	cse2scse_r  $1 "$4"; tidy $1_scse.r

#$1_cse.m: $1_def.r $1_cse.r $1_sympar.r  $1_subs.r 
#	cse_r2m $1; matlab_tidy $1_cse.m
$1_scse.m: $1_def.m $1_scse.r $1_sympars.txt
	mtt_r2m $optimise  -parameters $1 scse;  
	matlab_tidy $1_scse.m; matlab_tidy $1_scseo.m; 

$1_scse.tex: $1_scse.r  $1_sympar.r $1_simp.r
	cse_r2tex $1 $2; latex_tidy $1_scse.tex


#SUMMARY ode	ordinary differential equations (r)
#SUMMARY ode*	ordinary differential equations (m)
#SUMMARY ode	ordinary differential equations (c)
#SUMMARY ode	ordinary differential equations (tex)
#SUMMARY ode*	ordinary differential equations (view)
#SUMMARY ode	ordinary differential equations (ps)
#SUMMARY ode	ordinary differential equations (oct)
#Ordinary differential equations

ifeq ($dae_is_ode,1)
$1_ode.r: $1_dae.r
	echo Copying $1_dae.r to $1_ode.r
	cp $1_dae.r  $1_ode.r
else
$1_ode.r: $1_cse.r $1_cseo.r $1_def.r $1_sympar.r $1_subs.r
	cse2ode_r $optimise $1; tidy $1_ode.r
endif

$1_odeo.r: $1_ode.r
	touch $1_odeo.r

$1_ode.m: $1_def.r $1_ode.r
	mtt_r2m $optimise -parameters $1 ode m; #  matlab_tidy $1_ode.m
$1_odeo.m: $1_def.r $1_odeo.r
	mtt_r2m $1 odeo m

$1_odea.m: $1_ode.m
	touch $1_odea.m

$1_ode.tex: $1_ode.r  $1_sympar.r $1_simp.r
	ode_r2tex $1; latex_tidy $1_ode.tex


$1_lde.r: $1_dae.r
	dae2lde_r $optimise $1; tidy $1_lde.r

$1_lde.tex: $1_lde.r  $1_sympar.r $1_simp.r
	lde_r2tex $1; latex_tidy $1_lde.tex

# The main simulation programme
ifeq ($integration_method,implicit)
$1_ode2odes.m : $1_def.r $1_sympars.txt \
                $1_smxa.m $1_smxax.m\
                $1_simpar.m $1_numpar.m $1_state.m $1_input.m \
                $1_csex.m $1_cseo.m  $1_logic.m
ifeq ($using_oct,yes)
	touch $1_ode2odes.m # Create a dummy which wont' be used
	mtt $mtt_switches -q -u $1 ode2odes oct
else
	make_ode2odes $1 m $integration_method $algebraic_solver $sort_method
endif
endif
ifneq ($integration_method,implicit)
ifeq ($sort_method,seqn)
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_sese.m $1_logic.m
else
ifeq ($use_reduce,no)
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_sesx.m $1_sesy.m $1_logic.m
else
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_ode.m $1_odeo.m  $1_logic.m
endif
endif
ifeq ($using_oct,yes)
	echo "*** Warning: Shouldn't be here! Creating dummy $1_ode2odes.m"
	touch $1_ode2odes.m # Create a dummy which wont' be used
	mtt $mtt_switches -q -u $1 ode2odes oct
else
	make_ode2odes $1 m $integration_method $algebraic_solver $sort_method
endif
endif

#SUMMARY ode2odes Simulation function (m)
#SUMMARY ode2odes Simulation function (cc)
#SUMMARY ode2odes Simulation function (oct)
#SUMMARY ode2odes_rtxi Simulation function (o)
#SUMMARY ode2odes Simulation function (exe)
$1_ode2odes.exe: $1_def.h $1_sympar.h\
		 $1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o mtt_kpathsea.o
	echo Creating $1_ode2odes.exe
	${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\
	$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o mtt_kpathsea.o\
	${MTT_LDFLAGS} ${MTT_CXXLIBS}

$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
	echo Creating $1_ode2odes.o
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DCODEGENTARGET=STANDALONE

$1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common_oct.stamp $1_ode2odes_${integration_method}_oct.stamp $1_ode2odes_${algebraic_solver}.o
	touch $1_ode2odes.m
	echo Creating $1_ode2odes.oct
	$MKOCTFILE ${MTT_CXXINCS} -DCODEGENTARGET=OCTAVEDLD $1_ode2odes.cc mtt_${algebraic_solver}.cc mtt_Solver.cc mtt_AlgebraicSolver.cc

$1_ode2odes.mexglx: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
	touch $1_ode2odes.m
	echo Creating $1_ode2odes.mexglx
	${MTT_CXX} -DCODEGENTARGET=MATLABMEX -o $1_ode2odes.mexglx $1_ode2odes.cc \
	$1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o \
	${MTT_MATLAB_FLAGS} ${MTT_CXXINCS} ${MTT_CXXLIBS} ${MTT_CXXFLAGS} \
	${MTT_LIB}/cc/mtt_kpathsea.cc ${MTT_LIB}/cc/mtt_matlab_octave.cc

$1_ode2odes.cc: $1_def.r $1_sympars.txt\
		$1_ode2odes_common_m.stamp $1_ode2odes_common_cc.stamp\
		$1_ode2odes_${integration_method}_m.stamp $1_ode2odes_${integration_method}_cc.stamp\
		mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.cc mtt_${algebraic_solver}.hh
	touch $1_ode2odes.m
	make_ode2odes $1 cc $integration_method $algebraic_solver $sort_method

#SUMMARY rtxi real time module (cc)
#SUMMARY rtxi real time module (so)
$1_ode2odes_rtxi.lo: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o \
		    $1_rtxi.cc $1_rtxi.h
	@echo "Creating \$@"
	${MTT_RTXI_CXXCOMPILE} ${MTT_RTXI_CXXFLAGS} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DCODEGENTARGET=RTXI -o \$@
	@echo compilation complete

$1_rtxi.so: $1_rtxi.cc $1_ode2odes_rtxi.lo $1_rtxi.h
	@echo Compiling module
	${MTT_RTXI_CXXCOMPILE} ${MTT_RTXI_CXXFLAGS} -c $1_rtxi.cc -o $1_rtxi.lo
	@echo Compilation complete
	${MTT_RTXI_CXXLINK} ${MTT_RTXI_LIBS} ${MTT_RTXI_LDFLAGS} ${MTT_CXXLIBS} -rpath ${MTT_RTXI_RPATH}$1 -o $1_rtxi.la $1_rtxi.lo $1_ode2odes_rtxi.lo
	@echo Module created

$1_rtxi.install: $1_rtxi.so
	@echo Installing module in ${MTT_RTXI_RPATH}$1)
	${MTT_RTXI_LIBTOOL} --mode=install cp $1_rtxi.la ${MTT_RTXI_RPATH}$1

$1_rtxi.cc: $1_struc.txt $1_sympar.txt
	echo Creating \$@
	sympar2rtxi_txt2cc $1

$1_rtxi.h: $1_sympar.txt
	echo Creating \$@
	sympar2rtxi_txt2h $1



#Conversion of m to p to c
#SUMMARY ode	ordinary differential equations (c)
#SUMMARY ode	ordinary differential equations (p)
#SUMMARY state	state declaration (c) 
#SUMMARY state	state declaration (p) 
$1_simpar.p : $1_def.r $1_simpar.m
	mtt_m2p $1_simpar.m
$1_numpar.p : $1_def.r $1_numpar.m
	mtt_m2p $1_numpar.m
$1_state.p : $1_def.r $1_state.m
	mtt_m2p $1_state.m

#SUMMARY input	numerical input declaration (m) 
ifeq ($stdin,stdin)
$1_input.m : $1_def.r
	make_stdin $1 m
$1_input.p : $1_def.r
	make_stdin $1 p
$1_input.cc:
	make_stdin $1 cc
else
$1_input.m:  $1_input.txt $1_sympars.txt
	mtt_txt2m $1 input
$1_input.p : $1_def.r $1_input.m
	mtt_m2p $1_input.m
endif

$1_ode.p : $1_def.r $1_ode.m
	mtt_m2p $1_ode.m
$1_odeo.p : $1_def.r $1_odeo.m
	mtt_m2p $1_odeo.m
$1_csex.p : $1_def.r $1_cse.m
	mtt_m2p $1_csex.m
$1_cseo.p : $1_def.r $1_cseo.m
	mtt_m2p $1_cseo.m
$1_smx.p : $1_def.r $1_smx.m
	mtt_m2p $1_smx.m
$1_smxa.p : $1_def.r $1_smxa.m
	mtt_m2p $1_smxa.m
$1_smxax.p : $1_def.r $1_smxax.m
	mtt_m2p $1_smxax.m
$1_logic.p : $1_def.r $1_logic.m
	mtt_m2p $1_logic.m

ifeq ($integration_method,implicit)
$1_ode2odes.p : $1_ode2odes.m $1_def.r $1_smxa.p $1_smxax.p\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_csex.p $1_cseo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif
ifneq ($integration_method,implicit)
$1_ode2odes.p : $1_ode2odes.m $1_def.r\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_ode.p $1_odeo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif

$1_ode2odes.c: $1_ode2odes.p 
	mtt_p2c $info_switch $1 ode2odes

##SUMMARY sim Octave simulation function (m)

#ifeq ($computation,octave)
#$1_sim.m: $1_def.r $1_sympar.txt $1_cse.m $1_cseo.m $1_smxa.m $1_smxax.m $1_numpar.m $1_state.m
	mtt_make_sim $1 $integration_method $computation 
#endif

#ifeq ($computation,c)
#$1_sim.m: $1_def.r $1_sympar.txt $1_ode2odes.out $1_numpar.m $1_state.m
#	mtt_make_sim $1 $integration_method $computation 
#endif

#SUMMARY ssim Octave sensitivity simulation function (m)
$1_ssim.m: $1_def.r $1_ode2odes.${m}
	make_ssim $1 m

#SUMMARY sim Octave simulation function (m)
$1_sim.m: $1_def.r $1_ode2odes.${m}
	make_sim $1 m

#SUMMARY obs	observer equations for CGPC (r)
#SUMMARY obs*	observer equations for CGPC (m)
#SUMMARY obs	observer equations for CGPC (tex)
#SUMMARY obs*	observer equations for CGPC (view)
#SUMMARY obs	observer equations for CGPC (ps)
#Observer functions for GPC
$1_obs.r: $1_ode.r $1_def.r $1_obspar.r $1_subs.r
	ode2obs_r $1; tidy $1_obs.r
$1_obs.m: $1_def.r $1_sympars.txt $1_obs.r $1_obspar.r $1_numpar.m
	mtt_r2m $optimise  -parameters $1 obs
$1_obs.tex: $1_obs.r  $1_sympar.r $1_simp.r
	obs_r2tex $1; latex_tidy $1_obs.tex


#SUMMARY rfe	robot-form equations (r)
#SUMMARY rfe	robot-form equations (tex)
#SUMMARY rfe*	robot-form equations (view)
#SUMMARY rfe	robot-form equations (ps)
#Robot-form equations
$1_rfe.r: $1_cse.r $1_csm.r $1_def.r $1_sympar.r
	cse2rfe_r $1; tidy $1_rfe.r
$1_rfe.tex: $1_rfe.r  $1_sympar.r  $1_simp.r
	rfe_r2tex $1; latex_tidy $1_rfe.tex

#SUMMARY ss	steady-state equations (r)
#SUMMARY ss*	steady-state equations (m)
#SUMMARY ss	steady-state equations (tex)
#SUMMARY ss*	steady-state equations (view)
#SUMMARY ss	steady-state equations (ps)
#Steady-states
$1_ss.r: $1_def.r $1_sspar.r $1_cr.r $1_ode.r
	sspar2ss_r $1; tidy $1_ss.r
$1_ss.m: $1_def.r  $1_ss.r  $1_numpar.m
	ss_r2m $1; matlab_tidy $1_ss.m
$1_ss.tex: $1_def.r $1_ss.r $1_simp.r
	ss_r2tex $1; latex_tidy $1_ss.tex 


#SUMMARY dm	descriptor matrices (r)
#SUMMARY dm*	descriptor matrices (m)
#SUMMARY dm	descriptor matrices (tex)
#SUMMARY dm*	descriptor matrices (view)
#SUMMARY dm	descriptor matrices (ps)
#Linearised system: descriptor matrices
$1_dm.r: $1_dae.r $1_def.r $1_cr.r  $1_ss.r $1_sympar.r
	dae2dm_r $1; tidy $1_dm.r
$1_dm.m: $1_def.r $1_dm.r $1_sympars.txt
		mtt_r2m $optimise -parameters $1 dm
$1_dm.tex: $1_dm.r $1_sympar.r $1_simp.r 
	dm_r2tex $1; latex_tidy $1_dm.tex



#SUMMARY csm	constrained-state matrices (r)
#SUMMARY csm	constrained-state matrices (m)
#SUMMARY csm	constrained-state matrices (tex)
#SUMMARY csm	constrained-state matrices (view)
#SUMMARY csm    constrained-state matrices (ps)
#Linearised system: constrained-state matrices
$1_csm.r: $1_cse.r $1_def.r $1_cr.r $1_sspar.r
	cse2csm_r $1 csm; tidy $1_csm.r
$1_csm.m: $1_def.r $1_csm.r $1_sympars.txt
		mtt_r2m $optimise  -parameters $1 csm;  matlab_tidy $1_csm.m
$1_csm.tex: $1_csm.r  $1_sympar.r $1_simp.r
	csm_r2tex $1 csm; latex_tidy $1_csm.tex
#SUMMARY scsm	sensitivity constrained-state matrices (r)
#SUMMARY scsm	sensitivity constrained-state matrices (m)
#SUMMARY scsm	sensitivity constrained-state matrices (tex)
#SUMMARY scsm	sensitivity constrained-state matrices (view)
#SUMMARY scsm	sensitivity constrained-state matrices (ps)
#Linearised system: sensitivity constrained-state matrices
$1_scsm.r: $1_scse.r $1_def.r $1_cr.r $1_sympar.r $1_sspar.r
	cse2csm_r $1 scsm; tidy $1_scsm.r
$1_scsm.m: $1_def.r $1_scsm.r $1_sympars.txt
		csm_r2m $1 scsm;  matlab_tidy $1_scsm.m
$1_scsm.tex: $1_scsm.r  $1_sympar.r $1_simp.r
	csm_r2tex $1 scsm; latex_tidy $1_scsm.tex

#SUMMARY sm	state matrices (r)
#SUMMARY sm*	state matrices (m)
#SUMMARY sm	state matrices (icad)
#SUMMARY sm	state matrices (tex)
#SUMMARY sm	state matrices (c)
#SUMMARY sm*	state matrices (view)
#SUMMARY sm	state matrices (ps)
#Linearised system: state matrices
$1_sm.r: $1_csm.r $1_def.r $1_cr.r $1_ss.r $1_sympar.r
	csm2sm_r $optimise $1 sm; tidy $1_sm.r
$1_sm.m: $1_def.r $1_sm.r $1_sympars.txt 
		mtt_r2m $optimise  -parameters $1 sm
$1_sm.icad:  $1_sm.m $1_numpar.m
		sm_m2icad $1
$1_sm.c: $1_def.r $1_sm.r $1_sympar.c
		sm_r2c $1
$1_sm.tex: $1_sm.r  $1_sympar.r $1_simp.r
	sm_r2tex $1 sm; latex_tidy $1_sm.tex

#SUMMARY ssm	sensitivity state matrices (r)
#SUMMARY ssm	sensitivity state matrices (icad)
#SUMMARY ssm	sensitivity state matrices (tex)
#SUMMARY ssm	sensitivity state matrices (c)
#SUMMARY ssm	sensitivity state matrices (ps)
#Linearised system: sensitivity state matrices
$1_ssm.r: $1_scsm.r $1_def.r $1_cr.r $1_ss.r $1_sympar.r
	csm2sm_r $optimise $1 ssm; tidy $1_ssm.r
$1_ssm.m: $1_def.r $1_ssm.r $1_sympars.txt 
		mtt_r2m $optimise -parameters $1 ssm
$1_ssm.tex: $1_ssm.r  $1_sympar.r $1_simp.r
	sm_r2tex $1 ssm; latex_tidy $1_ssm.tex

#SUMMARY smx	state matrices with variable state x (r)
#SUMMARY smx	state matrices with variable state x (m)
#SUMMARY smxx	Sparse computation of Ax (m)
#SUMMARY smxtx	Sparse computation of ATx (m)
$1_smx.r: $1_def.r $1_def.m $1_ode.r $1_subs.r
		ode2smx_lang $1 r; tidy $1_smx.r

$1_smx.m: $1_def.r $1_def.m $1_cse.r $1_sympars.txt $1_subs.r
		cse2smx_lang $fixcc $optimise -parameters $1 smx m

$1_smxa.m: $1_def.r $1_def.m $1_cse.r  $1_sympars.txt $1_subs.r
		cse2smx_lang $fixcc $optimise -parameters $matrix_smxa $1 smxa m

$1_smxax.m: $1_def.r $1_def.m $1_cse.r $1_sympars.txt $1_subs.r
		cse2smx_lang $fixcc $optimise -parameters $1 smxax m

#SUMMARY smc	controller form state matrices etc. - siso only (r)
#SUMMARY smc	controller form state matrices etc. - siso only (tex)
#SUMMARY smc*	controller form state matrices etc. - siso only (m)
#SUMMARY smc*	controller form state matrices etc. - siso only (view)
#SUMMARY smc	controller form state matrices etc. - siso only (ps)
#Linearised system: controller form state matrices etc.
$1_smc.r: $1_sm.r $1_def.r $1_tf.r 
	sm2smc_r $1; tidy $1_smc.r
$1_smc.tex: $1_smc.r  $1_simp.r
	smc_r2tex $1; latex_tidy $1_smc.tex
$1_smc.m: $1_def.r $1_smc.r $1_numpar.m
		smc_r2m $1;  matlab_tidy $1_smc.m

#SUMMARY smo	observer form state matrices etc. - siso only (r)
#SUMMARY smo	observer form state matrices etc. - siso only (tex)
#SUMMARY smo*	observer form state matrices etc. - siso only (m)
#SUMMARY smo*	observer form state matrices etc. - siso only (view)
#SUMMARY smo	observer form state matrices etc. - siso only (ps)
#Linearised system: observer form state matrices etc.
$1_smo.r: $1_sm.r $1_def.r $1_tf.r 
	sm2smo_r $1; tidy $1_smo.r
$1_smo.tex: $1_smo.r  $1_simp.r
	smo_r2tex $1; latex_tidy $1_smo.tex
$1_smo.m: $1_def.r $1_smo.r $1_numpar.m
		smo_r2m $1;  matlab_tidy $1_smo.m

#SUMMARY ssk	State-space controller gain - siso only (r)
#SUMMARY ssk	State-space controller gain - siso only (tex)
#SUMMARY ssk*	State-space controller gain - siso only (m)
#SUMMARY ssk*	State-space controller gain - siso only (view)
#SUMMARY ssk	State-space controller gain - siso only (ps)
#Linearised system: State-space controller gain
$1_ssk.r: $1_def.r $1_smc.r 
	smc2ssk_r $1; tidy $1_ssk.r
$1_ssk.tex: $1_ssk.r  $1_simp.r
	ssk_r2tex $1; latex_tidy $1_ssk.tex
$1_ssk.m: $1_def.r $1_ssk.r $1_numpar.m
		ssk_r2m $1;  matlab_tidy $1_ssk.m

#SUMMARY ssl	State-space observer gain - siso only (r)
#SUMMARY ssl	State-space observer gain - siso only (tex)
#SUMMARY ssl*	State-space observer gain - siso only (m)
#SUMMARY ssl*	State-space observer gain - siso only (view)
#SUMMARY ssl	State-space observer gain - siso only (ps)
#Linearised system: State-space observer gain
$1_ssl.r: $1_def.r $1_smo.r 
	smo2ssl_r $1; tidy $1_ssl.r
$1_ssl.tex: $1_ssl.r  $1_simp.r
	ssl_r2tex $1; latex_tidy $1_ssl.tex
$1_ssl.m: $1_def.r $1_ssl.r $1_numpar.m
		ssl_r2m $1;  matlab_tidy $1_ssl.m

#SUMMARY tf	transfer function (r)
#SUMMARY tf*	transfer function (m)
#SUMMARY tf	transfer function (tex)
#SUMMARY tf*	transfer function (view)
#SUMMARY tf	transfer function (ps)
#Linearised system: transfer function
$1_tf.r: $1_dm.r $1_sympar.r 
	dm2tf_r $1; tidy $1_tf.r
$1_tf.m: $1_def.r $1_sympars.txt $1_tf.r 
	tf_r2m $1; matlab_tidy $1_tf.m
$1_tf.tex: $1_def.r $1_tf.r $1_sympar.r $1_simp.r
	tf_r2tex $1; latex_tidy $1_tf.tex

#SUMMARY pkim	partialyy-known system identification matrix (r)
#SUMMARY pkim	partialyy-known system identification matrix (tex)
#SUMMARY pkim	partialyy-known system identification matrix (view)
#SUMMARY pkim	partialyy-known system identification matrix (ps)
$1_pkim.r: $1_tf.r $1_sympar.r 
	tf2pkim_r $1; tidy $1_pkim.r
$1_pkim.tex: $1_def.r $1_pkim.r $1_simp.r
	pkim_r2tex $1; latex_tidy $1_pkim.tex

#SUMMARY ctf    controller transfer function (r)
#SUMMARY ctf	controller transfer function (m)
#SUMMARY ctf	controller transfer function (tex)
#SUMMARY ctf	controller transfer function (view)
#SUMMARY ctf	controller transfer function (ps)
#Linearised system: transfer function
$1_ctf.r: $1_dm.r $1_ssk.r  $1_ssl.r   $1_sm.r  
	ssk2ctf_r $1; tidy $1_ctf.r
$1_ctf.m: $1_def.r $1_ctf.r 
	ctf_r2m $1; matlab_tidy $1_ctf.m
$1_ctf.tex: $1_def.r $1_ctf.r $1_sympar.r $1_simp.r
	ctf_r2tex $1; latex_tidy $1_ctf.tex

#SUMMARY ir	impulse response - state (m)
#SUMMARY ir	impulse response - state (dat)
#SUMMARY ir	impulse response - state (ps)
#SUMMARY ir	impulse response - state (view)

#SUMMARY iro	impulse response - output (m)
#SUMMARY iro	impulse response - output (dat)
#SUMMARY iro	impulse response - output (ps)
#SUMMARY iro	impulse response - output (view)

#SUMMARY sr	step response - state (m)
#SUMMARY sr	step response - state (dat)
#SUMMARY sr	step response - state (ps)
#SUMMARY sr	step response - state (view)

#SUMMARY sro*	step response - output (m)
#SUMMARY sro	step response - output (dat)
#SUMMARY sro	step response - output (ps)
#SUMMARY sro*	step response - output (view)

#SUMMARY odes	ode solution - state (m)
#SUMMARY odes*	ode solution - state (dat)
#SUMMARY odes*  ode solution - state & output for SciGraphica (sg)
#SUMMARY odes*	ode solution - state (ps)
#SUMMARY odes*	ode solution - state (view)

#SUMMARY sms	ode (in state matrix form) solution - state & output (c)

#SUMMARY odeso	ode solution - output (m)
#SUMMARY odeso*	ode solution - output (dat)
#SUMMARY odeso*	ode solution - output for spreadsheet (sdat) 
#SUMMARY odeso	ode solution - output (ps)
#SUMMARY odeso*	ode solution - output (view)

#SUMMARY daes   dae solution - state (m)
#SUMMARY daes	dae solution - state (dat)
#SUMMARY daes	dae solution - state (ps)
#SUMMARY daes	dae solution - state (view)

#SUMMARY daeso  dae solution - output (m)
#SUMMARY daeso	dae solution - output (dat)
#SUMMARY daeso	dae solution - output (ps)
#SUMMARY daeso	dae solution - output (view)

#Time responses
$1_ir.m: $1_sm.m $1_numpar.m $1_def.m $1_simpar.m
	sm2ir_m $1 '$ARGS'
$1_iro.m: $1_ir.m
	touch $1_iro.m
$1_ir.dat: $1_ir.m
	m2dat $1_ir
$1_iro.dat: $1_iro.m
	m2dat $1_iro
$1_sr.m: $1_sm.m $1_numpar.m $1_simpar.m $1_def.m
	sm2sr_m $1 
$1_sr.dat: $1_sr.m
	m2dat $1_sr
$1_sro.m: $1_sr.m
	touch $1_sro.m$
$1_sro.dat: $1_sro.m
	m2dat $1_sro
1_odes.c: $1_ode.c $1_def.r $1_sympar.r
	ode2odes_r2c $1 
$1_sms.c: $1_sm.c $1_def.r $1_sympar.r
	sm2sms_r2c $1

.PRECIOUS: $1_odes.dat2
ifeq ($computation,octave)
ifeq ($using_oct,yes)
$1_odes.dat2: $1_ode2odes.oct
	time octave_ode2odes $1
else
$1_odes.dat2: $1_ode2odes.m
	time octave_ode2odes $1
endif
endif

$1_ode2odes.out: $1_ode2odes.c $1_cr.h
	echo Creating $1_odes.out by compiling $1_ode2odes.c 
	$CC $1_ode2odes.c -lp2c -lm -o $1_ode2odes.out

ifeq ($computation,c)
$1_odes.dat2: $1_ode2odes.out
	echo Creating $1_odes.dat2 using c version
	    time ./$1_ode2odes.out>$1_odes.dat2
endif

ifeq ($computation,cc)
$1_sim.exe: $1_ese.r 
	mtt $mtt_switches -q $1 sim exe

$1_odes.dat2: $1_ode2odes.exe 
	echo Creating $1_odes.dat2 using cc version $ARGS
	    time ./$1_ode2odes.exe $ARGS >$1_odes.dat2
endif


#$1_odeso.m: $1_odes.m
#	touch $1_odeso.m
#$1_smso.m: $1_sms.m
#	touch $1_smso.m
#$1_daes.m: $1_dae.m $1_numpar.m  $1_def.m $1_input.m $1_simpar.m
#	dae2daes_m $1 '$ARGS'
#$1_daeso.m: $1_daes.m
#	touch $1_daeso.m


#Conversion of data files from dat to sdat format
$1_odeso.sdat: $1_odeso.dat $1_struc.txt
	odeso_dat2sdat $1

$1_odes.sdat: $1_odes.dat $1_struc.txt
	odes_dat2sdat $1

#Conversion of data to SciGraphica
$1_odes.sg: $1_struc.m $1_odes.dat2
	echo Creating $1_odes.sg
	dat22sg.sh $1

#SUMMARY odess	ode numerical steady-states - states (m)
#SUMMARY odess	ode numerical steady-states - states (dat)
#SUMMARY odess	ode numerical steady-states - states (ps)
#SUMMARY odess	ode numerical steady-states - states (view)

#SUMMARY odesso	ode numerical steady-states - outputs (m)
#SUMMARY odesso	ode numerical steady-states - outputs (dat)
#SUMMARY odesso	ode numerical steady-states - outputs (ps)
#SUMMARY odesso	ode numerical steady-states - outputs (view)

#Numerical steady states
$1_odess.dat2: $1_ode.m $1_odeo.m $1_numpar.m  $1_input.m $1_simpar.m
	ode2odess_m2dat2 $1 
#$1_odess.m: $1_ode.m $1_odeo.m $1_numpar.m  $1_input.m $1_simpar.m
#	ode2odess_m $1 
#$1_odesso.m: $1_odess.m
#	touch $1_odesso.m


#SUMMARY fr	frequency response (m)
#SUMMARY fr	frequency response (dat)
#SUMMARY fr	frequency response (ps)
#SUMMARY fr	frequency response (view)

#SUMMARY lmfr	loglog modulus frequency response (m)
#SUMMARY lmfr	loglog modulus frequency response (dat)
#SUMMARY lmfr	loglog modulus frequency response (ps)
#SUMMARY lmfr*	loglog modulus frequency response (view)

#SUMMARY lpfr	semilog phase frequency response (m)
#SUMMARY lpfr	semilog phase frequency response (dat)
#SUMMARY lpfr	semilog phase frequency response (ps)
#SUMMARY lpfr*	semilog phase frequency response (view)

#SUMMARY nyfr	Nyquist style frequency response (m)
#SUMMARY nyfr	Nyquist style frequency response (dat)
#SUMMARY nyfr	Nyquist style frequency response (ps)
#SUMMARY nyfr	Nyquist style frequency response (view)

#SUMMARY nifr	Nichols style frequency response (m)
#SUMMARY nifr	Nichols style frequency response (dat)
#SUMMARY nifr	Nichols style frequency response (ps)
#SUMMARY nifr	Nichols style frequency response (view)


#Frequency responses
$1_fr.m: $1_dm.m $1_numpar.m $1_def.m $1_simpar.m
	dm2fr_m $1 
$1_lmfr.m $1_lpfr.m $1_nyfr.m $1_nifr.m: $1_fr.m

$1_fr.dat: $1_fr.m
	m2dat $1_fr
$1_lmfr.dat: $1_lmfr.m
	m2dat $1_lmfr
$1_lpfr.dat: $1_lpfr.m
	m2dat $1_lpfr
$1_nyfr.dat: $1_nyfr.m
	m2dat $1_nyfr
$1_nifr.dat: $1_nifr.m
	m2dat $1_nifr


ifeq ($REPTYPE,txt)
#Generic conversion of txt files to tex files
$1_$2.tex: $1_$2.txt
	txt2tex $1 $2 txt
 endif

#Conversion of dat2 files  to dat format
$1_odeso.dat: $1_odes.dat2 $1_def.r
	echo Creating $1_odeso.dat
	dat22dat $1 ode so
$1_odes.dat: $1_odes.dat2 $1_def.r
	echo Creating $1_odes.dat
	dat22dat $1 ode s
$1_odesso.dat: $1_odess.dat2 $1_def.r
	echo Creating $1_odesso.dat
	dat22dat $1 odes so
$1_odess.dat: $1_odess.dat2 $1_def.r
	echo Creating $1_odess.dat
	dat22dat $1 odes s

#Generic conversion of data files from dat to (gplot) gdat format 
$1_$2.gdat: $1_$2.dat $1_struc.txt  $1_args.m
	dat2gdat $1 $2 "$ARGS" "$NyquistStyle"

## Conversion of gdat to fig files
ifeq ($REPTYPE,data)
$1_$2.fig: $1_$2.gdat
	gdat2fig $1_$2

ifneq ($ARGS,) ## Multiple plots
	echo Creating $1_$2$__ARGS.fig
	mv $1_$2.fig $1_$2$__ARGS.fig
	rm -f $1_$2.gdat
endif

## Conversion of gdat fig files to ps/pdf
ifeq ($ARGS,) # single plot
$1_$2.$ps : $1_$2.fig
	echo Creating $1_$2.$ps
	fig2dev -L$eps $1_$2.fig > $1_$2.$ps
else ## Multiple plots
$1_$2.$ps : $1_$2.fig
	mtt -q -r $1 $2 dat $4
	echo Creating $1_$2$__ARGS.$ps
	fig2dev -L$eps $1_$2$__ARGS.fig > $1_$2$__ARGS.$ps
endif

endif


#Generic conversion of Latex to latex document
mtt.sty:
	echo Copying mtt.sty to here
	cp $MTTPATH/trans/mtt.sty .
$1_$2.doc: $1_$2.tex
	makedoc "$mtt_switches" "$1" "$2" "$3" "$4" "$documenttype" "$ps"


#Create PostScript version of dia and fig files
ifeq ($REPTYPE,bg)
ifeq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_$2.$ps : $1_$2.dia
else
$1_$2.$ps : $1_$2.fig
endif
	echo Creating $1_$2.$ps
	bg2eps $1 $2 $ps $eps
endif

ifeq ($REPTYPE,lbg)
$1_$2.$ps : $1_$2.fig
	labg_fig2ps $1_$2
endif

ifeq ($REPTYPE,tex)
#Generic conversion of LaTeX doc to dvi or pdf
$1_$2.$ps: $1_$2.doc
	doc2$ps $1_$2 "$documenttype"
endif


ifeq ($REPTYPE,tex)
#Create html version of dvi file
$1_$2.html: $1_$2.doc
	echo Creating $1_$2/$1_$2.html
	$LATEX2HTML $1_$2.doc>latex2html.log 2>latex2html.log
endif

#Default view
ifeq ($REPTYPE,bg)
$1_$2.view : $Subsystem_$2.pview
endif

ifeq ($REPTYPE,data)
$1_$2.view: $1_$2.$ps
ifeq ($ARGS,) # single plot
	echo Creating view of $1_$2 - $ps file
	$psview $1_$2.$ps&
else
	echo Creating view of $1_$2$__ARGS - $ps file
	$psview $1_$2$__ARGS.$ps&
endif
endif

ifeq ($REPTYPE,tex)
$1_$2.view : $1_$2.pview
endif

ifeq ($REPTYPE,txt)
$1_$2.view : $1_$2.tview
endif

# Hypertext view
$1_$2.hview: $1_$2.html
	$HTMLVIEW $1_$2/$1_$2.html&

#View a ps file
$Subsystem_$2.pview: $1_$2.$ps
	echo Creating view of $Subsystem_$2 - $ps file
	mtt_multi $psview $Subsystem $2 $ps $viewlevel  | sh 

#View a gdat file
$1_$2.dview: $1_$2.gdat
	echo Creating view of $1_$2
	gdat2view $1_$2 '$ARGS'&

#View a tex file
$1_$2.tview: $1_$2.dvi
	echo Creating view of $1_$2
	$DVIVIEW $1_$2.dvi&

#Report generation
$1_rep.make: $1_rep.txt
	rep_txt2make $1 "$mtt_switches"

$1_reps_made:
	rep_txt2sh $1 "$mtt_switches";  touch $1_reps_made

$1_rep.tex: $1_rep.txt $1_reps_made
	rep_txt2tex $1 "$documenttype" "$directory" "$mtt_switches";

#SUMMARY abg Acausal bond graph report (tex)
$1_abg.tex: $1_sub.sh $1_labg.tex
	sh $1_sub.sh "mtt -q " " labg tex"
	abg2tex $pdf ${sensitivity_switch} $1

#SUMMARY tf Transfer function (mml)
$1_$2.mml: $1_$2.r
	mtt_r2mml $1 $2


# Version control system - uses RCS
RCS:
	echo Creating RCS
	mkdir RCS
$1_$2.vc: RCS 
	echo Version control on $1_$2.$VCext with message: $log_message
	ci -m"$log_message" -I $1_$2.$VCext </dev/tty  ; co -l $1_$2.$VCext 

EOF
# Remember the exit status of make
make_status=$?

# Tidy up.
# echo Removing log files and other garbage
  rm -f  *_unique_raw_list *_raw_list
  rm -f mtt_error.txt mtt_info.txt 
  rm -f  mtt_info.txt warning.txt
#  rm -f *_*.idx *_*.ind *_*.ilg  *_*.lof *_*.toc

# Remove logs if not debugging
if [ "$debug" != "debug" ]; then
  rm -f *.log
else
  echo Debugging - log files retained in LOGFILES  
  mkdir -p LOGFILES
  mv -f *.log LOGFILES 2> /dev/null
fi

#Print what's going on if in verbose mode
if [ -n "$Verbose" ]; then
    echo Finishing mtt  $mtt_switches  $1 $2 $3 $4 at level $level
fi

if [ "$make_status" != "0" ]; then
    echo Exiting MTT with error $make_status
    exit 1
fi

Added mtt/bin/mtt_backup version [390999ad3b].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
# Does a backup with date of selected files.


while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
    -d)
         format=date;
	 shift
	;;
    -v)
         format=version;
	 shift
	;;
    -h)
         echo "Usage: mtt_backup [-d|-v] [lib|doc]";
	 exit
	;;
    *)
         format=date;
esac
done

#Name of archive
if [ -z "$1" ]; then
    mtt="mtt"
    dirs='mtt mtt-lib mtt-cc mtt-doc'
else
    mtt="mtt-$1"
    dirs=$mtt
fi

## Create appropriate filename
case $format in
    date)
         filename=`date | gawk '{printf("%s_%s%s_%s.tgz\n", mtt, $2,$3,$6)}' mtt=$mtt`;
	 shift
	;;
    version)
         filename=`mtt --version | gawk '{printf("%s-%s.tar.gz\n", mtt, $NF)}' mtt=$mtt`;
	 shift
	;;

    *)

esac

echo Backup file $filename



#Check whether archive exists here
if [ -f "$filename" ]; then
    echo File $filename already exists - exiting
    exit    
fi

# Listing files to ignore
#echo Finding irrelevant files
#find $dirs -name '*.*' -print |\
#  grep 'dvi$\|ps$\|gif$\|log$\|dat$\|MTT_work\|core\|~$' >IGNORE
#wc IGNORE | gawk '{print "Ignoring", $1, "files"}'

#echo examples >> IGNORE

#Inform user
echo Backing up $dirs to $filename

#Tar the files
#tar --exclude-from IGNORE --create --gzip --file $filename $dir
tar --create --gzip --file $filename $dirs
#Size info
ls -l $filename
#

Added mtt/bin/mtt_backups version [6f813c5536].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
# Does a backup with date of all mtt components
# $Log$
# Revision 1.2  2000/10/03 12:17:58  peterg
# Prints usage line
#

if [ -z "$1" ]; then
   echo "Usage: mtt_backups [-v|-d]"
   exit    
fi
mtt_backup $1
mtt_backup $1 cc
mtt_backup $1 lib
mtt_backup $1 doc

Added mtt/bin/mtt_check_sese version [4337a95ac3].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
## This script tests the sese generation by comparing the 
## dae files generated by the conventional approach
## Copyright (C) 2003 by Peter J. Gawthrop

sys=$1

## Correct dae file.
rm -vf ${sys}_ese.r MTT_work/${sys}_ese.r
mtt -q ${sys} dae r
mv -v ${sys}_dae.r ${sys}_dae.r_CORRECT

## sese file   
rm -vf ${sys}_sese.r MTT_work/${sys}_sese.r
mtt -q ${sys} sese r

## Create the dae file from the sese file 
cp -v ${sys}_sese.r ${sys}_ese.r
mtt -q ${sys} dae r

## And test
diff ${sys}_dae.r ${sys}_dae.r_CORRECT > mtt_diffs

## Result
if [ "$?" = "0" ]; then
    echo "****** dae files are the same ******"
else
    echo "****** dae files are different ******"
    cat mtt_diffs
fi

Added mtt/bin/mtt_check_var version [afd404bde7].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_check_var

# P.J.Gawthrop July 1997
# Copyright (c) P.J.Gawthrop 1997


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1997/12/04  10:41:15  peterg
# Added third argument to print env. variables.
#
## Revision 1.1  1997/07/27 13:11:37  peterg
## Initial revision
##
###############################################################

var=$1
name=$2
print=$3
software=$4

if [ -z "$1"  ]; then
 echo '*** MTT WARNING Environment variable' $name 'not set. *****'
 echo "Please check that software package $software has been correctely installed"
 echo
 exit
fi

if [ "$print" = "print" ]; then
 echo Environment variable $name set to $var
fi

Added mtt/bin/mtt_check_vars version [aa8113cf2e].





























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_check_vars

# P.J.Gawthrop July 1997
# Copyright (c) P.J.Gawthrop 1997


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8.2.1  2001/03/06 03:48:43  geraint
## Print additional environment variable for "mtt -p".
## MTT_LDFLAGS defaults to " " to avoid installation warning.
##
## Revision 1.8  2000/12/27 13:11:42  peterg
## *** empty log message ***
##
## Revision 1.7  2000/08/04 15:48:30  peterg
## Added PDF
##
## Revision 1.6  2000/05/22 12:37:24  peterg
## *** empty log message ***
##
## Revision 1.5  2000/05/22 12:34:07  peterg
## Added MTT_REP
##
## Revision 1.4  1998/07/30 17:30:41  peterg
## Added some more paths
##
## Revision 1.3  1998/01/23 13:33:47  peterg
## Removed OCTAVE_PATH
## Removed RMATRIX
##
# Revision 1.2  1997/12/04  10:41:49  peterg
# Added -p argument to print environment variables
#
## Revision 1.1  1997/07/27 13:12:03  peterg
## Initial revision
##
###############################################################

#Look for a command line argument
while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-p )
		print=print ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Octave
#mtt_check_var "$OCTAVE_PATH" "OCTAVE_PATH" "$print" "Octave"

# LaTeX
#mtt_check_var "$TEXFORMATS" "TEXFORMATS" "$print" "LaTeX"
#mtt_check_var "$TEXINPUTS" "TEXINPUTS" "$print" "LaTeX"
#mtt_check_var "$TEXFONTS" "TEXFONTS" "$print" "LaTeX"

# MTT variables
mtt_check_var "$MAKE" "MAKE" "$print" "MTT"
mtt_check_var "$MTTPATH" "MTTPATH" "$print" "MTT"
mtt_check_var "$MTT_CRS" "MTT_CRS" "$print" "MTT"
mtt_check_var "$MTT_COMPONENTS" "MTT_COMPONENTS" "$print" "MTT"
mtt_check_var "$MTT_EXAMPLES" "MTT_EXAMPLES" "$print" "MTT"
mtt_check_var "$MTT_LIB" "MTT_LIB" "$print" "MTT"
mtt_check_var "$MTT_REP" "MTT_REP" "$print" "MTT"
mtt_check_var "$MATRIX" "MATRIX" "$print" "MTT"
mtt_check_var "$SYMBOLIC" "SYMBOLIC" "$print" "MTT"
mtt_check_var "$FIG" "FIG" "$print" "MTT"
mtt_check_var "$PSVIEW" "PSVIEW" "$print" "MTT"
mtt_check_var "$PDFVIEW" "PDFVIEW" "$print" "MTT"
mtt_check_var "$HTMLVIEW" "HTMLVIEW" "$print" "MTT"
mtt_check_var "$DVIVIEW" "DVIVIEW" "$print" "MTT"
mtt_check_var "$CC" "CC" "$print" "MTT"
mtt_check_var "$LATEX2HTML" "LATEX2HTML" "$print" "MTT"
mtt_check_var "$MKOCTFILE" "MKOCTFILE" "$print" "MTT"
mtt_check_var "$MTT_CXX" "MTT_CXX" "$print" "MTT"
mtt_check_var "$MTT_CXXFLAGS" "MTT_CXXFLAGS" "$print" "MTT"
mtt_check_var "$MTT_CXXLIBS" "MTT_CXXLIBS" "$print" "MTT"
mtt_check_var "$MTT_CXXINCS" "MTT_CXXINCS" "$print" "MTT"
mtt_check_var "$MTT_LDFLAGS" "MTT_LDFLAGS" "$print" "MTT"


Added mtt/bin/mtt_cvs2deb version [3cd53ec09b].































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

# Script to create a .deb package from the current cvs sources.

usage ()
{
    cat <<EOF

usage: $0 [options]

options:
	-dir /path/to/mttroot
		Build package from local directory /path/to/mttroot instead of sourceforge CVS.

        -email email@address
		email address of packager
	-keep
		Keep temporary directory after package creation

	-log changelog text
		Write changelog text to changelog file
		Note: this must be the last option given.

	-name name
		name of packager
	-version #.#
		Use version #.# instead of the date to label the .deb

EOF
}

error ()
{
    echo $0: error: ${1:-"unknown error"} - aborting.
    exit 1
}

# use -email and -name to change
DEBFULLNAME=${DEBFULLNAME:-"Geraint Paul Bevan"}
DEBEMAIL=${DEBEMAIL:-"geraint@users.sourceforge.net"}

# default switches
default_sources="sourceforge"
default_logtext="snapshot from ${default_sources}."
default_version=`date --iso-8601 | sed 's/\-/./g'`

sources=${default_sources}
logtext=${default_logtext}
version="5.0."${default_version}
keeptmp="remove"

# look for command line arguments
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-dir) # package directory instead of cvs sources
	    # should be the path to the mttroot directory
	    sources=$2
	    if [ ! "`basename ${sources}`" = "mttroot" ]; then
		error "directory ${sources} is not location of mttroot"
	    fi
	    if [ "${logtext}" = "${default_logtext}" ]; then
		logtext="snapshot from local sources (${sources})"
	    fi
	    echo "Using source directory: ${sources}"
	    shift ;;	
	-email) # email address of packager
	    DEBEMAIL=$2
	    echo "Using email address ${DEBEMAIL}"
	    shift ;;
	-h | -help | --help)
	    usage
	    exit 0 ;;	
	-keep) # keep temporary directory
	    echo "Keeping temporary files"
	    keeptmp="keep" ;;
	-log) # specify changelog text
	    shift
	    logtext="$*"
	    echo "Using changelog text: ${logtext}"
	    shift ;;
	-name) # name of packager
	    DEBFULLNAME=$2
	    echo "Using name ${DEBFULLNAME}"
	    shift ;;
	-version) # specify version
	    version=$2
	    echo "Using version number: ${version}"
	    shift ;;
	*)
	    usage
	    error "unknown option $1" ;;	    
    esac
    shift
done

topdir=`pwd`

## Main MTT
echo "Packaging mtt ..."

# create working directory
tmpdir=`mktemp -d mtt_cvs2deb.tmp.XXXXXXXXXX`
if [ ! -d ${tmpdir} ]; then
    error "cannot create temporary directory"
fi

# copy sources to working directory
cd ${tmpdir}
if [ "${sources}" = "${default_sources}" ]; then
    cvs -z3 -d:pserver:anonymous@mtt.cvs.sf.net:/cvsroot/mtt export -D now mttroot/mtt
else
    mkdir -p ./mttroot
    cp -a ${sources}/mtt ./mttroot/mtt
    for dir in $(find . -type d -name CVS); do
	rm -r $dir
    done
fi

# generate tarball of sources
cd mttroot
tar -cf mtt-${version}.tar mtt/
tar --file mtt-${version}.tar --delete mtt/lib/examples
gzip mtt-${version}.tar
cd mtt

# create .deb
echo "$0: information: a \"Could not find diffs\" error in the next few lines is probably harmless"
uupdate -u mtt-${version}.tar.gz
cd ../mtt-${version}/debian
dch -v ${version} ${logtext}
cd ..
dpkg-buildpackage -rfakeroot -k${DEBEMAIL} -m${DEBEMAIL}
cd ..

# clean up
cp mtt*.deb ${topdir}/
cd ${topdir}
if [ "${keeptmp}" = "remove" ]; then
    rm -r ${tmpdir}
else
    echo Keeping temporary directory: ${tmpdir}
fi


## Examples
echo "Packaging mtt-examples ..."

# create working directory
tmpdir=`mktemp -d mtt_cvs2deb.tmp.XXXXXXXXXX`
if [ ! -d ${tmpdir} ]; then
    error "cannot create temporary directory"
fi

# copy sources to working directory
cd ${tmpdir}
if [ "${sources}" = "${default_sources}" ]; then
    cvs -z3 -d:pserver:anonymous@mtt.cvs.sf.net:/cvsroot/mtt export -D now mttroot/mtt/lib/examples
else
    mkdir -p ./mttroot/mtt/lib/
    cp -a ${sources}/mtt/lib/examples ./mttroot/mtt/lib
    for dir in $(find . -type d -name CVS); do
	rm -r $dir
    done
fi

# generate tarball of sources
cd mttroot/mtt/lib
tar -cf mtt-examples-${version}.tar examples/
gzip mtt-examples-${version}.tar
cd examples

# create .deb
echo "$0: information: a \"Could not find diffs\" error in the next few lines is probably harmless"
uupdate -u mtt-examples-${version}.tar.gz
cd ../mtt-examples-${version}/debian
dch -v ${version} ${logtext}
cd ..
dpkg-buildpackage -rfakeroot -k${DEBEMAIL} -m${DEBEMAIL}
cd ..

# clean up
cp mtt-examples*.deb ${topdir}/
cd ${topdir}
if [ "${keeptmp}" = "remove" ]; then
    rm -r ${tmpdir}
else
    echo Keeping temporary directory: ${tmpdir}
fi

exit 0

Added mtt/bin/mtt_deb2cd version [4cf587b080].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

# Script to create a CD-ready directory from .deb package
# output from script will be a directory which should be copied to / of CDROM
# user of CDROM should run "apt-cdrom add"

usage ()
{
    cat <<EOF

usage: $0 debfile

EOF
}

error ()
{
    echo $0: error: ${1:-"unknown error"} - aborting.
    exit 1
}

debfile="$1"

# should be root for some of these commands
if [ ! `whoami` = "root" ]; then
    export my_user=${USER}
    export my_group=`groups | gawk '{print $1}'`
    echo root password required
    exec su -p -c "$0 $*"
    error "root authorisation failed"
fi

if [ -z "${debfile}" ]; then
    usage
    error "No debfile given"
fi

topdir=`pwd`

# create working directory
tmpdir=`mktemp -d mtt_deb2cd.tmp.XXXXXXXXXX`
if [ ! -d ${tmpdir} ]; then
    error "cannot create temporary directory"
fi

cp ${debfile} ${tmpdir}/
cd ${tmpdir}
mkdir .disk
echo "MTT (${debfile}, `date`)" > .disk/info
tmpfile=`mktemp mtt_deb2cd.tmp.XXXXXXXXXX`
echo "Scanning .deb packages"
dpkg-scanpackages . ${tmpfile} | gzip > ./Packages.gz
rm ${tmpfile}
# create Redhat package
echo "Creating .rpm, please wait ..."
alien --to-rpm ${debfile}
chown -R ${my_user:-"root"}.${my_group:-"root"} .
cd ..

echo "Directory created (${tmpdir}) - copy this to iso9660 image as /"

exit 0

Added mtt/bin/mtt_find version [a16165e9f1].





























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_find
# mtt_find path name operation
# P.J.Gawthrop Nov 1996
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/10/03 18:29:57  peterg
## *** empty log message ***
##
## Revision 1.6  1998/07/17 19:47:35  peterg
## Minor changes
##
## Revision 1.5  1998/07/17 07:50:33  peterg
## Now handles library name
## Returns a status
##   0 if exactly one result
##   1 if no results
##   2 if two or more results
##   3 if utterly confused
##
## Revision 1.4  1998/07/16 20:40:24  peterg
## Cleaned up algorithms
##
## Revision 1.3  1998/07/16 09:15:34  peterg
## Now prints:
## 	dir
## 	name_lbl.txt
##         access time
##
## Revision 1.2  1997/09/04 09:15:19  peterg
## Includes summary line as well as description lines
##
## Revision 1.1  1996/11/10 10:48:45  peterg
## Initial revision
##
###############################################################

# Set up dummy file
rm -f mtt_junk
touch mtt_junk

# Interpret the arguments
path="$1"

if [ -n "$2" ]; then
    name=`basename $2`
    longname=$2
    Name="-name $name"
else
    name='*'
fi

# If this is non-empty just print the path
path_only=$3

# Find all dirs in path with same name as component
# AND the path contains the full (name+library) name
paths=`echo $path | tr ":" " "`
foundpath=`\
for thepath in $paths; do
    find $thepath -type d  $Name -print 
done |\
sort -u |\
grep "$longname"`

# If empty set foundpath to the simple components path
if [  -z "$foundpath"  ]; then
  foundpath="$MTT_LIB/comp/simple"
fi

# If non-null result, check that the name_ext file exists in dir name
# and print dirname and file name and last access time
if [ -n "$foundpath" ]; then
  if [ -n "$path_only" ]; then
    format='%h\n';
  else
    format='%h\t%f\t%Ac\n';
  fi
  for thepath in $foundpath ;  do
    if [ "$thepath" = "$MTT_COMPONENTS/simple" ]; then
        ext='cause.m'; # finds _cause.m
        simple='simple';
    else
        ext='lbl.txt'; # finds _lbl.txt
    fi    
     dirname=`basename $thepath`
     if [ -n "$simple" ]; then
      fullname="$name"_"$ext"
    else
      fullname="$dirname"_"$ext"
    fi
  find $thepath -maxdepth 1 -name $fullname  -printf $format;
 done |\
 tee mtt_junk
fi

# Check exit status and return 
hits=`wc mtt_junk | gawk '{print $1}'`
rm -f mtt_junk

if [ $hits = "1" ]; then
    exit 0
elif [ $hits = "0" ]; then
    exit 1
elif [ $hits > "1" ]; then
    exit 2
else
    exit 3
fi





Added mtt/bin/mtt_help version [92a6751c3c].






































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_help

# P.J.Gawthrop Nov 1996
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2000/10/03 18:29:26  peterg
## crs now works after a fashion
##
## Revision 1.13  2000/04/04 15:22:44  peterg
## Major changes: simple components now work
## Single components now work
##
## Revision 1.12  1998/07/21 08:47:59  peterg
## Default null $2 (regexp) to '^' - ie match any line
##
## Revision 1.11  1998/07/16 20:41:05  peterg
## Now uses new mtt_help
##
## Revision 1.10  1998/05/18 08:35:19  peterg
## Surround arguments to tr with ""
##
## Revision 1.9  1998/03/26 08:23:02  peterg
## Use mixed case Topic for *) part of case sttement
##
## Revision 1.8  1998/03/22 21:13:17  peterg
## Fixed bug in above
##
## Revision 1.7  1998/03/22 20:21:11  peterg
## $topic now converted to lower case.
##
## Revision 1.6  1997/09/04 09:35:04  peterg
## Changed $ext to give accurate match -- matches t ot m at end of
## filename
##
# Revision 1.5  1997/09/04  09:21:01  peterg
# Added context-dependent sort.
#
# Revision 1.4  1997/09/04  09:16:29  peterg
# Removed sort -u
#
## Revision 1.3  1996/11/09 21:10:20  peterg
## Tidied up searches by putting everyrhing into lib.
##
# Revision 1.2  1996/11/02  10:22:54  peterg
# Now browses crs.
#
## Revision 1.1  1996/11/01 12:34:54  peterg
## Initial revision
##
###############################################################

comment='#';
Topic=$1
topic=`echo $Topic | tr "[A-Z]" "[a-z]"`

if [ -n "$2" ]; then
    regexp=$2;
else
    regexp='^';
fi

if [ "$topic" = "" ]; then
    echo 'Usage: mtt help representations'
    echo '       mtt help simple'
    echo '       mtt help components'
    echo '       mtt help examples' 
    echo '       mtt help CRs'    
    echo '       mtt help representations <match_string>'
    echo '       mtt help components <match_string>'
    echo '       mtt help examples  <match_string>'
    echo '       mtt help CRs <match_string>'
    echo '       mtt help <component_or_example_or_CR_name>'
  exit
fi

ext='_[cl]*.*[mt]'
summary='[%#]SUMMARY'
description='[%#]DESCRIPTION'
alias='[%#]ALIAS'
lbl="_lbl.txt"

case $topic in
  components)
    key=$summary 
    find_path="$MTT_COMPONENTS"
    name=''
    sort='sort -u'
    blurb="components";;

  simple)
    key=$summary 
    find_path="$MTT_COMPONENTS/simple"
    name=''
    sort='sort -u'
    blurb="simple components";;

  crs) 
    key=$summary 
    find_path=$MTT_CRS/r
    name='*.cr'
    sort='sort -u'
    blurb="constitutive relationships";;

  examples) 
    key=$summary 
    find_path=$MTT_EXAMPLES
    name=''
    all='all'
    sort='sort -u'
    blurb="Examples";;

  representations)
    key=$summary 
    find_path=$MTTPATH
    name='mtt'
    all='all'
    sort='sort -u'
    blurb="Representations";;

  *)
    other=OTHER;
    key="$summary|$description|$alias" 
    find_path=$MTT_LIB
    name=$Topic
    all='all'
    sort='cat'
    blurb=$Topic;;     
esac

subtopic=$2
if [ "$subtopic" = "" ]; then
  subtopic='.'
fi;


case $topic in
    representations)
         echo $comment $blurb
         mtt2reps_txt

	;;
    crs)
	echo  $comment $blurb
        find $find_path -name "$name" -print |\
        gawk '{print "grep", key, $1}' key=$key | sh |\
        sed "s/$key //" | $sort
	;;
    *)
	
    fullnames=`mtt_find $find_path "$name" | gawk '{printf("%s/%s\n",$1,$2)}'`
    N=`echo $fullnames | wc -w`;
    if [ -z "$fullnames" ]; then
	echo $comment No $blurb found.
    else
    echo $comment $N $blurb found.
    for fullname in $fullnames; do
        name=`basename $fullname`
	if [ -n "$other" ]; then
	cat $fullname | egrep $key 
	else
        info=`cat $fullname | egrep $key | gawk '{for (i=2;i<=NF;i++) print $i}'`
	category=`echo $fullname |   sed "s!$find_path/!!" ` 
        category=`dirname $category`
	echo $category $name $info
	fi
    done
    fi
  esac
exit


  gawk '{print "cat " $1 "/" $2}'  | sh |\
  egrep $key  | egrep $regexp  |\
  sed "s/$summary[	]*//" |\
  sed "s/$description[	]*/  /" |\
  sed "s/$alias[	]*/  Alias: /" |\
  sed "s!$find_path/!!" |\
  $sort








Added mtt/bin/mtt_pause version [9430af6a72].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

## mtt_pause: Just waits for an EOF
## P J Gawthrop April 2000
## Copyright (C) 2000 by Peter J. Gawthrop

echo $*

mtt $*
cat>/dev/null

Added mtt/bin/mtt_rename version [f11f51dae2].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_rename

# P.J.Gawthrop Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2002/04/22 08:05:26  gawthrop
## New regexp.
##
## Revision 1.5  2000/12/27 13:11:42  peterg
## *** empty log message ***
##
## Revision 1.4  1998/08/15 13:50:22  peterg
## Doesn't zap preexisting files
##
## Revision 1.3  1998/08/14 15:37:38  peterg
## rename now copies - no delete
##
## Revision 1.2  1998/01/06 13:57:39  peterg
## Now removes old version after copying
##
# Revision 1.1  1998/01/06  13:48:23  peterg
# Initial revision
#
###############################################################

old_name=$1
new_name=$2
extension=$3

left='[^a-zA-Z]'
right=$left
if [ -f "$new_name$extension" ]; then
   echo  "$new_name$extension already exists -- no action taken"
   exit
fi
if ls $old_name$extension > /dev/null 2>&1 
    then
	echo Renaming $old_name$extension to $new_name$extension
	sed \
         -e "s/\($left\)$old_name\($right\)/\1$new_name\2/g" \
         -e "s/^$old_name\($right\)/$new_name\1/g" \
        <$old_name$extension >$new_name$extension
fi



Added mtt/bin/mtt_rename_all version [2428ae4c1a].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_rename_all

# P.J.Gawthrop Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/03/17 11:50:18  peterg
## Added pic.fig -- schematic
##
## Revision 1.6  1998/07/22 15:20:06  peterg
## Added state.txt
##
## Revision 1.5  1998/04/13 09:15:36  peterg
## Added obspar
##
## Revision 1.4  1998/03/27 07:38:32  peterg
## simpar.r ---> simpar.txt
##
## Revision 1.3  1998/03/26 14:47:43  peterg
## Addes subs and cr
##
## Revision 1.2  1998/03/02 17:14:06  peterg
## Added simpar to list
##
## Revision 1.1  1998/01/06 13:57:59  peterg
## Initial revision
##
###############################################################

old_name=$1
new_name=$2

mtt_rename $old_name $new_name _abg.fig
mtt_rename $old_name $new_name _cr.r
mtt_rename $old_name $new_name _desc.tex
mtt_rename $old_name $new_name _input.txt
mtt_rename $old_name $new_name _lbl.txt
mtt_rename $old_name $new_name _logic.txt
mtt_rename $old_name $new_name _numpar.txt
mtt_rename $old_name $new_name _obspar.r
mtt_rename $old_name $new_name _odes.h
mtt_rename $old_name $new_name _rep.txt
mtt_rename $old_name $new_name _pic.fig
mtt_rename $old_name $new_name _simp.r
mtt_rename $old_name $new_name _simpar.txt
mtt_rename $old_name $new_name _sspar.r
mtt_rename $old_name $new_name _state.txt
mtt_rename $old_name $new_name _subs.r

Added mtt/bin/mtt_version version [6c3f7fc85e].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_version
# Prints out version of a GNU-style tool

# P.J.Gawthrop May 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1999/12/20 02:08:38  peterg
## Added second arg option
##
## Revision 1.2  1998/05/28 09:31:44  peterg
## Cosmetic changes
##
## Revision 1.1  1998/05/28 09:31:13  peterg
## Initial revision
##
###############################################################

if [ -z "$2" ]; then
    echo Trying $1 ...
    ver=`$1 --version | head -1`
     if [ -n "$ver" ]; then
        echo is OK and has version $ver.
    else
        echo Either $1 does not exist or is not the GNU version.
    fi
else
    echo $1: $2
fi








Added mtt/bin/mtt_versions version [631ca6b658].

























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_versions

# P.J.Gawthrop May 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2005/02/17 22:15:35  geraint
## Added missing quotes to conditional expression.
##
## Revision 1.5  2005/02/17 18:36:38  geraint
## Removed a bash-ism: replaced [[ conditional ]] with [ conditional ]
##
## Revision 1.4  2003/08/06 22:39:40  geraint
## Fixed reporting of non-existent software, no longer says "is OK and has version .".
##
## Revision 1.3  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.2  2000/11/13 21:40:26  peterg
## Sorted out the non-gnu
##
## Revision 1.1  1998/05/28 09:24:41  peterg
## Initial revision
##
###############################################################

echo Versions of mtt and its components on `date`

## gnu standard --version
mtt_version mtt

echo Doing the GNU components
mtt_version gawk
mtt_version basename
mtt_version cat
mtt_version cp
mtt_version dirname
mtt_version gcc
mtt_version grep
mtt_version head
mtt_version make
mtt_version octave
mtt_version sed
mtt_version tail
mtt_version tr

## Non standards
echo Doing the non-GNU components

print_version ()
{
    program=${1:-"Error: unknown program"}
    shift;
    version=$*
    if [ "${version:-""}" ]; then
	echo is OK and has version $version.
    else
	echo $program does not exist.
    fi
}

echo Trying xfig ...
xfig -help 2> mtt_junk; version=`grep Xfig mtt_junk`
print_version xfig $version

echo Trying fig2dev ...
fig2dev -h > mtt_junk; version=`grep -i patchlevel mtt_junk`
print_version fig2dev $version

echo Trying reduce ...
reduce -w >mtt_junk 2>1 <<EOF
bye;
EOF
version=`grep  -i REDUCE mtt_junk`
print_version reduce $version


Added mtt/bin/mtt_xargs.sh version [0e001e0d54].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
#! /bin/sh

cmd=$1
for arg in $2; do
	eval $cmd $arg
done

Added mtt/bin/mttrc version [38af940af8].





































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mttrc - sets up paths etc for mtt
# Usage: mttrc 

# Copyright (c) P.J.Gawthrop 1996,1977.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.45  2009/06/26 01:08:49  geraint
## Octave load path no longer accepts trailing // as recursive.
## Path is now calculated using find, which is much quicker than Octave's genpath()
##
## Revision 1.44  2006/04/25 23:24:29  geraint
## Reverted to simple g++ for MTT_CXX. Trying to force the version causes library problems.
##
## Revision 1.43  2006/02/09 23:49:40  geraint
## added rtxi build flags
##
## Revision 1.42  2005/11/16 00:43:15  geraint
## rtxi
##
## Revision 1.41  2004/02/17 17:53:34  geraint
## Fixed [ 898739 ] libhdf5 dependency breaks -cc reps.
## Now uses mkoctfile to determine include and library flags.
##
## Revision 1.40  2003/09/23 15:57:18  gawthrop
## And back to gv
##
## Revision 1.39  2003/09/22 17:38:56  gawthrop
## gv --> ghostview
##
## Revision 1.38  2003/07/13 21:53:24  geraint
## Updated to conform to latest Octave (tested with 2.1.49).
## - the pathsearch library was merged into liboctave last year
## - static_cast no longer seems to work between Matrix and ColumnVector
##
## Revision 1.37  2002/09/19 08:08:15  gawthrop
## Updated documentation documentation
##
## Revision 1.36  2002/08/28 15:48:00  geraint
## Updated mttrc to make standalone C++ compilation configuration clearer.
##
## Revision 1.35  2002/08/06 09:56:54  geraint
## Updated to work with changes in unstable version of Octave 2.1.36.
## Tested with 2.0.17 (ok) but will break earlier unstables (2.1.(<=35)).
##
## Revision 1.34  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.33  2002/05/08 11:39:36  gawthrop
## Added MTT_REP to PATH
##
## Revision 1.32  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.31  2002/05/02 20:12:45  geraint
## Added -Wl,--rpath to MTT_CXXLIBS. Sets the runtime linker path so that the
## sys-admin does not have to ldconfig the octave directory for -cc to work.
##
## Revision 1.30  2002/05/02 11:10:11  geraint
## s/loctave/loctinterp/
##
## Revision 1.29  2002/05/02 11:03:46  geraint
## Reinstated -liboctinterp and -lncurses; needed by xleftdiv.
##
## Revision 1.28  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.27  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.26  2002/04/26 16:16:33  geraint
## Removed unnecessary variables PLAT and GCCVERS.
##
## Revision 1.25  2002/04/02 09:16:39  geraint
## Tidied up library search paths, now assumes that system libraries are set up correctly.
## For Debian, this means installing the following: blas-dev, fftw-dev, lapack-dev, libncurses5-dev, libkpathsea-dev, libreadline-dev
## It may also be necessary to run /sbin/ldconfig on the relevant directories (especially Octave's).
##
## Revision 1.24  2001/10/15 14:28:35  gawthrop
## Now has . at start of components library path $MTT_COMPONENTS
##
## Revision 1.23  2001/07/24 22:32:49  gawthrop
## Use gv, not ghostview
##
## Revision 1.22  2001/04/12 03:08:00  geraint
## Improved sh->csh conversion, reduces environment namespace pollution.
## Still need to do proper if [ -z $MTT_BASE ] ... else ... fi conversion.
##
## Revision 1.21  2001/04/10 13:56:13  gawthrop
## Uses standard mkoctfile
##
## Revision 1.20  2001/04/10 13:08:19  gawthrop
## Smoother translation to .cs using sh2csh
##
## Revision 1.19  2001/03/30 15:13:49  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.18  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.17.2.4  2001/03/06 03:48:43  geraint
## Print additional environment variable for "mtt -p".
## MTT_LDFLAGS defaults to " " to avoid installation warning.
##
## Revision 1.17.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.17.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.17.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.17  2000/12/27 16:46:13  peterg
## Stripped the mtt- from paths
##
## Revision 1.16  2000/12/27 15:16:44  peterg
## If then else format
##
## Revision 1.15  2000/12/27 14:57:43  peterg
## Now takes the base path as an argument
##
## Revision 1.14  2000/12/27 13:11:43  peterg
## *** empty log message ***
##
## Revision 1.13  2000/10/03 12:12:14  peterg
## New path structure to account for three way split in mtt tree
##
## Revision 1.12  2000/09/18 12:17:07  peterg
## Now includes to control system toolbox in OCTAVE_PATH
## Don't use -path stuff - use :: instead.
##
## Revision 1.11  2000/05/21 17:55:15  peterg
## New rep path
##
## Revision 1.10  2000/05/16 11:41:23  peterg
## *** empty log message ***
##
## Revision 1.9  1999/03/11 04:02:19  peterg
## Revised so that sh2csh does its stuff.
##
## Revision 1.8  1998/07/17 19:48:46  peterg
## *** empty log message ***
##
## Revision 1.7  1998/03/24 09:11:49  peterg
## Compatible with .csh version
##
## Revision 1.6  1998/03/13 11:53:29  peterg
## reduce --> reduce 64
##
## Revision 1.5  1998/01/16 08:55:01  peterg
## MAKE=make
##
## Revision 1.4  1998/01/06 09:14:51  peterg
## Added latex2html to setup
##
# Revision 1.3  1998/01/06  09:11:26  peterg
# Removed matlab from the setup
#
# Revision 1.2  1997/12/04  10:49:16  peterg
# Put under RCS at last
# Added CC variable
#
###############################################################

## When using csh, replace $1 by the mtt base path, eg /usr/share/mtt/latest
export MTT_BASE=$1

if [ -z "$MTT_BASE" ]; then
  echo mttrc requires one argument: eg mttrc /usr/share/mtt/latest
else
  echo Setting paths with base $MTT_BASE
  # The following line sets up the make to use -- gmake is the standard 
  # but you may wish to use lsmake for parallelism
  export MAKE='make'
  
  # The following sets up the c compiler
  export CC='gcc'
  
  # Setup the paths
  export MTTPATH=$MTT_BASE/bin
  export MTT_LIB=$MTT_BASE/lib
  export MTT_DOC=$MTT_BASE/doc
  export MTT_CC=$MTT_BASE/cc
  
  export MTT_COMPONENTS=.:$MTT_LIB/comp
  export MTT_CRS=$MTT_LIB/cr
  export MTT_EXAMPLES=$MTT_LIB/examples
  export MTT_REP=$MTT_LIB/rep
  
  export PATH=$PATH\:$MTTPATH\:$MTTPATH/trans\:$MTT_CC\:$MTT_REP
  
  #Setup octave
##<<<<<<< mttrc
##  export MATRIX_PATH=$MTTPATH/trans/m/
##  export MATRIX_PATH=$MATRIX_PATH\:$MTT_LIB/comp/simple/
##  export MATRIX_PATH=$MATRIX_PATH\:$MTT_LIB/control/
##  export MATRIX_PATH=$MATRIX_PATH\:$MTT_LIB/octave/\:\:
  
##=======
  MATRIX="octave"
  #MATRIX_PATH1=$(echo "genpath('$MTTPATH/trans/m')"     |$MATRIX -q | awk '{print $3}') 
  #MATRIX_PATH2=$(echo "genpath('$MTT_LIB/comp/simple')" |$MATRIX -q | awk '{print $3}') 
  #MATRIX_PATH3=$(echo "genpath('$MTT_LIB/control')"     |$MATRIX -q | awk '{print $3}') 
  #MATRIX_PATH4=$(echo "genpath('$MTT_LIB/octave')"      |$MATRIX -q | awk '{print $3}') 
  #export MATRIX_PATH=$MATRIX_PATH1:$MATRIX_PATH2:$MATRIX_PATH3:$MATRIX_PATH4
  MATRIX_PATH1=$(find $MTTPATH/trans/m     -type d|grep -v CVS|awk '{printf ":%s", $0}')
  MATRIX_PATH2=$(find $MTT_LIB/comp/simple -type d|grep -v CVS|awk '{printf ":%s", $0}')
  MATRIX_PATH3=$(find $MTT_LIB/control     -type d|grep -v CVS|awk '{printf ":%s", $0}')
  MATRIX_PATH4=$(find $MTT_LIB/octave      -type d|grep -v CVS|awk '{printf ":%s", $0}')
  export MATRIX_PATH=$MATRIX_PATH1:$MATRIX_PATH2:$MATRIX_PATH3:$MATRIX_PATH4
##>>>>>>> 1.45
  export OCTAVE_PATH=.\:$MATRIX_PATH
##<<<<<<< mttrc
  export MATRIX="octave --path $OCTAVE_PATH"
##=======
##  export MATRIX="$MATRIX --path $OCTAVE_PATH"
##>>>>>>> 1.45
  
  # Setup the symbolic stuff
  ##export SYMBOLIC='reduce 64'
  export SYMBOLIC='reduce -w'
  
  
  # Setup xfig
  export FIG="xfig  \
  	-startfontsize 20 \
  	-metric \
  	-portrait \
  	-startgridmode 2 \
  	-pheight 21 \
  	-pwidth 30 \
  	-library_dir $MTT_LIB/xfig/\
  	"
  
  # Setup ps viewer
  export PSVIEW='evince'
  
  # Setup pdf viewer
  export PDFVIEW='acroread'
  
  # Setup html viewer
  export HTMLVIEW='firefox'
  
  # Setup dvi viewer
  export DVIVIEW='xdvi'
  
  # Setup latex2html
  export LATEX2HTML="latex2html -contents_in_navigation -index_in_navigation -address http://mtt.sourceforge.net"
  
  # Ascend stuff
  export ASCENDLIBRARY=$MTTPATH/ascend/lib
  
  # Oct file generation - use version with no optimisation.
  #export MKOCTFILE=$MTT_LIB/octave/mkoctfile # This for no optimisation
  export MKOCTFILE=mkoctfile

  #########################################################################################
  ##
  ## Configure environment for standalone compilation of files linked with Octave libraries
  ## (required for ode2odes.exe only)
  
  # location of Octave directories on local system (usually /usr, /usr/local or /opt)
      
  OCTAVEPREFIX="/usr"
  
  # include paths for Octave
  
  IOCTAVE="-I${OCTAVEPREFIX}/include/octave/ -I${OCTAVEPREFIX}/include/octave/octave"
      
  # include and library paths for Octave
      
  if [ -z `which ${MKOCTFILE}` ]; then
      # Octave development stuff not installed
      # C++ and .oct representations will not work
      OCTAVE_INC_FLAGS=" "
      OCTAVE_LIB_FLAGS=" "
  else
      OCTAVE_INC_FLAGS="`${MKOCTFILE} --print INCFLAGS`"
      OCTAVE_LIB_FLAGS="\
        `${MKOCTFILE} --print LFLAGS`              \
        `${MKOCTFILE} --print LIBOCTAVE`           \
        `${MKOCTFILE} --print LIBCRUFT`            \
        `${MKOCTFILE} --print LIBOCTINTERP`        \
        `${MKOCTFILE} --print BLAS_LIBS`           \
        `${MKOCTFILE} --print FFTW_LIBS`           \
        `${MKOCTFILE} --print LIBS`                \
        `${MKOCTFILE} --print FLIBS`               \
        `${MKOCTFILE} --print RLD_FLAG`"
  fi
      
  # C++ compiler options
      
  DEBUG="-g"
  OPTIM="-O3"
  FLAGS="-fno-rtti -fno-exceptions -fno-implicit-templates"
  
  # exported variables
      
  export MTT_CXX="g++"
  export MTT_CXXFLAGS="${DEBUG} ${OPTIM} ${FLAGS}"
  export MTT_CXXLIBS="${OCTAVE_LIB_FLAGS}"
  export MTT_CXXINCS="-I. -I${MTT_LIB}/cc ${OCTAVE_INC_FLAGS}"
  export MTT_LDFLAGS=" "
  
  ## End of Octave environment configuration
  ##
  #########################################################################################

  ############################################################  
  ##
  ## Configure environment for compilation of Matlab mex files
    
    MATLAB_ARCH="glnx86"
    MATLAB_ROOT="/usr/local/matlab6p1"
    MATLAB_FLAGS="-shared -fPIC -ansi -D_GNU_SOURCE -pthread"
    MATLAB_INCS="-I${MATLAB_ROOT}/extern/include"
    MATLAB_LIBS="-Wl,--rpath-link,${MATLAB_ROOT}/extern/lib/${MATLAB_ARCH},--rpath-link,${MATLAB_ROOT}/bin/${MATLAB_ARCH} -L${MATLAB_ROOT}/bin/${MATLAB_ARCH} -lmx -lmex -lm"

    # exported variables

    export MTT_MATLAB_FLAGS="${MATLAB_FLAGS} ${MATLAB_INCS} ${MATLAB_LIBS}"

  ## End of Matlab environment configuration
  ##
  #############################################################

  #######################################################
  ##
  ## Configure environment for compilation of RTXI module

##<<<<<<< mttrc
 ## RTXI_INCS="-I/usr/local/src/mtt/rtxi/rtxi_cvs_30Sep05/include -I/usr/include/qt3 -I/home/peterg/Development/rtxi/include"
#  MORE_RTXI_INCS="-I/usr/realtime/include -I/usr/src/linux/include"
##=======
  ROOT="/usr/local/rtxi-knoppix"

  RTXI_LIBTOOL="${ROOT}/usr/local/lib/rtxi/libtool"
  RTXI_CXX="g++-3.3"
  RTXI_CXXLD="g++-3.3"
  RTXI_CXXCOMPILE="${RTXI_LIBTOOL} --mode=compile --tag CXX ${RTXI_CXX}"
  RTXI_CXXLINK="${RTXI_LIBTOOL} --mode=link --tag CXX ${RTXI_CXXLD}"

  RTXI_INCS=""
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/share/qt3/include"
  RTXI_INCS="${RTXI_INCS} -I."
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/realtime/include"
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/share/qt3/include"
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/src/comedi/include"
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/src/rtxi/include"

  RTXI_DEFS="-D_REENTRANT -DQT_THREAD_SUPPORT"
  RTXI_CXXFLAGS="-g -O2 ${RTXI_INCS} ${RTXI_DEFS}"
  RTXI_LIBS="-L${ROOT}/usr/share/qt3/lib -lqt-mt"
##>>>>>>> 1.45
  RTXI_FLAGS="-DHAVE_CONFIG_H -D_REENTRANT -DQT_THREAD_SUPPORT"
  RTXI_LDFLAGS="-L${ROOT}/usr/realtime/lib -lpthread -module -avoid-version"
  RTXI_RPATH="${ROOT}/usr/local/lib/rtxi/models/"

  export MTT_RTXI_CXXCOMPILE="${RTXI_CXXCOMPILE}"
  export MTT_RTXI_CXXLINK="${RTXI_CXXLINK}"
  export MTT_RTXI_LIBTOOL="${RTXI_LIBTOOL}"
  export MTT_RTXI_CXXFLAGS="${RTXI_CXXFLAGS}"
  export MTT_RTXI_LIBS="${RTXI_LIBS}"
  export MTT_RTXI_FLAGS="${RTXI_RTXI_FLAGS}"
  export MTT_RTXI_LDFLAGS="${RTXI_LDFLAGS}"
  export MTT_RTXI_RPATH="${RTXI_RPATH}"

  ## End of RTXI environment configuration
  ##
  #############################################################

fi

Added mtt/bin/mttrc.csh version [7afd308e13].




















































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/csh
## Automatically generated from bashrc on Wed Aug 28 15:17:42 BST 2002 - DO NOT EDIT
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mttrc - sets up paths etc for mtt
# Usage: mttrc 

# Copyright (c) P.J.Gawthrop 1996,1977.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.35  2002/08/06 09:56:54  geraint
## Updated to work with changes in unstable version of Octave 2.1.36.
## Tested with 2.0.17 (ok) but will break earlier unstables (2.1.(<=35)).
##
## Revision 1.34  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.33  2002/05/08 11:39:36  gawthrop
## Added MTT_REP to PATH
##
## Revision 1.32  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.31  2002/05/02 20:12:45  geraint
## Added -Wl,--rpath to MTT_CXXLIBS. Sets the runtime linker path so that the
## sys-admin does not have to ldconfig the octave directory for -cc to work.
##
## Revision 1.30  2002/05/02 11:10:11  geraint
## s/loctave/loctinterp/
##
## Revision 1.29  2002/05/02 11:03:46  geraint
## Reinstated -liboctinterp and -lncurses; needed by xleftdiv.
##
## Revision 1.28  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.27  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.26  2002/04/26 16:16:33  geraint
## Removed unnecessary variables PLAT and GCCVERS.
##
## Revision 1.25  2002/04/02 09:16:39  geraint
## Tidied up library search paths, now assumes that system libraries are set up correctly.
## For Debian, this means installing the following: blas-dev, fftw-dev, lapack-dev, libncurses5-dev, libkpathsea-dev, libreadline-dev
## It may also be necessary to run /sbin/ldconfig on the relevant directories (especially Octave's).
##
## Revision 1.24  2001/10/15 14:28:35  gawthrop
## Now has . at start of components library path $MTT_COMPONENTS
##
## Revision 1.23  2001/07/24 22:32:49  gawthrop
## Use gv, not ghostview
##
## Revision 1.22  2001/04/12 03:08:00  geraint
## Improved sh->csh conversion, reduces environment namespace pollution.
##
## Revision 1.21  2001/04/10 13:56:13  gawthrop
## Uses standard mkoctfile
##
## Revision 1.20  2001/04/10 13:08:19  gawthrop
## Smoother translation to .cs using sh2csh
##
## Revision 1.19  2001/03/30 15:13:49  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.18  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.17.2.4  2001/03/06 03:48:43  geraint
## Print additional environment variable for "mtt -p".
## MTT_LDFLAGS defaults to " " to avoid installation warning.
##
## Revision 1.17.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.17.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.17.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.17  2000/12/27 16:46:13  peterg
## Stripped the mtt- from paths
##
## Revision 1.16  2000/12/27 15:16:44  peterg
##
## Revision 1.15  2000/12/27 14:57:43  peterg
## Now takes the base path as an argument
##
## Revision 1.14  2000/12/27 13:11:43  peterg
## *** empty log message ***
##
## Revision 1.13  2000/10/03 12:12:14  peterg
## New path structure to account for three way split in mtt tree
##
## Revision 1.12  2000/09/18 12:17:07  peterg
## Now includes to control system toolbox in OCTAVE_PATH
## Don't use -path stuff - use :: instead.
##
## Revision 1.11  2000/05/21 17:55:15  peterg
## New rep path
##
## Revision 1.10  2000/05/16 11:41:23  peterg
## *** empty log message ***
##
## Revision 1.9  1999/03/11 04:02:19  peterg
## Revised so that sh2csh does its stuff.
##
## Revision 1.8  1998/07/17 19:48:46  peterg
## *** empty log message ***
##
## Revision 1.7  1998/03/24 09:11:49  peterg
## Compatible with .csh version
##
## Revision 1.6  1998/03/13 11:53:29  peterg
## reduce --> reduce 64
##
## Revision 1.5  1998/01/16 08:55:01  peterg
## MAKE=make
##
## Revision 1.4  1998/01/06 09:14:51  peterg
## Added latex2html to setup
##
# Revision 1.3  1998/01/06  09:11:26  peterg
# Removed matlab from the setup
#
# Revision 1.2  1997/12/04  10:49:16  peterg
# Put under RCS at last
# Added CC variable
#
###############################################################

## When using csh, replace /usr/local/mtt/mttroot/mtt by the mtt base path, eg /usr/share/mtt/latest
setenv MTT_BASE /usr/local/mtt/mttroot/mtt

  echo Setting paths with base $MTT_BASE
  # The following line sets up the make to use -- gmake is the standard 
  # but you may wish to use lsmake for parallelism
  setenv MAKE 'make'
  
  # The following sets up the c compiler
  setenv CC 'gcc'
  
  # Setup the paths
  setenv MTTPATH $MTT_BASE/bin
  setenv MTT_LIB $MTT_BASE/lib
  setenv MTT_DOC $MTT_BASE/doc
  setenv MTT_CC $MTT_BASE/cc
  
  setenv MTT_COMPONENTS .:$MTT_LIB/comp
  setenv MTT_CRS $MTT_LIB/cr
  setenv MTT_EXAMPLES $MTT_LIB/examples
  setenv MTT_REP $MTT_LIB/rep
  
  setenv PATH $PATH\:$MTTPATH\:$MTTPATH/trans\:$MTT_CC\:$MTT_REP
  
  #Setup octave
  setenv MATRIX_PATH $MTTPATH/trans/m//
  setenv MATRIX_PATH $MATRIX_PATH\:$MTT_LIB/comp/simple//
  setenv MATRIX_PATH $MATRIX_PATH\:$MTT_LIB/control//
  setenv MATRIX_PATH $MATRIX_PATH\:$MTT_LIB/octave//\:\:
  
  setenv OCTAVE_PATH .\:$MATRIX_PATH
  setenv MATRIX "octave"
  
  # Setup the symbolic stuff
  setenv SYMBOLIC 'reduce 64'
  
  
  # Setup xfig
  setenv FIG "xfig  \
  	-startfontsize 20 \
  	-metric \
  	-portrait \
  	-startgridmode 2 \
  	-pheight 21 \
  	-pwidth 30 \
  	-library_dir $MTT_LIB/xfig/\
  	"
  
  # Setup ps viewer
  setenv PSVIEW 'gv'
  
  # Setup pdf viewer
  setenv PDFVIEW 'acroread'
  
  # Setup html viewer
  setenv HTMLVIEW 'netscape'
  
  # Setup dvi viewer
  setenv DVIVIEW 'xdvi'
  
  # Setup latex2html
  setenv LATEX2HTML "latex2html -contents_in_navigation -index_in_navigation -address http://mtt.sourceforge.net"
  
  # Ascend stuff
  setenv ASCENDLIBRARY $MTTPATH/ascend/lib
  
  # Oct file generation - use version with no optimisation.
  #setenv MKOCTFILE $MTT_LIB/octave/mkoctfile # This for no optimisation
  setenv MKOCTFILE mkoctfile

  #########################################################################################
  ##
  ## Configure environment for standalone compilation of files linked with Octave libraries
  ## (required for ode2odes.exe only)

    # location of Octave directories on local system (usually /usr, /usr/local or /opt)

set OCTAVEPREFIX="/usr"

    # include paths for Octave

set IOCTAVE="-I${OCTAVEPREFIX}/include/octave/ -I${OCTAVEPREFIX}/include/octave/octave"

    # library paths for Octave

set OCTAVEVERS=`octave --version | head -1 | gawk '{ print $4 }'`
set OCTAVEMINOR=`echo ${OCTAVEVERS} | gawk -F\. '{print $2}'`
    if [ "${OCTAVEMINOR}" = "0" ] ; then # stable
	LOCTAVE="-L${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS} -loctave -lcruft -loctinterp -Wl,--rpath,${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS}"
	LOCTAVE="-L${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS} -loctave -lcruft -loctinterp -Wl,--rpath,${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS} -loct-pathsearch -loct-readline"
    fi
set LSYSTEM="-ldl -lm -lncurses -lkpathsea -lreadline -lblas -llapack -lfftw -lg2c"
    
    # C++ compiler options

set DEBUG="-g"
set OPTIM="-O3"
set FLAGS="-fno-rtti -fno-exceptions -fno-implicit-templates"

    # exported variables

    setenv MTT_CXX "g++"
    setenv MTT_CXXFLAGS "${DEBUG} ${OPTIM} ${FLAGS}"
    setenv MTT_CXXLIBS "${LOCTAVE} ${LSYSTEM}"
    setenv MTT_CXXINCS "-I. -I${MTT_LIB}/cc ${IOCTAVE}"
    setenv MTT_LDFLAGS " "

  ## End of Octave environment configuration
  ##
  #########################################################################################

  ############################################################  
  ##
  ## Configure environment for compilation of Matlab mex files
    
set MATLAB_ARCH="glnx86"
set MATLAB_ROOT="/usr/local/matlab6p1"
set MATLAB_FLAGS="-shared -fPIC -ansi -D_GNU_SOURCE -pthread"
set MATLAB_INCS="-I${MATLAB_ROOT}/extern/include"
set MATLAB_LIBS="-Wl,--rpath-link,${MATLAB_ROOT}/extern/lib/${MATLAB_ARCH},--rpath-link,${MATLAB_ROOT}/bin/${MATLAB_ARCH} -L${MATLAB_ROOT}/bin/${MATLAB_ARCH} -lmx -lmex -lm"

    # exported variables

    setenv MTT_MATLAB_FLAGS "${MATLAB_FLAGS} ${MATLAB_INCS} ${MATLAB_LIBS}"

  ## End of Matlab environment configuration
  ##
  #############################################################

Added mtt/bin/sh2csh version [4b9c1fb401].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2001/04/12 03:08:00  geraint
## Improved sh->csh conversion, reduces environment namespace pollution.
## Still need to do proper if [ -z $MTT_BASE ] ... else ... fi conversion.
##
## Revision 1.2  1999/03/11 04:12:26  peterg
## Put in heading.
##
## Revision 1.1  1999/03/11 04:02:45  peterg
## Initial revision
##
###############################################################

#Converts mttrc to csh form.

date=`date`
wd=`pwd`
base=`dirname $wd`

echo Converting $1 to $1.csh using $base as default 

cat<<EOF >$1.csh
#!/bin/csh
## Automatically generated from bashrc on $date - DO NOT EDIT
EOF

# grep -v lines need to be replaced with proper if...then conversion
cat $1 |\
 sed 's/export[ \t]*\([A-Za-z0-9_]*\)=/setenv\ \1\ /' |\
 sed 's/^\([\ \t]*\)\([A-Za-z0-9_]*\)=/set\ \2=/' |\
 grep -v "if \[ -z " |\
 grep -v "echo mttrc requires one argument: eg mttrc /usr/share/mtt/latest" |\
 grep -v "else" |\
 grep -v -e "^fi" |\
 sed "s%\$1%$base%" \
>>$1.csh


echo done.


Added mtt/bin/trans/ICD_txt2lang.sh version [9756a243af].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

sys=$1
lang=$2

ICD=${sys}_ICD.${lang}
txt=${sys}_ICD.txt
struc=${sys}_struc.txt

case ${lang} in
    c)	lb='['; rb=']'; offset=0; comment='//';;
    cc)	lb='('; rb=')'; offset=1; comment='//';;
    m)	lb='('; rb=')'; offset=0; comment='#';;
    *)	echo Language ${lang} not yet supported.; exit -1;;
esac

echo Creating ${ICD}

cat <<EOF > ${ICD}
${comment} Interface Control Definition mappings for system ${sys}
${comment} ${ICD}: Generated by MTT `date`

EOF

# ICD.txt Format:
# Input|Output ICD_Name PortName Causality: causality Units: units
# $1           $2       $3       $4         $5        $6     $7

cat <<EOF >> ${ICD}

${comment} Inputs

EOF
for name in `cat ${txt} | gawk '($1 == "Input:") { print $3 }'`
do
    num=`grep ${name} ${struc} | gawk '($1 == "input") { print $2 }'`
    grep ^Input ${txt} |\
	gawk '($3 == name) { printf ("\tmttu%c%d%c\t= %s;\n", lb, num-offset, rb, $2) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done

cat <<EOF >> ${ICD}

${comment} Outputs

EOF
for name in `cat ${txt} | gawk '($1 == "Output:") { print $3 }'`
do
    num=`grep ${name} ${struc} | gawk '($1 == "output") { print $2 }'`
    grep ^Output ${txt} |\
	gawk '($3 == name) { printf ("\t%-30s = mtty%c%d%c;\n", $2, lb, num-offset, rb) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done

Added mtt/bin/trans/abg2cbg_m version [aeca6fdc92].
































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2cbg_m
#
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  2001/07/28 21:09:22  geraint
## Eliminated duplicate lines in type.sh.
##
## Revision 1.16  2001/07/26 04:07:28  gawthrop
## Changed a to w on open (Geraint's suggestion)
## Explictly close files
##
## Revision 1.15  2001/07/23 23:24:02  gawthrop
## Now only writes to type.sh and cbg.m when causality is complete
##
## Revision 1.14  2000/12/28 12:16:13  peterg
## *** empty log message ***
##
## Revision 1.13  1998/07/27 20:30:12  peterg
## *** empty log message ***
##
## Revision 1.12  1998/07/10 08:43:46  peterg
## Added -I switch
##
## Revision 1.11  1998/01/23 13:29:54  peterg
## $RMATRIX --> $MATRIX
##
# Revision 1.10  1996/12/04  21:51:02  peterg
# Now uses filenum instead of line name.
# Uses fopen
#
# Revision 1.9  1996/11/06  15:49:33  peterg
# Cahged $MATRIX to $RMATRIX
#
# Revision 1.8  1996/08/25  09:31:49  peter
# More error handling.
#
## Revision 1.7  1996/08/25 09:22:55  peter
## # Print errors, if any.
## mtt_error error.txt
##
## Revision 1.6  1996/08/24 14:36:01  peter
## Error handling included.
##
## Revision 1.5  1996/08/19 15:38:31  peter
## Removed bug work round.
##
## Revision 1.4  1996/08/16 14:28:45  peter
## Some debugging lines removed.
##
## Revision 1.3  1996/08/08 18:06:55  peter
## Unified naming scheme.
##
## Revision 1.2  1996/08/05 11:25:00  peter
## Removed bonds argument from abg2cbg.
## Removed call to $1_abg.
##
## Revision 1.1  1996/08/04 17:45:11  peter
## Initial revision
##
###############################################################

# The causal BG is described by four matrices
# (the same structure as the acausal BG except that Causality is 1 ot -1):
#   junctions: describes the junctions -
#     Column 1   Index of component (see components)
#     Column 2.. Indices of bonds on junction (see jbonds)
#                  rows may be padded with zeros
#
#    cjbonds:    describes the true bonds -
#     Column 1     Index of component (see components)
#     Column 2     Direction
#                    1 away from junction
#                   -1 towards junction
#     Column 3    Effort causality 
#                     1 stroke at arrow end
#                    -1 stroke at other end
#                     0 no stroke (ie acausal)
#     Column 4    Flow causality 
#                     1 stroke at arrow end
#                    -1 stroke at other end
#                     0 no stroke (ie acausal)
#     Columns 5:6  x,y coordinates of non-arrow end (in Fig)
#     Columns 7:8  x,y coordinates of arrow end (in Fig)
#
#   mbonds:    describes the modulation bonds -
#     Column 1     Index of component at non-arrow end
#     Column 2     Index of component at arrow end
#     Columns 4:5  x,y coordinates of non-arrow end (in Fig)
#     Columns 6:7  x,y coordinates of arrow end (in Fig)
#
#   components: describes the comonents -
#     Column 1     Type of component
#                    0  0-junction
#                    1  1-junction
#                    2  R component
#                    3  C component
#                    4  I component
#                    11 TF component
#                    12 GY component
#                    13 A  component
#     Column 2     Flag for explicit junction
#                    4  Explicit component (4 means text type)
#                    0  Implicit component
#     Column 3-14    fig file information (see fig documentation)
#
# Lists of under- and over-causal junctions are displayed.
#
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.


# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.

derivative=0;blurb=integral
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-derivative )
                derivative=1; blurb=derivative;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

infofile='mtt_info.txt'
errorfile='mtt_error.txt'
typefile="$1_type.sh"

# Remove the old log file
rm -f abg2cbg_m.log
rm -f $1_cbg.m
rm -f $typefile
rm -f $infofile


#Inform user
echo "Creating $1_cbg.m (maximise $blurb causality)"
echo Creating $1_type.sh

## Start the type.sh file
mtt_header $1 type sh > $typefile

# Use matrix manipulation to accomplish the transformation
$MATRIX << EOF  >abg2cbg_m.log  #2>mtt_error.txt

  infofilenum  = fopen("$infofile",'wt');
  errorfilenum = fopen("$errorfile",'wt');
  typefilenum  = fopen("$typefile",'wt');

  %Convert from acausal to causal bond graph in m-file form.
  system_name='$1';

  port_bonds = [];
  port_direction = [];
  port_status = [];
  [cbonds,status] = abg2cbg(system_name, '', '', port_bonds, port_direction, port_status, ...
      $derivative,typefilenum, infofilenum, errorfilenum);

    ## close the files
    fclose(infofilenum);
    fclose(errorfilenum);
    fclose(typefilenum);

EOF

cat $typefile | sort -u > ${typefile}.tmp
mv ${typefile}.tmp $typefile

if [ "$info" = "info" ]; then
  cat $infofile
fi

# cp $1_$1_cbg.m $1_cbg.m 2>> mtt_error.txt 

# Print errors, if any.
mtt_error mtt_error.txt

Added mtt/bin/trans/abg2cmp_dia2txt version [1bb3659b08].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

### abg2cmp_dia2txt
## Creates list of components contained in _abg.dia
## Copyright (C) 2002 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

mtt_uncompress.sh $1_abg.dia
dia2abg.pl --create_component_list --diagram_name=$1

Added mtt/bin/trans/abg2cmp_fig2txt version [ef01106a85].
















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

### abg2cmp_fig2txt
##  Creates list of components contained in _abg.fig
## Copyright (C) 2002 by Peter J. Gawthrop

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Log$
  ## Revision 1.3  2002/12/06 22:12:28  geraint
  ## Removed unique option from sort
  ## - prevents multiple anonymous components from existing
  ## - duplicate named components are caught by rbg_fig2m.awk anyway
  ##
  ## Revision 1.2  2002/12/06 11:47:49  gawthrop
  ## Checks levels in fig file to extract genuine components
  ## Puts comments at top of cmp.txt file
  ##
  ## Revision 1.1  2002/12/01 14:54:39  gawthrop
  ## Replaces defunct abg2lbl_fig2txt
  ##
  ##
  ###############################################################

system=$1
infile=${system}_abg.fig
outfile=${system}_cmp.txt
date=`date`

echo Creating ${outfile}

header() {
    cat <<EOF
## List of components contained in system ${system}
## File ${outfile}
## Created by mtt on ${date}

EOF
}
get_valid_components()

{
gawk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;
  length_terminator=4;

}
{
  object = $1;
  zero_depth =  (modulo10($4)==0)&&(object==text);
  if (zero_depth) {
    print substr($NF,1,length($NF)-length_terminator)
  }
}' 

}

remove_port_labels() {
  grep -v '^\[.*\]$'
}

## Create header
header > ${outfile}

## Make list of components
get_valid_components < ${infile} |\
   remove_port_labels |\
   sort >> ${outfile}

Added mtt/bin/trans/abg2connections_m2dat version [123924ba9b].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

### abg2connections_m2dat
## Creates connections.dat from abg.m
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

sys=$1

file=${sys}_connections.dat

${MATRIX} <<EOF  >abg2connections_m.log

abg = ${sys}_abg;

${sys}_connections = abg2connections (abg);

str = save_header_format_string;
save_header_format_string =  ["# Model Transformation Tools\t", ...
			      " -*-octave-*-\n", ...
			      "# Created by abg2connections_m\n", ...
			      str];

save -text ${file} ${sys}_connections;

EOF

Added mtt/bin/trans/abg2cr_m2txt version [66557e28d3].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2cr_m2txt

# Abg file to constitutive relationship conversion
# P.J.Gawthrop march 2000
# Copyright (C) 2000 by Peter J. Gawthrop



# Inform user
if [ "$1_cr.txt" -nt "$1_abg.m" ]; then
    echo "Using  $1_cr.txt"
    exit
else
    echo "Creating $1_cr.txt"
fi


rm -f mtt_error


# This is the main transformation using awk 
# And remove crs with same name as system
grep 'cr = ' $1_abg.m | gawk '
BEGIN {
# Include lin cr anyway.
print "lin"
}
{
  crs=substr($3,2,length($3)-3);
    N=split(crs,cr,";");
      for (i=1;i<=N;i++){
        if (length(cr[i])>0)
        print cr[i];
      }
}'  2>mtt_error.txt | sort -u | grep -v none | grep -v '\$[0-9]'> $1_cr.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt




Added mtt/bin/trans/abg2ibg_dia2m version [0f6a6c0a05].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

### abg2ibg_dia2m
## Creates _ibg.m from _abg.dia
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

mtt_uncompress.sh $1_abg.dia
dia2abg.pl --create_ibg --diagram_name=$1

Added mtt/bin/trans/abg2lbl_fig2txt version [914b9ec92b].































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2lbl_fig2txt
#
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.27  2002/05/10 09:08:55  gawthrop
## Added EMTF and INTF
## Fixed bug in writing out component headings
##
## Revision 1.26  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.25  2001/10/15 14:27:00  gawthrop
## Now handles [1:N] style port labels
##
## Revision 1.24  2001/08/02 03:24:48  geraint
## Replaced mtt_version.sh with mtt_banner.sh - I think this was the intent.
##
## Revision 1.23  2001/07/26 04:08:35  gawthrop
## Removed lines deleting _type.sh and cbg.m
##  -- how did they get there ??
##
## Revision 1.22  2001/07/08 03:28:11  gawthrop
## Fixed a bug: abg2sympar_m2txt neads a _lbl.txt file when using
## "usinglabel" option
##
## Revision 1.21  2001/07/06 00:46:50  gawthrop
## Added -cr option -- forces cr to be loaded before the ese.r file
## This avoids causality problems when using multi-port Rs to represent
## arbitary equations
##
## Revision 1.20  2001/07/04 05:19:57  gawthrop
## Added RT & CT to list
##
## Revision 1.19  2001/07/03 23:51:10  gawthrop
## Now puts outline #Summary and #Description lines at top of lbl file
##
## Revision 1.18  2001/06/13 18:24:10  gawthrop
## Made "lin" default in place of "none"
## Still needs arg and cr alias clashes to be sorted ....
##
## Revision 1.17  2001/06/13 10:41:06  gawthrop
## Further changes towards aouto creation of lbl files.
## Prettified lbl files
##
## Revision 1.16  2001/06/11 19:43:49  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.15  2001/06/11 16:53:49  gawthrop
## Now uses abg2sympar_m2txt to get the arguments
##
## Revision 1.14  2001/06/11 15:06:58  gawthrop
## Now handles user-defined components
##
## Revision 1.13  2001/06/04 08:13:37  gawthrop
## Various changes to support PPP
##
## Revision 1.12  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.11  2000/09/19 11:14:30  peterg
## Now writes the first component type header correctely
##
## Revision 1.10  2000/01/26 10:11:10  peterg
## Added I component
##
## Revision 1.9  1999/11/10 00:47:08  peterg
## Replaced ifs by a table of cr/arg information
##
## Revision 1.8  1999/11/09 22:32:41  peterg
## Under RCS ready for using arrays to contaain defaults.
##
## Revision 1.7  1998/07/04 10:37:21  peterg
## Major revision to include:
## 	aliases
## 	new Style
## 	prettyfied
##
## Revision 1.6  1998/03/05 10:09:47  peterg
## Corrected bug in writing "other" components
##
## Revision 1.5  1998/03/02 09:26:18  peterg
## Now does default CR and args for the basic components only
## SS,I,R,C,GY,TF
## C now has a default of effort input.
##
## Revision 1.4  1998/02/23 16:20:33  peterg
## Summary line just contains the model name
##
## Revision 1.3  1997/05/09 14:21:35  peterg
## Default to flow,component_name
##
# Revision 1.2  1997/03/19  12:08:01  peterg
# No longer writes out non-unique names - now done in rbg_fig2m
#
# Revision 1.1  1997/03/18  13:55:01  peterg
# Initial revision
#
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997

infofile='mtt_info.txt'
typefile="$1_type.sh"
sensitivity=$2;
system=$1
outfile=$1_lbl.txt

if [ -n "$sensitivity" ]; then
    sys="-s ${system}"
else
    sys=${system}
fi

# Remove unwanted files
rm -f abg2lbl_fig2txt.log
rm -f $infofile
rm -f mtt_junk*

## Create lbl files beneath this one
mtt -q -u -l 1 ${sys} sub sh # Create the list
sh $1_sub.sh "abg2lbl_fig2txt " " $sensitivity"

if [ -f "$1_lbl.txt" ]; then
  ##echo "$1_lbl.txt exists in `pwd` - no action taken"
  exit
##else 
  ##echo "$1_lbl.txt dosn not exist in `pwd` "
fi

#Inform user
if [ -n "$sensitivity" ]; then
    echo "Creating ${outfile} (sensitivity version)"
else
    echo "Creating ${outfile}"
fi

write_header()

{
cat<<EOF
#SUMMARY ${system}
#DESCRIPTION Detailed description here

## System ${system}, representation lbl, language txt
## File ${system}_lbl.txt
## Generated by MTT on `date`

EOF
cat $MTT_DOC/mtt_banner.sh


}

write_blurb()
{
cat <<EOF

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----
EOF
}

create_lbl_body()
{

## Find names of all components
grep -v '\[[0-9]*:[0-9]*\]' $1_abg.fig  |\
gawk '/:/ {print $NF}'  | \
sed 's/\\001//' | \
sort | \
tee $1_raw_list | \
sort -u> $1_unique_raw_list


#Write out non-unique names
#echo 'Non-unique names (if any):'
#diff $1_unique_raw_list  $1_raw_list | grep '>' | sed 's/>/	/'

#Write out the outline lbl file
grep -v  '\[[0-9]*\]'  $1_unique_raw_list | \
gawk --field-separator ':' '
 BEGIN {
    OldComponent="None";
    default_cr = "lin";
 }
 { 
  Component = $1;
  Name = $2;
  Arg = $3;

##Aliases
  if (Component == "SS") {
    port_alias[++j] = Name;
  }
  else {
    alias[++i] = Name;
    if (length(sensitivity)>0) {
      s_arg = sprintf("%ss",Name);
      alias[++i] = s_arg;
      s_arg = sprintf(";%s",s_arg);
      Component_type = Component;
      Component = substr(Component,2);
      lin = "slin"
    }
   else {
      Component_type = Component;
      lin = "lin";
    }
  
 }

    ## Table of components
    cr["SS"] = "SS";  arg["SS"] = "external,external";

    cr["Se"] = "SS";  arg["Se"] = sprintf("external%s", s_arg);
    cr["Sf"] = "SS";  arg["Sf"] = sprintf("external%s", s_arg);

    cr["De"] = "SS";  arg["De"] = "external";
    cr["Df"] = "SS";  arg["Df"] = "external";

    cr["R"] = lin;  arg["R"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["C"] = lin;  arg["C"]  = sprintf("effort,%s%s", Name, s_arg);
    cr["I"] = lin;  arg["I"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["INTF"] = lin;  arg["INTF"]  = "";

    cr["CS"] = "lin";  arg["CS"]  = sprintf("effort,%s;%s_x0%s", Name, Name, s_arg);
    cr["IS"] = "lin";  arg["IS"]  = sprintf("flow,%s;%s_x0%s", Name, Name, s_arg);
    cr["INTFS"] = "lin";  arg["INTFS"]  = sprintf("%s_x0%s", Name, s_arg);

    cr["TF"] = "lin";  arg["TF"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["GY"] = "lin";  arg["GY"]  = sprintf("flow,%s%s", Name, s_arg);

    ##cr["EMTF"] = sprintf("%s", Name);  arg["EMTF"]  = sprintf("l%s",  s_arg);
    cr["EMTF"] = "lin";  arg["EMTF"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["AE"] = "lin";  arg["AE"]  = sprintf("%s%s", Name, s_arg);
    cr["AF"] = "lin";  arg["AF"]  = sprintf("%s%s", Name, s_arg);
    cr["AEf"] = "lin";  arg["AEf"]  = sprintf("%s%s", Name, s_arg);
    cr["AFe"] = "lin";  arg["AFe"]  = sprintf("%s%s", Name, s_arg);

    cr["CDx"] = "lin";  arg["CDx"]  = sprintf("%s%s", Name, s_arg);


    cr["FMR"] = lin;  arg["FMR"]  = sprintf("effort,%s%s", Name, s_arg);

    cr["RS"] = lin;  arg["RS"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["RT"] = lin;  arg["RT"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["CT"] = lin;  arg["CT"]  = sprintf("effort,%s%s", Name, s_arg);

    ## Put in the explicit arguments
    if (length(Arg)>0) {
      arg[Component] = Arg;
      if (match(Arg,"=")>0) # Its an equation type cr
        cr[Component] = "cr"
      else # assume a linear cr
        cr[Component] = "lin";
    }

  ## Print component header 
  if (Component != OldComponent) print "\n## Component type", Component_type

  ## Print Component
    printf("\t%s\t", Name);
    if (Component in cr)
      printf("%s\t\t", cr[Component])
    else 
      printf("%s\t\t", default_cr);

   if (Component in arg)
      printf("%s\t\t\n", arg[Component])
    else {
	print "lbl2args_txt2out", Component_type | "/bin/sh"; close("/bin/sh")
    }

    OldComponent=Component;
    delete arg[Component]; # Zap the element
    delete cr[Component]; # Zap the element
  }
  END{
    print "\n## Port aliases" >> "mtt_junk_alias.txt";
    for (k=1;k<=j;k++){
      if (port_alias[k] ~ "\\["){ # Only do ports
        port_name = substr(port_alias[k],2,length(port_alias[k])-2);
        if (length(sensitivity)==0)
          print "#ALIAS\t" port_name "\t" port_name >> "mtt_junk_alias.txt";
        else
          print "#ALIAS\t" port_name "\t" port_name "_1," port_name "_2" >> "mtt_junk_alias.txt";
      }
    }

#    print "\n% Argument aliases" >> "mtt_junk_alias.txt";
#    for (k=1;k<=i;k++){
#      print "%ALIAS\t\$" k "\t" alias[k] >> "mtt_junk_alias.txt";
#    }
 }' sensitivity=$sensitivity
}

create_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF
abg2sympar_m2txt ${system} ${system} use_label_file |\
gawk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
}

## Main 

create_lbl_body $1> $1_lbl.txt
create_arg_aliases > mtt_args.txt # using $1_lbl.txt
mv $1_lbl.txt mtt_junk_lbl.txt

write_header            > ${outfile}
cat mtt_junk_alias.txt >> ${outfile}
cat mtt_args.txt       >> ${outfile}
write_blurb            >> ${outfile}
cat mtt_junk_lbl.txt   >> ${outfile}
## Put a blank line at end
cat >> ${outfile} <<EOF

EOF
## Clean up
rm -f mtt_junk*





Added mtt/bin/trans/abg2sabg_fig version [42ae42721b].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sabg_fig
#
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:18:40  peterg
## Initial revision
##
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997

infofile='mtt_info.txt'
typefile="$1_type.sh"

# Remove the old log file
rm -f abg2sabg_fig.log
rm -f $1_cbg.m
rm -f $typefile
rm -f $infofile


#Inform user
echo Creating $1_sabg.txt

gawk '{\
    Depth=7;\
    print $Depth}' $1_abg.fig

Added mtt/bin/trans/abg2sensitivity_fig version [019c577d2e].

















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Converts abg.fig to sensitivity version

## Copyright (C) 1999 by Peter J. Gawthrop

filename=$1_abg.fig
sfilename=s$filename

if [ -f "$sfilename" ]; then
    echo $sfilename exists -- no action taken
    exit
fi

if [ -f $filename ]; then
    echo Using existing $filename
else
    echo "Looking for $1 in library"
    mtt -q  compcopy $1  
fi


echo Creating $sfilename   

gawk '
  function modulo10(x) {
    return x-int(x/10)*10
    }
  {

  level_index = 4;
  if ( match($NF,"001")&&(modulo10($level_index)==0)&&(index($NF,"[") != 1) ){
    last = $NF
    if ( (index($NF,"0") != 1)&&(index($NF,"1") != 1)&&(index($NF,"SS") != 1) ) {
      $NF = sprintf("s%s", $NF);
      print $0;
    }
    else {
      x_1_index = 10;
      x_2_index = 12;
      y_1_index = 11;
      y_2_index = 13;
      colour_index=3;
      yellow = 6;

      ## save details 
      colour=$colour_index;
      component=$NF;
      x_1 = $x_1_index;
      x_2 = $x_2_index;
      y_1 = $y_1_index;
      y_2 = $y_2_index;
      
      ## print the label
      $colour_index = yellow;
      $NF = "[1,2]\\001";
      $x_1_index = x_1+1;
      $x_2_index = x_2+1;
      $y_1_index = y_1+1;
      $y_2_index = y_2+1;
      print $0;

      ## print the component
      $colour_index = colour;
      $NF = component;
      $x_1_index = x_1;
      $x_1_index = x_1;
      $y_1_index = y_1;
      $y_2_index = y_2;
      print $0;

      
    }
  }
  else
    print $0;
'} < $filename >$sfilename



Added mtt/bin/trans/abg2sub_fig2sh version [aa4b28a58d].















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sub_m2sh
  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.4  2002/04/22 10:25:47  gawthrop
  ## Handles unnamed components & ingnores artwork
  ##
  ## Revision 1.3  2001/10/15 14:27:34  gawthrop
  ## Now handles [1:N] style port labels
  ##
  ## Revision 1.2  2001/07/23 23:26:23  gawthrop
  ## Removed some boring user feedback
  ##
  ## Revision 1.1  2001/06/11 19:47:49  gawthrop
  ## Makes the sub.sh file directly from the abg.fig file
  ## Used for making lbl files (abg2lbl_fig2txt)
  ##
  ##
  ###############################################################

# Copyright (C) 1996--2002 by Peter J. Gawthrop



get_valid_components()

{
gawk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;

}
{
object = $1;
zero_depth =  (modulo10($4)==0)&&(object==text);
if (zero_depth) print $0

}' < $1_abg.fig

}
#if [ -f "$1_sub.sh" ]; then
#    echo Using "$1_sub.sh"
#    exit
#else
    #Inform user
    echo Creating $1_sub.sh    
#fi

echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components from the _abg file
get_valid_components $1 |\
grep -v '\[[0-9]*:[0-9]*\]' |\
grep -v '\[.*\]' |\
gawk '{if ($1==4) split($14,a,":"); print a[1]}'  |\
sed 's/\\001//' |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Added mtt/bin/trans/abg2sub_m2sh version [2502a0a331].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sub_m2sh

# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/10/03 11:34:53  peterg
## Correct $MTT_LIB
##
## Revision 1.2  2000/03/17 09:53:10  peterg
## Removed irritating echo Using "$1_sub.sh"
##
## Revision 1.1  2000/03/15 21:23:20  peterg
## Initial revision
##
###############################################################


if [ -f "$1_sub.sh" ]; then
    #echo Using "$1_sub.sh"
    exit
else
    #Inform user
    echo Creating $1_sub.sh    
fi


echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _abg file
gawk '/type = / {print substr($3,2,length($3)-3)}' $1_abg.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
echo ls $MTT_LIB/comp/simple
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Added mtt/bin/trans/abg2sympar_m2txt version [f1c08a0b7a].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sympar_m2txt

# Label file to symbolic parameters conversion
# Copyright (C) 2000 by Peter J. Gawthrop

# Inform user
##echo "Creating $1_sympar.txt" with $1 $2 $3

# Separation characters
SEPS='^=*;+/()-'
# Replace by ,
REPS='[,*]'

SystemName=$2
UseLabelFile=$3

if [ -n "$UseLabelFile" ]; then ## Take input from lbl.txt
     strip_comments < $1_lbl.txt  | tr $SEPS $REPS |\
     gawk '{printf("%s %s \"%s\",\n",$1,$2,$3)}' > mtt_stripped_file
else ## Take input from _abg.m
     cat $1_abg.m | grep "arg =" | tr $SEPS $REPS > mtt_stripped_file
fi

rm -f mtt_error
# This is the main transformation using gawk
cat mtt_stripped_file | \
gawk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
}

BEGIN {
  var = "[%|#][PAR|VAR]";
  not_an_arg = "effort flow state internal external zero unknown\
                mtt_e mtt_f\
		sqrt exp log sign sin asin cos acos tan atan \
		sin asin cos acos tan atan \
		sinh asinh cosh acosh tanh atanh \
                none abs";
  arg_line = "arg = ";
}
{
  ## Explicit VAR declarations
  if (match($1,var)>0) print $2 "\t" system_name;

   ## Implicit declarations from the arg list
##  if (match($1,"arg")>0) {
    args= substr($3,2,length($3)-3);
    if (length(args)>0)
      printf("%s\t%s\n", args,system_name)
##  }
}' system_name=$SystemName |\
grep -v '^\$' | mtt_strip_args | sort -u > mtt_stripped_args


## Now get the explicit declarations
if [ -n "$UseLabelFile" ]; then ## Take input from lbl.txt
    ext=_lbl.txt
else
    ext=_abg.m
fi

strip_pars.sh $1${ext} $1 |  sort -u > mtt_explicit_args

## And write sorted list
cat  mtt_explicit_args mtt_stripped_args 


Added mtt/bin/trans/abg2tex version [5c7c8f0f51].



















































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2tex
# Creates a tex file describing the system abg
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2004/08/26 16:11:48  geraint
## Fixed ignore() and pipe so that subsystems are included in reports again.
##
## Revision 1.6  2004/02/11 10:10:04  gawthrop
## Includes a _pic.fig file (schematic) if such exists
##
## Revision 1.5  2004/02/10 16:12:21  gawthrop
## Don't give details of Se De Sf Df INTF
##
## Revision 1.4  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.2  2000/11/27 17:45:00  peterg
## Removed "System" from  heading
##
## Revision 1.1  2000/11/27 15:11:15  peterg
## Initial revision
##
## Revision 1.7  1997/12/06 16:20:37  peterg
## Added another argument - the label
##
## Revision 1.6  1997/12/06 15:49:35  peterg
## Changed order of fig arguments to put filename first.
##
## Revision 1.5  1997/08/15 11:32:05  peterg
## Removed an echo left in by mistake
##
# Revision 1.4  1997/08/15  11:19:25  peterg
# Minto cosmetics.
#
## Revision 1.3  1997/05/21 12:07:22  peterg
## Replaced echo by cat -- much simpler.
##
## Revision 1.2  1997/05/19 16:25:53  peterg
## Explicit include of tex files .. latex2html seems to prefer this!
##
# Revision 1.1  1997/05/19  11:30:00  peterg
# Initial revision
#
###############################################################

## Subsystems that don't need documentation
ignore(){ 
   gawk '
BEGIN{
ignored = " Se De Sf Df INTF ";
}
{
     subsys = sprintf(" %s ", $1);
     if (match(ignored,subsys)==0)
       print $1 
  }'
}

#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-pdf )  pdf='-pdf'
                ;;
	-s )  sensitivity='-s'
                ;;

	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


if [ -z "$2" ]; then
  filename="$1_abg.tex";
  echo > $filename
  echo Creating $filename
  subsection='section'
else
  filename=$2
  subsection='subsection'
fi


#Section heading (if not at top level)
if [ -n "$2" ]; then
cat<<EOF >> $filename

%% Subsystem $1
  \subsection{\textbf{$1}}
    \label{sec:$1}
    \index{\textbf{$1} -- abg} 

EOF
else
mtt -q -u ${sensitivity} $1 abg m # Make sure all the subsystems exist -- nasty kludge
cat<<EOF > $filename
   % abg report for system $1 ($filename)
   % Generated by MTT at `date`
EOF
fi

# Figure
##echo mtt -q -u $pdf $1 abg ps
mtt -q -u  $pdf $1 abg ps
cat <<EOF  >> $filename

%%   \fig{`pwd`/$1_labg}{$1_abg}{0.9}{System \textbf{$1}: acausal bond graph}
   \tfig{`pwd`/$1_labg}{$1_abg}{0.9}{System \textbf{$1}: acausal bond graph}

EOF

## Put a schematic if exists (_pic.fig)
if [ -e "$1_pic.fig" ]; then
  echo Inserting $1_pic.fig
  fig2dev -L eps $1_pic.fig  > $1_pic.ps
cat <<EOF  >> $filename

   \fig{`pwd`/$1_pic}{$1_pic.ps}{0.9}{System \textbf{$1}: schematic diagram}

EOF
fi

# Description
mtt -q -u $1 desc tex
# Put in absolute pathnames in figures -- and fix bug in old desc files
sed "s;fig{;fig{`pwd`/;g" < $1_desc.tex |\
sed "s/Ref{$1_abg}/Ref{fig:$1_abg.ps}/" >> $filename

# Label file
mtt -q -u $1 lbl tex
cat<<EOF  >> $filename
 \sub$subsection{Summary information} 
 \label{sec:$1_lbl} 
 \index{\textbf{$1} -- lbl} 
EOF
cat $1_lbl.tex   >> $filename


# CRs
#mtt -q -u $1 cr tex
#cat<<EOF  >> $filename
# \sub$subsection{Constitutive relationships} 
# \label{sec:$1_cr} 
# \index{\textbf{$1} -- cr} 
#EOF
#cat $1_cr.tex   >> $filename

# Subsystems
mtt -q -u $1 sub tex 
cat<<EOF  >> $filename
 \sub$subsection{Subsystems} 
 \label{sec:$1_sub} 
 \index{\textbf{$1} -- subsystems} 
EOF
cat $1_sub.tex   >> $filename

#Now do the subsystems (if at top level)
if [ -z "$2" ]; then
    sub2subs $1 | sort -u | ignore |\
  gawk '{print "abg2tex", pdf, $1, filename}' pdf=$pdf filename=$filename | sh
fi

Added mtt/bin/trans/abg_m2a4c version [18547a7f99].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg_m2a4c
#
# Acausal bond graph to ascend format

infofile='mtt_info.txt'
errorfile='mtt_error.txt'


# Remove the old log file
rm -f abg_m2a4c_m.log
rm -f $1_abg.a4c



#Inform user
echo "Creating $1_abg.a4c" 

# Use matrix manipulation to accomplish the transformation
octave -q << EOF  >$1_abg.a4c
    ABG = $1_abg;
    name = "$1";
    abg_m2a4c(ABG,name);
EOF

if [ "$info" = "info" ]; then
  cat $infofile
fi

Added mtt/bin/trans/alias_txt2m version [00b2a256d4].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: alias_m
# Creates the component aliases in text form

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/02 19:16:03  peterg
## Prettyfied output
##
## Revision 1.1  1998/07/02 09:21:55  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_alias.m

#Create the alias file complete with headers.
echo "function alias = $1_alias" > $1_alias.m
echo "%% Alias file ($1_alias.m)" >> $1_alias.m
echo "%% Generated by MTT at `date`" >> $1_alias.m

#Write out the variables 
gawk '{
       if (NF==2) {i++; print "alias."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "alias = 0;"
        }' $1_alias.txt >> $1_alias.m









Added mtt/bin/trans/apply_crs version [60be95a20f].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

sys=$1

# check for the existence of CRs that we need
crs=''
for cr in `cat ${sys}_cr.txt`; do
  if [ -f ${cr}.pm -o -f mtt/${cr}.pm ]; then
      crs="$crs $cr"
  fi
done

# should be reading the output from ese_r2make
# on standard input
${MTT_LIB}/cr/perl/apply_cr.pl ${crs}

Added mtt/bin/trans/awk/lbl2cr.awk version [aa06076c55].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: lbl2cr.awk
# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.9  1998/03/08 21:01:40  peterg
## Now does multiple crs
##
## Revision 1.8  1998/03/06 09:15:28  peterg
## Ignores SS fields (assumes that if first field is a symbol then other
## field is and SS-style field.
##
## Revision 1.7  1997/04/22 12:50:15  peterg
## New much simpler version -- does not check for multiple crs -- these
## are removed later anyway.
##
# Revision 1.6  1997/03/22  15:15:44  peterg
# Ignores symbolic ($i) crs.
#
# Revision 1.5  1997/03/20  12:05:31  peterg
# Now just writes out the cr name.
#
# Revision 1.4  1996/11/09  20:38:45  peterg
# Put in new lib pat
#
## Revision 1.3  1996/11/04 14:51:14  peterg
## Added none to no cr list
##
# Revision 1.2  1996/11/02  10:22:22  peterg
# Now ignores SS lines.
#
###############################################################


function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
    }

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
    }


BEGIN {
comment = "%|#";
cr_delimiter = ";";
not_a_cr = "effort flow state internal external zero none";
is_a_SS = "internal external zero";
numeric = "[0-9]";
symbolic = "\044"; # Ascii $
symbol_count = 0;
symbols = "";

# Include lin cr anyway.
print "lin"
}
{
  if ( (match($1,comment)==0) && (NF>=3) ) {
      crs = $2
    n_crs = split(crs,cr,cr_delimiter);
    for (i = 1; i <= n_crs; i++) {
      first_char = substr(cr[i],1,1);
      if ( (matches(not_a_cr,cr[i])==0) &&
         (match(numeric,first_char)==0) &&
         (matches(is_a_SS,$3)==0))
	 print cr[i];
    }
  }
}

Added mtt/bin/trans/awk/lbl2sympar.awk version [c5c057bec5].












































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: lbl2sympar.awk
# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.13  1998/07/15 09:26:50  peterg
## Reinstated the second column of the sympar file - the system name
##
## Revision 1.12  1998/07/04 11:09:46  peterg
## Cleaned up - assumes new lbl style for SS
##
## Revision 1.11  1998/05/13 12:39:23  peterg
## Added `unknown' to list od names to avoid
##
## Revision 1.10  1998/03/26 13:03:23  peterg
## Changed SS field fudge.
##
## Revision 1.9  1998/02/16 16:09:57  peterg
## And taken it out again!
##
## Revision 1.8  1998/02/16 12:08:38  peterg
## Put back the matrix declaration
##
# Revision 1.7  1997/03/18  17:25:24  peterg
# Now just generates names - formatting removed.
#
# Revision 1.6  1996/12/07  20:02:43  peterg
# Fixed symbolic parameter bug.
#
## Revision 1.5  1996/12/07 18:06:50  peterg
## Now detects symbolic args ($1 etc) and ignores them.
##
# Revision 1.4  1996/08/30  18:45:32  peter
# Removed header stuff.
#
## Revision 1.3  1996/08/30 10:30:54  peter
## Switched order of args in matches.
##
## Revision 1.2  1996/08/30 09:35:10  peter
## Fixed problem with global variable in function.
##
## Revision 1.1  1996/08/24 13:34:48  peter
## Initial revision
##
###############################################################



function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
}


BEGIN {
sys_name = ARGV[1];
comment = "%|#";
var = "[%|#]VAR";
arg_delimiter = ",";
not_an_arg = "effort flow state internal external zero unknown 0 1";
SS_parameter = "internal external zero 0 1";
numeric = "[0-9-]";
symbol_count = 0;
symbols = "";
}
{
  if (match($1,var)>0) print $2 "\t" name;

  if ( (match($1,comment)==0) && (NF>=3) ) {
    n_args = split($3,arg,arg_delimiter);
    for (i = 1; i <= n_args; i++) {
      first_char = substr(arg[i],1,1);
      if ( (matches(not_an_arg,arg[i])==0) \
	   && (match(first_char,numeric)==0) \
	   && (match(arg[i],"\\$")==0) \
	   && (length(arg[i])>0) \
	   && (matches(symbols,arg[i]) ==0) ) {
	 print arg[i] "\t" name;
	  }
    }
  }
}





Added mtt/bin/trans/awk/rbg_fig2m.awk version [fb6f8561fe].























































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: rbg_fig2m.awk
# Raw  bond-graph conversion from fig to matlab
# P.J.Gawthrop June 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.46  2004/08/04 19:46:42  geraint
## Sorts components alphabetically (type:name) within the categories:
## internal ports, components, 0 junctions and 1 junctions.
##
## Standardising the order in which components are listed allows models
## built with different editors to interact correctly by separating the
## graphical information from the data which is required to build models.
##
## Revision 1.45  2004/04/07 12:17:43  gawthrop
## Handles new Fig header line.
##
## Revision 1.44  2002/05/25 09:23:47  gawthrop
## Self-naming components: name is mttTYPE or mttTYPE_2 ...
##
## Revision 1.43  2002/05/22 10:33:18  gawthrop
## Nameless components are now named according to type - replaces old
## mtt1 etc style.
##
## Revision 1.42  2002/03/26 12:05:27  geraint
## Escaped characters to eliminate awk warnings.
##
## Revision 1.41  2001/06/13 10:41:06  gawthrop
## Further changes towards aouto creation of lbl files.
## Prettified lbl files
##
## Revision 1.40  2001/06/11 19:43:50  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.39  2001/05/09 08:50:02  gawthrop
## Uses _art.fig to transmit the art work to the cbg.fig rep.
##
## Revision 1.38  2001/03/23 14:57:31  gawthrop
## Now puts space after header fields + writes _port.fig
##
## Revision 1.37  2000/09/14 08:43:32  peterg
## Add additional directional informatiuon to rbonds:
## 	cols 7-8 Arrow end directional bond
## 	cols 9-10 Arrow end directional bond
##
## Revision 1.36  1999/11/19 04:00:26  peterg
## Changed a comment to be more accurate.
##
## Revision 1.35  1999/07/25 22:19:45  peterg
## Fixed bug with false objects when compound objects present.
## -- Reset object to 0 after processing text.
##
## Revision 1.34  1999/02/17 06:23:49  peterg
## Bugs arising from Fig 3.2 fixed
##
## -- depth now zero modulo 10 (3.2 defaults to depth 100!!)
## -- horrible bug using = in place of == fixed.
##
## Revision 1.33  1998/08/10 15:51:06  peterg
## Comments may now be prefaced by # as well as %
##
## Revision 1.32  1998/07/27 20:30:03  peterg
## *** empty log message ***
##
## Revision 1.31  1998/04/16 13:18:13  peterg
## Now ignores spurious ports (in lbl but not Figure \ref{) but gives
## warning
##
## Revision 1.30  1998/04/12 15:01:17  peterg
## Converted to uniform port notation - always use []
##
## Revision 1.29  1998/04/12 12:35:32  peterg
## Named and unnamed SS handled in a uniform manner - in particular, the
## attributes are passed through
## wrote_component function used.
##
## Revision 1.28  1998/04/06 08:41:48  peterg
## Fixed bug due to adding (and then removing) 0 and 1 as port types
##
## Revision 1.27  1998/04/04 10:54:58  peterg
## Remove a debugging print statement
##
## Revision 1.26  1998/04/04 07:29:26  peterg
## SS now only port component
##
## Revision 1.25  1998/04/03 15:07:20  peterg
## Now correctly write 0/1 port names
##
## Revision 1.24  1998/04/03 14:02:50  peterg
## Added 0 and 1 to list of possible ports
##
## Revision 1.23  1998/02/01 18:37:41  peterg
## Don't print irritating warnings about ports listed in lbl files.
##
# Revision 1.22  1997/08/09  14:42:39  peterg
# Added underscore to port regexp
#
## Revision 1.21  1997/08/04 12:49:17  peterg
## Modified to use named (as opposed to numbered) ports.
## Generates a list of component ports in the .rbg file.
## As octave handles string vectors properly, the .cmp file format is not
## really necessary - but I've let it be for the moment.
##
## Revision 1.20  1997/03/19 12:02:01  peterg
## Now writes an error message if a lable is used twice in the fig file.
##
# Revision 1.19  1997/03/19  09:49:39  peterg
# Ports now written in cmp file.
#
# Revision 1.18  1997/03/19  09:42:08  peterg
# Now writes out the following additional fig  files:
# _head.fig	The fig header
# _bnd.fig	The bonds actually used
# _cmp.fig	The components actually used.
#
# Revision 1.17  1997/01/02  11:21:17  peterg
# Now assumes all components bonds etc at depth zero in fig file.
# Ie anything at depth>0 is ignored.
# Thanks to Donald for suggesting this.
#
## Revision 1.16  1996/12/30 20:00:29  peterg
## Fixed bent-bond bug.
## NB unfixed problems:
## 1. xfig writes multi line fields if more than about 5 segments.
## 2. rbg2abg takes a multi-segment bond as a straignt line between the
## end points - so computation of stroke and arrow directions may be
## iffy.
##
## Revision 1.15  1996/12/30 19:23:35  peterg
##  Allows for bent bonds - ie bonds with more than 2 line segments.
##
## Revision 1.14  1996/12/21 19:47:53  peterg
## Changed \* to \\*
##
## Revision 1.13  1996/12/21 19:47:23  peterg
## Put back under VC
##
# Revision 1.12  1996/08/24  16:30:12  peter
# Fixed error in nonport_regexp.
#
## Revision 1.11  1996/08/19 10:48:57  peter
## Added `-' to the component regexp.
##
## Revision 1.10  1996/08/19 09:03:13  peter
## Parses repetative components: ie suffixed by *n.
##
## Revision 1.9  1996/08/09 08:23:11  peter
## Fixed bug: ports not recognised.
##
## Revision 1.8  1996/08/05 20:12:43  peter
## Now writes a _fig.fig file.
##
## Revision 1.7  1996/08/05 18:44:56  peter
## Now writes out a _cbg file without ----- symbol.
##
## Revision 1.6  1996/08/05 12:17:37  peter
## n_ports now appear in the _abg file instead.
##
## Revision 1.5  1996/08/05 12:01:28  peter
## The _cmp function now returns the number of ports.
##
## Revision 1.4  1996/08/05 10:14:46  peter
## Made ports appear, in order, at top of component lists
##
## Revision 1.3  1996/08/04 20:32:28  peter
## Stopped complaint about missing lbl entry for port components
##
## Revision 1.2  1996/08/04 20:05:25  peter
## Included port components - eg SS:[1]
##
## Revision 1.1  1996/08/04 20:01:58  peter
## Initial revision
##
###############################################################


##############################################################
# This (g)awk script reads a fig file in fig 3.1 format.
# It interprets the picture as: bonds, arrows and components
# as follows:
#
# Bonds are firm (not dashed etc) polylines with n line segments - 
#  fig represents this by  a firstline record where
#    field 1 = 2 (always 2)
#    field 2 = 1 (polyline)
#    field 3 = 0 (style is a firm line)
#    field 7 = 0 (depth is zero [top level])
#    field 14 = 0 (no forward arrow)
#    field 15 = 0 (backward arrow) 
#    field 16 = Number of point in line (points=segments+1)
#  a data field starting with a tab followed by  points (x,y) cordinates
#
#
# Strokes are polylines with 1 line segment and and no arrow 
#  fig represents this by  a firstline record where
#    field 1 = 2 (always 2)
#    field 2 = 1 (polyline)
#    field 3 = 0 (style is a firm line)
#    field 14 = 0 (no forward arrow)
#    field 15 = 0 (backward arrow) 
#    field 16 = Number of point in line =2
#  a data field starting with a tab followed by 2 (x,y) cordinates
#
# Arrows are polylines with 1 line segment and an arrow 
#  fig represents this by  a firstline record where
#    field 1 = 2 (always 2)
#    field 2 = 1 (polyline)
#    field 3 = 0 (style is a firm line)
#    field 14 = 1 for a forward arrow  
#    field 15 = 1 for a backward arrow 
#  an additional data files
#  a data field starting with a tab followed by 2(x,y) cordinates
#
# Components appear in two files -- the fig file and the lbl file
# these two files are concatenated with the lbl file first
#  	The lbl file represents components by 3 fields
#		field  1 is the name
#		field  2 is the CR name
#		field  3 is the CR arguments
#  	The fig file represents components by 14 fields
#             field 1 = 4
#		fields 12 and 13 are the coordinates
#		field 14 is the type:name string terminated by \001
# To prevent text being confused with components, components consist
# of alphanumeric characters and : and _ only.
# 
# Components are sorted alphabetically ("type:name")
# within the following categories:
# 1) internal ports (SS:[...])
# 2) basic components, subsystems and external ports 
# 3) 0 junctions
# 4) 1 junctions
##############################################################

function modulo10(x) {
  return x-int(x/10)*10
    }

function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
    }

function write_component(i) {
    name = label[i,1];
    cr   = label[i,2];
    arg  = label[i,3];
    if (length(x[name])==0) {
        # print error - its in lbl but not fig file
        printf(warning_l, name);
    }
    else {
      component_index++;
      print x[name], y[name], info[name] >> b_file;
      printf("if i==%1.0f\n", component_index) 	>> c_file;
      printf("\tcomp_type = %s%s%s;\n", q, comp_type[name], q) >> c_file;
      printf("\tname = %s%s%s;\n", q, name, q) >> c_file;
      printf("\tcr = %s%s%s;\n", q, cr, q) >> c_file;
      printf("\targ = %s%s%s;\n", q, arg, q) >> c_file;
      printf("\trepetitions = %s;\n",  reps[name]) >> c_file;
      print "end" >> c_file
	}
  }

function process_lbl() {
# This puts the components in the lable file at the top of the list
# and saves up the corresponding CR and arguments
# note that there may be more than one component per label
  if ((match($1,comment_regexp)==0)&&(NF>0))
    { 
      i_label++;
      name = $1;
      CR   = $2;
      args = $3;

      label[i_label,1] = name; 
      label[i_label,2] = CR;
      label[i_label,3] = args;
	}
}

function sort_cmp() {
# Sorts components alphabetically by type then name
  for (i = 1; i <= i_label; i++) {
    name = label[i,1];
    type = comp_type[name];
    cmp_list[i] = sprintf ("'%s:%s'", type, name);
  }

  if (no_alpha_sort=="no_alpha_sort")
      print "Not sorting components alphabetically"
  else {
      print "Sorting components alphabetically";
      asort (cmp_list)
  };

  for (i = 1; i <= i_label; i++) {
    for (j = 1; j <= i_label; j++) {
      name = label[j,1];
      type = comp_type[name];
      typename = sprintf ("'%s:%s'", type, name);
      if (typename == cmp_list[i]) {
	sort_cmp_list[i] = j;
      }
    }
  }
}

function fig_info() {
# Grabs the fig-file information for a component
  return(sprintf("%s %s %s %s %s %s %s %s %s %s %s ", \
		 $1, $2, $3, $4, $5, $6, $7, \
		 $8, $9, $10, $11))
	 }

function type_name(type) {
#    if (type==1)
#      return "one"
#    else {
#      if (type==0)
#        return "zero"
#      else
#        return type
#    }
    return sprintf("mtt%s", type);
}

function process_text() {
# The text string is field 14 onwards
  str = $14; 
  for (i=15; i<=NF; i++) {
    str = sprintf("%s %s", str, $i)
      }

# The depth is field 4 (for strings)
  depth = modulo10($4);

# It is terminated by \001 - so delete this termination
  str = substr(str,1,length(str)-4);

# Zap maths
  ##gsub(/[()-+*/]/,"",str); 

# Lose the cr stuff (if present)
  if (depth==0) {
      N=split(str,a,delimiter);
      if (N==3)
	  str=sprintf("%s%s%s", a[1],delimiter,a[2]);
    }

# A component string contains only alphanumeric  _ and :
  isa_plain_component = match(str, component_regexp)==0;
# It must also be specified at depth 0 (modulo 10)
  isa_plain_component = isa_plain_component && (depth==0);

# A port is a string within []
  isa_port = (match(str, port_regexp)>0)

# It must also be specified at depth 0
  isa_port = isa_port && (depth==0);

# Vector port definitions
  isa_PORT = ((match(str, PORT_regexp)>0) && (depth==0));

  if (isa_PORT) {
    print str
  }

# A port component is an SS  followed by a port string
  isa_port_component = 0;
  if (match(str, delimiter)) {
    split(str,a,delimiter);
    isa_port_component = (match(a[1], port_component_regexp))&&
      (match(a[2], port_regexp)>0)
      }

# It must also be specified at depth 0
  isa_port_component = isa_port_component && (depth==0);

# A component is a plain or a port component
  isa_component = isa_plain_component||isa_port_component;

# Coordinates in fields 12 & 13
  x_coord = $12;
  y_coord = $13;

# Do the ports
  if (isa_port) {
    i_port++;
    port_name = str;
    ports[i_port] = sprintf("%s %s %s", x_coord, y_coord, port_name);
  }

# Do the port components
#  if (isa_port_component) {
#    i_port_component++;
#    type = a[1];
#    # Port name is the bit between the []
#    port_label  = substr(a[2],2,length(a[2])-2);
#    x_port[i_port_component] = x_coord;
#    y_port[i_port_component] = y_coord;
#    info_port[i_port_component] = fig_info();
#    port_labels[i_port_component] = port_label;
#      }

# Do the components
  if (isa_component) {
    i_text++;

# Get repetitions (if any)
    if (match(str,repetition_regexp) > 0) {
      split(str,b,repetition_delimiter);
      repetitions = b[2];
      str = b[1];
	}
    else {
      repetitions = "1";
    };

    named_component = (match(str,delimiter) > 0);
    if (named_component) {
      split(str,a,delimiter);
      type = a[1];
      name = a[2];
# Check  if name is in label file and if used already
      found = 0; name_used = 0;
      for (i=1; i<=i_label; i++) {
	  lname = label[i,1];
	if ( lname==name ) {
	  found = 1;
	  if (name in used) {
	    name_used = 1;
	    CR = label[i,2];
	    args = label[i,3];
	  }
	  else {
	    used[name] = 1
	      }
	  break
	    }
      }

if (!found) {
printf(warning_f, name);
i_label++;
CR = default_cr;
args = "";
label[i_label,1] = name; 
label[i_label,2] = CR;
label[i_label,3] = args
}

# Give it a new entry if already used
#  -- also tell user as it is an error now(?)
      if (name_used) {
	printf(warning_u, name);
	i_label++;
	i_name++;
	name = sprintf("%1.0f", i_name);
	label[i_label,1] = name; 
	label[i_label,2] = CR;
	label[i_label,3] = args
	  }
    }

# Unnamed component
    if (named_component==0) {
      type = str;

      if (type in name_index) 
        name_index[type]++
      else
        name_index[type] = 1;

      if (name_index[type]==1)
        name = sprintf("%s", type_name(type))
      else
        name = sprintf("%s_%i", type_name(type), name_index[type]);

      i_label++;
      label[i_label,1] = name;
      label[i_label,2] = default_cr;
      label[i_label,3] = default_args
	}

# Save in associative arrays by name	
    comp_type[name] = type;
    x[name] = x_coord;
    y[name] = y_coord;
    info[name] =  fig_info();
    reps[name] = repetitions;
  }

}

#Euclidean length of a line between (first_x,first_y) and (second_x,second_y)
function line_length(first_x,first_y,second_x,second_y) {
  x_length = second_x-first_x;
  y_length = second_y-first_y;
  return sqrt( x_length*x_length +  y_length*y_length );
}

# Returns 1 if (bond) arrow at beginning of field or 2 if arrow at end of field
function arrow_end(first_x,first_y,second_x,second_y,penultimate_x,penultimate_y,last_x,last_y) {
  if ( line_length(first_x,first_y,second_x,second_y) < line_length(first_x,first_y,second_x,second_y) ) {
  return 1
  }
  else {
  return 2
  }
}

function process_bond() {

  arg_count++;
  if ( (arg_count-arrow)==1 ) 
    {

#Save up bond coords - no arrow and more segments than a stroke has.
# Allows for bent bonds - but just write out the relevant coordinates
	if ( (!arrow)&& (NF>2*stroke_coords+1) ) {
	    i_bond++;
	    a_end = arrow_end($2,$3,$4,$5,$(NF-3),$(NF-2),$(NF-1),$NF);
	    if (a_end==1) {
		arrow_end_vector_x = $6-$4; 
		arrow_end_vector_y = $7-$5; 
		other_end_vector_x = $(NF-1)-$(NF-3);
		other_end_vector_y = $(NF)-$(NF-2);
		bonds[i_bond] = sprintf("%s %s %s %s %s %s %s %s %s %s", \
					$2, $3, $4, $5, $(NF-1), $(NF),
					arrow_end_vector_x,
					arrow_end_vector_y,
					other_end_vector_x,
					other_end_vector_y);
	    }
	    else {
		other_end_vector_x = $4-$2; 
		other_end_vector_y = $5-$3; 
		arrow_end_vector_x = $(NF-3)-$(NF-5);
		arrow_end_vector_y = $(NF-2)-$(NF-4);
		bonds[i_bond] = sprintf("%s %s %s %s %s %s %s %s %s %s", \
					$2, $3, $(NF-3),$(NF-2),$(NF-1),$NF,
					arrow_end_vector_x,
					arrow_end_vector_y,
					other_end_vector_x,
					other_end_vector_y);
	    }
      }
      
#Save up arrow coords 
      if ( (arrow)&&(NF==(2*arrow_coords+1)) ) {
	i_arrow++;
	arrows[i_arrow] = sprintf("%s %s %s %s",  $2, $3, $4, $5);
      }
      
#Save up stroke coords
      if ( (!arrow)&&(NF==(2*stroke_coords+1)) ) {
	i_stroke++;
	strokes[i_stroke] = sprintf("%s %s %s %s",  $2, $3, $4, $5);
      }
    }
}

function write_fig() {
# Create _fig.fig file from _abg file - not components
# and write out the components in a _cmp.fig file
# and write out the bonds in a _bnd.fig file

# The artwork -- not header and not zero depth
    
    if ((NF>2)&&(!zero_depth)) {
	art=$0;
	sub("----","    ",art)
	printf("%s\n", art) >> art_file
	    }
	    

#Everything except components
  if ( ((object!=text)||(isa_component==0)) ) {
    #Replace the data_symbol
    if (exact_match($1,data_symbol)) {
      field_1 = out_data_symbol
	}
    else {
      field_1 = $1
      }

    printf("%s",field_1)   >> fig_file
      for (i=2; i<=NF; i++)
	printf(" %s", $i)  >> fig_file;
    if (NF==1) 
	printf(" ")   >> fig_file; # Put space after header fields
    printf("\n") >> fig_file
    }

# Header
  if ($1=="#FIG") 
    printf("%s", $0)  >> head_file;

  if ( NF<3 ) {
	printf("%s", $1)  >> head_file;
        for (i=2; i<=NF; i++)
	  printf(" %s", $i)  >> head_file;
	if (NF==1) 
	    printf(" ")   >> head_file; # Put space after header fields
	printf("\n") >> head_file
    }
# Bonds
  if (isa_bond) {

    #Replace the data_symbol
    if (exact_match($1,data_symbol)) {
      field_1 = out_data_symbol
	}
    else {
      field_1 = $1
	}

    printf field_1   >> bnd_file
      for (i=2; i<=NF; i++)
	printf(" %s", $i)  >> bnd_file;
    printf("\n") >> bnd_file
      }

# Components & ports
  if ( isa_component||isa_port ) {
      for (i=1; i<=NF; i++)
	  printf(" %s", $i)  >> cmp_file;
      printf("\n") >> cmp_file
	  }

# Ports
  if ( isa_port_component ||isa_port) {
      for (i=1; i<=NF; i++)
	  printf(" %s", $i)  >> port_file;
      printf("\n") >> port_file
}
}

function process_fig() {
# Test for the fig format first line and data line
  data_line = (match($1,data_symbol)>0);
  first_line = (data_line==0)&&(NF>min_line_length);

#Process firstline
  if (first_line) {
    object = $1;
    sub_type = $2;
    style = $3;
    zero_depth = ((modulo10($7)==0)&&(object==polyline)) || ((modulo10($4)==0)&&(object==text))
    f_arrow = ($14==1)&&(object=polyline);
    b_arrow = ($15==1)&&(object=polyline);
    arrow = f_arrow||b_arrow;
    arg_count = 0;
  }

#Process text
  if (object==text) {
    process_text();
    object = 0; # Text on one line so reset object to zero- avoids compound problem
      }

# Process bond
isa_bond = (zero_depth &&\
       (object==polyline)&& \
       (sub_type==sub_polyline)&& \
       (style==firm_style) \
       );   

if ( isa_bond && data_line)
{
    process_bond()
      }   

if (isa_fig_file){
     write_fig()
    }

    }

BEGIN {
  sys_name = ARGV[1];
  delete ARGV[1];

  b_file = sprintf("%s_rbg.m", sys_name);
  c_file = sprintf("%s_cmp.m", sys_name);
  fig_file = sprintf("%s_fig.fig", sys_name);
  cmp_file = sprintf("%s_cmp.fig", sys_name);
  port_file = sprintf("%s_port.fig", sys_name);
  bnd_file = sprintf("%s_bnd.fig", sys_name); 
  head_file = sprintf("%s_head.fig", sys_name);
  art_file = sprintf("%s_art.fig", sys_name);

  warning_f = "WARNING %s \t in fig file but not lbl file  - using\n";
  warning_l = "WARNING %s \t in lbl file but not fig file  - ignoring\n";
  warning_p = "ERROR system ports are not consecutively numbered\n";
  warning_u = "ERROR %s has already appeared in the fig file\n";

  comment_regexp = "%|#"
  data_symbol = "----";
  out_data_symbol = "\t";
  default_cr = "";
  default_args = "";
  delimiter = ":";
  repetition_delimiter = "*";
  repetition_regexp = "\\*";
  q = "\047";
  terminator = "\\001";
  component_regexp = "[^0-9a-zA-Z_:*-]";
  port_regexp = "^[[a-zA-Z0-9_,]*]";
  nonport_regexp = "[a-zA-Z]";
  PORT_regexp = "^PORT .*=";  
  port_component_regexp = "SS";
  isa_fig_file = 0;
  min_line_length = 10;
  object = 0;
  polyline = 2;
  sub_polyline=1; 
  firm_style = 0;
  text = 4;
  compound_object = 6;
  bond_coords = 3;
  stroke_coords = 2;
  arrow_coords = 2;

  i_bond = 0;
  i_port = 0;
  i_stroke = 0;
  i_arrow = 0;
  i_label = 0;
  i_text = 0;
  i_port_component = 0;

  component_index = 0;
}
{
# Start of .fig file?
  if ($1=="#FIG") {
    isa_fig_file=1;
  }
  if (isa_fig_file==0) {
    process_lbl()    
      }
  else {
    process_fig()
      }
}

END {
#Print out the Octave functions
  printf("function [rbonds, rstrokes,rcomponents,port_coord,port_name,port_list] = %s_rbg\n", sys_name) > b_file;
  printf("%% [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = %s_rbg\n", sys_name) > b_file;
  printf("%% Generated by MTT\n\n") > b_file;

  printf("function [comp_type, name, cr, arg, repetitions] = %s_cmp(i)\n",\
		 sys_name) > c_file;
  printf("%% [comp_type, name, cr, arg, repetitions] = %s_cmp\n", sys_name) > c_file;
  printf("%% Generated by MTT\n\n") > c_file;

  printf("rbonds = [\n") >> b_file;
  for (i = 1; i <= i_bond; i++)
    print  bonds[i] >> b_file;
  for (i = 1; i <= i_arrow; i++)
    print  arrows[i], "-1 -1" >> b_file;
  printf("];\n") >> b_file;
  
  printf("rstrokes = [\n") >> b_file;
  for (i = 1; i <= i_stroke; i++)
    print  strokes[i] >> b_file;
  printf("];\n") >> b_file;

  printf("rcomponents = [") >> b_file;
  j = 0;

  sort_cmp();	# sort components alphabetically

# Do the port components, in order of appearance, first.
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (match(name,port_regexp))
      write_component(num);
  }
  
# then do the ordinary components, in order of appearance.
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if ((!match(comp_type[name],"0"))&&
	  (!match(comp_type[name],"1"))) 
	write_component(num);
  }
  
# followed by the 0 junctions
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if (match(comp_type[name],"0"))
	write_component(num);
  }
# and finally the 1 junctions
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if (match(comp_type[name],"1"))
	write_component(num);      
  }
  printf("];\n") >> b_file;
  
# Print the (internal) ports list
  printf("port_coord = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    printf("%s %s\n", a[1], a[2]) >> b_file;
  }
  printf("];\n\n") >> b_file;

  printf("port_name = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    # Dont Remove the []
    # name = substr(a[3],2,length(a[3])-2);
    name = a[3];
    printf("'%s'\n", name) >> b_file;
  }
  printf("];\n\n") >> b_file;

# Print the (external) port list - ignore spurious ports (in lbl, not fig)
  printf("port_list = [\n") >> b_file;
  for (i = 1; i <= i_label; i++) {
    name = label[i,1];
    if (length(x[name])>0) {
      if (match(name,port_regexp))
	printf("'%s'\n", name) >> b_file;
    }
  }
  printf("];\n\n") >> b_file;
  
}



Added mtt/bin/trans/awk/rep_txt2make.awk version [1a899189e1].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: rep_txt2make
# Converts the text file describing a report to makefile dependencies
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.3  1997/05/19  15:40:04  peterg
# Pass mtt swithches to the new make file
#
# Revision 1.2  1996/11/21  15:57:28  peterg
# Now runs mtt quietly.
#
# Revision 1.1  1996/08/18  19:59:00  peter
# Initial revision
#
###############################################################


{
  if (NF==2)
    if( match("tex txt r m ps",$2)>0)
      print "mtt -q", switches, system_name, $1, $2
}



Added mtt/bin/trans/awk/rep_txt2tex.awk version [3c9239d1bd].

















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: rep_txt2tex
# Converts the text file describing a report to a report.
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.5  1997/05/22  11:12:34  peterg
# Chaged figure label.
#
## Revision 1.4  1997/05/22 07:36:35  peterg
## \ref --> \Ref
##
## Revision 1.3  1997/05/19 16:43:34  peterg
## Explicit include of tex files 'cos latex2html prefers this!
##
# Revision 1.2  1997/05/19  16:11:10  peterg
# Modified section headers.
#
# Revision 1.1  1996/08/18  19:58:49  peter
# Initial revision
#
###############################################################


BEGIN {
  split(ARGV[1],a,"_");
  system_name = a[1];
  args = ARGV[2];
  comment="\%";
}
{
  if ((match($1,comment)==0)&&(NF==2)) {
    Representation = $1;
    Language = $2;
    Rep_lang = sprintf("%s_%s", Representation, Language);
    section_head = sprintf("System \\textbf{%s}: representation \\textbf{%s}, language \\textbf{%s}", \
			   system_name,Representation,Language);
# section headings
    print "\\section{" section_head "}";
    print "\\label{" Rep_lang "}";
    print "\\index{\\textbf{" system_name "} -- " Representation "}";

# tex files
    if( match("tex",Language)>0) {
      # printf("  \\input{%s_%s.%s}\n", system_name, Representation, Language);
      command = sprintf("cat %s_%s.%s", system_name, Representation, Language);
      system(command);    }
# text files
    if( match("txt r m c h",Language)>0) {
      print "  \\begin{verbatim}";
      command = sprintf("cat %s_%s.%s", system_name, Representation, Language);
      system(command);
      print "  \\end{verbatim}";  
    }
# ps files
    if( match("ps",Language)>0) {
      printf("This representation is given as Figure \\Ref{fig:%s}.\n", Rep_lang);
      print "  \\begin{figure}";
      printf("   \\shadowbox{ \\epsfig{file=%s_%s.%s,width=0.9\\linewidth} }\n", \
	     system_name, Representation, Language);
      printf("    \\caption{System \\textbf{%s}, representation %s}\n", system_name, Representation);
      printf("    \\label{fig:%s}\n", Rep_lang);
      print "  \\end{figure}";
    }
  }
}
END {

}



Added mtt/bin/trans/awk/tex2doc.awk version [a8fccd0d60].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: tex2doc
# Encapsulates a tex file in a document.
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1997/04/15  11:18:49  peterg
# Uses supertabular package
#
# Revision 1.1  1996/08/18  20:00:10  peter
# Initial revision
#
###############################################################


END{
#  split(ARGV[1],a,"_");
#  system_name = a[1];
#  split(a[2],b,".");
#  representation = b[1];
  makefile = sprintf("%s_rep.make", $system_name, $representation);
  print "\\documentclass[12pt,a4paper]{article}";
  printf("\\title{System %s, representation %s}\n", \
	 system_name, representation) 
  print "\\author{Generated by MTT}";
  print "  \\usepackage{epsfig}";
  print "  \\usepackage{supertabular}";
  print "\\begin{document}";
  print "  \\maketitle";
  print"  \\input{}", system_nam,e $representation;
  print $system_name $representation
  print "\\end{document}"
}

Added mtt/bin/trans/bg2eps version [b8f9ead8c5].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

set +e				# prevent dia errors from halting MTT

sys=$1
rep=$2
ps=$3
eps=$4

dia_files=`ls ${sys}*_${rep}.dia 2>/dev/null | sed 's/\.dia$//'`
fig_files=`ls ${sys}*_${rep}.fig 2>/dev/null | sed 's/\.fig$//'`

for file in ${dia_files}
  do
  dia --export-to-format=eps ${file}.dia
  if [ "${ps}" != "eps" ]
      then mv ${file}.eps ${file}.${ps}
  fi
done

for file in ${fig_files}
  do
  fig2dev -L${eps} ${file}.fig > ${file}.${ps}
done

Added mtt/bin/trans/c-tidy version [28f2822d80].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1997/02/04 18:50:07  peterg
## Initial revision
##
## Revision 1.2  1996/08/20 08:26:06  peter
## Version control header added.
##
###############################################################

# Bourne shell script: c_tidy
# Tidies up C format files
# P.J.Gawthrop 14 June 1990 13 Nov 1990, 19 Nov 93, April 1994, Dec 1994, 
# June 1995
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

# Remove blank lines
cat $1 | \
tr -s '\012' '\012'\
>junk
mv junk $1







Added mtt/bin/trans/c_tidy version [58bf61dcc7].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1997/02/04 18:52:34  peterg
## Copied from matlab tidy -- removed everthing except removal of blank
## lines
##
## Revision 1.1  1997/02/04 18:50:07  peterg
## Initial revision
##
## Revision 1.2  1996/08/20 08:26:06  peter
## Version control header added.
##
###############################################################

# Bourne shell script: c_tidy
# Tidies up C format files
# P.J.Gawthrop 14 June 1990 13 Nov 1990, 19 Nov 93, April 1994, Dec 1994, 
# June 1995
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

# Remove blank lines
cat $1 | \
tr -s '\012' '\012'\
>junk
mv junk $1







Added mtt/bin/trans/can_r2m version [4c4db15907].



























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: can_r2m
# Reduce canonical forsm to matlab
# P.J.Gawthrop  January 8th 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################



# Inform user
echo Creating $1_can.m

# Remove the old log file
rm -f can_r2m.log

# Use reduce to accomplish the transformation
reduce >can_r2m.log << EOF

%Read in the definitions file
IN "$1_def.r";

%Read the reduce state-space A,B,C and D matrices file
IN "$1_can.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read in the parameter file
IN "$1_sympar.r";

OUT "$1_can.m";
%Headings - Matlab style
%(Note. The ;; are deleted by for2mat)

write "function [A_c,B_c,C_c,D_c,Con,Obs,K,L,A_comp,B_comp,C_comp] = $1_can;;";
write "%function [A_c,B_c,C_c,D_c,Con,Obs,K,L,A_comp,B_comp,C_comp] = $1_can;;";

write "%Canonical forms and controller design for system $1";
write "%File $1_can.m";
write "%Generated by MTT";
write "";

IF MTTNvar>0 THEN
BEGIN
  write "% Set the parameters";
  write "global ...;;";
  FOR i := 1:MTTNx DO
    write "alpha_c",i, " alpha_o",i, "...;;";
  
  FOR i := 1:MTTNvar DO
    BEGIN
      IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
        % Do nowt
      END
      ELSE  
      BEGIN
        write MTTVar(i,1), " ...";
      END;
    END;
    write " ";
END;


%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "MTTA_c = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTB_c = zeros(", MTTNx, ",", MTTNu, ");";
write "MTTC_c = zeros(", MTTNy, ",", MTTNx, ");";
write "MTTD_c = zeros(", MTTNy, ",", MTTNu, ");";

write "MTTCon = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTObs = zeros(", MTTNx, ",", MTTNx, ");";

write "MTTK = zeros(", MTTNy, ",", MTTNx, ");";
write "MTTL = zeros(", MTTNx, ",", MTTNu, ");";

write "MTTA_comp = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTB_comp = zeros(", MTTNx, ",", MTTNy, ");";
write "MTTC_comp = zeros(", MTTNu, ",", MTTNx, ");";


ON NERO;	% Suppress zero elements.
MTTA_c := MTTA_c;
MTTB_c := MTTB_c;
MTTC_c := MTTC_c;
MTTD_c := MTTD_c;

MTTCon := MTTCon; 
MTTObs := MTTObs; 


MTTK := MTTK; 
MTTL := MTTL;

MTTA_comp := MTTA_comp;
MTTB_comp := MTTB_comp;
MTTC_comp := MTTC_comp;
MTTD_comp := MTTD_comp;


OFF FORT;
write "";

SHUT "$1_can.m";

Added mtt/bin/trans/can_r2tex version [5939f4edfe].


































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: can_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Inform user
echo Creating $1_can.tex

# Remove the old log file
rm -f can_r2tex.log

# Use reduce to accomplish the transformation
reduce >can_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the canonical-form matrices file
in "$1_can.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

OUT "$1_can.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_can.tex";
write"";


% Controllable form
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Observer Gain matrix - observer form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$


% Controllable form
MTT_Matrix := MTTA_comp$ 
MTT_Matrix_name := "MTTA_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_comp$ 
MTT_Matrix_name := "MTTB_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_comp$ 
MTT_Matrix_name := "MTTC_comp"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$



write "\begin{equation}";
  write "MTTur = {", MTTu_r, "}";
write "\end{equation}";

SHUT "$1_can.tex";
quit;
EOF

Added mtt/bin/trans/cbg2ese_m2r version [fe2612a1bc].


































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cbg2ese_m
#
#
# P.J.Gawthrop June 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$
## Revision 1.32  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.31  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.30  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.29.2.1  2001/06/26 22:29:05  geraint
## mtt_xargs.sh eliminates Arg list too long error for large models.
## (UNIX xargs does not work if the environment is too large).
##
## Revision 1.29  2001/03/29 19:24:14  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.28  2001/02/05 17:19:52  gawthrop
## Now gives unique names to the states of multiports. Second name
## onwards labeled with port number
##
## Revision 1.27  2000/12/05 12:09:56  peterg
## Changed function name to name()
##
## Revision 1.26  2000/12/05 09:04:54  peterg
## *** empty log message ***
##
## Revision 1.25  2000/12/01 14:51:26  peterg
## Major changes towards partioning
##
## - generates sub ese, def and struc
## - generates indices for conversion of subsystem in/out/state - but not used yet
##
## Revision 1.24  2000/11/30 15:12:55  peterg
## Zapped the declaration of subsystem connections - now in individual
## .def files
##
## Revision 1.23  2000/11/30 15:07:28  peterg
## Sorted out mtt_getsize
##
## Revision 1.22  2000/11/12 17:18:30  peterg
## Changed ' to "
##
## Revision 1.21  2000/10/16 08:40:35  peterg
## Whoops! Must touch mtt_aliased
##
## Revision 1.20  2000/10/16 08:36:31  peterg
## Creat empty _aliased file if it doesn't exist
##
## Revision 1.19  2000/10/12 19:25:39  peterg
## Now generateds the _aliased.txt file
##
## Revision 1.18  2000/09/15 08:09:42  peterg
## Removed another debugging line
##
## Revision 1.17  2000/09/15 08:06:17  peterg
## Removed debug lines
##
## Revision 1.16  2000/09/02 15:55:51  peterg
## *** empty log message ***
##
## Revision 1.15  1998/07/08 14:43:12  peterg
## Restored inforfile
##
## Revision 1.14  1998/07/08 08:26:26  peterg
## Added -I option -- if set prints out the information messages
##
## Revision 1.13  1998/05/12 14:49:10  peterg
## Don't write END; any more - ese-tidy does this now!
##
## Revision 1.12  1998/01/23 13:30:46  peterg
## $RMATRIX --> $MATRIX
##
## Revision 1.11  1997/12/16 18:05:03  peterg
## Increased size of structure vector by on to include unknown_inputs as
## 6th element
##
## Revision 1.10  1997/04/15 09:18:26  peterg
## Added structure file
##
# Revision 1.9  1996/12/07  18:21:25  peterg
# Now uses fopen + file number
#
## Revision 1.8  1996/12/05 10:05:28  peterg
## Removed the Octave switch: empty_list_elements_ok = 1;
## This is now in .octaverc
##
# Revision 1.7  1996/08/30  11:29:49  peter
# Added constitutive relationship to argument list.
# Put in explicit argument list to cbg2ese.
#
# Revision 1.6  1996/08/26  13:25:07  peterg
# Corrected error handling.
#
# Revision 1.5  1996/08/24  14:38:11  peter
# Error handling included.
#
## Revision 1.4  1996/08/19 09:02:12  peter
## Errors go to user - not log.
##
## Revision 1.3  1996/08/18 20:05:55  peter
## Included zero outputs.
##
## Revision 1.2  1996/08/08 18:08:37  peter
## Sorted out file naming scheme.
##
## Revision 1.1  1996/08/08 15:57:15  peter
## Initial revision
##
###############################################################

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


infofile='mtt_info.txt';
structurefile="$1_struc.txt";
eqnfile="$1_ese.r";
deffile="$1_def.r";


# Remove the old log file
rm -f cbg2ese_m.log

# Remove the info and error files
rm -f mtt_info.txt
rm -f mtt_error.txt
rm -f mtt_aliased.txt

# Remove relevent ese files
rm -f $1_ese.r $1_*_ese.r 

#Inform user
echo Creating $eqnfile $blurb
echo Creating $deffile
echo Creating $structurefile

# Use matrix manipulation to accomplish the transformation
# This creates an ese file for every subsystem.
$MATRIX << EOF > cbg2ese_m2r.log 2>mtt_error.txt

infofile = "$infofile";;
infofilenum = fopen(infofile,"wt");
structurefile = "$structurefile";;
structurefilenum = fopen(structurefile,"wt");
deffile = "$1_def.r";
deffilenum = fopen(deffile,"wt");

system_name = "$1";
system_type = "";
system_cr = "";
system_args = "";
full_name = "";
full_name_repetition = "";

% Structure matrix [states,nonstates,inputs,outputs,zero_outputs]

structure = zeros(1,7);  # Initialise structure vector

structure = cbg2ese(system_name, system_type, system_cr, ...
                     system_args, full_name, full_name_repetition, ...
                     1, structure, structurefilenum, infofilenum);
makedef(structure,deffilenum);
EOF

echo "END;" >> $1_def.r

if [ "$info" = "info" ]; then
  cat $infofile
fi

if [ -z "$partition" ]; then
  ## Don't partition

  # Create the composite ese file
  mtt_xargs.sh cat "$1_ese.r $1_*_ese.r $1_modpar.r"  > $1_ese.tmp 2>> /dev/null

  mv $1_ese.tmp $1_ese.r

  # Zap the sub ese files
  mtt_xargs.sh "rm -f" "$1_*_ese.r"

  echo "END;" >> $1_ese.r

else # Partition the system

  # Save up the full def file
  mv $1_def.r mtt_all_def.r

## Recreate def file from the ese file directly
makedef ()
{

echo Creating $1_def.r

Nx=`mtt_getsize -external $1 dX`
Nz=`mtt_getsize -external $1 z`
Ny=`mtt_getsize -external $1 y`
Nu=`mtt_getsize -external $1 u`
Nui=`mtt_getsize -external $1 ui`
Nuc=`mtt_getsize -internal $1 u`

# echo Ny $Ny Nu $Nu Nx $Nx Nui $Nui Nuc $Nuc

## Definitions file
octave -q <<EOF
  deffile = '$1_def.r';
  deffilenum = fopen(deffile,'wt');

  ## Set up the structure vector
  structure = zeros(1,7);  
  structure(1) = $Nx; # States
  structure(2) = $Nz; # Non-states
  structure(3) = $Nu; # Inputs
  structure(4) = $Ny; # Outputs
  structure(5) = 0;   # Zero outputs
  structure(6) = $Nui; #Internal inputs 
  structure(7) = $Nuc; # Connecting inputs

  makedef(structure,deffilenum);  #Create definitions
EOF

echo "END;" >> $1_def.r
}


get_indices ()
{
  sys=$1
  which=$2
  gawk '{if ($1==which) print $2}' which=$which < ${sys}_struc.txt
}

convert_indices ()
{
  sys=$1
  Which="input output state"
  for which in $Which; do
  
    indices=`get_indices ${sys} $which`
  
    case $which in
      input)
  	name=u
  	;;
      output)
  	name=y
  	;;
      state)
  	name=x
  	;;
      *)
  	
    esac
  
    new=0
    for old in $indices; do
      new=`expr $new + 1`
      pattern="MTT${name}(${old},1)"
      replacement="MTT${name}(${new},1)"
      mv ${sys}_ese.r mtt_junk
      sed "s/$pattern/$replacement/" <mtt_junk >${sys}_ese.r
    done
  done
}
  # Find subsystems
  subsystems=`mtt_get_subsystems $1`

  # Top level  
  makedef $1;
  echo "END;" >> $1_ese.r

  ## Subsystems
  for subsystem in $subsystems; do
    echo Connecting $subsystem
#    Ny=`mtt_getsize -internal ${subsystem}_1 y`
#    Nu=`mtt_getsize -internal ${subsystem}_1 u`
#    Nx=`mtt_getsize -internal ${subsystem}_1 u`
#    echo Ny $Ny Nu $Nu Nx $Nx


#    echo MATRIX "MTT_"$subsystem"_uc("$Nu",1);"  >> $1_def.r

    echo >> $1_ese.r
    echo %Subsystem input connections for $subsystem  >> $1_ese.r
    octave -q <<EOF                            >> $1_ese.r
    for i=1:$Nu
      printf("MTT_%s_uc(%i,1) := %s_1_MTTu%i;\n", "$subsystem", i, "$subsystem", i);
    endfor;
EOF
  ## Subsystems (Only works when no repetitions at this level)
  esefile=${subsystem}_ese.r
  echo Creating $esefile
  mtt_xargs.sh cat "${subsystem}_1_ese.r ${subsystem}_1_*_ese.r" > $esefile 2> /dev/null
  echo "END;" >> $esefile

  ## Def file for subsystem
  makedef ${subsystem}
  
  echo Creating ${subsystem}_struc.txt
  grep $subsystem < $1_struc.txt > ${subsystem}_struc.txt

  echo Converting subsystem indices
  convert_indices ${subsystem}

  done

fi


# Create the _alised file
touch mtt_aliased.txt
echo Creating $1_aliased.txt
mv mtt_aliased.txt $1_aliased.txt

# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile

# Relabel states with multiple ports
relabel_multiple_definitions(){
  mv $structurefile junk
  gawk '
  BEGIN{
     var_type_index=1;  
     oldname="";
  }
  {
     name=$4;
     newname=name;
     if ($1==var_type) {
       if (name==oldname)
         newname = sprintf("%s_%i",name, ++var_type_index);
       else
         var_type_index=1; 
   }
     $4 = newname
     for (i=1;i<NF;i++) printf("%s\t",$i);
     printf("%s\n", $NF)
     oldname = name;
  '} < junk var_type=$1> $structurefile
}

relabel_multiple_definitions input;
relabel_multiple_definitions output;
relabel_multiple_definitions state;

# Now invoke the standard error handling.
mtt_error mtt_error.txt







Added mtt/bin/trans/cbg2pcbg version [fcf7f64a42].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/bash

## Colour the reactions in the path

## Colours
blue=1
green=2
cyan=3
red=4
magenta=5
yellow=6
colour=$magenta

## Fonts
Times_Bold_Italic=3
Helvetica_Bold_Oblique=19
Helvetica_Narrow_Bold_Oblique=23
font=${Helvetica_Bold_Oblique}

sys=$1
path="$2"

cp ${sys}_cbg.fig tmp.fig
for p in $path; do
    ##echo doing $p
    sed "s/\([0-9] [0-9]\) [0-9]* \([0-9]* [0-9]*\) [0-9]* \(.*:$p.001$\)/\1 $colour \2 $font \3/" \
	< tmp.fig >TMP.fig
    mv TMP.fig tmp.fig
done

mv  tmp.fig ${sys}_pcbg.fig

Added mtt/bin/trans/cbg2sese_m2r version [f1a37f79fd].



















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  2003/03/13 15:44:53  gawthrop
  ## The main transformation for sorted elementary equations
  ##
  ## Revision 1.3  2003/03/13 09:00:22  peterg
  ## Revised for new mtt_component_eqn arg list
  ##
  ## Revision 1.2  2003/03/11 10:16:03  peterg
  ## Removed NAME argument
  ##
  ## Revision 1.1  2003/03/11 10:08:49  peterg
  ## Initial revision
  ##
  ##
  ###############################################################

## cbg2seqn_m2r: Converts causal bond graph into sorted equations
## Copyright (C) 2003 by Peter J. Gawthrop

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;

	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

infofile='mtt_info.txt';
strucfile=$1_struc.txt
outfile=$1_sese.r
make=mtt_make_sese.m
CD='%%%% ====='
## Inform user
echo Creating ${outfile}

## Header
create_header() {
cat<<EOF    
$CD File ${outfile}
$CD Created by MTT on `date`

EOF
}

## Setup states etc
set_known() {
  gawk '{
  name["state"]="x";
  name["input"]="u";

  if ($1==which) {
   printf("MTT%s_%s := MTT%s(%s,1);\n", name[$1], $4, name[$1], $2);
   }
}'  which=$1 < ${strucfile}      
}

## Setup outputs, derivatives etc
set_out() {
  gawk '{
  name["state"]="dx";
  name["output"]="y";

  if ($1==which) {
   printf("MTT%s(%s,1) := MTT%s_%s;\n", name[$1], $2, name[$1], $4);
   }
}'  which=$1 < ${strucfile}      
}


## Create the octave commands for state, output etc
create_octave() {
gawk '{
  if ($1==which) {
     printf("printf(\"\\n%s The %s equation for %s\");\n", CD, $1, $4);
     printf("[known] = mtt_component_eqn\\\n");
     printf("(\"%s\",1,mtt_other_causality(\"%s\"),known,\"\",\"\");\n", $4, $6);
   }
}' "CD=${CD}" which=$1 < ${strucfile}         
}

create_octave_header() {
cat <<EOF
## Octave commands to generate sese file
## Created by mtt on `date`

known = "";

EOF
}

## Header
create_header > ${outfile}
cat >> ${outfile}<<EOF
${CD} Set up the state and input variables

EOF
which_list="state input"
for which in ${which_list}; do
    set_known ${which} >> ${outfile}
done


## Create a file of octave commands
create_octave_header > ${make}
which_list="state output"
for which in ${which_list}; do
    create_octave ${which} >> ${make}
done


## Execute the m file
octave -q < ${make} >> ${outfile}

## Tail
cat >> ${outfile}<<EOF

${CD} Set up the state derivative and output variables

EOF
which_list="state output"
for which in ${which_list}; do
    set_out ${which} >> ${outfile}
done

cat<<EOF >> ${outfile}
END;
EOF

## Print info

if [ "$info" = "info" ]; then
  cat $infofile
fi

Added mtt/bin/trans/cbg_m2dia version [ddc0cb4e01].



























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

### cbg_m2dia
##
## Creates cbg.dia from:
## abg.dia, ibg.m, connections.dat, cbg.m
##
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

sys=$1
name=$2

## need to fix MTT to create connections.dat using make
## in the meantime:
mtt -q ${sys} connections dat

dia=${sys}_abg.dia
if [ ! -f ${dia} ]; then
    # probably not a dia model
    exit;
fi

echo Creating ${name}_cbg.dia -- component type ${sys}

con=${sys}_connections.dat
out=${name}_cbg.dia

${MATRIX:-octave} -q <<EOF > cbg_m2dia_spec.txt
ibg	= ${sys}_ibg;
cbg	= ${name}_cbg;

## get connections data: ${sys}_connections
## structure with two cell arrays: head and tail 
## the index of each array element is the bond index
## the value of each array element is a component name
load -text ${sys}_connections.dat;
con	= ${sys}_connections;

nibgbonds = length (fieldnames (ibg.bonds));
ncbgbonds = length (con.head);

## map cbg data to connection data
for [bond, bond_name] = ibg.bonds

  head = bond.head.component;
  tail = bond.tail.component;

  i = index (head, ':');
  head = substr (head, i+1, length(head)-i);

  i = index (tail, ':');
  tail = substr (tail, i+1, length(tail)-i);

  ## index of bond in diagram
  idia = str2num (strrep (bond_name, "bond", ""));

  ## find index of bond in cbg
  e(idia) = f(idia) = 0;
  for i = 1 : ncbgbonds
    if (strcmp (con.head{i}, deblank (head)) && ...
	strcmp (con.tail{i}, deblank (tail)))
      e (idia) = cbg.bonds (i, 1); # effort
      f (idia) = cbg.bonds (i, 2); # flow
   endif
  endfor
endfor

espec	= "--change_effort_causality ";
fspec	= "--change_flow_causality   ";
for i = 1 : nibgbonds
  espec = sprintf ("%s%d:%d;", espec, i, e(i));
  fspec = sprintf ("%s%d:%d;", fspec, i, f(i));
endfor
disp (espec)
disp (fspec)
EOF

spec=`cat cbg_m2dia_spec.txt`

/usr/local/src/mtt/mttroot/mtt/bin/trans/dia2abg.pl \
    --diagram_name    $sys	\
    --dia_input_file  $dia	\
    --dia_output_file $out	\
    $spec

Added mtt/bin/trans/cbg_m2fig version [f290f42a19].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cbg_m2fig
#
# Causal bond graph:  mfile format to fig file format
# The resultant fig file is the original _abg.fig with
# additional causal strokes superimposed.
#
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/03/23 14:55:03  gawthrop
## Fixed cosmetic bugs -- component display
##
## Revision 1.11  2000/12/28 12:19:49  peterg
## *** empty log message ***
##
## Revision 1.10  2000/09/14 12:04:48  peterg
## New 2 parameter version
##
## Revision 1.9  1998/01/23 13:31:23  peterg
## $RMATRIX --> $MATRIX
##
## Revision 1.8  1996/12/07 19:23:07  peterg
## Registered agian.
##
# Revision 1.7  1996/11/09  19:04:34  peterg
# Removed cp $1_$1_cbg.fig $1_cbg.fig.
#
## Revision 1.6  1996/11/06 15:58:46  peterg
## Changed Matrix to RMATRIX
##
# Revision 1.5  1996/11/02  10:16:50  peterg
# Changed stroke length to 150
#
# Revision 1.4  1996/08/25  09:28:59  peter
# More error handling.
#
## Revision 1.3  1996/08/24 14:40:31  peter
## Error handling included.
##
## Revision 1.2  1996/08/08 18:07:31  peter
## Sorted out naming scheme for files
##
## Revision 1.1  1996/08/05 20:13:56  peter
## Initial revision
##
###############################################################


# Remove the old log file
rm -f cbg_m2fig.log
rm -f mtt_info.txt

# The following sets up the fig header file for the system
# and each sub system.
# (ls $1_*_cbg.m \
# | sed 's/\(.*_\)\(.*_\)cbg.m/cp \2fig.fig \1\2cbg.fig/' \
#| sh ) 2>mtt_error.txt

#sh $1_type.sh 'cp ' '_fig.fig ' '_cbg.fig'> mtt_error.txt

# Copy the unchaging part of the figure file
cat $1_head.fig $1_port.fig $1_bnd.fig $1_art.fig> $2_cbg.fig

#Inform user
echo Creating $2_cbg.fig -- component type $1

# Use  matrix manipulation to accomplish the transformation
$MATRIX   <<EOF  2>mtt_error.txt > cbg_m2fig.log

  system_type = "$1"
  system_name = "$2"

  thick = 3; length = 150; red = 4; blue = 1; green = 12; font = 18;
  cbg2fig(system_name, system_type, '', ...
          length, thick, blue, ...
          font, green, red);
EOF

#cp $1_$1_cbg.fig $1_cbg.fig 2>> mtt_error.txt

# Print errors, if any.
mtt_error mtt_error.txt

Added mtt/bin/trans/cmp2cmp_m version [da616cbb8d].












































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2cmp_m
# Revises the component file (cmp) to account for aliases.

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:20:04  peterg
## Initial revision
##
###############################################################

# Inform user
echo Revising $1_cmp.m

# Copy the alias and cmp files.
cat $1_alias.txt $1_cmp.m > junk

#Create the cmp file complete with headers.
#echo "# Component file ($1_cmp.m)" #> $1_cmp.m
#echo "# Revised by MTT at `date`" #>> $1_cmp.m

#Write out the variables 
gawk '
BEGIN{
alias_file=1
Parameter_Regexp = "^_Parameter_"
Line_Regexp = "cr|arg"
quote = "\047"
}
{
  if (alias_file) {
    if (match($1,Parameter_Regexp)>0){
      alias[$2] = $1;
      sub(Parameter_Regexp,"$",alias[$2]); # Replace by $ format
    }
  }
  else {
    if (match($1,Line_Regexp)){
      cr_or_args = substr($3,2,length($3)-3); # It it a cr or arg line
      N=split(cr_or_args,a,";"); # Split into parts
      for (i=1;i<=N;i++){
        if (a[i] in alias)       # Replace by alias
          a[i] = alias[a[i]];
      }
      cr_or_args = a[1];         # Recombine
      for (i=2;i<=N;i++)
        cr_or_args = sprintf("%s;%s", cr_or_args, a[i]);
      print   "\t" $1 "\t" $2 "\t" quote cr_or_args quote
    }
    else
      print $0
  }
  if ($1=="###_END_OF_ALIAS_###")
    alias_file=0;
}' <junk > $1_cmp.m

rm -f junk








Added mtt/bin/trans/cmp2lbl_txt version [cfe16ef4bc].










































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2lbl_txt
#
# Component list to skeleton lable file
# Hacked from (now redundent) abg2lbl_txt

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/12/06 11:45:57  gawthrop
## Strips comments from _cmp.txt before processing
##
## Revision 1.1  2002/12/01 14:54:52  gawthrop
## Replaces defunct abg2lbl_fig2txt
##
##
## Old log from abg2lbl_fig2txt
## Revision 1.28  2002/10/30 00:04:22  gawthrop
## Added AEf and AFe to list
##
## Revision 1.27  2002/05/10 09:08:55  gawthrop
## Added EMTF and INTF
## Fixed bug in writing out component headings
##
## Revision 1.26  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.25  2001/10/15 14:27:00  gawthrop
## Now handles [1:N] style port labels
##
## Revision 1.24  2001/08/02 03:24:48  geraint
## Replaced mtt_version.sh with mtt_banner.sh - I think this was the intent.
##
## Revision 1.23  2001/07/26 04:08:35  gawthrop
## Removed lines deleting _type.sh and cbg.m
##  -- how did they get there ??
##
## Revision 1.22  2001/07/08 03:28:11  gawthrop
## Fixed a bug: abg2sympar_m2txt neads a _lbl.txt file when using
## "usinglabel" option
##
## Revision 1.21  2001/07/06 00:46:50  gawthrop
## Added -cr option -- forces cr to be loaded before the ese.r file
## This avoids causality problems when using multi-port Rs to represent
## arbitary equations
##
## Revision 1.20  2001/07/04 05:19:57  gawthrop
## Added RT & CT to list
##
## Revision 1.19  2001/07/03 23:51:10  gawthrop
## Now puts outline #Summary and #Description lines at top of lbl file
##
## Revision 1.18  2001/06/13 18:24:10  gawthrop
## Made "lin" default in place of "none"
## Still needs arg and cr alias clashes to be sorted ....
##
## Revision 1.17  2001/06/13 10:41:06  gawthrop
## Further changes towards aouto creation of lbl files.
## Prettified lbl files
##
## Revision 1.16  2001/06/11 19:43:49  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.15  2001/06/11 16:53:49  gawthrop
## Now uses abg2sympar_m2txt to get the arguments
##
## Revision 1.14  2001/06/11 15:06:58  gawthrop
## Now handles user-defined components
##
## Revision 1.13  2001/06/04 08:13:37  gawthrop
## Various changes to support PPP
##
## Revision 1.12  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.11  2000/09/19 11:14:30  peterg
## Now writes the first component type header correctely
##
## Revision 1.10  2000/01/26 10:11:10  peterg
## Added I component
##
## Revision 1.9  1999/11/10 00:47:08  peterg
## Replaced ifs by a table of cr/arg information
##
## Revision 1.8  1999/11/09 22:32:41  peterg
## Under RCS ready for using arrays to contaain defaults.
##
## Revision 1.7  1998/07/04 10:37:21  peterg
## Major revision to include:
## 	aliases
## 	new Style
## 	prettyfied
##
## Revision 1.6  1998/03/05 10:09:47  peterg
## Corrected bug in writing "other" components
##
## Revision 1.5  1998/03/02 09:26:18  peterg
## Now does default CR and args for the basic components only
## SS,I,R,C,GY,TF
## C now has a default of effort input.
##
## Revision 1.4  1998/02/23 16:20:33  peterg
## Summary line just contains the model name
##
## Revision 1.3  1997/05/09 14:21:35  peterg
## Default to flow,component_name
##
# Revision 1.2  1997/03/19  12:08:01  peterg
# No longer writes out non-unique names - now done in rbg_fig2m
#
# Revision 1.1  1997/03/18  13:55:01  peterg
# Initial revision
#
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997
# Copyright (C) 2002 by Peter J. Gawthrop

infofile='mtt_info.txt'
typefile="$1_type.sh"
sensitivity=$2;
system=$1
outfile=$1_lbl.txt

if [ -n "$sensitivity" ]; then
    sys="-s ${system}"
    sensitivity_switch=" -s "
else
    sys=${system}
fi

# Remove unwanted files
rm -f abg2lbl_fig2txt.log
rm -f $infofile
rm -f mtt_junk*

## Create lbl files beneath this one
mtt -q -u -l 1 ${sys} sub sh # Create the list
sh $1_sub.sh "echo mtt -q -l 1 ${sensitivity_switch}" " lbl txt" | sh

if [ -f "$1_lbl.txt" ]; then
  ##echo "$1_lbl.txt exists in `pwd` - no action taken"
  exit
##else 
  ##echo "$1_lbl.txt dosn not exist in `pwd` "
fi

#Inform user
if [ -n "$sensitivity" ]; then
    echo "Creating ${outfile} (sensitivity version)"
else
    echo "Creating ${outfile}"
fi

write_header()

{
cat<<EOF
#SUMMARY ${system}
#DESCRIPTION Detailed description here

## System ${system}, representation lbl, language txt
## File ${system}_lbl.txt
## Generated by MTT on `date`

EOF
cat $MTT_DOC/mtt_banner.sh


}

write_blurb()
{
cat <<EOF

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----
EOF
}

create_lbl_body()
{


#Write out the outline lbl file
strip_comments <$1_cmp.txt | grep -v  '\[[0-9]*\]' | \
gawk --field-separator ':' '
 BEGIN {
    OldComponent="None";
    default_cr = "lin";
 }
(NF == 1) {
  Component = $1 " (anonymous => default parameters)";
  Name = "# " $1;
  cr[Component] = "\t";
  arg[Component] = "\t";
}
(NF > 1) { 
  Component = $1;
  Name = $2;
  Arg = $3;
}
{
##Aliases
  if (Component == "SS") {
    port_alias[++j] = Name;
    Component_type = Component;
  }
  else {
    alias[++i] = Name;
    if (length(sensitivity)>0) {
      s_arg = sprintf("%ss",Name);
      alias[++i] = s_arg;
      s_arg = sprintf(";%s",s_arg);
      Component_type = Component;
      Component = substr(Component,2);
      lin = "slin"
    }
   else {
      Component_type = Component;
      lin = "lin";
    }
  
 }

    ## Table of components
    cr["SS"] = "SS";  arg["SS"] = "external,external";

    cr["Se"] = "SS";  arg["Se"] = sprintf("external%s", s_arg);
    cr["Sf"] = "SS";  arg["Sf"] = sprintf("external%s", s_arg);

    cr["De"] = "SS";  arg["De"] = "external";
    cr["Df"] = "SS";  arg["Df"] = "external";

    cr["R"] = lin;  arg["R"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["C"] = lin;  arg["C"]  = sprintf("effort,%s%s", Name, s_arg);
    cr["I"] = lin;  arg["I"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["INTF"] = lin;  arg["INTF"]  = "";

    cr["CS"] = "lin";  arg["CS"]  = sprintf("effort,%s;%s_x0%s", Name, Name, s_arg);
    cr["IS"] = "lin";  arg["IS"]  = sprintf("flow,%s;%s_x0%s", Name, Name, s_arg);
    cr["INTFS"] = "lin";  arg["INTFS"]  = sprintf("%s_x0%s", Name, s_arg);

    cr["TF"] = "lin";  arg["TF"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["GY"] = "lin";  arg["GY"]  = sprintf("flow,%s%s", Name, s_arg);

    ##cr["EMTF"] = sprintf("%s", Name);  arg["EMTF"]  = sprintf("l%s",  s_arg);
    cr["EMTF"] = "lin";  arg["EMTF"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["AE"] = "lin";  arg["AE"]  = sprintf("%s%s", Name, s_arg);
    cr["AF"] = "lin";  arg["AF"]  = sprintf("%s%s", Name, s_arg);
    cr["AEf"] = "lin";  arg["AEf"]  = sprintf("%s%s", Name, s_arg);
    cr["AFe"] = "lin";  arg["AFe"]  = sprintf("%s%s", Name, s_arg);

    cr["CDx"] = "lin";  arg["CDx"]  = sprintf("%s%s", Name, s_arg);


    cr["FMR"] = lin;  arg["FMR"]  = sprintf("effort,%s%s", Name, s_arg);

    cr["RS"] = lin;  arg["RS"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["RT"] = lin;  arg["RT"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["CT"] = lin;  arg["CT"]  = sprintf("effort,%s%s", Name, s_arg);

    ## Put in the explicit arguments
    if (length(Arg)>0) {
      arg[Component] = Arg;
      if (match(Arg,"=")>0) # Its an equation type cr
        cr[Component] = "cr"
      else # assume a linear cr
        cr[Component] = "lin";
    }

  ## Print component header 
  if (Component != OldComponent) print "\n## Component type", Component_type

  ## Print Component
    printf("\t%s\t", Name);
    if (Component in cr)
      printf("%s\t\t", cr[Component])
    else 
      printf("%s\t\t", default_cr);

   if (Component in arg)
      printf("%s\t\t\n", arg[Component])
    else {
	print "lbl2args_txt2out", Component_type | "/bin/sh"; close("/bin/sh")
    }

    OldComponent=Component;
    delete arg[Component]; # Zap the element
    delete cr[Component]; # Zap the element
  }
  END{
    print "\n## Port aliases" >> "mtt_junk_alias.txt";
    for (k=1;k<=j;k++){
      if (port_alias[k] ~ "\\["){ # Only do ports
        port_name = substr(port_alias[k],2,length(port_alias[k])-2);
        if (length(sensitivity)==0)
          print "#ALIAS\t" port_name "\t" port_name >> "mtt_junk_alias.txt";
        else
          print "#ALIAS\t" port_name "\t" port_name "_1," port_name "_2" >> "mtt_junk_alias.txt";
      }
    }

#    print "\n% Argument aliases" >> "mtt_junk_alias.txt";
#    for (k=1;k<=i;k++){
#      print "%ALIAS\t\$" k "\t" alias[k] >> "mtt_junk_alias.txt";
#    }
 }' sensitivity=$sensitivity
}

create_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF
abg2sympar_m2txt ${system} ${system} use_label_file |\
gawk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
}

## Main 

create_lbl_body $1> $1_lbl.txt
create_arg_aliases > mtt_args.txt # using $1_lbl.txt
mv $1_lbl.txt mtt_junk_lbl.txt

write_header            > ${outfile}
cat mtt_junk_alias.txt >> ${outfile}
cat mtt_args.txt       >> ${outfile}
write_blurb            >> ${outfile}
cat mtt_junk_lbl.txt   >> ${outfile}

## Put a blank line at end
cat >> ${outfile} <<EOF

EOF
## Clean up
rm -f mtt_junk*





Added mtt/bin/trans/cmp2sub_m2sh version [abbcf4831f].




























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2sub_m2sh

# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2000/10/03 11:34:29  peterg
## Put in correct $MTT_LIB
##
## Revision 1.7  2000/01/18 14:22:58  peterg
## Now exits if file already exists
##
## Revision 1.6  1999/08/25 21:20:07  peterg
## Don't list components starting with 0 ot 1
##
## Revision 1.5  1996/11/09 21:09:43  peterg
## Added lib path.
##
# Revision 1.4  1996/11/03  21:19:55  peterg
# Generates generic commands in form $1name$2.
#
## Revision 1.3  1996/11/01 12:48:21  peterg
## Run mtt in quiet mode.
##
## Revision 1.2  1996/10/20 19:22:41  peterg
## Cleans up after itself.
##
## Revision 1.1  1996/10/20 19:19:50  peterg
## Initial revision
##
###############################################################

if [ -f "$1_sub.sh" ]; then
    echo Using "$1_sub.sh"
    exit
else
    #Inform user
    echo Creating $1_sub.sh    
fi


echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _cmp file
gawk '/comp_type = / {print substr($3,2,length($3)-3)}' $1_cmp.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Added mtt/bin/trans/cmp2sub_m2txt version [1729bdb196].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makecr

# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1996/09/12 19:28:55  peter
## Added rcs header.
##
## Revision 1.4  1996/09/12 12:06:38  peter
## Removed reducndant lines.
##
## Revision 1.3  1996/09/12 12:05:01  peter
## Removed default crs.
##
## Revision 1.2  1996/09/10 16:18:37  peter
## Uses default constitutive relationship mtt/cr/r
##
## Revision 1.1  1996/08/24 14:53:06  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_cr.r

echo % Default CR file			>  $1_cr.r
echo % File $1_cr.r			>> $1_cr.r
echo % Generated by MTT on `date`.	>> $1_cr.r
echo					>> $1_cr.r
cat $MTTPATH/trans/m/rcs_header.txt	>> $1_cr.r
echo 'END;'				>> $1_cr.r








Added mtt/bin/trans/cmp2sub_txt2sh version [b21f209e4e].


























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2sub_txt2sh

# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/12/06 12:26:34  gawthrop
## Strips comments from cmp.txt file
##
## Revision 1.1  2002/12/03 23:26:08  geraint
## Convert _cmp.txt to _sub.sh.
## Slightly edited copy of (obsolete) abg2sub_m2sh.
##
## Revision 1.4  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  2000/10/03 11:34:53  peterg
## Correct $MTT_LIB
##
## Revision 1.2  2000/03/17 09:53:10  peterg
## Removed irritating echo Using "$1_sub.sh"
##
## Revision 1.1  2000/03/15 21:23:20  peterg
## Initial revision
##
###############################################################


if [ -f "$1_sub.sh" ]; then
    #echo Using "$1_sub.sh"
    exit
else
    #Inform user
    echo Creating $1_sub.sh    
fi


echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _abg file
strip_comments < $1_cmp.txt | gawk -F\: '{print $1}' |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
# echo ls $MTT_LIB/comp/simple
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Added mtt/bin/trans/contents.tex version [23a4ae4ea9].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Contents etc for MTT documents


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 11:52:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  \tableofcontents
  \newpage
  \listoffigures
  \newpage

Added mtt/bin/trans/convert_simpar.sh version [884ce541cf].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Gets rid of redundant METHOD lines.
echo Converting $1
## backup
cp $1 $1_old
sed 's/METHOD/## METHOD/'< $1_old > $1



Added mtt/bin/trans/cr_txt2r version [fd5454f1e3].



















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################


# Bourne shell script: cr_txt2r

# Label file to constitutive relationship conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2002/05/09 15:52:09  gawthrop
## Now uses current cr file is its newer than abg.m
##
## Revision 1.13  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.12  2002/04/08 17:04:21  geraint
## Removed spurious "\n" from output.
##
## Revision 1.11  2000/08/01 07:34:33  peterg
## Replaced printf by echo
##
## Revision 1.10  2000/02/25 09:10:12  peterg
## Changed -e to -f in if [ -f "$crf" ]; then
##  -- cuased probs on SUN
##
## Revision 1.9  2000/02/16 15:58:17  peterg
## Set level='' not $2
##
## Revision 1.8  1998/11/20 09:48:31  peterg
## Remove the _lower stuff -- see idf this works now.
##
## Revision 1.7  1998/04/14 17:46:28  peterg
## To avoid clashes when creating for more thsan one top level file, adds
## _lower attribute to lower lecel constitutive relationship files.
## .constitutive relationship files only in top level _constitutive
## relationship files.
##
## Revision 1.6  1998/04/14 13:54:15  peterg
## Uses the _sub.sh rep to recursively generate and include sub systems.
##
## Revision 1.5  1998/03/09 13:36:00  peterg
## Cosmetic change
##
## Revision 1.4  1998/03/06 15:54:41  peterg
## Put message bcak in in simpler form
##
## Revision 1.3  1998/03/06 15:51:06  peterg
## Zapped the irritating error message
##
## Revision 1.2  1998/03/04 15:32:53  peterg
## Major revision.
## Now just includes cr files using in"";
## Two sorts of CR:
## 	generic (.cr)
## 	tied to a system (_cr.r)
##
## Revision 1.1  1998/03/04 15:31:14  peterg
## Initial revision
##
# Revision 1.3  1997/04/09  12:59:43  peterg
# Looks for .cr file in current directory - copies from library if they
# don't already exist.
#
# Revision 1.2  1997/04/09  09:25:55  peterg
# Now copies .cr files from linrary to here (if they don't exist
# already).
#
# Revision 1.1  1997/04/09  09:08:12  peterg
# Initial revision
#
###############################################################

# The level of the recursion null at top level; _lower at lower levels.

level='' ## Used to be $2 - now set to null.

abgfile=$1_abg.m
crfile=$1_cr.r
CRFILE=$1_cr.r

if [ -f "$crfile" ]; then
    echo "Using    $crfile"
else
    # Inform user
    echo "Creating $crfile"

    echo "% Constitutive relation file for $1 ($crfile)" > $crfile
    echo "% Generated by MTT at `date`" >> $crfile

    echo  >> $crfile

    # Recursively create subsystem CR files -- at lower level
    sh $1_sub.sh 'cr_txt2r ' ' _lower' 
    
    # Include subsystem CR files
    sh $1_sub.sh 'echo ' "_cr.r" |\
    gawk '{
      print "in \"" $1 "\";"
    }'  >> $crfile

##  if [ -z "$level" ]; then

    # Copy .cr files
    gawk '{
	 if (NF>0) {
         print "mtt -q -u crcopy " $1; 
         }
    }' $1_cr.txt  | sh

    # Include the .cr files
#    gawk '{
#	 if (NF>0) {
#         print "in \"" $1 ".cr\";"
#         }
#    }' $1_cr.txt  >> $crfile

    ## list of the crs
    crs=`cat $1_cr.txt`
    for cr in $crs; do
        crf=$cr'_cr.r'
	if [ -f "$crf" ]; then
##	   printf "\045 (%s exists)\n" $crf >> $crfile
	   echo "% ($crf exists)"  >> $crfile
	else
##	   printf 'in "%s.cr";\n' $cr >> $crfile
	   echo 'in "'$cr.cr'";' >> $crfile
	fi
    done
##  fi
echo 'END;' >> $crfile

fi
# Now invoke the standard error handling.
#mtt_error mtt_error.txt


Added mtt/bin/trans/cse2csm_r version [5225d88b5f].


































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2csm_r
# Constrained-state equation to linear constrained-state matrices conversion
# P.J.Gawthrop  6th September 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/04/07 19:11:59  peterg
## reduce --> $SYMBOLIC
##
## Revision 1.6  2000/04/06 11:27:56  peterg
## Removed the in _cr.r
##
## Revision 1.5  1999/12/08 02:04:46  peterg
## Removed bug - uj := MTTU(j,1); not commented out
##
## Revision 1.4  1999/11/22 23:49:50  peterg
## Writes out the new MTTNx and MTTNy
##
## Revision 1.3  1999/11/22 23:38:51  peterg
## Now does scse 2 scsm as well.
## Uses mkid.
##
## Revision 1.2  1998/07/13 09:56:31  peterg
## Back under RCS for major revision
##
# Revision 1.1  1996/08/25  10:13:37  peter
# Initial revision
#
###############################################################

# Inform user
echo Creating $1_$2.r

case $2 in
    csm)
	rep=cse;
	;;
    scsm)
	rep=scse;
	;;
    *)
	echo Representation must be csm or scsm;
        exit
esac
# Remove the old log file
rm -f cse2csm_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >cse2csm_r.log << EOF

in "$1_def.r";
in "$1_$rep.r";
%%in "$1_cr.r";
%%in "$1_sympar.r";

OFF Echo;
OFF Nat;

% Get rid of the old mttx and u - now use mkid instead
clear MTTx, MTTu;

IF (MTTNx>0) THEN
BEGIN
% Find MTTA : the A matrix
matrix MTTA(MTTNx,MTTNx);

  FOR j := 1:MTTNx DO
    BEGIN
    %xj := MTTX(j,1);
    xj := mkid(MTTx,j);
    FOR i := 1:MTTNx DO
      MTTA(i,j) := df(MTTEdx(i,1), xj, 1);
    END;
END;

IF (MTTNx>0) AND (MTTNu>0) THEN
BEGIN
% Find MTTB : the B matrix
matrix MTTB(MTTNx,MTTNu);

  FOR j := 1:MTTNu DO
    BEGIN
    %uj := MTTU(j,1);
    uj := mkid(MTTu,j);
    FOR i := 1:MTTNx DO
      MTTB(i,j) := df(MTTEdx(i,1), uj, 1);
    END;
END;

IF (MTTNx>0) AND (MTTNy>0) THEN
BEGIN
% Find MTTC : the C matrix
matrix MTTC(MTTNy,MTTNx);

  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNx DO
    BEGIN
      %xj := MTTX(j,1);
      xj := mkid(MTTx,j);
      MTTC(i,j) := df(MTTY(i,1), xj, 1);
    END;
END;

IF (MTTNy>0) AND (MTTNu>0) THEN
BEGIN

% Find MTTD : the D matrix
matrix MTTD(MTTNy,MTTNu);

  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO
    BEGIN
      %uj := MTTU(j,1);
      uj := mkid(MTTu,j);
      MTTD(i,j) := df(MTTY(i,1), uj, 1);
    END;
END;

%Substitute the ss values
in "$1_sspar.r";

%Create the output file
OUT "$1_$2.r";

% Constants

write "% New constants";
write "MTTNx := ", MTTNx, ";";
write "MTTNy := ", MTTNy, ";";


%Write out the matrices.
IF MTTNx>0 THEN
BEGIN
  write "matrix MTTE(", MTTNx, ",", MTTNx, ");";
  FOR i := 1:MTTNx DO
   FOR j := 1:MTTNx DO IF MTTE(i,j) NEQ 0 THEN
      write "MTTE(", i, ",", j, ") := ", MTTE(i,j);

  write "matrix MTTA(", MTTNx, ",", MTTNx, ");";
  FOR i := 1:MTTNx DO
   FOR j := 1:MTTNx DO IF MTTA(i,j) NEQ 0 THEN
      write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
END;

IF MTTNx>0 THEN
IF MTTNu>0 THEN
BEGIN
  write "matrix MTTB(", MTTNx, ",", MTTNu, ");";
  FOR i := 1:MTTNx DO
   FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
      write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
END;

%Write it out
IF MTTNy>0 THEN
IF MTTNx>0 THEN
BEGIN
  write "matrix MTTC(", MTTNy, ",", MTTNx, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNx DO IF MTTC(i,j) NEQ 0 THEN
      write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
END;

IF MTTNy>0 THEN IF MTTNu>0 THEN 
BEGIN
  write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
      write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
END;

write "END;";

SHUT "$1_$2.r";

EOF

# Now invoke the standard error handling.
mtt_error_r cse2csm_r.log



Added mtt/bin/trans/cse2ode_r version [280cac859b].




























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2ode_r
# Reduce constrained-state equations to ode.
# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Dec 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3.4.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.3.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.3  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.2  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.1.4.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.1  2000/12/28 12:21:31  peterg
## Put under RCS
##
## Revision 1.2  1997/01/06 21:17:10  peterg
## Removed:  OFF Exp; OFF GCD;
##
## Revision 1.1  1996/08/25 10:05:45  peter
## Initial revision
##
###############################################################

optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-optimise_global )
	    optimise='-optimise_global'
	    optimise_msg=' with global optimisation' ;;
	-optimise_local )
	    optimise='-optimise_local'
	    optimise_msg=' with local optimisation' ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Create the reduce output code
def2write_r $1 ode
def2write_r $1 odeo

#Inform user
echo Creating $1_ode.r $optimise_msg
echo Creating $1_odeo.r $optimise_msg

# Remove the old log file
rm -f cse2ode_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >cse2ode_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

%Read the definitions file
in "$1_def.r";

%Read the substitution file
in "$1_subs.r";

%Read the constrained-state equations file
in "$1_cse.r";

%Read the algebraic equations file
in "$1_ae.r";

IF MTTNx>0 THEN
 IF MTTNz>0 THEN
   MTTdXX := MTTE^(-1)*MTTEdX
 ELSE
   MTTdXX := MTTEdX;

%Remove all dX terms from y - a rather nasty method, sorry!
  MTTdX1 := 0;
  MTTdX2 := 0;
  MTTdX3 := 0;
  MTTdX4 := 0;
  MTTdX5 := 0;
  MTTdX6 := 0;
  MTTdX7 := 0;
  MTTdX8 := 0;
  MTTdX9 := 0;
  MTTdX10 := 0;
  MTTdX11 := 0;
  MTTdX12 := 0;
  MTTdX13 := 0;
  MTTdX14 := 0;
  MTTdX15 := 0;
  MTTdX16 := 0;
  MTTdX17 := 0;
  MTTdX18 := 0;
  MTTdX19 := 0;
  MTTdX20 := 0;

%Substitute  dX into y;
IF MTTNz>0 THEN
  IF MTTNx>0 THEN
    MTTY := MTTY + MTTEyx*MTTdX;

OFF Echo;
OFF Nat;

MTTdX := MTTdXX;

%Write out the  ordinary differential equations.
OUT "$1_ode.r";
write "%File: $1_ode.r";
in ("$1_ode_write.r");
write "in ""$1_odeo.r"";";
write "END;";
SHUT "$1_ode.r";

%Write out the  output equations
OUT "$1_odeo.r";
write "%File: $1_odeo.r";
in ("$1_odeo_write.r");
write "END;";
SHUT "$1_odeo.r";
quit;
EOF

if [ ${optimise:-""} = "-optimise_global" ]; then
    mtt_optimise global $1 ode
    mtt_optimise global $1 odeo
elif [ ${optimise:-""} = "-optimise_local" ]; then
    mtt_optimise local $1 ode
    mtt_optimise local $1 odeo
fi

# Now invoke the standard error handling.
mtt_error_r cse2ode_r.log

Added mtt/bin/trans/cse2rfe_r version [5e4feb17e7].






















































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2rfe_r
# Reduce  constrained-state equations to robot matrices
# Experimental version!
# State vector should have momenta in odd rows,angles in even;
# the last row should have the gravity velocity term.
# There should be one output (only) for each joint velocity.
# P.J.Gawthrop, Nov 92, Dec 93, May 1994
# Copyright (c) P.J.Gawthrop, 1992, May 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1996/12/05 12:10:00  peterg
## Version history added.
##
###############################################################

# Inform user
echo Creating $1_rfe.r

# Remove the old log file
rm -f cse2rfe_r.log

# Use reduce to accomplish the transformation
reduce >cse2rfe_r.log << EOF

IN "$1_def.r";
IN "$1_sympar.r";
IN "$1_csm.r";
IN "$1_cse.r";

MTTN2 := MTTNy;


%Find E11 and E12 matrices
MATRIX MTTE11(MTTN2,MTTN2), MTTE12(MTTN2,MTTN2);
FOR i := 1:MTTN2 DO
  FOR j := 1:MTTN2 DO
  BEGIN
    MTTE11(i,j) := MTTE(2*i-1,2*j-1);
    MTTE12(i,j) := MTTE(2*i-1,2*j);
  END;

%Find inertia matrix
MATRIX MTTImi(MTTN2,MTTN2);
FOR i := 1:MTTN2 DO
  BEGIN
    MTTImi(i,i) := MTTC(i,2*i-1);
   END;

MTTIm := MTTImi^-1;

%Find gravity matrix if there is an extra gravity state
MATRIX MTTG(MTTN2,1);
MTTNy2 := 2*MTTNy;
IF ( (MTTNx-1)/MTTNy2 = 1) THEN
FOR i := 1:MTTN2 DO
  BEGIN
    MTTG(i,1) := MTTE(2*i-1,MTTNx);
   END;



%Find V matrix from RHS of equation
MTTu1 := 0;
MTTu2 := 0;
MTTu3 := 0;
MTTu4 := 0;
MTTu5 := 0;
MTTu6 := 0;

MTTx2 := theta_1;
MTTx4 := theta_2;
MTTx6 := theta_3;
MTTx8 := theta_4;
MTTx10 := theta_5;
MTTx12 := theta_6;

MTTx1 := dot_theta_1*MTTIm(1,1);
MTTx3 := dot_theta_2*MTTIm(2,2);
MTTx5 := dot_theta_3*MTTIm(2,3);

MATRIX MTTdt(6,1);
MTTdt(1,1) := dot_theta_1;
MTTdt(2,1) := dot_theta_2;
MTTdt(3,1) := dot_theta_3;
MTTdt(4,1) := dot_theta_4;
MTTdt(5,1) := dot_theta_5;
MTTdt(6,1) := dot_theta_6;

MATRIX dtheta(MTTN2,1);
FOR i := 1:MTTN2 DO
  BEGIN
    dtheta(i,1) := MTTdt(i,1);
   END;

MATRIX MTTVrhs(MTTN2,1);
MATRIX MTTV(MTTN2,1);
FOR i := 1:MTTN2 DO
  BEGIN
    MTTVrhs(i,1) := MTTEdX(2*i-1,1);
   END;

%Find V matrix 
MTTV := MTTE12*dtheta - MTTVrhs;

%Find C matrix
MATRIX MTTC(MTTN2,MTTN2);
k := 0;
FOR i := 1:MTTN2 DO
  FOR j := 1:MTTN2 DO
  BEGIN
  coeffs := coeff(MTTV(i,1),MTTdt(j,1));
  IF length(coeffs)>2 THEN co := part(coeffs,3) ELSE co := 0;
  MTTC(i,j) := co;
  END;

%Find B matrix
MTTN3 := MTTN2*(MTTN2-1)/2;

IF MTTN3>0 THEN
BEGIN
MATRIX MTTB(MTTN2,MTTN3);
FOR i := 1:MTTN2 DO
BEGIN
  counter := 0;
  FOR j := 1:MTTN2-1 DO
  BEGIN
  coeffs := coeff(MTTV(i,1),MTTdt(j,1));
  IF length(coeffs)>1 THEN co := part(coeffs,2) ELSE co := 0;
    FOR k := j+1:MTTN2 DO
    BEGIN 
    counter := counter+1;
    coeffs2 := coeff(co,MTTdt(k,1));
    IF length(coeffs2)>1 THEN co2 := part(coeffs2,2) ELSE co2 := 0;
     MTTB(i,counter) := co2;
    END;
  END;
END;
END;

OFF Echo;
OFF Nat;
ON NERO;

OUT "$1_rfe.r";

%% M
write "MATRIX MTTM(", MTTN2, ",", MTTN2, ")";
MTTM := MTTE11*MTTIm;

%% V
write "MATRIX MTTRV(", MTTN2, ",1)";
MTTRV := MTTV;

%% 

write "MATRIX MTTRC(", MTTN2, ",", MTTN2, ")";
MTTRC := MTTC;

IF MTTN3>0 THEN
  BEGIN
  write "MATRIX MTTRB(", MTTN2, ",", MTTN3, ")";
  MTTRB := MTTRB;
END;

write "MATRIX MTTRG(", MTTN2, ", 1)";
MTTRG := MTTG;

write ";END;"$
SHUT "$1_rfe.r";
quit;
EOF

Added mtt/bin/trans/cse2scse_r version [31a5612a2e].



































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2scse_r
# Reduce constrained-state equations to sensitivity version
# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Dec 1994
# Copyright (c) P.J.Gawthrop, 1999

# 	$Id$	

# Arguments
system=$1; 
system_def=$1_def.r
system_cse=$1_cse.r
system_scse=$1_scse.r

# Parameters
n=`echo $2 | sed 's/,/ /g' |wc -w` ## Number of parameters

## Parameter information for reduce.
parameters=`echo $2 | sed 's/,/ /g' |\
 gawk '{
   for (i=1; i<=NF; i++) {
      printf("mttpar(%i,1) := %s;\n", i, $i);
      printf("mttcoef(%i,1) := %ss;\n", i, $i);
   }
  }'`

## Update sympar list.
echo Recreating $1_sympar.txt
# Zap any sensitivity coeficients
mv $1_sympar.txt mtt_junk
grep -v MTT_Sensitivity_Coefficients mtt_junk > $1_sympar.txt

# Create the new sens coeffs at end of list.
echo $2 | sed 's/,/ /g' |\
gawk '{
   for (i=1; i<=NF; i++) {
      printf("%ss\tMTT_Sensitivity_Coefficients\n",$i);
   }
  }' >> $1_sympar.txt

touch $1_sympar.txt

matrix="matrix mttpar("$n",1); matrix mttcoef("$n",1);"

# Number of states
Nx=`grep "MTTNx " <$system_def | gawk '{print $3}' | sed 's/;//'`

#Inform user
echo Creating $system_scse "(for parameters $2, $Nx states)"

# Remove the old log file
rm -f cse2scse_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC  << EOF >cse2scse_r.log

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

%Read the definitions file
in "$system_def";

%Read the constrained-state equations file
in "$system_cse";

% Declare the parameter matrix and fill it
$matrix
$parameters
mtt_n_par := $n;

MTTNx2 := 2*MTTNx;
MTTNy2 := 2*MTTNy;

% Compute the sensitivity E matrix
matrix MTTssE(MTTNx,MTTNx);
clear MTTx; % Dont use - mkid is better

FOR ii := 1:MTTNx DO
  FOR jj := 1:MTTNx DO
  IF MTTE(ii,jj) NEQ 0 THEN IF MTTE(ii,jj) NEQ 1 THEN
  BEGIN
    % First with respect to theta...
    FOR kk := 1:mtt_n_par DO
    BEGIN
      mttpar_k := mttpar(kk,1);
      mttcoef_k := mttcoef(kk,1);
      MTTssE(ii,jj) := MTTssE(ii,jj) + df(MTTE(ii,jj), mttpar_k)*mttcoef_k;
    END;
    % then with respect to x
    FOR i := 1:MTTNx DO
    BEGIN
      xi := mkid(MTTx,i);
      sxi := mkid(MTTsx,i);
      MTTssE(ii,jj) := MTTssE(ii,jj) + df(MTTE(ii,jj), xi)*sxi;
    END;
  END;

% Compute the sensitivity of the RHS of the cse
matrix MTTssEdx(MTTNx,1);
FOR ii := 1:MTTNx DO
BEGIN 
  % First with respect to theta
    FOR kk := 1:mtt_n_par DO
    BEGIN
      mttpar_k := mttpar(kk,1);
      mttcoef_k := mttcoef(kk,1);
      MTTssEdx(ii,1) := MTTssEdx(ii,1) + df(MTTEdx(ii,1), mttpar_k)*mttcoef_k;
    END;
% Then with respect to x
  FOR i := 1:MTTNx DO
  BEGIN
    xi := mkid(MTTx,i);
    sxi := mkid(MTTsx,i);
    MTTssEdx(ii,1) := MTTssEdx(ii,1) + df(MTTEdx(ii,1), xi)*sxi;
  END; 
END; 

% Sensitivity output function
matrix MTTssY(MTTNy,1);
FOR ii := 1:MTTNy DO
BEGIN 
  % First with respect to theta
    FOR kk := 1:mtt_n_par DO
    BEGIN
      mttpar_k := mttpar(kk,1);
      mttcoef_k := mttcoef(kk,1);
      MTTssY(ii,1) := MTTssY(ii,1) + df(MTTY(ii,1), mttpar_k)*mttcoef_k;
    END;
% Then with respect to x
  FOR i := 1:MTTNx DO
  BEGIN
    xi := mkid(MTTx,i);
    sxi := mkid(MTTsx,i);
    MTTssY(ii,1) := MTTssY(ii,1) + df(MTTY(ii,1), xi)*sxi;
  END; 
END; 


% Now reorganise everything into composite system
%  - odd rows are the system 
%  - even rows are the sensitivity system
% NB at this stage, the states are numbered incorrectly - sorted out below.

%E matrix 
matrix MTTsE(MTTNx2,MTTNx2);
FOR i := 1:MTTNx DO
  FOR j := 1:MTTNx DO
  BEGIN
    MTTsE(2*i-1,2*j-1) := MTTE(i,j);  % System
    MTTsE(2*i,2*j)     := MTTE(i,j);  % Sensitivity system
    MTTsE(2*i,2*j-1)   := MTTssE(i,j);  % Sensitivity system
  END; 

%dX matrix
matrix MTTsEdX(MTTNx2,1);

FOR i := 1:MTTNx DO
BEGIN
  MTTsEdX(2*i-1,1) := MTTEdx(i,1);
  MTTsEdX(2*i,1)   := MTTssEdx(i,1);
END; 

%Y matrix
matrix MTTsY(MTTNy2,1);%dX matrix
matrix MTTsEdX(MTTNx2,1);

FOR i := 1:MTTNx DO
BEGIN
  MTTsEdX(2*i-1,1) := MTTEdx(i,1);
  MTTsEdX(2*i,1)   := MTTssEdx(i,1);
END; 


FOR i := 1:MTTNy DO
BEGIN
  MTTsY(2*i-1,1) := MTTY(i,1);
  MTTsY(2*i,1)   := MTTssY(i,1);
END; 




OFF nat;

OUT "$system_scse";

write "%File: $system_scse";

% Constants

write "% New constants";
write "MTTNx := ", MTTNx2, ";";
write "MTTNy := ", MTTNy2, ";";

% E matrix
MTT_Matrix := MTTsE$ 
MTT_Matrix_name := "MTTE"$
MTT_Matrix_n := MTTNx2$
MTT_Matrix_m := MTTNx2$
Reduce_Matrix()$

% State derivative
MTT_Matrix := MTTsEdX$ 
MTT_Matrix_name := "MTTEdX"$
MTT_Matrix_n := MTTNx2$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTsY$ 
MTT_Matrix_name := "MTTY"$
MTT_Matrix_n := MTTNy2$
MTT_Matrix_m := 1$
Reduce_Matrix()$

write "END;";

SHUT "$system_scse";
quit;
EOF

# Now invoke the standard error handling.
mtt_error_r cse2scse_r.log


## Now reorganise the  states
mv -f $system_scse mtt_junk


##echo "Nx = $Nx"
gawk '{
  ## Make sure all MTTn variables are followed by a space
  gsub(/mttx[0-9]*/, "& ");

  for (i=Nx;i>0;i--) {

    state = sprintf("mttx%i ",i);
    newstate = sprintf("mttx%i ",2*i-1);
    sstate = sprintf("mttsx%i",i);
    newsstate = sprintf("mttx%i",2*i);

    gsub(state,newstate);
    gsub(sstate,newsstate);

  }
  print $0
}' Nx=$Nx <mtt_junk > $system_scse






Added mtt/bin/trans/cse2smx_lang version [a64f19c513].









































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2smx_lang
# Constrained-state equation to state matrices with x vector
# Used for implicit integration
# Copyright (C) 2000 by Peter J. Gawthrop
## Modified from eailier version


# Args
## Now default to matrix form
matrix='yes'
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
    -noglobals)
	noglobals='-noglobals';
	;;
    -parameters)
	parameters='-parameters';
	;;
    -matrix)
	matrix='yes';
	;;
    -optimise_global | -optimise_local )
	optimise='LOAD SCOPE; ON GENTRANOPT;';
        iname='INAME mtt_o;';
	;;
    -fixcc )
        fix_mtt_pow='FOR ALL x,y LET x^y = mtt_pow(x,y);'
        operator='OPERATOR mtt_pow;'
        blurb2='fixing c and cc code';
        unfix_mtt_pow='FOR ALL x,y CLEAR x^y;'
        unfix_pow='FOR ALL x,y LET pow(x,y) = x^y;';
		;;
    *)
	echo $1 is an unknown option
        exit;;
  esac
  shift
done

## Representation
if [ -z $1 ]; then
    echo 'usage [options] cse2smx_lang system [smx|smxa|smxax]'
    exit
fi


# Language
if [ -n "$3" ]; then
    lang=$3
else
    lang="m"
fi

## Representation
if [ -z $2 ]; then
    rep=smx;
else
    rep=$2
fi

case $rep in
    smx)
	nrep=0;
        out='[mtta,mttax]';
        nmatrix=1;
	;;
    smxa)
        nrep=1;
	if [ -n "$matrix" ]; then
          blurb="in matrix form";
          nmatrix=1;
	else
          blurb="in vector form";
          nmatrix=0;
	fi
        out='mtta';
	;;
    smxax)
	nrep=2
        out='mttax';
        nmatrix=0;
	;;
    *) echo Representation $2 not recognised;
       exit;;
esac


# Inform user
if [ -n "$optimise" ]; then
    blurbopt=' using code optimisation'
fi

echo Creating $1_$rep.$lang $blurb $blurbopt $blurb2
#echo Creating $1_smxx.$lang
#echo Creating $1_smxtx.$lang

# Remove the old log file
rm -f cse2smx_r.log
rm -f $1_smx.$lang
rm -f $1_smxx.$lang
rm -f $1_smxtx.$lang
rm -f $1_$rep.body

# Use reduce to accomplish the transformation
$SYMBOLIC << EOF  >cse2smx_lang.log

${operator} %% Define mtt_pow if needed
lang := $lang;

in "$1_subs.r";
in "$1_def.r";
in "$1_cse.r";
in "$1_cr.r";


clear mttx; % Dont need this now - use mkid instead

OFF Echo;

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'Pascal;
ON GENTRANSEG; % Segmentation

OFF GENDECS;  % No declarations
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_tmp;
%% '
% Optimise
$optimise


ON GETDECS;    % Create decrarations automatically
DEFTYPE!* := 'REAL; % and default to real

%%% The following is a bug fix  from ZIB to fix 
%%% segmentation violation problem
symbolic procedure maxtype type;
% ------------------------------------------------------------------- ;
% A type may be a pair (l u) wher l is the minimum type for a variable;
% and  u is the maximum type. This procedure returns the maximum type.;
% ------------------------------------------------------------------- ;
   if atom type
   then type
   else if pairp cdr type then cadr type else car type;

% This fix handles the case that the type is a list with ONE entry.
% Should never happen ?? W.N.
%%%%%% End of bug fix

%Set up output according to the language.
 OFF NAT;
 GENTRANOUT "$1_$rep.body";

% Set up output according to the language.
    IF (lang = r) THEN 
    BEGIN
      write "matrix mtta(", mttnx, ",", mttnx, ");";    
      write "matrix mttb(", mttnx, ",", mttnu, ");";    
      write "matrix mttc(", mttny, ",", mttnx, ");";    
      write "matrix mttd(", mttny, ",", mttnu, ");";    
    END;

 ${unfix_pow} %% set pow(x,y) to x^y

% find MTTA : the A matrix
  FOR i := 1:MTTNx DO
  BEGIN
    mttAAx_i := 0;
    FOR j := 1:MTTNx DO
    BEGIN
      ${unfix_mtt_pow} %% Revert to x^y form
      ij := i + MTTNx*(j-1);
      xj := mkid(mttx,j);
      a_ij := df(MTTEdx(i,1), xj, 1);
      aa_ij := MTTE(i,j) - mttt*a_ij;
      ${fix_mtt_pow} %% set x^y to mtt_pow(x,y)
      IF (aa_ij NEQ 0) THEN
        IF ($nmatrix EQ 1) THEN
        BEGIN
          %% Write a  with full indexing
          $iname
          GENTRAN mtta(i,j) ::=: aa_ij;
        END;
        IF (($nmatrix EQ 0) AND ($nrep EQ 1)) THEN
        BEGIN
          %% Write a  with vector indexing
          $iname
          GENTRAN mtta(ij) ::=: aa_ij;
        END;
        mttAAx_i := mttAAx_i + aa_ij*xj;
      END;
      IF (mttAAx_i NEQ 0) THEN
        IF (($nrep EQ 0) OR ($nrep EQ 2)) THEN
        BEGIN
          $iname
          GENTRAN mttax(i) ::=: mttAAx_i;
        END;


  END;

  
%Shut the  output according to the language.
 GENTRANSHUT "$1_$rep.body";
EOF

fix_broken_numbers ( ) {
    sed -e "/[0-9.]$/ N" -e "s/\([0-9.]\)[\n\t\ ]*\([0-9]\)/\1\2/g"
}

refix_pow() {
    sed 's/mtt_pow/pow/g'
}

if [ "$lang" = "m" ]; then
#  lang_header $noglobals $parameters $1 $rep m 'mttx,mttu,mttt,mttpar' $out > $1_$rep.m
  mtt_header $1 $rep m > $1_$rep.m
  cat $1_$rep.body | fix_broken_numbers | refix_pow | mtt_p2m >> $1_$rep.m
  echo "## END Code" >> $1_$rep.m
  echo "endfunction" >> $1_$rep.m
fi
 
# Now invoke the standard error handling.
mtt_error_r cse2smx_lang.log

Added mtt/bin/trans/cse_r2m version [4aef2899f0].














































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse_r2m
# Reduce constrained-state to simulab  constrained-state equations  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994.
# Copyright (c) P.J.Gawthrop 1991, 1994.

# Output must be filtered by matlab_tidy.

#Inform user
echo Creating $1_cse.m

# Remove the old log file
rm -f cse_r2m.log

# Use reduce to accomplish the transformation
reduce >cse_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  constrained-state equations   file
in "$1_cse.r";

%Read the reduce  substitution file
in "$1_subs.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
%%in "$1_sympar.r";


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
OFF Nat;

ON NERO;        % Suppress zero elements

OUT "$1_cse.m";

%Headings - Simulab style
%(Note. The ;; are deleted by for2mat)

write "function [sys,x0] = $1_cse(t,x,u,flag,xInitial);";

IF MTTNvar>0 THEN
BEGIN
  write "% Read in the parameters";
  write "global ...;;";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), " ..."
                  ELSE write MTTVar(i,1), ";"
  END;
END;


write "%Constrained-state eqns in Simulab form for system $1;;";
write "%File $1_cse.m;;";
write "%Generated by MTT;;";


write "if nargin<4; flag=0; end;";	
write "if (abs(flag) == 1) | (abs(flag) == 3)";	
write "% Set up the State variables";
FOR i := 1:MTTNx DO
BEGIN
  write "MTTx", i, " = x(", i, ");";
END;

write "% Set up the Input variables";
IF MTTNu>0 THEN
FOR i := 1:MTTNu DO
BEGIN
  write "MTTu", i, " = u(", i, ");";
END;
write "end;";

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "if abs(flag) == 1	%State derivative";

write "MTTE = zeros(", MTTNx, ",", MTTNx, ");";
MTTE := MTTE;
MTTEdx := MTTEdx;
write "sys = MTTE\MTTEdx;";

write "elseif abs(flag) == 3	%Outputs";
MTTy := MTTy;
write "sys = MTTy;";

write "elseif abs(flag) == 0	%Structure";
write "	sys = [", MTTNx, ",0,", MTTNy, ",", MTTNu, ",0,0]";
write "	if nargin<5; xInitial = zeros(", MTTNx, ",1); end;";
write "	x0  = xInitial;";
write "end;";
SHUT "$1_cse.m";

Added mtt/bin/trans/cse_r2tex version [a671e2cc38].





































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse_r2tex
# Reduce constrained-state to LaTex constrained-state equations.
# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Jan 1995
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2000/08/24 11:48:55  peterg
## Include _subs file
##
## Revision 1.5  1999/11/22 23:44:47  peterg
## Now does scse as well
##
## Revision 1.4  1999/11/22 23:04:08  peterg
## *** empty log message ***
##
# Revision 1.3  1996/11/12  09:53:59  peterg
# Reads in the params.r file now.
#
# Revision 1.2  1996/11/12  09:11:20  peterg
# Removed all the hoorrible name changes
#
# Revision 1.1  1996/11/05  09:19:28  peterg
# Initial revision
#
###############################################################

#Inform user
echo Creating $1_$2.tex

# Remove the old log file
rm -f cse_r2tex.log

# Use reduce to accomplish the transformation
reduce >cse_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the parameter file
%%in "$1_params.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the constrained-state equations file
in "$1_$2.r";

OFF Echo;
OFF Nat;

OUT "$1_$2.tex";

%Write out the  constrained-state equations.

write "%File: $1_$2.tex";

write "%constrained-state equations";
	IF MTTNx>0 THEN
	FOR Row := 1:MTTNx DO
	BEGIN
	        write"\begin{equation}";
		write "\dot MTTEX", Row, " = ";
		write "{";
		write MTTEdX(Row,1);
		write "}";
		write"\end{equation}";
	END;



	IF MTTNy>0 THEN
	FOR Row := 1:MTTNy DO
	BEGIN
		write"\begin{equation}";
		write "MTTy", Row, " = ";
		write "{";
		write MTTy(Row,1);
		write "}";
		write"\end{equation}";
	END;


IF MTTNx NEQ 0 THEN
BEGIN
write "%  - E matrix";
write "\begin{equation}";
write "MTTE = \begin{pmatrix}";
	FOR Row := 1:MTTNx DO
	BEGIN
		FOR Col := 1:MTTNx DO
		BEGIN
			Write "{", MTTE(Row,Col), "}";
			IF Col<MTTNx THEN Write "&"
		END;

	IF Row<MTTNx THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;



%write "%  - E matrix";
%write "\begin{eqnarray}";
%	FOR Row := 1:MTTNx DO
%	BEGIN
%	  FOR Col := 1:MTTNx DO %IF MTTE(Row,Col) NEQ 0 THEN
%	  BEGIN
%	      Write "MTTE", Row, Col, " &=& {", MTTE(Row,Col), "}";
% 	      IF Row<MTTNx OR Col<MTTNx THEN Write "\cr";
%	  END;   
%	END;
%write "\end{eqnarray}";


SHUT "$1_$2.tex";
quit;
EOF

Added mtt/bin/trans/csm2sm_r version [f4ea164861].



































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: csm2sm_r
# Constrained-state equation to linear constrained-state matrices conversion
# P.J.Gawthrop  6th September 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2.4.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.2.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.2  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.1  2000/12/28 12:24:03  peterg
## Put under RCS
##
## Revision 1.2  1996/08/25 10:11:32  peter
## Added END in output file.
## Error handling.
##
## Revision 1.1  1996/08/19 15:06:16  peter
## Initial revision
##
###############################################################

optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-optimise_global )
	    optimise='-optimise_global'
	    optimise_msg=' with global optimisation' ;;
       	-optimise_local )
	    optimise='-optimise_local'
	    optimise_msg=' with local optimisation' ;;
	* )
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Create the reduce output code
def2write_r $1 $2

# Inform user
echo Creating $1_$2.r $optimise_msg

case $2 in
    sm)
        rep=csm;
        ;;
    ssm)
        rep=scsm
        ;;
    *)
        echo Representation must be sm or ssm
esac

# Remove the old log file
rm -f csm2sm_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >csm2sm_r.log << EOF

in "$1_def.r";
in "$1_$rep.r";
in "$1_cr.r";
%%in "$1_sympar.r";

OFF Echo;
OFF Nat;

% Find MTTA and MTTB : the A and B matrices

MTTinvE := MTTE^(-1);
MTTA := MTTinvE*MTTA;
MTTB := MTTinvE*MTTB;

% Create the matrix declarations
OUT "$1_$2.r1";
write "MATRIX MTTA(", MTTNx, ",", MTTNx, ")$"; 
write "MATRIX MTTB(", MTTNx, ",", MTTNu, ")$"; 
write "MATRIX MTTC(", MTTNy, ",", MTTNx, ")$"; 
write "MATRIX MTTD(", MTTNy, ",", MTTNu, ")$"; 
SHUT "$1_$2.r1";

%Create the output file
OUT "$1_$2.r2";
write "%File: $1_ode.r";

write "% New constants";
write "MTTNx := ", MTTNx, ";";
write "MTTNy := ", MTTNy, ";";

in ("$1_sm_write.r");

%Write out the matrices.
% IF MTTNx>0 THEN
% BEGIN
%   write "matrix MTTA(", MTTNx, ",", MTTNx, ");";
%   FOR i := 1:MTTNx DO
%    FOR j := 1:MTTNx DO IF MTTA(i,j) NEQ 0 THEN
%       write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
% END;

% IF MTTNx>0 THEN
% IF MTTNu>0 THEN
% BEGIN
%   write "matrix MTTB(", MTTNx, ",", MTTNu, ");";
%   FOR i := 1:MTTNx DO
%    FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
%       write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
% END;

% %Write it out
% IF MTTNy>0 THEN
% IF MTTNx>0 THEN
% BEGIN
%   write "matrix MTTC(", MTTNy, ",", MTTNx, ");";
%   FOR i := 1:MTTNy DO
%     FOR j := 1:MTTNx DO IF MTTC(i,j) NEQ 0 THEN
%       write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
% END;

% IF MTTNy>0 THEN IF MTTNu>0 THEN 
% BEGIN
%   write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
%   FOR i := 1:MTTNy DO
%     FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
%       write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
% END;

write "END;";

SHUT "$1_$2.r2";
quit;

EOF

cat $1_$2.r1 $1_$2.r2 > $1_$2.r

if [ ${optimise:-""} = "-optimise_global" ]; then
    mtt_optimise global $1 $2
elif [ ${optimise:-""} = "-optimise_local" ]; then
    mtt_optimise local $1 $2
fi

# Now invoke the standard error handling.
mtt_error_r csm2sm_r.log

Added mtt/bin/trans/csm_r2m version [79de729926].



















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: csm_r2m
# Reduce constained state-space A,B,C,D and E matrices to Matlab
# P.J.Gawthrop July 1990, Feb 1991, May 1991, Sep 91, Dec 93, Jan 94, May 94.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1996/08/19 18:40:02  peter
## read in the nuim_par function etc.
##
## Revision 1.1  1996/08/19 16:27:04  peter
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_$2.m

# Remove the old log file
rm -f csm_r2m.log

# Use reduce to accomplish the transformation
reduce >csm_r2m.log << EOF

%Read in the definitions file
in "$1_def.r";

%Read the reduce state-space A,B,C and D matrices file
in "$1_$2.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read in the parameter file
%%in "$1_sympar.r";


OUT "$1_$2.m";

%Headings - Matlab style
%(Note. The ;; are deleted by for2mat)

IF MTTNvar>0 THEN
BEGIN
  write "function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
                  ELSE write MTTVar(i,1), ");;";
  END;
END
ELSE write "function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2;;";


IF MTTNvar>0 THEN
BEGIN
  write "%function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write "%", MTTVar(i,1), ",..."
                  ELSE write "%", MTTVar(i,1), ");;";
  END;
END
ELSE write "%function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2;;";


write "%Linearised constrained-state matrices for system $1";
write "%File $1_$2.m";
write "%Generated by MTT";

IF MTTNvar>0 THEN
BEGIN
  write "% Read in the parameters";
  write "[ ...;;";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
                  ELSE write MTTVar(i,1), "] = $1_numpar"
  END;
  write "% Read in the arguments";
  write "$1_args";
END;

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "MTTA = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTB = zeros(", MTTNx, ",", MTTNu, ");";
write "MTTC = zeros(", MTTNy, ",", MTTNx, ");";
write "MTTD = zeros(", MTTNy, ",", MTTNu, ");";
write "MTTE = zeros(", MTTNx, ",", MTTNx, ");";

ON NERO;	% Suppress zero elements.
MTTA := MTTA;
MTTB := MTTB;
MTTC := MTTC;
MTTD := MTTD;
MTTE := MTTE;

SHUT "$1_$2.m";

Added mtt/bin/trans/csm_r2tex version [c5c521eb67].




















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: csm_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994.

# Inform user
echo Creating $1_$2.tex

# Remove the old log file
rm -f csm_r2tex.log

# Use reduce to accomplish the transformation
reduce >csm_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the constrained-state matrices file
in "$1_$2.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

OUT "$1_$2.tex";

%Write out the constrained-state matrices.
write "%constrained-state  matrices $1";
write "%File: $1_$2.tex";
write"";

write "%constrained-state matrices";

MTT_Matrix := MTTA$ 
MTT_Matrix_name := "MTTA"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB$ 
MTT_Matrix_name := "MTTB"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC$ 
MTT_Matrix_name := "MTTC"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD$ 
MTT_Matrix_name := "MTTD"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTE$ 
MTT_Matrix_name := "MTTE"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

SHUT "$1_$2.tex";
quit;
EOF

Added mtt/bin/trans/ctf_r2tex version [995ac3d6a0].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ctf_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Inform user
echo Creating $1_ctf.tex

# Remove the old log file
rm -f ctf_r2tex.log

# Use reduce to accomplish the transformation
reduce >ctf_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the smconical-form matrices file
in "$1_ctf.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_ctf.tex";

%Write out the canonical matrices
write "%Controler TF $1";
write "%File: $1_ctf.tex";
write"";

MTT_Matrix := MTTcTF$ 
MTT_Matrix_name := "MTTcTF"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNy$
Latex_Matrix()$


SHUT "$1_ctf.tex";
quit;
EOF

Added mtt/bin/trans/dae2cse_r version [7002845624].































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2cse_r
# Differential-algebraic equations to constrained-state equations
# P.J.Gawthrop 14 June 1991, 8 Aug 1991, 2 April 1992, 14 April 1994, 28 Dec 94
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.28  2005/09/07 17:04:12  geraint
## Fixes chi for cse representation.
##
## Revision 1.27  2005/03/21 11:50:39  gawthrop
## Don't write an empty cseo file
##
## Revision 1.26  2002/10/28 23:31:21  gawthrop
## Added additional term to MTTEdx to account for zdot terms on
## Right-Hand Side state equations
##
## Revision 1.25  2002/09/18 19:46:48  geraint
## Refined test to reduce shell loop overhead for unnecessary E matrix.
## Removed unnecessary attempt to optimise cse.
## Fixes sm representation.
##
## Revision 1.24  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.23.2.3  2002/09/12 18:50:50  geraint
## Uncommented cse optimisations - they seem to work ok.
##
## Revision 1.23.2.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.23.2.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.23  2002/07/10 17:43:05  geraint
## Added feature [ 562453 ] Optimisation of algebraic equations.
##
## Revision 1.22  2002/06/28 15:35:47  geraint
## Commented out aej.r generation (not used yet).
##
## Revision 1.21  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.20.2.1  2002/06/05 11:14:50  geraint
## ae.r now generated using def2write_r like cse?.r
## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r.
##
## Revision 1.20  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.19  2001/10/26 01:01:49  geraint
## fixcc when rdae_is_dae (-cr).
##
## Revision 1.18  2001/10/05 23:37:32  geraint
## Fixed assignment statement in ae.r when RHS=0.
##
## Revision 1.17  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.16  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.15.2.4  2001/06/26 00:55:48  geraint
## Writes algebraic equation Jacobian _aej.r (not used yet).
##
## Revision 1.15.2.3  2001/05/09 00:19:22  geraint
## Fixed EOF error when MTTNYZ=0.
##
## Revision 1.15.2.2  2001/05/05 20:50:16  geraint
## Fixed errors when MTTNx=0.
##
## Revision 1.15.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.15  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.14.2.1  2001/03/19 00:29:08  geraint
## Parse switches (-A) before calling def2write_r.
## Update $1_def.* instead of removing.
##
## Revision 1.14  2000/12/28 12:24:35  peterg
## *** empty log message ***
##
## Revision 1.13  2000/10/11 08:52:46  peterg
## Creates csex (cse with dxe only) rep.
##
## Revision 1.12  2000/10/10 21:00:58  peterg
## New code genration
##
## Revision 1.11  1998/11/26 09:18:55  peterg
## Incluse subs.r
##
## Revision 1.10  1998/11/18 13:50:29  peterg
## Removed writeing of EYz matrix
##
## Revision 1.9  1998/11/18 10:53:38  peterg
## Put in some more "IF MTTNx>0 THEN" to avoid error messages when no
## states.
##
## Revision 1.8  1998/11/10 08:54:34  peterg
## Put in "IF MTTNx>0 THEN" to prevent probs when Nx=0
##  -- still a couple of apparent error messages - but answers now
## correct
##
## Revision 1.7  1998/10/05 10:46:15  peterg
## Commented out redundant MTTY := MTTY + MTTEyx*MTTEdX;
##
## Revision 1.6  1998/07/19 12:44:35  peterg
## Set MTTYz := 0 if the array is empty - avoids irritating error
## message.
##
## Revision 1.5  1998/05/20 15:23:26  peterg
## Put MTTYz := MTTYz outsise the BEGIN/END
##
## Revision 1.4  1998/05/20 15:13:09  peterg
## Writes out algebraic equations (if any).
##
## Revision 1.3  1998/03/03 09:02:46  peterg
## Replaced MTTEyx*MTTEdX + MTTEyu*MTTdu; term
##
## Revision 1.2  1997/08/26 08:22:36  peterg
## Changed
## MTTY := MTTY + MTTEyx*MTTdX + MTTEyu*MTTdu;
## to
## MTTY := MTTY + MTTEyx*MTTEdX + MTTEyu*MTTdu;
##
## This sorts out the problem when dz appears in the output equation.
##
## Revision 1.1  1997/08/26 08:20:18  peterg
## Initial revision
##
## Revision 1.2  1996/08/25 09:57:30  peter
## Sorted out bug when MTTNz=0
##
## Revision 1.1  1996/08/15 16:47:02  peter
## Initial revision
##
###############################################################

#Explicit solution option and optimise option
solve=0; solve_msg=''
optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
        -A )
                solve=1
		solve_msg=' with explicit solution of algebraic equations' ;;
	-fixcc )
		fixcc='-fixcc'
                include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'`
                fix_msg='fixing c and cc code';
		;;
        -optimise_global )
	    optimise='-optimise_global'
	    optimise_msg=' with global optimisation' ;;
	-optimise_local )
	    optimise='-optimise_local'
	    optimise_msg=' with local optimisation' ;;
        *)
                echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Create the reduce output code
def2write_r $fixcc $1 ae 
def2write_r $fixcc $1 cse 
def2write_r $fixcc $1 csex # Version without E matrix
def2write_r $fixcc $1 cseo

echo "Creating $1_ae.r $optimise_msg"
echo "Creating $1_cse.r $solve_msg $optimise_msg $fix_msg"
echo "Creating $1_csex.r $optimise_msg"
echo "Creating $1_cseo.r $optimise_msg"

# Remove the old log file
rm -f dae2cse_r.log

# Remove some files
rm -f $1_ae.r? $1_cse.r? $1_cseo.r?

# Use reduce to accomplish the transformation
$SYMBOLIC >dae2cse_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

OFF Echo;
OFF Nat;
ON NERO;

%Fix c code if required
$include

in "$1_def.r";
MTTdxs := MTTdX;  %Save the symbolic form of dX

in "$1_subs.r";
in "$1_dae.r";


%Create F_x, F_y matrices - assumming equations are 
% linear in dZ
IF MTTNz>0 THEN 
BEGIN

IF MTTNx>0 THEN 
BEGIN

% Find MTTFx;
write "% Find MTTFx;";

matrix MTTFx(MTTNx,MTTNz);
FOR j := 1:MTTNz DO
  BEGIN
  dzj := MTTdZ(j,1);
  FOR i := 1:MTTNx DO
    MTTFx(i,j) := df(MTTdX(i,1), dzj, 1);
  END;

END;

% Find MTTFy;
write "% Find MTTFy;";

matrix MTTFy(MTTNy,MTTNz);
FOR j := 1:MTTNz DO
  BEGIN
  dzj := MTTdZ(j,1);
  FOR i := 1:MTTNy DO
    MTTFy(i,j) := df(MTTy(i,1), dzj, 1);
  END;

%Create G_x, G_u matrices 
write "%Create G_x, G_u matrices ";


% Find MTTGx;
IF MTTNx>0 THEN 
BEGIN
write "% Find MTTGx;";

matrix MTTGx(MTTNz,MTTNx);
FOR j := 1:MTTNx DO
  BEGIN
  xj := MTTX(j,1);
  FOR i := 1:MTTNz DO
    MTTGx(i,j) := df(MTTZ(i,1), xj, 1);
  END;
END;

% Find MTTGu;
write "% Find MTTGu;";

matrix MTTGu(MTTNz,MTTNu);
FOR j := 1:MTTNu DO
  BEGIN
  uj := MTTu(j,1);
  FOR i := 1:MTTNz DO
    MTTGu(i,j) := df(MTTZ(i,1), uj, 1);
  END;

%Create E matrices
write "%Create E matrices";

IF MTTNx>0 THEN 
BEGIN
matrix MTTExx(MTTNx,MTTNx); MTTExx := MTTFx*MTTGx;
matrix MTTExu(MTTNx,MTTNu); MTTExu := MTTFx*MTTGu;
matrix MTTEyx(MTTNy,MTTNx); MTTEyx := MTTFy*MTTGx;
matrix MTTE(MTTNx,MTTNx);   MTTE := MTTI - MTTExx;
END;
matrix MTTEyu(MTTNy,MTTNu); MTTEyu := MTTFy*MTTGu;




  %% The following gets rid of the dZs; there must be a better way.
  MTTdZ1 := 0;
  MTTdZ2 := 0;
  MTTdZ3 := 0;
  MTTdZ4 := 0;
  MTTdZ5 := 0;
  MTTdZ6 := 0;
  MTTdZ7 := 0;
  MTTdZ8 := 0;
  MTTdZ9 := 0;
  MTTdZ10 := 0;
  MTTdZ11 := 0;
  MTTdZ12 := 0;
  MTTdZ13 := 0;
  MTTdZ14 := 0;
  MTTdZ15 := 0;
  MTTdZ16 := 0;
  MTTdZ17 := 0;
  MTTdZ18 := 0;
  MTTdZ19 := 0;

IF MTTNx>0 THEN 
BEGIN
MTTEdX := MTTdX; %Ie MTTEdX is MTTdX with the dz terms deleted ie EdX.
MTTdX := MTTdXs;  %Restore the symbolic dX

%% Add on input derivative terms
MTTEdX := MTTEdX + MTTExu*MTTdu;
%% Add on output derivative terms
MTTEdx := MTTEdX + MTTEyx*(MTTE^(-1))*MTTEdX;
END;


%%%%%MTTY := MTTY + MTTEyx*MTTEdX;
%%% This causes the matrix mismatch
%%% MTTdXs and MTTdu need setting in _def.r file
MTTY := MTTY +  MTTEyu*MTTdu;

IF MTTNx>0 THEN 
  MTTY := MTTY + MTTEyx*(MTTE^(-1))*MTTEdX;


END; %%of MTTNz>0

IF MTTNz=0 THEN 
BEGIN
  MTTEdX := MTTdX;
  MTTE   := MTTI;
END;

IF (MTTNyz>0) AND ($solve>0) THEN
BEGIN
  %%%% Try and solve algebraic loops!!

  %Create list of the relevant equations 
  MTT_eqns := {};
  FOR i := 1:MTTNyz DO
    MTT_eqns := append(MTT_eqns,{MTTyz(i,1)});

  %Create list of the relevant unknowns
  MTT_unknowns := {};
  FOR i := 1:MTTNyz DO
    MTT_unknowns := append(MTT_unknowns,{MTTUi(i,1)});

  %Solve the algebraic equations symbolically
    MTT_sol := solve(MTT_eqns,MTT_unknowns);
  %The result seems to be in an extra list - I dont know why
  % So remove the outer list with first.
  % But only if more than one list element!

  if MTTNyz>1 THEN
    MTT_sol := first(MTT_sol);

  %Substitute back into the equations
  FOR i := 1:MTTNyz DO
  BEGIN
    MTT_sol_i := first(MTT_sol); MTT_sol := rest(MTT_sol);
    set(lhs(MTT_sol_i),rhs(MTT_sol_i));
  END;

  % No algebraic variables left!
  MTTNYz := 0;
END; % IF MTTNyz>0 and $solve

%OUT "$1_aej.r";
%IF (MTTNyz>0) THEN % as above
%BEGIN
%    WRITE "MATRIX MTTyzj(",MTTNyz,",",MTTNyz,")";
%    WRITE "%File: $1_aej.r";
%    FOR i := 1:MTTNyz DO
%	FOR j := 1:MTTNyz DO
%	BEGIN
%	   didj := df(MTTyz(i,1),mkid('mttui,j));
%	   IF (didj NEQ 0) THEN
%	      WRITE "MTTyzj(",i,",",j,") := ",didj," +0";
%	END;
%END;
%WRITE ";END;";
%SHUT "$1_aej.r";

IF MTTNyz>0 THEN % not $solve or solution failed
BEGIN
OUT "$1_ae.r1";
write "MATRIX MTTYZ(", MTTNyz, ",", 1, ")$";
SHUT "$1_ae.r1";
END;
OUT "$1_ae.r2";
write "%File: $1_ae.r";
in ("$1_ae_write.r");
write "END;";
SHUT "$1_ae.r2";

% Create the matrix declarations
OUT "$1_cse.r1";
write "%";
IF (MTTNx > 0) THEN
BEGIN
    write "MATRIX MTTEdx(", MTTNx, ",", 1, ")$"; 
    write "MATRIX MTTE(", MTTNx, ",", MTTNx, ")$"; 
END;
SHUT "$1_cse.r1";

OUT "$1_csex.r1";
write "%File:$1_csex.r1";
IF (MTTNx > 0) THEN
    write "MATRIX MTTEdx(", MTTNx, ",", 1, ")$"; 
SHUT "$1_csex.r1";

IF MTTNy>0 THEN
BEGIN
  OUT "$1_cseo.r1";
  write "MATRIX MTTY(", MTTNy, ",", 1, ")$"; 
  SHUT "$1_cseo.r1";
END;

%%Create the _cse.r file
OUT "$1_cse.r2";
write "%File: $1_cse.r";
in ("$1_cse_write.r");
write "in ""$1_cseo.r"";";
write "END;";

% % State derivative
% MTT_Matrix := MTTEdX$ 
% MTT_Matrix_name := "MTTEdX"$
% MTT_Matrix_n := MTTNx$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

% % Output
% MTT_Matrix := MTTY$ 
% MTT_Matrix_name := "MTTY"$
% MTT_Matrix_n := MTTNy$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

% % Inputs
% MTT_Matrix := MTTU$ 
% MTT_Matrix_name := "MTTU"$
% MTT_Matrix_n := MTTNu$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$
% MTT_Matrix := MTTdU$ 
% MTT_Matrix_name := "MTTdU"$
% MTT_Matrix_n := MTTNu$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

% % E matrix
% MTT_Matrix := MTTE$ 
% MTT_Matrix_name := "MTTE"$
% MTT_Matrix_n := MTTNx$
% MTT_Matrix_m := MTTNx$
% Reduce_Matrix()$

% % Eyx matrix
% MTT_Matrix := MTTEyx$ 
% MTT_Matrix_name := "MTTEyx"$
% MTT_Matrix_n := MTTNy$
% MTT_Matrix_m := MTTNx$
% %Reduce_Matrix()$

% % Yz
% MTT_Matrix := MTTYz$ 
% MTT_Matrix_name := "MTTYz"$
% MTT_Matrix_n := MTTNyz$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

write ";END;";

SHUT "$1_cse.r2";

OUT "$1_csex.r2";
write "%File: $1_cse.r";
in ("$1_csex_write.r");
write "END;";
SHUT "$1_csex.r2";

%Write out the  output equations
OUT "$1_cseo.r2";
write "%File: $1_cseo.r";
IF MTTNy>0 THEN
   in ("$1_cseo_write.r");
write "END;";
SHUT "$1_cseo.r2";
quit;
EOF

touch $1_ae.r1 $1_ae.r2
touch $1_cseo.r1
touch $1_cseo.r2
cat $1_ae.r1 $1_ae.r2 > $1_ae.r
cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ ${optimise:-""} = "-optimise_global" ]; then
    mtt_optimise global $1 ae
    mtt_optimise global $1 cseo
    mtt_optimise global $1 csex
elif [ ${optimise:-""} = "-optimise_local" ]; then
    mtt_optimise local $1 ae
    mtt_optimise local $1 cseo
    mtt_optimise local $1 csex
fi

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files"
    gawk '{
     if ($1=="MTTNyz") 
       print "MTTNyz := 0;" 
     else print $0
    }' $1_def.r > mtt_junk
  # Make sure it preserves the time stamp!!
  # and remove dependent reps
   touch -r $1_def.r mtt_junk
   mv mtt_junk $1_def.r
   for file in `ls $1_def.*`; do
      if [ $file != $1_def.r ]; then
          ext=`echo $file|gawk -F\. '{print $2}'`
          mtt -q $1 def $ext
      fi
   done
fi


# Now invoke the standard error handling.
mtt_error_r dae2cse_r.log

Added mtt/bin/trans/dae2daes_m version [2d36d30236].





















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2daesol_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/05/14 08:14:28  peterg
## Now reads in data from the simpar file.
##
## Revision 1.5  1998/05/13 16:42:03  peterg
## Fixed various bugs etc.
##
# Revision 1.4  1996/08/24  14:27:59  peter
# Global parameters.
# Error handling.
#
## Revision 1.3  1996/08/18 12:00:19  peter
## Unified format of responses.
##
## Revision 1.2  1996/08/16 13:17:57  peter
## Changed default args to include nx+nz
## Fixed bug with vector outputs.
##
## Revision 1.1  1996/08/15 16:24:55  peter
## Initial revision
##
###############################################################


echo Creating $1_daes.m
echo Creating $1_daeso.m
rm -f dae2daes_m.log
rm -f $1_daes.m
rm -f $1_daeso.m


$MATRIX << EOF > dae2daes_m.log 2>mtt_error.txt

  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
  
  % Number of descriptor "states"
  NX = nx+2*nz+nyz;

  %Read in parameters
  $1_numpar; 
 
  %Read in state (needs redoing for descriptor xevtor
  %x = $1_state;


  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;  %Just in case its in the parameter list

  %Defaults
  if exist('T')==0
    T=[0:0.1:10]
  end;

  if exist('x0')==0
    x0 = zeros(NX,1);
  end;

  if exist('dx0')==0
   dx0 = zeros(NX,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

if NX>0
  x = dassl("$1_dae", x0, dx0,  T);
  write_matrix([T,x], '$1_daes');
else
  x = zeros(size(T));
end;

if ny>0
  i=0;
  Y = [];
  for tt=T'
    i=i+1;
    y = $1_daeo(x(i,:),tt);
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_daeso');
end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt








Added mtt/bin/trans/dae2daes_m version [27f1864b05].





















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2daesol_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/05/14 08:14:28  peterg
## Now reads in data from the simpar file.
##
## Revision 1.5  1998/05/13 16:42:03  peterg
## Fixed various bugs etc.
##
# Revision 1.4  1996/08/24  14:27:59  peter
# Global parameters.
# Error handling.
#
## Revision 1.3  1996/08/18 12:00:19  peter
## Unified format of responses.
##
## Revision 1.2  1996/08/16 13:17:57  peter
## Changed default args to include nx+nz
## Fixed bug with vector outputs.
##
## Revision 1.1  1996/08/15 16:24:55  peter
## Initial revision
##
###############################################################


echo Creating $1_daes.m
echo Creating $1_daeso.m
rm -f dae2daes_m.log
rm -f $1_daes.m
rm -f $1_daeso.m


$MATRIX << EOF > dae2daes_m.log 2>mtt_error.txt

  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
  
  % Number of descriptor "states"
  NX = nx+2*nz+nyz;

  %Read in parameters
  $1_numpar; 
 
  %Read in state (needs redoing for descriptor xevtor
  %x = $1_state;


  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;  %Just in case its in the parameter list

  %Defaults
  if exist('T')==0
    T=[0:0.1:10]
  end;

  if exist('x0')==0
    x0 = zeros(NX,1);
  end;

  if exist('dx0')==0
   dx0 = zeros(NX,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

if NX>0
  x = dassl("$1_dae", x0, dx0,  T);
  write_matrix([T,x], '$1_daes');
else
  x = zeros(size(T));
end;

if ny>0
  i=0;
  Y = [];
  for tt=T'
    i=i+1;
    y = $1_daeo(x(i,:),tt)';
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_daeso');
end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt








Added mtt/bin/trans/dae2dm_r version [ba38e9420b].














































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2dm_r
# Differential-algebraic equation to linear descriptor matrices conversion
# P.J.Gawthrop  8th May 1991, 7 June 1991, April 1994.
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2005/03/21 11:44:06  gawthrop
## Avoid error messages when no inputs or no outputs or no states
##
## Revision 1.3  1998/07/27 20:25:36  peterg
## *** empty log message ***
##
# Revision 1.2  1996/08/25  09:53:35  peter
# Error handling added.
#
## Revision 1.1  1996/08/18 20:03:51  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_dm.r

# Remove the old log file
rm -f dae2dm_r.log

# Use reduce to accomplish the transformation
reduce >dae2dm_r.log << EOF

in "$1_def.r";
in "$1_dae.r";
in "$1_cr.r";
%%in "$1_sympar.r";

OFF Echo;
OFF Nat;


%Total number of descriptor variables
MTTN := MTTNx + 2*MTTNz + MTTNyz;

IF MTTN>0 THEN
BEGIN
% Find MTTE : the E matrix
matrix MTTE(MTTN,MTTN);

% First row partition
IF MTTNx>0 THEN 
    FOR j := 1:MTTNx DO
      MTTE(j,j) := 1;

% Second row partition
  IF MTTNz>0 THEN 
     FOR j := 1:MTTNz DO
      MTTE(j+MTTNx, j+MTTNx) := 1;

% Find MTTA : the A matrix

% First row partition: x
IF MTTN>0 THEN 
  BEGIN
  matrix MTTA(MTTN,MTTN);
  FOR j := 1:MTTNx DO
    BEGIN
    xj := MTTX(j,1);
    FOR i := 1:MTTNx DO
      MTTA(i,j) := df(MTTdX(i,1), xj, 1);
    END;

  IF MTTNz>0 THEN 
     FOR j := 1:MTTNz DO
       BEGIN
       dzj := MTTdz(j,1);
       FOR i := 1:MTTNx DO
         MTTA(i, j + MTTNx + MTTNz) := df(MTTdX(i,1), dzj, 1);
       END;

  IF MTTNyz>0 THEN 
     FOR j := 1:MTTNyz DO
       BEGIN
       uij := MTTUi(j,1);
       FOR i := 1:MTTNx DO
         MTTA(i, j + MTTNx + 2*MTTNz) := df(MTTdX(i,1), uij, 1);
       END;
  END;

% Second row partition: z
IF MTTNz>0 THEN 
  FOR j := 1:MTTNz DO
    MTTA(j + MTTNx, j + MTTNx + MTTNz) := 1;

% Third row partition
IF MTTNz>0 THEN 
  BEGIN
  IF MTTNx>0 THEN 
  FOR j := 1:MTTNx DO
    BEGIN
    xj := MTTX(j,1);
    FOR i := 1:MTTNz DO
      MTTA(i + MTTNx + MTTNz,j) := df(MTTZ(i,1), xj, 1);
    END;

   FOR j := 1:MTTNz DO
	MTTA(j + MTTNx + MTTNz, j + MTTNx) := -1;

   FOR j := 1:MTTNz DO
     BEGIN
     dzj := MTTdz(j,1);
     FOR i := 1:MTTNz DO
       MTTA(i + MTTNx + MTTNz, j + MTTNx + MTTNz) := df(MTTZ(i,1), dzj, 1);
     END;

  IF MTTNyz>0 THEN 
     FOR j := 1:MTTNyz DO
       BEGIN
       uij := MTTUi(j,1);
       FOR i := 1:MTTNz DO
         MTTA(i+MTTNx+MTTNz, j+MTTNx+2*MTTNz) := df(MTTZ(i,1), uij, 1);
       END;
  END;


% Fourth row partition
IF MTTNyz>0 THEN 
  BEGIN
  IF MTTNx>0 THEN 
  FOR j := 1:MTTNx DO
    BEGIN
    xj := MTTX(j,1);
    FOR i := 1:MTTNyz DO
      MTTA(i + MTTNx + 2*MTTNz,j) := df(MTTYz(i,1), xj, 1);
    END;

  IF MTTNz>0 THEN 
  FOR j := 1:MTTNz DO
    BEGIN
     dzj := MTTdz(j,1);
    FOR i := 1:MTTNyz DO
      MTTA(i + MTTNx + 2*MTTNz, j + MTTNx + MTTNz) := df(MTTYz(i,1), dzj, 1);
    END;

  IF MTTNyz>0 THEN 
     FOR j := 1:MTTNyz DO
       BEGIN
       uij := MTTUi(j,1);
       FOR i := 1:MTTNyz DO
         MTTA(i+MTTNx+2*MTTNz, j+MTTNx+2*MTTNz) := df(MTTYz(i,1), uij, 1);
       END;
  END;

% Find MTTB : the B matrix

IF MTTNu>0 THEN
BEGIN
matrix MTTB(MTTN,MTTNu);

% First row partition
IF MTTNx>0 THEN 
  BEGIN
  FOR j := 1:MTTNu DO
    BEGIN
    uj := MTTU(j,1);
    FOR i := 1:MTTNx DO
      MTTB(i,j) := df(MTTdX(i,1), uj, 1);
    END;
  END;

% Third row partition
IF MTTNz>0 THEN 
  BEGIN
  FOR j := 1:MTTNu DO
    BEGIN
    uj := MTTU(j,1);
    FOR i := 1:MTTNz DO
      MTTB(i + MTTNx + MTTNz ,j) := df(MTTZ(i,1), uj, 1);
    END;
  END;

% Fourth row partition
IF MTTNyz>0 THEN 
  BEGIN
  FOR j := 1:MTTNu DO
    BEGIN
    uj := MTTU(j,1);
    FOR i := 1:MTTNyz DO
      MTTB(i + MTTNx + 2*MTTNz,j) := df(MTTYz(i,1), uj, 1);
    END;
  END;

END;

% Find MTTC : the C matrix
IF MTTNy>0 THEN
BEGIN
matrix MTTC(MTTNy,MTTN);

% First column partition
IF MTTNx>0 THEN 
  BEGIN
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNx DO
    BEGIN
      xj := MTTX(j,1);
      MTTC(i,j) := df(MTTY(i,1), xj, 1);
    END;
  END;

% Third column partition
IF MTTNz>0 THEN 
  BEGIN
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNz DO
    BEGIN
      dzj := MTTdZ(j,1);
      MTTC(i, j + MTTNx + MTTNz) := df(MTTY(i,1), dzj, 1);
    END;
  END;

% Fourth column partition
IF MTTNyz>0 THEN 
  BEGIN
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNyz DO
    BEGIN
      uij := MTTUi(j,1);
      MTTC(i, j + MTTNx + 2*MTTNz) := df(MTTY(i,1), uij, 1);
    END;
  END;

END;
END; %of MTTN>0

% Find MTTD : the D matrix
IF MTTNy>0 THEN
IF MTTNu>0 THEN
BEGIN
  matrix MTTD(MTTNy,MTTNu);
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO
    BEGIN
      uj := MTTU(j,1);
      MTTD(i,j) := df(MTTY(i,1), uj, 1);
    END;
END;

%Zap the dz terms (not a nice way)
MTTdz1 := 0;
MTTdz2 := 0;
MTTdz3 := 0;
MTTdz4 := 0;
MTTdz5 := 0;
MTTdz6 := 0;
MTTdz7 := 0;
MTTdz8 := 0;
MTTdz9 := 0;
MTTdz10 := 0;
MTTdz11 := 0;
MTTdz12 := 0;
MTTdz13 := 0;
MTTdz14 := 0;
MTTdz15 := 0;
MTTdz16 := 0;
MTTdz17 := 0;
MTTdz18 := 0;
MTTdz19 := 0;


%Substitute the ss values
in "$1_sspar.r";

%Create the output file
OUT "$1_dm.r";

%Write out the matrices.
IF MTTN>0 THEN
BEGIN
  write "matrix MTTE(", MTTN, ",", MTTN, ");";
  FOR i := 1:MTTN DO
   FOR j := 1:MTTN DO IF MTTE(i,j) NEQ 0 THEN
      write "MTTE(", i, ",", j, ") := ", MTTE(i,j);

  write "matrix MTTA(", MTTN, ",", MTTN, ");";
  FOR i := 1:MTTN DO
   FOR j := 1:MTTN DO IF MTTA(i,j) NEQ 0 THEN
      write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
END;

IF MTTN>0 THEN
IF MTTNu>0 THEN
BEGIN
  write "matrix MTTB(", MTTN, ",", MTTNu, ");";
  FOR i := 1:MTTN DO
   FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
      write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
END;

%Write it out
IF MTTNy>0 THEN
IF MTTN>0 THEN
BEGIN
  write "matrix MTTC(", MTTNy, ",", MTTN, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTN DO IF MTTC(i,j) NEQ 0 THEN
      write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
END;

IF MTTNy>0 THEN IF MTTNu>0 THEN 
BEGIN
  write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
      write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
END;

write "END;";

SHUT "$1_dm.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r dae2dm_r.log

Added mtt/bin/trans/dae2ker_r version [d1d098f9c2].


























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
## Shell script dae2ker_r
## Converts dae to behavioral kernal rep. 


echo Creating $1_ker.r

$SYMBOLIC > dae2ker.log <<EOF

% Read the files
in "$1_dae.r";

% Substitute for the non-state derivatives
FOR i:=1:MTTNz DO
BEGIN
  set(mkid(mttdz,i),s*mttz(i,1));
END;

% Create a list algebraic equations set to zero
eq_list:={}; v_list:={};
FOR i:=1:MTTNyz DO
BEGIN
  eq_list := append(eq_list, {MTTyz(i,1)=0});
  v_list := append(v_list,{mkid(mttui,i)});
END;

eq_list; v_list;

%Solve for the "unknown" latent variables
sol := solve(eq_list,v_list);

% Substitute into the manifest variables array
FOR i:=1:MTTNy DO
BEGIN
  mtty(i,1) := sub(sol,mtty(i,1));  
END;

% Eliminate the "external" latent variables
eq_list:={}; v_list:={};
FOR i:=1:MTTNy DO
BEGIN
  u_i := mkid(mttu,i);
  w_i := mkid(mttw,i);
  eq_list := append(eq_list, {w_i=MTTy(i,1)});

  IF i>MTTNu THEN
    v_list := append({w_i},v_list)
  ELSE
    v_list := append({u_i},v_list);
END;

eq_list; v_list;
sol := solve(eq_list,v_list);
sol := first(sol);

% Pluck out the manifest variable solutions
behaviour_list:={};
FOR i:=1:(MTTNy-MTTNu) DO
BEGIN
  soli := first(sol);
  sol := rest(sol);
  behaviour := DEN(RHS(soli))*LHS(soli) - NUM(RHS(soli)) = 0;
  behaviour_list := append(behaviour_list, {behaviour});
END;
behaviour_list := behaviour_list;

MATRIX MTTR(MTTNy-MTTNu,MTTNy);
FOR i:=1:(MTTNy-MTTNu) DO
BEGIN
  FOR j:=1:MTTNy DO
  BEGIN
    w_j := mkid(mttw,j);
    coeffs := coeff(lhs(first(behaviour_list)),w_j);
    IF length(coeffs)>1 THEN
      MTTR(i,j) := second(coeff(lhs(first(behaviour_list)),w_j));
  END;
  behaviour_list := rest(behaviour_list);
END;

%% Now do coefficient matrices

OFF NAT;
OUT "$1_ker.r";
write "MATRIX MTTR(", MTTNy-MTTNu, ",", MTTNy, ");";
MTTR := MTTR;
SHUT "$1_ker.r";


EOF

Added mtt/bin/trans/dae2lde_r version [b551dcb121].


























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lde2ode.r
# Reduce differential-algebraic equations to Lagranges equations
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2.4.3  2002/09/13 10:10:42  geraint
## Commented out optimisation.
##
## Revision 1.2.4.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.2.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.2  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.1  2000/12/28 12:25:13  peterg
## Initial revision
##
###############################################################

optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-optimise_global )
#	    optimise='-optimise_global'
#	    optimise_msg=' with global optimisation' ;;
	    optimise=''
	    optimise_msg='' ;;
	-optimise_local )
#	    optimise='-optimise_local'
#	    optimise_msg=' with local optimisation' ;;
	    optimise=''
	    optimise_msg='' ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Create the reduce output code
def2write_r $1 lde
def2write_r $1 ldeo

#Inform user
echo Creating $1_lde.r $optimise_msg
echo Creating $1_ldeo.r $optimise_msg

# Remove the old log file
rm -f cse2lde_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC  << EOF >cse2lde_r.log

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

%Read the definitions file
in "$1_def.r";

%Read the substitution file
in "$1_subs.r";

%Read the dae file
in "$1_dae.r";

% Zap bits we dont need
clear mttui, mttu, mttdu, mttx, mttdz;

%% The lagrangian eqns are those set to zero.
MTTL := mttyz;

% Create the second derivative of z
MATRIX mttddz(MTTNz,1);
FOR i := 1:MTTNz DO
BEGIN
  mttuii := mkid(mttui,i);
  mttdduii := mkid(mttddui,i);
  mttddz(i,1) :=  sub(mttuii=mttdduii,mttz(i,1));
END;
mttddz;

% Create Lagranges Equations
FOR j := 1:MTTNyz DO
BEGIN
  %% Create derivative of the equations by substituting:
  %du for u
  mttuj := mkid(mttu,j);
  mttduj := mkid(mttdu,j);
  MTTL :=  sub(mttuj=mttduj,MTTL);

  % dv for v
  mttuij := mkid(mttui,j);
  mttduij := mkid(mttdui,j);
  MTTL :=  sub(mttuij=mttduij,MTTL);

  % dx for x
  mttxj := mkid(mttx,j);
  MTTL :=  sub(mttxj=mttdx(j,1),MTTL);

  % ddz for dz
  mttdzj := mkid(mttdz,j);
  MTTL :=  sub(mttdzj=mttddz(j,1),MTTL);

END;

L = MTTL;

OFF Echo;
OFF Nat;


%Write out the  ordinary differential equations.
OUT "$1_lde.r";
write "%File: $1_lde.r";
in ("$1_lde_write.r");
write "in ""$1_ldeo.r"";";
write "END;";
SHUT "$1_lde.r";

%Write out the  output equations
OUT "$1_ldeo.r";
write "%File: $1_ldeo.r";
in ("$1_ldeo_write.r");
write "END;";
SHUT "$1_ldeo.r";
quit;
EOF

# TODO: edit mtt_optimise to accept lde and ldeo
# if [ ${optimise:-""} = "-optimise_global" ]; then
#     mtt_optimise global $1 lde
#     mtt_optimise global $1 ldeo
# elif [ ${optimise:-""} = "-optimise_local" ]; then
#     mtt_optimise local $1 lde
#     mtt_optimise local $1 ldeo
# fi

# Now invoke the standard error handling.
mtt_error_r cse2lde_r.log

Added mtt/bin/trans/dae_r2m version [d91c90bd7e].






















































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae_r2m
# Reduce DAE to OCTAVE (DASSL) DAE  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95, Aug 97.
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1998/05/13 16:43:03  peterg
## Now uses matlab_matrix to write the matrices
## Various bug fixes
## New global generation method
##
# Revision 1.6  1997/08/28  14:07:16  peterg
# Changed MTTDx to MTTDeriv
#
# Revision 1.5  1996/08/24  14:27:29  peter
# Global parameters.
#
## Revision 1.4  1996/08/18 20:02:21  peter
## Include zero outputs.
##
## Revision 1.3  1996/08/16 13:10:53  peter
## Fixed bug Ny changed to Nx in redidual loop.
##
## Revision 1.2  1996/08/16 08:57:34  peter
## Reads $1_input.
##
## Revision 1.1  1996/08/15 16:46:06  peter
## Initial revision
##
###############################################################


# WARNING this is experimental!!
# It asumes that the output y is NOT dependent on derivatives of
#  z or u.


#Inform user
echo Creating $1_dae.m
echo Creating $1_daeo.m


# Remove the old log file
rm -f dae_r2m.log

# Remove temp. files
rm -f $1_dae.m?
rm -f $1_daeo.m?

# Use reduce to accomplish the transformation
$SYMBOLIC >dae_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  DAE   file
in "$1_dae.r";

% Matrix output function
in"$MTTPATH/trans/matlab_matrix.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
%%in "$1_sympar.r";


%% ON NERO;        % Suppress zero elements

%Define the common part of the functions.

PROCEDURE common;
BEGIN

  write "% Read in the input";
  write "u = $1_input(x,t)";

 % write "% Read in the arguments";
 % write "$1_args";
  
  write "% Set up the State variables";
  FOR i := 1:MTTNx DO
  BEGIN
    write "mttx", i, " = mttx(", i, ");";
  END;

  write "% Set up the non-state variables";
  FOR i := 1:MTTNz DO
  BEGIN
    write "mttz", i, " = mttx(", MTTNx+ i, ");";
  END;
  write "% Set up the non-state derivatives";
  FOR i := 1:MTTNz DO
  BEGIN
    write "mttdz", i, " = mttx(", MTTNx+MTTNz+ i, ");";
  END;

   write "% Set up the internal inputs";
  FOR i := 1:MTTNyz DO
  BEGIN
    write "mttui", i, " = mttx(", MTTNx+2*MTTNz+i, ");";
  END;
  
  write "% Set up the Input variables";
  IF MTTNu>0 THEN
  FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ");";
  END;
END;
  
% Firstly do the residual = f(dx,x,t) function.

% MTTGx and u are the derivatives of z wrt x and u respectively

% Find MTTGx;
if MTTNz>0 THEN
BEGIN
matrix MTTGx(MTTNz,MTTNx);
FOR j := 1:MTTNx DO
  BEGIN
  xj := MTTX(j,1);
  FOR i := 1:MTTNz DO
    MTTGx(i,j) := df(MTTZ(i,1), xj, 1);
  END;

% Find MTTGu;
matrix MTTGu(MTTNz,MTTNu);
FOR j := 1:MTTNu DO
  BEGIN
  uj := MTTu(j,1);
  FOR i := 1:MTTNz DO
    MTTGu(i,j) := df(MTTZ(i,1), uj, 1);
  END;
END;

IF MTTNz=0 THEN
BEGIN
  MTTGx := 0;
  MTTGu := 0;
  MTTz := 0;
END;

OUT "$1_dae.m1";
write "function residual = $1_dae(mttx,deriv0,t);";
write "% residuals = $1_dae(dx,x,t);";
write "%DAE in DASSL $1;;";
write "%File $1_dae.m;;";
write "%Generated by MTT;;";


common();
SHUT "$1_dae.m1";

GENTRANOUT "$1_dae.m3";
write "% State derivative";
IF MTTNX>0 THEN
BEGIN
  MTT_Matrix := MTTdX$ 
  MTT_Matrix_name := "deriv"$
  MTT_Matrix_n := MTTNx$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN deriv := mtt_matrix$
END;

IF MTTNYz>0 THEN
BEGIN
  MTT_Matrix := MTTYz$ 
  MTT_Matrix_name := "MTTYz"$
  MTT_Matrix_n := MTTNYz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTYz := mtt_matrix$
END;

if MTTNz>0 THEN
BEGIN
  MTT_Matrix := MTTz$ 
  MTT_Matrix_name := "MTTz"$
  MTT_Matrix_n := MTTNz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTz := mtt_matrix$

  MTT_Matrix := MTTGu$ 
  MTT_Matrix_name := "MTTGu"$
  MTT_Matrix_n := MTTNz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTGu := mtt_matrix$

  MTT_Matrix := MTTGu$ 
  MTT_Matrix_name := "MTTGx"$
  MTT_Matrix_n := MTTNz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTGx := mtt_matrix$

END;


SHUT "$1_dae.m3";

OUT "$1_dae.m4";
%  write "% Set up the non-state derivatives";
%  FOR i := 1:MTTNz DO
%    write "mttdz", i, " = mttderiv0(", MTTNx+ i, ");";
%  END;

write "j = 0;";

%Residual has 3 parts as follows:
%Part 1: dx/dt - dx_0/dt
if MTTNx>0 THEN
BEGIN
  write "for i=1:", MTTNx, ";;";
  write "  j = j+1";
  write "  residual(j) = deriv(i)-deriv0(j);";
  write "end;";
END;

%Part 2: dz/dt - dz_0/dt
IF MTTNz>0 THEN
BEGIN
  if MTTNx>0 THEN
    write "mttdzx = mttgx*mttdx"
  ELSE
    write "mttdzx = zeros(", MTTNz, ",1);";


  if MTTNu>0 THEN
    write "mttdzu = mttgu*mttdu"
  ELSE
    write "mttdzu = zeros(", MTTNz, ",1);";

  write "mttdz = mttdzx + mttdzu";

  write "for i=1:", MTTNz, ";;";
  write "  j = j+1";
  write "  residual(j) = mttdz(i)-mttderiv0(j);";
  write "end;";
END;

%Part 3: v=0 (the algebraic bits)
IF MTTNyz>0 THEN
BEGIN  
  write "for i=1:", MTTNyz, ";;";
  write "  j = j+1";
  write "  residual(j) = mttyz(i)";
  write "end;";
END;

SHUT "$1_dae.m4";


% Now do the y = g(x,t) function.
OUT "$1_daeo.m1";
  
write "function mtty = $1_daeo(mttx,t);";
write "% mtty = $1_daeo(mttx,t);";
write "%DAE in Simulab form for system $1;;";
write "%File $1_daeo.m;;";
write "%Generated by MTT;;";

SHUT "$1_daeo.m1";

OUT "$1_daeo.m3";
common();


%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 500$
OFF period$

MTTy := MTTy;

SHUT "$1_daeo.m3";

EOF

# Create the globals
sympar2global_txt2m $1> $1_dae.m2
sympar2global_txt2m $1> $1_daeo.m2

# Put together the pieces
cat $1_dae.m?>$1_dae.m
cat $1_daeo.m?>$1_daeo.m







Added mtt/bin/trans/dae_r2tex version [ed25283fdf].


































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae_r2tex
# Reduce differential-algebraic to LaTex differential-algebraic equations.
# P.J.Gawthrop 10th May 1991, April 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1998/01/23 16:08:09  peterg
## changed eqnarray to equation + aligned
##
## Revision 1.3  1997/06/13 13:30:43  peterg
## Removed eqn labels.
##
# Revision 1.2  1996/12/19  10:25:15  peterg
# Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
# conversion.
#
# Revision 1.1  1996/10/21  08:50:15  peterg
# Initial revision
#
###############################################################


while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

# Inform user
echo Creating $1_dae.tex $blurb

logname=dae_r2tex.log

# Remove the old log file
rm -f dae_r2tex.log

# Use reduce to accomplish the transformation
$SYMBOLIC >$logname << EOF

%Read the definitions file
in "$1_def.r";

%Read the differential-algebraic equations file
in "$1_dae.r";

%Read the symbolic parameter file
%%in "$1_sympar.r";


OFF Echo;
OFF Nat;


%Read the substitution file
in "$1_subs.r";

%Read the simplifying expressions file
IN "$1_simp.r";

% Read the formating function
in "$MTTPATH/trans/latex_equations.r";

OUT "$1_dae.tex";

%Write out the  differential-algebraic equations.

write "%File: $1_dae.tex";

write "%differential-algebraic equations";
%ON Rounded;
%Precision 5;

latex_equations();

SHUT "$1_dae.tex";
quit;
EOF

if [ -n "$partition" ]; then
  rm -f mtt_junk
  # Now for the subsystems
  # Find subsystems
  subsystems=`mtt_get_subsystems $1`

  for subsystem in $subsystems; do
  echo Doing $subsystem
  ucname="MTT_"$subsystem"_uc"
  subsystem_dae=$subsystem"_dae"
  #subname=`echo $subsystem | mtt_remove_underscore`

  Nu=`mtt_getsize -internal $subsystem"_1" u`
  echo Nu $Nu

  # Use symbolic algebra to accomplish the transformation
  $SYMBOLIC >$logname  << EOF


  %Read the definitions file
  in "$1_def.r";
  
  
  %Read the symbolic parameter file
  %%in "$1_sympar.r";
  
  
  % Read the formating function
  in  "$MTTPATH/trans/latex_equations.r";

  OFF Echo;
  OFF Nat;
  
  
  %Read the substitution file
  in "$1_subs.r";
  
  %Read the simplifying expressions file
  IN "$1_simp.r";

  %Read the differential-algebraic equations file
  in "$1_dae.r";

  %Create the output file
  OUT "mtt_junk_1";

  % Connecting inputs
  IF $Nu>0 THEN
  BEGIN
    write "\section{Subsystem $subsystem}";

    write "\subsection{Connections}";
    write"\begin{itemize}";
  FOR Row := 1:$Nu DO
    BEGIN
  	write "\item Input ", Row, " is connected to ";
  	write $ucname(Row,1);
    END;
    write"\end{itemize}";
  END;
  SHUT "mtt_junk_1";

  %Read the differential-algebraic equations file
  in "$subsystem_dae.r";

  %Create the output file
  OUT "mtt_junk_2";
  write "\subsection{Dynamics}";
   latex_equations();
  SHUT "mtt_junk_2";

EOF
  echo >> $1_dae.tex
  echo %Connections for subsystem $subsystem >> $1_dae.tex

  # Sort out underscores and remove mtt to avoide post processor
  cat mtt_junk_1 | mtt_remove_underscore | sed 's/mtt//g'>> $1_dae.tex
  cat mtt_junk_2  >> $1_dae.tex
  rm -rf mtt_junk_?
  done
fi


# Now invoke the standard error handling.
mtt_error_r dae_r2tex.log











Added mtt/bin/trans/dat22dat version [cbdbd4dbd6].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat22dat
# Splits the data file into output and state bits

# Copyright (c) P.J.Gawthrop 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2000/10/17 12:24:02  peterg
## Three argument generic version
##
## Revision 1.9  2000/09/27 16:12:50  peterg
## Use expr to evaluate arithmetic - compatible with sh (as opposed to
## bash)
##
## Revision 1.8  2000/09/21 10:07:06  peterg
## Now correctely writes out the state into _odes.dat rep.
##
## Revision 1.7  2000/04/06 09:02:46  peterg
## Removed bash let commands as unsupported by sh
## Do arithmetic within awk - yuk
##
## Revision 1.6  2000/04/06 08:36:15  peterg
## *** empty log message ***
##
## Revision 1.5  1999/03/15 22:42:52  peterg
## Strip comments (put in by Octave save function)
##
## Revision 1.4  1999/03/15 21:55:36  peterg
## Does away with the # symbol in the file - uses _de to get Nx Ny
## instead
##
###############################################################
if [ -z "$1" ]; then
  echo "Usage: dat22dat system ode|odes so|s"
  exit
fi

# Find Nx and Ny
Nx=`mtt_getsize $1 x` # States
Ny=`mtt_getsize $1 y` # Outputs

case $3 in
    so)
	First=1; Last=`expr $First + $Ny`
	;;
    s)
	First=`expr $Ny + 2`; Last=`expr $First + $Nx`
	;;
    *)
	First=1; Last=`expr $Ny + 1`
        ;;
esac

echo Creating $1_$2$3.dat

gawk '{
      ## Extract the data
      if (index($1,"#") != 1){
        for (i=First;i<=Last;i++)
	  printf("%s ", $i);
      printf("\n"); 
  }
}' First=$First Last=$Last <$1_$2s.dat2  > $1_$2$3.dat

Added mtt/bin/trans/dat22sg.sh version [2702996b8e].




















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

# Convert simulation data to SciGraphica (v 0.61) Project file ($sys_odes.sg)

sys=$1

write_project_header ()
{
    cat <<EOF
<?xml version="1.0"?>

<sg:Project xmlns:sg="http://scigraphica.sourceforge.net">
  <sg:Summary>
    <sg:Item>
      <sg:name>application</sg:name>
      <sg:val-string>scigraphica</sg:val-string>
    </sg:Item>
    <sg:Item>
      <sg:name>author</sg:name>
      <sg:val-string>MTT:${USER}</sg:val-string>
    </sg:Item>
  </sg:Summary>

EOF
}

write_project_footer ()
{
    echo ''
    echo '</sg:Project>'
}

write_worksheet_header ()
{
    name=$1 ; ncol=$2 ; nrow=$3
    cat <<EOF

<sgw:Worksheet xmlns:sgw="http://scigraphica.sourceforge.net">
  <sgw:Summary>
    <sgw:Item>
      <sgw:name>application</sgw:name>
      <sgw:val-string>scigraphica</sgw:val-string>
    </sgw:Item>
    <sgw:Item>
      <sgw:name>author</sgw:name>
      <sgw:val-string>MTT:${USER}</sgw:val-string>
    </sgw:Item>
  </sgw:Summary>
  <sgw:Geometry Width="400" Height="350"/>
  <sgw:Name>${name}</sgw:Name>
  <sgw:MaxCol>${ncol}</sgw:MaxCol>
  <sgw:MaxRow>${nrow}</sgw:MaxRow>
  <sgw:Begin>-1</sgw:Begin>
  <sgw:End>-1</sgw:End>
EOF
}

write_worksheet_footer ()
{
    echo ''
    echo '</sgw:Worksheet>'
}

write_column_headings ()
{
    gawk '{ printf ("  <sgw:Column No=\"%d\" Width=\"80\" Title=\"%s\" Format=\"0\" Precision=\"3\">\n  </sgw:Column>\n", NR-1,$0) }'
}

write_output_headings ()
{
    sys=$1
    ${MATRIX} -q <<EOF | write_column_headings
	[u_names,y_names,x_names] = ${sys}_struc;
	printf ("Time\n");
	disp (y_names);
EOF
}

write_state_headings ()
{
    sys=$1
    ${MATRIX} -q <<EOF | write_column_headings
	[u_names,y_names,x_names] = ${sys}_struc;
	printf ("Time\n");
	disp (x_names);
EOF
}

write_cell_values ()
{
    sys=$1 ; vec=$2
    ${MATRIX} -q <<EOF
function write_cell (row,col,val)
    printf ("\n");
    printf ("  <sgw:Cell Row=\"%d\" Col=\"%d\">\n", row,col);
    printf ("    <sgw:Content>%f</sgw:Content>\n", val);
    printf ("    <sgw:Formula>%f</sgw:Formula>\n", val);
    printf ("  </sgw:Cell>\n");
endfunction

    [u_names,y_names,x_names] = ${sys}_struc;
    ncol = size(${vec}_names)(1);

    load ("${sys}_odes.dat2");
    nrow = size(mtt_data)(1);

    # write Time
    for r = 1:nrow
	write_cell (r-1,0,mtt_data(r,1));
    endfor

    if ("${vec}" == "y")
	offset = 1;
    elseif ("${vec}" == "x")
	offset = size(y_names)(1);
    endif

    for r = 1:nrow
	for c = 1:ncol
	    write_cell (r-1,c,mtt_data(r,c+offset));
	endfor
    endfor
EOF
}

file=${sys}_odes.sg

NX=`mtt_getsize ${sys} x`
NY=`mtt_getsize ${sys} y`
NTMP=`wc -l ${sys}_odes.dat2 | gawk '{print $1}'`
NROW=`expr ${NTMP} - 4`		# 4 comment lines in mtt_data

{
    write_project_header
    # states
    write_worksheet_header	"X_${sys}" ${NX} ${NROW}
    write_state_headings	${sys}
    write_cell_values		${sys} x
    write_worksheet_footer
    # outputs
    write_worksheet_header	"Y_${sys}" ${NY} ${NROW}
    write_output_headings	${sys}
    write_cell_values		${sys} y
    write_worksheet_footer
    write_project_footer
} > ${file}

Added mtt/bin/trans/dat2gdat version [11ab5c7503].








































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2gdat

# Converts a data file in data format to gplot data format

# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/04/16 11:36:03  gawthrop
## These were flagged with M on cvs update
##
## Revision 1.1  2000/12/28 12:26:15  peterg
## Put under RCS
##
## Revision 1.8  1998/09/29 20:01:27  peterg
## 4th argument for nyquist style files - ie differnt x for each y
##
## Revision 1.7  1997/12/04 22:10:32  peterg
## Handles argument list - variable names.
##
## Revision 1.6  1997/05/22 10:34:05  peterg
## Changed argument structure.
##
## Revision 1.5  1997/05/22 10:11:19  peterg
## Fixed parametetr bug
##
# Revision 1.4  1997/05/16  13:03:10  peterg
# Now selects variables to display.
#
# Revision 1.3  1996/08/26  13:02:58  peterg
# Cahged awk to awk.
#
# Revision 1.2  1996/08/15  11:49:11  peter
# Puts a blank line at the end of the file:
#  this allows user to cat files for use in gnuplot.
#
## Revision 1.1  1996/08/14 09:13:52  peter
## Initial revision
##
###############################################################

echo Creating $1_$2.gdat
rm -f $1_$2.gdat

DifferentX=$4;

# Convert multi-columns into gnuplot format -
# ie stack two columns vertically separated by blank lines

#Get the desired data index
which=`name2index $1 "$3"`
echo $1 $3 $which

if [ -z "$DifferentX" ]; then
gawk '
BEGIN{
  row=0; col=0;
}
{ 
  if (row==0) {
     N=split(which,Which,",");
    }
  row++;
  j=1;
  if (Which[1]==0) {
    x[row] = $1;
    for (i=1; i<NF; i++) {
      ycol = i+1;
      y[row,j++] = $ycol;
    }
  }
  else {
  xcol = Which[1];
  x[row] = $xcol
  for (i=1; i<N; i++) {
      ycol = Which[i+1];
      y[row,j++] = $ycol;
    }
  }
  cols=j-1;
}
END {
  rows = row;
  for (col = 1; col <= cols; col++) {
    for (row = 1; row <= rows; row++) {
      print x[row], y[row,col]
    };
  if (col<=cols) {
    printf("\n")
  }
  }
}'  which="$which" <$1_$2.dat >   $1_$2.gdat

else
gawk '
BEGIN{
  row=0; col=0;
}
{ 
  row++; cols=NF/2
    for (i=1; i<=cols; i++) {
      ycol=2*i;
      xcol=ycol-1;
      x[row,i] = $xcol
      y[row,i] = $ycol;
    }
}
END {
  rows = row;
  for (col = 1; col <= cols; col++) {
    for (row = 1; row <= rows; row++) {
      print x[row,col], y[row,col]
    };
  if (col<=cols) {
    printf("\n")
  }
  }
}'   <$1_$2.dat >   $1_$2.gdat
    
fi






Added mtt/bin/trans/dat2sdat version [e7c1c34fa1].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2sdat

# Structure file - dat to sdat conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997, 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1.4.1  2001/06/26 00:57:21  geraint
## Prints more useful name.
##
## Revision 1.1  2000/12/28 12:26:34  peterg
## Put under RCS
##
## Revision 1.1  1999/03/28 21:29:40  peterg
## Initial revision
##
###############################################################

if [ "$2" = "odes" ]; then
    which="state"
else
    which="output"
fi

awk '
BEGIN{
printf("Time");
}
{ 
  if ($1==which)
    printf(" %s(%s)", $4, $5);
}
END{
printf("\n");
}
'  SYSTEM=$1 which=$which  < $1_struc.txt

cat $1_$2.dat



Added mtt/bin/trans/dat2siag version [ce0ee2cbb1].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2siag
# Converts data to siag (scheme in a grid) format - ie columns become rows.

# Data file dat to sdat conversion
# P.J.Gawthrop February 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/04/16 22:22:06  geraint
## *** empty log message ***
##
## Revision 1.1  1999/03/29 03:35:13  peterg
## Initial revision
##
###############################################################




# This is the main transformation using awk
gawk '{
    i++
    for (j=1;j<=NF;j++)
	data[i,j]=$j;
    Cols=NF;
    Rows++;
}
END{
    for (j=1;j<=Cols;j++) {
	for (i=1;i<=Rows;i++){
	    printf("%s ", data[i,j]);
	}
	printf("\n");
    }
}'


Added mtt/bin/trans/def2write_r version [58e178bc16].
























































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: def2write.r
# Generates r code to write matrices
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.16.2.3  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.16.2.2  2002/09/10 22:09:14  geraint
## Fixed presentation of globally optimised equations (ode view).
##
## Revision 1.16.2.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.16  2002/09/03 19:34:15  geraint
## Write EdX regardless - csex is needed to create ode when not optimised.
##
## Revision 1.15  2002/08/29 15:45:20  geraint
## Tests for existence of matrix before entering shell loop.
## Tests for existence of expression before attempting to write or optimise.
##
## Revision 1.14  2002/08/09 14:34:45  geraint
## Fix to prevent numbers being formed with a decimal point in the exponent, Reduce cannot handle these.
##
## Revision 1.13  2002/07/10 17:43:05  geraint
## Added feature [ 562453 ] Optimisation of algebraic equations.
##
## Revision 1.12  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.11.2.1  2002/06/05 11:14:51  geraint
## ae.r now generated using def2write_r like cse?.r
## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r.
##
## Revision 1.11  2002/05/17 09:14:58  geraint
## Optimises each line in a separate session. Allows larger models to be built.
##
## Revision 1.10  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.9  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.8  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.7.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.7  2001/04/11 09:44:26  gawthrop
## Fixed cc and c problems to do with pow(x,y) and integers
## mtt/lib/reduce/fix_c.r is included in rdae2dae and cse2smx_lang for
## -c, -cc and -oct options
##
## Revision 1.6  2000/11/29 20:48:53  peterg
## Zapped unnecessary Npar creation
##
## Revision 1.5  2000/11/09 10:12:24  peterg
## Removed debugging line
##
## Revision 1.4  2000/10/14 16:19:54  peterg
## Just optimize one line at a time ...
##
## Revision 1.3  2000/10/11 09:07:17  peterg
## Added csex rep (cse without E)
##
## Revision 1.2  2000/10/10 21:02:17  peterg
## Added cse reps
##
## Revision 1.1  2000/10/10 09:07:32  peterg
## Initial revision
##
###############################################################

optimise=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-fixcc )
	    include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'` ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

sys=$1 # System name
rep=$2 # System representation

# Inform User
echo Creating $1_$2_write.r

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nxx=`mtt_getsize $sys xx` # States x States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Outputs 
Nyz=`mtt_getsize $sys yz` # Zero outputs
#Npar=`wc -l $sys\_sympar.txt | gawk '{print $1}'`

# Set up representation-specific stuff
case $rep in
    ae)
	matrices='Yz'
	ns="$Nyz"
	ms="1"
	;;
    cse)
        matrices='EdX E'
        ns="$Nx $Nx"
        ms="1 $Nx"
	;;
    csex)
        matrices='EdX'
        ns="$Nx"
        ms="1"
	;;
    cseo)
        matrices='Y'
        ns="$Ny"
        ms="1"
	;;
    lde)
        matrices='L'
        ns="$Nyz"
        ms="1"
	;;
    ldeo)
        matrices='Y Yz'
        ns="$Ny $Nyz"
        ms="1 1"
	;;
    ode)
        matrices='dX'
        ns="$Nx"
        ms="1"
	;;
    odeo)
        matrices='Y'
        ns="$Ny"
        ms="1 1"
	;;
    sm)
        matrices='A B C D'
        ns="$Nx $Nx $Ny $Ny"
        ms="$Nx $Nu $Nx $Nu"
	;;
    *)
        echo def2write_r: representation $rep not recognised
        exit
esac

# Remove log files
rm -f def2write_r1.log def2write_r2.log

# Write out the code
echo "" > $1_$2_write.r

echo 'off echo$' >> $1_$2_write.r
echo 'load gentran$' >> $1_$2_write.r

for matrix in $matrices; do
    ignore_matrix="no"
    if [ "$matrix" = "E" ]; then
	matrix_exists=`grep -i MTTE ${sys}_dae.r | wc -l | gawk '{print $1}'`
	if [ ! $matrix_exists -gt 0 ]; then
	    ignore_matrix="yes"
	    n=`first "$ns"`; ns=`rest "$ns"` 
	    m=`first "$ms"`; ms=`rest "$ms"`
 	    is=`n2m 1 $n`;
	    echo "write \"% Begin Matrix MTTE\"$" >> $1_$2_write.r
	    for i in $is; do
		echo 'write'
		name=`echo MTTE'('$i','$i')'`
		echo '  '$comma$name ':=' $name '$'
	    done >> $1_$2_write.r
	    echo "write \"% End Matrix MTTE\"$" >> $1_$2_write.r
	fi
    fi
    if [ ! "$ignore_matrix" = "yes" ]; then
	n=`first "$ns"`; ns=`rest "$ns"` 
	m=`first "$ms"`; ms=`rest "$ms"`
	is=`n2m 1 $n`; 
	js=`n2m 1 $m`; 
	echo "write \"% Begin Matrix MTT${matrix}\"$" >> $1_$2_write.r
	if [ $n -ge 1 ]; then
	    for i in $is; do
		for j in $js; do
		    echo 'write'
		    name=`echo MTT$matrix'('$i','$j')'`
		    echo '  '$comma$name ':=' $name '$'
		done
	    done
	fi >> $1_$2_write.r
	echo "write \"% End Matrix MTT${matrix}\"$" >> $1_$2_write.r
    fi
done
echo ';END;'                           >>$1_$2_write.r

Added mtt/bin/trans/def_r2m version [b27ff6c61a].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: def_r2m
# transforms definitions from reduce to m file.
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/25 10:21:37  peterg
## Entirely rewritten
##
## Revision 1.1  1998/07/25 07:10:41  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_def.m

# Remove the old log file
rm -f def_r2m.log


# Header
cat <<EOF > $1_def.m
function  [nx,ny,nu,nz,nyz] = $1_def;
% function  [nx,ny,nu,nz,nyz] = $1_def;
% System $1, representation def, language m
% File $1_def.m;
% Generated by MTT on `date`;
%
EOF

# Constants
Nx=`grep "MTTNx " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Ny=`grep "MTTNy " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nu=`grep "MTTNu " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nz=`grep "MTTNz " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nyz=`grep "MTTNyz " <$1_def.r | gawk '{print $3}' | sed 's/;//'`


cat<<EOF >> $1_def.m 
  nx = $Nx;
  ny = $Ny;
  nu = $Nu;
  nz = $Nz;
  nyz = $Nyz;
EOF

Added mtt/bin/trans/dia2abg.pl version [c5d3faf6c4].




























































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/usr/bin/perl -w

#----------------------------------------------------------------------------
# dia2abg.pl
# Copyright (C) 2002; David Hoover.
# Modified      2004  Geraint Bevan.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# 
# The GNU General Public License should be found in the file license.txt.
# For more information about free software, visit http://www.fsf.org/
#----------------------------------------------------------------------------

#############################################################################
# Given a DIA diagram, the script has functions that perform the following
# MTT (model transformation tools) functions:
# 1. Write a _cmp.txt file containing component types:names
# 2. Write a _ibg.m file containing an acausal bond graph suitable for 
#    processing by MTT.
# 3. Modify a diagram by changing causality as desired.
#############################################################################

#----------------------------------------------------------------------------
# Dia uses a unique id for each object.
# get_component_data and get_bond_data read the xml file and collect
# important information about component and bond id's, component
# names, and bond connectivity.  These data structures are described here:

# The %component_id_tag hash provides component names and types:
#
# key=component_id
# value=component type:name

# 'start' ALWAYS refers to dia's interpretation of start.  This means,
# when you draw a line or an arrow, 'start' is the point where you
# initally press down the mouse button.  'end' is the point where you
# release the mouse button.  'start' and 'end' have nothing to do with
# a bond's direction.  A half arrow could be on a dia 'start' or 'end'
# point.

# The %bond_id_start_id and %bond_id_end_id hashes provides
# connectivity info for line start points and end points:
#
# key=bond_id
# value=component_id

# The %bond_id_arrow_on_start hash is a boolean that indicates whether
# the power arrow (half head) is on the dia line start point.
#
# key=bond_id
# value=boolean arrow_on_start

# The %bond_id_effort_causality hash is a boolean that provides the
# effort arrow-oriented causality.
#
# key=bond_id
# value=arrow-oriented effort causality.

# The %bond_id_flow_causality hash is a boolean that provides the
# flow arrow-oriented causality.
#
# key=bond_id
# value=arrow-oriented flow causality.

# %mtt_bond_id_index provides a unique positive integer index for each
# Dia bond ID.  The index is written to the ibg.m file for mtt.

# The %component_id_type, %component_id_name, %component_id_reps hashes
# store the information from _cmp.m for each component
#
# key=component_id
# value=component type, name or number of repetitions

#----------------------------------------------------------------------------

#----------------------------MAIN PROGRAM------------------------------------
use strict;
use Getopt::Long;
use XML::DOM;

my (%component_id_tag, %bond_id_start_id, %bond_id_end_id,
    $objects, %mtt_bond_id_index,
    %bond_id_arrow_on_start, %bond_id_flow_causality, %bond_id_effort_causality,
    %bond_id_start_label,%bond_id_end_label);

my (%component_id_type, %component_id_name, %component_id_reps);

# Parse user options:
my $diagram_name		= '';
my $dia_input_file		= '';
my $dia_output_file		= '';
my $component_list_file		= '';
my $debug			= 0;
my $create_component_list	= 0;
my $create_ibg			= 0;
my $ibg_file			= '';
my $change_flow_causality	= '';
my $change_effort_causality	= '';
GetOptions ('diagram_name=s'		=> \$diagram_name,
	    'dia_input_file=s'		=> \$dia_input_file,
	    'dia_output_file=s'		=> \$dia_output_file,
	    'component_list_file=s'	=> \$component_list_file,
	    'debug'			=> \$debug,
	    'create_component_list'	=> \$create_component_list,
	    'create_ibg'		=> \$create_ibg,
	    'ibg_file=s'		=> \$ibg_file,
	    'change_flow_causality=s'	=> \$change_flow_causality,
	    'change_effort_causality=s'	=> \$change_effort_causality,
	    );

die usage() if $diagram_name eq '';

# Use defaults if necessary:
$dia_input_file      = $diagram_name . "_abg.dia" if ($dia_input_file      eq '');
$dia_output_file     = $diagram_name . "_cbg.dia" if ($dia_output_file     eq '');
$ibg_file            = $diagram_name . "_ibg.m"   if ($ibg_file            eq '');
$component_list_file = $diagram_name . "_cmp.txt" if ($component_list_file eq '');

# Start Parsing XML, and creating files:
my $dom = new XML::DOM::Parser;
my ($doc);

$doc = $dom->parsefile($dia_input_file);
$objects = get_objects_node($doc,"Bond Graph");

get_component_data($objects);
parse_component_data();

get_bond_data($objects);

create_component_list() if ($create_component_list);

if ($create_ibg) {
    open (OUT,">$ibg_file") ||
	die "Cannot open $ibg_file for writing.\n";
    output_ibg();
    
}   

if ($change_flow_causality ne '' || $change_effort_causality ne '') {
    open (DIA_OUT,">$dia_output_file") ||
	die "Cannot open $dia_output_file for writing.\n";
    print DIA_OUT $doc->toString;
    close DIA_OUT;
}

exit 0;


#----------------------------SUBROUTINES-------------------------------------
sub create_component_list {
    my ($type, $name);

    print_debug("CREATING unique_raw_list...\n");
    open (RAW,">$component_list_file") ||
	die "Cannot open $component_list_file for writing.\n";

    my (%reverse_component_id_tag) = reverse (%component_id_tag);
    foreach my $val (sort values(%component_id_tag)) {	
	my ($id, $type);
	$id = $reverse_component_id_tag{$val};
	$type = $component_id_type{$id};
	$_ = $val;
	id_cleaner();
	$val =  $_;
	print RAW $val . "\n";
    }
    close(RAW);
}

sub get_objects_node {
    my ( $doc_node, $layer_name )= @_;
    my ($root,$layer_node,$objects);

    $root = get_first_element_subnode($doc_node);
    die "could not find top-level element dia_diagram.\n"
	unless $root->getTagName eq 'dia:diagram';
    
    $layer_node = get_first_subnode_by_nodename_attribute(0,$root,"dia:layer","name",$layer_name);
    die "I found no dia:layer named $layer_name.  Are you sure the diagram has one?\n" unless
	$layer_node->getTagName eq 'dia:layer' &&
	$layer_node->getAttributeNode("name")->getValue eq $layer_name;
    
    $objects = $layer_node->getElementsByTagName('dia:object');

    return $objects;
}

sub output_ibg_header {
    my ($date);
    $date = `date`; chomp($date);

    print OUT <<"EOF";
## -*-octave-*- put Emacs into Octave mode

function [${diagram_name}] =  ${diagram_name}_ibg

  ## Intermediate bond graph representation of $diagram_name
  ## Generated by MTT on $date

  ## head refers to the harpoon end of a bond
  ## tail refers to the other end of a bond
  ## causality.? is the end at which ? is imposed


EOF
}

sub output_ibg_footer {
    print OUT <<"EOF";
endfunction
EOF
}

sub output_ibg {
    my ($key,$component,$type,$name,
	%reverse_mtt_bond_id_index,$mtt_bond_id,$dia_bond_id,
	@bonds,
	$bond_id,$start,$end,$id,
	$head,$head_component,$head_type,$head_name,
	$tail,$tail_component,$tail_type,$tail_name,
	$start_label,$end_label,
	$head_label,$tail_label,
	$effort_causality,$flow_causality);

    output_ibg_header();

    %reverse_mtt_bond_id_index = reverse (%mtt_bond_id_index);

    @bonds = (sort keys (%reverse_mtt_bond_id_index));
    foreach $mtt_bond_id (@bonds) {
 
	$dia_bond_id = $reverse_mtt_bond_id_index{$mtt_bond_id};

	$start = $bond_id_start_id{$dia_bond_id};
	$end   = $bond_id_end_id  {$dia_bond_id};

	if ($bond_id_arrow_on_start{$dia_bond_id}) {
	    $head = $end;
	    $tail = $start;
	} else {
	    $head = $start;
	    $tail = $end;
	}

	$start_label = $bond_id_start_label{$dia_bond_id};
	$end_label   = $bond_id_end_label  {$dia_bond_id};

	# treat label as a comment if not enclosed by [ ]
	if ($start_label !~  /\[.*\]/) {
	    $start_label = "[]";
	}
	if ($end_label !~ /\[.*\]/) {
	    $end_label = "[]";
	}

	if ($bond_id_arrow_on_start{$dia_bond_id}) {
	    $head_label = $end_label;
	    $tail_label = $start_label;
	} else {
	    $head_label = $start_label;
	    $tail_label = $end_label;
	}

	$head_component = "$component_id_type{$head}:$component_id_name{$head}";
	$tail_component = "$component_id_type{$tail}:$component_id_name{$tail}";

	$effort_causality = $bond_id_effort_causality{$dia_bond_id};
	$flow_causality   = $bond_id_flow_causality  {$dia_bond_id};

	for ($effort_causality) {
	    if (/-1/) { $effort_causality = "tail";}
	    if (/0/) { $effort_causality = "none";}
	    if (/1/) { $effort_causality = "head";}
	}
	for ($flow_causality) {
	    if (/-1/) { $flow_causality = "head";}
	    if (/0/) { $flow_causality = "none";}
	    if (/1/) { $flow_causality = "tail";}
	}
		       
	print OUT
	    "  ## bond $mtt_bond_id \n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "head.component = \"${head_component}\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "tail.component = \"${tail_component}\";\n";

	print OUT
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "head.ports = \"$head_label\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "tail.ports = \"$tail_label\";\n";

	print OUT
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "causality.effort = \"$effort_causality\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "causality.flow = \"$flow_causality\";\n\n";
    }
    
    output_ibg_footer();
}

sub get_component_data {
    my ( $objects_node )= @_;
    my($obj,$id,$attr,$comp,$strattr,$str_elem,$string);

    print_debug("READING COMPONENTS FROM $dia_input_file...\n");
    for my $i (0..$objects_node->getLength-1) {
      $obj = $objects_node->item($i);
      next if ($obj->getAttributeNode("type")->getValue ne "BondGraph - MTT port");
      
      $id = $obj->getAttributeNode("id")->getValue;
      print_debug($id . "\n");
      
      $attr = get_first_subnode_by_nodename_attribute(0,$obj,"dia:attribute","name","text");
      $comp = get_first_subnode_by_nodename_attribute(0,$attr,"dia:composite","type","text");
      $strattr = get_first_subnode_by_nodename_attribute(0,$comp,"dia:attribute","name","string");
      $str_elem = get_first_element_subnode($strattr);
      $string = get_first_text_subnode($str_elem);
      $component_id_tag{$id} = $string->getData;
  }
    die "There are no components!\n" unless keys(%component_id_tag) > 0;
}

sub parse_component_data {
    my (%anon_index, $id, $component);

    while (($id, $component) = each (%component_id_tag)) {
	$_ = $component;
	id_cleaner();
	$component = $_;
	my ($type_name, $repetitions) = split (/\*/, $component);
	if (! $repetitions) {
	    $type_name = $component;
	    $repetitions = 1;
	}
	my ($type, $name) = split (/:/, $type_name);
	if (! $name) {
	    $type = $type_name;
	    if (! defined ($anon_index{$type})) {
		$anon_index{$type} = 1;
		$name = "mtt${type}";
	    } else {
		my $num = ++$anon_index{$type};
		$name = "mtt${type}_${num}";
	    }
	}
	$component_id_type{$id} = $type;
	$component_id_name{$id} = $name;
	$component_id_reps{$id} = $repetitions;
    }
}

# Dia stores its attributes in a strange way, not using typical xml attributes.
sub get_dia_attribute_value {
    my ($type, $attribute_node )= @_;
    my ($subnode);
    $subnode = get_first_subnode_by_nodename_attribute(0,$attribute_node,$type);

    return $subnode->getAttributeNode("val")->getValue;
}

# Dia stores its attributes in a strange way, not using typical xml attributes.
sub set_dia_attribute_value {
    my ($type, $attribute_node, $new_value )= @_;
    my ($subnode);
    $subnode = get_first_subnode_by_nodename_attribute(0,$attribute_node,$type);

    $subnode->setAttribute(val => $new_value);
#    return $subnode->getAttributeNode("val")->getValue;
}

sub get_dia_attribute_string {
    my ($attribute) = @_;
    my ($str_elem, $string);
    $str_elem = get_first_element_subnode($attribute);
    $string = get_first_text_subnode($str_elem)->getData;
    $string =~ s/\#//g;
    return $string;
}

sub get_arrow_info {
    my ( $object_node, $id, $id_index )= @_;
    my($attribute,$attributes);

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "arrow_on_start");
    $bond_id_arrow_on_start{$id} = defined($attribute) ? get_dia_attribute_value("dia:boolean",$attribute) : 0;

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "effort_causality");
    change_causality($id_index, $attribute, $change_effort_causality);
    $bond_id_effort_causality{$id} = defined($attribute) ? get_dia_attribute_value("dia:enum",$attribute)-1 : 1;

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "flow_causality");
    change_causality($id_index, $attribute, $change_flow_causality);
    $bond_id_flow_causality{$id} = defined($attribute) ? get_dia_attribute_value("dia:enum",$attribute)-1 : 1;

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "start_label");
    $bond_id_start_label{$id} = defined($attribute) ? get_dia_attribute_string($attribute) : "[]";

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "end_label");
    $bond_id_end_label{$id} = defined($attribute) ? get_dia_attribute_string($attribute) : "[]";
}

sub change_causality() {
    my ($id_index, $attribute_node, $causality_change_string)=@_;
    my ($mtt_id, $arrow_oriented_causality);

    foreach my $id_causality (split(/;/,$causality_change_string)) {
	($mtt_id, $arrow_oriented_causality) = split(/:/,$id_causality);
	if ($mtt_id eq "all" || $id_index == $mtt_id) {
	    set_dia_attribute_value("dia:enum",$attribute_node,$arrow_oriented_causality + 1);
	}
    }
}

sub get_bond_data {
    my ( $objects_node )= @_;
    my ($id_index, $obj, $id, $connections, $connection, $to, $handle,
	$connections_att);

    print_debug("READING BONDS FROM $dia_input_file...\n");
    $id_index = 0;
    for my $i (0..$objects_node->getLength-1) {
      $obj = $objects_node->item($i);
      next if ($obj->getAttributeNode("type")->getValue ne "BondGraph - MTT bond");
      
      $id = $obj->getAttributeNode("id")->getValue;
      
      print_debug("Bond " . $id . ":\n");
      $mtt_bond_id_index{$id} = ++$id_index;
      
      get_arrow_info($obj,$id,$id_index);
      print_debug("Flow causality ($id):" . $bond_id_flow_causality{$id} . "\n");
      print_debug("Effort causality ($id):" . $bond_id_effort_causality{$id} . "\n");
      print_debug("Arrow on start ($id):" . $bond_id_arrow_on_start{$id} . "\n");

      # get connection info
      $connections_att = $obj->getElementsByTagName('dia:connections');
      die "A bond without connections exists!\n"
	  unless $connections_att->getLength > 0;

      $connections = $connections_att->item(0)->getElementsByTagName('dia:connection');
      die "Bond $id does not have two connections!\n" unless
	  $connections->getLength == 2;

      for my $j (0..$connections->getLength-1) {
	  
	  $connection = $connections->item($j);
	  $handle = $connection->getAttributeNode("handle")->getValue;
	  $to = $connection->getAttributeNode("to")->getValue;
	  
	  print_debug("handle " . $handle . "\n");
	  print_debug("to " . $to . "\n");
	  
	  if ($handle eq "0") {
	      $bond_id_start_id{$id} = $to;
	  } else {
	      $bond_id_end_id{$id} = $to;
	  }
      }
  }
    die "There are no bonds!\n" unless keys(%mtt_bond_id_index) > 0;
}

# if($relax), then this routine will return 'undef' instead of dying, if valid node not found.
sub get_first_subnode_by_nodename_attribute {
    my ( $relax, $node, $nodename, $key, $value)= @_;
    my ($subnodes,$subnode);

    $subnodes = $node->getChildNodes;
    
    for my $k (0..$subnodes->getLength-1) {
      next if ($subnodes->item($k)->getNodeType != ELEMENT_NODE);
      next if ($subnodes->item($k)->getNodeName ne $nodename);
      $subnode = $subnodes->item($k);
      next if defined($value) && defined($key) &&
	  ($subnode->getAttributeNode($key)->getValue ne $value);
      
      return $subnode;
  }
    if($relax) {
	return undef;
    } else {
	die "I found no subnode of " . $node->getNodeName .
	    " named $nodename with key/value pair: ($key,$value).\n" unless
	    $subnode->getTagName eq $nodename &&
	    $subnode->getAttributeNode($key)->getValue eq $value;
    }
}

sub get_first_element_subnode {
    my ( $node )= @_;
    my ($subnodes,$subnode);

    $subnodes = $node->getChildNodes;
    
    for my $k (0..$subnodes->getLength-1) {
      next if ($subnodes->item($k)->getNodeType != ELEMENT_NODE);
      $subnode = $subnodes->item($k);

      return $subnode;
  }
    die " I found no element subnode of " . $node->getNodeName . "." unless
	$subnode->getNodeType == ELEMENT_NODE;
}

sub get_first_text_subnode {
    my ( $node )= @_;
    my ($subnodes,$subnode);

    $subnodes = $node->getChildNodes;
    
    for my $k (0..$subnodes->getLength-1) {
      next if ($subnodes->item($k)->getNodeType != TEXT_NODE);
      $subnode = $subnodes->item($k);

      return $subnode;
  }
    die " I found no text subnode of " . $node->getNodeName . "." unless
	$subnode->getNodeType == TEXT_NODE;
}

sub id_cleaner {
    s/#?([^#]*)#?/$1/;
}

sub print_debug {
    print STDERR $_[0] if ($debug);
}

sub usage {
    return 
	"\n" .
	"Usage: dia2abg.pl --diagram_name <diagram_name> [options]\n" .
	"Options:\n" .
	"\t--dia_input_file  <dia_input_file>\n" .
	"\t--dia_output_file <dia_output_file>\n" .
	"\t--component_list_file\n" .
	"\t--create_component_list\n" .
	"\t--create_ibg\n" .
	"\t--debug\n" .
	"\t--ibg_file <ibg_file>\n" .
	"\t--change_flow_causality <bond causality spec>\n" .
	"\t--change_effort_causality <bond causality spec>\n" .
	"\n" .
	"\t\tBond causality spec:\n" .
	"\t\t 'bond:causality;bond:causality;...'\n" .
	"\t\tbond:\n" .
	"\t\t [mtt_bond_id|all]\n" .
	"\t\tcausality:\n" .
	"\t\t [-1|0|1]\n" .
	"\n" .
	"\t\tCausality is arrow-oriented-causality.\n" .
	"\t\tAny causality changes are made BEFORE further processing.\n" .
	"\n"
}

Added mtt/bin/trans/dir2paths version [45c39d446b].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dir2paths
# Finds paths of all valid MTT examples

# P.J.Gawthrop Mar 98
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/11/10 17:12:15  peterg
## Removed sorting
##
## Revision 1.1  1998/03/11 10:32:35  peterg
## Initial revision
##
###############################################################


dotdot=$2 # Set to ../ if we are in MTT_work


# Create paths for all valid examples - ie dir name is system name
find $dotdot$1 -name '*_abg.fig' -print |\
  gawk '{
   N=split($1,name,"/"); 
   printf("%s", name[1]);
   for (i=2;i<N;i++) printf("/%s", name[i]); 
   printf(" %s %s\n", name[N-1], name[N]);
  }' |\
  gawk '{
  correctname=sprintf("%s_abg.fig", $2);
  if ($3==correctname) print  $1,$2
  }'

Added mtt/bin/trans/dir2rep version [bc594f5e2a].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dir2rep
# Creates a rep file for a directory

# P.J.Gawthrop Dec 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/12/28 12:26:45  peterg
## *** empty log message ***
##
## Revision 1.2  1998/03/11 10:32:11  peterg
## Now uses dir2paths transformation
##
## Revision 1.1  1998/02/05 13:31:25  peterg
## Initial revision
##
###############################################################

dotdot=$2 # Set to ../ if we are in MTT_work

# Inform user
echo "Creating $1_rep.txt (Directory version)"

# Headings
echo "% Verbal description for directory $1 ($1_rep.txt)"> $1_rep.txt
echo "% Generated by MTT on" `date`. >> $1_rep.txt                  	   

# Create paths for all valid examples - ie dir name is system name
dir2paths $1 $2 | sed 's/Introduction/AAAAA/g' | sort | sed 's/AAAAA/Introduction/g' | \
gawk '{
     print "mtt -t -d " $1,$2 " rep tex";
  }' >> $1_rep.txt

Added mtt/bin/trans/dm2fr_m version [905d7cb644].










































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm2fr_m

# Transformation: descriptor matrix to frequency response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15  2003/05/08 18:46:45  gawthrop
## Fixed range bug by using isfield in place of exists
##
## Revision 1.14  2000/05/20 15:35:18  peterg
## Parameterised version
##
## Revision 1.13  1998/09/03 09:12:32  peterg
## Removed debugging lines
##
## Revision 1.12  1998/09/02 12:02:14  peterg
## Added mttinput paramater
##
## Revision 1.11  1998/08/11 13:32:42  peterg
## Lowercase mttLAST etc
##
## Revision 1.10  1998/07/27 20:27:25  peterg
## Now get parameters for simpar file.
##
## Revision 1.9  1998/02/26 15:12:26  peterg
## Removed parameter stuff
##
# Revision 1.8  1996/08/30  14:54:36  peter
# Took back lock.
#
## Revision 1.7  1996/08/24  14:23:00  peter
## Global parameter passing.
## Proper error handling.
#
## Revision 1.6  1996/08/16 14:26:07  peter
## Fixed multi-output bug.
## Made sure that u0 is ok.
##
## Revision 1.5  1996/08/15 16:23:02  peter
## Now uses W in place of w for consistancy with time responses.
##
## Revision 1.4  1996/08/15 11:52:42  peter
## Now creats a number of versions:
## fr 	complex frequency response
## lmfr 	log  magnitude of fr
## lpfr  	phase of fr
## nyfr  	real and imag parts - Nyquist style
## nifr 	Nichols style.
##
## Revision 1.3  1996/08/11 19:08:08  peter
## Parameter passing now enabled.
##
## Revision 1.2  1996/08/11 09:32:12  peter
## Now takes the numpar parameters correctly
##
## Revision 1.1  1996/08/10 14:11:11  peter
## Initial revision
##
###############################################################

echo Creating $1_fr.m
echo Creating $1_lmfr.m
echo Creating $1_lpfr.m
echo Creating $1_nyfr.m
echo Creating $1_nifr.m

#if [ "$2" = "" ]; 
#then
#  PARAMS='W=logspace(-1,2,100); u0=zeros(nu,1); u0(1)=1;'
#  echo Using default parameter $PARAMS
#else
#  PARAMS=$2;
#fi

$MATRIX << EOF > dm2fr_m.log 2>mtt_error.txt

# Data
  mttpar=$1_numpar;

# Simulation parameters
  simpar=$1_simpar;

  [nx,ny,nu,nz,nyz] = $1_def;

  %Defaults
  
  if (isfield(simpar,"wmin")==0)
    simpar.wmin = -1;
  end;

  if (isfield(simpar,"wmax")==0)
    simpar.wmax = 2
  end;

  if (isfield(simpar,"wsteps")==0)
    simpar.wsteps = 100;
  end;

  W = logspace(simpar.wmin,simpar.wmax,simpar.wsteps)';
  if (isfield(simpar,"mttinput")==0)
    mttinput = 1;
  end;
  mttu0 = zeros(nu,1);
  mttu0(mttinput) = 1;

  [n,m]=size(W);
  if m>n
    W=W';
  end;

  [n,m]=size(mttu0);
  if m>n
    mttu0=mttu0';
  end;

  [A,B,C,D,E] = $1_dm(mttpar);
  fr = dm2fr(A,B,C,D,E,W,mttu0);
  lw = log10(W);
  lmfr = log10(abs(fr));
  pfr = angle(fr)*180/pi;

% Complex frequency response
  write_matrix([W fr], "$1_fr");

% Log magnitude v log frequency
  write_matrix([lw lmfr], "$1_lmfr");

% Angle v log frequency
  write_matrix([lw pfr], "$1_lpfr");

% Nyquist style
  re = real(fr);
  im = imag(fr);
  nyq = [re(:,1) im(:,1)];
  for i = 2:ny
    nyq = [nyq re(:,i) im(:,i)];
  end;
  write_matrix(nyq, "$1_nyfr");

% Nichols style
  re = lmfr;
  im = pfr;
  nic = [im(:,1) re(:,1)];
  for i = 2:ny
    nic = [nic im(:,i) re(:,i)];
  end;
  write_matrix(nic, "$1_nifr");

EOF

# Now invoke the standard error handling,"
mtt_error mtt_error.txt






Added mtt/bin/trans/dm2ir_m2dat version [d3255be9a0].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2ps

# Tramsforms descriptor matrix rep to frequency response dat.


# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1996/08/11 19:48:29  peter
## Parameter passing added.
##
## Revision 1.2  1996/08/11 10:40:00  peter
## Now handles e and NaN numbers.
##
## Revision 1.1  1996/08/10 14:15:03  peter
## Initial revision
##
###############################################################

echo Creating $1_ir.dat

if [ "$2" = "" ]; 
then
  PARAMS='t=[0:0.1:10]'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi


$MATRIX << EOF | gawk '$1 !~ /[A-MO-Zb-cf-z]/ && NF>0 {print} '  >$1_ir.dat

  $PARAMS;
  [n,m]=size(t);
  if m>n
    t=t';
  end;

  [A,B,C,D,E] = $1_dm($1_numpar);
  y = dm2ir(A,B,C,D,E,t);

  [Ny,Nu]=size(D);
  NN = Ny*Nu;

  xy = [t y(:,1)];
  for i=2:NN
    xy = [xy t y(:,i)];
  end;
xy

EOF

Added mtt/bin/trans/dm2tf_r version [60f01453cb].


























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm2tf_r
# Reduce  descriptor matrices to transfer function
# P.J.Gawthrop 8th May 1991, Dec 1993, April 1994.
# Copyright (c) P.J.Gawthrop, 1991, 1993, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/03/27 15:00:23  peterg
## reduce ---> symbolic
##
## Revision 1.1  1996/08/25 10:09:55  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_tf.r

# Remove the old log file
rm -f dm2tf_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >dm2tf_r.log << EOF

%ON FLOAT;

IN "$1_def.r";
IN "$1_dm.r";
IN "$1_subs.r";

OFF Echo;
OFF Nat;

%create sE-A
%MTT_SEA := s*MTTE-MTTA;

%Find the denominator of the TF - det(sE-A);
%comden := det(MTT_SEA);

%Find the Adjoint transpose.
%matrix AdjT(MTTNx,MTTNx);
%FOR i := 1:MTTNx DO
%  BEGIN
%  FOR j := 1:MTTNx DO
%    AdjT(i,j) := cofactor(MTT_SEA,i,j);
%  END;

%Adj := TP(AdjT);

%Find the numerator matrix
%Num := MTTC*Adj*MTTB + MTTD*comden;


%Create the transfer function matrix
MTTTF := MTTD;
IF MTTNy>0 THEN MTTTF := MTTTF + (MTTC * ((s*MTTE-MTTA)^-1) * MTTB);

%MTTTF := Num/comden;


OUT "$1_tf.r";

%Declare the transfer function matrix
write "matrix MTTTF(", MTTNy, ",", MTTNu, ")$"$

%And write it.
%MTTTF := MTTTF;
FOR i := 1:MTTNy DO
  BEGIN
  FOR j := 1:MTTNu DO
    IF MTTTF(i,j) NEQ 0 THEN write "MTTTF(", i, ",", j, ") := ", MTTTF(i,j)$
  END;

write ";END;"$
SHUT "$1_tf.r";

EOF

# Now invoke the standard error handling.
mtt_error_r dm2tf_r.log

Added mtt/bin/trans/dm_r2m version [dc94c23287].




































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm_r2m
# Reduce descriptor state-space A,B,C,D and E matrices to Matlab
# P.J.Gawthrop 29th July 1990, 6th Feb 1991, 28 May 1991, Dec 1993, Jan 94
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993,1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1998/04/13 11:01:55  peterg
## Now uses generic header : matlab_header
##
# Revision 1.6  1997/04/16  13:43:29  peterg
# Added matrix dimenensions
#
# Revision 1.5  1997/02/24  14:44:28  peterg
# Ignores numerical parameters in global list.
#
## Revision 1.4  1996/08/24 14:16:25  peter
## Global parameter passing.
##
## Revision 1.3  1996/08/18 12:02:46  peter
## Fixed bug when some matrices are empty.
##
## Revision 1.2  1996/08/12 20:22:20  peter
## Paramaters passed via an internal call to _numpar.
## _args script can overide these parameters - sneaky.
##
## Revision 1.1  1996/08/12 19:09:13  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_dm.m

# Remove the old log file
rm -f dm_r2m.log

# Use reduce to accomplish the transformation
reduce >dm_r2m.log << EOF

ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab

%Read in the definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read in the parameter file
%%in "$1_sympar.r";

%Read the reduce state-space A,B,C and D matrices file
in "$1_dm.r";

IF MTTNvar>0 THEN
BEGIN
  write "% Set the parameters";
  write "global ...;;";
  FOR i := 1:MTTNvar DO
    BEGIN
      IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
        % Do nowt
      END
      ELSE  
      BEGIN
        write MTTVar(i,1), " ...";
      END;
    END;
    write " ";
END;


%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

MTTN := MTTNx + 2*MTTNz + MTTNyz;
write "MTTA = zeros(", MTTN, ",", MTTN, ");";
write "MTTB = zeros(", MTTN, ",", MTTNu, ");";
write "MTTC = zeros(", MTTNy, ",", MTTN, ");";
write "MTTD = zeros(", MTTNy, ",", MTTNu, ");";
write "MTTE = zeros(", MTTN, ",", MTTN, ");";

OUT "$1_dm.1";

ON NERO;	% Suppress zero elements.
MTTA := MTTA;
MTTB := MTTB;
MTTC := MTTC;
MTTD := MTTD;
MTTE := MTTE;

SHUT "$1_dm.1";


EOF

# Header
matlab_header $1 dm 'A,B,C,D,E'> $1_dm.m

#Define array sizes.
grep -v 'function' $1_def.m | grep -v '%' >>  $1_dm.m
echo 'mtta = zeros(nx+nyz+2*nz,nx+nyz+2*nz);' >>  $1_dm.m
echo 'mttb = zeros(nx+nyz+2*nz,nu);' >>  $1_dm.m
echo 'mttc = zeros(ny,nx+nyz+2*nz);' >>  $1_dm.m
echo 'mttd = zeros(ny,nu);' >>  $1_dm.m
echo 'mtte = zeros(nx+nyz+2*nz,nx+nyz+2*nz);' >>  $1_dm.m


#Code
cat $1_dm.1 >> $1_dm.m


rm -f $1_dm.1


Added mtt/bin/trans/dm_r2tex version [acd65c348e].




































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm_r2tex
# Reduce descriptor matrices to LaTex descriptor matrices.
# P.J.Gawthrop 9 June 1990, 8th July 1990, 14 Feb 1991, 10th May 1991, 4th June 1991
# Copyright (c) P.J.Gawthrop, 1990, 1991.

#Inform user
echo Creating $1_dm.tex

# Remove the old log file
rm -f dm_r2tex.log

# Use reduce to accomplish the transformation
reduce >dm_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Number of descriptor variables
MTTN := MTTNx + 2*MTTNz + MTTNyz;

%Read the descriptor matrices file
in "$1_dm.r";

OFF Echo;
OFF Nat;

OUT "$1_dm.tex";

%Write out the descriptor matrices.
write "%Descriptor matrices $1";
write "%File: $1_dm.tex";
write"";

write "%Descriptor matrices";

%IF (MTTNz+MTTNyz) NEQ 0 THEN
%BEGIN
%  write "%  - E matrix";
%  write "\begin{equation}";
%  write "MTTE = MTTI_0(", MTTNx+MTTNz, ",", MTTNz+MTTNyz, ")";
%  write "\end{equation}";
%END;


IF MTTN NEQ 0 THEN
IF (MTTNz+MTTNyz) > 0 THEN
BEGIN
write "%  - E matrix";
write "\begin{equation}";
write "MTTE = \begin{pmatrix}";
	FOR Row := 1:MTTN DO
	BEGIN
		FOR Col := 1:MTTN DO
		BEGIN
			Write "{", MTTE(Row,Col), "}";
			IF Col<MTTN THEN Write "&"
		END;

	IF Row<MTTN THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;



IF MTTN NEQ 0 THEN
BEGIN
write "%  - A matrix";
write "\begin{equation}";
write "MTTA = \begin{pmatrix}";
	FOR Row := 1:MTTN DO
	BEGIN
		FOR Col := 1:MTTN DO
		BEGIN
			Write "{", MTTA(Row,Col), "}";
			IF Col<MTTN THEN Write "&"
		END;

	IF Row<MTTN THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;

IF MTTN NEQ 0 THEN IF MTTNu NEQ 0 THEN
BEGIN
write "%  - B matrix";
write "\begin{equation}";
write "MTTB = \begin{pmatrix}";
	FOR Row := 1:MTTN DO
	BEGIN
		FOR Col := 1:MTTNu DO
		BEGIN
			Write "{", MTTB(Row,Col), "}";
			IF Col<MTTNu THEN Write "&"
		END;

	IF Row<MTTN THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;

IF MTTN NEQ 0 THEN IF MTTNy NEQ 0 THEN
BEGIN
write "%  - C matrix";
write "\begin{equation}";
write "MTTC = \begin{pmatrix}";
	FOR Row := 1:MTTNy DO
	BEGIN
		FOR Col := 1:MTTN DO
		BEGIN
			Write "{", MTTC(Row,Col), "}";
			IF Col<MTTN THEN Write "&"
		END;

	IF Row<MTTNy THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;

IF MTTNy NEQ 0 THEN IF MTTNu NEQ 0 THEN
BEGIN
write "%  - D matrix";
write "\begin{equation}";
write "MTTD = \begin{pmatrix}";
	FOR Row := 1:MTTNy DO
	BEGIN
		FOR Col := 1:MTTNu DO
		BEGIN
			Write "{", MTTD(Row,Col), "}";
			IF Col<MTTNu THEN Write "&"
		END;

	IF Row<MTTNy THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;




SHUT "$1_dm.tex";
quit;
EOF

Added mtt/bin/trans/doc2dvi version [e8e1f97833].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: doc2dvi
# Converts doc file to dvi file

# Copyright (c) P.J.Gawthrop 1998


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/11/24 12:03:27  peterg
## Indexing of book docs.
##
## Revision 1.2  1998/04/15 18:40:43  peterg
## Run LateX three times
##
## Revision 1.1  1998/03/03 08:35:50  peterg
## Initial revision
##
###############################################################

system=$1
documenttype=$2

# Inform user
echo "Creating $system.dvi"

#Run latex , bibtex and makeindex
latex $system.doc > doc2dvi.log
bibtex $system    >> doc2dvi.log
latex $system.doc >> doc2dvi.log
latex $system.doc >> doc2dvi.log

if [ "$documenttype" = "book" ]; then
    makeindex $system >> doc2dvi.log
else
    touch $system.ind
fi

latex $system.doc >> doc2dvi.log
latex $system.doc >> doc2dvi.log

# Make sure transformation succeeeds
exit 0

Added mtt/bin/trans/doc2pdf version [17899ec521].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: doc2pdf
# Converts doc file to pdf file

# Copyright (c) P.J.Gawthrop 1998


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
##
###############################################################

system=$1
documenttype=$2

# Inform user
echo "Creating $system.pdf"

#Run pdflatex , bibtex and makeindex
pdflatex $system.doc > doc2pdf.log
bibtex $system    >> doc2pdf.log
pdflatex $system.doc >> doc2pdf.log
pdflatex $system.doc >> doc2pdf.log

if [ "$documenttype" = "book" ]; then
    makeindex $system >> doc2pdf.log
else
    touch $system.ind
fi

pdflatex $system.doc >> doc2pdf.log
pdflatex $system.doc >> doc2pdf.log

# Make sure transformation succeeeds
exit 0

Added mtt/bin/trans/doc2ps version [d08f5c88d0].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: doc2dvi
# Converts doc file to dvi file

# Copyright (c) P.J.Gawthrop 1998


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1999/11/02 07:56:46  peterg
## Removed documenttype in blurb
##
## Revision 1.3  1998/11/24 12:03:27  peterg
## Indexing of book docs.
##
## Revision 1.2  1998/04/15 18:40:43  peterg
## Run LateX three times
##
## Revision 1.1  1998/03/03 08:35:50  peterg
## Initial revision
##
###############################################################

system=$1
documenttype=$2

# Inform user
echo "Creating $system.ps"

doc2dvi $system $documenttype

dvips -o $system.ps $1 

# Make sure transformation succeeeds
exit 0

Added mtt/bin/trans/ese2rdae_r version [c877f50297].







































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ese2rdae_r
# Reduce equations to raw differential-algebraic equation conversion
# P.J.Gawthrop  8th May 1991, May 1994, June 1996
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2002/08/30 15:39:04  geraint
## Read fix_c.r before ese.r and explicitly overload ** operator with pow().
## These changes are required for the Codemist version of Reduce.
##
## Revision 1.13  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.12.2.2  2002/06/05 17:28:00  geraint
## Cosmetic change.
##
## Revision 1.12.2.1  2002/06/05 11:14:51  geraint
## ae.r now generated using def2write_r like cse?.r
## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r.
##
## These changes produce the desired result (optimised algebraic equations) but
## have highlighted a problem; when optimisation fails, Reduce does not write
## a result. For complicated systems, this can lead to missing assignments in
## the resultant code.
##
## Revision 1.12  2001/07/23 23:31:17  gawthrop
## Added -cr option to load CRs first - avoids alg. loops with R
## implementation of mutiports.
##
## Revision 1.11  2001/07/06 00:46:50  gawthrop
## Added -cr option -- forces cr to be loaded before the ese.r file
## This avoids causality problems when using multi-port Rs to represent
## arbitary equations
##
## Revision 1.10  2000/11/30 15:23:16  peterg
## Taken out all subsystem stuff - now done in mtt using
## mtt_make_subsystems
##
## Revision 1.9  2000/09/07 12:18:31  peterg
## Prettified layout of this file
##
## Revision 1.8  2000/09/07 12:07:26  peterg
## *** empty log message ***
##
## Revision 1.7  2000/09/01 13:34:15  peterg
## Exit on option error
##
## Revision 1.6  2000/09/01 13:30:32  peterg
## Added -partition switch
##
## Revision 1.5  2000/09/01 12:14:57  peterg
## Added connecti9ng inputs
##
## Revision 1.4  1998/04/07 15:06:46  peterg
## Correct log file name
##
## Revision 1.3  1998/03/07 12:57:19  peterg
## Fixed logname bug
##
## Revision 1.2  1998/03/07 12:51:20  peterg
## This is the new version of ese2dae - it does not do the CRs at this
## stage to give reduce an easier time.
##
## rese2ese_r does the constitutive relationship bit
##
## Revision 1.1  1998/03/07 12:49:31  peterg
## Initial revision
##
## Revision 1.12  1998/01/31 16:22:59  peterg
## Added IF MTTNx>0 THEN and IF MTTNy>0 THEN before the relevant
## assignements of MTTdX and MTTY to themselves.
##
## Revision 1.11  1997/09/18 09:45:08  peterg
## Canged the comment about linux reduce -- reduce reads this for some
## reason.
##
## Revision 1.10  1997/09/15 14:21:18  peterg
## Reads ese file twice to avoid a bug in Linux reduce !!!???
##
## Revision 1.9  1997/08/30 09:59:31  peterg
## Changed mehtod of writing out mtty to avoid a strange segmentation violation.
## Now uses MTTY := MTTY; approach.
##
## Revision 1.8  1997/04/23 09:31:20  peterg
## Now reads in the (top level) def file in the generated reduce code.
##
# Revision 1.7  1997/04/23  09:23:15  peterg
# Two argument version in preparation for heirarchical version
#
# Revision 1.6  1996/11/21  15:47:48  peterg
# Now inputs _params.r not _sympar.r
#
## Revision 1.5  1996/11/02 10:17:35  peterg
## Removed default constitutive relationship input.
##
# Revision 1.4  1996/09/12  12:10:05  peter
# Now reads the default constitutive relationship file.
#
## Revision 1.3  1996/08/25 09:43:26  peter
## General error handling.
##
## Revision 1.2  1996/08/25 08:31:28  peter
## Error handling added.
##
###############################################################


while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-cr )
                load_cr=yes;
                blurb2=' using cr and subs first';
                ;;
      -fixcc )
		include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'`
		blurb3='fixing c and cc code';
		;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
      -sort )
	  	sort=sort;
		blurb1='using sorted equations';
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

#Create the top-level system name
topname=$1

#Create the system names
if [ -z "$2" ]; 
    then
	sysname=$topname;
    else
	sysname=$1_$2;
fi

defname=$topname"_def.r"
crname=$topname"_cr.r"
subsname=$topname"_subs.r"
paramname=$topname"_params.r"
daename=$sysname"_rdae.r"

if [ -n "$sort" ]; then
    esename=$sysname"_sese.r"
else
    esename=$sysname"_ese.r"
fi

logname=ese2rdae.log

if [ -n "${load_cr}" ]; then
    load_cr_comm="in \"${crname}\";"
    load_subs_comm="in \"${subsname}\";"
fi

# Inform user
echo Creating $daename $blurb $blurb1 $blurb2 $blurb3

# Remove the old log file
rm -f $logname

# Use symbolic algebra to accomplish the transformation
$SYMBOLIC >$logname  << EOF

%Read in the cr and sub when  -cr is set
$load_cr_comm
$load_subs_comm

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

% Definitions
in "$defname";

% Fix c code if required
$include

% Elementary system equations
in "$esename";

OFF Echo;
OFF Nat;

%Create the output file
OUT "$daename";

write "in ""$defname""";

% State
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Nonstate
MTT_Matrix := MTTZ$ 
MTT_Matrix_name := "MTTZ"$
MTT_Matrix_n := MTTNz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTy$ 
MTT_Matrix_name := "MTTy"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Zero outputs
MTT_Matrix := MTTYz$ 
MTT_Matrix_name := "MTTYz"$
MTT_Matrix_n := MTTNyz$
MTT_Matrix_m := 1$
Reduce_Matrix()$


SHUT "$daename";
quit;

EOF

#if [ -n "$partition" ]; then
#  rm -f mtt_junk
#  # Now for the subsystems
#  # Find subsystems
#  subsystems=`mtt_get_subsystems $1`
#
#  for subsystem in $subsystems; do
#    echo Doing $subsystem
#    ucname="MTT_"$subsystem"_uc"
#  
#    Nu=`mtt_getsize -internal $subsystem u`
#    echo Nu $Nu
#  
#    # Use symbolic algebra to accomplish the transformation
#    $SYMBOLIC >$logname  << EOF
#  
#    %Read the formatting function
#    in "$MTTPATH/trans/reduce_matrix.r";
#  
#    % Definitions
#    in "$defname";
#  
#    % Elementary system equations
#    in "$esename";
#  
#    OFF Echo;
#    OFF Nat;
#   
#    %Create the output file
#    OUT "mtt_junk";
#    % Connecting inputs
#    MTT_Matrix := $ucname $
#    MTT_Matrix_name := "$ucname" $
#    MTT_Matrix_n := $Nu $
#    MTT_Matrix_m := 1$
#    Reduce_Matrix()$
#  
#    shut "mtt_junk";
#EOF
#    echo >> $1_rdae.r
#    echo %Connections for subsystem $subsystem  >> $1_rdae.r
#    echo >> $1_rdae.r
#  
#    cat mtt_junk >> $1_rdae.r
#    rm -rf mtt_junk
#  done
#fi

echo "END;" >> $1_rdae.r

# Now invoke the standard error handling.
mtt_error_r $logname

Added mtt/bin/trans/ese_r2txt.pl version [afe19321de].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/perl -w

use strict;

$/ = ';';			# statements are terminated by ;
while (<STDIN>) {
    chomp;
    s/%.*\n//g;			# strip comments (% to end of line)
    s/(\s)*//g;			# strip whitespace
    s/^END$//;			# strip junk
    next if /^(\s)*$/;		# skip blank lines
    printf ("%s\n", $_);	# print what remains
}

Added mtt/bin/trans/ese_tidy version [351111a9a5].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Bourne shell script: ese_tidy
# Tidies up Matlab format files
# P.J.Gawthrop May 1998
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

#Puts the state & output equations at the end of the file

grep -v '^MTT' $1_ese.r>junk1
grep '^MTT' $1_ese.r>junk2
echo 'END;' >junk3
cat junk1 junk2 junk3> $1_ese.r




Added mtt/bin/trans/ese_txt2make.pl version [5c51d89569].














































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/perl -w
#
#     ese_txt2make.pl - sorts equations using Make
#     Copyright (C) 2004  Geraint Paul Bevan
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#		--------------------------
#		Model Transformation Tools
#		--------------------------
#
# Creates a makefile from the elementary system equations
# Executing the makefile causes make to sort the equations
#
#-------------------------------------------------------------------------------

use strict;
use Getopt::Long;

my %dependencies;		# left-values right-dependencies
my %expressions;		# left-values right-expression

my $sys		= '';
my $debug	=  0;
my $infile	= '';
my $outfile	= '';

GetOptions ('sys=s'	=> \$sys,
	    'debug'	=> \$debug,
	    'infile=s'	=> \$infile,
	    'outfile=s'	=> \$outfile);

# default file names
$infile	 = "${sys}_ese.txt"	if ($infile  eq '');
$outfile = "${sys}_ese.make"	if ($outfile eq '');

#-------------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------------

if ($debug) {
    my $logfile = "ese_txt2make_${sys}.log";
    open (LOG, ">$logfile") or die ("MTT: ese_txt2make, cannot open $logfile");
}

# First the elementary system equations are read
# and placed in the "expressions" hash.
read_ese_txt ();

# Then the occurence of any lvalue in the expression
# of any other is sought. 
get_dependencies ();

# Finally the expressions are written to a makefile
# where the targets are the left hand values and the
# pre-requisites are the dependencies
write_make ($sys);

close (LOG) if ($debug);

#-------------------------------------------------------------------------------
# subroutines
#-------------------------------------------------------------------------------
sub read_ese_txt {

    open (ESE, $infile)
	or die ("MTT Error:\nese_txt2make, cannot open $infile\n");

    while (<ESE>) {

	chomp;

	# separate the left and right side of equations
	# and assign them to the expressions hash
	my ($lvar,$expr) = split (/:=/);
	$expressions{$lvar} = $expr;

	print LOG "$lvar\t= $expressions{$lvar}\n" if $debug;
    }
    
    close (ESE);
}
#-------------------------------------------------------------------------------
sub get_dependencies {

    # compare the pattern to each expression
    foreach my $lvar (keys %expressions) {
	$dependencies{$lvar} = "";
	$_ = $expressions{$lvar};
	for my $lvar2 (keys %expressions) {
	    if ($expressions{$lvar} =~ /$lvar2/) {
		# a left value has been found in the expression
		# add it to the dependencies for this lvar
		$dependencies{$lvar} = "$dependencies{$lvar} $lvar2";
	    }
	}
	print LOG "$lvar:\t$dependencies{$lvar}\n" if $debug;
    }
}
#-------------------------------------------------------------------------------
sub write_make {
    
    # create lists of rates, states and tmpvars so that
    # separate rules can be created in the makefile
    my @list_of_rates;
    my @list_of_outputs;
    my @list_of_unknown;
    my @list_of_nonstates;
    my @list_of_tmpvars;

    for my $lvar (sort (keys %expressions)) {
	if ($lvar =~ /^MTTdX\(/) {
	    @list_of_rates = (@list_of_rates, $lvar) ;
	} elsif ($lvar =~ /^MTTy\(/) {
	    @list_of_outputs = (@list_of_outputs, $lvar);
	} elsif ($lvar =~ /^MTTyz/) {
	    @list_of_unknown = (@list_of_unknown, $lvar);
	} elsif ($lvar =~ /^MTTz/) {
	    @list_of_nonstates = (@list_of_nonstates, $lvar);
	} elsif ($lvar =~ /^${sys}_/) {
	    @list_of_tmpvars = (@list_of_tmpvars, $lvar);
	} else {
	    die "MTT Error:\nese_txt2make, unclassified variable: $lvar\n";
	}
    }
    my @sorted_rates     = sort (@list_of_rates);
    my @sorted_outputs   = sort (@list_of_outputs);
    my @sorted_unknown   = sort (@list_of_unknown);
    my @sorted_nonstates = sort (@list_of_nonstates);
    my @sorted_tmpvars   = sort (@list_of_tmpvars);


    # write the header
    open (ESE, ">$outfile") or
	die ("MTT Error:\nese_txt2make, cannot open $outfile\n");

    my $date = localtime;

    print ESE
	"# $outfile\t-*-makefile-*-\n" .
	"#\n";

    print ESE
	"#\t\t--------------------------\n" .
	"#\t\tModel Transformation Tools\n" .
	"#\t\t--------------------------\n" .
        "#\n" .
	"# Created by MTT: $date\n\n";    

    # write the rules that external programs use
    print ESE
        "all: declare_tmpvars MTTdX MTTy\n\n" .
	"MTTdX: @sorted_rates\n\n" .
	"MTTy:  @sorted_outputs\n\n" .
	"MTTyz: @sorted_unknown\n\n" .
	"MTTz:  @sorted_nonstates\n\n";
    
    # set the default output format:
    # double tmpvar;
    # lvalue := expression;
    print ESE
	"# default output format\n" .
	"ifeq (\"\$(assignment)\",\"\")\n" .
	"assignment=:=\n" .
	"endif\n\n" .
	"ifeq (\"\$(declaration)\",\"\")\n" .
	"declaration=double\n" .
	"endif\n\n" .
	"ifeq (\"\$(terminator)\",\"\")\n" .
	"terminator=;\n" .
	"endif\n\n";

    # write a rule to declare the temporary variables
    print ESE
	"# declare temporary variables\n" .
	"declare_tmpvars:\n";
    for my $var (@sorted_tmpvars) {
	print ESE "\t\@echo \"\$(declaration) $var \$(terminator)\"\n";
    }
    print ESE "\n";

    # write the equations
    print ESE "# the equations\n";
    for my $lvar (sort (keys %expressions)) {
	print ESE "$lvar: $dependencies{$lvar}\n";
	print ESE "\t\@echo \"$lvar \$(assignment) " .
	    "$expressions{$lvar} \$(terminator)\"\n\n";
    }
    print ESE "\n";

    close (ESE);
}
#-------------------------------------------------------------------------------

Added mtt/bin/trans/examples_txt2tk version [f746b105d0].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: examples_txt2tk
# Creates tk/tcl file for xmtt.
# Copyright (c) P.J.Gawthrop, 1998,1999


# Examples menu
gawk 'BEGIN{
    basemenu=".exam.exam"
    oldmenu=basemenu
    OLDPATH="";
    }
    {
    if (NF>1){
    PATH=$1;
    N=split(PATH,path,"/"); # Find current example path
    oldN=split(OLDPATH,oldpath,"/"); # Find last example path
    same=1; menu=basemenu;
    while ((path[same]==oldpath[same])&&(same<=N)){
       menu=menu"."tolower(path[same])
       same++
    }
      oldmenu=menu
      for (i=same;i<N;i++){
        menu=tolower(menu"."path[i])
        category=path[i];
	printf("\n# Example category %s (%i)\n", category, N)
        printf("%s  add  cascade -label \"%s\" -menu %s \n", oldmenu, category, menu);
        printf("menu %s\n", menu)
	oldmenu=menu
      }
    oldN=N
    OLDPATH=PATH
    oldcategory=category
    split($2,EXAMPLE,"_");
    example = EXAMPLE[1];
    printf(" set mtt \"xmtt --example %s\" \n", example); 
    printf("%s add command -label %s -command \" exec $mtt &\"\n", menu, example);
 }
}' 

Added mtt/bin/trans/first version [6060a423fe].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: first
# Gives first of space seperated string
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

echo $1 | cut -d ' ' -f 1 

Added mtt/bin/trans/gdat2fig version [2b58db4954].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: gdat2ps

# Converts a data file in gplot format to a ps file

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:29:52  peterg
## Initial revision
##
## Revision 1.8  1997/12/07 18:45:44  peterg
## Set to monochrome (not colour). This gives clearer plots.
##
## Revision 1.7  1996/08/26 13:04:43  peterg
## Changed $() to ``.
##
# Revision 1.6  1996/08/16  14:51:21  peter
# Put in some cosmetic postscript options.
#
## Revision 1.5  1996/08/15 09:37:58  peter
## Parameters in title.
##
## Revision 1.4  1996/08/14 09:21:17  peter
## Gnu plot conversion now done externally in dat2gdat
##
## Revision 1.3  1996/08/10 14:12:48  peter
## Revised to new dat format: [x y x y x y] in place of [x y y y].
##
## Revision 1.2  1996/08/10 12:54:56  peter
## Reorganised data file for gnuplot input.
##
## Revision 1.1  1996/08/10 09:52:39  peter
## Initial revision
##
###############################################################

echo Creating $1.fig

gnuplot << EOF
  set terminal fig color portrait fontsize 16 size 20 10 metric
  set output '$1.fig'
  set grid
  set title "MTT simulation on `date` "
  set nokey
  plot '$1.gdat' with lines
  exit

EOF

## Add a gold box to give a nice picture
cat >> $1.fig <<EOF
2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5
	 9675 5310 9675 270 225 270 225 5310 9675 5310
EOF

Added mtt/bin/trans/gdat2ps version [de49bc31ff].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: gdat2ps

# Converts a data file in gplot format to a ps file

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1996/08/26 13:04:43  peterg
## Changed $() to ``.
##
# Revision 1.6  1996/08/16  14:51:21  peter
# Put in some cosmetic postscript options.
#
## Revision 1.5  1996/08/15 09:37:58  peter
## Parameters in title.
##
## Revision 1.4  1996/08/14 09:21:17  peter
## Gnu plot conversion now done externally in dat2gdat
##
## Revision 1.3  1996/08/10 14:12:48  peter
## Revised to new dat format: [x y x y x y] in place of [x y y y].
##
## Revision 1.2  1996/08/10 12:54:56  peter
## Reorganised data file for gnuplot input.
##
## Revision 1.1  1996/08/10 09:52:39  peter
## Initial revision
##
###############################################################

echo Creating $1.ps

gnuplot << EOF
  set terminal postscript eps monochrome "Times-Roman" 24
  set size 1.5,1.5
  set output '$1.ps'
  set grid
  set title "`date` $2 "
  plot '$1.gdat' with lines
  exit
EOF

Added mtt/bin/trans/gdat2view version [5424332042].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: gdat2view

# Converts a data file in gplot format to  view 

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1996/08/15  09:36:00  peter
# Parameters in title.
#
## Revision 1.1  1996/08/15 08:50:20  peter
## Initial revision
##
###############################################################


# echo Creating view of $1

gnuplot << EOF
  set grid
#  set title "$1. Generated by MTT on $(date)"
  set title "`date` $2 "
  plot '$1.gdat' with lines
  pause 100000
EOF

Added mtt/bin/trans/ibg2abg_m version [6f2e346232].



























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ibg2abg_m
# Based on rbg2abg_m

while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-I )
	    info=info ;;
	-nounits )
	    units=no ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Set up some vars
sys=$1
lbl_file=${sys}_lbl.txt
abg_file=${sys}_abg.m
err=mtt_error.txt
log=ibg2abg_m_${sys}.log

# Remove the old log file
rm -f ibg2abg_m.log
rm -f ${abg_file}

# Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');
  
  ## Interpret data from the ibg representation
  ibonds = $1_ibg;
  bonds = ibonds.bonds;

  [bonds,components,n_vector_bonds] = ibg2abg(name,bonds, ...
					      infofile,errorfile)

  ## Write the acausal bond graph m-file
  write_abg(name,bonds,components,n_vector_bonds);
EOF

# Set the units for the abg file
test_units()
{
      grep '^[\s]*[#|%]UNITS' < ${lbl_file} >/dev/null
  if [ $? = "0" ]; then 
    grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
    gawk '{
      printf("mtt_units.sh %s %s %s %s %s\n", sys, $2, $3, $4, $5)
    }' sys=${sys}  | sh | grep ERROR
    if [ $? = "0" ]; then
      echo "    " *MTT_ERROR: domains and units are not OK - exiting
      exit 1  
    else
      echo "    " domains and units are OK 
    fi
  else
    echo "  no domains or units declared"
  fi
} 

check_ports_exist()
{
 declared_ports=`grep '^[\s]*[#|%]UNITS' < ${lbl_file} | gawk '{print $2}'`
  for declared_port in $declared_ports; do
    grep "${sys}\.ports\.${declared_port}\.type" ${abg_file} >/dev/null
    if [ $? = "1" ]; then
      echo "*MTT_ERROR: Units declared for non-existent port ${declared_port}"
      exit 1
    fi
  done
}

set_units()
{ 
  grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
  gawk '{
    printf("  %s.ports.%s.domain = \"%s\";\n", sys, $2, $3);
    printf("  %s.ports.%s.units.effort = \"%s\";\n", sys, $2, $4);
    printf("  %s.ports.%s.units.flow = \"%s\";\n", sys, $2, $5);
  }' sys=${sys}
} 

if [ -z "$units" ]; then
  echo Checking port domains and units
  check_ports_exist;
  test_units;
  echo "## Port domain and units" >> ${abg_file}
  set_units >> ${abg_file}
fi

# Append any VAR declarations
if [ -f "$1_lbl.txt" ]; then
  echo "## Explicit variable declarations" >> ${abg_file}
  grep '^[\s]*[%|#][V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
  grep '^[\s]*[%|#]NOT[V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
fi

# Close off the function
echo "endfunction" >> ${abg_file}

# Errors and info
if [ "$info" = "info" ]; then
    cat mtt_info.txt
fi

if mtt_error mtt_error.txt; then
    exit 0
else
    exit 1
fi

Added mtt/bin/trans/icd2ICD_txt22txt.sh version [bb77e3bfab].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

sys=$1
icd=${sys}_*_icd.txt2
ICD=${sys}_ICD.txt

echo Creating ${ICD}

# lbl.txt ICD Format:
# [#|%]ICD PortName EffortName,EffortUnit;FlowName,FlowUnit
# $1       $2       $3
# Comma / Semi-colon distinction unenforced

# icd.txt Format
# PortName EffortName,EffortUnit;FlowName,FlowUnit input|output,input|output
# $1       $2         $3         $4       $5       $6           $7

cat <<EOF > ${ICD}
## Interface Control Definition for System ${sys}
## ${ICD}: Generated by MTT `date`

EOF

cat ${icd}		|\
    sed 's/[\,\;]/\ /g'	|\
    gawk '
    ($2 != "null" && $6 == "input")  { printf ("Input:  %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "input")  { printf ("Input:  %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ($2 != "null" && $6 == "output") { printf ("Output: %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "output") { printf ("Output: %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ' | sort >> ${ICD}

Added mtt/bin/trans/icd_txt2m.sh version [9439894fee].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

# Inform user
echo Creating $1_icd.m

#Create the component ICD file complete with headers.
echo "function icd = $1_icd" > $1_icd.m
echo "%% Component icd file ($1_icd.m)" >> $1_icd.m
echo "%% Generated by MTT at `date`" >> $1_icd.m

#Write out the variables 
gawk '{
       if (NF==2) {i++; print "icd."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "icd = 0;"
        }' $1_icd.txt >> $1_icd.m

Added mtt/bin/trans/ker_r2tex version [efd3e610b9].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ker_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994, 1996.
# Copyright (C) 2001 by Peter J. Gawthrop


# Inform user
echo Creating $1_ker.tex

# Remove the old log file
rm -f ker_r2tex.log

# Use reduce to accomplish the transformation
reduce >ker_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the constrained-state matrices file
in "$1_ker.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

MATRIX MTT_Matrix(MTTNy-MTTNu,MTTNy);

OUT "$1_ker.tex";

%Write out the kernel matrix
write "%Kernel  matrices $1";
write "%File: $1_ker.tex";
write"";

MTT_Matrix := MTTR$ 
MTT_Matrix_name := "MTTR"$
MTT_Matrix_n := MTTNy-MTTNu$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$

SHUT "$1_ker.tex";
quit;
EOF

Added mtt/bin/trans/labg_fig2ps version [3fff3368d1].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: labg_fig2ps

# Eps figures from labg rep.
echo Creating $1.ps
fig2ps --nogv --forcespecial --add=$MTT_LIB/latex/bg $1.fig >/dev/null

Added mtt/bin/trans/landscape2portrait.sh version [2711c6c9b6].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: landscape2portrait.sh
# Converts one or more figure files from landscape mode to portrait mode

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ###############################################################

# Copyright (C) 2001 by Peter J. Gawthrop

figfiles=$*

for figfile in $figfiles; do
    count=`grep -c Landscape $figfile`
    if [ "$count" = "1" ]; then
       echo Converting $figfile
       mv $figfile ${figfile}.bak
       sed 's/Landscape/Portrait/'< ${figfile}.bak > $figfile
    fi
done

Added mtt/bin/trans/lang_header version [63caba35a0].




















































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

# Generates function header for a computer language
# PJ Gawthrop May 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  2000/05/11 08:03:02  peterg
## Remove the mtt no global stuff
##
## Revision 1.10  2000/04/18 11:14:32  peterg
## - parameters option
##
## Revision 1.9  2000/04/08 10:23:38  peterg
## Added -noglobal option
##
## Revision 1.8  1999/02/16 04:14:53  peterg
## Small change to modeline generation
##
## Revision 1.7  1999/01/20 22:19:21  peterg
## Puts emacs mode line at top of .m files
##
## Revision 1.6  1998/07/27 20:30:39  peterg
## Mods for dm rep - no globals ...
##
## Revision 1.5  1998/07/25 20:42:30  peterg
## No assignements for switch either
##
## Revision 1.4  1998/07/25 10:43:10  peterg
## No assignments of x or u if sm rep.
##
## Revision 1.3  1998/07/19 15:52:15  peterg
## Don't call the _input function - make it external from now on ...
##
## Revision 1.2  1998/05/24 12:47:39  peterg
## This still needs worjk doing for c generation!!
##
## Revision 1.1  1998/05/23 16:17:40  peterg
## Initial revision
##
###############################################################

# Args
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
    -noglobals)
	noglobals=noglobals;
	;;
    -parameters)
	parameters=parameters;
	;;
    *)
	echo $1 is an unknown option
        exit;;
  esac
  shift
done

# Set up the language specific stuff
system=$1
rep=$2
language=$3
args=$4
output=$5
extras=$6

case $language in
    m)
	modeline='% -*-octave-*- Put Emacs into octave-mode%';
	ext='m';
	Lc='#';
	Rc='#';
	Lb='(';
	Rb=')';
	;;
    p)
	modeline='% -*-octave-*- Put Emacs into octave-mode%';
	ext='m';
	Lc='#';
	Rc='#';
	Lb='[';
	Rb=']';
	;;
    c)
	ext='c';
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    java)
	ext='java';
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac


######### Octave (matlab) code
if [ "$language" = m ]; then
cat <<EOF
function $output = $1_$rep($args);
% $output = $1_$rep($args);
%System $system, representation $rep, language $language;
%File $1_$rep.$ext;
%Generated by MTT on `date`;
%
EOF
fi


######### c code
if [ "$language" = c ]; then
cat <<EOF
void $1_$rep() {
/*
System $system, representation $rep, language $language;
File $1_$rep.$ext;
Generated by MTT on `date`;

NB Arrays are be defined to be one larger than expected
 - the 0 element is not used.
*/

EOF

# Appropriate emacs mode line
cat <<EOF
$modeline
EOF

# Declarations
$MATRIX -q  <<EOF 
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;

  printf("$Lc Declare standard arrays $Rc\n");
  printf("  extern double mtty[%i]; \t $Lc $1_ode output $Rc\n", ny+1);
  printf("  extern double mttdx[%i]; \t $Lc $1_ode state derivative $Rc\n", nx+1);
  printf("  extern double mttx[%i]; \t $Lc $1_ode state $Rc\n", nx+1);
  printf("  extern double mttu[%i]; \t $Lc $1_ode input $Rc\n\n", nu+1);

  printf("$Lc Dummy variable list $Rc\n");
  printf("  double t0;\n\n");


  printf("$Lc State variable list $Rc\n");
  for i = 1:nx
    printf("  double mttx%i;\n",i);
  end;
printf("\n");

printf("$Lc State variable input list $Rc\n");
for i = 1:nu
  printf("  double mttu%i;\n",i);
end;
printf("\n");

printf("$Lc Counter $Rc\n");
printf("  int i;\n");
printf("\n");

printf("$Lc Time $Rc\n");
printf("  double t;\n");
printf("\n");

EOF

fi

if [ "$language" = "java" ]; then
cat <<EOF
public class $1_ode{
/*
System $system, representation $rep, language $language;
File $1_$rep.$ext;
Generated by MTT on `date`;
*/

EOF
fi

# Any extra bits ..
if [ -n "$extras" ]; then
cat <<EOF
$Lc Extra bits here $Rc
$extras
EOF
fi

# Globals
if [ -z "$noglobals" ]; then
    sympar2global_txt2lang $1 $language
else
cat<<EOF
global ...
mtt_no_globals ;
EOF
fi

# Explicit parameters
if [ -n "$parameters" ]; then
    sympar2par_txt2m $1 
fi

## if [ "$language" = "c" ] || [ "$language" = "m" ]; then
##   if [ "$rep" != "sm" ]&&[ "$rep" != "dm" ]&&[ "$rep" != "switch" ]; then
##   # Common part - ode (c and m)
##   # Use octave for this bit - needs the definition file
##   $MATRIX -q  <<EOF 
##     %System structure
##     [nx,ny,nu,nz,nyz] = $1_def;
## 
##   printf("$Lc====== Set up the state variables ======$Rc\n");
##   for i = 1:nx
##     printf("  mttx%i = mttx$Lb%i$Rb;\n",i,i);
##   end;
##   printf("\n");
## 
##   printf("$Lc====== Set up the input variables ======$Rc\n");
##   for i = 1:nu
##   printf("  mttu%i = mttu$Lb%i$Rb;\n",i,i);
##   end;
##   printf("\n");
## 
## EOF
##  fi
## fi
## #if [ "$language" = "java" ]; then

#$MATRIX -q <<EOF   
#    printf("JAVA\n");
#EOF

#fi

Added mtt/bin/trans/lang_matrix.r version [f4b204b20b].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in computer - language form
% P.J.Gawthrop  March 1998, May 1988
% Copyright (c) P.J.Gawthrop, 1998



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.7  2000/08/29 17:33:59  peterg
% % After much fiddling about ..
% %  now does global optimisation (over all elements of matrix / vector)
% %  still fails for _sm.m
% %
% % Revision 1.6  2000/08/25 09:23:40  peterg
% % Made both names the same!
% %
% % Revision 1.5  2000/08/24 17:12:01  peterg
% % Now optimises using SCOPE
% %
% % Revision 1.4  1998/07/27 17:34:59  peterg
% % Sorted syntax errors
% %
% % Revision 1.3  1998/07/27 16:31:10  peterg
% % Sorted out to work with mtt_r2m
% %
% % Revision 1.2  1998/05/23 15:00:27  peterg
% % Removed the name = matrix statement - now done by sed.
% %
% % Revision 1.1  1998/05/23 10:49:25  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



PROCEDURE Lang_Matrix();
BEGIN
%INAME(mtt_o); % Set temp name
GENTRAN mtt_matrix :=: mtt_matrix;

%     FOR row := 1:MTT_Matrix_n DO
%     BEGIN
%       IF MTT_Matrix_m>1 THEN
%       BEGIN
%         FOR col := 1:MTT_Matrix_m DO
%         BEGIN
%               IF (row EQ 1) AND (col EQ 1) THEN DELAYOPTS;
%               INAME(mtt_o); % Set temp name
%               %SETLENGTH(2); % Adjust optimisation
%               gentran declare mtt_matrix_element:REAL;
%               gentran declare mtt_matrix:REAL;
%               mtt_matrix_element := mtt_matrix(row,col);
%               GENTRAN mtt_matrix(row,col) ::=: mtt_matrix_element;
%               IF (row EQ MTT_matrix_n) AND (col EQ MTT_Matrix_m) THEN MAKEOPTS;
%             END;
%       END
%       ELSE
%         BEGIN
%           IF (row EQ 1) THEN DELAYOPTS;
%           INAME(mtt_o); % Set temp name
%           GENTRAN mtt_matrix(row) ::=: mtt_matrix(row,1);
%           IF (row EQ MTT_matrix_n) THEN MAKEOPTS;
%         END;
%     END
END;

END;;


Added mtt/bin/trans/latex_equations.r version [25e7283cc5].












































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Reduce file to generate equations
% Copyright (C) 2000 by Peter J. Gawthrop

PROCEDURE latex_equations;
BEGIN
IF MTTNx>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
  FOR Row := 1:MTTNx DO
  BEGIN
	write "\dot MTTX", Row, " &= "$
	write "{"$
	write MTTdx(Row,1)$
	write "}"$
        IF Row<MTTNx THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$
END$

IF MTTNz>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
FOR Row := 1:MTTNz DO
  BEGIN
	write "MTTz", Row, " &= "$
	write "{"$
	write MTTz(Row,1)$
	write "}"$
        IF Row<MTTNz THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$

END$

IF MTTNyz>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
FOR Row := 1:MTTNyz DO
  BEGIN
	write "0 &= "$
	write "{"$
	write MTTyz(Row,1)$
	write "}"$
        IF Row<MTTNyz THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$

END$

IF MTTNy>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
FOR Row := 1:MTTNy DO
  BEGIN
	write "MTTy", Row, " &= "$
	write "{"$
	write MTTy(Row,1)$
	write "}"$
        IF Row<MTTNy THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$

END$

END$

END$

Added mtt/bin/trans/latex_matrix.r version [a9950295a9].
















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in latex form
% P.J.Gawthrop  January 22 1998
% Copyright (c) P.J.Gawthrop, 1998

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Version control history
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $Id$
%% $Log$
%% Revision 1.6  2000/10/10 21:02:42  peterg
%% *** empty log message ***
%%
%% Revision 1.5  2000/08/09 10:41:39  peterg
%% Changed criterion form 3 to 5
%%
%% Revision 1.4  1998/11/10 14:15:36  peterg
%% Now does matrix style for m<3
%%
%% Revision 1.3  1998/03/14 11:07:09  peterg
%% Removed comma from array subscript
%%
%% Revision 1.2  1998/02/25 22:11:28  peterg
%% Added big matrix version
%%
%% Revision 1.1  1998/01/22 09:59:36  peterg
%% Initial revision
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


PROCEDURE Latex_Matrix;
BEGIN
IF MTT_Matrix_m<10 THEN %% Do matrix style version
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      write "\begin{equation}";
      write MTT_Matrix_name, " = \begin{pmatrix}";
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          write "{", MTT_Matrix(Row,Col), "}";
          IF Col<MTT_Matrix_m THEN Write "&"
        END;

	IF Row<MTT_Matrix_n THEN Write "\cr";
      END;
      write "\end{pmatrix}";
      write "\end{equation}";
    END;
END
ELSE  %% write out the elements one-by-one.
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          MTT_element := MTT_Matrix(Row,Col);
          IF MTT_element NEQ 0 THEN
          BEGIN
            write "\begin{equation}";
            write MTT_Matrix_name, "_", Row, Col, " = {", MTT_element, "}\cr";
            write "\end{equation}";
          END;
        END;
      END;
    END;
END;
END;

END;;

Added mtt/bin/trans/latex_matrix_no.r version [5376ee5dcb].




















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in latex form
% P.J.Gawthrop  January 22 1998
% Copyright (c) P.J.Gawthrop, 1998

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Version control history
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $Id$
%% $Log$
%% Revision 1.7  2000/11/02 14:28:08  peterg
%% and up to 10 ...
%%
%% Revision 1.6  2000/10/10 21:02:42  peterg
%% *** empty log message ***
%%
%% Revision 1.5  2000/08/09 10:41:39  peterg
%% Changed criterion form 3 to 5
%%
%% Revision 1.4  1998/11/10 14:15:36  peterg
%% Now does matrix style for m<3
%%
%% Revision 1.3  1998/03/14 11:07:09  peterg
%% Removed comma from array subscript
%%
%% Revision 1.2  1998/02/25 22:11:28  peterg
%% Added big matrix version
%%
%% Revision 1.1  1998/01/22 09:59:36  peterg
%% Initial revision
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



PROCEDURE Latex_Matrix;
BEGIN
IF MTT_Matrix_m<10 THEN %% Do matrix style version
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      write "\begin{equation}";
      write MTT_Matrix_name, " = \begin{matrix}";
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          write "{", MTT_Matrix(Row,Col), "}";
          IF Col<MTT_Matrix_m THEN Write "&"
        END;

	IF Row<MTT_Matrix_n THEN Write "\cr";
      END;
      write "\end{matrix}";
      write "\end{equation}";
    END;
END
ELSE  %% write out the elements one-by-one.
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          MTT_element := MTT_Matrix(Row,Col);
          IF MTT_element NEQ 0 THEN
          BEGIN
            write "\begin{equation}";
            write MTT_Matrix_name, "_", Row, Col, " = {", MTT_element, "}\cr";
            write "\end{equation}";
          END;
        END;
      END;
    END;
END;
END;

END;;

Added mtt/bin/trans/latex_tidy version [99494feab4].



























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: latex_tidy
# Tidies up LaTex format files
# P.J.Gawthrop 12 June 1990, Dec 1994
# Copyright (c) P.J.Gawthrop, 1990, 1994

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.24  2003/08/17 11:35:45  gawthrop
## Zapped ^ to uparrow conversion.
##
## Revision 1.23  2003/08/17 11:35:07  gawthrop
## Fixed problem with parentheses
##
## Revision 1.22  2002/09/26 08:33:54  geraint
## Removed comma from pattern so that braces are places around each argument
## of a function call. Added greek letter nu as a special variable.
##
## Revision 1.21  2002/08/21 18:11:15  geraint
## Replaced |x| with |{x}|. LaTeX now renders abs(fractions) correctly.
##
## Revision 1.20  2002/08/20 19:33:21  geraint
## Minor bug fixes and enhancements (I hope):
##
## Delimited expressions within function calls to prevent denominators from continuing beyond commas.
## Allow latex to adjust size of parentheses according to expression within.
## Replaced ^ with \uparrow (less misleading - latex maths doesn't understand operator precedence or words).
## Replaced abs(x) with |x| when x does not contain brackets.
##
## Revision 1.19  2002/08/19 14:37:05  geraint
## Fixed eta, beta, theta, Theta and zeta.
##
## Revision 1.18  2001/06/11 19:43:50  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.17  2000/12/28 12:31:15  peterg
## *** empty log message ***
##
## Revision 1.16  2000/10/10 21:03:20  peterg
## *** empty log message ***
##
## Revision 1.15  1998/04/07 08:44:11  peterg
## zapped eta - it messes up theta
##
## Revision 1.14  1998/02/25 22:12:07  peterg
## Added , to regexp for subscripts
##
## Revision 1.13  1998/02/18 09:06:07  peterg
## Added dX0
##
## Revision 1.12  1998/02/09 14:11:08  peterg
## Added ctf --> D(s)
##
## Revision 1.11  1998/01/30 15:15:14  peterg
## Sorted out superscript problem
##
# Revision 1.10  1997/08/19  10:38:26  peterg
# Added pi to the list
#
## Revision 1.9  1997/02/24 13:02:17  peterg
## Added gamma and delta transformations
##
## Revision 1.8  1996/12/31 16:14:53  peterg
## Now handles multi-character subscripts.
##
## Revision 1.7  1996/12/19 10:24:29  peterg
## Uniform conversion of mttxi --> x_{i} for x,u,y and z
## Convert ???mttx to mtt x for  x,u,y and z
##
## Revision 1.6  1996/12/12 16:03:19  peterg
## Removed global argument stuff for y - its already done in the
## translation.
##
## Revision 1.5  1996/12/12 15:59:06  peterg
## Generic handling of subscript for y,u,ui
##
## Revision 1.4  1996/12/12 15:54:20  peterg
## Saved it.
##
## Revision 1.3  1996/08/30 14:36:46  peter
## Added some more subscripts.
## -- its high time this was rewritten in awk or perl!!!
##
## Revision 1.2  1996/08/19 14:35:51  peter
## Prettyfied z dot.
##
## Revision 1.1  1996/08/18 20:03:12  peter
## Initial revision
##
###############################################################
 
cat $1 | \
tr "[A-Z]" "[a-z]" | \
sed \
    -e "s/_\([a-z0-9]*\)/_{\1}/g" \
    -e "s/\// \\\over /g" \
    -e "s/[0-9a-z_]*mtty/mtty/g" \
    -e "s/[0-9a-z_]*mttu/mttu/g" \
    -e "s/mttx\([0-9]*\)/x_{\1}/g" \
    -e "s/mttex\([0-9]*\)/\\\chi_{\1}/g" \
    -e "s/mttddui\([0-9]*\)/\\\ddot{v}_{\1}/g" \
    -e "s/mttdui\([0-9]*\)/\\\dot{v}_{\1}/g" \
    -e "s/mttui\([0-9]*\)/v_{\1}/g" \
    -e "s/mttu\([0-9]*\)/u_{\1}/g" \
    -e "s/mtty\([0-9]*\)/y_{\1}/g" \
    -e "s/mttz\([0-9]*\)/z_{\1}/g" \
    -e "s/mttdx0/\\\dot x_0/g" \
    -e "s/mttdx/\\\dot x/g" \
    -e "s/mttdz/\\\dot z_/g" \
    -e "s/mttdu/\\\dot u_/g" \
    -e "s/dot_/ \\\dot /g" \
    -e "s/mtttf/G(s)/g" \
    -e "s/mttctf/D(s)/g" \
    -e "s/mtta/A/g" \
    -e "s/mttb/B/g" \
    -e "s/mttc/C/g" \
    -e "s/mttd/D/g" \
    -e "s/mtte/E/g" \
    -e "s/mttg/G/g" \
    -e "s/mtti/I/g" \
    -e "s/mttk/K/g" \
    -e "s/mttl/L/g" \
    -e "s/mttm/M/g" \
    -e "s/mtttheta/\\\Theta/g" \
    -e "s/mtto/O/g" \
    -e "s/mttv/V/g" \
    -e "s/mtty0/y_0/g" \
    -e "s/mttu0/u_0/g" \
    -e "s/mttx/x/g" \
    -e "s/mttz/z/g" \
    -e "s/mttyy/Y/g" \
    -e "s/mttw/w/g" \
    -e "s/mttt/T/g" \
    -e "s/mttpar//g" \
    -e "s/!/\\\/g" \
    -e "s/\\$//g" \
    -e "s/f\{0,1\}abs(\([^()]*\))/|{ \1 }|/g" \
    -e "s/(\([^(),]*\),/( { \1 } ,/g" \
    -e "s/,\([^(),]*\),/, { \1 } ,/g" \
    -e "s/,\([^(),]*\))/, { \1 } )/g" \
    -e "s/(/{\\\\left (/g" \
    -e "s/\*\*/^/g" \
    -e "s/\*/ /g" \
    -e "s/)/\\\right )}/g" \
    -e "s/sqrt/\\\sqrt/g" \
    -e "s/theta/\\\theta/g" \
    -e "s/tau/\\\tau/g" \
    -e "s/alpha/\\\alpha/g" \
    -e "s/beta/\\\beta/g" \
    -e "s/gamma/\\\gamma/g" \
    -e "s/delta/\\\delta/g" \
    -e "s/epsilon/\\\epsilon/g" \
    -e "s/\([^b(Th)(th)z]\)eta/\1\\\eta/g" \
    -e "s/^eta/\\\eta/g" \
    -e "s/kappa/\\\kappa/g" \
    -e "s/lambd/\\lambda/g" \
    -e "s/lambda/\\\lambda/g" \
    -e "s/mu/\\\mu/g" \
    -e "s/nu/\\\nu/g" \
    -e "s/phi/\\\phi/g" \
    -e "s/pi/\\\pi/g" \
    -e "s/rho/\\\rho/g" \
    -e "s/sigma/\\\sigma/g" \
    -e "s/omega/\\\omega/g" \
    -e "s/zeta/\\\zeta/g" \
    -e "s/infty/\\\infty/g" \
    -e "s/sin/\\\sin/g" \
    -e "s/cos/\\\cos/g" \
    -e "s/23/{23}/g" \
    -e "s/+-/ -/g" \
 | cat -s  | \
sed -e "s/ $//g" | \
tr  -s '\012' '\012' \
>junk

mv junk $1

Added mtt/bin/trans/lbl2alias_txt version [5801411229].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2alias_txt2txt
# Creates the component aliases in text form

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/02 08:34:00  peterg
## Renamed to lbl2alias_txt2txt
##
## Revision 1.1  1998/07/02 08:14:07  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_alias.txt

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
grep '[%|#]ALIAS' $1_lbl.txt |\
gawk '{print $2,$3}' >> $1_alias.txt









Added mtt/bin/trans/lbl2alias_txt2txt version [8e2770c7f9].














































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2alias_txt2txt
# Creates the component aliases in text form

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/07/17 19:46:56  peterg
## No change
##
## Revision 1.5  1998/07/17 16:31:37  peterg
## Ignore component aliases (with /)
##
## Revision 1.4  1998/07/03 15:21:26  peterg
## Replace sub by gsub -- need to replace ALL ,
##
## Revision 1.3  1998/07/03 13:49:03  peterg
## Flips the order of alias and name when $ is involved.
##
## Revision 1.2  1998/07/03 07:54:39  peterg
## Tidied
##
## Revision 1.1  1998/07/02 09:22:10  peterg
## Initial revision
##
## Revision 1.2  1998/07/02 08:34:00  peterg
## Renamed to lbl2alias_txt2txt
##
## Revision 1.1  1998/07/02 08:14:07  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_alias.txt

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
    grep '[%|#]ALIAS' $1_lbl.txt |\
    gawk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          alias=$2; name =$3
        }
        else{
          alias=$3; name =$2
        }
        gsub(",","__",alias); #Replace ,
        n=split(alias,a,"|");
        for (i=1; i<=n; i++)
          print a[i] "\t" name;
	   }
      }
      END{
      print "###_END_OF_ALIAS_###"
     }' >> $1_alias.txt









Added mtt/bin/trans/lbl2args_txt2out version [81dc428574].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
# Writes argument list to standard output ready for use in calling lbl file

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:08  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ## Revision 1.1  2001/06/11 15:06:58  gawthrop
  ## Now handles user-defined components
  ##
  ###############################################################

# Copyright (C) 2001 by Peter J. Gawthrop

if [ -f "$1_lbl.txt" ]; then
grep '[#%]ALIAS' $1_lbl.txt |\

gawk '{
  if (match($2,"\\$[0-9]")==1) ## Test if its a argument alias
  {
    i = substr($2,2);
    arg[i] = $3
    N++
  }
}
END{
    for (j=1;j<=N;j++){
      if (length(arg[j])==0)
        arg[j] = "??";
    }
    for (j=1;j<N;j++){
      if (length(arg[j])==0)
        arg[j] = "??";
      printf("%s;", arg[j]);
    }
    printf("%s\n",arg[N]);
}'
fi

Added mtt/bin/trans/lbl2cmp_txt2m.pl version [aba4e1a1e3].














































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/perl -w

### lbl2cmp_txt2m
## Creates _cmp.m from _lbl.txt
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

use strict;
use diagnostics;
use Getopt::Long;

sub usage;
sub read_cmp_file;
sub read_cmp_line;
sub name_anonymous_component;
sub port_or_component_or_junction;
sub read_lbl_file;
sub read_lbl_line;
sub sort_components;
sub sort_rule;
sub write_header;
sub write_body;
sub write_component;

my $debug = 0;

## fields to write to cmp.m
my (@component_name,
    %component_type,    
    %component_cr,
    %component_arg,
    %component_rep);

my (%sorted_component_list,
    %component_class,
    %anonymous_component_type_index);

## files to read/write
my ($cmp, $lbl, $out);

my $sys = '';

GetOptions ('sys=s' => \$sys,
	    'debug' => \$debug);

die usage() if ($sys eq '');

if ($debug) {
    my $logfile = "lbl2cmp_txt2m_${sys}.log";
    open (LOG, ">$logfile") or die ("MTT: lbl2cmp_txt2m, cannot open $logfile");
}

$cmp = "${sys}_cmp.txt";
$lbl = "${sys}_lbl.txt";
$out = "${sys}_cmp.m";

read_cmp_file();
read_lbl_file();
sort_components();
write_header();
write_body();

close (LOG) if ($debug);

sub usage() {
    return "Usage: lbl2cmp_txt2m --sys=<sys>\n";
}

sub read_cmp_file() {
    my ($line, $name, $type, $class, $rep, $i);

    open (CMP, $cmp) or die ("MTT: lbl2cmp_txt2m, cannot open $cmp");

    $i = 0;
    while (<CMP>) {
	
	chomp;
	# skip blank lines
	next if (/^(\s)*$/);
	# skip comments
	next if (/^(\s)*[%\#]/);
	# remove leading and trailing whitespace
	s/^\s*(\S.*\S)\s*$/$1/;
	
	$line = $_;
	print LOG "read_cmp_file: line='${line}'\n" if ($debug);

	# cmp provides type, name and repetition information
	# class is inferred from type and name
	# (cr and args are placeholders)

	($type, $name, $rep) = read_cmp_line($line);
	$name = name_anonymous_component($type) if ($name eq '');	
	$class = port_or_component_or_junction ($type, $name);

	$component_name  [$i++]   = $name;
	$component_type  {$name}  = $type;
	$component_rep   {$name}  = $rep;
	$component_cr    {$name}  = '';
	$component_arg   {$name}  = '';
	$component_class {$name}  = $class;
    }
    close (CMP);
}

sub read_cmp_line() {
    my $line = $_;
    my ($type, $name, $rep, $misc);
    
    ($type, $misc) = split (/:/, $line);
    $type = $line unless defined ($type);

    if (defined ($misc)) {
	($name, $rep) = split (/\*/, $misc);
	$name = $misc unless defined ($name);
    }

    $name = '' unless defined $name;
    $rep  = 1  unless defined $rep;
    
    print LOG "read_cmp_line: type='$type', name='$name', rep='$rep'\n" if ($debug);
    return ($type, $name, $rep);
}

sub name_anonymous_component() {
    my $type = $_;
    my ($name, $num);
    if (defined ($anonymous_component_type_index{$type})) {
	$num = ++$anonymous_component_type_index{$type};
	$name = "mtt${type}_${num}";
    } else {
	$anonymous_component_type_index{$type} = 1;
	$name = "mtt${type}";
    }
    print LOG "name_anonymous_component: type='${type}', name='${name}'\n" if ($debug);
    return ($name);
}

sub port_or_component_or_junction() {

    # ports are internal SS components (SS:[...])
    # junctions are '0' and '1' types
    # everything else is a component, including external SS types.

    my ($type, $name) = @_;
    my $retval;
    if ($type eq "SS") {
	$_ = $name;
	if (/\[.+\]/) {
	    $retval = "port";
	} else {
	    $retval = "component";
	}
    } elsif ($type eq "0") {
	$retval = "0junction";
    } elsif ($type eq "1") {
	$retval = "1junction";
    } else {
	$retval = "component";
    }
    print LOG "port_or_component_or_junction: type='$type', name='$name' class='$retval'\n" if ($debug);
    return ($retval);
}

sub read_lbl_file() {
    my (@line, $name, $type, $cr, $arg, $i);
    
    open (LBL, $lbl) or die ("MTT: lbl2cmp_txt2m, cannot open $lbl");
    
    $i = 0;
    while (<LBL>) {
	
	chomp;
	# skip blank lines
	next if (/^(\s)*$/);
	# skip comments
	next if (/^(\s)*[%\#]/);
	# remove leading and trailing whitespace
	s/^\s*(\S.*\S)\s*$/$1/;
	
	# lbl provides name, cr and arg information

	($name, $cr, $arg) = read_lbl_line (@line);
	
	$component_cr{$name}  = $cr;
	$component_arg{$name} = $arg;
    }

    close (LBL);
}

sub read_lbl_line() {
    my @line = @_;
    my ($name, $cr, $arg);

    @line = split (/\s+/);
    $name = shift (@line);

    # strip repetitions (if any)
    $name =~ s/([^\*]*)\*.*/$1/;

    $cr  = shift (@line);
    $arg = shift (@line);

    $cr   = '' unless defined ($cr);
    $arg  = '' unless defined ($arg);
    
    print LOG "read_lbl_line: name='$name' cr='$cr' arg='$arg'\n" if ($debug);
    return ($name, $cr, $arg);
}

sub write_header() {
    my $date = `date`;
    chomp ($date);

    open (OUT, ">$out") or
	die "MTT: cannot open $out for writing.\n";
    
    print OUT << "EOF";
## $out -*-octave-*-
## Generated by MTT on $date
    
function [comp_type, name, cr, arg, repetitions] = ${sys}_cmp(i)

EOF

    close (OUT);
}

sub sort_components ()
{
    # sorts components into alphabetical order (type:name)
    # within the classes: ports, components then junctions.

    my ($name, $class, $i, $j, $target);

    $i = 0;
    foreach $target ("port", "component", "0junction", "1junction") {
	my @sorted_list = sort (sort_rule @component_name);
	for $name (@sorted_list) {
	    $class = $component_class{$name};
	    if ($class eq $target) {
		if (! defined ($sorted_component_list{$name})) {
		    $sorted_component_list{$name} = $i++;
		    print LOG "sorted: '$name' '$i'\n" if ($debug); 
		}
	    }
	}
    }
}

sub sort_rule ()
{
    my ($type1, $name1, $string1,
	$type2, $name2, $string2);

    $name1 = $a;
    $name2 = $b;

    $type1 = $component_type{$name1};
    $type2 = $component_type{$name2};

    $string1 = sprintf ("%s:%s", $type1, $name1);
    $string2 = sprintf ("%s:%s", $type2, $name2);

    return ($string1 cmp $string2);
}
    
    
sub write_body() {
    my (%reverse_sorted_component_list, $name);
    
    %reverse_sorted_component_list = reverse (%sorted_component_list);
    for (my $key = 0; $key < scalar @component_name; $key++) {
	$name = $reverse_sorted_component_list{$key};
	write_component ($name);
    }
}

sub write_component() {
    my ($name) = @_;

    my $i = $sorted_component_list{$name}+1;

    open (OUT, ">>$out") or
	die "MTT: cannot open $out for writing.\n";

    print OUT
	"if (i == $i)\n" .
	"\tcomp_type   = '$component_type{$name}';\n" .
	"\tname        = '$name';\n" .
	"\tcr          = '$component_cr{$name}';\n" .
	"\targ         = '$component_arg{$name}';\n" .
	"\trepetitions =  $component_rep{$name} ;\n" .
	"end\n";

    close (OUT);
}

Added mtt/bin/trans/lbl2component version [f6ffaf551e].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2component
# Creates the commands to pull down components from libraries

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2003/08/09 00:29:52  geraint
## Fixed grep error when lbl file doesn't exist.
##
## Revision 1.4  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  1998/07/28 11:23:31  peterg
## Put / explicitly in awk.
##
## Revision 1.2  1998/07/27 08:38:11  peterg
## Just look for / in the relevant field.
##
## Revision 1.1  1998/07/17 17:04:50  peterg
## Initial revision
##
###############################################################

if [ -f "$1_lbl.txt" ]; then
  ## Regexp for an alias
  alias='^[#%]ALIAS'
  grep $alias $1_lbl.txt | gawk '{if (match($3,"/")>0) print "mtt -q compcopy " $3}'
fi









Added mtt/bin/trans/lbl2cr_txt2r version [44253224e2].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2cr_txt2r

# Label file to constitutive relationship conversion
# P.J.GawthropNovemebr 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:32:06  peterg
## Put under RCS
##
# Revision 1.3  1996/11/03  21:11:44  peterg
# Removed END; statement
#
## Revision 1.2  1996/11/02 10:20:53  peterg
## Created from lbl2sympar
##
###############################################################


# Inform user
echo "Creating $1_cr.r"

rm -f mtt_error

#Write some file headers
echo "%% constitutive relationship  file ($1_cr.r)" > $1_cr.r
echo "%% Generated by MTT at `date`" >> $1_cr.r

# This is the main transformation using awk
gawk -f $MTTPATH/trans/awk/lbl2cr.awk <$1_lbl.txt  2>mtt_error.txt | \
	sh >> $1_cr.r

# Now invoke the standard error handling.
#mtt_error mtt_error.txt


Added mtt/bin/trans/lbl2icd_txt2txt.sh version [2a3b38ea21].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2icd_txt2txt
# Creates the component ICDs in text form

# Adapted from lbl2alias_txt2txt

sys=$1
icd=${sys}_icd.txt
lbl=${sys}_lbl.txt

# Inform user
echo Creating ${icd}

#Create the ICD file complete with headers.
echo "# Component ICD file ($1_icd.txt)" > ${icd}
echo "# Generated by MTT at `date`" >> ${icd}

#Write out the variables 
    grep '[%|#]ICD' ${lbl} |\
    gawk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          icd=$2; name =$3
        }
        else{
          icd=$3; name =$2
        }
        n=split(icd,a,"|");
        for (i=1; i<=n; i++)
          print a[i] "\t" name;
	   }
      }
      END{
      print "###_END_OF_ICD_###"
     }' >> ${icd}

Added mtt/bin/trans/lbl2modpar_txt version [7d9600f181].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2modpar_txt2txt
# Creates the component modpares in text form

# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$
## Revision 1.1  2001/03/29 19:24:14  gawthrop
## Can now use c representations of crs when using -c option
##
###############################################################

# Inform user
echo Creating $1_modpar.txt

#Create the modpar file complete with headers.
echo "# Modpar file ($1_modpar.txt)" > $1_modpar.txt
echo "# Generated by MTT at `date`" >> $1_modpar.txt

#Write out the variables 
grep '[%|#]MODPAR' $1_lbl.txt |\
gawk '{printf("%s\t%s\n", $2,$3)}' >> $1_modpar.txt

echo "# End of $1_modpar.txt" >> $1_modpar.txt








Added mtt/bin/trans/lbl2sympar_txt2r version [d2dc2feb77].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2sympar_txt2r

# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/12/28 12:32:06  peterg
## Put under RCS
##
# Revision 1.6  1996/12/07  19:39:51  peterg
# Minor debugging.
#
## Revision 1.5  1996/09/12 17:18:44  peter
## Don't add an RCS header ..
##
## Revision 1.4  1996/08/30 19:01:21  peter
## Added headers to sympar file.
##
## Revision 1.3  1996/08/30 10:18:33  peter
## New path for awk script.
##
## Revision 1.2  1996/08/30 10:04:20  peter
## Included `;' in demimiter list.
##
# Revision 1.1  1996/08/24  13:34:09  peter
# Initial revision
#
###############################################################


# Inform user
echo "Creating $1_sympar.r"

rm -f mtt_error

#Write some file headers
echo "%% Symbolic parameter file ($1_sympar.r)" > $1_sympar.r
echo "%% Generated by MTT at `date`" >> $1_sympar.r

# This is the main transformation using awk
tr ';' ',' <  $1_lbl.txt | \
gawk -f $MTTPATH/trans/awk/lbl2sympar.awk | sort >> $1_sympar.r 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Added mtt/bin/trans/lbl_txt2tex version [04d132b22f].





























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl_txt2tex
# Latex summary of the lbl file

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.11  2002/04/19 08:39:45  gawthrop
## Changed \# to # and \% to # to avoid warning in latest gawk version
##
## Revision 1.10  2000/12/28 12:32:06  peterg
## Put under RCS
##
## Revision 1.9  2000/11/16 13:11:06  peterg
## Included PAR and UNITS declarations
##
## Revision 1.8  1999/02/17 21:42:19  peterg
## Replaced print by printf to avoid extra nl in paragraph command.
##
## Revision 1.7  1998/07/27 12:56:26  peterg
## Splits up | separated expressions.
##
## Revision 1.6  1998/07/27 10:56:31  peterg
## Cosmetics.
##
## Revision 1.5  1998/07/27 08:29:44  peterg
## Include a comment field in the aliases
##
## Revision 1.4  1998/07/17 19:46:44  peterg
## Included component alias.
##
## Revision 1.3  1998/07/16 20:39:52  peterg
## More cosmetic changes
##
## Revision 1.2  1998/07/16 16:34:09  peterg
## Cosmetic changes
##
## Revision 1.1  1998/07/16 16:31:47  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_lbl.tex

#Create the alias file complete with headers.
echo "% Label summary file ($1_lbl.tex)" > $1_lbl.tex
echo "% Generated by MTT at `date`" >> $1_lbl.tex

#Write out the Description
    grep '[%|#]SUMMARY' $1_lbl.txt | sed 's/_/\\_/g'  |\
    gawk '{
           printf("\\paragraph{System %s:",$2);
           for (i=3;i<=NF;i++) printf("%s ",$i); print ""
           print  "}"
         }' >> $1_lbl.tex
#    grep '[%|#]DESCRIPTION' $1_lbl.txt | sed 's/_/\\_/g'  |\
#    gawk '{
#           for (i=2;i<=NF;i++) printf("%s ",$i); print ""
#         }' >> $1_lbl.tex

#Write out the aliases
cat <<EOF >> $1_lbl.tex
\paragraph{Interface information:}
\begin{description}
EOF
    grep '[%|#]ALIAS' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
      N=split($2,a,"|");
      for (i=1;i<=N;i++){
        if (match(a[i],"\\$")>0){
          printf("\\item [Parameter \\%s] represents actual parameter ",a[i])
        }
        else if (match($3,"/")>0){
          printf("\\item [Component %s]  is in library ",a[i])
        }
        else{
          printf("\\item [Port %s] represents actual port ",a[i])
        }
        printf("\\textbf{%s}",$3)
        if (match($4,"[#%]")==1) printf(" -- ");
        for (j=5;j<=NF;j++) printf(" %s", $j)
        printf("\n");
        }
      }
    END{if (NR==0) print "\\item This component has no ALIAS declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF

#Write out the VARS
cat <<EOF >> $1_lbl.tex
\paragraph{Variable declarations:}
\begin{description}
EOF
    grep '[%|#][V|P]AR' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
        printf("\\item %s\n",$2)
      }
    END{if (NR==0) print "\\item This component has no PAR declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF


#Write out the UNITS
cat <<EOF >> $1_lbl.tex
\paragraph{Units declarations:}
\begin{description}
EOF
    grep '[%|#]UNITS' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
        printf("\\item [Port %s] has domain %s\n",$2, $3)
	printf("\\begin{description}\n")
        printf("\\item [Effort units] %s\n",$4)
        printf("\\item [Flow units] %s\n",$5)
	printf("\\end{description}\n")
      }
    END{if (NR==0) print "\\item This component has no UNITs declarations"
}' >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF

# Write the actual lbl file
cat >> $1_lbl.tex <<EOF
\subsubsection*{The label file: $1\_lbl.txt}
\begin{verbatim}
EOF
cat $1_lbl.txt >> $1_lbl.tex
cat >> $1_lbl.tex <<EOF
\end{verbatim}
EOF







Added mtt/bin/trans/lde_r2tex version [d2cd6c0a98].











































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lde_r2tex
# Reduce differential-algebraic to LaTex differential-algebraic equations.
# P.J.Gawthrop 10th May 1991, April 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/01/23 15:51:01  peterg
## Repleace eqnarray by equation + aligned -- this works with Latex2html
##
## Revision 1.2  1996/12/20 08:59:10  peterg
## Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
## conversion.
##
## Revision 1.1  1996/12/20 08:53:57  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_lde.tex

# Remove the old log file
rm -f lde_r2tex.log

# Use reduce to accomplish the transformation
reduce >lde_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the differential-algebraic equations file
in "$1_lde.r";

%Read the symbolic parameter file
%%in "$1_sympar.r";



OFF Echo;
OFF Nat;

%Read the substitution file
IN "$1_subs.r";

%Read the simplifying expressions file
IN "$1_simp.r";

OUT "$1_lde.tex";

%Write out the  differential-algebraic equations.

write "%File: $1_lde.tex";

write "%ordinary differential equations";
write "% Generated by MTT";

IF MTTNyz>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_lde_x}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNx DO
  BEGIN
	write "{";
	write MTTl(Row,1);
	write "}";
	write " &= 0";
        IF Row<MTTNx THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;


IF MTTNy>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_lde_y}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNy DO
  BEGIN
	write "MTTy", Row, " &= ";
	write "{";
	write MTTy(Row,1);
	write "}";
        IF Row<MTTNy THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;





SHUT "$1_lde.tex";
quit;
EOF

Added mtt/bin/trans/m/abg2cbg.m version [27f38055ab].







































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [port_bonds, status] = abg2cbg(system_name, system_type, full_name,
					port_bonds,
					port_bond_direction,
					port_status,
					derivative_causality,
					typefile, infofile, errorfile)

  ## abg2cbg - acausal to causal bg conversion
  ##
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function  abg2cbg.m
  ## Acausal bond graph to causal bond graph: mfile format
  ## [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.53  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.52  2004/09/07 18:22:53  geraint
  ## ## Issues a more helpful error message than the cryptic Octave stuff
  ## ## if there are unconnected ports.
  ## ##
  ## ## Revision 1.51  2004/02/20 20:42:40  geraint
  ## ## Initialize Flipped.cons with [] instead of "".
  ## ##
  ## ## Revision 1.50  2003/03/13 15:18:39  gawthrop
  ## ## Now uses __ to delimit subsystems in names.
  ## ##
  ## ## Revision 1.49  2001/07/26 05:02:53  geraint
  ## ## Now writes cbg.fig when under-causal (again).
  ## ##
  ## ## Revision 1.48  2001/07/23 23:20:27  gawthrop
  ## ## Now only writes to type.sh and cbg.m when causality is completed.
  ## ##
  ## ## Revision 1.47  2000/03/20 16:45:26  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.46  2000/02/17 16:14:49  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.45  1999/11/01 03:17:45  peterg
  ## ## Added extra info - current subsystem
  ## ##
  ## ## Revision 1.44  1999/03/11 23:54:11  peterg
  ## ## Include possibility of vector SS when finding port_bond_index
  ## ##
  ## ## Revision 1.43  1998/12/14 15:19:36  peterg
  ## ## Added missing "derivative_causality," argument to recursive call of
  ## ## this function
  ## ##
  ## ## Revision 1.42  1998/12/03 14:55:40  peterg
  ## ## Now uses number of components with complete causality to measure
  ## ## progress of algorithm -- Done.
  ## ## This replaces bond count -- done.
  ## ##
  ## ## Revision 1.41  1998/11/20 10:52:28  peterg
  ## ## Copies port bonds if the port bonds ARE set
  ## ## -- replaces Copies port bonds if the component bonds are NOT set
  ## ##
  ## ## Revision 1.40  1998/09/02 11:47:09  peterg
  ## ## Now uses explicit ordered list of ports instead of port.index.
  ## ## Note that subsystems are still treated in arbitrary order.
  ## ##
  ## ## Revision 1.39  1998/08/25 20:06:16  peterg
  ## ## Writes flipped port info
  ## ##
  ## ## Revision 1.38  1998/08/25 09:15:28  peterg
  ## ## Fixed couple of problems with using two copies of the one data
  ## ## stucture:
  ## ##
  ## ## ABG_field and ABG.field
  ## ##
  ## ## Maybe this is conceptually wrong?
  ## ##
  ## ## Revision 1.37  1998/08/25 08:33:29  peterg
  ## ## Now does ports as well - fixed string prob by using deblank
  ## ##
  ## ## Revision 1.36  1998/08/25 06:44:40  peterg
  ## ## Furhter revisions
  ## ##
  ## ## Revision 1.35  1998/08/24 10:16:32  peterg
  ## ## Coverted to new structure - still needs status sorting.
  ## ##
  ## ## Revision 1.34  1998/08/24 07:35:03  peterg
  ## ## About to go to new abg format.
  ## ##
  ## ## Revision 1.33  1998/07/29 13:36:37  peterg
  ## ## Don't set port status if there aren't any ports.
  ## ##
  ## ## Revision 1.32  1998/07/28 19:06:11  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.31  1998/07/28 13:15:10  peterg
  ## ## Vector SS ports included.
  ## ##
  ## ## Revision 1.30  1998/07/27 20:29:49  peterg
  ## ## Had another go at causality ....
  ## ##   1. Impose external causality onto all port bonds
  ## ##   2. Set C_cause.m so that it DOESN'T set causality
  ## ##       -- I_cause is already ok !
  ## ##
  ## ## Revision 1.29  1998/07/10 09:01:42  peterg
  ## ## Added error + info file in new form
  ## ##
  ## ## Revision 1.28  1998/07/08 09:23:42  peterg
  ## ## Undid the previous change -- needs more thought.
  ## ##
  ## ## Revision 1.27  1998/07/03 19:03:31  peterg
  ## ## Always override the causality of port bonds!
  ## ##
  ## ## Revision 1.26  1998/06/27 13:24:04  peterg
  ## ## Causality now set correctly for:
  ## ## 	multi-port C and I
  ## ## 	C and I with arrows pointing in
  ## ##
  ## ## Revision 1.25  1998/06/25 18:53:30  peterg
  ## ## Actually, the previous comment was optimistic.
  ## ## The port causalities on a compound are now forced to be the same as
  ## ## that specified by a a _cuase.m file (if it exists)
  ## ##
  ## ## Revision 1.24  1998/06/25 17:45:03  peterg
  ## ## No change -- but checked that explicit causality works!
  ## ##
  ## ## Revision 1.23  1998/04/04 10:46:37  peterg
  ## ## Coerces port bonds to have smae direction as the imposing bonds
  ## ## _cbg now generates the (coerced) components as welll as the (coerced)
  ## ## causality.
  ## ##
  ## ## Revision 1.22  1997/08/19 10:21:09  peterg
  ## ## Only copy port cuaslity info if not already set within the
  ## ## subsystem. I thought I'd done this already ....
  ## ##
  ## ## Revision 1.21  1997/08/18 16:25:25  peterg
  ## ## Minor bug fixes
  ## ##
  ## ## Revision 1.20  1997/08/18 12:45:24  peterg
  ## ## Replaced: comp_bonds = bonds(bond_list,:)
  ## ## by: 	for kk = 1:n_comp
  ## ## 	  comp_bonds(kk,:) = bonds(comp(kk),:);
  ## ## 	end;
  ## ##
  ## ## to avoid an octave bug in 1.92.
  ## ##
  ## ## Revision 1.19  1997/08/18 11:23:59  peterg
  ## ## Main component loop now misses out the ports (SS:[]) -- the causality
  ## ## is merely passed through these components.
  ## ##
  ## ## Revision 1.18  1997/08/08 08:11:04  peterg
  ## ## Suppress compoment trace.
  ## ##
  ## ## Revision 1.17  1997/08/07 16:10:13  peterg
  ## ## Move the if status ..  to the beginning of the main loop.
  ## ##
  ## ## Revision 1.16  1997/08/04 13:11:19  peterg
  ## ## Only change to component-orientated causality for simple components
  ## ## NOT for compound components.
  ## ##
  ## ## Revision 1.15  1997/01/05 12:25:59  peterg
  ## ## More informative message about port bonds incompatible with  ports
  ## ##
  ## ## Revision 1.14  1996/12/31 16:20:42  peterg
  ## ## Just write causality information at top level -- it gets a bit
  ## ## voluminous if written at deeper levels.
  ## ##
  ## ## Revision 1.13  1996/12/31 11:49:09  peterg
  ## ## Don't copy port bond causality if already set -- allows subsystem
  ## ## causality to be preset directely on named SS.
  ## ##
  ## ## Revision 1.12  1996/12/31 11:42:36  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.11  1996/12/07  17:10:48  peterg
  ## ## Allows port SS at top level - ie takes it to be an ardianry SS at top
  ## ## level.
  ## ##
  ## ## Revision 1.10  1996/12/04 21:48:55  peterg
  ## ## Compares full-name with empty string (instead of testing for zero
  ## ## length.
  ## ##
  ## ## Revision 1.9  1996/08/30  12:55:40  peter
  ## ## More heirachical stuff added.
  ## ##
  ## ## Revision 1.8  1996/08/26  10:04:25  peterg
  ## ## Fixed error due to a line wrap.
  ## ##
  ## ##Revision 1.7  1996/08/16  12:58:58  peter
  ## ## Now does preferred causality of I and C.
  ## ## Revision 1.6  1996/08/09 08:27:29  peter
  ## ## Added a few deguging lines
  ## ##
  ## ## Revision 1.5  1996/08/08 18:06:18  peter
  ## ## Unified file naming scheme
  ## ##
  ## ## Revision 1.4  1996/08/08 08:30:06  peter
  ## ## The cbg filename contains the system name - this makes things easier
  ## ## when setting up the m to fig translation and m to ese translation
  ## ##
  ## ## Revision 1.3  1996/08/05 18:53:21  peter
  ## ## Fixed bug passing causality from subsystems.
  ## ##
  ## ## Revision 1.2  1996/08/05 15:41:41  peter
  ## ## Now recursively does causality on subsystems.
  ## ##
  ## ## Revision 1.1  1996/08/04 17:55:55  peter
  ## ## Initial revision
  ## ##
  ## ###############################################################


  mtt_info(sprintf("Completing causality for subsystem %s", system_name), infofile);

  pc = '%';
  sub_delim = "__";		# Subsystem delimiter

  if nargin<1
    system_name = 'no_name';
  end;

  if nargin<4
    port_bonds = [];
  end;

  if nargin<5
    infofile = 'stdout';
  end;

  ## Are we at the top level of the heirarchy?
  at_top_level = strcmp(full_name, '');

  ## Create a file to contain shell commands which map subsystem types 
  ## onto components
#   if at_top_level # Then at top level
#     fprintf(typefile, "# Commands to map types onto subsystems\n");
#     fprintf(typefile, "# File %s_type.sh\n", system_name);
#     fprintf(typefile, "# Generated by MTT at %s\n\n", ctime(time));
#   end;

  ## Create the (full) system name
  if at_top_level
    full_name = system_name;
    system_type = system_name;
  else
    full_name = [full_name, sub_delim, system_name];
  end;
  
  fun_name = [system_type, "_abg"];

  disp("====================================");
  disp(["BEGIN: ", full_name, " (", fun_name, ")"]);
  disp("====================================");

  ## If no such function - then there is nothing to be done.
  if exist(fun_name)~=2
    mtt_error(["m-file ", fun_name, " does not exist"], errorfile);
    bonds = [];
    status = [];
    return
  end;

  ## Evaluate the system function to get the bonds and number of ports
  ##eval(["[bonds,components,n_ports,N_ports]=", fun_name, ";"]);
  eval(["[ABG]=", fun_name, ";"]);
  !isfield(ABG,"subsystems")
  if !isfield(ABG,"subsystems")# Are there any subsystems?
    return;			# Nothing to do
  else
    [n_subsystems,junk] = size(fieldnames(ABG.subsystems))
  endif
  
  if isfield(ABG,"portlist")# Are there any ports?
    [n_ports,junk] = size(ABG.portlist);
    ##     port_bond_index=zeros(n_ports,1);
    i_port = 0;
    for i=1:n_ports		# Find indices of the internal ports
      name = deblank(ABG.portlist(i,:)); # Name of this port
      eval(["port = ABG.ports.",name,";"]); # Extract port info
      for j=1:length(port.connections) # Maybe vector SS
	port_bond_index(++i_port) = abs(port.connections(j));
      endfor;
    endfor
  else
    n_ports = 0;
  endif				   

  
  [n_bonds,columns] = size(ABG.bonds);# Find number of bonds
  if (columns ~= 2)&(n_bonds>0)
    error("Incorrect bonds matrix: must have 2 columns");
  end;

  
  ## Find number of components
  ##  [n_components,m_components] = size(components);
  ##  if n_components==0 # there is nothing to be done
  ##    return
  ##  end;


  
  ## Coerce the port (SS:[]) component bonds to have the same direction as
  ## of the bonds in the encapsulating system -- but not at top level
  Flipped.ports="";Flipped.subs="";Flipped.cons=[];
  
  if (n_ports>0)&&(!at_top_level) # Coerce directions
    for i=1:n_ports
      name = deblank(ABG.portlist(i,:)); # Name of this port
      eval(["port = ABG.ports.",name,";"]); # Extract port info
      disp ("----");
      i
      name
      port
      port_bond_direction
      port.connections

      if (i > max (size (port_bond_direction)))
	the_system = sprintf ("\"%s:%s\"", system_type, system_name);
	mtt_error (sprintf ("Please check that %s has no disconnected ports.", the_system));
	mtt_error (sprintf ("abg2cbg: port_bond_direction(%d) does not exist.", i));
	exit(1);
      end
      if (sign(port.connections)!=port_bond_direction(i)) # Direction different?
      	eval(["ABG.ports.",name,".connections = - port.connections;"]); # Flip direction at port
	Flipped.ports=[Flipped.ports;name];	# Remember which port has been flipped
        bond_index=abs(port.connections); # Index of bond on port
      	mtt_info(sprintf("Flip port %s on %s" ...
			 ,name,full_name),infofile); # And report
      	for [subsystem,name] = ABG.subsystems # and at the other end
	  for k=1:length(subsystem.connections)
	    if (abs(subsystem.connections(k))==bond_index) # Then flip the connection
	      eval(["ABG.subsystems.",name,".connections(k)   = -subsystem.connections(k);"]);
	      Flipped.subs=[Flipped.subs;name];	# Remember which subsystem has been flipped
	      Flipped.cons=[Flipped.cons;k];	# Remember which connection has been flipped
      	      mtt_info(sprintf("Flip subsystem %s on %s" ...
			       ,name,full_name),infofile); # And report
	    endif
	  endfor
      	endfor			# subsystem = ABG.subsystems

      	ABG.bonds(bond_index,:) = -ABG.bonds(bond_index,:);	# Flip the bond causalities 
	##(these are arrow-orientated)
      endif			# Is the direction different?
    endfor			# port = ABG.ports
  endif				# (n_ports>0)&&(!at_top_level)

  ## If not at top level, then copy the port bonds.
  if !at_top_level		# Find number of port bonds

    for j=1:n_ports
      jj = port_bond_index(j); # The index of the bond
      for k = 1:2
	##	if ABG.bonds(jj,k)==0 # only copy if not already set
	##	  ABG.bonds(jj,k) = port_bonds(j,k);
	##	endif
	if port_bonds(j,k)!=0	# only copy if port bonds are set
	  ABG.bonds(jj,k) = port_bonds(j,k);
	endif
      endfor
    endfor
  else
    n_port_bonds=0;
  endif
  
  ## Causality indicator
  total = 2*n_bonds;
  done = sum(sum(abs(ABG.bonds)))/total*100;

  fields=["ports";"subsystems"];	# Do for both ports and subsystems -
  ## ports first
  for i=1:2
    field=deblank(fields(i,:));
    if isfield(ABG,field);
      eval(["ABG_field = ABG.",field, ";"]);
      field,ABG_field
      
      sum_ok = 0; n_comp = 0;
      for [subsystem,name] = ABG_field# Find % status = 0 (causally complete)
    	eval(["ok = (ABG_field.",name,".status==0);"]);
	sum_ok = sum_ok + ok; n_comp ++;
      endfor;
      Done = sum_ok/n_comp*100
      
      ## Outer while loop sets preferred causality
      ci_index=1;

      ##      for [subsystem,name] = ABG_field# Set new status field to -1
      ##    	eval(["ABG_field.",name,".status=-1;"]);
      ##      endfor;
      
      while( ci_index>0)
    	old_done = inf;
    	old_Done = inf;
	
    	while Done!=old_Done	# Inner loop propagates causality
	  old_Done = Done;
	  for [subsystem,name] = ABG_field
	    name,subsystem
      	    if subsystem.status != 0 # only do this if causality not yet complete
	      comp = subsystem.connections; # Get the bonds on this component
	      bond_list = abs(comp);
	      direction = sign(comp)'*[1 1];
              n_bonds = length(bond_list);

	      if strcmp(subsystem.type,"0") # Change names
	    	subsystem.type = "zero";
	      end;
	      if strcmp(subsystem.type,"1")
	    	subsystem.type = "one";
	      end;
	      
	      cause_name = [subsystem.type, "_cause"];# Component causality procedure name
	      eqn_name = [subsystem.type, "_eqn"]; #Component equation procedure name
	      
	      comp_bonds=[];	# Bonds on this component (arrow-orientated) -- these become the
	      for kk = 1:n_bonds # port bonds on the ith component of this subsystem.
	    	comp_bonds(kk,:) = ABG.bonds(bond_list(kk),:);
	      end;

	      if exist(eqn_name)!=2 # Try a compound component
		## Port status depends on whether the corresponding bonds are
		##  fully causal at this stage.
            	one = ones(n_bonds,1);
            	port_status = (sum(abs(comp_bonds'))'==2*one) - one;
		
	    	port_bond_direction = -sign(subsystem.connections)'; # Direction of bonds

            	if exist(cause_name)==2	# If there is a predefined causality function; use it
		  comp_bonds = comp_bonds.*(port_bond_direction*[1 1]);	# Convert from arrow orientated to component orientated causality
		  eval([ "[comp_bonds] = ", cause_name, "(comp_bonds);" ]); # Evaluate the built-in causality procedure

		  comp_bonds = comp_bonds.*(port_bond_direction*[1 1]);	# and convert from component orientated to arrow orientated causality
            	end;
		
		port_bond_direction,comp_bonds
	    	[comp_bonds,subsystem.status] = abg2cbg(name, subsystem.type, full_name, 
							comp_bonds, port_bond_direction, port_status, ...
							derivative_causality, ...
						    	typefile, infofile, errorfile);

		
	      else # its a simple component -- or explicit causality defined
		mtt_info(sprintf("Completing causality for component %s (%s)",
				 name, subsystem.type), infofile);
	    	disp(["---", name, " (", cause_name, ") ---"]);
	    	comp_bonds_in = comp_bonds
	    	
		## Convert from arrow orientated to component orientated causality
	    	comp_bonds = comp_bonds.*direction;
	    	
		## Evaluate the built-in causality procedure
		##eval([ "[comp_bonds,status(i)] = ", cause_name, "(comp_bonds);" ]);
	    	eval([ "[comp_bonds,subsystem.status] = ", cause_name, "(comp_bonds)" ]);
		## and convert from component orientated to arrow orientated causality
            	comp_bonds = comp_bonds.*direction; 
		
	    	comp_bonds_out = comp_bonds
	      end;
	      
	      ABG.bonds(bond_list,:) = comp_bonds;# Update the full bonds list
	      eval(["ABG_field.",name,".status = subsystem.status;"]);
    	    end;
	  end;

	  sum_ok = 0; n_comp = 0;
	  for [subsystem,name] = ABG_field# Find % status = 0 (causally complete)
    	    eval(["ok = (ABG_field.",name,".status==0);"]);
	    sum_ok = sum_ok + ok; n_comp ++;
	  endfor;

	  Done = sum_ok/n_comp*100
	  done = sum(sum(abs(ABG.bonds)))/total*100
	  ##disp(sprintf("Causality is #3.0f#s complete.", done, pc), infofile));
	  
    	endwhile			# done!=old_done
  	
    	[name,prefered] = getdynamic(ABG_field) # Set causality of a C or I which is not already set
    	if prefered==0
	  ci_index=0;
    	else
	  disp("Set causality of a C or I which is not already set")
	  eval(["ci_bond_index = ABG.",field,".",name,".connections;"]); # Get bonds
	  ci_direction = sign(ci_bond_index);
	  ci_bond_index = abs(ci_bond_index);
	  if derivative_causality
	    prefered = -prefered;
	  end;
	  ABG.bonds(ci_bond_index,1:2) = prefered*ci_direction'*[1 1]
	  eval(["ABG.subsystems.",name,".status=0"]); #set status of the C or I
    	endif
      endwhile			# ( ci_index>0)
      eval(["ABG.",field," = ABG_field;"]); # Copy back to actual structure
    endif			# isfield(CBG,field(i,:));
  endfor
  ##  if n_ports>0
  ##    status(1:n_ports) = zeros(n_ports,1); # Port status not relevant
  ##  endif;
  
  ## Print final causality
  ##  final_done =  (sum(status==zeros(n_components,1))/n_components)*100;
  
  if at_top_level
    mtt_info(sprintf("Final causality of %s is %3.0f%s complete.", ...
		     full_name, Done, pc), infofile);
    
    if Done<100
      mtt_error(sprintf("Unable to complete causality"),errorfile);
    end;
  endif				# at_top_level
  


  
  ## Return the port bonds - arrow orientated causality - and the direction 
  status=0;
  if !at_top_level # Not at top level
    port_bonds = ABG.bonds(port_bond_index,:); # Return port bonds
  endif;				# at top level

  for [subsystem,name] = ABG.subsystems
    if subsystem.status==-1	# Under causal
      status=-1;
      mtt_info(sprintf("Component %s (%s) is undercausal", name, subsystem.type), ...
	       infofile);
    elseif subsystem.status==1;	# Over causal
      status=-1;
      mtt_info(sprintf("Component %s (%s) is overcausal", name, subsystem.type), ...
	       infofile);
    endif;
  endfor;			# [subsystem,name] = ABG.subsystems

  ## write out the component .cbg file
    disp(["Writing ", full_name]);
    write_cbg(full_name,system_type,ABG,Flipped);
    fprintf(typefile, "$1%s$2%s$3\n", system_type, full_name);
  


  status, port_bonds
  disp("====================================");
  disp(["END: ", full_name, " (", fun_name, ")"]);
  disp("====================================");


endfunction;

Added mtt/bin/trans/m/abg2connections.m version [83377ee03d].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- put Emacs into Octave mode
##
##     ###################################### 
##     ##### Model Transformation Tools #####
##     ######################################
##
## abg2connections_m
##
## Creates a cell array recording the name of the
## component at each end of every bond.
##
## This data may differ from ibg.m because of the
## expansion of vector bonds that takes place
## during the generation of abg.m

function connections = abg2connections (abg)

  substructures = {"ports", "subsystems"};

  for i = [1,2]
    substruct = substructures{i};
    
    if (isfield (abg, substruct))
      for [val, key] = eval (sprintf ("abg.%s", substruct))
	for bond_id = val.connections
	  if (bond_id > 0)
	    connections.head {+bond_id} = key
	  else
	    connections.tail {-bond_id} = key
	  endif
	endfor
      endfor
    endif

  endfor

endfunction

Added mtt/bin/trans/m/add_bond.m version [575ba3aab9].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function comp_list = add_bond(comp_list,bond_number,comp_number);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Adds a new bond entry to a list of components -- pads the list appropriately.

[N,M] = size(comp_list);
if M==0
  M=1;
end;

if comp_number>N % Pad with zeros
  comp_list = [comp_list;zeros(comp_number-N,M)];
end;

this_comp = [nozeros(comp_list(comp_number,:)), bond_number];

L = length(this_comp);

[N,M] = size(comp_list);

if L<M %pad new row with zeros
  comp_list(comp_number,:) = [this_comp, zeros(1,M-L)];
elseif L>M %pad matrix with zeros and insert new row
  comp_list = [comp_list zeros(N,L-M)];
  comp_list(comp_number,:) = this_comp;
else %Sizes match so just insert
  comp_list(comp_number,:) = this_comp;
end;

Added mtt/bin/trans/m/add_row.m version [8618dcbf0d].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function New=add_row(Old,Row); # Adds a row to end of matrix

  [N,M]=size(Old);
  [n,m] = size(Row);

  if m>M
    Old = [Old, zeros(N,m-M)];	# Pad with zeros
  elseif M>m
    Row = [Row, zeros(n,M-m)];
  endif

  New = [Old;Row];

endfunction

	   

Added mtt/bin/trans/m/adjbond.m version [266020f198].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [index,distance] = adjbond(point,arrow_end,other_end);
% adjbond:  Determines the bond closest to the point 
%  [index,distance] = adjbond(point,arrow_end,other_end);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[n,m] = size(other_end);
one = ones(n,1);
arrow_distance = length2d(one*point - arrow_end);
min_arrow_distance = min(arrow_distance);

other_distance = length2d(one*point - other_end);
min_other_distance = min(other_distance);

min_distance = min([arrow_distance; other_distance]);

adjacent = [arrow_distance, other_distance] == min_distance*[one one];
[index,n] = getindex(adjacent,1);
distance = min_distance;

Added mtt/bin/trans/m/adjcomp.m version [142766d077].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function indices = adjcomp(arrow_end,other_end,components);
% adjcomp: Determines the two components at each end of the bond



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[n,m] = size(components);
one = ones(n,1);

arrow_distance = length2d(one*arrow_end - components(:,1:2));
min_arrow_distance = min(arrow_distance);

other_distance = length2d(one*other_end - components(:,1:2));
min_other_distance = min(other_distance);

arrow_adjacent = arrow_distance==min_arrow_distance*one;
other_adjacent = other_distance==min_other_distance*one;
[index,n] = getindex([arrow_adjacent,other_adjacent],1);

if index(1,2)==1
  indices = index(1:2,1)';
else
  indices = index(2:-1:1,1)';
end;


Added mtt/bin/trans/m/alias_args.m version [52ee84b0ea].



















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function args = alias_args(args,alias,delim,message,FileID,sys_name)

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2012/10/15 19:16:03  geraint
## split is obsolete in Octave, replaced with strsplit
##
## Revision 1.9  2009/11/02 16:54:03  geraint
## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
##
## Revision 1.8  2001/06/13 16:07:15  gawthrop
## Fixed bug with three separators in a row eg )/(
##
## Revision 1.7  2001/06/13 14:50:15  gawthrop
## Operator ^ now ok in args in abg and/or lbl
##
## Revision 1.6  2001/04/23 16:23:30  gawthrop
## Now stips ; from bottlom level argument list - allows aliasing of
## parts of a,b,c (eg a,b by using a,b;c
##
## Revision 1.5  2000/10/12 19:27:20  peterg
## Now writes out the aliased args ...
##
## Revision 1.4  2000/09/14 13:35:43  peterg
## appended '(' and ')' to SEPS
##   -- otherwise first argument after '(' doesn't get substituted
## (Fixed by Geraint)
##
## Revision 1.3  1998/08/11 14:09:05  peterg
## Replaced incorrect length(args>0) with !isempty(args)
##
## Revision 1.2  1998/07/27 10:24:20  peterg
## Included , in the the list of seperators (SEPS)
## This makes it substitute for bits of args separated by commas.
##
## Revision 1.1  1998/07/03 18:29:40  peterg
## Initial revision
##
###############################################################

  if isstruct(alias)
    if !isempty(args)
      Args = char(strsplit(args,delim)); args="";
      [N,M]= size(Args);
      for i=1:N
        arg = deblank(Args(i,:));
        arg_ = strrep(arg,",","__");
        if isfield(alias,arg_)
          eval(["new_arg = alias.", arg_,";"]);
  	  mtt_info(["Replacing ", arg, "\t by ", ...
		    new_arg, message],FileID);
  	  mtt_save_alias(arg,sys_name);
##	  printf("%s --> %s\n",arg,new_arg);
          arg = new_arg;
## 	else
## 	  mtt_info(["NOT replacing ", arg, message],FileID);
        end
        SEPS = ",+-*/()^";
        for j = 1:length(SEPS)
	  if (length(arg)>1)&&(length(findstr(arg,SEPS(j)))>0)
	    arg = alias_args(arg,alias,SEPS(j),message,FileID,sys_name);
	  end 
	end;
        args = sprintf("%s%s%s", args, delim, arg);
      end
      if (length(args)>1)
	if (substr(args,1,1)==delim)
	  args = substr(args,2); # loose leading delimiter
	endif
      endif
      
    end
  end;
endfunction;





Added mtt/bin/trans/m/args2arg.m version [88e206959b].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function arg = args2arg(args,n,FS)
% args2arg - pulls the nth argument from a FS-separated list.
% FS defaults to `;'.
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  args2arg.m
% arg = args2arg(args,n,FS) 
% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/08/30 09:58:55  peter
% %% Uses str2ch to exteact a char from a string.
% %%
% %% Revision 1.1  1996/08/27  12:50:43  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Field separator
if nargin<3
  FS = ';';
end;

Added mtt/bin/trans/m/cause2index.m version [d105a576d5].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function index = cause2index (causality)

  ## usage:  index = cause2index (causality)
  ##
  ## 

  if isstr(causality)
    if strcmp(causality,"effort")
      index = 1;
    elseif strcmp(causality,"flow")
      index = 2;
    elseif strcmp(causality,"state")
      index = 3
    else
      error(sprintf("Causality ""%s"" not recognised",causality));
    endif
    
  else
    if causality==1
      index = 1;
    elseif causality==-1
      index = 2;
    else
      error(sprintf("Causality ""%i"" not recognised",causality));
    endif
  endif

endfunction

Added mtt/bin/trans/m/cause2name.m version [1ae26e00bb].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = cause2name(causality)
% cause2name - converts causality to a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cause2name
% name = cause2name(causality)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if causality==1
  name = 'effort';
elseif causality ==-1
  name = 'flow';
else
  name = 'state';
end;

Added mtt/bin/trans/m/cause2num.m version [596056c3f2].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function num = cause2num(causality)
% cause2num - converts causality to a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cause2num
% num = cause2num(causality)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if causality==1
  num = 1;
elseif causality ==-1
  num = 2;
else
  num = 3;
end;

Added mtt/bin/trans/m/cbg2ese.m version [fbe5a968f6].







































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function structure = cbg2ese(system_name, system_type, system_cr, ...
			     system_args, full_name, full_name_repetition, ...
			     repetition,...
			     structure, structure_file,infofilenum)
  ## Set up globals to count the component inputs and outputs. This relies on
  ## the named SS (the ports) being in the correct order. Using globals here
  ## avoids changing the common argument list for all _eqn files for something
  ## which is only used for named SS components.
  global local_u_index
  global local_y_index
  global at_top_level
  ## 
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function  cbg2ese.m
  ## Acausal bond graph to causal bond graph: mfile format
  ## Structure matrix [states,nonstates,inputs,outputs,zero_outputs]
  
  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.54  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.53  2005/03/21 11:09:47  gawthrop
  ## ## Now handles bicausal SS component -
  ## ##   ie source-source or sensor-sensor
  ## ##
  ## ## Revision 1.52  2004/09/12 22:27:27  geraint
  ## ## Appended 't' to fopen mode string to open in text mode.
  ## ##
  ## ## Revision 1.51  2003/05/16 11:16:28  gawthrop
  ## ## Fixed bug with multiports
  ## ##
  ## ## Revision 1.50  2003/05/08 18:47:50  gawthrop
  ## ## Fixed __ bug when using * representations
  ## ##
  ## ## Revision 1.49  2003/03/13 15:19:04  gawthrop
  ## ## Now uses __ to delimit subsystems in names.
  ## ##
  ## ## Revision 1.48  2003/03/13 15:10:26  gawthrop
  ## ## Removed redundant final column
  ## ##
  ## ## Revision 1.47  2003/02/28 09:12:17  gawthrop
  ## ## Two more columns in _stuc.txt: causality and subsystem name
  ## ##
  ## ## Revision 1.46  2002/08/20 15:51:17  gawthrop
  ## ## Update to work with ident DIY rep
  ## ##
  ## ## Revision 1.45  2002/05/22 09:15:03  gawthrop
  ## ## Non-repetitive components no longer use _1 in names
  ## ##
  ## ## Revision 1.44  2001/11/11 18:12:30  geraint
  ## ## Moved fflush(structure_file) out of loop.
  ## ##
  ## ## Revision 1.43  2001/11/11 08:32:00  geraint
  ## ## fflush (structure_file).
  ## ##
  ## ## Revision 1.42  2001/04/23 16:23:30  gawthrop
  ## ## Now stips ; from bottlom level argument list - allows aliasing of
  ## ## parts of a,b,c (eg a,b by using a,b;c
  ## ##
  ## ## Revision 1.41  2001/04/15 21:15:41  geraint
  ## ## Added interface definition rep: _ICD.(txt|c|cc|m).
  ## ##
  ## ## Revision 1.40  2001/02/05 01:50:29  geraint
  ## ## No unit type comparison at ports if either is "none".
  ## ##
  ## ## Revision 1.40  2000/12/16 08:10:55  geraint
  ## ## No unit type comparison at ports if either is "none".
  ## ##
  ## ## Revision 1.39  2000/11/16 12:54:14  peterg
  ## ## Added checking of unit consistency at ports
  ## ##
  ## ## Revision 1.38  2000/11/16 10:00:57  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.37  2000/11/12 16:45:57  peterg
  ## ## Close ese file before recursive call of cbg2ese -- reopen when
  ## ## finished.
  ## ## THis prevents a new file being opened for each subsystem which fails
  ## ## when > 1K files opened
  ## ##
  ## ## Revision 1.36  2000/10/13 10:54:47  peterg
  ## ## Now writes out a unique name for each state etc
  ## ##
  ## ## Revision 1.35  2000/10/12 19:27:47  peterg
  ## ## Now writes the aliased args
  ## ##
  ## ## Revision 1.34  2000/09/01 08:42:44  peterg
  ## ## Cahged somes ends to end for etc for clarity
  ## ##
  ## ## Revision 1.33  2000/09/01 08:05:32  peterg
  ## ## Reformatted with out changing function
  ## ##
  ## ## Revision 1.32  1998/11/16 13:01:19  peterg
  ## ## Fixed problem with repetitions>1 due to new data structures -- now
  ## ## computes initial next_bond correctly
  ## ##
  ## ## Revision 1.31  1998/09/24 12:57:44  peterg
  ## ## Now ignores aliasing if no arguments given.
  ## ##
  ## ## Revision 1.30  1998/09/02 11:14:23  peterg
  ## ## Revised to use ordered lists of subsystems and ports
  ## ##
  ## ## Revision 1.29  1998/08/25 09:22:34  peterg
  ## ## Correctely recognises port SSs its now easy -- they are in there own
  ## ## field
  ## ##
  ## ## Revision 1.28  1998/08/25 08:31:42  peterg
  ## ## Fixed bug - didn't find the ports - use deblank
  ## ##
  ## ## Revision 1.27  1998/08/25 07:16:49  peterg
  ## ## Modified to data struture representation
  ## ##
  ## ## Revision 1.26  1998/08/24 14:53:55  peterg
  ## ## Uses new _cbg structure.
  ## ##
  ## ## Revision 1.25  1998/07/28 19:05:12  peterg
  ## ## Sttill has vector SS port bug?
  ## ##
  ## ## Revision 1.24  1998/07/27 10:26:02  peterg
  ## ## No change - but fixed bug in alias_args
  ## ##
  ## ## Revision 1.23  1998/07/08 12:33:51  peterg
  ## ## Reinstated the infofilenum parameter.
  ## ##
  ## ## Revision 1.22  1998/07/04 07:10:27  peterg
  ## ## Don't evaluate alias if no constitutive relationship or args and write
  ## ## message.
  ## ##
  ## ## Revision 1.21  1998/07/03 18:58:58  peterg
  ## ## Put arg alias stuff within function alias_args
  ## ## Called recursively to handle arithmetic expressions
  ## ##
  ## ## Revision 1.20  1998/07/03 14:39:09  peterg
  ## ## Added info messages a bit busy now!
  ## ##
  ## ## Revision 1.19  1998/04/12 11:58:19  peterg
  ## ## Rename port components by changing name_r to [name_r
  ## ##
  ## ## Revision 1.18  1998/04/11 18:59:16  peterg
  ## ## at_top_level now global - passed to SS components
  ## ##
  ## ## Revision 1.17  1998/04/04 10:47:31  peterg
  ## ## Uses (coerced) components from _cbg file - _abg not now used here.
  ## ##
  ## ## Revision 1.16  1998/03/06 09:38:58  peterg
  ## ## Now writes correct structure file for multiport C & I
  ## ##
  ## ## Revision 1.15  1997/12/16 18:24:33  peterg
  ## ## Added unknown_input to structure list
  ## ##
  ## ## Revision 1.14  1997/08/26 07:51:10  peterg
  ## ## Now counts the local input and outputs by order of appearence rather
  ## ## than by port number - it therfore handles ports with bicausality correctely.
  ## ##
  ## ## Revision 1.13  1997/05/19 16:45:56  peterg
  ## ## Fixed ISW bug -- deleted spurious ISW_eqn.m file
  ## ##
  ## ## Revision 1.12  1997/04/15  09:17:26  peterg
  ## ## Added the structure file - contains details of states etc.
  ## ## 
  ## ## Revision 1.11  1996/12/07 18:20:11  peterg
  ## ## Replaces null argument by a default and tells user.
  ## ##
  ## ## Revision 1.10  1996/12/07 17:37:07  peterg
  ## ## Now handles numbered SS ports appearing at top level.
  ## ##
  ## ## Revision 1.9  1996/12/04 21:49:47  peterg
  ## ## Compares full-name with empty string (instead of testing for zero
  ## ## length)
  ## ##
  ## ## Revision 1.8  1996/08/30  16:36:08  peter
  ## ## More info written to ese files.
  ## ##
  ## ## Revision 1.7  1996/08/30 11:23:13  peter
  ## ## Argument substitution implemented.
  ## ##
  ## ## Revision 1.6  1996/08/27  08:04:52  peterg
  ## ## Handles complex components and repetative components.
  ## ##
  ## ## Revision 1.5  1996/08/24  15:02:23  peter
  ## ## Writes `END;' to keep reduce happy.
  ## ##
  ## ## Revision 1.4  1996/08/19 09:03:41  peter
  ## ## Handles repeating components.
  ## ##
  ## ## Revision 1.3  1996/08/18 20:08:02  peter
  ## ## Included additional structure: structure(5) = zero_outputs.
  ## ##
  ## ## Revision 1.2  1996/08/08 18:08:11  peter
  ## ## Sorted out file naming sceme
  ## ##
  ## ## Revision 1.1  1996/08/08 15:53:23  peter
  ## ## Initial revision
  ## ##
  ## #############################################################
  
  ## disp("cbg2ese");
  ## system_name, system_type, full_name, repetition
  
  pc = "%";
  sub_delim = "__";		# Subsystem delimiter
  

  unit_error = "Component %s connects inconsistent ports with units %s and %s";
  unit_info = "Component %s connects ports with units %s and %s";  

  ## Set up the names corresponding to the structure matrix.
  structure_name = [
		    "state        ",
		    "nonstate     ",
		    "input        ",
		    "output       ",
		    "zero_output  ",
		    "unknown_input"];
  
  
  ## Are we at the top level of the heirarchy?
  at_top_level = strcmp(full_name, "");
  
  ## Create the (full) system name
  if at_top_level
    full_name = system_name;
    full_name_repetition = system_name;
    system_type = system_name;
  else
    full_name = [full_name, sub_delim, system_name];

    if (repetition>1)
      full_name_repetition = [full_name_repetition, ...
			      sub_delim, system_name, sub_delim, ...
			      num2str(repetition)];
    else
      full_name_repetition = [full_name_repetition, ...
			      sub_delim, system_name];
    endif
    
  end;
  
  
  
  cbg_name = [full_name, "_cbg"];
  if exist(cbg_name)~=2		# Return if cbg file doesn't exist
    disp([cbg_name, " does not exist"]);
    return
  end;
  
  ## Setup files
  ese_name = [full_name_repetition, "_ese.r"];
  ese_file = fopen(ese_name, "wt") # open file (first time)
  icd_file = fopen([full_name_repetition,"_icd.txt2"],"wt")

  fprintf(ese_file, "\n%s%s Equation file for system %s (file %s)\n", ...
	  pc, pc, full_name_repetition, ese_name);
  fprintf(ese_file, "%s%s Generated by MTT\n\n", pc, pc);
  
  ## Evaluate the system function to get the bonds
  eval(["CBG = ", cbg_name, ";"]);
  ##eval(["[bonds,status,system_type,components] = ", cbg_name, ";"]);
  ##  abg_name = [system_type, "_abg"];
  ##  cmp_name = [system_type, "_cmp"];
  ##  alias_name = [system_type, "_alias"];
  
  ## No longer needed - cbg now has components:  
  ##  eval(["[junk,components]=", abg_name, ";"]);
  
  ## Find number of bonds
  [n_bonds,columns] = size(CBG.bonds);
  if (columns ~= 2)&(n_bonds>0)
    error("Incorrect bonds matrix: must have 2 columns");
  endif;

  ## Set up initial bond units
  for i=1:n_bonds
    bond_effort_unit(i,:)="null";
    bond_flow_unit(i,:)="null";
  endfor

  ##  ## Find number of components
  ##  [n_components,columns] = size(components);
  ##  n_components = n_components
  
  ## Set up the first dummy bond number - needed for repetative components
  ##  next_bond = max(max(abs(components)))+1;
  next_bond = n_bonds+1;
  
  ## Set up the counters for the labelled SS. These are, by definition,
  ## encountered first and so the counters will not be messed up by subsystems.
  local_u_index = 0;
  local_y_index = 0;
  
  if (length(system_args)==0)
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s(%s)", ...
		     system_name,system_type), infofilenum);
    AliasingArguments=0;
  else
    AliasingArguments=1;
  endif;
  
  if (length(system_cr)==0)
    mtt_info(sprintf("No cr given so no cr aliasing done for system %s(%s)", ...
		     system_name,system_type), infofilenum);
    AliasingCRs=0;
  else
    AliasingCRs=1;  endif;
  
  
  fields=["ports";"subsystems"]; # Do for both ports and subsystems -
  ## ports first
  lists=["portlist";"subsystemlist"];
  for i=1:2
    field=deblank(fields(i,:));
    list=deblank(lists(i,:));
    if isfield(CBG,list);
      eval(["namelist=CBG.",list,";"]); # List of ports/subsystems
      [N,M]=size(namelist);	# Number of ports/subsystems
      for j=1:N
      	comp_name = deblank(namelist(j,:)); # Name of this component
	eval(["subsystem=CBG.",field,".",comp_name,";"]); # Pluck out the details
    	comp = subsystem.connections; # Connections
    	bond_list = abs(comp);
    	direction = sign(comp)'*[1 1];
				# Convert from arrow orientated to component orientated causality
    	comp_bonds = CBG.bonds(bond_list,:).*direction;
	
    	## disp(["---- ", field, " ---"]);    
    	
	if AliasingArguments	# Alias the args list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s", ...
			    comp_name,subsystem.type,full_name);    
    	  if isfield(CBG,"alias")
	    subsystem.arg = alias_args(subsystem.arg,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;
	
	if AliasingCRs	# Alias the CR list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s", ...
			    comp_name,subsystem.type,full_name);    
    	  if isfield(CBG,"alias")
	    subsystem.cr = alias_args(subsystem.cr,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;

	## Substitute positional ($1 etc) arguments
    	subsystem.cr = subs_arg(subsystem.cr,system_cr, ...
				"lin",full_name,subsystem.type,comp_name,infofilenum);
    	subsystem.arg = subs_arg(subsystem.arg,system_args, ...
				 "1",full_name,subsystem.type,comp_name,infofilenum);
    	
	## change name of 0 and 1 components -- matlab doesn't like numbers here
    	if strcmp(subsystem.type,"0")
	  subsystem.type = "zero";
    	endif;
    	if strcmp(subsystem.type,"1")
	  subsystem.type = "one";
    	endif;
    	
    	ports = length(bond_list);
    	
    	if subsystem.repetitions>1
	  port_pairs = ports/2;
	  if round(port_pairs)~=port_pairs;
	    mtt_info(["Repeated component ", comp_name, ...
		      " has an odd number of ports - ignoring repetitions"], infofilenum);
	    subsystem.repetitions = 1;
	  endif;
    	endif;
    	
    	if subsystem.repetitions>1
	  odd_bonds = bond_list(1:2:ports-1);
	  even_bonds = bond_list(2:2:ports);
    	endif;
    	
    	for k = 1:subsystem.repetitions
	  
	  if subsystem.repetitions>1
	    
	    if k==1
	      bond_list(1:2:ports-1) = odd_bonds;
	    else
	      bond_list(1:2:ports-1) = bond_list(2:2:ports);
	    endif;
	    
	    if k==subsystem.repetitions
	      bond_list(2:2:ports) = even_bonds;
	    else
	      new_bonds = [next_bond:next_bond+port_pairs-1];
	      next_bond = next_bond+port_pairs;
	      bond_list(2:2:ports) = new_bonds;
	    endif;
	    
	  endif;
	  
	  ## Invoke the appropriate equation-generating procedure
	  name_r = full_name_repetition;
	  eqn_name = [subsystem.type, "_eqn"];
	  
	  if exist(eqn_name)~=2 ## Try a compound component
            fclose(ese_file);	# Close but reopen later

	    disp("---PUSH---"); bond_list, comp_name, subsystem.type
	    structure = cbg2ese(comp_name, subsystem.type, subsystem.cr, subsystem.arg, ...
				full_name, full_name_repetition, ...
				k, structure,  structure_file, infofilenum);
	    
	    disp("---POP---");
	    ese_file = fopen(ese_name, "at") # open file (again)

	    eval(["subABG = ",subsystem.type , "_abg;"]); # Get the information

	    ## Link up the bonds for this compound component
	    fprintf(ese_file, ...
		    "\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		    pc, comp_name, subsystem.type);
	    
	    if (k>1)
	      name_comp_name = sprintf("%s%s%s%s%d", ...
				       full_name_repetition, sub_delim, ...
				       comp_name, sub_delim, k);
	    else
	      name_comp_name = sprintf("%s%s%s", ...
				       full_name_repetition, sub_delim, ...
				       comp_name);
	    endif
	    
	    
	    printf("\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		   pc, comp_name, subsystem.type);
	    
	    u_index = 0; y_index = 0; ## Count the inputs and outputs
	    for port_number=1:length(bond_list)
	      repetition,port_number
              port_bond_number = bond_list(port_number)
# 	      this_bond_effort_unit = ...
# 		  deblank(bond_effort_unit(port_bond_number,:))
# 	      this_bond_flow_unit = ...
# 		  deblank(bond_flow_unit(port_bond_number,:));

# 	      ## Extract the unit/domain stuff
#               this_port_name = subABG.portlist(port_number,:);
              
#               eval(sprintf("this_port = subABG.ports.%s;", ...
# 			   this_port_name));
# 	      if isfield(this_port,"units")
#                 eval(["effort_unit = ...
# 		    subABG.ports.",this_port_name,".units.effort;"]);
#                 eval(["flow_unit = ...
# 		    subABG.ports.",this_port_name,".units.flow;"]);
# 	      else
# 		effort_unit = "none";
# 		flow_unit = "none";
# 	      endif

# 	      ## and check consistency
#               ## Efforts
# 	      if strcmp(this_bond_effort_unit,"null") # set
# 		bond_effort_unit = ...
# 		    [bond_effort_unit(1:port_bond_number-1,:)
# 		     effort_unit
# 		     bond_effort_unit(port_bond_number+1:n_bonds,:)
# 		     ]
# 	      elseif (!strcmp(this_bond_effort_unit,"none") && !strcmp(effort_unit,"none")) # check
# 		mtt_info(sprintf(unit_info,full_name, effort_unit, ...
# 				 this_bond_effort_unit), infofilenum);
# 		if !strcmp(this_bond_effort_unit,effort_unit)
# 		  error_string = sprintf(unit_error, full_name, ...
# 					 effort_unit, ...
# 					 this_bond_effort_unit);
# 		  mtt_error(error_string);
# 		endif
# 	      endif
# 	      ## Flows
# 	      if strcmp(this_bond_flow_unit,"null") # set
# 		bond_flow_unit = ...
# 		    [bond_flow_unit(1:port_bond_number-1,:)
# 		     flow_unit
# 		     bond_flow_unit(port_bond_number+1:n_bonds,:)
# 		     ]
# 	      elseif (!strcmp(this_bond_flow_unit,"none") && !strcmp(flow_unit,"none")) # check
# 		mtt_info(sprintf(unit_info,full_name, flow_unit, ...
# 				 this_bond_flow_unit), infofilenum);
# 		if !strcmp(this_bond_flow_unit,flow_unit)
# 		  error_string = sprintf(unit_error, full_name, ...
# 					 flow_unit, ...
# 					 this_bond_flow_unit);
# 		  mtt_error(error_string);
# 		endif
# 	      endif
	      

	      ## Effort
	      if comp_bonds(port_number,1)==1 # Source
	     	u_index = u_index + 1;
	     	fprintf(ese_file, "%s_MTTu%d := %s;\n", ...
		 	name_comp_name, u_index, varname(name_r, ...
							 bond_list(port_number),1));
	      else # Sensor
	     	y_index = y_index + 1;
	     	fprintf(ese_file, "%s := %s_MTTy%d;\n", ...
		 	varname(name_r, ...
				bond_list(port_number),1), name_comp_name, y_index);
	      end;
	      ## Flow
	      if comp_bonds(port_number,2)==-1 # Source
	     	u_index = u_index + 1;
	     	fprintf(ese_file, "%s_MTTu%d := %s;\n", ...
		 	name_comp_name, u_index, varname(name_r, ...
							 bond_list(port_number),-1));
	      else # Sensor
	     	y_index = y_index + 1;
	     	fprintf(ese_file, "%s := %s_MTTy%d;\n", ...
		 	varname(name_r, ...
				bond_list(port_number),-1), name_comp_name, y_index);
	      end;	
	    end;
	    
	  else # its a simple component
	    fprintf(ese_file, "\n\t%s Equations for component %s (%s), repetition %d\n\n", ...
		    pc, comp_name, subsystem.type,k);
	    
	    
	    ##				# Is it a named port? (Name begins with [)
	    ##            Named_Port = (comp_name(1)=="[");
	    
	    if strcmp(field,"ports") #Add [ to start of name
	      name_r = ["[" name_r];
	    endif;
	    
	    ## Save the current structure
	    old_structure = structure;
	    
	    ## Generate the simple component equations
	    ## .. firstly replacing ; by , in argument list
	    subsystem_arg = strrep(subsystem.arg,";",",");

	    eval(["structure = ", ...
		  eqn_name, ...
		  "(name_r,bond_list,comp_bonds, ...
		    direction,subsystem.cr,subsystem_arg,structure,ese_file);" ]);
	    
	    ## If structure has changed, write info to structure file.
	    structure_change = structure-old_structure;
	    
	    ## The following line is to avoid probs with multiport C or I
	    ## it needs changing to handle multi ports correctly
	    structure_changes = sum(structure_change);
	    
	    structure_change = structure_change>zeros(size(structure_change));
 	    if structure_changes>0
 	      which_indices = getindex(structure_change,1);
 	      which_indices = which_indices(:,2)';
 	      for which_index=which_indices
 	    	value = structure(which_index);
	    	value_change=value-old_structure(which_index);
 	    	for k=1:value_change
		  if strcmp(subsystem.type,"SS") # One port, may be bicausal
		    cause_name = cause2name(-comp_bonds(1,k));
		  else		# Maybe multiport - but unicausal
		    cause_name = cause2name(-comp_bonds(k,1));
		  endif
 		  fprintf(structure_file, ...
 			  "%s\t%i\t%s\t%s%s%s\t%i\t%s\n", ...
 			  structure_name(which_index,:), value-k+1, ...
 			  comp_name, full_name_repetition, sub_delim, comp_name, ...
 			  repetition, cause_name); 
 	    	endfor;
 	      endfor;
 	    endif;
	  endif
	endfor
	fflush (structure_file);

	## component interface definition
	if isfield(CBG,"icd")
	  if isfield(CBG.icd,comp_name)
	    if AliasingArguments
	      subsystem.icd = alias_args(eval(["CBG.icd.",comp_name]),CBG.alias,";",message,infofilenum,full_name);
	    endif
	  endif
	  if (isfield(subsystem,"icd"))
	    subsystem.icd = subs_arg(subsystem.icd,system_args, ...
				     "null",full_name,subsystem.type,comp_name,infofilenum);
	    
	    fprintf(icd_file,"%s_%s\t%s\t",full_name_repetition,comp_name,subsystem.icd);
	    if (comp_bonds(1) == 1)
	      fprintf(icd_file,"output,");
	    elseif (comp_bonds(1) == -1)
	      fprintf(icd_file,"input,");
	    endif
	    if (comp_bonds(2) == 1)
	      fprintf(icd_file,"input\n");
	    elseif (comp_bonds(2) == -1)
	      fprintf(icd_file,"output\n");
	    endif
	  endif
	endif			# End of component interface definition

      endfor			# [subsystem,comp_name] = CBG_field
    endif			# isfield(CBG,field)
  endfor			# i=1:2

  fclose(icd_file);
  fclose(ese_file);		# Close
  
endfunction



Added mtt/bin/trans/m/cbg2fig.m version [7c46356009].































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function cbg2fig(system_name, system_type, full_name, ...
                 stroke_length, stroke_thickness, stroke_colour, ...
                 comp_font, comp_colour_u, comp_colour_o)

  ## cbg2fig - converts causal bg to figure
  ##
  ##     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% Model
  ##     Transformation Tools %%%%%
  ##     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ##
  ## Matlab function  cbg_m2fig Causal bond graph:  mfile format to fig
  ## file format The resultant fig file is the original _abg.fig with
  ## additional causal strokes superimposed. cbg2fig(system_name, ...
  ## system_type, full_name, ... stroke_length, stroke_thickness,
  ## stroke_colour, ... comp_font, comp_colour_u, comp_colour_o)
  ## Note this uses geometric info from _rbg.fig - so don't use with
  ## -abg switch.  

  ## P.J.Gawthrop May 1996
  ## Copyright (c) P.J.Gawthrop, 1996.

  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% Version control history
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% $Id$
  ## %% $Log$
  ## %% Revision 1.17  2004/09/12 22:27:27  geraint
  ## %% Appended 't' to fopen mode string to open in text mode.
  ## %%
  ## %% Revision 1.16  2001/03/23 14:58:16  gawthrop
  ## %% Fixed cosmetic bugs -- component display
  ## %%
  ## %% Revision 1.15  2001/03/23 11:20:20  gawthrop
  ## %% Fixed bug with vector components --NB takes geometric info from _rbg.fig
  ## %%
  ## %% Revision 1.14  2000/09/14 12:07:15  peterg
  ## %% Fixed overwriting of ports.
  ## %%
  ## %% Revision 1.13  2000/09/14 09:12:19  peterg
  ## %% Fixed stroke orientation bug with bent bonds
  ## %% Uses new info from the _rbg.m file - 4 new cols in rbonds
  ## %%
  ## %% Revision 1.12  2000/09/14 08:07:00  peterg
  ## %% Reformated as an Octave function
  ## %%
  ## %% Revision 1.11  2000/01/18 14:52:02  peterg
  ## %% Removed recursion --- maybe put back via a flag later
  ## %%
  ## %% Revision 1.10  1998/12/14 15:27:32  peterg
  ## %% Added separate handling of ports ( poss zero)
  ## %%
  ## %% Revision 1.9  1998/08/25 06:43:02  peterg
  ## %% Revised (partially) for data strucures - needs to include graphic info
  ## %% in abg file.
  ## %%
  ## %% Revision 1.8  1998/04/04 10:45:01  peterg
  ## %% Don't do strokes on port bonds
  ## %%
  ## %% Revision 1.7  1997/08/19 09:49:19  peterg
  ## %% Modified to take account of the expanded vector bonds. Only displays
  ## %% causality corresponding to the bond connecting the first element of
  ## %% the vector ports.
  ## %%
  ## %% Revision 1.6  1997/08/19 09:41:47  peterg
  ## %% Some debugging lines added.
  ## %%
  ## %% Revision 1.5  1997/05/16  07:33:45  peterg
  ## %% Now checks to see if sub system is a simple component before
  ## %% recursion.
  ## %% 0 --> zero
  ## %% 1 --> one
  ## %%
  ## %% Revision 1.4  1996/12/07  21:34:52  peterg
  ## %% Tests for null string with strcmp
  ## %% 
  ## %% Revision 1.3  1996/08/08  15:52:28  peter
  ## %% Recursive version.
  ## %% Fails due to octave bug - reported.
  ## %%
  ## %% Revision 1.2  1996/08/05 20:15:39  peter
  ## %% Prepared for recursive version.
  ## %%
  ## %% Revision 1.1  1996/08/05 18:12:25  peter
  ## %% Initial revision
  ## %%
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  if nargin<4
    stroke_length = 20;
  end;

  if nargin<5
    stroke_thickness = 2;
  end;

  if nargin<6
    stroke_colour = 1; %Blue
  end;

  if nargin<7
    comp_font = 18; %Helvetica bold
  end;

  if nargin<8
    comp_colour_u = 12; %Green
  end;

  if nargin<9
    comp_colour_o = 4; %Red
  end;

  ## Create a back slash '\' character.
  bs = char(92);

  ## Create the (full) system name
  if strcmp(full_name,'')
    full_name = system_name;
  else
    full_name = [full_name, '_', system_name];
  end;

  full_name_type = [full_name, '_', system_type];
  ## $$$ fig_name = [full_name_type, '_cbg.fig'];
  fig_name = [full_name, '_cbg.fig']
  
  ## Return if initial fig file doesn't exist
  if exist(fig_name)~=2
    return
  end;

  ## Setup file - append to the fig file
  filenum = fopen(fig_name, 'at');

  ## Get the raw and the processed bonds
  eval(['[rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = ', system_type, '_rbg;']);
  eval(["ABG = ", system_type, "_abg;"]);
  bonds=ABG.bonds;

  ## Original number of bonds
  [n_bonds,junk] = size(rbonds);

  ## Get the causal bonds
  #eval(['[cbonds,status]=', full_name, '_cbg;']);
  eval(["CBG = ", full_name, "_cbg;"]);
  cbonds=CBG.bonds;

  ## Check sizes
  [Rows,Columns] = size(rcomponents);
  if (Columns ~= 13)
    error('Incorrect rcomponents matrix: must have 13 columns');
  end;
  M_components = Columns;
  N_rcomponents = Rows;		# Number of raw components

  [N_rports,junk] = size(port_list);
  [N_components, Columns] = size(CBG.subsystemlist); # Number of derived
						     # components

  if isfield(CBG,'portlist')
    [N_ports, Columns] = size(CBG.portlist);
  else
    N_ports = 0;
  end


  ## Rotation matrix
  rot = [0 -1; 1 0];


  ## Determine coordinates of the arrow end of the bond and the other end
  ## and other geometry
  other_end_1 = rbonds(:,1:2);
  arrow_end = rbonds(:,3:4);
  other_end_2 = rbonds(:,5:6);

  distance_1 = length2d(other_end_1 - arrow_end);
  distance_2 = length2d(other_end_2 - arrow_end);
  which_end = (distance_1>distance_2)*[1 1];
  one = ones(size(which_end));
  other_end = which_end.*other_end_1 + (one-which_end).*other_end_2;
  arrow_barb = which_end.*other_end_2 + (one-which_end).*other_end_1;
  arrow_vector =  arrow_barb-arrow_end;
  unit_arrow_vector = arrow_vector./(length2d(arrow_vector)*[1 1]);
  
  ## Extract directional information
  arrow_end_direction = [rbonds(:,7), rbonds(:,8)];
  other_end_direction = [rbonds(:,9), rbonds(:,10)];


  ## Get indices of bonds with changed causality -- but ignore the extra bonds
  ## due to vector bond expansion
  changed_e = bonds(1:n_bonds,1)~=cbonds(1:n_bonds,1);
  changed_f = bonds(1:n_bonds,2)~=cbonds(1:n_bonds,2);
  changed = changed_e|changed_f;

  index_e  = getindex(changed_e,1)';
  index_f  = getindex(changed_f,1)';
  index_ef  = getindex(changed,1)';

  ## Print the new strokes in fig format
  if index_ef(1,1)>0
    for i = index_e		# Do the effort stroke - opp. side to arrow
      if cbonds(i,1)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;

      ## Work out the direction for the stroke (right angles to bond)
      unit_bond_vector = bond_vector./(length2d(bond_vector)*[1 1]);
      unit_stroke_vector = (rot*unit_bond_vector')';
      
      sig = sign(unit_arrow_vector(i,:)*unit_stroke_vector');
      stroke_end_2 = stroke_end_1 - stroke_length*sig*unit_stroke_vector;
      

      ## print the fig3 format firstline spec.
      polyline = 2; 
      firstline = fig3(polyline,stroke_thickness,stroke_colour);
      fprintf(filenum, '%s\n', firstline);

      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;

    for i = index_f		# Do the flow stroke - same side as arrow
      if cbonds(i,2)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;
      
      ## Work out the direction for the stroke (right angles to bond)
      unit_bond_vector = bond_vector./(length2d(bond_vector)*[1 1]);
      unit_stroke_vector = (rot*unit_bond_vector')';
      
      sig = sign(unit_arrow_vector(i,:)*unit_stroke_vector');
      stroke_end_2 = stroke_end_1 + stroke_length*sig*unit_stroke_vector;

      ## print the fig3 format firstline spec.
      polyline = 2; 
      firstline = fig3(polyline,stroke_thickness,stroke_colour);
      fprintf(filenum, '%s\n', firstline);

      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;
  end;

  ## Print all the components - coloured acording to causality.
  ## Miss out the ports
  
  for i = N_rports+1:N_rcomponents
    eval(['[comp_type,comp_name] = ', system_type, '_cmp(i);']);
    eval(["comp_status = CBG.subsystems.", comp_name, ".status;"]);

#     if i>N_rports			# Subsystem
#       comp_name = CBG.subsystemlist(i-N_rports,:);
#       eval(["comp_status = CBG.subsystems.", comp_name, ".status;"]);
#     else
#       comp_name = CBG.portlist(i,:);
#       eval(["comp_status = CBG.ports.", comp_name, ".status;"]);
#     end

    
    fig_params = rcomponents(i,3:M_components);
    coords = rcomponents(i,1:2);
    
    if comp_status==-1		# Then under causal
      fig_params(3) = comp_colour_u;
      fig_params(6) = comp_font;
    end;

    if comp_status==1		# Then over causal
      fig_params(3) = comp_colour_o;
      fig_params(6) = comp_font;
    end;


    ## Now print the component in fig format
    
    if index(comp_name,"mtt")==1 # Its a dummy name
      typename = comp_type;	# just show type
    else
      typename = [comp_type,":",comp_name];
    endif;

    Terminator = [bs, '001'];  
    real_index = 8;
    for j = 1:length(fig_params)
      if j==real_index
	fprintf(filenum, '%2.4f ', fig_params(j));
      else
	fprintf(filenum, '%i ', fig_params(j));
      endif
      

    endfor
    
    

    fprintf(filenum, '%1.0f %1.0f ', coords(1), coords(2)); 
    fprintf(filenum, '%s%s\n', typename, Terminator);

  endfor

  ## Close the file
  fclose(filenum);
  return

endfunction

Added mtt/bin/trans/m/cr2name.m version [27c939caaa].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function crname = cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args,port);
% cr2name - Constructs a string for the cr of a component.
% % 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cr2name
% cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args);

% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/08/22  18:31:06  peter
% %% Fixed comment bug.
% %%
% %% Revision 1.1  1996/08/22 13:14:39  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin<7
  port=0
end;


if length(args)==0
  a_comma = '';
else
  a_comma = ',';
end;

if length(cr)==0
  cause_name = '';
  lp = '';
  rp = '';
  c_comma = '';
else
  cause_name = cause2name(LHS_cause);
  lp = '(';
  rp = ')';
  c_comma = ',';
end

if port == 0
  port_name = '';
  p_comma = '';
else
  port_name = sprintf('%1.0f',port);
  p_comma = ',';
end;

crname = sprintf('%s%s%s%s%s%s%s%s%s\t%s', ...
    cr,lp, args, a_comma, port_name, p_comma, cause_name, c_comma, ...
    varname(name, RHS_number,RHS_cause),rp);
    
    





Added mtt/bin/trans/m/csm2sm.m version [82261a8899].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D] = csm2sm(A,B,C,D,E);
% [A,B,C,D] = csm2sm(A,B,C,D,E);
% Converts constrained-state matrices to state matrices.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


A = E\A;
B = E\B;

Added mtt/bin/trans/m/dm2fr.m version [55c366535d].


























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  fr = dm2fr(A,B,C,D,E,W,u0)
# fr = dm2fr(A,B,C,D,E,W,u0)
# Descriptor matrix to frequency response.
# A,B,C,D,E - descriptor matrices
# W vector of frequency points
# u0 input gain vector: u = u0*unit phasor

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.8  1997/06/13 13:05:38  peterg
# ## Replaced 'C*( (E*j*w - A) \ B*u0 ' by  C*( inv(E*j*w - A)*B*u0 ). \
# ## seems to have a bug for complex nos (??)
# ##
# ## Revision 1.7  1996/11/06  16:40:38  peterg
# ## Explicit definition of j
# ##
# ## Revision 1.6  1996/08/24  14:22:23  peter
# ## Put in a ; to avoid excessive log output.
# ##
# ## Revision 1.5  1996/08/16 14:26:37  peter
# ## Check and fix size of u0.
# ##
# ## Revision 1.4  1996/08/15 12:50:51  peter
# ## Put in a conj to undo effect of transpose.
# ##
# ## Revision 1.3  1996/08/15 11:53:44  peter
# ## Now has u0 input vector
# ##
# ## Revision 1.2  1996/08/15 10:24:28  peter
# ## Includes u0 argument.
# ##
# ## Revision 1.1  1996/08/10 14:11:28  peter
# ## Initial revision
# ##
# ###############################################################

[Ny,Nu] = size(D);
[Ny,Nx] = size(C);
N = length(W);

if nargin<7
  U0 = zeros(Nu,1);
  U0(1) = 1;
else
  for i=1:Nu
    U0(i) = u0(i);
  end;
end;

u0 = U0;

[n,m]=size(W);
if m>n
  W=W';
end;

[n,m]=size(u0);
if m>n
  u0=u0';
end;

j = sqrt(-1);
fr = zeros(N,Ny);
i = 0;
for w = W'
  i = i+1;
  ##   EjA = E*j*w - A;
  ##   iEjA = conj(EjA)*inv(conj(EjA)*EjA);
  ##   FR = C*iEjA*B*u0 + D*u0;
  FR = C*( (E*j*w - A) \ B*u0 ) + D*u0;
  ## FR = C*( inv(E*j*w - A)*B*u0 ) + D*u0;
  fr(i,:) = conj(FR');
end;













Added mtt/bin/trans/m/dm2ir.m version [205a34d87e].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ir = dm2ir(A,B,C,D,E,T);
% ir = dm2ir(A,B,C,D,E,T);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/08/10 14:16:04  peter
% %% Now has T vector input - it was tmax & tstep
% %%
% %% Revision 1.2  1996/08/10 11:49:39  peter
% %% Fixed multi-input/output problem
% %%
% %% Revision 1.1  1996/08/10 10:26:00  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;

[Ny,Nu] = size(D);
NN=Ny*Nu;

ir = zeros(N,NN);
i = 0;
for t = T'
  i=i+1;
  ir(i,:) = reshape(C*expm(A*t)*B, 1,NN);
end;

Added mtt/bin/trans/m/dm2sr.m version [ef0adb9b22].



































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/08/15 08:34:08  peter
% %% Added step gain (u0) and initial condition (x0)
% %%
% %% Revision 1.3  1996/08/11 19:33:24  peter
% %% Replaced exp by expm - whoops!
% %%
% %% Revision 1.2  1996/08/11 10:37:40  peter
% %% Corrected mistake in step-response calculation.
% %%
% %% Revision 1.1  1996/08/11 09:42:40  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if nargin<7
  u0 = zeros(Nu,1);
  u0(1) = 1;
end;

if nargin<8
  x0 = zeros(Nx,1);
end;

[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;

one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);
i = 0;
for t = T'
  i=i+1;
  if Nx>0
    expAt = expm(A*t);
    x = ( A\(expAt-one) )*B*u0 + expAt*x0;
    X(i,:) = x';
    if Ny>0
      y = C*x + D*u0;
      Y(i,:) = y';
    end;
  elseif Ny>0
    y = D*u0;
    Y(i,:) = y';
  end;
end;

Added mtt/bin/trans/m/equation.m version [20f1c9cc29].








































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function eqn =  equation(comp_type, name,cr,args,outbond,outcause,outport, ...
                         inbonds,incauses,inports)
  ## eqn is a string containing the equation
  ## 
  ## 
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function equations.m
  ## eqn =  equation(name,cr,args,outbond,outcause,outport, ...
  ##                              inbonds,incauses,inports)


  ## ############################################################### ## Version
  ## control history
  ## ############################################################### ## $Id:
  ## equation.m,v 1.6 2000/12/27 16:06:00 peterg Exp $ ## $Log:
  ## equation.m,v $ ## Revision 1.6  2000/12/27 16:06:00  peterg ## ***
  ## empty log message *** ## ## Revision 1.5  1996/12/05  11:26:51
  ## peterg ## Null strings now detected with strcmp not length. ## ##
  ## Revision 1.4  1996/09/12 16:42:01  peter ## Default now out side
  ## this function - need to be none for each ## component. ## ##
  ## Revision 1.3  1996/09/12 12:03:58  peter ## Added some error
  ## checking. ## If no constitutive relationship, only add diagonal
  ## elementts to ## default unity output. ## ## Revision 1.2
  ## 1996/09/10 11:29:47  peter ## Removed causality & port info when no
  ## constitutive relationship. ## ## Revision 1.1  1996/09/10 11:11:11peter
  ## ## Initial revision ##
  ## ###############################################################


  ## Find the number of inports
  nports = length(inbonds);

  ## Check some arguments
  if length(incauses) ~= nports
    error("equation.m: incauses inconsistent with inbonds");
  endif


  if length(inports) ~= nports
    error("equation.m: inports inconsistent with inbonds");
  endif


  ## Set up LHS
  LHS = varname(name, outbond, outcause);

  ## Set up various strings to get correct syntax if some strings are empty
  if strcmp(cr,"")
    cause_name = "";
    port_name = "";
    lp = "";
    rp = "";
    c_comma = "";
  else
    cause_name = cause2name(outcause);
    port_name = sprintf("%i", outport');
    lp = sprintf("(%s, ", comp_type); 
    rp = ")";
    c_comma = ",";
  end

  if strcmp(args,"")
    a_comma = "";
  else
    a_comma = ",";
  endif


  ## Set up first line of RHS
  RHS1 = sprintf("%s%s%s%s%s%s%s%s", ...
		 cr, lp, args, a_comma, cause_name, c_comma, port_name, c_comma);


  ## Set up rest of RHS - the input variables, causality and ports.
  RHS2 = "";
  for i=1:nports
    RHS2 = sprintf("%s\t%s", ...
		   RHS2, varname(name, inbonds(i), incauses(i)));
    
    if strcmp(cr,"")==0 # add the causality & port info
      RHS2 = sprintf("%s,%s,%i", ...
		     RHS2, cause2name(incauses(i)), inports(i));
      
    endif
    
    if (i<nports) # Add a comma
      RHS2 = sprintf("%s,",RHS2);
    else
      RHS2 = sprintf("%s",RHS2);

    endif

  endfor
  
  
  
  ## Set up equation
  eqn = sprintf("%s := %s%s%s;\n", LHS, RHS1, RHS2, rp);

endfunction

Added mtt/bin/trans/m/fig3.m version [482caa1bd5].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function first_line = fig3(object,thickness,colour)
% first_line = fig3(object,thickness,colour)
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Matlab function fig3.m
% Provides the "first line" format for polyines and text objects
% See fig 3 documentation for details
%
% P.J.Gawthrop June 1996
% Copyright (c) P.J.Gawthrop, 1996.

red = 4;
blue = 1;

if (object==2)	%Polyline
  sub_type = 1;
  line_style = 0;

  if nargin<2
    thickness = 3;
  end;

  if nargin<3
    colour = red;
  end;
  
  fill_colour = -1;
  depth = 0;
  pen_style = 0;
  area_fill = -1;
  style_val = 0.0;
  join_style = 0;
  cap_style = 0;
  radius = -1;
  f_arrow = 0;
  b_arrow = 0;
  npoints = 2;
  first_line = [... 
    int2str(object), ' ', ... 
    int2str(sub_type), ' ', ... 
    int2str(line_style), ' ', ...
    int2str(thickness), ' ', ...
    int2str(colour), ' ', ...
    int2str(fill_colour), ' ', ...
    int2str(depth), ' ', ...
    int2str(pen_style), ' ', ...
    int2str(area_fill), ' ', ...
    num2str(style_val), ' ' ...
    int2str(join_style), ' ', ...
    int2str(cap_style), ' ', ...
    int2str(radius), ' ', ...
    int2str(f_arrow), ' ', ...
    int2str(b_arrow), ' ', ...
    int2str(npoints)];
 
elseif (object==4) %text


else
  error('Object must be 2 (polyline) or 4(text)');
end;



Added mtt/bin/trans/m/figfig.m version [f08a96551e].




































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function figfig(filename,language,boxed,monochrome,key)
  ## Usage: figfig(filename[,language,boxed,monochrome])
  ## Puts octave figure into fig file (filename.fig)
  ## If second argument, converts to filename.language using fig2dev
  ## eg:
  ##    figfig("foo");
  ##    figfig("foo","eps");
  ##    figfig("foo","pdf");
  ## Boxed=1 gives a box around the figure
  ## Monochrome=1 gives a monchrome plot
  ## key=1 gives the key legend

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.11  2004/03/15 11:44:34  gawthrop
  ## Yet another option (to allow legend).
  ##
  ## Revision 1.10  2003/08/19 13:13:28  gawthrop
  ## No legend
  ##
  ## Revision 1.9  2002/09/12 08:39:27  gawthrop
  ## Removed spurious text
  ##
  ## Revision 1.8  2002/09/11 15:04:59  gawthrop
  ## Optional boxing
  ##
  ## Revision 1.7  2002/08/20 15:51:17  gawthrop
  ## Update to work with ident DIY rep
  ##
  ## Revision 1.6  2001/05/24 07:44:36  gawthrop
  ## Minor updates ..
  ##
  ## Revision 1.5  2001/05/10 19:08:35  gawthrop
  ## Cosmetic improvements
  ##
  ## Revision 1.4  2001/05/08 15:18:12  gawthrop
  ## Added trig and hyperbolic functions to argument exclusion list
  ##
  ## Revision 1.3  2001/04/10 12:54:50  gawthrop
  ## Minor fixes for sensitivity versions
  ##
  ## Revision 1.2  2000/12/27 16:06:02  peterg
  ## *** empty log message ***
  ##
  ## Revision 1.1  2000/11/03 10:43:10  peterg
  ## Initial revision
  ###############################################################

  if nargin<3
    boxed=0;
  endif
  
  if nargin<4
    monochrome=0;
  endif
  
  if nargin<5
    key=0;
  endif
  
  
  figfilename = sprintf("%s.fig",filename);
  
  eval(sprintf("gset output \"%s\" ",figfilename));

  if key!=1
    gset nokey			# No legend
  endif
  
  if (monochrome==1)
    gset term fig monochrome portrait fontsize 16 size 20 10 metric thickness 3
  else
    gset term fig color portrait fontsize 16 size 20 10 metric thickness 3
  endif
  replot;
  gset term x11
  gset output
  replot;

  if boxed # Add a box - makes a visible bounding box
    fid = fopen(figfilename,"a+t");
    fprintf(fid,"2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5\n");
    fprintf(fid,"\t9675 5310 9675 270 225 270 225 5310 9675 5310\n");
    fclose(fid);
  endif
  

  if nargin>1			# Do a file in another langueage
    sleep(1);
    psfilename = sprintf("%s.%s",filename,language);
    convert = sprintf("fig2dev -L%s %s > %s", language, figfilename, psfilename);
    system(convert);
  endif

  gset key			# Put it back
endfunction

Added mtt/bin/trans/m/getdynamic.m version [96484d5f7e].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,prefered] = getdynamic(subsystems);
# Get the index of a dynamic components which is not set.

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1996/08/16 12:51:22  peter
# ## Removed debugging lines.
# ##
# ## Revision 1.1  1996/08/16 12:50:41  peter
# ## Initial revision
# ##
# ###############################################################

  prefered = 0;			# No prefered causality to start with
  for [subsystem,name] = subsystems
    if subsystem.status==-1 # Undercausal
      if strcmp(subsystem.type,'C')
      	prefered=-1;
      	break;
      endif;
      if strcmp(subsystem.type,'I')
      	prefered=1;
      	break;
      endif;
    endif;
  endfor;

  if prefered==0
    name = "";
  end;
  
endfunction

Added mtt/bin/trans/m/getindex.m version [b17581b243].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [index, n, otherindex, m] = getindex(array,value);
% Finds the n indices of the elements of array equal to value
% otherindex contains indeces of the the m other  elements.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[N,M] = size(array);
n=0; m=0;
for i=1:N
  for j = 1:M
    if array(i,j)==value
      n=n+1;
      index(n,:) = [i j];
    else
      m=m+1;
      otherindex(m,:) = [i j];
    end;
  end;
end;


if (M==1)&(n>0)
  index = index(:,1);
end;

if (M==1)&(m>0)
  otherindex = otherindex(:,1);
end;

% Octave doesn't like empty matrices
if n==0
  index=0;
end;

if m==0
  otherindex=0;
end;



Added mtt/bin/trans/m/ibg2abg.m version [acf7448537].




























































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*-

function [bonds,components,n_vector_bonds] = ...
      ibg2abg(name,bonds,infofile,errorfile)

  ## write useful quantity of data to log
  struct_levels_to_print(6);

  ################################
  ## create component structure ##
  ################################
  
  ## loop over each bond in ibg.m file
  for [bond, bond_name] = bonds
    ## get the bond number
    bond_name
    i = str2num(strtok(bond_name, "bond"))

    ## populate "head" and "tail" structures
    ## then copy the contents to an overall structure

    ## track (signed) vector bond number within each component
    head.index = +i
    tail.index = -i

    ## extract type of component at each end
    head_type = deblank(char(strsplit(bond.head.component, ":"))(1,:))
    tail_type = deblank(char(strsplit(bond.tail.component, ":"))(1,:))

    ## extract name of component at each end
    head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:))
    tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:))

    ## extract port label data
    head.label = bond.head.ports
    tail.label = bond.tail.ports

    disp("--checking head and tail for components or ports --") 
    ## determine whether internal port or subsystem
    ## and fix names of ports
    if (strcmp(head_type, "SS") & (index(head_name, "[") == 1))
      head_comp_or_port = "port"
      head_name = mtt_strip_name(head_name);
    else
      head_comp_or_port = "comp"
    endif
    if (strcmp(tail_type, "SS") & (index(tail_name, "[") == 1))
      tail_comp_or_port = "port"
      tail_name = mtt_strip_name(tail_name);
    else
      tail_comp_or_port = "comp"
    endif

    ## copy data to object structure (objects)
    cmd = sprintf("objects.%s.%s.type = '%s';",
		  head_comp_or_port, head_name, head_type)
    eval(cmd)
    cmd = sprintf("objects.%s.%s.type = '%s';",
		  tail_comp_or_port, tail_name, tail_type)
    eval(cmd)
    
    cmd = sprintf("objects.%s.%s.bond%i = head;", 
		  head_comp_or_port, head_name, i)
    eval(cmd)
    cmd = sprintf("objects.%s.%s.bond%i = tail;", 
		  tail_comp_or_port, tail_name, i)
    eval(cmd)
  endfor    

  disp("--finished extracting data from ibg.m --")
  objects
    
  ## object structure:
  ##
  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       bond%i
  ##         label
  ##   port
  ##     %s (name)
  ##       type
  ##       bond%i
  ##         label
  ##
  ## "comp" contains components, subsystems and external SS
  ## "port" contains internal SS:[...]

  ####################################################
  ## count number of vector bonds on each component ##
  ####################################################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      n = size(fieldnames(comp))(1) - 1;
      eval(sprintf("objects.comp.%s.n_bonds = %i;",
		   comp_name, n));
    endfor
  endif
  
  if (isfield(objects, "port"))
    for [port, port_name] = objects.port
      n = size(fieldnames(port))(1) - 1;
      eval(sprintf("objects.port.%s.n_bonds = %i;",
		   port_name, n));
    endfor
  endif

  disp("-- finished counting number of bonds on components --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label

  ########################################################
  ## ensure labels exist on all ports of each component ##
  ########################################################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      if (strcmp(comp.type, "0") | strcmp(comp.type, "1"))

	## convert type
	if (strcmp(comp.type, "0"))
	  comp.type = "zero";
	elseif (strcmp(comp.type, "1"))
	  comp.type = "one";
	endif

	## component is a junction
	n_named_ports = 0;
	
	## get labelled ports
	for [bond, bond_name] = comp
	  if (index(bond_name, "bond") == 1)
	    if (! isfield (bond, "label"))
	      bond.label = "[]"
	    endif
	    if (! strcmp(bond.label, "[]"))
	      n_named_ports += 1;
	      port_label = bond.label;
	    endif
	  endif
	  eval(sprintf("comp.%s = bond;", bond_name));
	endfor
	
	## attach labels to unlabelled ports
	if (n_named_ports == 0)
	  mtt_info(sprintf("Defaulting all ports on junction %s to 'in'", ...
			   comp_name), infofile);
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      bond.label = "in";
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	elseif (n_named_ports == 1)
	  mtt_info(sprintf("Defaulting all ports on junction %s to %s", ...
			   comp_name, port_label), infofile);
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      bond.label = port_label;
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	elseif (n_named_ports != comp.n_bonds)
	  mtt_error(sprintf("Junction must have 0,1 or %i port labels", ...
			    comp.n_bonds), errorfile);
	endif
	
      else
	## component is not a junction
	for [bond, bond_name] = comp
	  if (index(bond_name, "bond") == 1)
	    if (strcmp(bond.label, "[]"))
	      if (bond.index > 0)
		bond.label = "in";
	      else
		bond.label = "out";
	      endif
	    else
	      bond.label = mtt_strip_name(bond.label);
	    endif
	  endif
	  eval(sprintf("comp.%s = bond;", bond_name));
	endfor
      endif
      
      eval(sprintf("objects.comp.%s = comp;", comp_name));
    endfor
  endif

  ####################
  ## expand aliases ##
  ####################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      if ((! strcmp(comp.type, "zero")) & (! strcmp(comp.type, "one")))
	alias = eval(sprintf("%s_alias", comp.type));
	if (isstruct(alias))
	  for [bond, bond_name] = comp;
	    if (isstruct(bond))
	      if (isfield(alias, bond.label))
		old_name = bond.label;
		new_name = eval(sprintf("alias.%s", old_name));
		bond.label = new_name;
		mtt_info(sprintf("Aliasing [%s] on %s (%s) to [%s]",
				 old_name, comp_name, comp.type, new_name),
			 infofile);
	      endif
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	endif
	eval(sprintf("objects.comp.%s = comp;", comp_name));
      endif
    endfor
  endif

  disp("-- finished expanding aliases --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label

  ##########################################
  ## create sub-bonds according to labels ##
  ##########################################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      for [bond, bond_name] = comp
	if (index(bond_name, "bond") == 1)
	  [sub_bonds, n_sub_bonds] = split_port(bond.label);
	  for i = 1:n_sub_bonds
	    eval(sprintf("bond.subbond%i.label = '%s';",
			 i, deblank(sub_bonds(i,:))))
	  endfor
	endif
	eval(sprintf("comp.%s = bond;", bond_name));
      endfor
      eval(sprintf("objects.comp.%s = comp;", comp_name));
    endfor
  endif

  if (isfield(objects, "port"))
    for [port, port_name] = objects.port
      for [bond, bond_name] = port
	if (index(bond_name, "bond") == 1)
	  [sub_bonds, n_sub_bonds] = split_port(bond.label);
	  for i = 1:n_sub_bonds
	    eval(sprintf("bond.subbond%i.label = '%s';",
			 i, deblank(sub_bonds(i,:))));
	  endfor
	endif
	eval(sprintf("port.%s = bond;", bond_name));
      endfor
      eval(sprintf("objects.port.%s = port;", port_name));
    endfor
  endif

  disp("-- finished creating sub-bonds --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i

  #########################################
  ## assign a unique number to each bond ##
  #########################################

  unique_bond_number = 0;
  
  for [bond, bond_name] = bonds
    i = str2num(strtok(bond_name, "bond"));

    ## extract type of component at each end
    head.type = deblank(char(strsplit(bond.head.component, ":"))(1,:));
    tail.type = deblank(char(strsplit(bond.tail.component, ":"))(1,:));

    ## extract name of component at each end
    head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:));
    tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:));
 
    ## determine whether internal port or subsystem
    ## and fix names of ports
    if (strcmp(head.type, "SS") & (index(head_name, "[") == 1))
      head_comp_or_port = "port";
      head_name = mtt_strip_name(head_name);
    else
      head_comp_or_port = "comp";
    endif
    if (strcmp(tail.type, "SS") & (index(tail_name, "[") == 1))
      tail_comp_or_port = "port";
      tail_name = mtt_strip_name(tail_name);
    else
      tail_comp_or_port = "comp";
    endif

    ## create strings to reference each component
    head_str = sprintf("objects.%s.%s.bond%i",
		       head_comp_or_port, head_name, i)
    tail_str = sprintf("objects.%s.%s.bond%i",
		       tail_comp_or_port, tail_name, i)

    head_bond = eval(head_str);
    tail_bond = eval(tail_str);
    
    ## check compatible sizes
    head.n_subs = size(fieldnames(head_bond))(1) - 2;
    tail.n_subs = size(fieldnames(tail_bond))(1) - 2;
    if (head.n_subs != tail.n_subs)
      mtt_error(sprintf("Vector ports '%s' (%s:%s) and '%s' (%s:%s) are not compatible",
			head_bond.label, head.type, head_name,
			tail_bond.label, tail.type, tail_name),
		errorfile);
    elseif (head.n_subs > 1)
      mtt_info(sprintf("Vector port '%s'(%s:%s) matches '%s' (%s:%s)",
		       head_bond.label, head.type, head_name,
		       tail_bond.label, tail.type, tail_type),
	       infofile);
    endif

    ## write type at other end
    eval(sprintf("%s.other_end_type = '%s';",
		 head_str, tail.type));
    eval(sprintf("%s.other_end_type = '%s';",
		 tail_str, head.type));

    ## assign bond number
    for i = 1:head.n_subs
      ++unique_bond_number;
      eval(sprintf("%s.subbond%i.index = +%i;",
		   head_str, i, unique_bond_number));
      eval(sprintf("%s.subbond%i.index = -%i;",
		   tail_str, i, unique_bond_number));

      ## write causality for bond
      if (strcmp(bond.causality.effort, "head"))
	eval(sprintf("causality(%i,1) = +1;", unique_bond_number));
      elseif (strcmp(bond.causality.effort, "tail"))
	eval(sprintf("causality(%i,1) = -1;", unique_bond_number));
      else
	eval(sprintf("causality(%i,1) = 0;", unique_bond_number));
      endif

      if (strcmp(bond.causality.flow, "head"))
	eval(sprintf("causality(%i,2) = -1;", unique_bond_number));
      elseif (strcmp(bond.causality.flow, "tail"))
	eval(sprintf("causality(%i,2) = +1;", unique_bond_number));
      else
	eval(sprintf("causality(%i,2) = 0;", unique_bond_number));
      endif
      
    endfor
  endfor

  disp("-- finished assigning unique numbers to bonds --")
  objects
  
  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index

  ## causality matrix is called "bonds"
  bonds = causality
  disp("-- finished writing bonds matrix --")  

  #################################
  ## map component data to cmp.m ##
  #################################

  ## count number of components
  if (isfield(objects, "comp"))
    n_comps = size(fieldnames(objects.comp), 1)
  else
    n_comps = 0;
  endif

  ## count number of internal ports
  if (isfield(objects, "port"))
    n_ports = size(fieldnames(objects.port), 1)
  else
    n_ports = 0;
  endif

  ## read data from _cmp.m
  for cmp = 1:(n_comps + n_ports)
    [this_type, this_name] = eval(sprintf("%s_cmp(%i)", name, cmp));
    ## determine if internal port (and fix name) or subsystem
    if (strcmp(this_type, "SS") & (index(this_name, "[") == 1))
      comp_or_port = "port";
      this_name = mtt_strip_name(this_name)
    else
      comp_or_port = "comp";
    endif
    eval(sprintf("objects.%s.%s.index = cmp;", comp_or_port, this_name));
  endfor

  disp("-- finished getting component indices from cmp.m --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index
  ##       index
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index
  ##       index

  ##########################
  ## write n_vector_bonds ##
  ##########################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      n_vector_bonds(comp.index,1) = comp.n_bonds;
    endfor
  endif

  disp("-- finished writing n_vector_bonds --")
  n_vector_bonds

  ###########################################
  ## Write connections matrix (components) ##
  ###########################################
  
  if (isfield(objects, "comp"))
    n_comps = size(fieldnames(objects.comp))(1);
  else
    n_comps = 0;
  endif

  components = zeros(n_comps+n_ports, max(n_vector_bonds));

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      ## get portlist for component      
      if exist([comp.type, '_cause']) == 0
 	eval(sprintf("ABG = %s_abg;", comp.type));
 	if isfield(ABG, "portlist")
 	  port_list = ABG.portlist;
 	else
 	  error(sprintf("Component %s has no ports", comp.type));
 	endif
      else
	## must be a simple component:
	## lib/comp/simple/comp_ports.m assigns port numbers
 	port_list = comp_ports(comp.type, comp.n_bonds)
      endif
      ## but do what with it?

      counter = 0;

      n_ports = size(port_list,1)
      if (strcmp(comp.type, "zero")) | (strcmp(comp.type, "one"))
	for port = 1 : n_ports
	  component_type = comp.type
	  the_port_list = port_list
	  the_port = port
	  label = port_list(port,:)
	  if (index (label, "[") == 1)
	    label = mtt_strip_name(label)
	  endif
	  label = deblank(label)
	  
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      for [sub_bond, sub_bond_name] = bond
		
		if (index(sub_bond_name, "subbond") == 1)
		  sub_bond_label = sub_bond.label
		  if (index (sub_bond_label, "[") == 1)
		    sub_bond_label = mtt_strip_name(sub_bond_label)
		  endif
		  sub_bond_label = deblank(sub_bond_label)
		  		  
		  if (strcmp(sub_bond_label, label) | strcmp (sub_bond_label,"in"))
		    components(comp.index, ++counter) = sub_bond.index
		  endif
		  
		endif
	      endfor
	    endif
	  endfor
	endfor
	
      elseif (n_ports == 1)
	## no ordering necessary
	for [bond, bond_name] = comp
	  if (index(bond_name, "bond") == 1)
	    for [sub_bond, sub_bond_name] = bond
	      if (index(sub_bond_name, "subbond") == 1)
		components(comp.index, ++counter) = sub_bond.index
	      endif
	    endfor
	  endif
	endfor

      else
	## multiple ports, need to order them
	for port = 1 : n_ports
	  component_type = comp.type
	  the_port_list = port_list
	  the_port = port
	  label = port_list(port,:)
	  if (index (label, "[") == 1)
	    label = mtt_strip_name(label)
	  endif
	  label = deblank(label)
		    	  
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      for [sub_bond, sub_bond_name] = bond

		if (index(sub_bond_name, "subbond") == 1)
		  sub_bond_label = sub_bond.label
		  if (index (sub_bond_label, "[") == 1)
		    sub_bond_label = mtt_strip_name(sub_bond_label)
		  endif
		  sub_bond_label = deblank(sub_bond_label)

		  ## unalias sub_bond label
		  if exist([comp.type, '_alias'])
		    eval(sprintf("alias = %s_alias", comp.type))
		    if isstruct(alias)
		      while_counter = 0;
		      while isfield(alias, sub_bond_label)
			old_sub_bond_label = sub_bond_label;
			sub_bond_label = eval(sprintf("alias.%s", sub_bond_label))
			if strcmp(old_sub_bond_label, sub_bond_label)
			  break;
			endif
		      endwhile
		    endif
		  endif
		    
		  if (strcmp(sub_bond_label, label))
		    components(comp.index, ++counter) = sub_bond.index
		  endif

		endif
	      endfor
	    endif
	  endfor
	endfor

      endif
    endfor
  endif
  disp("-- finished getting port_list --")
  port_list
  
   if (isfield(objects, "port"))
     for [port, port_name] = objects.port
       counter = 0;
       for [bond, bond_name] = port
 	if (index(bond_name, "bond") == 1)
 	  for [sub_bond, sub_bond_name] = bond
 	    if (index(sub_bond_name, "subbond") == 1)
 	      components(port.index, ++counter) = sub_bond.index;
 	    endif
 	  endfor
 	endif
       endfor
     endfor
   endif

  disp("-- finished writing components matrix --")
  components

endfunction

Added mtt/bin/trans/m/length2d.m version [ad2755e59c].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function len = length2d(vector_array)
% length2d - Finds (geometric) length of row vectors stacked 
% into a column vector
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  length2d
% len = length2d(vector_array)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% 

len = sqrt(sum(vector_array'.^2)');

Added mtt/bin/trans/m/makedef.m version [4b8ed092ca].




































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function makedef(structure,deffilenum);

  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% Version control history
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% $Id$
  ## %% $Log$
  ## %% Revision 1.8  2000/10/20 13:26:41  peterg
  ## %% Made sure that mttui not declared twice
  ## %%
  ## %% Revision 1.7  2000/10/20 13:16:29  peterg
  ## %% Reformated
  ## %%
  ## %% Revision 1.6  1996/12/07 18:21:57  peterg
  ## %% Now uses fopen + file number
  ## %%
  ## %% Revision 1.5  1996/11/09 21:05:44  peterg
  ## %% Only generates MTTIm when at least 2 states!
  ## %%
  ## %% Revision 1.4  1996/08/30  19:42:36  peter
  ## %% Added newline at end of file.
  ## %%
  ## %% Revision 1.3  1996/08/24 15:06:22  peter
  ## %% Write `END;' at end to please reduce.
  ## %%
  ## %% Revision 1.2  1996/08/18 20:05:20  peter
  ## %% Put unded version control
  ## %%
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



  states = structure(1);
  nonstates=structure(2);
  inputs=structure(3);
  outputs=structure(4);
  zero_outputs = structure(5);
  internal_inputs = structure(6);
  connecting_inputs = structure(7);

  pc = '%';
  ## Declare reduce constants;
  fprintf(deffilenum, 'MTTNx := %1.0f;\n', states);
  fprintf(deffilenum, 'MTTNz := %1.0f;\n', nonstates);
  fprintf(deffilenum, 'MTTNu := %1.0f;\n', inputs);
  fprintf(deffilenum, 'MTTNy := %1.0f;\n', outputs);
  fprintf(deffilenum, 'MTTNyz := %1.0f;\n', zero_outputs);
  fprintf(deffilenum, 'MTTNui := %1.0f;\n', internal_inputs);
  fprintf(deffilenum, 'MTTNuc := %1.0f;\n', connecting_inputs);

  ## Declare reduce matrices
  fprintf(deffilenum, '%s Declare reduce matrices\n', pc);
  if states>0
    fprintf(deffilenum, 'matrix MTTx(%1.0f,1);\n', states);
    fprintf(deffilenum, 'matrix MTTdx(%1.0f,1);\n', states);
  endif

  if nonstates>0
    fprintf(deffilenum, 'matrix MTTz(%1.0f,1);\n', nonstates);
    fprintf(deffilenum, 'matrix MTTdz(%1.0f,1);\n', nonstates);
  endif

  if inputs>0
    fprintf(deffilenum, 'matrix MTTu(%1.0f,1);\n', inputs);
    fprintf(deffilenum, 'matrix MTTdu(%1.0f,1);\n', inputs);
  endif

  if outputs>0
    fprintf(deffilenum, 'matrix MTTy(%1.0f,1);\n', outputs);
  endif

  if zero_outputs>0
    fprintf(deffilenum, 'matrix MTTyz(%1.0f,1);\n', zero_outputs);
    fprintf(deffilenum, 'matrix MTTui(%1.0f,1);\n', zero_outputs);
  elseif internal_inputs>0
    fprintf(deffilenum, 'matrix MTTui(%1.0f,1);\n', inputs);
  endif

  if connecting_inputs>0
    fprintf(deffilenum, 'matrix MTTuc(%1.0f,1);\n', connecting_inputs);
  endif


  ## Make an Nx x Nx unit matrix
  if states>0
    fprintf(deffilenum, 'matrix MTTI(%1.0f,%1.0f);\n', states,states);
    for i = 1:states
      fprintf(deffilenum, 'MTTI(%1.0f,%1.0f) := 1;\n', i, i);
    end
  endif


  ## Make an Nx/2 x Nx/2 unit matrix
  if states>1
    fprintf(deffilenum, 'matrix MTTIm(%1.0f,%1.0f);\n', states/2,states/2);
    for i = 1:states/2
      fprintf(deffilenum, 'MTTIM(%1.0f,%1.0f) := 1;\n', i, i);
    end
  endif


  ## Set the y, yz, du, u, x and dx matrices
  fprintf(deffilenum, '%s Set the y, yz, u and x matrices\n', pc);
  for i=1:outputs
    fprintf(deffilenum, 'MTTy(%1.0f,1) := MTTy%1.0f;\n', i, i);
  endfor

  for i=1:zero_outputs
    fprintf(deffilenum, 'MTTyz(%1.0f,1) := MTTyz%1.0f;\n', i, i);
    fprintf(deffilenum, 'MTTui(%1.0f,1) := MTTui%1.0f;\n', i, i);
  endfor

  for i=1:inputs
    fprintf(deffilenum, 'MTTu(%1.0f,1) := MTTu%1.0f;\n', i, i);
  endfor

  for i=1:inputs
    fprintf(deffilenum, 'MTTdu(%1.0f,1) := MTTdu%1.0f;\n', i, i);
  endfor

  for i=1:states
    fprintf(deffilenum, 'MTTx(%1.0f,1) := MTTx%1.0f;\n', i, i);
  endfor

  for i=1:nonstates
    fprintf(deffilenum, 'MTTdz(%1.0f,1) := MTTdz%1.0f;\n', i, i);
  endfor

  fflush (deffilenum);

endfunction

Added mtt/bin/trans/m/mat2mfile.m version [e8cb0dd3b5].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  mat2mfile(matrix, matrix_name, filenum);
% mat2mfile - writes a matrix as part of an  m-file
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  mat2mfile
% mat2mfile(matrix, matrix_name, filenum)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/04 21:53:00  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

%Writes out a matrix as a matlab m-file

[N, M] = size(matrix);

empty = (N==1)&(M==1)&(matrix(1,1)==0);

%Write out the matrix
fprintf(filenum, '%s = [\n', matrix_name);

if ~empty
  for i = 1:N,
    for j = 1:M
      fprintf(filenum, '%1.0f ', matrix(i,j));
    end;
    fprintf(filenum, '\n');
  end;
else
  fprintf(filenum,'0');
end;
fprintf(filenum, '];\n');
fprintf(filenum, '\n');

Added mtt/bin/trans/m/mat2tex.m version [557dae5024].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function tex = mat2tex(mat)
  ## mat2tex: converts matrix into LaTeX form.
  ## tex = mat2tex(mat)
  

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  1999/03/25 01:33:51  peterg
  ## Initial revision
  ##
  ###############################################################

  [n,m]=size(mat);

  for i=1:n
    for j=1:m
      if mat(i,j) == 0
	printf("0    ");
	else
	  printf("%5.2f", mat(i,j));
	endif
      if j<m
 	printf("&");
      endif
    endfor
      printf("\\\\\n");
  endfor
  
endfunction



Added mtt/bin/trans/m/mtt.m version [f788927636].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mtt (sys,rep,lang)

  ## usage:  mtt (system[,representation,language])
  ##
  ## Invokes mtt from octave to generate system_representation.language
  ## Ie equivalent to "mtt system representation language" at the shell
  ## Representation and language defualt to "sm" and "m" respectively

  if nargin<2
    rep='sm';
  endif
  
  if nargin<3
    lang='m';
  endif

  filename = sprintf("%s_%s.%s", sys, rep, lang);

  command = sprintf("mtt -q %s %s %s", sys, rep, lang);
  system(command);


endfunction

Added mtt/bin/trans/m/mtt2sys.m version [7280c84db2].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function sys = mtt2sys (Name,par)

  ## usage:  sys = mtt2sys (Name[,par])
  ##
  ## Creates a sys structure for the Octave Control Systems Toolbox
  ## from an MTT system with name "Name"
  ## Optional second argument is system parameter list
  ## Assumes that Name_sm.m, Name_struc.m and Name_numpar.m exist

  ## Copyright (C) 2000 by Peter J Gawthrop


  if nargin<1
    error("missing system name, usage:  sys = mtt2sys (Name)");
  else
    ## Create function names
    numpar_name = sprintf("%s_numpar",Name);
    sm_name = sprintf("%s_sm",Name);
    struc_name = sprintf("%s_struc",Name);
  endif

  if nargin<2			# Use predefined parameters
    mtt(Name,"numpar");
    eval(sprintf("par=%s_numpar;", Name)); # Parameters
    mtt(Name,"sm");		# Create state matrices
    mtt(Name,"struc");		# Create structure info
    mtt(Name,"sympar");		# Create sympar details
  else				# Only create other file if not there
    if  exist(sm_name)!=2
      mtt(Name,"sm");		# Create state matrices
    endif

    if  exist(struc_name)!=2
      mtt(Name,"struc");	# Create state matrices
    endif

  endif
 
  eval(sprintf("[A,B,C,D]=%s_sm(par);", Name)); # State matrices
  sys = ss(A,B,C,D);		# Sys form
  if (rindex(version,"2.0."))	# stable (pre-list)
    eval(sprintf("[sys.inname,sys.outname,sys.stname]=%s_struc;", Name)); # Setup names
  else 				# development version
    eval(sprintf("[mtt_inname,mtt_outname,mtt_stname]=%s_struc;",Name)); # Setup names
    eval(sprintf("sys = syssetsignals(sys,\"in\", mtt_inname);"));
    eval(sprintf("sys = syssetsignals(sys,\"out\",mtt_outname);"));
    eval(sprintf("sys = syssetsignals(sys,\"st\", mtt_stname);"));
  endif
endfunction






Added mtt/bin/trans/m/mtt_alias.m version [95ae877303].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [args] = mtt_alias (fullname,args,default);
  ## usage:  [cr,args] = mtt_alias (fullname,cr,args)
  ##
  ## Aliasing code for mtt.
  ## Abstracted from cbg2ese for use in cbg2sese_m2r

  ## Copyright (C) 2003 by Peter J. Gawthrop

  filenum = -1;			# No file number for messages

  [Name,name] = mtt_subname(fullname); # Split fullname

  if (length(args)==0)
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s", ...
		     fullname));
    return
  endif
  
  ## Info for component and surrounding subsystem
  cbg = mtt_cbg(fullname);	# Structure for this component

  if (length(Name)==0)
    return
  else
    Cbg = mtt_cbg(Name);		# Structure for this subsystem
  endif
  

  ## Argument aliasing
  message = sprintf("\tfor component  %s within %s",name,Name);
  if isfield(cbg,"alias")
    args = alias_args(args,cbg.alias,";",message,filenum,fullname);
  endif;

  ## Substitute positional params
  Args = eval(sprintf("Cbg.subsystems.%s.arg;", name));
  args = subs_arg(args,Args,default,Name,"",name,filenum);

endfunction

Added mtt/bin/trans/m/mtt_cbg.m version [d685c05ad4].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function cbg = mtt_cbg (name)

  ## usage:  cbg = mtt_cbg (name)
  ##
  ## Gets the cbg (causal bond graph) structure for system name
  ## Copyright (C) 2003 by Peter J. Gawthrop


  ## File name   
  cbg_file = sprintf("%s_cbg",name);

  if (exist(cbg_file)==0)
    error(sprintf("mtt_cbg: subsystem \"%s\" does not exist", name));
  endif
  
  ## Subsystem data structure
  cbg = eval(sprintf("%s;", cbg_file));

endfunction

Added mtt/bin/trans/m/mtt_check_sigs.m version [9dbc2e2795].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function N = mtt_check_sigs (outsig,insigs)

  ## usage:  N = mtt_check_sigs (outsig,insigs)
  ##
  ## 

  ##  A signal has the columns: bond number signal causality (+1 or -1)
  ##  and component port number

  M=3;

  ## Sanity check
  [N_out,M_out] = size(outsig);
  if N_out!=1
    error("There must be exactly one outbond");
  endif
  [N_in,M_in] = size(insigs);
  if (M_out!=M)||(M_in!=M)
    error(sprintf("There must be exactly %i elements to a bond (number, causality, port)",M));
  endif

  N = N_in;

endfunction

Added mtt/bin/trans/m/mtt_component_eqn.m version [a190371a3c].




































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [known] = mtt_component_eqn (fullname, port, causality, ...
				      known, Cbg)

  ## function [known] = mtt_component_eqn (fullname, port, causality, known)
  ##
  ## Recursively finds the equations giving the signal of specified
  ## causality on the specified port of component named "name" within
  ## subsystem Name 

  ## fullname:  name of component and subsystem
  ## port: port number of component
  ## causality: effort or flow
  ## know_list: list of components already known

  ## Data structures.
  ## A signal is a row vector containing three numbers:
  ##   Index -- a unique (within a subsystem) signed integer
  ##            abs(index) is the unique bond number, sign is the direction.
  ##   Causality -- 1 for effort, -1 for flow
  ##   Port -- the port of the component to which it is connected.
  ## 

  [Name,name] = mtt_subname(fullname); # Split fullname

  SD = "__";			# Subsystem delimiter
  CD = "\n%%";			# Comment delimiter
  arg_default = "1";		# Default aliased arg
  cr_default = "lin";		# Default aliased arg

  DEBUG = 0;

  if DEBUG
    disp("=======================================");
    fullname, name, Name, port,causality,known
  endif
  
  eqn="## No equation -- something wrong"; # Default

  if length(known)<2		# Invalid
    known = "  ";
  endif

  if length(Name)>0
    cbg = mtt_cbg(Name);		# Structure for this subsystem
    if isfield (cbg, "ports")
      ## Combine ports with the other subsystems
      for [component_structure, component] = cbg.ports
	eval(sprintf("cbg.subsystems.%s=cbg.ports.%s;",component,component));
      endfor
    endif
  endif


  if length(name)>0 		# Alias
    ##Alias arguments
    eval(sprintf("ARG=cbg.subsystems.%s.arg;", name)); # Arguments
    ARG = mtt_alias (Name,ARG,arg_default); # Alias them
    eval(sprintf("cbg.subsystems.%s.arg=ARG;", name)); # and copy
    ## Alias CRs
    eval(sprintf("CR=cbg.subsystems.%s.cr;", name)); # CRs
    CR = mtt_alias (Name,CR,cr_default); # Alias them
    eval(sprintf("cbg.subsystems.%s.cr=CR;", name)); # and copy
  else			  # Call to a subsystem (represented by name="")
    if !isfield(cbg,"portlist")
      N_ports = 0;
    else
      [N_ports,M_ports] = size(cbg.portlist);
    endif
    
    if port>N_ports
      error(sprintf("port (%i) > N_ports (%i)", port, N_ports));
    else			# Get name and find equation
      name = deblank(cbg.portlist(port,:));
      if DEBUG
	disp("----> lower-level system")
      endif
      known = mtt_component_eqn (mtt_fullname(Name,name), 1, ...
				 causality, known, cbg);
      return
    endif
  endif
  

  ## Other causality representations
  if strcmp(causality,"effort")
    i_cause = 1;
    othercausality = "flow";
    index_cause = 1;
    cause = "e";
  elseif strcmp(causality,"flow")
    i_cause = -1;
    othercausality = "effort";
    index_cause = 2;
    cause = "f";
  else
    error(sprintf("mtt_component_eqn: causality %s invalid", causality));
  endif
  
  ## A useful composite name
  name_port_cause = sprintf("%s_%i_%s",name, port, cause);
  full_name_port_cause = mtt_fullname(Name,name_port_cause);

  ## If value is known, don't do anything.
  if findstr(sprintf(" %s ", full_name_port_cause), known)>0
    eqn = sprintf("%s The %s signal on port %i of %s is known already", ...
		  CD, causality, port, name);
    return
  else			# Add to list
    known = sprintf("%s %s", known, full_name_port_cause);
  endif
  
  
  
  ## Component type
  comp_type = eval(sprintf("cbg.subsystems.%s.type;", name));
  if DEBUG
    comp_type
  endif
  
  ## Component cr
  cr = eval(sprintf("cbg.subsystems.%s.cr;", name));

  ## Component arg
  arg = eval(sprintf("cbg.subsystems.%s.arg;", name));

  ## To which bond(s) is the component connected?
  connections = eval(sprintf("cbg.subsystems.%s.connections;", name));
  bond_list = abs(connections);	# Unsigned list 
  out_bond_number = bond_list(port);	# The bond at the output of this component
  direction = sign(connections); # Bond directions
  directions = direction'*[1 1]; 

  ## List of system bonds
  bonds = cbg.bonds;

  ## List of component bond causality (component-orientated causality)
  comp_bonds = bonds(bond_list,:).*directions; # Component bonds

  ## What components are at the other ends of the in bonds?
  ## Effort
  [in_e_bonds,in_e_components,in_e_ports,N_e] = mtt_component_inputs ...
      (name,comp_type,causality,"effort",comp_bonds,connections,cbg);
  ## Flow
  [in_f_bonds,in_f_components,in_f_ports,N_f] = mtt_component_inputs ...
      (name,comp_type,causality,"flow",comp_bonds,connections,cbg);


  ##Composite values
  N_ef = N_e + N_f;
  in_ef_bonds = [in_e_bonds; in_f_bonds];
  in_ef_components = [in_e_components; in_f_components];
  in_ef_ports = [in_e_ports; in_f_ports];
  in_causality = [ones(N_e,1); -ones(N_f,1)];

  ## Lists of signals relevant to this component
  outsig = [out_bond_number i_cause port];
  insigs = [in_ef_bonds in_causality in_ef_ports];
  innames = in_ef_components;

  if DEBUG
    outsig
    insigs
    innames
  endif
  
  ## Is the signal the output of a port?
  is_port_output = 0;			# Default
  if isfield (cbg, "ports")
    if isfield (cbg.ports,name)
      is_port_output = (outsig(2)!=insigs(1,2));
    endif
  endif
  
  if is_port_output
    ## Which port (number) is it?
    [N_ports,M_ports] = size(cbg.portlist);
    for i=1:N_ports
      if strcmp(deblank(cbg.portlist(i,:)), name)
	port_index = i;
	break;
      endif
    endfor

    ## File containing data structure
    NAME = mtt_subname(Name);
    CBG = mtt_cbg(NAME);
    
    ## And to which component (at higher level) is it connected?
    [new_Name,new_name] = mtt_subname(Name);
    port_bond = eval(sprintf("CBG.subsystems.%s.connections(%i);", new_name, port_index));
    [in_name, in_port, in_bond] = mtt_other_end (new_name,port_bond,CBG);

    ## Find its equation
    if DEBUG
      disp("----> higher level system")
    endif
    

    known = mtt_component_eqn (mtt_fullname(new_Name,in_name), ...
			       in_port, causality, known, cbg);

    LHS = Source_seqn ("external",Name);
    RHS = varname(NAME, abs(in_bond), i_cause);
    eqn = sprintf("%s%s%s := %s;", LHS, SD, name, RHS);

    if !DEBUG
      comment = sprintf("%s PORT", CD);
      disp(sprintf("%s\n%s",comment, eqn));
    endif

  endif
  

  ## Handle special components
  if strcmp(comp_type,"0")||strcmp(comp_type,"1") # Junctions
    [eqn,insigs,innames] = junction_seqn (comp_type,Name, outsig, ...
					  insigs, innames);
  else				# Everything else
    if exist(sprintf("%s_cause", comp_type)) # Simple component
      ## Do the equations
      [eqn,insigs,innames] = eval(sprintf("%s_seqn (Name, name, cr, ...
						    arg, outsig, ...
						    insigs, ...
						    innames, is_port_output);", ...
					  comp_type));
      ## Resolve CR
      eqn = mtt_resolve_cr(eqn);

    else			# Compound component
      new_NAME = Name;
      new_Name = mtt_fullname(Name,name);
      new_name = "";
      
      ## Get relevant data structure
      Cbg = mtt_cbg(new_Name);
      port_name = Cbg.portlist(port,:);

      LHS = varname(Name, outsig(1,1), outsig(1,2));
      RHS = Sensor_seqn ("external",new_Name);
      eqn = sprintf("%s := %s%s%s;", LHS, RHS, SD, port_name);

      if DEBUG
	disp("----> same-level subsystem")
      endif

      [known] = mtt_component_eqn ...
   	  (mtt_fullname(new_Name,new_name), port, causality, known, cbg);
      
    endif
  endif

  comment = ...
      sprintf("%s Equation for %s signal on port %i of %s (%s), subsystem %s.", ...
     	      CD, causality, port, name, comp_type, Name);

  if DEBUG
    disp(sprintf("%s\n%s",comment, eqn));
  endif
  
  is_external = mtt_is_external(comp_type,outsig, insigs, is_port_output);

  if !is_external
    ## Find the corresponding input equations
    [N_other,M_other] = size(insigs);
    for i = 1:N_other
      if insigs(i,2)==1
	other_causality = "effort";
      else
	other_causality = "flow";
      endif

      other_port = insigs(i,3);
      other_name = deblank(innames(i,:));
      if DEBUG
	disp("----> same-level component")
      endif
      

      [known] = mtt_component_eqn ...
    	  (mtt_fullname(Name,other_name), other_port, other_causality, ...
	   known, cbg);
    endfor
  endif

  ## Write this signal
  ##comment_2 = sprintf("Connected to:%s", in_component_list);
  if !DEBUG
    disp(sprintf("%s\n%s",comment, eqn));
  endif

endfunction

Added mtt/bin/trans/m/mtt_component_inputs.m version [6889a2a85b].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [in_bonds,in_components,in_ports,N] = mtt_component_inputs ...
      (name,comp_type, out_causality, causality,comp_bonds,bond_list,cbg)

  ## usage:  [in_bonds,in_components,in_ports,N] = mtt_component_inputs 
  ##      (name,comp_type, out_causality, causality,comp_bonds,bond_list,cbg)
  ##
  ## 


  ## Other causality representations  if strcmp(causality,"effort")
  if strcmp(causality,"effort")
    i_cause = 1;
    othercausality = "flow";
    index_cause = 1;
  elseif strcmp(causality,"flow")
    i_cause = -1;
    othercausality = "effort";
    index_cause = 2;
  else
    error(sprintf("mtt_component_eqn: causality %s invalid", causality));
  endif
  
  in_index = find(comp_bonds(:,index_cause)==i_cause);
  all_in_bonds = bond_list(in_index);
  N_all = length(all_in_bonds);

  ## What components are at the other ends of the in bonds?
  [in_components,in_ports,in_bonds] = mtt_other_end (name,all_in_bonds,cbg);
  N = length(in_bonds);
endfunction

Added mtt/bin/trans/m/mtt_error.m version [85c51b0617].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mtt_error(message, errorfile);
% mtt_error(message, errorfile);

% function [bonds, status] = abg2cbg(bonds,components,system_name,filename)
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/12/03 16:21:27  peterg
% %% Initial revision
% %%
% %% Revision 1.2  1997/02/11 10:06:42  peterg
% %% Removed a debugging line.
% %%
% %% Revision 1.1  1996/08/18  20:06:57  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Set default file if it isn't there already
if nargin<2
  errorfile = fopen('mtt_error.txt','at');
end;

fprintf(errorfile, '*MTT ERROR : %s\n', message);

#error('MTT exiting this transformation on error');

Added mtt/bin/trans/m/mtt_euler.m version [3653e4fcc1].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function [x] = mtt_euler(x,dx,dt,Nx,open) # Euler update
  I_open = nozeros(open.*[1:Nx]'); # Indices of open switches
  x(I_open) = 0.0;		# Open switches have zero state
  I = nozeros(!open.*[1:Nx]');	# Indices of states to update
  x(I) = x(I) + dx(I)*dt;	# Update states except open switches.
endfunction;

Added mtt/bin/trans/m/mtt_fullname.m version [95049fcb51].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
function fullname = mtt_fullname (subname,compname)

  ## usage:  fullname = mtt_fullname (subname,compname)
  ##
  ## Finds the standard mtt name of the component

  delim = "__";
  fullname = sprintf("%s%s%s", subname, delim, compname);

endfunction

Added mtt/bin/trans/m/mtt_identify.m version [21f7e88261].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [theta,Theta,Error,Y] = mtt_identify (system_name,y_s,theta_0,criterion,max_iterations)

  ## usage:  [theta,Theta,Error] = mtt_identify (system_name,theta_0,criterion,max_iterations)
  ##      y_s   actual system output
  ##      theta_0   initial parameter estimate
  ##      criterion convergence criterion
  ##      max_iterations limit to number of iterations

  if nargin<4
    criterion = 1e-5;
  endif
  
  if nargin <5
    max_iterations = 20;
  endif

  alpha = 1.0;
  e_last = 1e20;
  error=1e10;
  theta = theta_0;
  Theta = [];
  Error = [];
  Y = [];
  iterations = 0;
  while abs(e_last-error)>criterion
    theta
    iterations = iterations + 1;
    e_last = error;
    [t,y,y_theta] = mtt_ssimulate(system_name,theta); # Simulate system
    Theta = [Theta theta];	# Save parameters
    Y = [Y y];			# Save output
    E = (y - y_s);		# Error(t)
    error = (E'*E);			# Sum the error
    Error = [Error error];
    theta = theta - alpha*((y_theta'*y_theta)\(y_theta'*E));
  endwhile

endfunction

Added mtt/bin/trans/m/mtt_implicit.m version [d63b98c98d].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [x] = mtt_implicit(x,dx,AA,AAx,dt,Nx,open); 
  ## x = mtt_implicit(x,dx,AA,AAx,dt,Nx,open); 
  ## Implicit integration update

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.3  1999/04/20 06:14:53  peterg
  ## ## Reorder to make equivalent to .p version
  ## ##
  ## ## Revision 1.2  1999/04/20 00:58:22  peterg
  ## ## Set open-switch states to zero
  ## ##
  ## ## Revision 1.1  1999/04/02 06:23:20  peterg
  ## ## Initial revision
  ## ##
  ## ###############################################################

  ## Copyright (C) 1999 by P.J. Gawthrop

  I = nozeros(!open.*[1:Nx]');	# Indices of states to update
  x(I) = AA(I,I)\(AAx(I) + dx(I)*dt);	# Implicit update (except open switches);
  I_open = nozeros(open.*[1:Nx]'); # Indices of open switches
  x(I_open) = 0.0;		# Open switches have zero state

endfunction

Added mtt/bin/trans/m/mtt_info.m version [5fc6fed510].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mtt_info(info, infofile);
  ## mtt_info(info, infofile);

  ## function [bonds, status] = abg2cbg(bonds,components,system_name,filename)
  ## 
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.4  2003/03/24 12:18:00  gawthrop
  ## ## Default file when no second argument
  ## ##
  ## ## Revision 1.3  2000/11/12 17:10:51  peterg
  ## ## Close file if it is opened
  ## ## Reformated  octave style
  ## ##
  ## ## Revision 1.2  1997/02/11 10:06:42  peterg
  ## ## Removed a debugging line.
  ## ##
  ## ## Revision 1.1  1996/08/18  20:06:57  peter
  ## ## Initial revision
  ## ##
  ## ###############################################################

  ## Set default file if it isn't there already

  if nargin<2
    nofile = 1;
  elseif infofile<0
    nofile = 1;
  else
    nofile = 0;
  endif
  
  if nofile
    infofile = fopen("mtt_info.txt","at");
  end;

  fprintf(infofile, "INFORMATION: %s\n", info);

  if nofile
    fclose(infofile);
  end;

endfunction





Added mtt/bin/trans/m/mtt_is_external.m version [5dcc4690eb].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function is_external = mtt_is_external (comp_type,outsig, insigs, is_port)

  ## usage:  is_external = mtt_is_external (comp_type,outsig, insigs, is_port)
  ##
  ## This is to determine if mtt_component_equation should look for
  ## another equation. If is_external, the varable is available as a
  ## system input and therfore requires no further equation.
  ## I suspect that it needs more work.


  if nargin<4
    is_port = 0;
  endif

  is_external = 0;			# Default

  if is_port
    is_external = 0;
  elseif strcmp(comp_type,"SS");
    is_external = insigs(1,2)!=outsig(2);
  else
    is_external = 0;
  endif

endfunction

Added mtt/bin/trans/m/mtt_isunique.m version [6397cfa01f].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function u = mtt_isunique(x);
% if all the elements of x are different, returns 1 else returns 0


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/18 19:38:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

n = length(x);
u=1

disp("--checking uniqueness --")
x
for i=1:n
  for j = 1:i-1
    if iscell(x)
      if x{i}==x{j}
	u = 0
	break;
      end;
    else
      if x(i)==x(j)
	u = 0
	break;
      end;
    end
  end;
end;

Added mtt/bin/trans/m/mtt_name2names.m version [e20ba547b3].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
function names = mtt_name2names (name)

  ## usage:  names = mtt_name2names (name)
  ##
  ## Converts standard mtt name to an array of subsystem names

  ## Copyright (C) 2003 by Peter J. Gawthrop

  delim ="__";			# MTT delimiter
  names = char(strsplit(name,delim));

endfunction

Added mtt/bin/trans/m/mtt_names2name.m version [569f4874eb].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = mtt_names2name (names)

  ## usage:  name = names2name (names)
  ##
  ## Converts array of subsystem names to a standard mtt name

  delim ="__";			# MTT delimiter

  [n,m] = size(names);
  name = deblank(names(1,:));

  for i = 2:n
    name = sprintf("%s%s%s", name, delim, deblank(names(i,:)));
  endfor

endfunction

Added mtt/bin/trans/m/mtt_optimise.m version [261e38eb89].

















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [theta,Theta,Error,Y,iterations] = mtt_optimise (system_name,y_s,theta_0,method,free,weight,criterion,max_iterations,alpha,View)
  ## Usage: [theta,Theta,Error,Y,iterations] = mtt_optimise (system_name,y_s,theta_0,method,free,weight,criterion,max_iterations,alpha)
  ##  system_name     String containg system name
  ##  y_s   actual system output
  ##  theta_0   initial parameter estimate
  ##  free  Indices of the free parameters within theta_0
  ##  weight Weighting function - same dimension as y_s
  ##  method "time" or "freq"
  ##  criterion convergence criterion
  ##  max_iterations limit to number of iterations
  ##  alpha  Optimisation gain parameter

  ## Copyright (C) 1999 by Peter J. Gawthrop

  if nargin<4
    method="time";
  endif

  N = length(theta_0);
  if nargin<5
    free = [1:N];
  endif
  
  if nargin<6
    weight = ones(size(y_s));
  endif

  if nargin<7
    criterion = 1e-7;
  endif
  
  if nargin <8
    max_iterations = 25;
  endif

  if nargin<9
    alpha = 0.1;
  endif
  
  if nargin<10
    View = 0;
  endif
  
  if (!strcmp(method,"time"))&&(!strcmp(method,"freq"))
    error("method must be either time or freq")
  endif
  
  [n_data,n_y] = size(y_s);

  n_th = length(free);
  error_old = inf;
  error=1e50;
  theta = theta_0;
  Theta = [];
  Error = [];
  Y = [];
  iterations = 0;
  while (abs(error_old-error)>criterion)&&(abs(error)>criterion)&&(iterations<max_iterations)
    iterations = iterations + 1;
    error_old_old = error_old;
    error_old = error;
    eval(sprintf("[t,y,y_theta] = \
	mtt_s%s(system_name,theta,free);",method)); # Simulate system

    if View
      xlabel("");
      title(sprintf("mtt_optimise: Weighted actual and estimated Interation %i", iterations));
      plot(t,y.*weight,t,y_s.*weight);
    endif
    
    error = 0; 
    J = zeros(n_th,1);
    JJ = zeros(n_th,n_th);
    for i = 1:n_y
      E = weight(:,i).*(y(:,i) - y_s(:,i)); # Weighted error
      error = error + (E'*E);	# Sum the error

      Weight = weight(:,i)*ones(1,n_th); # Sensitivity weight
      y_theta_w = Weight.*y_theta(:,i:n_y:n_y*n_th); # Weighted sensitivity
      J  = J + real(y_theta_w'*E); # Jacobian
      JJ = JJ + real(y_theta_w'*y_theta_w); # Newton Euler approx Hessian
    endfor

    error
 
    if error<(error_old+criterion) # Save some diagnostics
      Error = [Error error];	# Save error
      Theta = [Theta theta];	# Save parameters
      Y = [Y y];		# Save output
    endif

    ## Update the estimate if we are not done yet.
    if (abs(error_old-error)>criterion)&&(abs(error)>criterion)&&(iterations<max_iterations)
      if error>(error_old+criterion) # Reduce step size and try again
        factor = 10;
	disp(sprintf("%2.2f*step",alpha));
	error = error_old;	# Go back to previous error value
	error_old = inf;	# Don't let it think its converged
	theta(free) = theta(free)  + step; # Reverse step
	step = alpha*step;	# new stepsize
      else			# Recompute step size
	tol = 1e-5;
	step =  pinv(JJ,tol)*J;	# Step size
	#step =  pinv(JJ)*J;	# Step size (built in tol)
      endif
      theta(free) = theta(free) - step; # Increment parameters
    endif
 ##   theta
  endwhile
endfunction


Added mtt/bin/trans/m/mtt_other_causality.m version [1f9cfc8d6c].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function other = mtt_other_causality (causality)

  ## usage:  other = mtt_other_causality (causality)
  ##
  ## 

  causality = deblank(causality);
  if strcmp(causality,"effort");
    other = "flow";
  elseif strcmp(causality,"flow");
    other = "effort";
  elseif strcmp(causality,"e");
    other = "f";
  elseif strcmp(causality,"f");
    other = "e";
  else
    error(sprintf("Causality \"%s\" not recognised",causality));
  endif
  

endfunction

Added mtt/bin/trans/m/mtt_other_end.m version [dfe2387a77].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [in_components,in_ports,in_bonds] = mtt_other_end (name,all_in_bonds,cbg);

  ## usage:  [in_components,in_ports,in_bonds] = mtt_other_end (name,all_in_bonds,cbg);
  ##
  ## 

  ## What components are at the other ends of the in bonds?
  in_components = "";
  in_ports = [];
  in_bonds = [];
  in_direction = [];
  for i = 1:length(all_in_bonds);
    for [component_structure, component] = cbg.subsystems
      if !strcmp(name,component)
	other_connections = component_structure.connections;
	one = ones(size(other_connections));
	port = find(abs(all_in_bonds(i))*one==abs(other_connections));
	if (length(port)==1)
	  in_components = [in_components; component];
	  in_bonds = [in_bonds; all_in_bonds(i)];
	  in_ports = [in_ports; port];
	endif
      endif
    endfor
  endfor

endfunction

Added mtt/bin/trans/m/mtt_resolve_cr.m version [bb4d4bdb2d].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function eqn = mtt_resolve_cr (eqn)
  ## usage:  eqn = mtt_resolve_cr (eqn)


  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2003/03/24 12:20:28  gawthrop
  ## *** empty log message ***
  ##
  ## Revision 1.1  2003/03/24 10:19:42  gawthrop
  ## Documentation added
  ##
  ###############################################################

  ## Temporary version to resolve lin only!

  ## How many equations here?
  N = length(findstr(eqn,"="));
  EQNS = char(strsplit(eqn,";"));

  eqn = "";
  for i = 1:N
      
      ## Split equation
      EQN = char(strsplit(EQNS(i,:),":="));
      LHS = deblank(EQN(1,:));
      RHS = deblank(EQN(2,:));

      if index(RHS,"lin(")>0	# lin cr is here

      RHS = sprintf("%s;", RHS); # Put back ;

      ## Make function into a list
      RHS = strrep(RHS,"lin(","{lin,");
      RHS = strrep(RHS,");","}");

      ## Convert "R" to R etc
      RHS = strrep(RHS,"\"","");
      
      
      RHS = g_subs(RHS, "{{lin,$6,$3,$1,$5,1,$2,$3,1}}", "{$2*$1}");
      RHS = g_subs(RHS, "{{lin,$6,$3,$1,$5,1,$2,$4,1}}", "{$2/$1}");
    endif

    eqn_i = sprintf("%s := %s;", LHS, RHS);
    eqn = sprintf("%s %s", eqn, eqn_i);
  endfor

endfunction
    

Added mtt/bin/trans/m/mtt_save_alias.m version [d6d06732d5].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mtt_save_alias (arg,system_name)

  ## usage:  mtt_save_alias (arg,system_name,FileID)
  ##
  ##
  ##     ###################################### 
  ##     #### Model  Transformation Tools #####
  ##     ######################################

  ## ############################################################### 
  ## Version
  ## control history
  ## ############################################################### ## $Id:
  ## mtt_info.m,v 1.2 1997/02/11 10:06:42 peterg Exp peterg $ ## $Log:
  ## mtt_info.m,v $ ## Revision 1.2  1997/02/11 10:06:42  peterg ##
  ## ###############################################################

  fileid = fopen('mtt_aliased.txt','at');
  fprintf(fileid, "%s\t%s\n", arg,system_name);
  fclose(fileid);
endfunction

Added mtt/bin/trans/m/mtt_sfreq.m version [22eb1c42b9].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [w,y,y_theta] = mtt_sfreq(system_name,theta,free);
  ## usage: [w,y,y_theta] = mtt_sfreq(system_name,theta,free);
  ##
  ## Frequency response with name system_name and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## y_theta contains the corresponding sensitivity functions
  ## Assumes system generated by the sBG approach
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Assumes SISO system 

  global mtt_n_parameters mtt_parameters # Global "argc argv"
  global mtt_w # Frequencies (if not specified in simpar file
 N = length(theta);

  eval(sprintf("[nx,ny,nu,nz,nyz] = %s_def;", system_name));
  if nargin<3
    free = 1;
  endif
  
  y_theta = [];

  if length(free)==0
    free=1;			# Make the loop happen once to get y and X
  endif
  
  [n,m]  = size(free);
  if m==1
    free = free';
  endif
  
  
  eval(sprintf("%s_simpar;", system_name)); # Read the "simulation"
					    # parameters
  if exist("mttwmin")		# Compute frequency range
    w = logspace(mttwmin,mttwmax,mttwsteps)'; # Frequency range
  else				# use global mtt_w
    w = mtt_w;
  endif
  
  y_theta = [];
  mtt_n_parameters = 1+N;
  mtt_parameters(2:1+N) = theta; # The actual parameters
  for i = free
    mtt_parameters(1) = i; # Select wich sens. function
    eval(sprintf("%s_numpar;", system_name)); # Read the parameters
    eval(sprintf("[A,B,C,D,E] = %s_dm;", system_name)); # Evaluate the
				# descriptor matrices
    fr = dm2fr(A,B,C,D,E,w);
    y_theta = [y_theta fr(:,2)]; # Sensitivity frequency response
  endfor

  y = fr(:,1);			# Actual frequency response
  
  
endfunction



Added mtt/bin/trans/m/mtt_simulate.m version [cbe0b154db].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [t,y,y_theta] = mtt_simulate(system_name,theta);
  ## usage: [t,y,y_theta] = mtt_simulate(r);
  ##
  ## Simulate system with name system and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Simulate using mtt-generated function
  y_theta = [];
   for i=1:length(theta)
     args="";
     for j=1:length(theta)
       i_sensitivity=(j==i);
       args = sprintf("%s%i %g ",args, i_sensitivity, theta(j));
     endfor

     command = sprintf("./%s_ode2odes.out %s > mtt_data.dat\n", system_name, args);
     system(command);

     ## Retrieve data
     load -force mtt_data.dat
     t = mtt_data(:,1);
     y = mtt_data(:,2);
     y_theta = [y_theta mtt_data(:,3)];
   endfor

endfunction



Added mtt/bin/trans/m/mtt_ssimulate.m version [5b7c3603ee].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [t,y,y_theta] = mtt_ssimulate(system_name,theta);
  ## usage: [t,y,y_theta] = mtt_ssimulate(system_name,theta);
  ##
  ## Simulate system with name system_name and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## y_theta contains the corresponding sensitivity functions
  ## Assumes system generated by the sBG approach
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Simulate using mtt-generated function
  y_theta = [];
   for i=1:length(theta)
     args="";
     for j=1:length(theta)
       i_sensitivity=(j==i);
       args = sprintf("%s%i %g ",args, i_sensitivity, theta(j));
     endfor

     command = sprintf("./%s_ode2odes.out %s > mtt_data.dat\n", system_name, args);
     system(command);

     ## Retrieve data
     load -force mtt_data.dat
     t = mtt_data(:,1);
     y = mtt_data(:,2);
     y_theta = [y_theta mtt_data(:,3)];
   endfor

endfunction



Added mtt/bin/trans/m/mtt_stime.m version [588e121a7c].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [t,y,y_theta,x,x_last] = mtt_stime(system_name,theta,free);
  ## usage: [t,y,y_theta,x,x_last] = mtt_stime(system_name,theta);
  ##
  ## Simulate system with name system_name and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## y_theta contains the corresponding sensitivity functions
  ## Assumes system generated by the sBG approach
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Simulate using mtt-generated function

  N = length(theta);

  eval(sprintf("[nx,ny,nu,nz,nyz] = %s_def;", system_name));
  if nargin<3
    free = 1;
  endif
  
  y_theta = [];

  if length(free)==0
    free=1;			# Make the loop happen once to get y and X
  endif
  
  [n,m]  = size(free);
  if m==1
    free = free';
  endif
  
  for i=free
    args=sprintf("%i",i);
    for j=1:length(theta)
      args = sprintf("%s %g",args, theta(j));
    endfor

    ## Run system and replace NaN by 1e30 -- easier to handle
    file_name = sprintf("%s_input.dat", system_name);
    if exist(file_name)==2	# Then use data from this file ...
      command = sprintf("./%s_ode2odes.out %s < %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", ...
			system_name, args, file_name);
    else
      command = sprintf("./%s_ode2odes.out %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", ...
			system_name, args);
    endif
      
   system(command);

    ## Retrieve out_data
    load -force mtt_out_data.dat
    y_theta = [y_theta mtt_out_data(:,3:2:1+ny)];
  endfor

  ## System out_data
  [n,m]=size(mtt_out_data);
  t = mtt_out_data(:,1);
  y = mtt_out_data(:,2:2:ny);
  x = mtt_out_data(:,3+ny:m);
  x_last = mtt_out_data(n,3+ny:m);
endfunction



Added mtt/bin/trans/m/mtt_strip_name.m version [04fb8c767f].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function stripped_name = mtt_strip_name (name)

  ## usage:  stripped_name = mtt_strip_name (name)
  ##
  ## Removes blanks and [] from a port name

  if (length(name)==0)
    error("Zero length port name found");
  endif


  [N,M] = size(name)
  if N>1
    error("Cannot resolve port names: redraw abg.fig");
  endif
  
  
  stripped_name = deblank(name); # remove blanks
  stripped_name = stripped_name(2:length(stripped_name)-1);
  stripped_name = deblank(stripped_name); # remove blanks

endfunction

Added mtt/bin/trans/m/mtt_subname.m version [653459832d].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [subname, compname] = mtt_subname (name)

  ## usage:  subname = mtt_subname (name)
  ##
  ## Finds the subsystem name from the component name
  ## Copyright (C) 2003 by Peter J. Gawthrop


  names = mtt_name2names(name);
  [n,m] = size(names);

  if n<2			# Simple name
    subname = "";
    compname = name;
  else				# Compound name
    subname = mtt_names2name(names(1:n-1,:));
    compname = deblank(names(n,:));
  endif

endfunction

Added mtt/bin/trans/m/mtt_type_name.m version [6cb1565552].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function NewType = mtt_type_name (OldType)

  ## usage:  NewType = mtt_type_name (OldType)
  ##
  ## 

  if OldType=="0";
    NewType = "Zero";
  elseif OldType=="1";
    NewType = "One";
  else
    NewType = OldType;
  endif

endfunction

Added mtt/bin/trans/m/mtt_update.m version [27453a1721].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
function [x] = mtt_update(dx,x,dt,STEPFACTOR,METHOD,name);

  if (METHOD==1)		#Euler
    ddt = dt/STEPFACTOR;
    x = x + dx*ddt;
  elseif (METHOD==2)		#Linear implicit or Implicit
    eval("[AA,AAx] = ",name,"_smx;");
    x = AA\(AAx + dx*dt);
  else
    error("Method %i is not defined", METHOD);
  endif;

endfunction;

Added mtt/bin/trans/m/mtt_write.m version [72eb26e77f].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mtt_write(t,x,y,nx,ny,first);

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2002/05/13 08:52:23  gawthrop
## FIRST parameter of simpar now specifies first printed point -
## simulation still starts at zero
##
## Revision 1.5  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.4  1999/03/15 23:05:29  peterg
## A complete rewrite - now puts into a Global matrix MTT_data
##
## Revision 1.3  1999/03/15 21:57:00  peterg
## Removed the # symbol
##
###############################################################

global MTT_data
  if (t==0.0)
    MTT_data=[];
  endif

  if (t>= first)
    MTT_data = [MTT_data; t,y(:)',t,x(:)'];
  endif
  
endfunction

Added mtt/bin/trans/m/mtt_zeroswitches.m version [ac6908b24d].





1
2
3
4
+
+
+
+
function [x] = mtt_zeroswitches(x,Nx,open)
  I_open = nozeros(open.*[1:Nx]'); # Indices of open switches
  x(I_open) = 0.0;		   # Open switches have zero states
endfunction;

Added mtt/bin/trans/m/name_in_list.m version [d44d5cda78].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function index = name_in_list(name,list)

% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  name_in_list.m
% Finds name in list and returns index -- zero if not found


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/23 09:22:05  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[N,M] = size(list);
if N<1
  error('list must have at least one element');
end;

index = 0;

for i = 1:N
 j = findstr(name,list(i,:));
 if (length(j)==1)
    if j(1)==1
      if index==0
        index = i;
      else 
        index = [index i];
      end
    end
 end;
end;

Added mtt/bin/trans/m/nozeros.m version [e7ac91823e].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function v = nozeros (v0,tol)

  ## usage:  v = nozeros (v0,tol)
  ##
  ## Zaps the zeros in a vector with tolerance tol (defaults to zero)

  ## Copyright (C) 2000 by Peter J. Gawthrop

  if nargin<2
    tol=eps;
  endif
  
  
  v = [];
  j=0;
  for i = 1:length(v0)
    if abs(v0(i))>tol
      j=j+1;
      v(1,j) = v0(i);
    end;
  end;
  

endfunction

Added mtt/bin/trans/m/pol2root2tex.m version [f78af4d947].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function tex = pol2root2tex(pol,name,f)
  ## pol2tex: converts polynomial into LaTeX form as (s-z_1)..(s-z_n)
  ## tex = pol2root2tex(pol,[name,f])
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/05/10 19:08:35  gawthrop
  ## Cosmetic improvements
  ##
  ## Revision 1.1  2001/05/10 11:44:40  gawthrop
  ## Useful conversion functions
  ##
  ## Revision 1.1  1999/05/24 22:05:53  peterg
  ## Initial revision
  ##
  ###############################################################

  if nargin<2
    name = "s"
  endif
  
  if nargin<3
    f = "%2.2f";
  endif

  n = length(pol)-1;

  if n>0
    r = sort(roots(pol));
  endif
  
  gain = pol(1);

  complex=0;
  if ((gain==1)&&(n>0))
    tex="";
  else
    tex = sprintf("%g", gain);
  endif
  
  for i=1:n
    if real(r(i))<0
      r_plusminus = '+';
    else
      r_plusminus = '-';
    endif
    if imag(r(i))<0
      i_plusminus = '+';
    else
      i_plusminus = '-';
    endif

    if complex
      complex=0;
    else
      if abs(imag(r(i)))<1e-5
	ff = sprintf("%%s (%s %%s %s)",name, f);
	tex = sprintf(ff, tex, r_plusminus, abs(r(i)));
      else
	ff = sprintf("%%s (%s %%s %s \\pm j %s)", name, f, f);
	tex = sprintf(ff, tex, r_plusminus, abs(real(r(i))), imag(r(i)));
	complex=1;
      endif
    endif
  endfor
  
endfunction



Added mtt/bin/trans/m/pol2tex.m version [20e8117d85].

















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function tex = pol2tex(pol,name,f)
  ## pol2tex: converts polynomial into LaTeX form.
  ## tex = pol2tex(pol,[name,f])
  
  ## pol  polynomial (row vector)
  ## name name of the variable (eg s or z)
  ## f    format of the coefficients (eg %2.4f)

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.3  2001/07/11 03:58:41  gawthrop
  ## removed {}
  ##
  ## Revision 1.2  2001/05/10 19:08:35  gawthrop
  ## Cosmetic improvements
  ##
  ## Revision 1.1  2001/05/10 11:44:40  gawthrop
  ## Useful conversion functions
  ##
  ## Revision 1.1  1999/03/25 01:33:51  peterg
  ## Initial revision
  ##
  ###############################################################

  if nargin<2
    name = "s";
  endif
  
  if nargin<3
    f = "%2.2f";
  endif
  
  n = length(pol);
  if n<1
    tex = "--";
    return
  endif

  if pol(1) == 1
    if n>1
      tex = '';
    else
      tex = '1';
    endif
  else
    ff = sprintf(" %s",f);
    tex = sprintf(ff, pol(1));
  endif
  
  if n>2
    tex = sprintf("%s%s^%i", tex, name, n-1);
  elseif n==2
    tex = sprintf("%s%s", tex, name);
  else
    tex = sprintf("%s", tex);
  endif

  for i=2:n
    if pol(i)<0
      plusminus = '-';
    else
      plusminus = '+';
    endif
    ff = sprintf("%%s %%s %s",f);
    tex = sprintf(ff, tex, plusminus, abs(pol(i)));
    if i<n-1
      tex = sprintf("%s%s^%i", tex, name, n-i);
    elseif i==n-1
      tex = sprintf("%s%s", tex, name); 
    else
      tex = sprintf("%s", tex);
    endif
  endfor
endfunction



Added mtt/bin/trans/m/pow.m version [0360ed3c86].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
function z = pow (x,y)

  ## usage:  z = pow (x,y)
  ##
  ## Computes z = x^y

  z = x^y;

endfunction

Added mtt/bin/trans/m/printcr.m version [33c745664a].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  printcr(name,outport,bond_number,cr,args,RHS_cause,eqnfile)
## printcr - prints cr and arguments
## Assumes that the (multiport) component is unicausal.
## 
##     ###################################### 
##     ##### Model Transformation Tools #####
##     ######################################
## 
## Octave function  printcr
## printcr(name,outport,bond_number,cr,args,RHS_cause,eqnfile


## ###############################################################
## ## Version control history
## ###############################################################
## ## $Id$
## ## $Log$
## ## Revision 1.2  2003/01/07 09:11:53  gawthrop
## ## Octavised
## ##
## ## Revision 1.1  1998/07/25 09:47:43  peterg
## ## Initial revision
## ##
## ###############################################################



  if nargin<7
    eqnfile = "stdout";
  endif

  ## Find the number of ports
  ports = length(RHS_cause);

  ## Print the CR
  if length(cr) == 0 # No CR given - use unity CR
    fprintf(eqnfile, "%s;\n", varname(name,bond_number(outport), ...
				      RHS_cause(outport)));
  else # CR exists
    fprintf(eqnfile, "%s(%s", cr, name); # The CR name and component type
    if ports>1 # Multi ports - port no. is first arg of CR
      fprintf(eqnfile, "#1.0f,", outport);
    endif
    fprintf(eqnfile, "%s", args); # Print the arguments
    for port = 1:ports # Print the input causalities and values
      fprintf(eqnfile, "\n\t\t,%s,%s", cause2name(RHS_cause(port)), ...
	      varname(name,bond_number(port), RHS_cause(port)));
    endif
    fprintf(eqnfile, "\n\t\t);\n");
  endif
endfunction


Added mtt/bin/trans/m/psfig.m version [e433f0a0b8].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function psfig(filename)
  ## Usage: psfig(filename)
  ## Puts figure into ps file

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  1999/11/30 23:26:21  peterg
  ## Initial revision
  ##
  ## Revision 1.3  1999/09/04 02:23:30  peterg
  ## Removed mv stuff - now uses gset on actual file
  ##
  ## Revision 1.2  1999/06/15 02:05:44  peterg
  ## Now adds a .ps if not there already
  ##
  ## Revision 1.1  1999/03/25 01:35:00  peterg
  ## Initial revision
  ##
  ###############################################################

  ## Add .ps if not there already
  if !index(filename,".")	# Is there a .
    filename = sprintf("%s.ps",filename);
  endif
  
  eval(sprintf("gset output \"%s\" ",filename));
  gset linestyle 1 lw 4		# Thicker lines
  gset linestyle 2 lw 4		# Thicker lines
  gset linestyle 3 lw 4		# Thicker lines
  gset linestyle 4 lw 4		# Thicker lines
  gset linestyle 5 lw 4		# Thicker lines


  gset term postscript eps 
  replot;
  gset term x11
  gset output 
  replot;

endfunction

Added mtt/bin/trans/m/rbg2abg.m version [19a07974ce].





















































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents, ...
				      port_coord,port_name, ...
				      infofile,errorfile)

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.51  2012/10/15 19:22:44  geraint
  ## ## mtt_isunique replaces unique which masks a built-in function.
  ## ##
  ## ## Revision 1.50  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.49  2004/07/22 13:18:02  geraint
  ## ## Minor typo in error message.
  ## ##
  ## ## Revision 1.48  2004/02/19 18:27:47  geraint
  ## ## [ 852694 ] octave 2.1.52 breaks rbg2abg
  ## ##
  ## ## Octave now prefers row vectors to column vectors.
  ## ##
  ## ## Revision 1.47  2002/08/27 16:09:01  geraint
  ## ## Added port_name to error message when multiple bonds are near a port.
  ## ##
  ## ## Revision 1.46  2000/09/11 08:22:02  peterg
  ## ## Checks for absent port list in subsystem abg file.
  ## ##
  ## ## Revision 1.45  1999/10/19 02:13:31  peterg
  ## ## Now assigns correct bonds to the new junction port names
  ## ##
  ## ## Revision 1.44  1999/10/19 00:05:44  peterg
  ## ## Now defaults junction ports when only one specified (for vector junctions)
  ## ##
  ## ## Revision 1.43  1999/10/18 04:08:46  peterg
  ## ## Now computes n_vector_bonds -- number apparent (maybe vector) bonds per component.
  ## ## Neeeded to vectorise junctions.
  ## ##
  ## ## Revision 1.42  1999/08/25 21:45:03  peterg
  ## ## Spurious start to vector 0 and 1
  ## ##
  ## ## Revision 1.41  1999/08/19 21:12:33  peterg
  ## ## Tidied and started implementaation of vector junctions
  ## ##
  ## ## Revision 1.40  1999/08/19 05:39:55  peterg
  ## ## Put into octave format
  ## ##
  ## ## Revision 1.39  1999/08/19 05:22:16  peterg
  ## ## To RCS prior to inplementing vector junctions
  ## ##
  ## ## Revision 1.38  1999/03/12 00:58:06  peterg
  ## ## Now gets portlist from the _abg.m file NOT the _rbg.m file
  ## ## - this allows expansion of vector SS ports.
  ## ##
  ## ## Revision 1.37  1998/07/28 19:06:43  peterg
  ## ## Still some bugs (vector SS ports)??
  ## ##
  ## ## Revision 1.36  1998/07/28 10:30:50  peterg
  ## ## Implemented vector SS ports.
  ## ##
  ## ## Revision 1.35  1998/07/08 15:35:15  peterg
  ## ## Added errorfile argument
  ## ##
  ## ## Revision 1.34  1998/07/02 19:41:29  peterg
  ## ## Fixed empty port string bug - set to null string.
  ## ##
  ## ## Revision 1.33  1998/07/02 17:16:06  peterg
  ## ## Commented out redundent code -- obsolete due to new default mechanism
  ## ##
  ## ## Revision 1.32  1998/07/02 15:12:05  peterg
  ## ## Added hard error reporting
  ## ## Added error when two unlabled bonds point in.
  ## ##
  ## ## Revision 1.31  1998/07/02 14:30:50  peterg
  ## ## Corrected various bugs - including resettting n_ports to correct value
  ## ##
  ## ## Revision 1.30  1998/07/02 13:40:50  peterg
  ## ## Added extra ports names (due to defaults) to relevant lists:
  ## ## 	port_name
  ## ## 	port_bond
  ## ##
  ## ## Revision 1.29  1998/07/02 13:28:31  peterg
  ## ## Added defaults in new form BEFORE alias expansion
  ## ##
  ## ## Revision 1.28  1998/07/02 12:36:05  peterg
  ## ## Removed debugging lines
  ## ##
  ## ## Revision 1.27  1998/07/02 12:24:02  peterg
  ## ## Expand port aliases
  ## ##
  ## ## Revision 1.26  1998/04/16 14:07:51  peterg
  ## ## Sorted out [] problem with vector ports -- new octave function
  ## ## split_port
  ## ##
  ## ## Revision 1.25  1998/04/12 15:01:04  peterg
  ## ## Converted to uniform port notation - always use []
  ## ##
  ## ## Revision 1.24  1998/02/19 08:57:16  peterg
  ## ## Fixed mtt-info bug -- confused filename with number
  ## ##
  ## ## Revision 1.23  1997/12/04 14:24:22  peterg
  ## ## Removed error message about through-pointing arrows
  ## ##
  ## ## Revision 1.22  1997/09/18 19:49:37  peterg
  ## ## Added test for uniquness of bonds on a component -- if non-unique
  ## ## implies same component at both ends of a bond.
  ## ##
  ## ## Revision 1.21  1997/09/16  15:14:14  peterg
  ## ## Added warning if a component has no bonds.
  ## ##
  ## ## Revision 1.20  1997/08/18  19:39:48  peterg
  ## ## Now generates (exampaded) port_bond list correctely
  ## ##
  ## ## Revision 1.19  1997/08/14  11:59:47  peterg
  ## ## Vector ports added!!
  ## ##
  ## ## Revision 1.18  1997/08/14  11:01:42  peterg
  ## ## Reordered algorithms as follows:
  ## ## bond end coordinates
  ## ## associate port labels with bonds (port_bond)
  ## ## associate bonds with components
  ## ## unsorted list of bonds on each component (components)
  ## ## interpret strokes and setup the causality of the bonds (bonds)
  ## ## expand vector ports & add new bonds and connections
  ## ## sort bonds on each component according to the labels -- two ports
  ## ## default included here.
  ## ##
  ## ## Revision 1.17  1997/08/09 11:31:16  peterg
  ## ## Default two port list is [in;out] (or [out;in])
  ## ## Dont do global default if no ports labels.
  ## ##
  ## ## Revision 1.16  1997/08/07  16:12:36  peterg
  ## ## Fixed sorting bug: now puts the jth component from the unsorted list
  ## ## into the kth component of the sorted list .. not vice versa!
  ## ##
  ## ## Revision 1.15  1997/08/06  21:43:19  peterg
  ## ## Corrected error in creating component list: the kth component of the
  ## ## list is given by the jth component of the original list NOT vice
  ## ## versa.
  ## ##
  ## ## Revision 1.14  1997/08/04 14:18:55  peterg
  ## ## If no ports labels at all, just use the default component list.
  ## ##
  ## ## Revision 1.13  1997/08/04 12:50:39  peterg
  ## ## Many bug fixes to the named port version + tied up the logic and
  ## ## supporting comments.
  ## ##
  ## ## Revision 1.12  1997/08/02 19:37:53  peterg
  ## ## Now uses named ports.
  ## ##
  ## ## Revision 1.11  1997/04/29 09:12:37  peterg
  ## ## Added error message if port label near to >1 bond.
  ## ##
  ## ## Revision 1.10  1997/03/17  13:45:42  peterg
  ## ## Added more error info.
  ## ##
  ## ## Revision 1.9  1996/12/31  11:25:57  peterg
  ## ## Clearer error messages for incorrect ports.
  ## ##
  ## ## Revision 1.8  1996/12/04 21:52:39  peterg
  ## ## Now uses fopen.
  ## ##
  ## ## Revision 1.7  1996/11/01 18:01:57  peterg
  ## ## Rationalised port ordering.
  ## ## Fixed port bug.
  ## ##
  ## ## Revision 1.6  1996/08/25 08:27:14  peter
  ## ## Now checks ports correctely - I hope.
  ## ##
  ## ## Revision 1.5  1996/08/24 19:21:26  peter
  ## ## More specific error messages.
  ## ##
  ## ## Revision 1.4  1996/08/24 18:00:33  peter
  ## ## Fixed bug with finding ports.
  ## ##
  ## ## Revision 1.3  1996/08/09 08:26:35  peter
  ## ## Cosmetic tidy up.
  ## ##
  ## ## Revision 1.2  1996/08/04 18:37:57  peter
  ## ## Fixed  no causal strokes bug.
  ## ##
  ## ## Revision 1.1  1996/08/04 18:30:14  peter
  ## ## Initial revision
  ## ##
  ## ###############################################################


  ##Default to no components
  components = [0];

  ## Xfig scaling factor
  scale = 1200.0/2.54546;

  ## Rotation matrix
  rot = [0 -1; 1 0];

  ## Find number of strokes
  [n_strokes,columns] = size(rstrokes);
  if (columns ~= 4)&(n_strokes>0)
    error('Incorrect rstrokes matrix: must have 4 columns');
  endif


  ## Find number of bonds
  [n_bonds,columns] = size(rbonds);
  if (columns ~= 6)&(n_bonds>0)
    error('Incorrect rbonds matrix: must have 6 columns');
  endif


  ## Find number of components
  [n_components,columns] = size(rcomponents);

  ## Find the number of ports refered to within the component
  [n_ports,columns] = size(port_coord)

  ## If port_name is empty, make it a empty string
  if (length(port_name)==0)
    port_name="";
  endif


  ## Determine coordinates of the arrow end of the bond and the other end
  other_end_1 = rbonds(:,1:2);
  arrow_end   = rbonds(:,3:4);
  other_end_2 = rbonds(:,5:6);

  distance_1   = length2d(other_end_1 - arrow_end);
  distance_2   = length2d(other_end_2 - arrow_end);
  which_end    = (distance_1>distance_2)*[1 1];
  one          = ones(size(which_end));
  other_end    = which_end.*other_end_1 + (one-which_end).*other_end_2;
  arrow_vector = ( which_end.*other_end_2 + (one-which_end).*other_end_1 ) - ...
      arrow_end;
  
  ## Locate the bond end nearest to each port
  ## col 1 of port_near_bond contains a signed bond number (+ for arrow end)
  ## col 2  of port_near_bond contains the corresponding port index
  port_bond = [];
  for i = 1:n_ports
    near_bond = adjbond(port_coord(i,1:2),arrow_end,other_end);
    [rows,cols]=size(near_bond);
    if rows>1
      error(sprintf ...
	    ("A port is near to more than one bond at coordinates %g,%g %s\n", ...
	     port_coord(i,1)/scale,  port_coord(i,2)/scale, deblank(port_name(i,:))));
    endif
    

    ##The (signed) bond corresponding to the ith port label
    port_bond(i,1) = near_bond(1)*sign(1.5-near_bond(2));
  endfor

  port_bond
  ##We now have the (signed) bond (port_bond(i)) correponding to the
  ## ith port label within the component 

  ## Locate the components at the ends of each bond
  ## col 1 of comp_near_bond contain the component nearest to the arrow end
  ## col 2 of comp_near_bond contain the component nearest to the other end
  for i = 1:n_bonds
    comp_near_bond(i,:) = adjcomp(arrow_end(i,:),other_end(i,:),rcomponents);
  endfor

  comp_near_bond
  ## We now have a list (comp_near_bond) of the component(s) at each end
  ## of each bond

  ## Now do a list of the bonds on each component - unsorted at this stage.
  ## Also expand aliases using the alias list for each component
  components = []; 
  i_vector=0;			# Counter for vector components
  for i = 1:n_components
    ##Get component type
    eval(['[comp_type, comp_name] = ', name, '_cmp(i)']);

    
    ## There are n_comp_bonds bonds on this component with corresponding index
    [index,n_comp_bonds] = getindex(comp_near_bond,i);

    if index(1,1)==0
      mtt_error(sprintf("Component %s (%s) has no bonds", comp_name,
			comp_type),errorfile);
    endif
    
    
    ## Create the signed list of bonds on this component
    one = ones(n_comp_bonds,1);
    bond_list = index(:,1); %  bond at component
    
    ## Check that all bonds are unique -- error if not
    if mtt_isunique(bond_list)==0
      mtt_error(sprintf("Component %s (%s) is at both ends of a bond", comp_name,
			comp_type),errorfile);
    endif
    
    

    ## which end of bond at component?
    bond_end = index(:,2); 
    direction = -sign(bond_end-1.5*one);
    signed_bond_list = bond_list.*direction;
    components = add_bond(components,signed_bond_list',i);
    
    ## Unalias and/or default all the ports on this componen
    unlabelled_ports = 0;  
    in_bonds = 0;
    out_bonds = 0;
    if ((comp_type=="0")||(comp_type=="1")) # A junction
      disp("---- default junctions ---- ");
      junction_names = 0;
      for j=1:n_comp_bonds
	port_name_index = getindex(port_bond,signed_bond_list(j));
	if port_name_index>0
	  junction_port_name = port_name(port_name_index,:);
	  named_bond_index = j;
	  junction_names++;
	endif
      endfor
      if junction_names==1	# one named port
	mtt_info(sprintf("Defaulting all ports on junction %s to %s", comp_name, junction_port_name));
	## Make the other n-1 names the same.
	junction_port_name = mtt_strip_name(junction_port_name);
	for j=1:n_comp_bonds;
	  if j!=named_bond_index
	    port_name = [port_name; ["[" junction_port_name "]"]]; # add to list
	    [port_name_index,junk] = size(port_name); # the corresponding index
	    port_bond(port_name_index,:) = signed_bond_list(j); # add to port bond
	  endif
	endfor
      elseif (junction_names!=0)&&(junction_names!=n_comp_bonds) # not allowed
	mtt_error(sprintf("Junction %s must have 0, 1 or %i port labels", comp_name,n_comp_bonds),errorfile);
      endif
      port_name = port_name
    else			# Not a junction
      for j=1:n_comp_bonds
	signed_bond = signed_bond_list(j);
	port_name_index = getindex(port_bond,signed_bond);
	port_direction = sign(signed_bond);
	
	if port_name_index==0	# There is no port on this bond - so try
				# to default
	  unlabelled_ports++;
	  if(unlabelled_ports==1)
	    if port_direction>0
	      in_bonds++;
	      port_name_i = "in";
	    else
	      out_bonds++;
	      port_name_i = "out";
	    endif
	    
	  elseif (unlabelled_ports==2)
	    if port_direction>0
	      if (++in_bonds>1)
		mtt_error(["More than one unlabelled INport on component " ...
			   comp_name " (" comp_type ")"],errorfile);
	      else
		port_name_i = "in";
	      end
	    else
	      if (++out_bonds>1)
		mtt_error(["More than one unlabelled OUTport on component " ...
			   comp_name " (" comp_type ")"],errorfile);
	      else
		port_name_i = "out";
	      end
	    endif
	    
	  else
	    mtt_error(["More than two unlabelled ports on component " ...
		       comp_name " (" comp_type ")"],errorfile);
          endif
	  
	  mtt_info(["Defaulting port name [" port_name_i "]\t on component " ...
		    comp_name " (" comp_type ")" ],infofile);
	  port_name = [port_name; ["[" port_name_i "]"]];	# add to list
	  [port_name_index,junk] = size(port_name); # the corresponding
				# index
	  port_bond(port_name_index,:) = signed_bond; # add to port bond
	else  
	  port_name_i = mtt_strip_name(port_name(port_name_index,:))
	  ## port_name_i = deblank(port_name(port_name_index,:));
	  ## port_name_i = port_name_i(2:length(port_name_i)-1) # strip []
	endif
	
	
	## Replace by alias -- if any
    	eval( ["alias = ", comp_type, '_alias';]); # Get aliases
    	if isstruct(alias)		# are there any aliases
          if isfield(alias,port_name_i) # Is this an alias?
	    eval(["new_port_name_i = alias.",port_name_i]);
	    mtt_info(["Aliasing name [" port_name_i "]\t on component " ...
		      comp_name " (" comp_type ")\t to [" new_port_name_i "]"],infofile);
	    port_name = replace_name(port_name, ...
				     ["[",new_port_name_i,"]"], ...
				     port_name_index);
	  endif
	  
      	endif
	
      endfor
      
    endif
    
  endfor
  
  ## At this point, every port should be labeled (port_name) and ...
  ## associated with a bond (port_bond).
  disp("--- Completed portnames and the corresponding bonds ---")
  port_name, port_bond


  ## Deduce causality from the strokes (if any) and create the list of bonds
  causality = zeros(n_bonds,2);
  if n_strokes>0
    ## Find out location of centre and ends of stroke.
    stroke_end_1 = [rstrokes(:,1) rstrokes(:,2)];
    stroke_end_2 = [rstrokes(:,3) rstrokes(:,4)];
    
    stroke_centre = (stroke_end_1 + stroke_end_2)/2;
    stroke_vector = (stroke_end_1 - stroke_end_2);
    stroke_length = length2d(stroke_vector);

    ## Deduce bond causality from the strokes 
    for i = 1:n_strokes
      stroke = [stroke_centre(i,:) 
		stroke_end_1(i,:)
		stroke_end_2(i,:)];


      ## Find the nearest bond end.
      [index,distance] = adjbond(stroke(1,:),arrow_end,other_end);
      if (distance>2*stroke_length(i))
	info = sprintf('Stroke at (%4.3f,%4.3f) is %4.3f away from the nearest bond\n', ...
		       stroke(1,1)/scale, stroke(1,2)/scale, distance/scale);
      endif
      
      
      ## Bond end coordinates
      j = index(1,1);
      which_end = index(1,2)==1;
      bond_end = arrow_end(j,:)*which_end + other_end(j,:)*(1-which_end);
      
      ## Now decide which bit of the stroke is nearest
      stroke_index = adjbond(bond_end,stroke,zeros(size(stroke)));
      
      if stroke_index(1)==1 ## uni-causal stroke
	causality(j,1:2) = (2*which_end-1)*[1 1];
      else ## bicausal stroke
	## Find out whether stroke is on flow side of bond
	stroke_direction = stroke(1,:) - stroke(stroke_index(1),:);
	flow_side = stroke_direction*arrow_vector(j,:)'>0;
	causality(j,1+flow_side) = 2*which_end-1;
      endif
      
    endfor
    
  endif


  bonds = causality;


  ## Find number of bonds on each component BEFORE vectorisation
  for i=1:n_components
    n_vector_bonds(i,1) = length(nozeros(components(i,:)))
  endfor
  
  ## Now expand vector ports
  disp("Expanding vector ports");
  [n_bonds,junk] = size(bonds);
  n_ports = length(port_bond);
  n_exp_ports=n_ports;
  exp_port_name="";
  exp_port_bond = [];
  ##exp_comps = [];
  for i=1:n_ports
    port_name_i = port_name(i,:)
    [subport,n_subports] = split_port(port_name_i, ','); ## Find the components of the vector port

    if n_subports==1 ## an ordinary port
      exp_port_name = [exp_port_name; subport(1,:)]; ## Write out the only port
      exp_port_bond = [exp_port_bond; port_bond(i)]; ## and the port_bond
    else ## its a vector port
      ## Check that there is a corresponding vector port at the other end of the
      ## bond
      signed_bond_index = port_bond(i);
      [other_bond_index,n_other] = getindex(port_bond,-signed_bond_index);
      if n_other == 1
	other_port_name = port_name(other_bond_index,:);
	[other_subport,n_other_subports] = split_port(other_port_name, ',');
	if n_other_subports~=n_subports
	  mtt_error(['Vector ports ', port_name_i, ' and ', other_port_name, 'are not compatible'],errorfile);
	end
      else # No explicit matching vector port
 	mtt_error(['Vector port ', port_name_i, ' has no matching port'], errorfile);
      endif
      
      
      if other_bond_index>i ##then its not been done yet
	mtt_info(["Vector port: ", port_name_i],infofile);
	mtt_info(["matching: ", other_port_name],infofile);
	## Remove sign info.
	bond_index = abs(signed_bond_index);
	sig = sign(signed_bond_index);
	
	## Put the first element of each port list in the expanded list
	exp_port_name = [exp_port_name; subport(1,:)];
	exp_port_name = [exp_port_name; other_subport(1,:)];
	
	## Add to the expanded port_bond list
	exp_port_bond = [exp_port_bond; signed_bond_index; ...
			 -signed_bond_index];
	
	## Add the other names to the expanded list and augment the bonds,
	## components and port_bond lists.
	for j=2:n_subports
	  ## Add a new name (for each end) to give a non-vector list
	  exp_port_name = [exp_port_name; subport(j,:)];
	  exp_port_name = [exp_port_name; other_subport(j,:)];
	  
	  ## Add one more bond to the list
	  bonds = [bonds; bonds(bond_index,:)];
	  n_bonds = n_bonds + 1;
	  
	  ## Add bond to the expanded port_bond list (ports at both ends)
	  exp_port_bond = [exp_port_bond; sig*n_bonds; -sig*n_bonds];


	  ## Add the new bond to the component at both ends (taking note 
	  ## of the direction).
	  arrow_index = comp_near_bond(bond_index,1);
	  components = add_bond(components, n_bonds, arrow_index);
	  other_index = comp_near_bond(bond_index,2);
	  components = add_bond(components, -n_bonds, other_index);
	endfor
	
      endif
      
    endif
    
  endfor



  ##Replace old list by new
  port_name = exp_port_name
  port_bond = exp_port_bond

  ## Resize the lists
  [n_ports,junk] = size(port_name);

  port_name, components
  ## Produce a list of bonds on each component (within this component) 
  ##  - sorted if explicit port numbers
  for i = 1:n_components    
    disp('-----------------');
    ##Get component type
    eval(['[comp_type, comp_name] = ', name, '_cmp(i)']);


    ##Convert junction names   
    if comp_type(1)=='0'	# Zero junction
      comp_type = 'zero';
      isa_junction = 1;
    elseif comp_type(1)=='1'	# One junction
      comp_type = 'one';
      isa_junction = 1;
    else
      isa_junction = 0;
    endif

    ## Find the (unsorted) bond list on this component
    signed_bond_list = nozeros(components(i,:));
    n_comp_bonds = length(signed_bond_list);
    direction = sign(signed_bond_list);
    
    ##Find the port list for this component
    if exist([comp_type, '_cause'])==0
      eval(["ABG = ",comp_type, "_abg;"]);
      if isfield (ABG, "portlist")
	port_list = ABG.portlist;
      else
	error(sprintf("Component %s has no ports", comp_type));
        port_list = [];
      endif
    else
      port_list=comp_ports(comp_type,n_comp_bonds)
    endif
    

    [n_comp_ports,m_comp_ports] = size(port_list);
    subport_list="";
    for p=1:n_comp_ports		# Expand any vector ports
      [subport,n_sub] = split_port(port_list(p,:), ','); # Find the components
				# of the vector port
      if n_sub>1
	mtt_info(sprintf("Expanding vector port %s of component type %s", ...
			 port_list(p,:), comp_type, infofile));	
      endif
      
      subport_list = [subport_list; subport];
    endfor
    
    port_list = subport_list;	# Set the expanded port list.
    

    ## Check that number of bonds on the component is the same as the number of
    ## ports
    [n_comp_ports,m_comp_ports] = size(port_list);
    if (n_comp_ports~=n_comp_bonds) & ...
	  ~(strcmp(comp_type,'zero')|strcmp(comp_type,'one'))
      message=sprintf('Component %s (%s) has %1.0f impinging bonds but has %1.0f ports', ...
		      comp_name,comp_type,n_comp_bonds,n_comp_ports);
      mtt_error(message, errorfile);
    endif
    
    
    unsorted_port_list="";
    if n_ports>0 ## then there are some named ports
      ## so find those associated with the bonds on this component.
      k=0; 
      for j = 1:n_comp_bonds
	b = signed_bond_list(j); 
	## Find the port label on component end of bond (if any)
	[port_index,m] = getindex(port_bond,b);
	if m==1
	  k=k+1;
	  unsorted_port_list(k,:) = port_name(port_index,:);
	endif
	
      endfor
      
    else 
      k=0;
    endif
    
    %Compute the number of labeled ports
    [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
    if m_unsorted_ports==0
      n_unsorted_ports = 0;
    endif
    
    ## Junctions (order of ports unimportant)
    if strcmp(comp_type,'zero')|strcmp(comp_type,'one')
      for j = 1:n_comp_bonds
	components(i,j) = signed_bond_list(j);
      endfor
      
    else ##Order of ports is important
      unsorted_port_list, port_list
      if n_unsorted_ports==0
	mtt_error(['Component ', comp_name, ' (', comp_type, ') has no labeled ports'], errorfile); 
      endif
      
      ##Write out the signed bond list in the correct order
      unsorted_port_list
      [n_list,m_list] = size(unsorted_port_list);
      if n_list!=n_comp_bonds
	error(sprintf("Component %s (%s) has %i bonds but %i port labels", ...
		      comp_name, comp_type, n_comp_bonds, n_list))
      endif

      for j = 1:n_comp_bonds
	j
	name_k = unsorted_port_list(j,:)
	k = name_in_list(name_k, port_list);
	## Check that it only appears once in port list
	if length(k)>1
	  mtt_error(['Component ', comp_name, ' (', comp_type, ') has ports with the same name:  ', name_k], errorfile); 
	endif
	
	
	##Check that it only appears one in the label list
	kk = name_in_list(name_k,unsorted_port_list);
	if length(kk)>1
	  mtt_error(['Component ', comp_name, ' (', comp_type, ') has multiple port labels:  ', name_k], errorfile); 
	endif
	
	
	if k==0
	  mtt_error(['Component ', comp_name, ' (', comp_type, ') has an unrecognised port: ', name_k], errorfile); 
	else
	  components(i,k) = signed_bond_list(j);     
	endif
      endfor
    endif
  endfor

endfunction

Added mtt/bin/trans/m/rbg2ibg.m version [ec747e75b4].
























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*-

function [bonds] = ...
      rbg2ibg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, ...
	      infofile, errorfile)

  rbonds
  rstrokes
  rcomponents
  port_coord
  port_name

  ## Default to no components
  components = [0];

  ## Xfig scaling factor
  scale = 1200.0/2.54546;

  ## Rotation matrix
  rot = [0, -1; 1, 0];

  ## Find number of strokes
  [n_strokes,columns] = size(rstrokes);
  if ((columns ~= 4) & (n_strokes > 0))
    error('Incorrect rstrokes matrix: must have 4 columns');
  endif

  ## Find number of bonds
  [n_bonds,columns] = size(rbonds);
  if ((columns ~= 6) & (n_bonds > 0))
    error('Incorrect rbonds matrix: must have 6 columns');
  endif

  ## Find number of components
  [n_components,columns] = size(rcomponents);

  ## Find number of ports referred to
  [n_ports,columns] = size(port_coord);
  
  ## If port_name empty, make it empty string
  if (length(port_name) == 0)
    port_name="";
  endif
  
  ## Determine coordinates of arrow end of bond and other end
  other_end_1	= rbonds(:,1:2);
  arrow_end	= rbonds(:,3:4);
  other_end_2	= rbonds(:,5:6);

  distance_1	= length2d(other_end_1 - arrow_end);
  distance_2	= length2d(other_end_2 - arrow_end);
  which_end	= (distance_1 > distance_2) * [1, 1];
  one		= ones(size(which_end));
  other_end	= which_end .* other_end_1 + (one - which_end) .* ...
      other_end_2;
  arrow_vector	= (which_end .* other_end_2 + (one - which_end) .* ...
		   other_end_1) - arrow_end;
  
  ## Locate bond end nearest each port
  ## col 1 of port_near_bond contains a signed bond number (+ for arrow
  ## end)
  ## col 2 of port_near_bond contains the corresponding port index
  port_bond = [];
  for i = 1:n_ports
    near_bond = adjbond(port_coord(i,1:2), arrow_end, other_end);
    [rows,cols] = size(near_bond);
    if (rows > 1)
      error(sprintf ...
	    ("A port is near to more than one bond at coordinates ...
	  %g,%g %s\n", ...
	     port_coord(i,1)/scale, port_coord(i,2)/scale, ...
	     deblank(port_name(i,:))));
    endif
    
    ## The (signed) bond corresponding to the ith port label
    port_bond(i,1) = near_bond(1) * sign(1.5 - near_bond(2));
  endfor
  port_bond

  ## Now have (signed) bond (port_bond(i)) corresponding to the ith port
  ## Create inverse mapping
  for i = 1:n_bonds
    eval(sprintf('bond_port_head%i = "[]"', i))
    eval(sprintf('bond_port_tail%i = "[]"', i))
  endfor  
  for i = 1:n_ports
    if (port_bond(i) > 0)
      eval(sprintf('bond_port_head%i = "%s"', port_bond(i), ...
		   deblank(port_name(i,:))))
    else
      eval(sprintf('bond_port_tail%i = "%s"', -port_bond(i), ...
		   deblank(port_name(i,:))))
    endif
  endfor
  
  ## Locate the components at the ends of each bond
  ## col 1 of comp_near_bond contains component nearest to the arrow end
  ## col 2 of comp_near_bond contains component nearest other end
  for i = 1:n_bonds
    comp_near_bond(i,:) = adjcomp(arrow_end(i,:), other_end(i,:), ...
				  rcomponents);
  endfor
  comp_near_bond

  ## Deduce causality from the strokes (if any)
  causality = zeros(n_bonds,2);
  if (n_strokes > 0)
    ## Find location of centre and ends of stroke
    stroke_end_1	= [rstrokes(:,1), rstrokes(:,2)];
    stroke_end_2	= [rstrokes(:,3), rstrokes(:,4)];

    stroke_centre	= (stroke_end_1 + stroke_end_2)/2;
    stroke_vector	= (stroke_end_1 - stroke_end_2);
    stroke_length	= length2d(stroke_vector);

    for i = 1:n_strokes
      stroke = [stroke_centre(i,:)
		stroke_end_1(i,:)
		stroke_end_2(i,:)];


      ## Find the nearest bond end
      [index,distance] = adjbond(stroke(1,:),arrow_end,other_end);
      if (distance > (2 * stroke_length(i)))
	info = sprintf('Stroke at (%4.3f,%4.3f) is %4.3f away from the nearest bond\n', ...
		       stroke(1,1)/scale, stroke(1,2)/scale, ...
		       distance/scale);
      endif

      ## Bond end coordinates
      j = index(1,1);
      which_end = (index(1,2) == 1);
      bond_end = arrow_end(j,:) * which_end + other_end(j,:) * (1 - ...
								which_end);
      
      ## Now decide which bit of the stroke is nearest
      stroke_index = adjbond(bond_end, stroke, zeros(size(stroke)));

      if (stroke_index(1) == 1)	# uni-causal stroke
	causality(j,1:2) = (2 * which_end - 1) * [1, 1];
      else			# bi-causal stroke
	stroke_direction = stroke(1,:) - stroke(stroke_index(1),:);
	flow_side = stroke_direction * arrow_vector(j,:)' > 0;
	causality(j,1+flow_side) = 2 * which_end - 1;
      endif
    endfor
  endif
  causality

  ## Write data
  for i = 1:n_bonds
    [hc_type, hc_name] = eval([name, '_cmp(comp_near_bond(i,1))']);
    [tc_type, tc_name] = eval([name, '_cmp(comp_near_bond(i,2))']);
    ## components
    eval(sprintf("bonds.bond%i.head.component\t= '%s:%s'", i, hc_type, ...
		 hc_name));
    eval(sprintf("bonds.bond%i.tail.component\t= '%s:%s'", i, tc_type, ...
		 tc_name));
    ## ports
    eval(sprintf("bonds.bond%i.head.ports\t= bond_port_head%i", i, i));
    eval(sprintf("bonds.bond%i.tail.ports\t= bond_port_tail%i", i, i));
    ## causality
    if (causality(i,1) == 1)
      effort_causality = "head"
    elseif (causality(i,1) == -1)
      effort_causality = "tail"
    else
      effort_causality = "none"
    endif

    if (causality(i,2) == 1)
      flow_causality = "tail"
    elseif (causality(i,2) == -1)
      flow_causality = "head"
    else
      flow_causality = "none"
    endif
    
    eval(sprintf("bonds.bond%i.causality.effort\t= '%s'", i, effort_causality));
    eval(sprintf("bonds.bond%i.causality.flow\t= '%s'", i, flow_causality));
  endfor

endfunction

Added mtt/bin/trans/m/rc_sim.m version [bf245ec09e].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y,x] = rc_sim(mttx_0,mttU,mttT,MTTpar);

  ## Initialise
  [MTTu]  = zero_input(1);	# Zero the input

  [MTTx] = mttx_0;	        # Read in initial state

  N = length(mttT);
  Nx = length(mttx_0);

  y = zeros(1,N);
  x = zeros(Nx,N);

  mttdt = mttT(2)-mttT(1);
  for i = 1:N
    MTTt = mttT(i);
    MTTu = mttU(i);
    [MTTy] = rc_cseo(MTTx,MTTu,MTTt,MTTpar);    # Output 
    y(1,i) = MTTy;
    x(:,i) = MTTx;
    if 1>0			# Dont if no states
      [MTTdx] = rc_cse(MTTx,MTTu,MTTt,MTTpar); # State derivative
      [mttAA] = rc_smxa(MTTx,MTTu,mttdt,MTTpar);	# (I-Adt)
      [mttAA] = reshape(mttAA,Nx,Nx);
      [mttAAx] = rc_smxax(MTTx,MTTu,mttdt,MTTpar);	# (I-Adt)x
      [MTTopen] = rc_switchopen(MTTx);        # Open switches
      [MTTx] = mtt_implicit(MTTx,MTTdx,mttAA,mttAAx,mttdt,1,MTTopen); # Implicit update
    else 
    endif;			# 1>0

  endfor;				# Integration loop

endfunction

Added mtt/bin/trans/m/rcs_header.txt version [52b8d3c3d8].









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Added mtt/bin/trans/m/replace_name.m version [f5eb963580].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function string_array = replace_name(string_array, new, index); 
% Replaces a row of a string vector with a string of arbitary length.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 12:36:39  peterg
## Initial revision
##
###############################################################

string_array,new,index
  [N,M]=size(string_array);
  L = length(new);
  
  if index>N 
    error(["String array has less than ", num2str(index), " rows"]);
  end;
  
  if L<M			# Pad the new string
    new = [new, blanks(M-L)];
  elseif M<L			# Pad the array
    for i=1:L-M
      string_array=[string_array, blanks(N)'];
    end
  end

  string_array(index,:) = new;	# Replace ith row by new string

endfunction

    
    


Added mtt/bin/trans/m/sign2name.m version [815733e396].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = sign2name(sign);
% sign2name - converts sign to a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sign2name


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



if sign==1
  name = '+';
elseif sign ==-1
  name = '-';
else
  name = '??';
end;

Added mtt/bin/trans/m/sm2ir.m version [4fd52f72ba].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% sm2ir - state matrix to impulse response.
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sm2ir
% [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% A,B,C,D,E - (constrained) state matrices
% T vector of time points
% u0 input gain vector: u = u0*unit impulse.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/12/05 10:17:34  peterg
% %% Put in version control history.
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if max(max(abs(D)))~=0
  mtt_info('D matrix non-zero - ignoring');
end;

if nargin<6
  u0 = zeros(Nu,1);
  u0(1) = 1;
end;

if nargin<7
  x0 = zeros(Nx,1);
end;

[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;



one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);

dt = T(2)-T(1);% Assumes fixed interval
##expAdt = expm(A*dt); % Compute matrix exponential
##expAt = one;
i = 0;
x = (B*u0+x0);
for t = T'
  i=i+1;
  if Nx>0
    ##expAt = expm(A*t);
    ##x = expAdt*x;
     x = expm(A*t)*(B*u0+x0);
    X(i,:) = x';
    if Ny>0
      y = C*x;
      Y(i,:) = y';
    end;
  end;
end;






Added mtt/bin/trans/m/sm2sr.m version [d2d3e4bb56].
































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% sm2sr - Constrained-state matrix to step response.
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sm2sr
% [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% A,B,C,D,E - (constrained) state matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/12/05 10:18:52  peterg
% %% Saved (quite old) version which integrates IR to give SR
% %%
% %% Revision 1.3  1996/10/27  10:39:04  peterg
% %% Only compute matrix exponential once.
% %%
% %% Revision 1.2  1996/09/10  16:48:21  peter
% %% Changed ar counts in default settings.
% %%
% %% Revision 1.1  1996/08/19 15:34:29  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if nargin<6
  u0 = zeros(Nu,1);
  u0(1) = 1;
end;

if nargin<7
  x0 = zeros(Nx,1);
end;

[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;



one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);

dt = T(2)-T(1);% Assumes fixed interval
expAdt = expm(A*dt); % Compute matrix exponential
i = 0;
expAt = one;

for t = T'
  i=i+1;
  if Nx>0
    x = ( A\(expAt-one) )*B*u0 + expAt*x0;
    expAt = expAt*expAdt;
    X(i,:) = x';
    if Ny>0
      y = C*x + D*u0;
      Y(i,:) = y';
    end;
  elseif Ny>0
    y = D*u0;
    Y(i,:) = y';
  end;
end;

% $$$ % Compute the impulse response
% $$$ [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% $$$ 
% $$$ % Assume fixed sample interval
% $$$ dT = T(2)-T(1);
% $$$ 
% $$$ % Do an Euler integration on it
% $$$  Y = mtt_euler(Y,dT);
% $$$  
% $$$  if nargout>1
% $$$    X = mtt_euler(X,dT);
% $$$  end;
% $$$  



Added mtt/bin/trans/m/split_port.m version [bf18ef5846].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [subport,n]=split_port(port_name);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/04/16 14:08:00  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



  subport = "";
  raw_subport = char(strsplit(port_name, ',')); # Find the components of the vector
				# port 
  [n,m] = size(raw_subport);	# Number of ports

  for i = 1:n
    s = deblank(raw_subport(i,:));
    l = length(s);

    if s(1)=="["		# Remove leading [ (if any)
      l = l-1;
      s = substr(s,2,l);
    end

    if s(l)=="]"		# Remove trailing ] (if any)
      l = l-1;
      s = substr(s,1,l);
    end

    s = ["[",s,"]"];		# Surround by []
    
    subport = [subport ;s];	# Return to the array
  end;

endfunction;





Added mtt/bin/trans/m/str2ch.m version [6886463212].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ch = str2ch(str,n)
% str2ch - pulls the nth char from a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  str2ch.m
% ch = str2ch(str,n)
% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/12/04 21:39:55  peterg
% %% Changed to handle null string (octave returns lenghth of 1)
% %%
% %% Revision 1.1  1996/08/30  09:54:44  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
implicit_str_to_num_ok = 1;

astr = abs(str);
if (n>0) &  (n<=length(str)) & (strcmp(str,'')==0)
  ch = char(astr(n));
else
  ch = '';
end;















Added mtt/bin/trans/m/subs_arg.m version [9eca75053a].






























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function args_out = subs_arg(args,Args, ...
    default,full_name,comp_type,comp_name,fileID)
% subs_arg - substitutes arguments into args from Args
% FS defaults to `;'.
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  subs_arg.m
% args_out = subs_arg(args,Args,default,comp_type,comp_name,infofile)
% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2001/07/03 22:59:10  gawthrop
% %% Fixed problems with argument passing for CRs
% %%
% %% Revision 1.6  1998/07/27 09:53:44  peterg
% %% No change
% %%
% %% Revision 1.5  1998/07/21 16:43:26  peterg
% %% Now writes to an explicit fileID - otherwise we may run out of IDs.
% %%
% %% Revision 1.4  1996/12/10 16:04:11  peterg
% %% Changed file handling on mtt_info.
% %%
% %% Revision 1.3  1996/12/07  18:19:39  peterg
% %% Replaces null argument by a default and tells user.
% %%
% %% Revision 1.2  1996/12/04 21:47:41  peterg
% %% Skips main loop when arg is null.
% %%
% %% Revision 1.1  1996/12/04 21:46:52  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Symbolic argument sign
S = '$';

args_out = '';
if strcmp(args,'')==0
  L = length(args);
  args_count = 1;
  num_count=0;
  while args_count <= L
    ch = str2ch(args,args_count);
    if ch~=S % copy character
      args_out = [args_out, ch];
      args_count = args_count+1;
    else % find argument number
      args_count = args_count+1;
 	
      ch = str2ch(args,args_count);    
      ## Modification for $p1 $a1 etc
      if !((ch>='0') & (ch<='9')) # It's not numerical - so loose it
	args_count = args_count+1;
	ch = str2ch(args,args_count);    
      endif

     i=0;
      while (ch>='0') & (ch<='9')
	i = 10*i + abs(ch)-abs('0');
	if args_count==L
	  args_count = args_count+1;
	  break
	end;
	args_count = args_count+1;
	ch = str2ch(args,args_count);
      end;
      arg_out = args2arg(Args,i);


      % Test for empty argument -- replace by default and tell user
      message = 'Argument %1.0f of component %s(%s) of system %s is undefined - \n replacing by %s';
      if strcmp(arg_out,'')
	info = sprintf(message, ...
	    i, comp_name, comp_type, full_name, default);
	arg_out = default;
      else
	info = sprintf("Replacing $%i \t by %s for component %s (%s) ...
	within %s", i, arg_out, comp_name, comp_type, full_name);
      end;
      mtt_info(info,fileID);
      args_out = [args_out, arg_out];
    end;
  end;
end;

Added mtt/bin/trans/m/varname.m version [936a174266].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = varname(name,index,causality);
  ## varname - Creates name of bond graph variable
  ## Usage: name = varname(name,index,causality);
 
##     ###################################### 
##     ##### Model Transformation Tools #####
##     ######################################
## 
## Matlab function  varname.m
## Copyright (C) 1994-2003 by Peter J. Gawthrop


# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.4  2003/03/24 09:09:52  gawthrop
# ## Reformated to octave standard
# ## Now writes variables in non-matrix form
# ##
# ## Revision 1.3  2003/03/13 14:22:34  gawthrop
# ## No negative bond numbers
# ##
# ## Revision 1.2  2000/12/27 16:06:15  peterg
# ## *** empty log message ***
# ##
# ## Revision 1.1  1996/08/27 08:08:44  peterg
# ## Initial revision
# ##
# ###############################################################


# # bond_name = [name,'_bond'];
# # name =sprintf('%s%1.0f_%s', bond_name, index, cause2name(causality));

# # bond_name = [name,'('];
# # name =sprintf('%s(%1.0f,%1.0f)', name, abs(index), cause2num(causality));

  name =sprintf('%s_%i_%s', name, abs(index), cause2name(causality));

endfunction

Added mtt/bin/trans/m/write_abg.m version [1dcbed067b].









































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function write_abg(system_name,bonds,connections,n_vector_bonds);

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  2004/09/12 22:27:27  geraint
## Appended 't' to fopen mode string to open in text mode.
##
## Revision 1.10  2004/08/09 14:47:28  gawthrop
## Changed arg to args to avoid strange octave bug
##
## Revision 1.9  2001/04/15 21:15:41  geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.8  1999/10/18 22:41:41  peterg
## Corrected vector junction expansion
##
## Revision 1.7  1999/10/18 05:16:51  peterg
## Now vectorises 0 and 1 junctions !!
##
## Revision 1.6  1998/09/02 11:35:20  peterg
## Removed port.index field
##
## Revision 1.5  1998/09/02 10:30:30  peterg
## Now writes out list of ports ans list of subsystems.
## These ordereded lists determine the order of processing of ports ans
## subsystems.
##
## Revision 1.4  1998/08/26 12:45:38  peterg
## Just prefix ports (comps can't start with numeral)
## Prefix with mttp
##
## Revision 1.3  1998/08/26 12:31:07  peterg
## numerical names prefixed by mtt
##
## Revision 1.2  1998/08/26 11:59:20  peterg
## Don't use strrep to remove[]
##
## Revision 1.1  1998/08/25 06:22:02  peterg
## Initial revision
##
###############################################################


  fid=fopen([system_name,"_abg.m"], "wt");
  [N,M]=size(connections);
  Sformat = "  %s.subsystems.%s.%s = \"%s\";\n";
  PSformat = "  %s.ports.%s.%s = \"%s\";\n";
  Iformat = "  %s.subsystems.%s.%s = %i;\n";
  PIformat = "  %s.ports.%s.%s = %i;\n";
  Cformat = "  %s.subsystems.%s.connections = [";
  PCformat = "  %s.ports.%s.connections = [";
  Bformat = "  %s.bonds = [\n";

  fprintf(fid,"function [%s] =  %s_abg\n", system_name, system_name);
  fprintf(fid,"# This function is the acausal bond graph representation of %s\n",system_name);
  fprintf(fid,"# Generated by MTT on %s",ctime(time));
  fprintf(fid,"# The file is in Octave format\n");

  fprintf(fid,"\n# Subsystems and Ports\n");
  i_port=0; SubsystemList = ""; PortList ="";
  for i=1:N
    eval(["[comp_type, name, cr, args, repetitions] = ", system_name, "_cmp(i);"]);
    c = nozeros(connections(i,:));# Connections to this component
    m = length(c);		# Number of connections

    ## Vectorise junctions?
    n_bonds = n_vector_bonds(i);
    if strcmp(comp_type,"0")||strcmp(comp_type,"1")
            n_vector = m/n_bonds;
	    m_vector = n_bonds;
    else
      n_vector = 1;
      m_vector = m;
    endif
      
    if index(name,"[")==0	# Not a port
      for i_vector = 1:n_vector;

	if i_vector>1		# Extras
	  new_name = sprintf("%sv%i", name,i_vector);
	else
	  new_name = name;
	endif
	
	SubsystemList = [SubsystemList; new_name];
	fprintf(fid,"\n# Component %s\n", new_name);
	fprintf(fid,Sformat,system_name,new_name,"type",comp_type);
	fprintf(fid,Sformat,system_name,new_name,"cr",cr);
	fprintf(fid,Sformat,system_name,new_name,"arg",args);
	fprintf(fid,Iformat,system_name,new_name,"repetitions",repetitions);
	fprintf(fid,Iformat,system_name,new_name,"status",-1);

	##Connections
	fprintf(fid,Cformat,system_name,new_name);
	## Each vector junction has n*m bonds
	## n - dimension of vector
	## m - number of bonds
	
	## The first m bonds (in c) correspond to the first vector element
	if i_vector==1		
	  for j=1:m_vector
      	    fprintf(fid,"%i ", c(j) );
	  endfor
	  ## The next block of n-1 bonds are the first bonds on vector elements 2,3 ...
	  ## followed by a  block of n-1 bonds being the second bonds on vector elements 2,3 ...
	  ## etc
	else	
	  k = m_vector+i_vector-1; # index of first bond at level i_vector
	  for j=1:m_vector
      	    fprintf(fid,"%i ", c(k) );
	    k = k + n_vector-1;
	  endfor
	endif
	
	fprintf(fid,"];\n");
      endfor
    else			# Its a port
      name=name(2:length(name)-1); # Strip []
      ch=name(1);		# First char of name
      if (ch>="0")&&(ch<="9")	# Its a numeral
      	name=["mttp",name];	# prefix by mttp
      endif;

      for i_port=1:m
	if m>1			# Index the port name
	  name_i = sprintf("%s_%i",name,i_port);
	else
	  name_i = name;	# Leave it alone
	endif;

	PortList = [PortList; name_i]; # Update port list
	
	fprintf(fid,"\n# Port %s\n", name_i); 
	fprintf(fid,PSformat,system_name,name_i,"type",comp_type);
	fprintf(fid,PSformat,system_name,name_i,"cr",cr);
	fprintf(fid,PSformat,system_name,name_i,"arg",args);
	fprintf(fid,PIformat,system_name,name_i,"repetitions",repetitions);
	fprintf(fid,PIformat,system_name,name_i,"status",-1);
	
	fprintf(fid,PCformat,system_name,name_i);
      	fprintf(fid,"%i ", c(i_port));
	fprintf(fid,"];\n");

      endfor;
    endif;
  endfor;

  [N,M]=size(PortList);
  if N>0			# Put name in list
    fprintf(fid,"\n# Ordered list of Port names\n");
    for i=1:N
      fprintf(fid,"  %s.portlist(%i,:) = \"%s\";\n", system_name, i, PortList(i,:));
    endfor;
  endif;

  [N,M]=size(SubsystemList);
  if N>0			# Put name in list
    fprintf(fid,"\n# Ordered list of subsystem names\n");
    for i=1:N
      fprintf(fid,"  %s.subsystemlist(%i,:) = \"%s\";\n", system_name, i, SubsystemList(i,:));
    endfor;
  endif;


  fprintf(fid,"\n# Bonds \n");
  [N,M]=size(bonds);		# Bonds
  fprintf(fid,Bformat,system_name);
  for i=1:N
    fprintf(fid,"      ");
    for j=1:M
      fprintf(fid,"%i ", bonds(i,j));
    endfor;
    fprintf(fid,"\n");
  endfor;
  fprintf(fid,"      ];\n");
    
  fprintf(fid,"\n# Aliases \n");
  fprintf(fid,"# A double underscore __ represents a comma \n");
  eval(["alias = ", system_name, "_alias;"]);
  if isstruct(alias)
    for [val,key] = alias
      fprintf(fid,"%s.alias.%s = \"%s\";\n", system_name,key,val);
    endfor
  endif

  fprintf(fid,"\n# Interface Definition\n");
  eval(["icd = ",system_name, "_icd;"]);
  if isstruct(icd)
    for [val,key] = icd
      fprintf(fid,"%s.icd.%s = \"%s\";\n",system_name,key,val);
    endfor
  endif
	

  fclose(fid);
  

Added mtt/bin/trans/m/write_cbg.m version [cabf88aa9f].
























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function write_cbg(system_name,system_type,system,Flipped)

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2004/09/12 22:27:27  geraint
## Appended 't' to fopen mode string to open in text mode.
##
## Revision 1.4  1998/08/26 12:26:17  peterg
## Replaced if N>0 by   if (N>0)&&(M>0)		# Flipped ports exist
##
## Revision 1.3  1998/08/25 20:05:33  peterg
## Write flipped port info
##
## Revision 1.2  1998/08/25 06:21:19  peterg
## Just writes additional information; basic info from the abg structure.
##
## Revision 1.1  1998/08/25 05:55:10  peterg
## Initial revision
##
###############################################################


  fid=fopen([system_name,"_cbg.m"], "wt");# Open file

  StatusFormat = "  %s.%s.%s.status = %i;\n";
  Bformat = "  %s.bonds = [\n";
  Iformat = "  %s.%s.%s.connections(%i) = %i;\n";


  fprintf(fid,"function [%s] =  %s_cbg\n", system_name, system_name);
  fprintf(fid,"# This function is the causal bond graph representation of %s\n",system_name);
  fprintf(fid,"# Generated by MTT on %s",ctime(time));
  fprintf(fid,"# The file is in Octave format\n");
  
  fprintf(fid,"\n# Acausal bond graph structure\n");
  fprintf(fid,"  [%s] =  %s_abg;\n", system_name, system_type);

  fprintf(fid,"\n# Status information\n");
#  if isfield(system,"ports")
#    for [port,name]=system.ports
#      fprintf(fid,StatusFormat,system_name,"ports",name,port.status);
#    endfor;
#  endif
  if isfield(system,"subsystems")
    for [subsystem,name]=system.subsystems
      fprintf(fid,StatusFormat,system_name,"subsystems",name,subsystem.status);
    endfor;
  endif
  
  [N,M]=size(system.bonds);		# Bonds
  fprintf(fid,"\n# Causal bond information\n");
  fprintf(fid,Bformat,system_name);
  for i=1:N
    fprintf(fid,"      ");
    for j=1:M
      fprintf(fid,"%i ", system.bonds(i,j));
    endfor;
    fprintf(fid,"\n");
  endfor;
  fprintf(fid,"      ];\n");

  [N,M]=size(Flipped.ports);
  if (N>0)&&(M>0)		# Flipped ports exist
    fprintf(fid,"\n# Flipped port information\n");
    for i=1:N
      name=deblank(Flipped.ports(i,:));
      eval(["con = system.ports.",name,".connections;"]);
      fprintf(fid,Iformat,system_name,"ports",name,1,con);
    endfor;
  endif;

  [N,M]=size(Flipped.subs);
  if (N>0)&&(M>0)		# Flipped subs exist
    for i=1:N
      name=deblank(Flipped.subs(i,:));
      k=Flipped.cons(i);
      eval(["con = system.subsystems.",name,".connections(",num2str(k),");"]);
      fprintf(fid,Iformat,system_name,"subsystems",name,k,con);
    endfor;
  endif;

  fclose(fid);
  

Added mtt/bin/trans/m/write_ibg.m version [bff06207d1].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*-

function write_ibg(system_name,bonds);
  
  fid = fopen([system_name,"_ibg.m"], "wt");
  [nbonds, junk] = size(fieldnames(bonds));
  format_hc = "  %s.bonds.bond%i.head.component\t= \"%s\";\n";
  format_tc = "  %s.bonds.bond%i.tail.component\t= \"%s\";\n";
  format_hp = "  %s.bonds.bond%i.head.ports\t= \"%s\";\n";
  format_tp = "  %s.bonds.bond%i.tail.ports\t= \"%s\";\n";
  format_ce = "  %s.bonds.bond%i.causality.effort\t= \"%s\";\n";
  format_cf = "  %s.bonds.bond%i.causality.flow\t= \"%s\";\n";

  fprintf(fid, "## -*-octave-*-\n\n");
  fprintf(fid, "function [%s] = %s_ibg\n\n", system_name, system_name);
  fprintf(fid, "  ## Intermediate bond graph representation of %s\n", ...
	  system_name);

  fprintf(fid, "  ## Generated by MTT on %s\n", ctime(time));
  fprintf(fid, "  ## head refers to the harpoon end of a bond\n");
  fprintf(fid, "  ## tail refers to the other end of a bond\n");
  fprintf(fid, "  ## causality.? is the end at which ? is imposed\n\n");

  for i=1:nbonds
    fprintf(fid, "\n  ## bond %i\n", i);
    fprintf(fid, format_hc, system_name, i, ...
	    eval(sprintf("bonds.bond%i.head.component", i)));
    fprintf(fid, format_tc, system_name, i, ...
	    eval(sprintf("bonds.bond%i.tail.component", i)));
    fprintf(fid, format_hp, system_name, i, ...
	    eval(sprintf("bonds.bond%i.head.ports", i)));
    fprintf(fid, format_tp, system_name, i, ...
	    eval(sprintf("bonds.bond%i.tail.ports", i)));
    fprintf(fid, format_ce, system_name, i, ...
	    eval(sprintf("bonds.bond%i.causality.effort", i)));
    fprintf(fid, format_cf, system_name, i, ...
	    eval(sprintf("bonds.bond%i.causality.flow", i)));
  endfor;

  fprintf(fid, "\nendfunction\n");
  fclose(fid);

endfunction;

Added mtt/bin/trans/m/write_matrix.m version [80adc0845c].












































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function write_matrix(matrix,name,extn);

% Writes the matrix function file

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.9  2006/09/27 13:55:08  geraint
% %% Write complex numbers in polar form instead of real and imaginary parts.
% %%
% %% Revision 1.8  2004/09/12 22:27:27  geraint
% %% Appended 't' to fopen mode string to open in text mode.
% %%
% %% Revision 1.7  2002/05/15 16:37:30  gawthrop
% %% Added third argument (file extension)
% %%
% %% Revision 1.6  2000/12/27 16:06:17  peterg
% %% *** empty log message ***
% %%
% %% Revision 1.5  1998/02/03 08:40:39  peterg
% %% Fixed a horrible bug -- changed filename -> filenum
% %%
% %% Revision 1.4  1996/08/15  11:56:11  peter
% %% Does complex matrices.
% %%
% %% Revision 1.3  1996/08/14 19:20:41  peter
% %% Fixed output naming bug.
% %%
% %% Revision 1.2  1996/08/14 08:36:52  peter
% %% Puts a tab between columns.
% %%
% %% Revision 1.1  1996/08/14 08:21:27  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if nargin<3
  extn="m";
endif

filename = sprintf("%s.%s", name, extn);
filenum = fopen(filename,'wt');

% Write the function m-file for the causal bond graph
pc = '%';
fprintf(filenum, 'function data = %s\n', name);
fprintf(filenum, '%s data = %s\n\n', pc, name);

fprintf(filenum, 'data = [\n');

[N,M] = size(matrix);
for row = 1:N
  for col = 1:M
    value = matrix(row,col);
    if iscomplex(value)
	fprintf(filenum, '%g*e^(%g*i)', abs(value),angle(value));
    else
	fprintf(filenum, '%g', value);
    end
    if col<M
      fprintf(filenum, '\t');
    end
  end;
  fprintf(filenum, '\n');
end;

fprintf(filenum, '];\n');
fprintf(filenum, '\n');

fclose(filenum);


Added mtt/bin/trans/m/zero_input.m version [2299a73554].




1
2
3
+
+
+
function [x] = zero_input(N);
  x = zeros(N,1);
endfunction;

Added mtt/bin/trans/m/zero_matrix.m version [4f191aac68].




1
2
3
+
+
+
function [A] = zero_matrix(N);
  A = zeros(N,N);
endfunction;

Added mtt/bin/trans/m2dat version [f209734a96].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: m2dat

# Transforms data in .m file to just the data - ie strips the matlab stuff

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1996/08/14 08:36:16  peter
## Initial revision
##
###############################################################

echo Creating $1.dat

gawk '$1 ~ /[0-9]/ && NF>0 {print} ' <$1.m  >$1.dat

Added mtt/bin/trans/make_ode2odes version [4c433b0d7e].






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
    ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.90  2005/04/26 23:43:34  geraint
## Reset open switches after update to eliminate overshoots.
##
## Revision 1.89  2004/08/29 16:04:44  geraint
## Fixed ae for non-sorted code.
##
## Revision 1.88  2004/08/29 13:15:28  geraint
## Uses sys_sae instead of sys_ae if sorted equations are being used.
##
## Revision 1.87  2004/08/29 01:46:56  geraint
## Added rules to create ode2odes for sorted system: sesx and sesy.
##
## Revision 1.86  2004/08/29 00:19:49  geraint
## Defaults to noAlgebraicSolver.
##
## Revision 1.85  2003/06/25 12:46:06  gawthrop
## Input only changed one per print interval
## No effect if stepfactor=1
## Fixes bug when _input.m is compiled using -stdin option
## and stepfactor>1
##
## Revision 1.84  2003/04/17 20:57:29  geraint
## Added -sort option to allow direct generation of ode2odes.m using sese.m
## instead of ode/csex.
##
## "mtt -sort rc odeso view" works without Reduce installed!!!
##
## Revision 1.83  2002/08/07 14:27:14  geraint
## Changes to make "-i dassl" work again.
##
## Revision 1.82  2002/07/24 14:00:12  geraint
## Corrected arguments passed to mtt_write when dumping data (sigint).
##
## Revision 1.81  2002/07/11 13:00:23  geraint
## Declared more function arguments to be "const" - improves compiler optimisation.
##
## Revision 1.80  2002/05/22 09:35:49  geraint
## Added insertor variable to stop sh-mode font-lock from getting hopelessly confused by embedded C++.
##
## Revision 1.79  2002/05/20 13:42:31  gawthrop
## Uses simpar.first for first printed output
##
## Revision 1.78  2002/05/11 01:14:17  geraint
## Fix for [ 553218 ] simpar.oct and simpar.m different.
## Translation added between ColumnVector in base .cc and Octave_map in .oct.
##
## Revision 1.77  2002/05/08 16:03:32  geraint
## Added mex support for ode2odes: mtt sys ode2odes mexglx.
## This mex stuff seems to require octave2.1-headers.
##
## Revision 1.76  2002/05/08 14:14:55  geraint
## Tidied up ode2odes code - reduced interweaving of STANDALONE/OCTAVEDLD sections
##
## Revision 1.75  2002/05/07 13:48:42  geraint
## Improved clarity of code generated for -cc and -oct (except ode2odes).
## Octave DEFUN_DLDs now call (rather than replace) their .cc equivalents.
##
## Revision 1.74  2002/05/01 17:30:56  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
## if necessary.
##
## Revision 1.73  2002/05/01 12:24:41  geraint
## Removed unnecessary inclusion of load-save.h.
##
## Revision 1.72  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.71  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp
## (and thus libreadline, libkpathsea, libncurses, etc).
##
## Revision 1.70  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.69  2002/04/17 13:46:58  geraint
## #include <fstream> for -oct as well as -cc.
##
## Revision 1.68  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).
##
## Revision 1.67  2002/04/09 12:04:21  geraint
## Replaced ios:: with std::ios:: for g++-3.0 compatability.
##
## Revision 1.66  2002/03/26 11:58:58  geraint
## Added cputime monitoring.
##
## Revision 1.65  2001/11/15 06:24:11  geraint
## Updated (-i dassl) residual function to use new DAEFunc (octave-2.1.35).
## YZ residual dependency on Ui still requires some work.
##
## Revision 1.64  2001/08/08 02:15:00  geraint
## Rationalisation of solver code, beginning with algebraic solvers.
##
## Revision 1.63  2001/08/07 04:39:24  geraint
## Consolidated dassl and residual functions.
##
## Revision 1.62  2001/08/01 22:14:32  geraint
## Bug fix for dassl.
##
## Revision 1.61  2001/08/01 04:06:07  geraint
## Added -i dassl for -cc and -oct.
##
## Revision 1.60  2001/07/16 22:23:00  geraint
## Fixed misleading variable name in .cc rep.
##
## Revision 1.59  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.58  2001/07/13 00:51:39  geraint
## Fixed generation of odes.sg from .m and .oct simulations.
## .cc, .m and .oct simulations now all write mtt_data (lower case).
##
## Revision 1.57.2.5  2001/07/13 04:02:31  geraint
## Implemented numerical algebraic solution for _ode2odes.oct.
##
## Revision 1.57.2.4  2001/07/02 00:34:56  geraint
## gcc-3.0 compatibility.
##
## Revision 1.57.2.3  2001/06/25 23:28:29  geraint
## Generic mtt_rate and mtt_output - allows method independent calls.
##
## Revision 1.57.2.2  2001/06/05 03:20:40  geraint
## added -ae option to select algebraic equation solution method.
##
## Revision 1.57.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.57  2001/04/01 03:38:54  geraint
## Reset row to zero after write to file, ready for subsequent runs.
## Eliminates SIGSEGV in Octave when _ode2odes called multiple times.
##
## Revision 1.56  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.55  2001/03/27 13:21:59  geraint
## Octave version compatibility for save_ascii_data(_for_plotting).
##
## Revision 1.54  2001/03/27 01:14:27  geraint
## Improved determination of Octave version.
##
## Revision 1.53  2001/03/21 03:24:59  geraint
## Calculate inputs before outputs (.cc).
##
## Revision 1.52  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.51.2.7  2001/03/17 09:51:07  geraint
## Implemented Runge-Kutta IV fixed-step method (-i rk4).
##
## Revision 1.51.2.6  2001/03/16 03:56:13  geraint
## Removed psignal/siginfo.h - problematic and unnecessary.
##
## Revision 1.51.2.5  2001/03/12 23:16:37  geraint
## Minor improvements to signal handling (.exe).
##
## Revision 1.51.2.4  2001/03/12 03:59:30  geraint
## SIGINT  (C-c C-c) now causes simulation data to be dumped to MTT.core.
## SIGQUIT (C-c C-\) as for SIGINT, then raises default SIGQUIT.
## SIGFPE  as for SIGINT, then raises default SIGABRT.
##
## Revision 1.51.2.3  2001/03/07 04:06:55  geraint
## Irix: catch SIGFPE and write data before aborting (.exe).
## GNU/Linux: nada.
##
## Revision 1.51.2.2  2001/03/02 00:45:21  geraint
## Separated Euler and Implicit methods in .cc code and dependencies.
##
## Revision 1.51.2.1  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.51  2001/02/19 06:33:19  geraint
## Removed operation form loop.
##
## Revision 1.50  2001/02/18 09:18:49  geraint
## Removed temporary Matrices from mtt_implicit.cc
##
## Revision 1.49  2001/02/14 06:06:34  geraint
## Removed octave_value_list wrappers from standalone.exe - speed improvements
##
## Revision 1.48  2001/02/11 07:08:59  geraint
## Static declarations of octave_value_lists: small .exe speed improvement
##
## Revision 1.47  2001/02/11 05:25:52  geraint
## Reduced number of matrix operations during .oct simulation data write
##
## Revision 1.46  2001/02/05 08:32:31  geraint
## typo
##
## Revision 1.45  2001/02/05 04:32:35  geraint
## Octave version 2.1.x compatability and #ifdef statements for standalone rep
##
## Revision 1.46  2001/01/08 06:21:59  geraint
## #ifdef STANDALONE stuff
##
## Revision 1.45  2001/01/07 01:25:49  geraint
## Compatibility with Octave 2.1.33
##
## Revision 1.44  2000/12/05 12:11:45  peterg
## Changed function name to name()
##
## Revision 1.43  2000/12/04 10:59:40  peterg
## *** empty log message ***
##
## Revision 1.42  2000/11/10 14:19:50  peterg
## Corrected the csex and cseo functions
##
## Revision 1.41  2000/11/09 17:06:39  peterg
## Now does euler for cc
##
## Revision 1.40  2000/10/17 09:55:00  peterg
## Replaced switchopen by logic
##
## Revision 1.39  2000/10/14 08:04:40  peterg
## Changed arguments to _inout for consistency
##
## Revision 1.38  2000/10/11 09:08:08  peterg
## cse --> csex
##
## Revision 1.37  2000/08/01 12:25:06  peterg
## Now includes euler
##
## Revision 1.36  2000/05/19 17:48:16  peterg
## Argument to state
##
## Revision 1.35  2000/05/18 18:59:40  peterg
## Removed the First time stuff
##
## Revision 1.34  2000/05/16 18:56:14  peterg
## *** empty log message ***
##
## Revision 1.33  2000/05/11 19:33:18  peterg
## Uniform version for _sim.m
##
## Revision 1.32  2000/05/11 08:30:00  peterg

##
## Revision 1.31  2000/05/10 18:33:25  peterg
## Use smxa and smxax in place of smx
##
## Revision 1.30  2000/04/18 11:24:19  peterg
## Removed _numpar.
##
## Revision 1.29  2000/04/07 19:10:57  peterg
## *** empty log message ***
##
## Revision 1.28  1999/12/08 05:56:52  peterg
## Reordered the writing of the input and output.
## Note that last value now discarded.
##
## Revision 1.27  1999/11/15 22:47:53  peterg
## Generates method-specific code.
##
## Revision 1.26  1999/10/20 01:31:43  peterg
## *** empty log message ***
##
## Revision 1.25  1999/08/29 06:55:26  peterg
## Removed [MTTu]  = zero_input($Nu);	# Zero the input
## to avoide the p2c bug ????
##
## Revision 1.24  1999/08/27 06:02:16  peterg
## removed zero_input to avoid p2c bug
##
## Revision 1.23  1999/08/02 13:39:19  peterg
## Replaced zero_vector by zero_input
##
## Revision 1.22  1999/04/20 06:16:07  peterg
## Removed initialisation of AA and AAx
## Remove _switch calls -- uses _switchopen exclusively
##
## Revision 1.21  1999/04/02 06:29:25  peterg
## New implicit method - solves numerical prob with ISW
##
## Revision 1.20  1999/04/02 02:13:58  peterg
## Back to RCS
##
## Revision 1.19  1999/03/30 21:39:25  peterg
## In implicit approach, set derivatives to zero (when switch is off)
## before update. This seems to stop numerical leakage though non-return
## switches.
##
## Revision 1.18  1999/03/15 01:17:07  peterg
## Removed some spurious debugging code
##
## Revision 1.17  1999/03/15 01:09:15  peterg
## Fixed bugs when Nx=0 (no state)
##
## Revision 1.16  1999/03/06 02:28:38  peterg
## Rearranged evaluation to: state - input - output - write
##
## Revision 1.15  1999/03/06 02:19:43  peterg
## Changed args to _input
##
## Revision 1.14  1998/10/01 16:02:01  peterg
## Integration with switches handled separately fro Euler and Implicit.
##
## Revision 1.13  1998/09/30 17:41:24  peterg
## Implicit method now allows for switches via _switchA
##
## Revision 1.12  1998/08/27 08:55:18  peterg
## Mods to integration methods
##
## Revision 1.11  1998/08/25 12:28:31  peterg
## Move initila switch to after initial input
##
## Revision 1.10  1998/08/25 12:22:45  peterg
## Put _switch after update and also at initilisation
##
## Revision 1.9  1998/08/15 13:46:59  peterg
## New versions of integration routines
##
## Revision 1.8  1998/08/11 13:28:03  peterg
## Lowercase mttLAST etc
##
## Revision 1.7  1998/07/30 11:29:54  peterg
## Added implicit integration stuff
##
## Revision 1.6  1998/07/30 10:44:37  peterg
## INcluded othe integration methods.
##
## Revision 1.5  1998/07/26 11:02:20  peterg
## Put mtt or MTT  in front of variable names to avoid clashes with
## globals
##
## Revision 1.4  1998/07/25 20:14:00  peterg
## update code added for flexibility and octave efficiency
##
###############################################################


# Bourne shell script: make_ode2odes

# Copyright (c) P.J.Gawthrop July 1998.

# Tell user
sys=$1
lang=$2
filename=${sys}_ode2odes.${lang}

if [ -n "$3" ]; then
  method=$3    
else
  method=implicit  
fi

if [ -n "$4" ]; then
    algebraic_solver=$4
else
  algebraic_solver="noAlgebraicSolver"
fi

if [ -n "$5" ]; then
    sorted_equations=$5
else
    sorted_equations="no"
fi

insertor=\<\<			# help emacs sh-mode handle C++ lines

echo Creating $filename with $method integration method

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Outputs  

case "$method" in
    "implicit")
	ae=ae
	ode=csex
	odeo=cseo
	algorithm="mtt_implicit(x,dx,AA,AAx,ddt,$Nx,open_switches)"
	;;
    "dassl")
	case "$sorted_equations" in
	    "make")		# used by sese generated by make
		ae=sae
		ode=sesx
		odeo=sesy
		;;
	    "seqn")		# shouldn't be here unless mtt has changed
		ae=ae
		ode=sese
		odeo=sese
		;;
	    "no" | *)	
		ae=ae
		ode=ode
		odeo=odeo
		;;
	esac
	algorithm="mtt_dassl(x,u,t,par,dx,ddt,MTTNX,MTTNYZ,open_switches)"
	;;
    "sorted_euler")		# used by sese generated from seqn
	algorithm="mtt_euler(x,dx,ddt,$Nx,open_switches)"
	;;
    "euler" | "rk4" | *)
	case "$sorted_equations" in
	    "make")		# used by sese generated by make
		ae=sae
		ode=sesx
		odeo=sesy
		;;
	    "seqn")		# shouldn't be here unless mtt has changed
		ae=ae
		ode=sese
		odeo=sese
		;;
	    "no" | *)	
		ae=ae
		ode=ode
		odeo=odeo
		;;
	esac
	algorithm="mtt_euler(x,dx,ddt,$Nx,open_switches)"
	;;
esac

make_m()
{
#lang_header  $1 ode2odes m  'x,par,simpar' '[Y,X,t]' > $filename
mtt_header ${sys} ode2odes m > $filename
cat <<EOF >> $filename 
global MTT_data

  if nargin<3
    simpar = ${sys}_simpar(); 
    [simpar.dt] = mtt_simpar_update;
  endif
  if nargin<2
    par = ${sys}_numpar(); 
    [par] = mtt_numpar_update(par);
  endif
  if nargin<1
    [x0]  =  ${sys}_state(par); 
    [x0] = mtt_state_update(x);
  endif

  ## Initialise
  t = 0.0;
  ddt = simpar.dt/simpar.stepfactor;
  ilast = round(simpar.last/ddt)+1; # Total number of steps
  x = x0;

## Following removed due to p2c bug
##  [u]  = zero_input($Nu);		# Zero the input
  for MTTi=1:$Ny
    y(MTTi) = 0;
  endfor;

  mttj = 0;
    for it = 1:ilast		#Integration loop
EOF

cat <<EOF >> $filename
    if mttj==0
      [u] = ${sys}_input(x,y,t,par);	# Input
EOF

if [ "$method" = "sorted_euler" ]; then
cat <<EOF >> $filename
      [dx,y] = ${sys}_sese(x,u,t,par); # Output
EOF
else
cat <<EOF >> $filename
      [y] = ${sys}_$odeo(x,u,t,par);  # Output 
EOF
fi

cat <<EOF >> $filename
      mtt_write(t,x,y,$Nx,$Ny,simpar.first);   # Write it out
    endif
EOF

if [ "$method" = "rk4" ]; then
cat << EOF >> $filename
    [k1] = ddt * ${sys}_${ode}(x,u,t,par);
    [k2] = ddt * ${sys}_${ode}(x+k1/2,u,t+ddt/2,par);
    [k3] = ddt * ${sys}_${ode}(x+k2/2,u,t+ddt/2,par);
    [k4] = ddt * ${sys}_${ode}(x+k3,u,t+ddt,par);
    [dx] = [k1 + 2.0 * [k2 + k3] + k4] / (6.0 * ddt);
EOF
elif [ "$method" = "sorted_euler" ]; then
cat <<EOF >> $filename
    [dx,y] = ${sys}_sese(x,u,t,par); # State derivative and Output
EOF
else
cat << EOF >> $filename
    [dx] = ${sys}_$ode(x,u,t,par);	# State derivative
EOF
fi

if [ "$method" = "implicit" ]; then
cat<< EOF >> $filename

    [AA] = ${sys}_smxa(x,u,ddt,par);	# (I-Adt) and (I-Adt)x
    [AAx] = ${sys}_smxax(x,u,ddt,par); # (I-Adt) and (I-Adt)x

EOF
fi

cat <<EOF >> $filename
    [open_switches] = ${sys}_logic(x,u,t,par); # Switch logic
    [x] = $algorithm; # Integration update
    [open_switches] = ${sys}_logic(x,u,t,par); # Switch logic
    [x] = mtt_zeroswitches(x,$Nx,open_switches);
    t = t + ddt;   # Time update
    mttj = mttj+1;    # Increment counter
    if mttj==simpar.stepfactor
       mttj = 0;      # Reset counter
    endif

  endfor;			# Integration loop

## Create the output data
    mtt_data = MTT_data;
endfunction

EOF
} # make_m

make_cc() 
{
# get octave version
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	feval_header=toplev.h
	;;
    1) # development
	vector_value=column_vector_value
	feval_header=parse.h
	;;
    *)
	vector_value=column_vector_value
	feval_header=parse.h
	;;
esac

cat <<EOF  > $filename

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#define MATLABMEX  2
#define RTXI       3
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#include <octave/oct.h>
#include <octave/lo-mappers.h>
#include <octave/variables.h>

#if (CODEGENTARGET == OCTAVEDLD)
#include <octave/${feval_header}>
#endif // (CODEGENTARGET == OCTAVEDLD)

#include "${sys}_def.h"
#include "${sys}_sympar.h"

#include "mtt_${algebraic_solver}.hh"

#include <fstream>
#if (CODEGENTARGET != OCTAVEDLD)

extern ColumnVector ${sys}_${ae} (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_input (
	const ColumnVector &x,
	const ColumnVector &y,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_logic (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_numpar (
	void);

extern ColumnVector ${sys}_simpar (
     	void);

extern ColumnVector ${sys}_state (
	const ColumnVector &par);

extern ColumnVector ${sys}_${ode} (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_${odeo} (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

EOF
case "$method" in
    "implicit")
	cat <<EOF >> $filename
extern ColumnVector Fmtt_implicit (
	ColumnVector &x,
	ColumnVector &dx,
	Matrix &AA,
	ColumnVector &AAx,
	const double &ddt,
	const int &nx,
	const ColumnVector &open_switches);

extern Matrix ${sys}_smxa (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_smxax (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);
 
EOF
    ;;
    "dassl")
	cat <<EOF >> $filename
extern ColumnVector Fmtt_dassl (
	ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par,
	const ColumnVector &dx,
	const double &ddt,
	const int nx,
	const int nyz,
	const ColumnVector &open_switches);

EOF
    ;;
    "euler" | "rk4" | *)
	cat <<EOF >> $filename
extern ColumnVector Fmtt_euler (
	ColumnVector &x,
	const ColumnVector &dx,
	const double &ddt,
	const int &nx,
	const ColumnVector &open_switches);
 
EOF
    ;;
esac
cat <<EOF >> $filename

#endif // (CODEGENTARGET != OCTAVEDLD)

ColumnVector
mtt_ae (const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
    return ${sys}_${ae}(x,u,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    static octave_value_list args, f;
    args (0) = octave_value (x);
    args (1) = octave_value (u);
    args (2) = octave_value (t);
    args (3) = octave_value (par);
    f = feval ("${sys}_${ae}", args, 1);
    return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_input (const ColumnVector &x,
	   const ColumnVector &y,
	   const double &t,
	   const ColumnVector &par)
{
  static MTT::${algebraic_solver} ae(MTTNPAR,MTTNU,MTTNX,MTTNY,MTTNYZ);
  static ColumnVector u  (MTTNU);

#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  u = ${sys}_input (x, y, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (y);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_input", args, 1);
  u = f(0).${vector_value} ();
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  if (MTTNYZ == 0)
    {
      return u;
    }
  else
    {
      return ae.solve(x,u,t,par);
    }
}

inline ColumnVector
mtt_logic (const ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_logic (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_logic", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_numpar (void)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_numpar ();
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  f = feval ("${sys}_numpar", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_simpar (void)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_simpar ();
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  f = feval ("${sys}_simpar", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_state (const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_state (par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (par);
  f = feval ("${sys}_state", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_rate (const ColumnVector &x,
	  const ColumnVector &u,
	  const double &t,
	  const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_${ode} (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_${ode}", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_output (const ColumnVector &x,
	    const ColumnVector &u,
	    const double &t,
	    const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_${odeo} (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_${odeo}", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_zeroswitches (ColumnVector &x,
		  const int Nx,
		  const ColumnVector &openx)
{
  for (register int i = 0; i < Nx; i++) {
    if (0 != openx (i)) {
      x(i) = 0.0;
    }
  }
  return x;
}
  

EOF
case "$method" in
    "implicit")
	cat <<EOF >> $filename
inline ColumnVector
mtt_implicit (ColumnVector &x,
	      ColumnVector &dx,
	      Matrix &AA,
	      ColumnVector &AAx,
	      const double &ddt,
	      const int &nx,
	      const ColumnVector &open_switches)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return Fmtt_implicit (x, dx, AA, AAx, ddt, nx, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (AA);
  args (3) = octave_value (AAx);
  args (4) = octave_value (ddt);
  args (5) = octave_value ((double)nx);
  args (6) = octave_value (open_switches);
  f = feval ("mtt_implicit", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline Matrix
mtt_smxa (const ColumnVector &x,
	  const ColumnVector &u,
	  const double &t,
	  const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_smxa (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_smxa", args, 1);
  return f(0).matrix_value ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_smxax (const ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_smxax (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_smxax", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

EOF
    ;;
    "dassl")
cat <<EOF >> $filename
inline ColumnVector
mtt_dassl (ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   const ColumnVector &par,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const int &nyz,
	   const ColumnVector &open_switches)
{
#if (CODEGENTARGET != OCTAVEDLD)
   return Fmtt_dassl (x, u, t, par, dx, ddt, nx, nyz, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
   static octave_value_list args, f;
    args (0) = octave_value (x);
    args (1) = octave_value (u);
    args (2) = octave_value (t);
    args (3) = octave_value (par);
    args (4) = octave_value (dx);
    args (5) = octave_value (ddt);
    args (6) = octave_value (static_cast<double> (nx));
    args (7) = octave_value (static_cast<double> (nyz));
    args (8) = octave_value (open_switches);
    f = feval ("mtt_dassl", args, 1);
    return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

#if (CODEGENTARGET != OCTAVEDLD)
ColumnVector
Fmtt_residual (const ColumnVector &X,
	      const ColumnVector &DX,
	      double t,
	      int &ires)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_residual, args, , "mtt_residual")
{
    static ColumnVector	X  (MTTNX+MTTNYZ);
    static ColumnVector	DX (MTTNX+MTTNYZ);
    static double      	t;
    static int		ires;

    X  = args(0).${vector_value} ();
    DX = args(1).${vector_value} ();
    t  = args(2).double_value ();
    ires = static_cast<int>(args(3).double_value ());
#endif // (CODEGENTARGET != OCTAVEDLD)

    static ColumnVector residual (MTTNX+MTTNYZ);
    static ColumnVector U (MTTNU+MTTNYZ);
    static ColumnVector u (MTTNU);
    static ColumnVector y (MTTNY,0.0);
    static ColumnVector par (MTTNPAR);
    static ColumnVector dx(MTTNX);
    static ColumnVector yz(MTTNYZ);

    static ColumnVector x (MTTNX);
    static ColumnVector ui (MTTNYZ);

    static octave_value_list new_args;

    x = X.extract (0,MTTNX-1);
    if (MTTNYZ > 0)
      ui = X.extract (MTTNX,MTTNX+MTTNYZ-1);    

#if (CODEGENTARGET != OCTAVEDLD)
    par = ${sys}_numpar();
    u = ${sys}_input(x,y,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    par = feval ("${sys}_numpar",  new_args, 1)(0).${vector_value} ();
    new_args(0) = octave_value (x);
    new_args(1) = octave_value (u);
    new_args(2) = octave_value (t);
    new_args(3) = octave_value (par);
    u = feval ("${sys}_input", new_args, 1)(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)

    U.insert (u,0);
    if (MTTNYZ > 0)
      U.insert (ui,MTTNU);

#if (CODEGENTARGET != OCTAVEDLD)
    dx = ${sys}_${ode} (x,U,t,par);
    yz = ${sys}_${ae} (x,U,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    new_args(1) = octave_value (U);
    dx = feval ("${sys}_${ode}", new_args, 1)(0).${vector_value} ();
    yz = feval ("${sys}_${ae}", new_args, 1)(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)

    for (register int i = 0; i < MTTNX; i++)
      residual (i) = dx(i) - DX(i);
    
    if (MTTNYZ > 0)
      {
	residual.insert (yz,MTTNX);

	// XXX:
	// DASSL needs residual to be dependent on Ui and Uidot
	// mtt_dassl always sets the initial Ui to zero, so
	// Ui - h*Uidot should equal zero BUT, we don't know h
	static double t_old;
	double step;
	if (t != t_old)
	  {
	    step = t - t_old;
	    t = t_old;
	  }
	else
	  step = t;	
	for (register int i = MTTNX; i < MTTNX+MTTNYZ; i++)
	  residual(i) += X(i) - DX(i)*step;
      }

#if (CODEGENTARGET != OCTAVEDLD)
    return residual;
#elif (CODEGENTARGET == OCTAVEDLD)
    return octave_value (residual);
#endif // (CODEGENTARGET != OCTAVEDLD)
}
    
EOF
    ;;
    "euler" | "rk4" | *)
cat <<EOF >> $filename
inline ColumnVector
mtt_euler (ColumnVector &x,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const ColumnVector &open_switches)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return Fmtt_euler (x, dx, ddt, nx, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (ddt);
  args (3) = octave_value ((double)nx);
  args (4) = octave_value (open_switches);
  f = feval ("mtt_euler", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

EOF
    ;;
esac
cat <<EOF >> $filename

inline void
mtt_write (const double &t,
	   const ColumnVector &x,
	   const ColumnVector &y,
           const double &first,
	   const int &nrows,
	   const bool dump_data = false,
	   std::ostream &file = std::cout)
{
  static Matrix data;
  static int row;

  if (dump_data)
    {
       if (row > 0)
         {
           Matrix written_data = data.extract (0, 0, row-1, data.cols ()-1);
	   file $insertor "# name: mtt_dump" $insertor std::endl
		$insertor "# type: matrix" $insertor std::endl
		$insertor "# rows: " $insertor written_data.rows () $insertor std::endl
		$insertor "# columns: " $insertor written_data.columns () $insertor std::endl
		$insertor written_data;
	   file.flush ();
	 }
       return;
    }

  const int nx = x.length (), ny = y.length ();
  register int col = 0;

  if (0 == row)
    data = Matrix (nrows, 1+ny+1+nx, 0.0);

  if (t >= first) {
  data.elem (row, col) = t;
  for (register int i = 0; i < ny; i++)
    data.elem (row, ++col) = y.elem (i);
  data.elem (row, ++col) = t;
  for (register int i = 0; i < nx; i++)
    data.elem (row, ++col) = x.elem (i);

  row++;
  };

  static std::fstream fcputime ("MTT.cputime", std::ios::out | std::ios::trunc | std::ios::app);
  static clock_t cputime0 = clock();
  static clock_t cputime1 = cputime0;
  clock_t cputime = clock();
  fcputime $insertor t $insertor '\t'
	   $insertor static_cast <double> (cputime - cputime0) / CLOCKS_PER_SEC $insertor '\t'
	   $insertor static_cast <double> (cputime - cputime1) / CLOCKS_PER_SEC $insertor std::endl;
  cputime1 = cputime;

  if (nrows == row)
    {
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == RTXI))
      file $insertor "# name: mtt_dump" $insertor std::endl
	   $insertor "# type: matrix" $insertor std::endl
	   $insertor "# rows: " $insertor data.rows () $insertor std::endl
	   $insertor "# columns: " $insertor data.columns () $insertor std::endl
	   $insertor data;
      file.flush ();
#elif ((CODEGENTARGET == OCTAVEDLD) || (CODEGENTARGET == MATLABMEX))
  set_global_value ("MTT_data", data);
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == RTXI))
    row = 0;
    fcputime.close();
    }
}

#if (CODEGENTARGET == RTXI)
#include "${sys}_rtxi.h"
void
${sys}::execute(void)
{
  static ColumnVector simpar (8), par (MTTNPAR), state0 (MTTNX);

  simpar	= mtt_simpar ();
  par		= mtt_numpar ();
  state0	= mtt_state (par);
  
#else

void
${sys}_ode2odes (const ColumnVector &state0,
		 const ColumnVector &par,
		 const ColumnVector &simpar)
{
#endif // (CODEGENTARGET == RTXI)
  static double first, dt, last, stepfactor;
  first		= simpar (0);
  last		= simpar (1);
  dt		= simpar (2);
  stepfactor	= simpar (3);

  static ColumnVector	dx (MTTNX, 0.0);
  static ColumnVector	x (MTTNX, 0.0);
  static ColumnVector	u (MTTNU, 0.0);
  static ColumnVector	y (MTTNY, 0.0);

  static Matrix	AA (MTTNX, MTTNX, 0.0);
  static ColumnVector	AAx (MTTNX, 0.0);
  
  static ColumnVector	open_switches (MTTNX, 0.0);

  register double t	= 0.0;

  const double	ddt	= dt / stepfactor;
  const int	ilast	= static_cast<int> (round ( last  / ddt)) + 1;
  const int	nrows	= static_cast<int> (round ((last - first) / dt)) + 1;

  for (register int i = 0; i < MTTNY; i++)
    {
      y (i) = 0.0;
#if (CODEGENTARGET == RTXI)
      output(i) = y(i);
#endif // (CODEGENTARGET == RTXI)
    }

  for (register int i = 0; i < MTTNX; i++)
    {
      x (i) = state0 (i);
    }

  for (register int j = 0, i = 1; i <= ilast; i++)
    {
#if (CODEGENTARGET != RTXI)
      u	= mtt_input (x, y, t, par);
#else
      for (register int i = 0; i < MTTNU; i++) {
	u(i) = input(i);
      }
#endif // (CODEGENTARGET != RTXI)
      y	= mtt_output (x, u, t, par);
      if (0 == j)
	{
#if (CODEGENTARGET != RTXI)
	  mtt_write (t, x, y, first, nrows);
#else
	  for (register int i = 0; i < MTTNU; i++) {
	    output(i) = y(i);
	  }
#endif // (CODEGENTARGET != RTXI)
	}
EOF
case "$method" in
    "rk4")
	cat << EOF >> $filename
      {
        static ColumnVector
          k1 (MTTNX,0.0),
          k2 (MTTNX,0.0),
          k3 (MTTNX,0.0),
          k4 (MTTNX,0.0);

        const double
          t1 = t + ddt/2.0,
          t2 = t + ddt;

        ColumnVector
          x1 (x),
          x2 (x),
          x3 (x);

        k1 = ddt * mtt_rate (x , u, t , par); x1 += k1 * 0.5;
        k2 = ddt * mtt_rate (x1, u, t1, par); x2 += k2 * 0.5;
        k3 = ddt * mtt_rate (x2, u, t1, par); x3 += k3;
        k4 = ddt * mtt_rate (x3, u, t2, par);
        dx = (k1 + 2.0 * (k2 + k3) + k4) / (6.0 * ddt);
      }
EOF
    ;;
    "dassl")
    ;;
    "implicit")
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, par);
      AA = mtt_smxa (x, u, ddt, par);
      AAx = mtt_smxax (x, u, ddt, par);
EOF
    ;;
    "euler" | *)
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, par);
EOF
    ;;
esac

## Common stuff
cat <<EOF >> $filename
      open_switches = mtt_logic (x, u, t, par);
      x =  $algorithm; 
      open_switches = mtt_logic (x, u, t, par);
      x = mtt_zeroswitches (x, $Nx, open_switches);
      t += ddt;
      j++;
      j = (j == static_cast<int> (stepfactor)) ? 0 : j;
    }

}

#if (CODEGENTARGET == STANDALONE)
#include <csignal>

void set_signal_handlers (void);

void dump_data (std::ostream &file)
{
  ColumnVector null (0);
  mtt_write (0.0, null, null, 0, 0, true, file);
}

void handle_signal (int signum)
{
  // handle some signals to ensure data is written.
  std::cerr $insertor "# Writing data to MTT.core (signal " $insertor signum $insertor ")" $insertor std::endl;
  std::ofstream corefile ("MTT.core");
  dump_data (corefile);
  switch (signum)
    {
      case SIGFPE:
        // Intel chips do not raise SIGFPE for DIVZERO :-(
	// raise (SIGABRT);
        break;
      case SIGINT:
	break;
      case SIGQUIT:
	signal (SIGQUIT, SIG_DFL);
	raise (SIGQUIT);
	break;
      default:
        std::cerr $insertor "# Warning: make_ode2odes needs updating!" $insertor std::endl;
	signal (signum, SIG_DFL);
	raise (signum);
        break;
    }
  corefile.close ();
  set_signal_handlers ();
}

void set_signal_handlers (void)
{
  signal (SIGFPE,	handle_signal);
  signal (SIGINT,	handle_signal);
  signal (SIGQUIT,	handle_signal);
}

int
main (void)
{
  set_signal_handlers ();

  static ColumnVector simpar (8), numpar (MTTNPAR), state0 (MTTNX);

  simpar	= mtt_simpar ();
  numpar	= mtt_numpar ();
  state0	= mtt_state (numpar);

  ${sys}_ode2odes (state0, numpar, simpar);

  return 0;
}
#elif (CODEGENTARGET == OCTAVEDLD)
#include <mtt_simpar.hh>

DEFUN_DLD (${sys}_ode2odes, args, ,
"Octave ode2odes representation of system with $method integration method\nUsage: mtt_data = ${sys}_ode2odes (state0, numpar, simpar)\n")
{
  static octave_value_list retval;

  static ColumnVector	state0 (MTTNX);
  static ColumnVector	numpar (MTTNPAR);
  static ColumnVector	simpar (8);
  
  int nargin = args.length ();
  switch (nargin)
    {
    case 3:
      simpar	= mtt_simpar (args(2).map_value ());
      numpar	= args(1).${vector_value} ();
      state0	= args(0).${vector_value} ();
      break;
    case 2:
      simpar	= mtt_simpar ();
      numpar	= args(1).${vector_value} ();
      state0	= args(0).${vector_value} ();
      break;
    case 1:
      simpar	= mtt_simpar ();
      numpar	= mtt_numpar ();
      state0	= args(0).${vector_value} ();
      break;
    case 0:
      simpar	= mtt_simpar ();
      numpar	= mtt_numpar ();
      state0	= mtt_state (numpar);
      break;
    default:
      usage("${sys}_ode2odes (x par simpar)", nargin);
      error("aborting.");
    }

  ${sys}_ode2odes (state0, numpar, simpar);
    
  retval = octave_value (get_global_value ("MTT_data"));
  return (retval);
}
#elif (CODEGENTARGET == MATLABMEX)
#include <mtt_matlab_octave.hh>

extern "C" {
  void
  mexFunction (int nlhs, mxArray *plhs[],
	       int nrhs, const mxArray *prhs[])
  {
    static ColumnVector	state0 (MTTNX);
    static ColumnVector	numpar (MTTNPAR);
    static ColumnVector	simpar (8);

    initialize_symbol_tables ();
    
    switch (nrhs)
      {
      case 3:
	simpar	= mtt_ColumnVector (prhs[2]);
	numpar	= mtt_ColumnVector (prhs[1]);
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 2:
	simpar	= mtt_simpar ();
	numpar	= mtt_ColumnVector (prhs[1]);
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 1:
	simpar	= mtt_simpar ();
	numpar	= mtt_numpar ();
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 0:
	simpar	= mtt_simpar ();
	numpar	= mtt_numpar ();
	state0	= mtt_state (numpar);
	break;
      default:
	std::cerr $insertor "usage: ${sys}_ode2odes (x par simpar)" $insertor std::endl;
	return;
      }

    ${sys}_ode2odes (state0, numpar, simpar);

    plhs[0] = mtt_mxArray (get_global_value ("MTT_data").matrix_value ());
  }
}

#endif // (CODEGENTARGET == STANDALONE)

EOF
}

case ${lang} in
    m)
        make_m	
	;;
    cc)
	make_cc
	;;
    *)
	echo Language ${lang} is not supported
esac

Added mtt/bin/trans/make_sim version [266de8bd1f].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Makes the sensitivity simulation
## Copyright (C) 2001 by Peter J. Gawthrop

sys=$1
lang=$2

outfile=${sys}_sim.${lang}

echo Creating $outfile

make_m() {
mtt_header ${sys} sim m  >  ${outfile}
cat >> ${outfile} <<EOF

 ## Pass input as a global
 global MTT_input MTT_input_index MTT_input_last

  [nx,ny] = ${sys}_def;
  y_par = [];
  MTT_input = u;
  [MTT_input_last,m] = size(u);

  MTT_input_index = 0;
  [mtt_data] = ${sys}_ode2odes(x0,par,simpar);
  y = mtt_data(:,2:1+ny);
  x = mtt_data(:,3+ny:2+ny+nx);
  ypar = [];

  if nargout>2
    ## Create time vector
    [N,M] = size(y);
    t = mtt_data(:,1);
  endif;

endfunction
EOF

}

case ${lang} in
    m)
	make_m
	;;
    *)
	echo Language ${lang} not supported - sorry
esac

Added mtt/bin/trans/make_ssim version [c5f9aeda27].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Makes the sensitivity simulation
## Copyright (C) 2001 by Peter J. Gawthrop

sys=$1
lang=$2

outfile=${sys}_ssim.${lang}

echo Creating $outfile
make_m() {
mtt_header ${sys} ssim m >  ${outfile}
cat >> ${outfile} <<EOF

  ## Pass input as a global
  global MTT_input MTT_input_index MTT_input_last

  if nargin>4  
    [n,m] = size(index);
    if (n>m)       # Make sure its a row vector
      index = index';
    endif
  endif

  [nx2,ny2] = ${sys}_def;
  y_par = [];
  MTT_input = u;
  [MTT_input_last,m] = size(u);

  if nargin<5			# No index given
    MTT_input_index = 0;
    [mtt_data] = ${sys}_ode2odes(x0,par,simpar);
    y = mtt_data(:,2:2:1+ny2);
    x = mtt_data(:,3+ny2:2:2+ny2+nx2);
    ypar = [];
  else				# Compute sensitivities as well
    for i=index
      MTT_input_index = 0;
      p = par;           # Reset parameters
      p(i) = 1;          # Set sensitivity index to 1
      [mtt_data] = ${sys}_ode2odes(x0,p,simpar);
      if (i==index(1))
	y = mtt_data(:,2:2:1+ny2);
      endif
      y_par = [y_par, mtt_data(:,3:2:2+ny2)];
      x = mtt_data(:,3+ny2:2+ny2+nx2);
    endfor
  endif

  if nargout>3
    ## Create time vector
    [N,M] = size(y);
        t = mtt_data(:,1);
  endif;

endfunction
EOF

}

case ${lang} in
    m)
	make_m
	;;
    *)
	echo Language ${lang} not supported - sorry
esac

Added mtt/bin/trans/make_stdin version [912a3db110].















































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

## 	$Id$	

# Copyright (C) 1999,2000 by Peter J. Gawthrop

# Tell user
Sys=$1
lang=$2
date=`date`
outfile=$1_input.$2

Nu=`mtt_getsize ${Sys} u` # Inputs 
echo  "Creating $outfile for standard input"

## Pascal code
make_p()
{
cat <<EOF > $outfile
PROCEDURE ${Sys}_input(VAR mttu : InputVector;
                       mttx : StateVector;
                       mtty : OutputVector;
                       mttt : REAL;
                       par  : ParameterVector);

{Created by MTT on $date for standard input to simulation}

VAR t : REAL; Start:BOOLEAN;

BEGIN{${Sys}_input}
  {Zap comments}
  IF (input^ = chr("#")) THEN
  BEGIN
    readln;
    WHILE (input^ = chr("#")) DO readln;
  END;

  read(t); { Read, and discard, first column (time) }
  FOR mtti:=1 TO $Nu DO {Read the inputs}
    read(mttu[mtti]);
  readln; {Next line}


END{${Sys}_input};
EOF
}

make_m() {
mtt_header ${Sys} input m stdin > $outfile
cat >> $outfile <<EOF
## The "standard input"
global MTT_input MTT_input_index MTT_input_last
  
  MTT_input_index = min(++MTT_input_index,MTT_input_last);
  mttu = MTT_input(MTT_input_index,:);
## END Code
endfunction
EOF

}


make_cc() {
cat > $outfile <<EOF
// -*-c++-*- Put emacs into c++-mode

// 
// System ${Sys}, representation input, language oct; 
// File ${Sys}_input.oct; 
// Generated by MTT on `date`; 

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
#include <octave/oct.h>
#include "${Sys}_def.h"

void strip_comments (istream &str)
{
  char c;
  c = str.peek ();
  while (c == '#')
    {
      str.unsetf(ios::skipws);
      while (c != '\n')
	{
	  str >> c;
	}
      str.setf(ios::skipws);
      c = str.peek ();
    }
}

ColumnVector ${Sys}_input (
	ColumnVector	&mttx,
	ColumnVector	&mtty,
	const double	&mttt,
	ColumnVector	&mttpar
)
{
#elif (CODEGENTARGET == OCTAVEDLD)
#include <octave/oct.h>
#include <variables.h>
#include "${Sys}_def.h"

DEFUN_DLD (${Sys}_input, args, ,
"Usage: [mttu] = ${Sys}_input()\n\
Octave input (-stdin) representation of system ${Sys}\n\
Generated by MTT on `date`")
{

  octave_value_list retval;
#endif // (CODEGENTARGET == STANDALONE)

  ColumnVector	mttu	(MTTNU);

  // Set up the mttu vector
#if (CODEGENTARGET == OCTAVEDLD)
  int MTT_input_index	= static_cast<int>(get_global_value ("MTT_input_index").double_value ());
  int MTT_input_last	= static_cast<int>(get_global_value ("MTT_input_last").double_value ());
  Matrix MTT_input 	= get_global_value ("MTT_input").matrix_value();

  mttu = MTT_input.row (MTT_input_index);

  if (MTT_input_index < (MTT_input_last - 1))
    {
      set_global_value ("MTT_input_index", static_cast<double>(++MTT_input_index));
    }
  
#elif (CODEGENTARGET == STANDALONE)
  double t, u;
  strip_comments (cin);
  cin >> t;
  for (register int i = 0; i < MTTNU; i++)
    {      
      cin >> u;
      mttu(i) = u;
    }
#endif // (CODEGENTARGET == OCTAVEDLD)


#if (CODEGENTARGET == OCTAVEDLD)
  retval (0)	= octave_value (mttu);
  return (retval);
}
#elif (CODEGENTARGET == STANDALONE)
  return mttu;
}
#endif // (CODEGENTARGET == OCTAVEDLD)
EOF
}

case $lang in
    p)
	make_p 
	;;
    m)
	make_m
	;;
    cc)
	make_cc
	;;
    *)
	echo language $lang not supported - sorry
esac

Added mtt/bin/trans/makecr version [b85c8207c2].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makecr

# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1996/09/12 12:06:38  peter
## Removed reducndant lines.
##
## Revision 1.3  1996/09/12 12:05:01  peter
## Removed default crs.
##
## Revision 1.2  1996/09/10 16:18:37  peter
## Uses default constitutive relationship mtt/cr/r
##
## Revision 1.1  1996/08/24 14:53:06  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_cr.r

echo % Default CR file			>  $1_cr.r
echo % File $1_cr.r			>> $1_cr.r
echo % Generated by MTT on `date`.	>> $1_cr.r
echo					>> $1_cr.r
cat $MTTPATH/trans/m/rcs_header.txt	>> $1_cr.r
echo 'END;'				>> $1_cr.r








Added mtt/bin/trans/makedesc version [3172bb98c8].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: maketex
# Makes template for (TeX) system description.

# P.J.Gawthrop August 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1999/03/03 01:07:27  peterg
## Label the figure correctely,
##
## Revision 1.3  1998/07/22 08:58:51  peterg
## Corrected spelling.
##
## Revision 1.2  1997/05/21 10:00:51  peterg
## Tidied up.
##
## Revision 1.1  1997/05/21 09:19:27  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_desc.tex

echo '% -*-latex-*- Put EMACS into LaTeX-mode' > $1_desc.tex
echo "% Verbal description for system $1 ($1_desc.tex)" >> $1_desc.tex
echo "% Generated by MTT on" `date`. >> $1_desc.tex                  	   
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_desc.tex

cat<<EOF >> $1_desc.tex
The acausal bond graph of system \textbf{$1} is
displayed in Figure \Ref{fig:$1_abg.ps}  
EOF

if [ -e "$1_pic.fig" ]; then
cat<<EOF >> $1_desc.tex
and the schematic diagram in Figure \Ref{fig:$1_pic.ps}
EOF
fi
   
cat<<EOF >> $1_desc.tex
.
The label file is listed in Section \Ref{sec:$1_lbl} and the
subsystems are listed in Section \Ref{sec:$1_sub}.
EOF

Added mtt/bin/trans/makedoc version [4df074a97b].
































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makedoc
# Encapsulates a tex file in a document.

# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/27 15:53:42  peterg
## Initial revision
##
## Revision 1.1  1997/05/17 13:55:42  peterg
## Initial revision
##
# Revision 1.2  1997/04/23  10:06:51  peterg
# Put output in the correct file!
#
# Revision 1.1  1997/04/23  10:03:41  peterg
# Initial revision
#
###############################################################

date=`date`
switches=$1
system=$2
representation=$3
lang=$4
args=$5
documenttype=$6
ps=$7

if [ "$documenttype" = "book" ]; then
  document=book
else
  document=article
fi

if [ "$documenttype" = "book" ]||[ "$documenttype" = "article" ]; then
    title="\title{Report on $system}"
else
    title="\title{System $system, representation $representation}"
fi

filename=$2_$3.doc
texname=$2_$3.tex
indexname=$2_$3.ind

# Inform user
echo "Creating $filename"
# Make arguments acceptable to LateX
Args=`echo $args | sed 's/_/\\\_/g'`

cat<<EOF  > $filename 
\nonstopmode
\documentclass[12pt,a4paper]{$document}
    $title
    \author{Generated by MTT using :\\\\
     (mtt $switches $system $representation $lang $Args)}
    \date{$date}
EOF

if [ "$documenttype" = "book" ]; then
  cat <<EOF   >> $filename 
  \makeindex
EOF
fi


##cp -v $MTTPATH/trans/*.sty .
##cat  >> $filename <<EOF
##\usepackage{mtt_$ps}
##EOF

## Explicitly include style files - avoids latex2html problem
cat $MTTPATH/trans/mtt.sty $MTTPATH/trans/mtt_$ps.sty >> $filename

cat <<EOF  >> $filename 
\begin{document}
  \maketitle
EOF

if [ "$documenttype" = "book" ]||[ "$documenttype" = "article" ]; then
  cat $MTTPATH/trans/contents.tex >> $filename
fi

cat <<EOF  >> $filename 
%Fancy headings
  \pagestyle{fancy}
  \renewcommand{\sectionmark}[1]{\markboth{#1}{}}
  \lhead{Report \textbf{$system}}
  \rhead{Representation \textbf{$representation}}
  \rfoot{Page \thepage.}\cfoot{}
  \lfoot{\emph{$date}}

  \input{$texname}
EOF

if [ "$documenttype" = "book" ]; then
  cat <<EOF   >> $filename 
  \input{$indexname}
EOF
fi

cat<<EOF  >> $filename 
\end{document}
EOF












Added mtt/bin/trans/makerep_txt version [62dfdf7ad4].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makerep_tex
# Makes template for (TeX) system description.

# P.J.Gawthrop July 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2000/11/15 10:56:45  peterg
## Added state tex
##
## Revision 1.5  2000/11/04 12:32:43  peterg
## Added more reps + more default reps
##
## Revision 1.4  1999/03/02 22:02:16  peterg
## Octave-mode style
##
## Revision 1.3  1998/11/18 10:47:39  peterg
## Added transfer function rep
##
## Revision 1.2  1998/11/10 09:16:41  peterg
## Added structure rep
##
## Revision 1.1  1998/07/22 09:14:42  peterg
## Initial revision
##
###############################################################


#Inform user
echo Creating $1_rep.txt

cat <<EOF > $1_rep.txt
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system $1 ($1_rep.txt)
## Generated by MTT on" `date`.

EOF

cat $MTTPATH/trans/rcs_header.sh >> $1_rep.txt

cat <<EOF >> $1_rep.txt
mtt $1 abg tex			# The system description
mtt $1 cbg ps 		        # The causal bond graph
mtt $1 struc tex	        # The system structure
mtt $1 sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt $1 dae tex	        # The system dae
## mtt $1 ode tex	        # The system ode 
## mtt $1 sspar tex		# Steady-state parameters
## mtt $1 ss tex 		# Steady state
## mtt $1 dm tex		# Descriptor matrices (of linearised system)
## mtt $1 sm tex		# State matrices (of linearised system)
## mtt $1 tf tex		# Transfer function (of linearised system)
## mtt $1 lmfr ps		# log modulus of frequency response (of linearised system)
## mtt $1 simpar txt		# Simulation parameters
## mtt $1 numpar txt		# Numerical simulation parameters
## mtt $1 state txt		# Simulation initial state
## mtt $1 input txt		# Simulation input
## mtt $1 logic txt		# Logic control
## mtt $1 odeso ps		# Simulation output

## mtt $1 rep txt		# This file
EOF

Added mtt/bin/trans/makesspar version [52aff62f6f].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makesspar
# Makes default sspar file: all states zero.

# P.J.Gawthrop February 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/02/09 14:13:39  peterg
## Put octave stuff to /dev/null
##
## Revision 1.2  1998/02/09 08:39:27  peterg
## Set inputs to zero as well.
##
## Revision 1.1  1998/02/06 15:53:49  peterg
## Initial revision
##
###############################################################


#Inform user
echo Creating $1_sspar.r

echo "% Steady-state parameters for system $1 ($1_sspar.r)"> $1_sspar.r
echo "% Generated by MTT on" `date`. >> $1_sspar.r                  	   
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_sspar.r
echo "% Set all states and inputs to zero" >> $1_sspar.r                  	   

$MATRIX  <<EOF >> /dev/null

fnum=fopen("$1_sspar.r","at");

[nx,ny,nu,nz,nyz] = $1_def;

for i = 1:nx
  fprintf(fnum,"MTTX%i := 0;\n", i);
end;
fprintf(fnum,"\n");
for i = 1:nu
  fprintf(fnum,"MTTU%i := 0;\n", i);
end;
   
  
EOF

 
echo "END;;" >> $1_sspar.r   

Added mtt/bin/trans/makesubs version [409b406455].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makesubs
# Makes the default substitution file

# Copyright (C) 2000 by Peter J. Gawthrop


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.1  2000/12/28 09:09:52  peterg
## Initial revision
##
##
###############################################################

#Inform user
echo Creating $1_subs.r

cat > $1_subs.r <<EOF
% Default SUBS file
% File $1_subs.r
% Generated by MTT on `date`.

EOF

cat $MTTPATH/trans/m/rcs_header.txt	>> $1_subs.r

cat >> $1_subs.r <<EOF
% Put algebraic substitution commands here
FOR ALL i LET arbint(i) = 0; % Zap arbitary constants
END;
EOF


exit

## NB the following messes up the expansion switch ????
cat >> $1_subs.r <<EOF
% Ordering switch
ORDER
EOF

# Symbolic params first
gawk '{
  print $1 ","
}' < $1_sympar.txt >> $1_subs.r

# Then states
Nx=`mtt_getsize $1 x` # States

gawk 'END{
  for (k=1;k<Nx;k++){
    printf("mttx%i,\n", k);
  }
    printf("mttx%i;\n", Nx);
  
}' Nx=$Nx < $1_sympar.txt >> $1_subs.r

cat >> $1_subs.r <<EOF
END;
EOF









Added mtt/bin/trans/matlab_header version [f6f0a00194].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: matlab_header
# Generic octave function header


#Write some file headers
echo "function [$3] = $1_$2" 
echo "% $2 function for system $1 ($1_$2.m)"   
echo "% Generated by MTT at `date`"  
echo  

#Globals
sympar2global_txt2m $1 
echo  ';'
echo  



Added mtt/bin/trans/matlab_matrix.r version [d9d59df9cf].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in matlab form
% P.J.Gawthrop  March 1998
% Copyright (c) P.J.Gawthrop, 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/03/22 10:26:47  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'FORTRAN;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 400;

PROCEDURE matlab_Matrix;
BEGIN
  ON NERO;
  write "mtt_matrix = zeros(", mtt_matrix_n, ",", mtt_matrix_m, ");";
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
    FOR i := 1:MTT_Matrix_n DO
      IF MTT_Matrix_m>1 THEN
        BEGIN
          FOR j := 1:MTT_Matrix_m DO 
            GENTRAN mtt_matrix(i,j) ::=: mtt_matrix(i,j);
        END
        ELSE
        BEGIN
         GENTRAN mtt_matrix(i) ::=: mtt_matrix(i,1);
        END;
    END;
  write MTT_matrix_name, " = mtt_matrix;";
END;

END;;


Added mtt/bin/trans/matlab_tidy version [3301711ae7].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.3  1997/08/28  13:41:57  peterg
# Removes translation of:
# mttx
# mttdx
# mtty
# mttu
#
# Revision 1.2  1996/08/20  08:26:06  peter
# Version control header added.
#
###############################################################

# Bourne shell script: matlab_tidy
# Tidies up Matlab format files
# P.J.Gawthrop 14 June 1990 13 Nov 1990, 19 Nov 93, April 1994, Dec 1994, 
# June 1995
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

#rm junk
#tr "[A-Z]" "[a-z]" | \

cat $1 | \
sed -e "s/      //" \
    -e "s/      //" \
    -e "s/\$\$//" \
    -e "s/\.\.;;/../" \
    -e "s/\$/;/g" \
    -e "s/;;;//g" \
    -e "s/;;/;/g" \
    -e "s/\.;/./g" \
    -e "s/,;/,/g" \
    -e "s/\*\*/^/g" \
    -e "s/nocr /nocr/g" \
    -e "s/nocr\\nl/nocr/g" \
    -e "s/;;/;/g" \
    -e "s/:=/=/g" \
    -e "s/ e  /e/g" \
    -e "s/*;/* .../g" \
    -e "s/+;/+ .../g" \
    -e "s/     . //g" \
    -e "s/^;$//g" \
    -e "s/\.\.\\$/../g"  \
    -e "s/\\$/;/g"  \
    -e "s/inv(mtte)\*/mtte\\\/g"\
    -e "s/\\$//" |\
tr -s '\012' '\012'\
>junk
mv junk $1




Added mtt/bin/trans/modpar_txt2r version [46d5afca36].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: modpar_txt2r
# Creates the reduce code for modulated parameters

# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$
## Revision 1.2  2002/04/16 11:36:03  gawthrop
## These were flagged with M on cvs update
##
## Revision 1.1  2001/04/02 08:19:18  gawthrop
## Translates modulated parameters into reduce
##
###############################################################

# Inform user
echo Creating $1_modpar.r

#Create the modpar file complete with headers.
echo "% Modpar file ($1_modpar.r)" > $1_modpar.r
echo "% Generated by MTT at `date`" >> $1_modpar.r

parameters=`strip_comments < $1_modpar.txt |  cut -f1`
inputs=`strip_comments < $1_modpar.txt |  cut -f2`


for parameter in $parameters; do
    grep $1_${parameter}_ $1_struc.txt |\
    gawk 'BEGIN{
               name["input"] = "u";
               name["output"] = "y";
               name["state"] = "x";
               name["nonstate"] = "z";
	      }
	 {
           printf("%s := mtt%s(%i,1);\n", parameter, name[$1],  $2)
         }' parameter=$parameter >> $1_modpar.r
done

Added mtt/bin/trans/mtt.sty version [bc0db184f2].




























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% mtt.sty -- LaTeX style file for MTT
% P.J.Gawthrop May 1997
% Copyright (c) P.J.Gawthrop, 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.11  2009/06/26 01:09:50  geraint
% %% fancyheadings is deprecated, replaced by fancyhdr
% %%
% %% Revision 1.10  2005/03/15 13:36:17  gawthrop
% %% Pretty abg figure in reports.
% %%
% %% Revision 1.9  2003/05/08 18:43:02  gawthrop
% %% Generate pdf from ps (using hyperref package for links etc)
% %%
% %% Revision 1.8  2000/12/01 14:15:16  peterg
% %% Removed hyperref stuff to mtt_pdf.sty
% %%
% %% Revision 1.7  2000/11/28 18:28:29  peterg
% %% Removed fancy box - messes up TOC
% %%
% %% Revision 1.6  2000/11/28 18:09:06  peterg
% %% Tidied up:
% %% added hyperef
% %% put fig stuff into mtt_ps.sty and mtt_pdf.sty
% %%
% %% Revision 1.5  1998/11/23 10:45:49  peterg
% %% Reinstated supertabular
% %%
% %% Revision 1.4  1998/07/01 17:34:43  peterg
% %% No change
% %%
% %% Revision 1.3  1997/12/06 16:22:10  peterg
% %% Added another argument - the label.
% %%
% %% Revision 1.2  1997/12/06 15:51:06  peterg
% %% Cahged order of fig args to put file first.
% %%
% %% Revision 1.1  1997/05/19 16:48:10  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Font
\usepackage{times}
%%\usepackage{mathptm}

%Verbatim file input
\usepackage{verbatim}
\usepackage{moreverb}

%Long tables
\usepackage{supertabular}

%AMS maths
  \usepackage{amsmath}

%Fancy headings
  %%\usepackage{fancyheadings}
  \usepackage{fancyhdr}

%Fancy boxes
%\usepackage{fancybox}


% Read in a verbatim file
\newcommand{\txt}[2]{
  \subsubsection*{#1}
  \verbatimtabinput{#2}
}

% Read in a LaTeX file
\newcommand{\Input}[1]{
  \input{#1}
}


% Page refs as well.
\newcommand{\Ref}[1]{\ref{#1} (on page \pageref{#1})}

%% Latex in figures etc
\newcommand{\B}[1]{\text{\sffamily\textbf{#1}}}
\newcommand{\BB}[2]{$\B{#1}$:$\mathbf{#2}$}

Added mtt/bin/trans/mtt2reps_txt version [14bdc5a92e].






















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

# mtt2reps_txt: Gives a tabular listing of representations and languages
# P J Gawthrop July 1998, October 1998
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/07/24 04:18:32  gawthrop
## Fixed problem with shell expanding * (used as important rep marker)
##
## Revision 1.11  2001/04/28 03:38:36  geraint
## Refined selection of matching patterns - checks for exact match.
##
## Revision 1.10  2000/09/14 07:54:13  peterg
## Removed -e option in echo
##
## Revision 1.9  2000/04/05 08:34:30  peterg
## removed output tab
##
## Revision 1.8  2000/04/05 08:04:01  peterg
## Minor reorganisation
##
## Revision 1.7  2000/04/04 16:15:14  peterg
## Fixed awk prob - must be the same sep. for each field (?)
## So tr tab to space
##
## Revision 1.6  2000/04/04 13:09:51  peterg
## *** empty log message ***
##
## Revision 1.5  2000/01/19 17:26:12  peterg
## Now includes the representation title.
##
## Revision 1.4  1999/03/09 00:03:06  peterg
## Revisions for xmtt
##
## Revision 1.3  1999/03/08 21:24:43  peterg
## Handles * representations:
##
## 	rep* is special
##         rep shows all possible languages
##
## Revision 1.2  1999/03/08 06:34:07  peterg
## Removed mtt help - replaced by grep #SUMMARY - quicker
##
## Revision 1.1  1998/10/20 08:15:08  peterg
## Initial revision
##
###############################################################

sep='|'; # Separates the languages from the rest.

## List of all representations (deleting the *)
representations=`grep '#SUMMARY' $MTTPATH/mtt | gawk '{sub("\*","+"); print $2'} | sort -u `


for rep in $representations ; do
    Rep=`echo $rep | tr '+' '*'`
    ## Title should be same for all languages -- but extract the first non-empty version
      title=`grep '#SUMMARY' $MTTPATH/mtt | tr '\t' ' ' | grep "[ *]$Rep[ *]" | \
      gawk  '{if (NF>2) {for (i=3;i<NF-1;i++) printf("%s ",$i); NF1=NF-1; printf("%s\n",$NF1)}}' |\
      head -1`
      
    language=`grep '#SUMMARY' $MTTPATH/mtt |\
      gawk '
        {
          if (index(rep,"*")==length(rep)){
            if ($2==rep) print $NF
          }
          else
            if (($2==rep)||($2==sprintf("%s*",rep))) print $NF
        }' rep=$Rep |\
      sort -u | sed 's/[()]//g'` 

      Title='('$title')'
      echo "$Rep" $Title  $sep $language
     
done




Added mtt/bin/trans/mtt_error version [36e03ad5ab].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_error
# Does the error handing for transformations and forces error exit.
# P.J.Gawthrop  August 1996
# Copyright (c) P.J.Gawthrop, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2000/12/28 12:34:49  peterg
## Put under RCS
##
## Revision 1.7  1998/03/06 17:14:09  peterg
## Cospetic change to message
##
## Revision 1.6  1998/03/05 10:17:41  peterg
## Cosmetic change
##
## Revision 1.5  1998/03/05 10:14:37  peterg
## Toned down the error warning message
##
## Revision 1.4  1998/02/26 10:21:51  peterg
## Revised to take account of new (??) wc output - now echos the file
## name (??)
##
## Revision 1.3  1998/02/25 21:35:00  peterg
## Put "" round if argument in case $err_length is null.
##
## Revision 1.2  1996/08/26 09:46:37  peterg
## Changed $() to ``
##
# Revision 1.1  1996/08/25  09:20:00  peter
# Initial revision
#
###############################################################

error_file=$1;

# Test for errors and print if any
err_length=`wc -c <$error_file | gawk '{print $1}'`
if [ "$err_length" != "0" ]
then
    echo "INFORMATION: An MTT transformation has generated the following messages"
#  echo "             (which may not be important)"
  cat $error_file
  exit 1
else
  exit 0
fi

Added mtt/bin/trans/mtt_error_r version [8500aa4349].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_error_r
# Does the error handing for transformations and forces error exit.
# This is the version for resuce which does not use error output.
# P.J.Gawthrop  August 1996
# Copyright (c) P.J.Gawthrop, 1996

log_file=$1

#Reduce writes errors to std output with ***** in front.
grep '\*\*\*\*\*' $log_file >mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt

Added mtt/bin/trans/mtt_fix_integers version [511eb60f9c].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

mttmatrix='\(mtt[A-Za-z][A-Za-z]*\)'
integer='\([0-9][0-9]*\)'

mtt_join_lines | gawk -v RS=${1:-"$"} -v ORS=${2:-"$\n"} ' {
str = $0;
str1 = gensub ( /([^A-Za-z_0-9\.\+])([0-9]+)([^\.0-9])/ , "\\1\\2.0\\3" , "g", str );
str2 = gensub ( /([^e]\+)([0-9]+)([^\.0-9])/ , "\\1\\2.0\\3" , "g", str1 );
str3 = gensub ( /([^A-Za-z_0-9\.\+])([0-9]+)e([0-9]+).0([^\.0-9])/ , "\\1\\2\\3\\4" , "g" , str2)
printf "%s$\n", str3 ;
}' | sed -e "s/$mttmatrix($integer\.0,/\1(\2,/g"

Added mtt/bin/trans/mtt_get_subsystems version [368cf1b1dc].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
# Gets the subsystems

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-strip )
                strip=yes;
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

subsystems=`sh $1_sub.sh "echo grep " " $1_abg.m" |\
            sh | gawk -F '.' '{print $3}'`

if [ -n "$strip" ]; then
      echo $subsystems  
   else
      for subsystem in $subsystems; do
	# echo -n $1_$subsystem' '
        echo $1_$subsystem #| gawk '{printf("%s ",$1)}'
    done
    echo
fi










Added mtt/bin/trans/mtt_getsize version [59fbe2a583].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_getsize

# Gets array sizes for the def.r file
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-internal )
                internal=yes;
		;;
	-external )
                external=yes;
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

if [ -n "$internal" ]; then
    name=MTT$2"[0-9]"; # echo $name
    grep -i "$name" $1_ese.r | wc -l
    exit
fi

if [ -n "$external" ]; then
    name="^MTT"$2"("; #echo $name
    grep -i "$name" $1_ese.r | wc -l
    exit
fi

## The original version for external sizes.
if [ "$2" = "xx" ]; then
  n=`mtt_getsize $1 x`
  N=`echo "$n * $n" | bc` 
else
  N=`grep "MTTN$2 " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
fi

echo $N

Added mtt/bin/trans/mtt_header version [342dc555fd].





























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_header
# Headings for functions
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.67  2005/11/16 00:43:15  geraint
## rtxi
##
## Revision 1.66  2005/02/17 18:54:23  geraint
## Fixed a bash-sim: replaced let with $(( ))
##
## Revision 1.65  2004/08/29 13:14:29  geraint
## Added rule to make header for sae (sorted algebraic equations).
##
## Revision 1.64  2004/08/29 01:48:46  geraint
## Added rules to create headers for sorted systems: sesx and sesy.
##
## Revision 1.63  2004/08/28 22:08:41  geraint
## Fixed zeromatrices statements: spaces instead of commas
##
## Revision 1.62  2004/07/19 22:22:25  geraint
## Fixed initialisation of ColumnVectors for -oct.
##
## Revision 1.61  2004/06/21 16:30:41  gawthrop
## Don't zero for cc code
##
## Revision 1.60  2004/06/21 16:05:58  gawthrop
## Zapped comment that causes
##
## Revision 1.59  2004/06/20 13:53:06  gawthrop
## Initialise for numpar as well
##
## Revision 1.58  2004/06/20 13:34:11  gawthrop
## Create vectors using zeros(N,1) - avoids new octave
## default to row vector - more reps now included
##
## Revision 1.57  2004/06/20 10:18:00  gawthrop
## Explicitly size vectors - avoid default row vector bug
##
## Revision 1.56  2003/04/17 20:07:33  geraint
## Added rule to create _sese.m
##
## Revision 1.55  2002/10/30 01:15:20  gawthrop
## Now gives correct-size matrices for dm rep.
##
## Revision 1.54  2002/07/11 13:00:23  geraint
## Declared more function arguments to be "const" - improves compiler optimisation.
##
## Revision 1.53  2002/06/10 23:22:16  geraint
## Fixed problem with Matlab fsolve failing because of "user function returned Inf or Nan" (fsolve.m, line 245).
##
## Revision 1.52  2002/05/27 14:52:15  geraint
## Parameters in sfun reps are now declared using sympar.h at the top of the
## sfun*.c file instead of in individual functions. This causes the optimisation
## variables (mtt_tmp*) to be declared correctly without causing conflicts in the
## scope of parameter declarations.
##
## Revision 1.51  2002/05/19 13:01:21  geraint
## Numerical solution of algebraic equations implemented for S-function target.
##
## Equation solving requires the Matlab Optimization Toolbox to be installed.
##
## Code has been changed from C++ to C to allow mex files to be built with LCC,
## the compiler bundled with Matlab.
##
## Parameters are now obtained from numpar.c instead of a dialogue box.
##
## `mtt <sys> sfun zip` creates all necessary files for building the model mex files.
##
## Revision 1.50  2002/05/15 14:22:25  geraint
## Code for Simulink S-function target written direct to sfun.cc instead of
## calling .mexglx files. This eliminates the sfun dependency on Octave
## ColumnVectors. sys_sfun.cc should build directly on a MS Windows machine
## (can't test this yet).
##
## added sfun.zip target to create source code to export.
##
## Revision 1.49  2002/05/11 01:14:17  geraint
## Fix for [ 553218 ] simpar.oct and simpar.m different.
## Translation added between ColumnVector in base .cc and Octave_map in .oct.
##
## Revision 1.48  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.47  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.46  2002/05/07 13:48:43  geraint
## Improved clarity of code generated for -cc and -oct (except ode2odes).
## Octave DEFUN_DLDs now call (rather than replace) their .cc equivalents.
##
## Revision 1.45  2002/05/02 09:30:22  gawthrop
## _ssim.m now returns t as 4th arg
##
## Revision 1.44  2002/05/01 17:30:56  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
## if necessary.
##
## Revision 1.43  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp
## (and thus libreadline, libkpathsea, libncurses, etc).
##
## Revision 1.42  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.41  2002/04/23 17:46:05  gawthrop
## _sim.m now returns time as third argument
##
## Revision 1.40  2002/04/17 16:23:59  geraint
## Partial fix for [ 545113 ] zeros missing in c++.
## Fixes -oct by removing duplicate initialisation (-c is still outstanding).
##
## Revision 1.39  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).
##
## Revision 1.38  2001/07/23 23:43:15  gawthrop
## header only version does not need to compute sizes from _def.r
##
## Revision 1.37  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.36  2001/07/12 04:00:51  gawthrop
## Now zeros y correctly - ie Ny NOT Nx elements
##
## Revision 1.35  2001/06/13 10:39:51  gawthrop
## Zeros output matices in csex and cseo just in case some elements are
## actually zero and not set in code. Works for m and oct.
##
## Revision 1.34  2001/05/26 18:36:43  gawthrop
## Further modifications. Now works on rcPPP
##  -- next jobs:
##     add identification to ppp_nlin_sim
##     create real-time ppp_nlin_run
##
## Revision 1.33  2001/05/26 15:46:38  gawthrop
## Updated to account for new nonlinear ppp
##
## Revision 1.32  2001/05/24 07:42:12  gawthrop
## Included and updated the missing tf_r2m
##
## Revision 1.31.2.2  2001/07/02 00:34:56  geraint
## gcc-3.0 compatibility.
##
## Revision 1.31.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.31  2001/04/03 14:49:42  gawthrop
## Revised to incorporate new ssim (sensitivity simulation)
## representation (m only just now).
##
## Revision 1.30  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.29  2001/03/27 13:10:23  geraint
## Improved determination of Octave version.
##
## Revision 1.28  2001/02/17 03:48:17  geraint
## Use assignment LHS to gather tmp variable names.
## Prevents collection of long expressions, eg: tmp34*(tmp75
##
## Revision 1.27  2001/02/14 06:06:34  geraint
## Removed octave_value_list wrappers from standalone.exe - speed improvements
##
## Revision 1.26  2001/02/05 08:50:58  geraint
## Octave 2.1.x compatability.
##
## Revision 1.28  2001/01/17 21:16:15  geraint
## uncomment parameter assignments in .m reps
##
## Revision 1.27  2001/01/14 23:51:26  geraint
## declare parameters as variables instead of constants
##
## Revision 1.26  2001/01/07 21:22:47  geraint
## Compatibility with Octave 2.1.x
## vector_value ---> column_vector_value
##
## Revision 1.25  2000/12/05 12:05:26  peterg
## Changed to () form
##
## Revision 1.24  2000/12/05 10:04:52  peterg
## Fixed dummy variable bug
##
## Revision 1.23  2000/12/05 09:47:50  peterg
## Include crs as c files
##
## Revision 1.22  2000/12/04 12:19:12  peterg
## Changed $() to `` and $() to expr for sh compatibility -- geraint
##
## Revision 1.21  2000/12/04 08:52:40  peterg
## Zapped () in functions for sh compatibility
##
## Revision 1.20  2000/12/04 08:19:27  peterg
## Added switch declarations - in logic.cc
##
## Revision 1.19  2000/12/03 16:11:43  peterg
## Corrected bug in logic declatations
##
## Revision 1.18  2000/12/03 16:06:22  peterg
## Fixed bug in generating dummies
## Added logic declarations
##
## Revision 1.17  2000/12/01 20:55:01  peterg
## Added Geraint's fix for zeroing matrices
##
## Revision 1.16  2000/12/01 17:56:30  peterg
## Removed spurious  echo '## Set matrices to zero' - thanks Geraint
##
## Revision 1.15  2000/11/29 21:06:16  peterg
## Removed Npar creation - not needed??
##
## Revision 1.14  2000/11/27 11:51:43  peterg
## Added zero matrices in matlab code
##
## Revision 1.13  2000/11/09 17:19:52  peterg
## Geraint's pow() mods
##
## Revision 1.12  2000/11/09 16:09:46  peterg
## Declare dummy variables (mtt_s1 etc)
##
## Revision 1.11  2000/11/09 15:29:35  peterg
## lower-case declarations
##
## Revision 1.10  2000/11/07 17:20:51  peterg
## useful-functions.hh now included locally
##
## Revision 1.9  2000/11/07 16:56:24  peterg
## Version from Geraint
##
## Revision 1.2  2000/11/03 00:55:42  geraint
## typo: missed out 'd' in mttedx
## todo: need to accommodate mttsimpar
##
## Revision 1.1  2000/11/02 04:28:39  geraint
## Initial revision
##
## Revision 1.8  2000/10/17 16:35:03  peterg
## No parameter,state or input conversion in txt files
##
## Revision 1.7  2000/10/17 09:53:20  peterg
## Fixed logic rep
##
## Revision 1.6  2000/10/17 08:37:23  peterg
## Included logic rep
##
## Revision 1.5  2000/10/14 09:12:14  peterg
## No dies arguments and output itself
##
## Revision 1.4  2000/10/14 06:49:31  peterg
## Make parameter listing representation dependent
##
## Revision 1.3  2000/10/11 08:59:15  peterg
## Added csex rep
##
## Revision 1.2  2000/10/11 08:01:42  peterg
## Added noglobal fudge
 ##
## Revision 1.1  2000/10/10 21:02:27  peterg
## Initial revision
##
###############################################################

# Arguments
system=$1
rep=$2
language=$3
fun_name=${1}_${2}

other=$4 # Anything else eg stdin

insertor=\<\<			# help emacs sh-mode with C++ lines


if [ -z "$system" ]; then
  echo 'Usage: mtt_header sys rep lang [stdin]'
  exit
fi


# get octave version
octave_development=`octave --version | gawk '{print $4}' | gawk -F\. '{print $2}'`
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	;;
    1) # development
	vector_value=column_vector_value
	;;
    *)
	vector_value=column_vector_value
	;;
esac


# Representation-specific stuff

eqnargs='mttx,mttu,mttt,mttpar'
inputeqnargs='mttx,mtty,mttt,mttpar'
case $rep in
    ae)
	states=yes;
	inputs=yes;
	parameters=yes;
	output=mttyz;
	args=$eqnargs;
	;;
    cse)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mttdx,mtte'
        args=$eqnargs
	zeromatrices='dx e'
	;;
    csex)
	states=yes;
        inputs=yes;
	parameters=yes;
        output=mttedx
        args=$eqnargs
        zeromatrices='edx';
	;;
    cseo)
	states=yes;
        inputs=yes;
	parameters=yes;
        output=mtty
        args=$eqnargs
        zeromatrices='y';
	;;
    dm)
	states=no;
	inputs=no;
	parameters=yes;
        output='mtta,mttb,mttc,mttd,mtte'
        args=mttpar
        zeromatrices='a b c d e';
	;;
   input)
	inputs=no;
        output=mttu
        args=$inputeqnargs
        if [ "$other" = "stdin" ]; then
	  states=no;
	  parameters=no;
          declareinputs=no;
        else
	  states=yes;
	  parameters=yes;
          declareinputs=yes
	  declarestates=yes
	  zeromatrices='u'
        fi
	;;
    logic)
	states=no;
	inputs=no;
	parameters=yes;
        output=mttopen
        args=$eqnargs
        declareinputs=yes
        declarestates=yes
	declareswitches=yes
        zeromatrices='open';
	;;
    numpar)
	states=no;
	inputs=no;
	parameters=no;
        output='mttpar'
	zeromatrices='par'
	;;
    ode)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mttdx,mtty'
        args=$eqnargs
	zeromatrices='dx y'
	;;
    odeo)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mtty'
        args=$eqnargs
	zeromatrices='y'
	;;
    ode2odes)
	states=no;
        inputs=no;
	parameters=no;
        output='mtt_data'
        args='x0,par,simpar'
	;;
    simpar)
	states=no;
	inputs=no;
	parameters=no;
	output='mttsimpar'
	oct_rep_include="#include <mtt_simpar.hh>"
	oct_return_type="mtt_simpar"
	;;
    sae)
	states=yes;
	inputs=yes;
	parameters=yes;
	output=mttyz;
	args=$eqnargs;
	;;
    sese)
	states=yes;
	inputs=yes;
	parameters=yes;
	output="mttdx,mtty";
	args=$eqnargs;
	zeromatrices="dx y";
	;;
    sesx)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mttdx'
        args=$eqnargs
	zeromatrices='dx'
	;;
    sesy)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mtty'
        args=$eqnargs
	zeromatrices='y'
	;;
    sm)
	states=no;
	inputs=no;
	parameters=yes;
        output='mtta,mttb,mttc,mttd'
        args=mttpar;
        zeromatrices='a b c d';
	;;
     smxa)
	states=no;
        inputs=no;
	parameters=yes;
        output='mtta'
        args=$eqnargs
        zeromatrices='a';
	;;
    smxax)
	states=no;
        inputs=no;
	parameters=yes;
        output='mttax'
        args=$eqnargs
        zeromatrices='ax';
	;;
    state)
	states=no;
	inputs=no;
	parameters=yes;
        output=mttx
        args=mttpar
        declarestates=yes
	zeromatrices='x'
	;;
    sim)
	states=no;
        inputs=no;
	parameters=no;
        output='y,x,t'
        args='x0,par,simpar,u'
	;;
    ssim)
	states=no;
        inputs=no;
	parameters=no;
        output='y,y_par,x,t'
        args='x0,par,simpar,u,index'
	;;
    tf)
	states=no;
	inputs=no;
	parameters=yes;
        output='mttnum,mttden'
        args=mttpar;
	;;    
    type)
	states=no;
	inputs=no;
	parameters=no;
	header_only=yes;
	;;

     *)
	echo Representation $rep not supported - sorry; exit 1
esac

## Sort out parentheses
if [ -n "$args" ]; then
    Args='('$args')'
fi
if [ -n "$output" ]; then
    Output="[$output] = "
fi


# Lanuage specific stuff
case $language in
    m)
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function="function"
	declaration="$Output$1_$rep$Args;"
        if [ "$other" != "stdin" ]; then
	  noglobals=true; # Fudge to make mtt_m2p work
        fi     
        start='## BEGIN Code'
        finish='## END Code'
        var_declaration=
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;
    sh)
	modeline='## -*-shell-script-*- Put Emacs into shell-script-mode ##';
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function=""
	declaration=""
        start=''
        parameters=no
	states=no
	inputs=no
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;
    txt)
	modeline='## -*-octave-*- Put Emacs into octave-mode ##';
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function=""
	declaration=""
        start=''
        parameters=no
	states=no
	inputs=no
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;
    oct)
	modeline="// -*-c++-*- Put Emacs into c++-mode";
	Lc='//';
	Lb='(';
	Rb=')';
	oct_header=yes;
        constant_declaration="const double "
        var_declaration="double "
	minusone="-1"
	map="_map"
        declaredummies=yes
	;;
    c)
	modeline="/* -*-c-*- Put Emacs into c-mode */";
	Lc='/*'
	Rc='*/'
	Lb='['
	Rb=']'
	constant_declaration="const double "
	var_declaration="double "
	minusone="-1"
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

if [ "$rep" = "simpar" ]; then
   output=${output}${map}    # Output is simpar_map in this case
fi

get_sizes()
    {
    Nx=`mtt_getsize $system x` # States
    Nz=`mtt_getsize $system z` # Non-states
    Nxx=`mtt_getsize $system xx` # States x States
    Nu=`mtt_getsize $system u` # Inputs 
    Ny=`mtt_getsize $system y` # Outputs 
    Nyz=`mtt_getsize $system yz` # Zero outputs

    case ${rep} in
	dm)
	Nx=$(( $Nx + 2 * $Nz + $Nyz )) # Matrices not usual size
	;;
	*)
	
    esac
    Npar=`wc -l $system\_sympar.txt | gawk '{print $1}'`
    }

zero_matrices()
{
## Set matrices to zero
echo
for name in $zeromatrices; do
    case $name in
	a)
	    N=$Nx; M=$Nx
	    ;;
	b)
	    N=$Nx; M=$Nu
	    ;;
	c)
	    N=$Ny; M=$Nx
	    ;;
	d)
	    N=$Ny; M=$Nu
	    ;;
	e)
	    N=$Nx; M=$Nx
	    ;;
	x)
	    N=$Nx; M=0
	    ;;
	dx)
	    N=$Nx; M=0
	    ;;
	edx)
	    N=$Nx; M=0
	    ;;
	y)
	    N=$Ny; M=0
	    ;;
	u)
	    N=$Nu; M=0
	    ;;
	open)
	    N=$Nx; M=0
	    ;;
	ax)
	    N=$Nx; M=0
	    ;;
	par)
	    N=$Npar; M=0
	    ;;
	*)
	    
    esac

    case ${language} in
	m)
	  if [ "$M" = "0" ]; then
	      M=1;
	  fi
          echo "   mtt$name = zeros($N,$M);"	
	;;
	oct)
	    if [ "$M" = "0" ]; then
		echo "   mtt$name = zeros($N);"
	    else
		echo "   mtt$name = zeros($N,$M);"
	    fi
	    ;;
        *)
    esac
done
}

declare_dummies()
{
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
    grep "${dummy}[0-9]*[ \t\n]*=" < ${fun_name}.m |\
    gawk '{ 
          if (match($1,dummy)==1)
             print $1
         }' dummy=$dummy >> mtt_dummies
done

dummy_list=`sort -u mtt_dummies`

# Comments
cat <<EOF

$Lc  Declarations of dummies $Rc
EOF

for dummy in $dummy_list; do
    echo '  ' $var_declaration $dummy';'
done
} # declare_dummies

declare_switches ()
{
cat <<EOF

$Lc  Declarations of switches $Rc
EOF
 strip_comments <${system}_switch.txt |\
 gawk '{printf("  double %s_logic = 0;\n", tolower($1))}' 
} # declare_switches

declare_vars()
{
# Grab the names
names=`gawk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`

# Comments
cat <<EOF

$Lc  Declarations for $1 names $Rc
EOF
# Declarations
for name in $names; do
    echo '  '$var_declaration $name';'
done
}


array2constant()
{
# Parameters
if [ "$parameters" = "yes" ]; then
cat <<EOF

$Lc Parameters $Rc
EOF
sympar2par_txt2m ${system} ""  "$var_declaration" "$minusone" "$Lb" "$Rb"
fi

# States
if [ "$states" = "yes" ]; then
cat <<EOF

$Lc States $Rc
EOF
N=`n2m 1 $Nx`
for i in $N; do
    echo $constant_declaration 'mttx'$i' = mttx'$Lb$i$minusone$Rb ';'
done
fi

if [ "$declarestates" = "yes" ]; then
  declare_vars state
fi

# Inputs
if [ "$inputs" = "yes" ]; then
cat <<EOF

$Lc Inputs $Rc
EOF

N=`n2m 1 $Nu`
for i in $N; do
  echo $constant_declaration 'mttu'$i' = mttu'$Lb$i$minusone$Rb';'
done
cat <<EOF

$Lc Unknown Inputs $Rc
EOF

Ni=`n2m 1 $Nyz`
for i in $Ni; do
  echo $constant_declaration 'mttui'$i' = mttu'$Lb$Nu+$i$minusone$Rb';'
done
fi

if [ "$declareinputs" = "yes" ]; then
  declare_vars input
fi

if [ "$declaredummies" = "yes" ]; then
  declare_dummies
fi

if [ "$declareswitches" = "yes" ]; then
  declare_switches
fi


zero_matrices;

}

# Argument specific stuff
get_arg_specific_stuff ()
{
    arg_name=${1:-""}
    case ${arg_name} in
	mtta | mtte)
	    arg_type="Matrix"
	    arg_init="(MTTNX,MTTNX,0.0)"
	    ;;
	mttb)
	    arg_type="Matrix"
	    arg_init="(MTTNX,MTTNU,0.0)"
	    ;;
	mttc)
	    arg_type="Matrix"
	    arg_init="(MTTNY,MTTNX,0.0)"
	    ;;
	mttd)
	    arg_type="Matrix"
	    arg_init="(MTTNY,MTTNU,0.0)"
	    ;;
	mttax | mttdx | mttedx | mttx | mttopen)
	    arg_type="ColumnVector"
	    arg_init="(MTTNX,0.0)"
	    ;;
	mttpar)
	    arg_type="ColumnVector"
	    arg_init="(MTTNPAR,0.0)"
	    ;;
	mttsimpar_map)
	    arg_type="ColumnVector"
	    arg_init="(8,0.0)";
	    ;;
	mttu)
	    arg_type="ColumnVector"
	    arg_init="(MTTNU,0.0)"
	    ;;
	mttyz)
	    arg_type="ColumnVector"
	    arg_init="(MTTNYZ,0.0)"
	    ;;
	mtty)
	    arg_type="ColumnVector"
	    arg_init="(MTTNY,0.0)"
	    ;;
	mttt)
	    arg_type="double"
	    arg_init=""
	    ;;
	nil)
	    arg_type="void *"
	    arg_init="(0x0)"
	    ;;
	*)
	    echo "Argument ${arg} not supported - sorry"; exit 1
    esac
}


get_field ()
{ # parse comma separated string
    s=${1:-""}					# comma separated string
    i=${2:-0}					# field number in string

    if [ 0 -eq ${i} ]; then			# return number of fields
	echo ${s} |\
	gawk -F\, '{ print NF }'
    else					# return ith field
	echo ${s} |\
	gawk -F\, -v i=${i} '{ print $i }'
    fi
}


get_extra_fields ()
{ # return list of words in s2 and not in s1
    s1=${1:-""}					# comma separated list
    s2=${2:-""}					# comma separated list

    c1=`get_field ${s1} 0`			# count words in s1
    c2=`get_field ${s2} 0`			# count words in s2
	
    ans=""
	
    i2=0					# s2 word index
    while [ ${i2} -lt ${c2} ]; do
        flag=0					# appearance of word in s1 and s2?
	i2=`expr ${i2} + 1`
	w2=`get_field ${s2} ${i2}`		# i2 th word in s2
	i1=0					# s1 word index
	while [ ${i1} -lt ${c1} ]; do
	    i1=`expr ${i1} + 1`
	    w1=`get_field ${s1} ${i1}`		# i1 th word in s1
	    if [ ${w2} = ${w1} ]; then
		flag=1				# w2 occurs in s1
	    fi
        done
	if [ ${flag} -eq 0 ]; then		# w2 is not in s1?
	    if [ -z ${ans:-""} ]; then		#  string is empty?
		ans=${w2}			#   assign w2
	    else
		ans=${ans},${w2}		#   append w2
	    fi
        fi
    done
    echo ${ans}
}


write_cc_header ()
{
    first_output=`get_field ${output:-""} 1`
    get_arg_specific_stuff ${first_output}
    # Should multiple vector outputs be returned as a single matrix?
    
    cat <<EOF

#include <octave/oct.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#define MATLABMEX  2
#define RTXI       3
#ifndef CODEGENTARGET
#define CODEGENTARGET STANDALONE
#endif // CODEGENTARGET

${arg_type} ${system}_${rep} (
EOF
    if [ -z ${args:-""} ]; then
	printf "\tvoid"
    else
	c=`get_field ${args:-""} 0`
	i=0
	while [ ${i} -lt ${c} ]; do
	    i=`expr ${i} + 1`
	    if [ ${i} -lt ${c} ]; then
		comma=","
	    else
		comma=""
	    fi
	    w=`get_field ${args} ${i}`
	    get_arg_specific_stuff ${w}
	    printf "\tconst ${arg_type}\t&${w}${comma}\n"
	done
    fi
    cat <<EOF
)
{
EOF

    if [ -z ${output:-""} ]; then
	printf "/* write_cc_header: no output specified. */"
    else
	c=`get_field ${output:-""} 0`
	i=0
	while [ ${i} -lt ${c} ]; do
	    i=`expr ${i} + 1`
	    w=`get_field ${output} ${i}`
	    get_arg_specific_stuff ${w}
	    printf "\tstatic ${arg_type}\t${w}${arg_init};\n"
	done
    fi
}

write_cc_footer ()
{
    first_output=`get_field ${output:-""} 1`
    # Should multiple vector outputs be returned as a single matrix?

    cat <<EOF
// BEGIN Code
// END   Code

  return ${first_output};
}

EOF
}


map_oct_inputs ()
{
    s=${1:-""}					# comma separated input list
    if [ -z ${s:-""} ];then return; fi
    c=`get_field ${s} 0`			# count of inputs
    i=0
    printf "  if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n"
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
	w=`get_field ${s} ${i}`		# argument name
	get_arg_specific_stuff ${w}
	case ${arg_type} in
	    "double")
		printf "  const ${arg_type}\t${w}\t= args(${j}).double_value ();\n"
		;;
	    ColumnVector | Matrix | *)
		printf "  const ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
		;;
	esac
    done
}	

map_mex_cc_inputs ()
{
    s=${1:-""}					# comma separated input list
    if [ -z ${s:-""} ];then return; fi
    c=`get_field ${s} 0`			# count of inputs
    i=0
    cat <<EOF
    if (${c} != nrhs)
     {
       std::cerr $insertor "${fun_name} expected " $insertor ${c} $insertor " argument(s): ${s}" $insertor std::endl;
       return;
     }
EOF
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
        w=`get_field ${s} ${i}`		# argument name
	get_arg_specific_stuff ${w}
	case ${arg_type} in
	    "const double")
		printf "  ${arg_type}\t${w}\t= mtt_double (prhs [${j}]);\n"
		;;
	    ColumnVector | Matrix | *)
		printf "  ${arg_type}\t${w}\t= mtt_${arg_type} (prhs [${j}]);\n"
		;;
	esac
    done
}	
    

write_oct()
{
    first_output=`get_field ${output:-""} 1`
    func=${1:-"<insert function name>"}
    args=${2:-""}
    cat <<EOF
#if (CODEGENTARGET == OCTAVEDLD)
$oct_rep_include

DEFUN_DLD (${system}_${rep}, args, ,
"Usage: [$first_output] = ${system}_${rep}($args)\nOctave ${rep} representation of system ${system}\nGenerated by MTT on `date`")
{
  static octave_value_list retval;

EOF
    map_oct_inputs ${args}
    cat <<EOF

  retval (0) = octave_value ($oct_return_type (${func} (${args})));
  return retval;
}
#endif // (CODEGENTARGET == OCTAVEDLD)

EOF
}

write_mex_cc ()
{
    func=${1:-"<insert function name>"}
    args=${2:-""}
    cat <<EOF
#if (CODEGENTARGET == MATLABMEX)
#include <mtt_matlab_octave.hh>

extern "C"
{
  void mexFunction (int nlhs, mxArray *plhs[],
		    int nrhs, const mxArray *prhs[])
  {
EOF
  map_mex_cc_inputs ${args}
cat <<EOF
  plhs[0] = mtt_mxArray (${func} (${args}));
  }
}
#endif

EOF
}

# Header information
cat<<EOF
$modeline
$function $declaration
$Lc $declaration
$Lc System $system, representation $rep, language $language; $Rc
$Lc File $1_$rep.$language; $Rc
$Lc Generated by MTT on `date`; $Rc
EOF

if [ -n "${header_only}" ]; then
    exit
else
    get_sizes;
fi

if [ ${language} = "oct" ];then
# standalone
    write_cc_header
    array2constant
    write_cc_footer
# oct and mex code
    write_oct ${system}_${rep} ${args}
    write_mex_cc ${system}_${rep} ${args}
elif [ $language = "c" ]; then
    array2constant
    cat <<EOF
/* BEGIN Code */
/* END Code */
EOF
else

if [ -n "$noglobals" ]; then
cat<<EOF

## Horrible fudge to make mtt_m2p work
global ...
mtt_no_globals ;
EOF
fi

## Arrays 
array2constant

# Mark start of code
echo
echo $start

fi

Added mtt/bin/trans/mtt_join_lines version [95d87c9e44].






1
2
3
4
5
+
+
+
+
+
#! /bin/sh

gawk '{ printf ( "%s" , $0 ) }'		|\
    gawk -v RS="$" '{ printf "%s$\n", $0 }'	|\
    gawk -v RS=";" '{ printf "%s;\n", $0 }'

Added mtt/bin/trans/mtt_langname version [080d1d07c0].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_langname

# Returns the language name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | gawk -F '.' '{print $2}'

Added mtt/bin/trans/mtt_m2p version [5aa349fe2c].



























































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_m2p
# Reduce octave 2 Pascal converter for MTT   
# P.J.Gawthrop July 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.67  2002/04/18 17:02:15  gawthrop
## foo=zeros(3,1) translated as zero_state(foo,3)
##
## Revision 1.66  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.65  2001/02/09 02:56:46  geraint
## Translate some binary operators
## Allows use of ! in logic.txt
##
## Revision 1.64  2001/02/03 14:00:01  gawthrop
## Geraint's temp. variable patch applied
##
## Revision 1.63  2000/12/04 08:24:29  peterg
## Added swithc logic declarations
##
## Revision 1.62  2000/12/03 17:15:18  peterg
## *** empty log message ***
##
## Revision 1.61  2000/11/10 14:46:53  peterg
## More fixes to avoid interpering variables as funs - basicly all
## functions now have at least ()
##
## Revision 1.60  2000/11/10 09:38:30  peterg
## Got rid of sys_name functions with no ()
##
## Revision 1.59  2000/11/10 09:29:31  peterg
## Changed the name regexp to be at least 3 characters long
##  - avoids problem translating som state files - but needs more work
##
## Revision 1.58  2000/10/17 09:54:29  peterg
## replaced switchopen by logic
##
## Revision 1.57  2000/10/15 10:35:35  peterg
## Fixed _input.p header
##
## Revision 1.56  2000/10/14 09:14:24  peterg
## *** empty log message ***
##
## Revision 1.55  2000/10/11 09:06:17  peterg
## New csex rep (uses scope optimisation)
##
## Revision 1.54  2000/09/30 14:10:06  peterg
## Zap lines containing "Remove in mtt_m2p"
##
## Revision 1.53  2000/08/24 17:10:59  peterg
## New dummy variables mtt_o (for optimisation), mtt_s (for segmentation)
##
## Revision 1.52  2000/08/24 08:30:45  peterg
## *** empty log message ***
##
## Revision 1.51  2000/08/01 12:25:24  peterg
## Some changes to include files
##
## Revision 1.50  2000/05/19 17:46:41  peterg
## New version of state with par argument
##
## Revision 1.49  2000/05/18 09:45:45  peterg
## Fixed missing ;
##
## Revision 1.48  2000/05/18 09:39:38  peterg
## Removed fifth argument from _input
##
## Revision 1.47  2000/05/16 18:56:03  peterg
## Upgraded for new simulation approach - uses data files to input
## parameters -- no more argv stuff
##
## Revision 1.46  2000/05/16 11:59:01  peterg
## Updated for new data file parameter/state update
##
## Revision 1.45  2000/05/13 13:16:52  peterg
## Matrix initialisation for smxa
##
## Revision 1.44  2000/05/13 11:52:16  peterg
## A now matrix in smxa rep
##
## Revision 1.43  2000/05/11 19:35:16  peterg
## Major revisions for new paprameter passing versions
##
## Revision 1.42  2000/04/18 11:11:44  peterg
## mtt_parameters ---> mttpar
## mtt_n_parameters ---> mttnpar
##
## Revision 1.41  2000/04/18 10:13:43  peterg
## Getargs now after numpar file
##
## Revision 1.40  2000/04/07 19:09:04  peterg
## New smxa and smxax reps
##
## Revision 1.39  2000/04/07 13:38:13  peterg
## New mtt_getsize to replace bc
##
## Revision 1.38  2000/04/07 13:24:41  peterg
## Modified for smxa and smxax
##
## Revision 1.37  2000/04/07 08:17:37  peterg
## Added mttpar to the arg list of cse and cseo
##
## Revision 1.36  1999/11/29 06:49:26  peterg
## Upped number of mtt_tnn
##
## Revision 1.35  1999/11/15 22:47:17  peterg
## Generates method-specific code for the ode2odeso rep.
##
## Revision 1.34  1999/10/28 05:08:48  peterg
## Added elseif
##
## Revision 1.33  1999/09/17 04:25:01  peterg
## END --> END; in translation
##
## Revision 1.32  1999/08/29 06:54:42  peterg
## Added code (mtt_parameters, get args etc) to allow arguments to the
## a.out file
##
## Revision 1.31  1999/08/02 13:40:03  peterg
## Added zero-state and zero_input to include list
## Removed zero_matrix
##
## Revision 1.30  1999/04/20 06:16:46  peterg
## Removed calls to _switch.m
##
## Revision 1.29  1999/04/02 06:27:55  peterg
## Modified for new implicit method with swoitches
##
## Revision 1.28  1999/02/17 02:59:54  peterg
## Added -q switch to mtt
##
## Revision 1.27  1999/02/16 21:56:52  peterg
## Now gets standard include files directly from source,
##
## Revision 1.26  1999/02/16 21:43:54  peterg
## Revises smx generation.
##
## Revision 1.25  1999/02/16 04:38:09  peterg
## Now forces creation of _smx file if METHOD=IMPLICIT in simpar.txt
##
## Revision 1.24  1998/11/18 16:56:15  peterg
## Now handles comments after IFS
##
## Revision 1.23  1998/11/18 14:38:01  peterg
## Now convert ALL globals to VAR .. the last one isn't repeated now
##
## Revision 1.22  1998/11/17 17:39:45  peterg
## Put _smx include at end of list (?????)
##
## Revision 1.21  1998/11/17 17:26:11  peterg
## Put sign.p first
##
## Revision 1.20  1998/10/01 16:01:09  peterg
## Now does implicit integration with switches
##
## Revision 1.19  1998/09/29 15:37:18  peterg
## Declare mttINPUT
##
## Revision 1.18  1998/08/27 08:55:40  peterg
## Mods to integration methods
##
## Revision 1.17  1998/08/27 07:38:40  peterg
## About to change to new integration (Euler/Implicit only)
##
## Revision 1.16  1998/08/19 08:46:00  peterg
## Now translates ; % to #
##
## Revision 1.15  1998/08/15 13:46:01  peterg
## Included new sparse update routines
##
## Revision 1.14  1998/08/12 15:21:12  peterg
## Added type definition for the SVD procedures
##
## Revision 1.13  1998/08/11 09:32:07  peterg
## Added comments at procedure begin and end.
##
## Revision 1.12  1998/07/30 11:30:42  peterg
## Included zeros function
##
## Revision 1.11  1998/07/29 14:18:34  peterg
## Reorganised rep dependednt output
##
## Revision 1.10  1998/07/27 20:26:15  peterg
## Added new VARs mttWSTEPS, MTTWMIN,mttWMAX
##
## Revision 1.9  1998/07/27 17:20:42  peterg
## Allow , between ()
##
## Revision 1.8  1998/07/26 19:38:17  peterg
## Replaced t0..t9 by mtt_temp0..
##
## Revision 1.7  1998/07/25 20:06:23  peterg
## Does the mtt_update function
##
## Revision 1.6  1998/07/25 16:59:40  peterg
## Give other procedures local i,j vars.
##
## Revision 1.5  1998/07/25 15:06:17  peterg
## Added DDT VAR
##
## Revision 1.4  1998/07/25 15:05:54  peterg
## DD
##
## Revision 1.3  1998/07/25 14:03:30  peterg
## Added () to [] conversion when the variable is i j k or an integer or
## combination
##
## Revision 1.2  1998/07/25 12:39:57  peterg
## begin on same line as for and if
##
## Revision 1.1  1998/07/25 09:42:52  peterg
## Initial revision
##
###############################################################



# Set up variables
args=`echo $1 | sed 's/_/ /' | sed 's/\./ /'`
Sys=`echo $args  | gawk '{print $1}'`
sys=`echo $Sys  | gawk '{print tolower($1)}'`
rep=`echo $args  | gawk '{print $2}'`
Sys_rep="$Sys""_""$rep"
Sys_smx="$Sys""_smx"
Sys_smxp="$Sys""_smx.p"
Filename="$Sys""_""$rep.p"
filename="$sys""_""$rep.p"

Method=$2; # The integration method
Stdin=$3;  # Using standard input

if [ -n "$Method" ]; then
  MethodBlurb=" with $Method integration method"
fi

if [ -n "$Stdin" ]; then
   StdinBlurb=" using standard input"
fi

# Inform user
  echo Creating $Filename $MethodBlurb $StdinBlurb 

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nxx=`mtt_getsize $Sys xx` # States x States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | gawk '{print $1}'`


#if [ "$rep" = "simpar" ]; then
#    mtt -q $Sys smx p
#fi

# Heading
(case $rep in
    state)
        echo "PROCEDURE $Sys_rep(VAR mttx : StateVector; 
                                     mttpar : ParameterVector);"
        ;;
    numpar)
        echo "PROCEDURE $Sys_rep(VAR mttpar : ParameterVector);"
        ;;
    simpar)
        echo "PROCEDURE $Sys_rep(VAR mttsimpar : SimulationParameters);"
        ;;
    input)
        echo "PROCEDURE $Sys_rep(VAR mttu : InputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mtty : OutputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    logic)
	echo "PROCEDURE $Sys_rep(VAR mttopen : StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    ode)
	echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    odeo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    csex)
	echo "PROCEDURE $Sys_rep(VAR mttedx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    cseo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"

	;;
    smx )
	echo "PROCEDURE $Sys_rep(VAR mtta       : StateMatrix;"
	echo "                   VAR mttax      : StateVector;"
	echo "                       mttx       : StateVector;"
	echo "                       mttu       : InputVector;"
	echo "                       mttdt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    smxa )
	echo "PROCEDURE $Sys_rep(VAR mtta       : StateMatrix;"
	echo "                       mttx       : StateVector;"
	echo "                       mttu       : InputVector;"
	echo "                       mttt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    smxax )
	echo "PROCEDURE $Sys_rep(VAR mttax      : StateVector;"
	echo "                       mttx       : StateVector;"
	echo "                       mttu       : InputVector;"
	echo "                       mttt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    ode2odes)
	echo "PROGRAM $Sys_rep;"
        echo ""
	echo "CONST"
	echo "    MTT_MaxParameters = 100;"
	echo "    MTT_Npar = $Npar;"
	echo "    MTT_Nx = $Nx;"
        echo ""
	echo "TYPE"
	echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"
	echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"
	echo "    OutputVector = ARRAY[1..$Ny] OF REAL;"
	echo "    ParameterVector = ARRAY[1..$Npar] OF REAL;"
	echo "    SimulationParameters = RECORD"
	echo "    dt, first, input, last, stepfactor, wmax, wmin, wsteps: REAL"
	echo "                           END;"
	echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;"
	echo "    StateMatrixVector  = ARRAY[1..$Nxx] OF REAL;"
	echo "    glnparray    = StateVector;"
	echo "    glmparray    = StateVector;"
	echo "    glnarray     = StateVector;"
	echo "    glnpbynp     = StateMatrix;"
	echo "    glmpbynp     = StateMatrix;"
	## echo "    IntegrationMethod = 1..4;"
	echo ""
	echo "VAR"
	echo "    simpar                      : SimulationParameters;"
        echo "    t,ddt                       : REAL;"
	echo "    x,x0,dx,AAx                 : StateVector;"
	echo "    mttx,mttdx,mttAAx,mttedx    : StateVector;"
	echo "    u,mttu                      : InputVector;"
	echo "    y,mtty                      : OutputVector;"
	echo "    par                         : ParameterVector;"
	echo "    mttpar                      : ParameterVector;"
	echo "    mttnpar                     : INTEGER;"
	echo "    AA,mtte                     : StateMatrix;"
	echo "    MTTi,MTTj,it,iLast: INTEGER;"
	##echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	## echo "    mttMETHOD : IntegrationMethod;"
	echo "    open_switches  : StateVector;"
	echo "    numparfile, statefile, simparfile  : TEXT;"
        strip_comments <${Sys}_switch.txt |\
          gawk '{printf("%s_logic : REAL;\n", tolower($1))}' 
	echo ""
        mtt_txt2declare $Sys sympar p
        mtt_txt2declare $Sys struc p
        ;;
#    switchopen)
#	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
#	echo "VAR"
#	echo "    MTTi,MTTj :  INTEGER;"
#	;;
    *)	echo "PROCEDURE $Sys_rep;"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
        ;;
esac) > $Filename

cat<<EOF >> $Filename

{*** System $Sys, rep $rep, language Pascal, file $Filename ***}
{*** Translated by MTT from $Sys_rep.m on `date` ***}

EOF

# Regexps
  name="[a-zA-Z0-9_]*"
  fun_name="$Sys\_$name"
  mttfun_name=$name
  tab='	'
  space="[ $tab]*"
  spaces="[ $tab][ $tab]*"
  non_space="[^ ]*"
  args='[a-zA-Z0-9,._"]*'

# Body	
fix_operators ()
{
    m_neq="(\!\=)|(\~\=)"
    m_not="\!"
    m__eq="\=\="

    p_neq="\<\>"
    p_not="NOT\ "
    p__eq="\="

    sed "s/$m_neq/$p_neq/g"	|\
    sed "s/$m_not/$p_not/g"	|\
    sed "s/$m__eq/$p__eq/g"
}

cat $Sys_rep.m |\
grep -v 'Remove in mtt_m2p'  |\
grep -v '^[ ]*function'  |\
grep -v '^[ ]*endfunction'  |\
grep -v 'MTT_data'  |\
sed "s/^$space%/#/" | sed "s/\([;)]$space\)%/\1#/" |\
gawk -F# '{printf("%s",$1) 
          if (NF>1) printf("{* %s *}", $2)
          printf("\n") 
         }' |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)/\2(\1)/" |\
sed "s/$space\($non_space\)$spaces=${spaces}zeros(\([0-9]*\),1)/zero_state(\1,\2)/" |\
sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/,)/)/" |\
fix_operators |\
gawk '
function printvar(Name,N) {
  if (N<1) return;
  width = 10;
  kk = 0; 
  for (k=1;k<=N;k++) {
    printf("mtt%s%i", Name, k);
    if (k==N)
      printf(" : REAL;\n")
    else
      printf(", "); 
    kk++;
    if (kk==width){printf("\n"); kk=0}
  }
}
BEGIN{
  comment_regexp = "{"
  doing_header = 0
  doing_globals = 0
  N_tmp = 100;
  inc ="$I"
}
{
  if ($1=="global") 
    doing_globals = 1
  else{ 
    if (doing_globals==1){
      global[++i]=$1; 
      if (match($0,";")==0){
      }
      else{
        doing_globals = 0
        doing_header = 1
      }
    }
    else 
    {
      if (doing_header==1){
        if (rep=="ode2odes"){
          printf("\n{%s $MTTPATH/trans/p/mtt_write.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_par_update.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/sign.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_euler.p}\n",inc)
          #printf("{%s $MTTPATH/trans/p/mtt_solve.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_implicit.p}\n",inc)
          #printf("{%s $MTTPATH/trans/p/zero_matrix.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_input.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_state.p}\n",inc)
          printf("{%s %s_simpar.p}\n",inc,Sys) 
          printf("{%s %s_numpar.p}\n",inc,Sys)
          # printf("{%s $MTTPATH/trans/p/mtt_getargs.p}\n",inc)
          printf("{%s %s_state.p}\n",inc,Sys)
          printf("{%s %s_input.p}\n",inc,Sys)

          if (Method=="euler") {
            printf("{%s %s_ode.p}\n",inc,Sys)
            printf("{%s %s_odeo.p}\n",inc,Sys)
          }
          if (Method=="implicit") {
            printf("{%s %s_csex.p}\n",inc,Sys)
            printf("{%s %s_cseo.p}\n",inc,Sys)
            printf("\n{%s %s_smxa.p}\n",inc,Sys);
            printf("\n{%s %s_smxax.p}\n",inc,Sys);
          }
          printf("{%s %s_logic.p}\n\n",inc,Sys)

          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN{%s}\n", Sys_rep)
          printf("  open(statefile,\"%s_state.dat\");\n", Sys)
          printf("  open(simparfile,\"%s_simpar.dat\");\n", Sys)
          printf("  open(numparfile,\"%s_numpar.dat\");\n", Sys)
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("VAR \n");
          for (k=1;k<i;k++) printf("  %s,\n",global[k])
          printf("%s : REAL;\n", global[i])
          printvar("x",Nx);
          printvar("u",Nu);
          printvar("y",Ny);
	  if ((rep=="ode")||(rep=="odeo")||(rep=="csex")||(rep=="cseo")||(rep=="smx")||(rep=="smxa")||(rep=="smxax")){
	    printvar("_tmp",N_tmp);
	    printvar("_s",N_tmp);
	  }
          printf("VAR mtt_i, mtt_j : INTEGER;\n");
          #if ( (rep=="smxa")||(rep=="smxax") ) {
          #  printvar("_t",Nt);
          #}
          printf("\nBEGIN{%s}\n", Sys_rep)
          if (rep=="smxa"){
            printf("FOR mtt_i:= 1 to %i DO\n\tFOR mtt_j:= 1 to %i DO\n\tmtta[mtt_i,mtt_j] := 0;\n", Nx,Nx);
          }
          if (rep=="smxax"){
            printf("FOR mtt_i:= 1 to %i DO\n\tmttax[mtt_i] := 0;\n", Nx);
          }
       }
        doing_header = 0;
      }
      if (match($1,comment_regexp)>0){
        if (doing_header==1)
          comment[++j] = $0
        else
          printf("%s\n", $0)
      }
      else {
        if ($1=="if") {
          sub(/==/, "=", $0)
            gsub(/&&/," AND ",$0)
            gsub(/\|\|/," OR ",$0)
          printf("%s THEN BEGIN\n", $0)
        }
        else { 
          #if ((match($1,"mtt_write")>0)&&(length(Stdin)>0)) {
          # sub(/mtt_write/, "if NOT eof THEN mtt_write");
          #}
          if ($1=="for"){
            if (($2=="it")&&(length(Stdin)>0)){
	      printf("WHILE NOT eof DO BEGIN {Integration loop}\n")
            }
            else {
              sub(/:/," TO ",$0)
              sub(/=/,":=",$0)
              printf("%s DO BEGIN\n", $0)
            } 
          }
          else{
            sub(/=/,":=",$0)
            sub(/endif/,"END;{IF}",$0)
            sub(/endfor/,"END;{FOR}",$0)
            sub(/elseif/,"END ELSEIF BEGIN",$0)
            sub(/else/,"END ELSE BEGIN",$0)
            gsub(/\^/,"**",$0)
            gsub(/&&/," AND ",$0)
            gsub(/\|\|/," OR ",$0)
            printf("%s\n",$0)
          }
        }
      }
    }
  }
}
END{
  if (rep=="def"){
    printf("EULER = 1,\n")
    printf("IMPLICITL = 2;\n")
    printf("IMPLICIT = 3;\n")
    }
    else
      if (rep=="ode2odes")
                printf("END{%s}.\n", Sys_rep)
      else
        printf("END{%s};\n", Sys_rep)
}' Sys=$Sys sys=$sys Sys_rep=$Sys_rep rep=$rep \
   Nx=$Nx Nu=$Nu Ny=$Ny Method=$Method Stdin=$Stdin |\
sed 's/\\$//'    |\
sed 's/(\([ijk0-9,]*\))/\[\1\]/g'    |\
sed 's/(\(MTT[ijk0-9],[0-9]*\))/\[\1\]/g' |\
sed 's/(\([0-9]*,MTT[ijk0-9]\))/\[\1\]/g' |\
sed 's/(\(MTT[ijk0-9],MTT[ijk0-9]\))/\[\1\]/g' |\
sed 's/(\(MTT[ijk0-9,]*\))/\[\1\]/g'  |\
sed 's/switcha(mttAA,/switcha(/g'   |\
sed 's/switch(MTTx,/switch(/g'  |\
sed 's/if nargin<[1-9] THEN//'  |\
sed 's/if nargin>[0-9] THEN//'  \
>> $Filename

# p2c doesn't like mixed case filenames!
#if [ "$Filename" != "$filename" ]; then
#  echo Creating $filename
#  cp -f $Filename $filename
#fi

if [ "$rep" = "ode2odes" ]; then
    # Explicitly include files
    mtt_pinclude $Filename>junk.p
    mv junk.p $Filename
fi



Added mtt/bin/trans/mtt_make_menu version [2bfaf2eae8].













































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_make_menu
# Creates tk/tcl menus for xmtt.
# Copyright (c) P.J.Gawthrop, 1998,1999

## Paths for its files
dotfile="$HOME/.mtt"
xdotfile="${dotfile}/xmtt"

repfile="${xdotfile}/reps"
exfile="${xdotfile}/examples"

#MTT blurb
title=`mtt --version`

#Collect all systems (inc dir name)
pwd=`pwd`;
dirname=`basename $pwd`
systems=`echo *_abg.fig | sed 's/\([a-zA-Z0-9]*\)_abg.fig/\1/g'`
dirname_in_systems=`echo $systems | grep -c $dirname`
if [ "$dirname_in_systems" = "0" ]; then
    systems="$systems $dirname"
fi

# Default system
system=$dirname

cat<<EOF
# Default system
set system "$system"

# Arguments to mtt
set args {-q}

# Default the again command
set mtt {mtt \$args warranty}

# The top level menu
button .mtt -text "$title \n Directory: $dirname \n NO WARRANTY \n (press for details)" -command "exec mtt warranty &"
menubutton .man -text "Manual" -menu .man.man
menubutton .util  -text "Utilities" -menu .util.util
menubutton .opt  -text "Options" -menu .opt.opt
menubutton .sys -text "Systems" -menu .sys.sys
menubutton .rep -text "Representations (major)" -menu .rep.rep
menubutton .repall -text "Representations (all)" -menu .repall.repall
menubutton .exam -text "Examples" -menu .exam.exam
#button .again -text "Again" -command "exec echo \$mtt &; exec \$mtt  &"
button .mtt_quit -text "Quit" -command exit
pack .mtt .exam .rep  .repall .sys  .util .opt  .man .mtt_quit

 
menu .man.man
.man.man add command -label "Browser (html)" -command "exec mtt -q hinfo &"
.man.man add command -label "Info" -command "exec xterm -e mtt -q info &"
.man.man add command -label "Text (ps)" -command "exec mtt -q manual &"

menu .util.util
# .mtt.opt.util add command -label "copy example" -command 
# .mtt.opt.util add command -label "copy" 
.util.util add command -label "clean" -command "exec mtt -q Clean &"
.util.util add command -label "recursive clean" -command "exec mtt -q rclean &"

menu .opt.opt


# System choice
menu .sys.sys
EOF

for sys in $systems; do
    echo .sys.sys add radio -label "{$sys}"  -command {set system "{$sys}"} 
done

# Create the options menu
mtt |  gawk '{
  if (Options) {
    option=substr($1,2);
    label="";
    if ($1 ~ /^-/) {
      for (i=2;i<=NF;i++)
        label = sprintf("%s %s",label,$i);
      printf(".opt.opt add check -label \"%s (-%s)\" -variable %s -command {set args \"$args -%s\" }\n", label, option, option, option); 
    }
  }
  if ($1=="Options:") Options = 1;
}'

# Examples menu
cat <<EOF
menu .exam.exam
EOF

echo '#' Examples menu
strip_comments <${exfile} | examples_txt2tk

# Representations menu
echo '#' Representations menu
cat<<EOF
menu .rep.rep
menu .repall.repall
EOF

strip_comments <${repfile}  | reps_txt2tk 

Added mtt/bin/trans/mtt_make_sim version [39947db7aa].






















































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

   ###################################### 
   ##### Model Transformation Tools #####
   ######################################


# Bourne shell script: mtt_make_sim
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.7  2000/05/19 17:47:35  peterg
## Fixed bug in oct version but still needs proper check
##
## Revision 1.6  2000/05/17 17:20:49  peterg
## Fixed bugs with ny>1. Could be made faster by not generating y when
## y_sim >1
##
## Revision 1.5  2000/05/17 16:01:42  peterg
## Fixed bug for n_y>1
##
## Revision 1.4  2000/05/16 18:57:15  peterg
## Still debugging
##
## Revision 1.3  2000/05/16 11:59:34  peterg
## Stard new version with data files not argv.
##
## Revision 1.2  2000/05/11 19:32:29  peterg
## Put in c version + sensitivity computation
##
## Revision 1.1  2000/04/08 10:43:26  peterg
## Initial revision
##
###############################################################

# Tell user
Sys=$1
method=$2
computation=$3

if [ -z "$method" ]; then
    method=implicit    
fi

if [ -n "$computation" ]; then
   blurb="for language $computation"    
fi

echo  "Creating $1_sim.m with $method integration method $blurb"

if [ $method = "implicit" ]; then
    ode=cse
    odeo=cseo
else
    ode=ode
    odeo=odeo
fi

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | gawk '{print $1}'`

# Header
lang_header -noglobals $1 sim m 'x0,u,t,par,sensitivities' '[y,ys]' > $1_sim.m

cat >> $1_sim.m <<EOF
##  tick=time; 
  if nargin<5
    sensitivities = [];
  endif;

  ##Sizes
  N = length(t);
  [n_u,N_u] = size(u);

  ## Doing sensitivities (assumes sensitivity system is invoked)
  n_sens = length(sensitivities);
  doing_sensitivities = (n_sens>0);
  if doing_sensitivities
    n_y = $Ny/2;
    doing_state=0;
    ys = [];
  else
    n_y = $Ny;
    doing_state=(nargout>1);
  endif;



  ## Initialise
  ui = zeros(n_u,1);	# Initial control
  [xi] = x0;	        # Read in initial state

  ## Timing parameters
  first = t(1);
  dt = t(2) - t(1);
  n_t = length(t);
  last = t(n_t);
EOF

if [ "$computation" = "c" ]; then
cat >> $1_sim.m <<EOF
  T = "";
  S = "";

  S = [S;"Save\t"];
  tim = time;

  ## Create the system input file
  t1 = [0:N_u-1]*dt; # Create time vector from zero (to fit u);
  ut = [t1' u'];
  save -text $1_input.dat ut 

  ## Create the state file
  xi = [[1:$Nx]' x0]; #'
  save -text   $1_state.dat xi

  ## Create the sympar file
  save -text   $1_simpar.dat dt

  ## Create the numpar file
  [n_par,m_par] = size(par);
  if m_par==1
    if n_par!=$Npar
      error(sprintf("Number of parameters is %i, should be %i", n_par, $Npar));
    else
      ipar= [[1:$Npar]' par]; #' 
    endif
  elseif m_par==2
    ipar = par;
  else
    error(sprintf("Number of parameter columns is %i, should be 1 or 2", m_par));
  endif;

  if !doing_sensitivities
      save -text   $1_numpar.dat ipar 
  endif;

  dtime = time-tim;
  T = [T; num2str(dtime)];

  ## main simulation loop
  n_sim = max(1,n_sens);
  for i_sim=1:n_sim
    i_1 = 2;

    if doing_state
      i_2 = i_1 + n_y - 1;
      i_3 = i_1 + n_y + 1;
      i_4 = i_1 + n_y + $Nx;
    else
      if doing_sensitivities
        i_2 = 1 + 2*n_y;
        ipars = [ipar; [sensitivities(i_sim) 1]];
        save -text   $1_numpar.dat ipars 
      else
        i_2 = i_1 + n_y -1;
      endif
    endif;

      if doing_state # Need to cut twice
        command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i,%i-%i | tail -%i;", i_1,i_2,i_3,i_4,n_t);
      else # not doing_state
        command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i | tail -%i;", i_1,i_2,n_t);
      endif

  ## Execute external programme
  S = [S;sprintf("Run %i\t",i_sim)];
  tim = time;
  yy_str=system(command);
  dtime = time-tim;
  T = [T; num2str(dtime)];

  ## Convert data
  S = [S;sprintf("Conv %i\t",i_sim)];
  tim = time;
  yy = str2num(yy_str)'; #'
  dtime = time-tim;
  T = [T; num2str(dtime)];


  [N_yy,M_yy] = size(yy);

  if i_sim==1
    if doing_sensitivities
      y = yy(1:n_y:2*n_y,:);              # Output
      ys = yy(2:n_y:2*n_y,:);
    else
      y = yy(1:n_y,:);
    endif;
    if doing_state 
      i_1 = n_y+1;
      i_2 = i_1 + $Nx - 1;
      ys = yy(i_1:i_2,:);
    endif;
  else # i_sim>1
    if doing_sensitivities
      ys =  [ys; yy(2:n_y:2*n_y,:)];
    endif; 
  endif

   endfor;
  ##RealTime = [S T]
endfunction

EOF
    
else

cat >> $1_sim.m <<EOF    
  A = zeros($Nx,$Nx);
  Ax = zeros($Nx,1);
  dx = zeros($Nx,1);

  ## Step size
  dt = t(2)-t(1);
  iFirst = first/dt;
  for i = 1:N
    ti = t(i);
    ui = u(:,i);
    yi = $1_cseo(xi,ui,ti,par);    # Output 
    y(:,i) = yi;
    x(:,i) = xi;
    dxi = $1_cse(xi,ui,ti,par); # State derivative
    A = $1_smxa(xi,ui,dt,par);	# (I-Adt)
    #A = reshape(A,$Nx,$Nx);
    Ax = $1_smxax(xi,ui,dt,par);	# (I-Adt)x
    #open = eval(sprintf("%s_switchopen(x);", system_name));        # Open switches
    #x = mtt_implicit(x,dx,A,Ax,dt,$Nx,zeros(20,1)); # Implicit update
    xi = A\(Ax + dxi*dt);        # Implicit update
  endfor;			

endfunction
EOF
fi

Added mtt/bin/trans/mtt_make_substruc version [39e2eb4e04].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

# Makes subsystem structure files for partitioning
# Copyright (C) 2000 by Peter J. Gawthrop

sys=$1
rep=$2
lang=$3

echo Creating structure files for subsystems
# Get subsystems
  subsystems=`mtt_get_subsystems -strip ${sys}`;

for subsystem in $subsystems; do
  grep $subsystem < ${sys}_struc.txt > ${sys}_${subsystem}_struc.txt
done

Added mtt/bin/trans/mtt_make_subsystems version [9acb3856cd].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

# Makes subsystems for partitioning
# Copyright (C) 2000 by Peter J. Gawthrop

sys=$1
rep=$2
lang=$3

echo Creating subsystem representations for ${sys}_${rep}.${lang}
# Get subsystems
  subsystems=`mtt_get_subsystems -strip ${sys}`;

for subsystem in $subsystems; do
    
mtt $options -u -q -sub $subsystem ${sys} ${rep} ${lang}
    ## Repeating systems need sorting out !!!!
    #cp $1_$subsystem"_"$2.$3 $1_$subsystem"_1_"$2.$3
done

Added mtt/bin/trans/mtt_make_sympar version [ce08d18b4a].












































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_make_sympar
# Makes the sympar.txt file
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2004/09/02 22:06:09  geraint
## Does not issue warnings about Reduce reserved words if the
## second argument (use_reduce) is "no".
##
## Revision 1.11  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.10  2001/07/28 21:10:18  geraint
## Generate warning instead of error if reserved word used.
##
## Revision 1.9  2001/07/23 05:16:39  geraint
## Simple filter for Reduce reserved words in sympar.
##
## Revision 1.8  2001/07/04 06:00:12  gawthrop
## Fixed a funny with tr - changed SEPS and REPS - something to do with ^
##
## Revision 1.7  2001/04/13 07:14:12  geraint
## Implemented lower level lbl.txt recognition of #NOT[V|P]AR
##
## Revision 1.6  2001/04/10 12:54:50  gawthrop
## Minor fixes for sensitivity versions
##
## Revision 1.5  2000/11/03 14:57:06  peterg
## Corrected regexp notvar
##
## Revision 1.4  2000/11/02 18:53:46  peterg
## Added NOPAR words to unwanted list.
##
## Revision 1.3  2000/10/16 09:41:29  peterg
## Fixed bug with printing a blank line.
##
## Revision 1.2  2000/10/16 09:10:08  peterg
## Now strips out "unwanted" bits frome the _aliased.txt file
##
## Revision 1.1  2000/10/12 19:24:28  peterg
## Initial revision
##
##
###############################################################


sys=$1 # System name
filename=$1_sympar.txt

use_reduce=$2

# Inform user
echo Creating $filename

# Create list of all sympars including those that are aliased
sh $1_type.sh 'echo ' ' ' ' ' |\
gawk '{printf("abg2sympar_m2txt %s %s\n ", $1, $2)}' |\
sh | sort -u > mtt_all_sympar.txt

# Sort the aliased list
mtt_strip_args < $1_aliased.txt | sort -u  > mtt_aliased_sort.txt

# Create list of unwanted stuff
cat  mtt_aliased_sort.txt> mtt_unwanted.txt

notvar="[%|#]NOT[V|P]AR";
sh $1_type.sh 'strip_notvars.sh ' ' ' ' mtt_unwanted.txt'

sort -u mtt_unwanted.txt > mtt_unwanted_sort.txt

# Compare it with the aliased list and show the differences
diff mtt_all_sympar.txt mtt_unwanted_sort.txt |\
gawk '{if ($1=="<") printf("%s\t%s\n", $2,$3)}' > mtt_sympar.txt

# Assume same name in different system is the same
gawk '{
    if ($1==name){
	sysname[i++]=$2
    }
    
    if ($1!=name){
        if (length(name)>0){
          printf("%s\t",name)
          comma="";
          for (j=1;j<=i;j++){
            printf("%s%s", comma, sysname[j]);
            comma=",";
          }
          printf("\n")
        }
        i=1;
        sysname[1]=$2;
    }
    name = $1
}
END{
        printf("%s\t",name)
        comma="";
        for (j=1;j<=i;j++){
          printf("%s%s", comma, sysname[j]);
          comma=",";
        }
        printf("\n")

}' < mtt_sympar.txt >$filename

if [ ! "${use_reduce}" = "no" ]; then
    reserved_words=`\
    cat ${MTT_LIB}/reduce/reserved_words.txt	|\
    gawk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
    sympar_words=`\
    cat ${filename}				|\
    cut -f1					|\
    gawk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
    flag=0
    for reserved_word in ${reserved_words}; do
	for sympar_word in ${sympar_words}; do
	    if [ ${sympar_word} = ${reserved_word} ]; then
		echo ""
		echo "*** MTT Warning:"
		echo "    ${sympar_word} is reserved (Reduce)"
		echo ""
	    fi
	done
    done
fi

Added mtt/bin/trans/mtt_mend_lines version [0579d4ac5f].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

# Copyright (C) 2000 by Peter J. Gawthrop

# Fixes broken lines from reduce.

#sed 's/[^#]\(.*\)[^;]$/\1\\/' 

gawk '{
  if ((match($1,"#")==0)&&(match($1,"global")==0)&&(match($1,"endfunction")==0)) {
    if(match($0,";")!=length($0))
      printf("%s \\\n",$0)
    else
      print $0
  }
  else print $0
   
}'

Added mtt/bin/trans/mtt_multi version [cdd0534fee].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

# Does mutiple commands down the hierarchy

command=$1
system=$2
rep=$3
lang=$4
relative_level=$5

current_level=`echo $system | gawk '{N=split($1,foo,"_"); print N-1}'`

if [ -z "$relative_level" ]; then
  relative_level=0;    
fi

mtt_xargs.sh "ls" "$2*_$3.$4"  |\
gawk '{
  level=split($1,foo,"_")-2;
  maxlevel = current_level +  relative_level;
  if (level<=maxlevel) print command, $0, "&";
'} command=$command relative_level=$relative_level current_level=$current_level

Added mtt/bin/trans/mtt_name2array version [3800132da3].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_name2array

# Generates array elements from names
# Copyright (C) 2000 by Peter J. Gawthrop


case $2 in
    numpar)
        name=mttpar
	cat $1_sympar.txt>mtt_infile
	;;
    state)
        name=mttx
	gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    input)
        name=mttu
	gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    *)
	echo Repesentation $2 not supported
esac

case $3 in
    zero)
	  strip_comments <mtt_infile | grep "$filter"  |\
          gawk '{
          i++; printf("  %s = 0.0;\n", tolower($1));
          }'
	;;
    set)
	  strip_comments <mtt_infile  |\
         gawk '{
           i++; printf("  %s(%i)\t= %s;\n", name, i, tolower($1));
         }' name=$name
        ;;
    *)
         strip_comments <mtt_infile  |\
         gawk '{
           i++; printf("  %s \t= %s(%i);\n", tolower($1), name, i);
         }' name=$name
	;;
esac




Added mtt/bin/trans/mtt_optimise version [ed8d518642].





























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

# script uses Reduce + Scope to optimise a vector
# either global (an entire vector) or local (line-by-line)

extent=$1			# global or local
system=$2
representation=$3

# error codes
E_REP_NOT_SUPPORTED=-19
E_FILE_NOT_EXIST=-20

case $representation in
    ae)
	matrix=yz ;
	nmatrix=`mtt_getsize $system yz` ;;
    csex)
	matrix=edx ;
	nmatrix=`mtt_getsize $system x` ;;
    ode)
	matrix=dx ;
	nmatrix=`mtt_getsize $system x` ;;
    cseo | odeo)
	matrix=y ;
	nmatrix=`mtt_getsize $system y` ;;
    *)
	exit $E_REP_NOT_SUPPORTED;;
esac

# Global optimisation: Generate a command of the form
# optimise mtt?(1,1) :=: mtt?(1,1), mtt?(2,1) :=: mtt?(2,1), ..., INAME mtt_tmp$
#
# Local optimisation: Generate a command of the form
# optimise mtt?(1,1) :=: mtt?(1,1) INAME mtt_tmp$ \
# optimise mtt?(2,1) :=: mtt?(2,1) INAME mtt_tmp$ ...
case $extent in
    "global" )
	delimiter=", "
	terminate="INAME mtt_tmp$"
	;;
    "local" )
	delimiter=" INAME mtt_tmp$ optimize"
	terminate="$"
	;;
    * )
	echo "*** unknown scope for optimisation"
	echo "*** should be global or local"
	exit -1
	;;
esac

if [ $nmatrix -gt 0 ]; then
    command="optimize"
    counter=1
    while [ $counter -le $nmatrix ]; do
	command="$command mtt$matrix($counter,1) :=: mtt$matrix($counter,1)$delimiter"
	counter=`expr $counter + 1`
    done
    command="$command $terminate"
else
    command=""
fi

logfile=${system}_${representation}_optimisation.log
tmpfile=${system}_${representation}_optimisation.tmp
outfile=${system}_${representation}.r

if [ ! -f $outfile ]; then
    exit $E_FILE_NOT_EXIST
fi

find_code ()
{
    file_in=${1:-${IN}}
    portion=${2:-"body"}
    head=`cat ${file_in} | gawk '($2 == "Begin" && $3 == "Matrix") { print NR }'`
    foot=`cat ${file_in} | gawk '($2 == "End"   && $3 == "Matrix") { print NR }'`
    case ${portion} in
	head)
	    start=0
	    end=${head}
	    ;;
	body)
	    start=${head}
	    end=${foot}
	    ;;
	foot)
	    start=${foot}
	    end=end
	    ;;
	*)
	    echo "Error in find_code: portion unknown"
	    return -1
	    ;;
    esac
    cat ${file_in} |\
    gawk --assign start=${start} --assign end=${end} '
	(start < NR && NR < end) { print $0 }'
};


# Use Reduce to perform the optimisation
${SYMBOLIC:-reduce} <<EOF > $logfile 2>&1
off nat;
in "${system}_def.r";
in "$outfile";
load scope;
out "$tmpfile";
$command;
shut "$tmpfile";
$end;
EOF

cp $outfile $outfile.unoptimised
cp $tmpfile $outfile.tmp

find_code $outfile head > $tmpfile.head
cat $tmpfile | mtt_fix_integers > $tmpfile.body
find_code $outfile foot > $tmpfile.foot
cat $tmpfile.head $tmpfile.body $tmpfile.foot > $outfile
echo ";end;" >> $outfile

mtt_error_r $logfile

Added mtt/bin/trans/mtt_p2C version [4c8ad0a9b3].




































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: p2C

# Pascal to a c program - intermediate step for mtt_p2oct
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	


sys_rep="$1_$2"
begin="BEGIN{$sys_rep}"

# Inform user
# echo "Creating $1_$2.pas"

# Find system constants
Nx=`mtt_getsize $1 x`
Nxx=`mtt_getsize $1 xx`
Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

Npar=`wc -l $1_sympar.txt | gawk '{print $1}'`


echo "PROCEDURE $1_$2;" > $1_$2.pas
echo "TYPE"             >>$1_$2.pas
echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"        >>$1_$2.pas
echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;" >>$1_$2.pas
echo "    StateMatrixVector  = ARRAY[1..$Nxx] OF REAL;" >>$1_$2.pas
echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"        >>$1_$2.pas
echo "    OutputVector  = ARRAY[1..$Ny] OF REAL;"       >>$1_$2.pas
echo "    ParameterVector  = ARRAY[1..$Npar] OF REAL;"  >>$1_$2.pas


# Create the predefined vars
echo "VAR"     >>$1_$2.pas
gawk '{
       printf("%s,", $1)
     }
     END{print "JUNK : REAL;"}'< $1_sympar.txt     >>$1_$2.pas

if [ "$2" = "ode2odes" ]; then
    first='PROCEDURE'
    gawk '
    {
    if (writing) print $0;
    if (i++==0) writing=1
    if (match($1,"PROCEDURE")==1) writing=0;
    }'  < $1_$2.p >>$1_$2.pas
else
    first='BEGIN'

 # Convert VAR format in the headings
    gawk 'BEGIN{writing=1}
    {
    if (match($1,"BEGIN")==1) writing=0;
    if (writing) print $0;
    }'  < $1_$2.p | \
    sed \
	-e 's/PROCEDURE [a-zA-Z_0-9]*(VAR/VAR/' \
	-e 's/PROCEDURE [a-zA-Z_0-9]*;//' \
	-e 's/REAL);/REAL;/' \
	-e 's/OutputVector);/OutputVector;/' \
	-e 's/ParameterVector);/ParameterVector;/' \
	>>$1_$2.pas
fi

# Write out the actual code until the begining of the procedure
gawk 'BEGIN{writing=0}
{
  if (match($1,first)==1) writing=1;
  if (writing) print $0;
  if (match($1,begin)==1) writing=0;

}' begin=$begin first=$first   < $1_$2.p  >>$1_$2.pas

# Write out the parameters
echo {Parameters}   >>$1_$2.pas
gawk '{
       printf("  %s \t:= mttpar[%i];\n", $1, ++i);
     }'< $1_sympar.txt  >>$1_$2.pas

# Write out the actual code from the end of the procedure
gawk 'BEGIN{writing=0}
{
  if (writing) print $0;
  if (match($1,begin)==1) writing=1;
}' begin=$begin   < $1_$2.p  >>$1_$2.pas

#echo "Creating $1_$2.C"
p2c -o $1_$2.C $1_$2.pas > mtt_p2C.log 2>> mtt_p2C.log


Added mtt/bin/trans/mtt_p2c version [d5850baa69].
































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_p2c
# Pascal to c converter for MTT
# Uses the wonderful GNU p2c by  Dave Gillespie, daveg@csvax.cs.caltech.edu.    
# P.J.Gawthrop July 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/04/11 07:36:10  gawthrop
## Now uses system_cr.h in place of system.h in .c rep -
##   compatible with older code
##
## Revision 1.11  2001/03/29 19:24:14  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.10  2000/09/15 09:01:41  peterg
## Updated internal comments
##
## Revision 1.9  2000/05/16 18:56:58  peterg
## Now realised that libp2c.a avoids many probs - so simplified it.
##
## Revision 1.8  2000/05/11 19:34:50  peterg
## *** empty log message ***
##
## Revision 1.7  1999/08/29 06:14:27  peterg
## No longer remove "PASCAL_MAIN"
##
## Revision 1.6  1999/04/20 06:17:15  peterg
## Fudge to avoid a bizzare bug (?) in p2c which corrupts "zero_matrix"
##
## Revision 1.5  1998/08/12 14:14:18  peterg
## Added pretty heading and explicitly include p2c header.
##
## Revision 1.4  1998/07/29 13:56:34  peterg
## Replces p2c include by local include.
##
## Revision 1.3  1998/07/27 20:32:51  peterg
## Now gives immediate warnings
##
## Revision 1.2  1998/07/25 16:35:43  peterg
## Sorted out log files etc
##
## Revision 1.1  1998/07/25 16:28:38  peterg
## Initial revision
##
###############################################################


# Options
info=''
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;
                ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

## Create p2crc with various configs.
cat > p2crc <<EOF
EatNotes [221]   # No warning messages about symbols
EOF

# Inform user
echo Creating $1_$2.c

# Use p2c to do the translation 
p2c -V  $1_$2.p  | grep Warning # > mtt_p2c.log 2>> mtt_p2c.log
cat $1_$2.log >> mtt_p2c.log
mv $1_$2.c mtt_junk.c

# Change p2c.h include.
#mv $1_$2.c mtt_junk1#
#cat mtt_junk1 | grep -v 'p2c/p2c.h'> mtt_junk2

# pretty heading
DATE=`date`

cat <<EOF  >$1_$2.c
/* C program  $1_$2.c */
/* Generated by MTT on $DATE */

/* Compile with gcc -lm -lp2c $1_$2.c -o $1_$2.out */
/* Note that p2c must be correctly installed so that p2c.h and libp2c.a are accessible */

/* Header file for user-defined crs (implemented in c) */ 
#include "$1_cr.h"
EOF

#cat<<EOF >>$1_$2.c
#/* The following is the header file included here for completeness */
#EOF

#cat $MTTPATH/trans/c/p2c.h >> $1_$2.c

#cat <<EOF >> $1_$2.c
#/* End of the header file. */
#
#
#EOF

## The sed item is to avoid a bizzare bug (?) in p2c which corrupts "zero_matrix"
###cat mtt_junk2 | sed 's/zero_matrix/mttmat/g'>> $1_$2.c

## Sort out the pascal EOF, PASCAL_MAIN etc
cat mtt_junk.c |\
 grep -v PASCAL_MAIN >> $1_$2.c

if [ -n "$info" ]; then
    cat mtt_p2c.log
fi

# Remove the garbage
rm -f mtt_junk.c

Added mtt/bin/trans/mtt_p2cc version [9cd1ab95be].
























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_p2cc

# Pascal to .cc (for octave .oct files).
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	

## Extract the system and rep names.
sys=`mtt_sysname $1` 
rep=`mtt_repname $1` 
sys_rep=$sys"_"$rep

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Inputs 

# Create the representation code
mtt_p2C $sys $rep

# Inform user
echo Creating $sys_rep.cc

# Create the c++ code
# Heading
date=`date`

cat > $sys_rep.cc <<EOF
#include <octave/oct.h>

DEFUN_DLD ($sys_rep, args, ,
	   "Usage: $sys_rep(x,u,t,par)\n$sys_rep was generated by MTT on $date")
{
  ColumnVector mttx = args(0).vector_value ();
  ColumnVector mttu = args(1).vector_value ();
  double mttt = args(2).double_value ();
  ColumnVector mttpar = args(3).vector_value ();

EOF

case "$rep" in
    ode)
	echo "  ColumnVector mttdx ($Nx);" >> $sys_rep.cc
	;;
    odeo)
	echo "  ColumnVector mtty ($Ny);" >> $sys_rep.cc
	;;
    cse)
	echo "  ColumnVector mttdx ($Nx);" >> $sys_rep.cc
	;;
    cseo)
	echo "  ColumnVector mtty ($Ny);" >> $sys_rep.cc
	;;
    smx | smxa | smxax)
        Nxx=`echo "$Nx*$Nx" | bc`
	echo "  Matrix mtta ($Nx,$Nx);" >> $sys_rep.cc
	echo "  ColumnVector mttax ($Nx);" >> $sys_rep.cc
	;;
    *)
	
esac

#Extract Type info
echo '/* Types */'                >> $sys_rep.cc
grep typedef $sys_rep.C              >> $sys_rep.cc

#Extract the rep code converting [] to () and deleting mtt variables etc
#The awk part detects the begin and end of the relevant code.
echo "/* Representation $rep information */" >> $sys_rep.cc
gawk '{
  if ( (match($1,"}")==1)&&(NF>1)) writing=0;
  if ( (writing) && !(match($2,"mtt[a-z]")==1) ) print $0;
  if (match($1,"{")==1) writing=1;
}' <$sys_rep.C |\
sed 's/\[\([a-z0-9_]*\)\]\[\([a-z0-9_]*\)\]/(\1,\2)/g' |\
sed 's/\[\([a-z_0-9]*\)\]/(\1)/g' >> $sys_rep.cc

# Tail
cat >> $sys_rep.cc <<EOF

EOF

case "$rep" in
    ode)
        echo "return octave_value (mttdx);" >> $sys_rep.cc;
	;;
    odeo)
        echo "return octave_value (mtty); " >> $sys_rep.cc;
	;;
    cse)
        echo "return octave_value (mttdx);" >> $sys_rep.cc;
	;;
    cseo)
        echo "return octave_value (mtty); " >> $sys_rep.cc;
	;;
    smxa)
        echo "return octave_value (mtta); " >> $sys_rep.cc;
	;;
    smxax)
        echo "return octave_value (mttax); " >> $sys_rep.cc;
	;;
    *)
	
esac

# Terminating }
echo "}" >> $sys_rep.cc;

# Convert to octave loadable code
#echo Creating $sys_rep.oct
#mkoctfile $sys_rep.cc

Added mtt/bin/trans/mtt_p2m version [a6fa5071b9].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
## Chages the Pascal output from gentran to octave form
# Copyright (C) 2000 by Peter J. Gawthrop

sed 's/begin$//' |\
sed 's/end$//' |\
sed 's/end;$/;/' |\
sed 's/\[\([0-9,]*\)\]/(\1)/g' |\
sed 's/:=/ = /' |\
sed 's/\*\*/\^/g' |\
sed 's/mtt\([a-z]\)\([a-z]*\)\([0-9]\)\([0-9]*\)/mtt\1\2(\3\4)/g' |\
gawk '{
  sub(/^[\ ]*/, "", $0)
  sub(/\$$/, ";", $0)
  
  if (match($NF,"[;#.%]$")==0){
    Previous[++i] = $0
  }
  else {
    for (j=1;j<=i;j++) printf("%s", Previous[j]);
    printf("%s\n", $0) 
    i=0;
  }
}' |\
sed 's/#/%/g'

Added mtt/bin/trans/mtt_pdf.sty version [9e3fc0e565].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Style file for postscript document

\usepackage{mtt} % Common stuff

% Figure definition
\newcommand{\fig}[4]{
  \begin{figure}[htbp]
    \begin{center}
      \fbox{
        \pdfimage width #3\linewidth {#1.pdf}
        %\includegraphics[width=#3\linewidth]{#1.ps}
        }
        \caption{#4}
      \label{fig:#2}
    \end{center}
  \end{figure}
  }

% Hyper stuff
\usepackage[implicit=true,
            bookmarks=true,
            pdfauthor={MTT},
            pdftitle={MTT report},
            pdfsubject={MTT},
            pdfkeywords={MTT, bond graphs}]{hyperref}

Added mtt/bin/trans/mtt_pinclude version [2dabecc7a7].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
# pinclude - explicitly includes Pascal files - p2c has probs. doing this

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:56:46  peterg
## Put under RCS
##
###############################################################



gawk ' {
  if ( (match($1,"{\\$I")>0) || (match($1,"\\*\\$I")>0) ) {
    sub(/}/,"",$2); 
    command=sprintf("mtt_pinclude %s",$2); 
    system(command)
  }
  else{
  print $0
  }
  

}' <$1

Added mtt/bin/trans/mtt_prepend.sh version [83feb02b68].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

usage ()
{
cat <<EOF

Usage: $0 [-p] file1 file2

       prepend file1 to file2
    
    options:

      -p preserves time attribute

EOF
}

preserve=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-p)
	    preserve='-p'
	    ;;
	-h)
	    usage
	    exit
	    ;;
	 *)
	    echo "Error: invalid option ($1)"
	    usage;
	    exit;
	    ;;
    esac
    shift
done

if [ $# -ne 2 ]; then
    usage;
    exit;
fi

file1=$1
file2=$2
tmp=mtt_prepend.sh_$file1_$file2.tmp

if [ ${preserve:=""} = "-p" ]; then
    time=mtt_prepend.sh_$file2.time
    touch -r $file2 $time
fi

cat $file1 $file2 > $tmp

if [ ${preserve:=""} = "-p" ]; then
    touch -r $time $tmp
    rm $time
fi

cp $preserve $tmp $file2
rm $tmp

Added mtt/bin/trans/mtt_ps.sty version [54d658c739].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Style file for postscript document

%%\usepackage{mtt} % Common stuff (Needs to be explicit now)

%Postscript figures 
\usepackage{graphicx,color}

% Figure definition
\newcommand{\fig}[4]{
  \begin{figure}[htbp]
    \begin{center}
      \fbox{
        \includegraphics[width=#3\linewidth,height=18cm,keepaspectratio]{#1.ps}
        }
        \caption{#4}
      \label{fig:#2}
    \end{center}
  \end{figure}
  }

  \newcommand{\tfig}[4]{
    \begin{figure}[htbp]
      \begin{center}
        \fbox{
          \resizebox{#3\linewidth}{!}{\input{#1}}
        }
        \caption{#4}
        \label{fig:#2}
      \end{center}
    \end{figure}
  }


% Hyper stuff
\usepackage[implicit=true,
            bookmarks=true,
            pdfauthor={MTT},
            pdftitle={MTT report},
            pdfsubject={MTT},
            pdfkeywords={MTT, bond graphs}]{hyperref}

Added mtt/bin/trans/mtt_r2m version [0603bb581c].

















































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_r2m
# Reduce to octave conversion
# Based on obsolete ode_r2m  and ode_r2lang
# Based on obsolete mtt_r2m_old
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95, May 1998
# July 1998
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996, 1998
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.33  2004/08/29 03:17:02  geraint
## Vectorise sesx and sesy.
##
## Revision 1.32  2003/04/17 20:07:33  geraint
## Added rule to create _sese.m
##
## Revision 1.31  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.30.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.30  2002/03/26 11:59:54  geraint
## Added dummy -optimise switch to prevent falling over for -cc generation.
##
## Revision 1.29  2001/09/07 00:25:56  geraint
## Partial fix for insidious bug which eliminates lines of code when parameter
## names of the form (in* or off*) start continuation lines.
##
## Revision 1.28  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.27.4.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.27  2001/02/08 00:39:56  geraint
## Removed clear from code generated by: mtt -c -i euler -o
##
## Revision 1.26  2000/11/27 11:52:10  peterg
## Changed some greps to be case insensitive
##
## Revision 1.25  2000/10/14 08:50:07  peterg
## Use new mtt_header
##
## Revision 1.24  2000/10/11 09:07:53  peterg
## Vectorisation
## csex rep.
##
## Revision 1.23  2000/10/10 21:00:43  peterg
## More reps added
##
## Revision 1.22  2000/09/15 08:27:07  peterg
## Removed debugging lines
##
## Revision 1.21  2000/08/30 11:43:40  peterg
## -optimise switch added
##
## Revision 1.20  2000/08/30 10:43:17  peterg
## Simplified version using GENTRAN matrix :=: matrix
## lang_matrix is no longer used at all
##
## Revision 1.19  2000/08/28 20:17:59  peterg
## Put in Winfried Neun's bug fix
## -- prevents segmentation violation using optimised gentran when matrix
## comtains a number
##
## Revision 1.18  2000/08/24 17:11:40  peterg
## Now optimises as well as segmenting - uses the SCOPE package
##
## Revision 1.17  2000/05/20 15:23:56  peterg
## Paramererised version of sm etc etc (using -parameter switch)
##
## Revision 1.16  2000/04/18 11:14:18  peterg
## Put in the -parameters option
##
## Revision 1.15  2000/02/10 14:58:57  peterg
## *** empty log message ***
##
## Revision 1.14  1999/12/08 02:06:00  peterg
## Now incudes csm rep.
##
## Revision 1.13  1999/11/23 00:59:14  peterg
## Now does ssm.m
##
## Revision 1.12  1999/11/15 22:57:20  peterg
## Removed a debugging line
##
## Revision 1.11  1999/11/01 21:20:14  peterg
## Removed the E matrix from the cse file.
##
## Revision 1.10  1999/10/27 07:38:30  peterg
## Now does cse version -- but not needed now exept for Euler integration
##
## Revision 1.9  1999/10/26 23:47:58  peterg
## Now does cse.m file
##
## Revision 1.8  1999/07/26 06:07:19  peterg
## Reinstated removal of the odeo.p file
##
## Revision 1.7  1999/03/16 00:38:06  peterg
## Done some more tidying up
##
## Revision 1.6  1999/03/15 07:29:25  peterg
## Fixed various obscure reduce bugs
## THIS NEEDS A MAJOR REWRITE!!!!
##
## Revision 1.5  1998/08/13 16:25:07  peterg
## Removed some documentation form odeo.m
##
## Revision 1.4  1998/08/13 15:10:47  peterg
## Change temp var name to mtt_t1 etc
##
## Revision 1.3  1998/08/13 12:43:19  peterg
## Cahnged tmp variable to mtt_1 etc
##
## Revision 1.2  1998/07/27 20:26:44  peterg
## Put in correct N and M values for dm rep
##
## Revision 1.1  1998/07/27 16:30:26  peterg
## Initial revision
##
###############################################################


# Args
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
    -noglobals)
	noglobals='-noglobals';
	;;
    -parameters)
	parameters='-parameters';
        par='mttpar'
	;;
    -optimise_local | -optimise_global )
	;;
    *)
	echo $1 is an unknown option
        exit;;
  esac
  shift
done

# Set up some strings
rep=$2
ext=m
out=$1"_"$rep.$ext

#Inform user
echo Creating $out

# Remove the old log file
rm -f mtt_r2m.log

#Header
case $rep in
    ae|csex|cseo|ode|odeo|sae|sese|sesx|sesy)
    vectorise=yes
       ;;
    *)
esac

    mtt_header  $1 $rep $ext  > mtt_junk

#Convert from the (optimised) r file
echo >> mtt_junk
echo '## Code' >> mtt_junk
strip_comments<$1_$2.r |\
tr [A-Z] [a-z] |\
grep -vi 'MATRIX ' |\
grep -vi 'END;' |\
grep -vi 'clear mtt' |\
grep -v '^off .*\$' |\
grep -v '^in .*\$' |\
sed \
    -e "s/^mtt/  mtt/" \
    -e "s/:=/=/" \
    -e "s/\\$/;/" \
 >> mtt_junk
echo '## END Code' >> mtt_junk
echo endfunction >> mtt_junk

# Mend broken lines
mtt_mend_lines < mtt_junk > mtt_junk_mended
# Vectorise (n,1) arrays when appropriate
if [ -n "$vectorise" ]; then
     mtt_vectorise <mtt_junk_mended >$out
else
     mv mtt_junk_mended $out
fi

# Now invoke the standard error handling.
#mtt_error_r mtt_r2m.log



Added mtt/bin/trans/mtt_remove_underscore version [539a78771f].




1
2
3
+
+
+
#!/bin/sh

sed 's/_/\\_/g'

Added mtt/bin/trans/mtt_repname version [bde7d0e306].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_repname

# Returns the representation name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | tr '.' '_' | gawk -F '_' '{print $2}'

Added mtt/bin/trans/mtt_strip_args version [bcb8540542].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: strip args
# Strips unwanted bits from a list of arguments
# Label file to symbolic parameters conversion
# Copyright (C) 2000 by Peter J. Gawthrop

## $Id$  ##
## $Log$
## Revision 1.6  2001/07/04 06:00:12  gawthrop
## Fixed a funny with tr - changed SEPS and REPS - something to do with ^
##
## Revision 1.5  2001/06/13 14:50:13  gawthrop
## Operator ^ now ok in args in abg and/or lbl
##
## Revision 1.4  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.3  2000/10/17 12:33:13  peterg
## Added mtt_mod to the zapped list
##
## Revision 1.2  2000/10/16 09:06:26  peterg
## Write out the system as a second columns as well
##
## Revision 1.1  2000/10/16 09:04:04  peterg
## Initial revision
## ##
# Inform user
#echo "Creating $1_sympar.txt"

# Separation characters
SEPS='^=*;+/()-'
# Replace by ,
REPS='[,*]'


# This is the main transformation using gawk
tr $SEPS $REPS | \
gawk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
}

BEGIN {
 not_an_arg = "effort flow state internal external zero unknown\
                mtt_e mtt_f\
		sqrt exp log sign sin asin cos acos tan atan \
		sin asin cos acos tan atan \
		sinh asinh cosh acosh tanh atanh \
                none abs";
}
{
    args=$1
    sys=$2
    N=split(args, arg, ",");
    for (i=1;i<=N;i++){
      if ( (length(arg[i])>0)&&(matches(not_an_arg,arg[i])==0)&&(match(arg[i],"^[0-9]+[.]*")==0) ){
        printf("%s\t%s\n", arg[i], sys);
      }
  }
}' |\
grep -v '^\$' 



Added mtt/bin/trans/mtt_sysname version [4a73c625bc].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_sysname

# Returns the system name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | gawk -F '_' '{print $1}'

Added mtt/bin/trans/mtt_txt2declare version [63bdb9c744].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2declare

# Symbolic parameters to variable declaration
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/10/14 09:32:50  peterg
## struc version only does state and input
##
## Revision 1.1  2000/10/14 09:26:48  peterg
## Initial revision
##
## Revision 1.1  2000/10/11 09:08:20  peterg
## Initial revision
##

###############################################################

sys=$1
what=$2
language=$3

case $language in
    p)
        first="VAR";
        delim=", ";
        last=': REAL;';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

case $what in
    struc)
	strip_comments < $sys"_"$what".txt" | gawk '{if (($1=="state")||($1=="input"))
                                                      print $4;
                                                   }' >mtt_names
	;;
    sympar)
      	strip_comments < $sys"_"$what".txt" | gawk '{print $1}' >mtt_names
	;;
    *)
	echo Argument 2 must be struc or sympar
esac

# Start
cat<<EOF
$first
EOF
#Write out the variables 
gawk '{
  i++; 
  var[i] = tolower($1);
}
END{
  n = i;
  for (i=1; i<n; i++){
    printf("%s%s",var[i], delim);
    j++; 
    if (j>4){
    printf("\n"); j=0;
    }
  }
  printf("%s%s\n",var[n], last);

}' "delim=$delim" "last=$last" mtt_names


Added mtt/bin/trans/mtt_txt2m version [46dbec9921].





































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_txt2m
# Converts txt file to matlab file (for numpar and state)

# Copyright (c) P.J.Gawthrop 1998


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.17  2002/04/28 18:41:27  geraint
# %% Fixed [ 549658 ] awk should be gawk.
# %% Replaced calls to awk with call to gawk.
# %%
# %% Revision 1.16  2002/04/18 17:51:11  gawthrop
# %% Put default values in _simpar.m in case of missing values in txt file
# %%
# %% Revision 1.15  2002/03/26 12:00:37  geraint
# %% Escaped characters to eliminate awk warnings.
# %%
# %% Revision 1.14  2001/07/13 04:54:04  geraint
# %% Branch merge: numerical-algebraic-solution back to main.
# %%
# %% Revision 1.13.4.2  2001/07/09 00:24:58  geraint
# %% input rep: Removed input name mapping, left state name mapping.
# %%
# %% Revision 1.13.4.1  2001/06/26 01:01:28  geraint
# %% Makes input and state names available for input rep.
# %%
# %% Revision 1.13  2001/02/05 03:33:18  geraint
# %% Convert user-defined txt to lower-case in translation.
# %% Required by logic.m (Octave is case sensitive).
# %%
# %% Revision 1.12  2000/11/08 11:20:49  peterg
# %% removed the empty matrix stuff
# %%
# %% Revision 1.11  2000/10/17 09:55:21  peterg
# %% Added logic rep
# %%
# %% Revision 1.10  2000/10/15 09:51:50  peterg
# %% Set array code in input rep
# %%
# %% Revision 1.9  2000/10/13 11:07:33  peterg
# %% Started conversion to new style state, input ext
# %%
# %% Revision 1.8  2000/09/30 13:53:07  peterg
# %% Default to empty matix in numpar.m -- avoids probs for parameter-free systems
# %%
# %% Revision 1.7  2000/05/19 17:46:17  peterg
# %% Give argument to state
# %%
# %% Revision 1.6  2000/05/19 14:59:03  peterg
# %% MTT --> mtt in fun output
# %%
# %% Revision 1.5  2000/05/19 14:05:10  peterg
# %% Zero parameters in the numpar.m file
# %%
# %% Revision 1.4  2000/05/18 12:05:42  peterg
# %% Replaced sympar by sympars in numpar rep
# %%
# %% Revision 1.3  2000/05/11 16:09:24  peterg
# %% Put in simpar.first parameter
# %%
# %% Revision 1.2  2000/05/11 12:16:46  peterg
# %% New version of simpar - with record
# %%
# %% Revision 1.1  2000/05/11 10:55:57  peterg
# %% Initial revision
# %%
# %% Revision 1.19  2000/02/11 13:35:16  peterg
# %% Added the new MTTpar generation
# %%
# %% Revision 1.18  1999/11/14 22:22:17  peterg
# %% Removed checks for implicit - now done at command-line level.
# %%
# %% Revision 1.17  1999/11/04 04:54:24  peterg
# %% Removed recreation of smx file.
# %%
# %% Revision 1.16  1999/03/06 02:18:10  peterg
# %% Changed argument list.
# %%
# %% Revision 1.15  1999/02/16 21:44:38  peterg
# %% Revised smx generation
# %%
# %% Revision 1.14  1999/02/16 04:38:22  peterg
# %% Now forces creation of _smx file if METHOD=IMPLICIT in simpar.txt
# %%
# %% Revision 1.13  1998/08/31 11:43:37  peterg
# %% Now lower cases globals in numpar files
# %%
# %% Revision 1.12  1998/08/14 10:47:31  peterg
# %% Put ImplicitS sub before Implicit!!
# %%
# %% Revision 1.11  1998/08/14 10:43:44  peterg
# %% Added ImplicitS - sparse integration
# %%
# %% Revision 1.10  1998/08/11 13:27:51  peterg
# %% Lowercase mttLAST etc
# %%
# %% Revision 1.9  1998/07/30 15:07:17  peterg
# %% Added _ to the disallowed chars around t
# %%
# %% Revision 1.8  1998/07/30 12:52:38  peterg
# %% Adds ; to end of statements
# %% Translates ' to " before removal
# %%
# %% Revision 1.7  1998/07/30 09:32:33  peterg
# %% Replaces:
# %% 	euler by 1
# %% 	implicitl by 1
# %% 	implicit  by 3
# %%
# %% Revision 1.6  1998/07/27 18:59:11  peterg
# %% Added WMIN etc
# %%
# %% Revision 1.5  1998/07/26 11:54:20  peterg
# %% Added  mtt to variables
# %%
# %% Revision 1.4  1998/07/26 09:50:12  peterg
# %% More forgiving of txt sytax.
# %%
# %% -- can use () or ()
# %% -- can use mttx() or x()
# %% -- can use mttu() or u()
# %%
# %% Revision 1.3  1998/07/25 20:40:35  peterg
# %% All vars in lower case now
# %%
# %% Revision 1.2  1998/07/25 09:48:31  peterg
# %% Tidied up for Pascal version
# %%
# %% Revision 1.1  1998/02/25 22:10:25  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

system=$1
representation=$2
outfile=$1_$2.m

tolower () { tr [A-Z] [a-z] ;}

# Inform user
echo Creating $outfile

#Create the rep  file complete with headers.
case $representation in
    input)
      name=mttu
      arraycode=$representation
      ;;
    logic)
      name=mttx
      ;;
    numpar)
       name=mttpar
      arraycode=$representation
      ;;
    simpar)
      ;;
    state)
      name=mttx
      arraycode=$representation
      ;;
    *)
      echo Representation $representation not supported
      exit
      #echo "function $name = $1_$2$arg" > $outfile
      #echo "%% $2 file ($1_$2.m)" >> $outfile
      #echo "%% Generated by MTT at `date`" >> $outfile
      #echo "% Global variable list" >>  $outfile
      #sympar2global_txt2m $1 >> $outfile
      ;;
esac

# Generate the header
mtt_header $system $representation m  > $outfile

## Special for logic rep
if [ "$representation" = "logic" ]; then
  echo >> $outfile
  echo "## Inputs" >> $outfile
  mtt_name2array $system input >> $outfile # Set up input by name
  echo >> $outfile
  echo "## States" >>$outfile
  mtt_name2array $system state >> $outfile # Set up state by name
fi

## Special for input rep
if [ "$representation" = "input" ]; then
  echo >> $outfile
  echo "## States" >>$outfile
  mtt_name2array $system state >> $outfile # Set up state by name
fi

## Special for simpar rep
if [ "$representation" = "simpar" ]; then
  cat >> $outfile<<EOF

## Defaults (in case of missing values in txt file)
  mttsimpar.first       =  0.0;      
  mttsimpar.last        =  10.0;      
  mttsimpar.dt          =  0.1;        
  mttsimpar.stepfactor  =  1;          
  mttsimpar.wmin        =  -1;         
  mttsimpar.wmax        =  2;          
  mttsimpar.wsteps      =  100;        
  mttsimpar.input       =  1; 

EOF
fi

# Write out the code from the txt file
echo >> $outfile
echo "## User defined code from $1_$2.txt" >> $outfile
cat  $1_$2.txt | strip_comments | grep -v METHOD |\
gawk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");
  if (N==2) {
    LHS = a[1];
    RHS = a[2];
    gsub(quote, doublequote, RHS);
    sub(/^[ 	]*FIRST/, "MTTsimpar.FIRST", LHS);
    sub(/^[ 	]*DT/, "MTTsimpar.DT", LHS);
    sub(/^[ 	]*LAST/, "MTTsimpar.LAST", LHS);
    sub(/^[ 	]*STEPFACTOR/, "MTTsimpar.STEPFACTOR", LHS);
    sub(/^[ 	]*METHOD/, "MTTsimpar.METHOD", LHS);
    sub(/^[ 	]*WMIN/, "MTTsimpar.WMIN", LHS);
    sub(/^[ 	]*WMAX/, "MTTsimpar.WMAX", LHS);
    sub(/^[ 	]*WSTEPS/, "MTTsimpar.WSTEPS", LHS);
    sub(/^[ 	]*INPUT/, "MTTsimpar.input", LHS);
    LHS = tolower(LHS);
    RHS = tolower(RHS);
    sub(/["]*euler["]*/, 1, RHS);   
    sub(/["]*implicit["]*/, 2, RHS);  
    statement = sprintf("%s= %s",LHS,RHS);
    if ( (match(statement,";")==0)&&\
         ((match(statement,"if ")==0))&&\
         ((match(statement,"for ")==0)) )
      statement = sprintf("%s;", statement);
  }
  else if (match($1,"global")==1) {
    statement = tolower($1); # Lower case globals as well
  }
  else
    statement = $1;

  if (NF<2) print "  " statement
  if (NF>1)  print statement " # " $2
}' | sed\
     -e 's/\[\([0-9]*\)\]/(\1)/g' \
     -e 's/\([^a-zA-Z_0-9]\)t\([^a-zA-Z_0-9]\)/\1mttt\2/g' \
     -e 's/\([^a-zA-Z_0-9]\)x(/\1mttx(/g' \
     -e 's/\([^a-zA-Z_0-9]\)u(/\1mttu(/g' \
     -e 's/mttmtt/mtt/g' \
| tolower >> $outfile

if [ -n "$arraycode" ]; then
  new_style=`strip_comments < $1_$2.txt| grep "$name(">/dev/null; echo $?`

  if [ "$new_style" = "1" ]; then
    echo >> $outfile
    echo "  ## Set up the $name vector"  >> $outfile
    ## echo "  $name = []; # Default to empty matrix (Remove in mtt_m2p)"  >> $outfile
    mtt_name2array $1 $arraycode set   >> $outfile
  else
    echo "Old-style file detected: not creating array translations"  
  fi
fi

## Special for logic rep
if [ "$representation" = "logic" ]; then
  echo >> $outfile
  echo "## Open switches" >> $outfile
  switch_txt2m $system | tolower >> $outfile
fi

# End of the function
echo '## END Code' >> $outfile
echo 'endfunction' >> $outfile

Added mtt/bin/trans/mtt_uncompress.sh version [164628bbec].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

file=$1

gzip --test --quiet $file 2> /dev/null ; file_is_uncompressed=$?

if [ $file_is_uncompressed -eq 0 ]; then
    gz=`mktemp $file.gz.tmpXXXXXX`
    mv $file $gz
    zcat $gz > $file
fi

Added mtt/bin/trans/mtt_units.sh version [40d4f9eae3].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## MTT units script - wrapper for the units program.

# Copyright (C) 2000 by Peter J. Gawthrop

# Arguments
sys=$1
port=$2
domain=$3
effort=$4
flow=$5

case ${domain} in
    electrical)
	base_effort=volt
	base_flow=amp
	;;
    translational)
	base_effort='newton'
	base_flow='m/s'
	;;
    rotational)
	base_effort='newton*m'
	base_flow='radian/s'
	;;
    fluid)
	base_effort='Pa'
	base_flow='m^3/s'
	;;
    thermal)
	base_effort='degK'
	base_flow='watt/degK'

	;;
    *)
	echo ${sys} ${port} DOMAIN_ERROR invalid domain ${domain}
	exit 1
esac

get_unit()
{
  if [ "$2" == "none" ]; then
      echo 1
  else
      factor=`units $2 $3 | head -1 | sed 's/\*//'`
      if [ `echo $factor | wc -w` = "1" ]; then
	  echo $factor
      else
	  echo $1_UNIT_ERROR unit $2 not compatible with domain ${domain}
      fi
  fi
}
## Check effort and flow for comptability + find factor
effort_factor=`get_unit EFFORT $effort $base_effort`
flow_factor=`get_unit FLOW $flow $base_flow`

echo ${sys} ${port} ${effort_factor} ${flow_factor}

Added mtt/bin/trans/mtt_update version [62e70479ff].






















































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_update
# Generates Updates core representations
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.23  2005/02/17 18:54:23  geraint
## Fixed a bash-sim: replaced let with $(( ))
##
## Revision 1.22  2003/08/19 13:08:44  gawthrop
## Ingnore if/endif
##
## Revision 1.21  2003/08/14 10:33:46  gawthrop
## Ignore if and endif
##
## Revision 1.20  2003/08/13 15:49:39  gawthrop
## Don't sort the states when defaulting - leave in implied order
##
## Revision 1.19  2003/08/05 15:29:36  gawthrop
## Now handles ss.r files with implicit zero values
##
## Revision 1.18  2003/08/04 09:10:30  gawthrop
## Now handles steady-state computation for _state.txt.
##
## Revision 1.17  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.16  2000/10/17 13:45:18  peterg
## split up state and input - different defaults
##
## Revision 1.15  2000/10/17 09:53:05  peterg
## More on logic rep
##
## Revision 1.14  2000/10/17 08:36:56  peterg
## Included logic rep.
##
## Revision 1.13  2000/10/15 09:27:13  peterg
## Better way of generating $infofile
##
## Revision 1.12  2000/10/14 16:11:00  peterg
## Made all variables, states etc lower case
##
## Revision 1.11  2000/10/13 11:07:00  peterg
## Added initialisation for state and input
##
## Revision 1.10  2000/10/13 10:56:07  peterg
## Now uses the full name from the struc file - no need to recreate.
##
## Revision 1.9  2000/10/13 09:55:09  peterg
## Changed state/input name to $4_$3
##
## Revision 1.8  2000/10/13 09:28:16  peterg
## Changed regexp to /\(.*$old.*=\)/
##
## Revision 1.7  2000/10/13 08:56:51  peterg
## Output variables as column, not row.
##
## Revision 1.6  2000/10/13 08:07:24  peterg
## Added state and input - it checks against sympar as well so that
## defined variables may be used here.
##
## Revision 1.5  2000/10/12 19:24:55  peterg
## Corrected output message
##
## Revision 1.4  2000/10/12 17:57:34  peterg
## Fixed header typos
##
## Revision 1.3  2000/10/12 15:11:30  peterg
## Added the update switch
##
## Revision 1.2  2000/10/12 13:45:13  peterg
## Put in the no-file version
##
## Revision 1.1  2000/10/12 12:32:23  peterg
## Initial revision
##
##
###############################################################


sys=$1 # System name
rep=$2 # System representation
update=$3 # Update or not
date=`date`

if [ -z "$2" ]; then
  echo Usage mtt_update system representation [update]    
  exit
fi

## Extract initial value from steady-state information
initial_value() {
    i=$1
    default=$2
    ssfile=${sys}_ss.r
    if [ "${rep}" = "state" ]; then
       if [ -f "${ssfile}" ]; then
	count=`grep -c "^MTTx($i" ${ssfile}`; # See if its there
	if [ $count = "1" ]; then
	    value=`grep "^MTTx($i" ${ssfile}| sed 's/ //g' | gawk -F '=' '{print substr($2,1,length($2)-2)}'`	    
	else
	    value="0.0"
	fi
       else
	value=${default}   
       fi 
    else
	value=${default}
    fi
}

## Remove if, end and endif from list
remove_if() {
    file=$1
    if [ -f ${file} ]; then
      tmpfile="$1_tmp"
    
      mv ${file} ${tmpfile}
      grep -v 'if[ (]\|endif;' <${tmpfile} > ${file} 

      ## Delete empty file
      size=`ls -s ${file} | awk '{print $1}'`
      if [ "${size}" = "0" ]; then
	  rm $file
      fi
    fi
 }
 rm -f mtt_empty
 touch mtt_empty

 case $rep in
     numpar)
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=$1_sympar.$lang
	     moreinfofile=$infofile
	     default='1.0'
	 ;;
     input)
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=mtt_list.$lang
	     moreinfofile=mtt_list_numpar.$lang
	     gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
	     <$1_struc.txt >$infofile
	     cat $infofile $1_sympar.$lang> $moreinfofile  
	     default='1.0'
	  ;;
     state)
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=mtt_list.$lang
	     moreinfofile=mtt_list_numpar.$lang
	     gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
	     <$1_struc.txt >$infofile
	     cat $infofile $1_sympar.$lang> $moreinfofile  
	     default='0.0'
	  ;;
     logic) 
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=mtt_list.$lang
	     moreinfofile=mtt_list_numpar.$lang
	     gawk '{if ($3=="MTT_SWITCH") printf("%s_logic\n", $4)}' rep=$2 \
	     <$1_struc.txt >$infofile
	     cat $infofile $1_sympar.$lang> $moreinfofile  
	     default='1.0'
	 ;;
     *)
	     echo Representation $rep not implemented
	     exit
 esac

 # Create a string containing the variables
 if [ -f "$textfile" ]; then
   # Inform User
   echo Checking $textfile
 else
   echo Creating $textfile
   mtt_header $sys $rep $lang > $textfile 
     if [ "${rep}" = "state" ]; then
	 info=`cut -f1 $infofile` # No sort
     else
	 info=`cut -f1 $infofile | sort` # Sort
     fi
   i=0;
   for new in $info; do
     i=$(( $i + 1 ));
     initial_value $i ${default}
     echo $new $value  |\
     gawk '{printf("%s\t= %s; # Default\n",$1,$2)}' >> $textfile
   done
   exit    
 fi

 # Remove tmp files
 rm -f mtt_in_text mtt_in_info

 # Strip files
 strip_comments <$textfile | tr 'A-Z' 'a-z' >mtt_text
 strip_comments <$infofile | tr 'A-Z' 'a-z' >mtt_info
 strip_comments <$moreinfofile  | tr 'A-Z' 'a-z' >mtt_moreinfo

 # Use awk to check file
 gawk '{
   if (FILENAME=="mtt_text") {
     gsub("[\t ]" ,""); # Remove whitespace
     split($0,a,"=");
     text[a[1]] = a[2];
   }
   if (FILENAME=="mtt_info"){
      info[$1] = Default;
   }
   if (FILENAME=="mtt_moreinfo"){
      moreinfo[$1] = Default;
   }
   }
 END{
   # for (iname in info) print iname
   for (tname in text) {
     if (!(tname in moreinfo)) print tname >> "mtt_in_text"
   }
   for (iname in info) {
     if (!(iname in text)) print iname >> "mtt_in_info"
   }
   }'  Default=$default mtt_text mtt_info mtt_moreinfo

 ## Remove if, end and endif from list
 remove_if mtt_in_text

if [ -z "$update" ]; then
  if [ -f "mtt_in_text" ]; then
    echo "The following variables are defined in $textfile, but do not exist:"
    sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  if [ -f "mtt_in_info" ]; then
    echo "The following variables exist, but are not defined in $textfile:"
    sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  exit    
fi
answered=''
if [ -f "mtt_in_text" ]; then
  in_text=`sort mtt_in_text`
  echo "The following variables are defined in $textfile, but do not exist:"
  sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'


  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)
	    answered=yes
 	    for old in $in_text; do
              echo Commenting out $old
	      sed "s/\(.*$old.*=\)/## Removed by MTT on $date: \1/I"\
               <$textfile > mtt_tmp
              mv mtt_tmp $textfile
              changed=yes
	    done
	    ;;
	n)
	    answered=yes
	    ;;
	*)
    esac
  done      
fi

answered=''
if [ -f "mtt_in_info" ]; then
  echo "The following variables exist, but are not defined in $textfile:"
  sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'

  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)
	    answered=yes
            in_info=`sort mtt_in_info`
 	    for new in $in_info; do
                echo Adding $new
                echo $new $default  |\
                gawk '{printf("%s\t= %s; # Added by MTT on %s\n",$1,$2,strftime())}'\
                >> $textfile
                changed=yes
	    done
	    ;;
	n)
	    answered=yes
	    ;;
	*)
    esac
  done      
fi

Added mtt/bin/trans/mtt_vectorise version [637c205a0e].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
#!/bin/sh
# Vectorises the matrix output of reduce ie converts (n,1) to (n)
# Copyright (C) 2000 by Peter J. Gawthrop

sed 's/mtt\([a-z]*\)(\([0-9]*\),1)/mtt\1(\2)/g'


Added mtt/bin/trans/multi_command version [b29c24f12c].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: multi_command

# Copyright (c) P.J.Gawthrop 1996.

# creates a list of commands - one for each file matching $2_*_$3
# Each command is of the form $1 $2_*_$3 &

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2.4.1  2001/06/28 22:58:27  geraint
## Using mtt_xargs.sh to prevent Arg list too long error.
##
## Revision 1.2  1996/11/09 21:16:06  peterg
## *** empty log message ***
##
# Revision 1.1  1996/10/21  12:31:40  peterg
# Initial revision
#
###############################################################


(mtt_xargs.sh "ls" "$2*_$3" \
| sed "s/\(.*_*\)$3/$1 \1$3 \&/")

Added mtt/bin/trans/n2m version [408bb45747].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: n2m
# Gives sting of integers from n to m (n<=m)
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

i=`expr $1 - 1`

while [ "$i" != "$2" ]; do
    i=`expr $i + 1`
    echo $i
done

Added mtt/bin/trans/name2index version [f7933c91d6].




























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: name2index

# Converts names to array index

# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/11/27 18:06:33  peterg
## *** empty log message ***
##
## Revision 1.4  1997/12/04 22:10:18  peterg
## Handles argument list - variable names.
##
## Revision 1.3  1997/05/22 09:42:48  peterg
## Returns 0 if no names.
##
## Revision 1.2  1997/05/22 09:28:22  peterg
## Removed trailing , in output.
##
## Revision 1.1  1997/05/22 08:48:21  peterg
## Initial revision
##
###############################################################

gawk '
{
  name_index[$4]=$2;
}
END{
  M=split(names,xynames,":");
  if (M==0)
    printf("0\n")
  else
    {
    if (M==1) 
      printf("1,");
    else {  
        printf("%i,",name_index[xynames[1]]+1);
        names=xynames[2]
       }

    N=split(names,Names,",");
    for (i=1; i<N; i++)
      printf("%i,",name_index[Names[i]]+1);
  printf("%i\n",name_index[Names[N]]+1);
  }
}'  names=$2 < $1_struc.txt

  

Added mtt/bin/trans/numpar2subs_txt2r version [7658495930].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
## Makes algebraic substitution file from numpar file.
## Omitting all parameter in 2nd argument

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  2002/11/14 05:48:53  gawthrop
  ## Useful utility not yet in mtt
  ##
  ###############################################################

# Copyright (C) 2002 by Peter J. Gawthrop

sys=$1
pars=$2

outfile=${sys}_subs.r
infile=${sys}_numpar.txt

echo Creating ${outfile} from ${infile}
cat<<EOF > ${outfile}_1
%% File ${outfile} generated on `date` from  ${infile}
%% All parameters replaced by numbers except for:
%%   ${pars}

EOF

sed 's/#/%/g' < ${infile} | sed 's/=/:=/' >> ${outfile}_1

cat >> ${outfile}_1 <<EOF
ON ROUNDED; %% Floating point
END;
EOF

gawk '
{
N=split(pars,par);
matched=0;
for (i=1;i<=N;i++)
  if ($1==par[i]) 
    matched=1;

if (!matched) print $0
}' pars="$pars" < ${outfile}_1 > ${outfile}

rm ${outfile}_1

Added mtt/bin/trans/numpar_txt2c version [c7bf2ec183].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: numpar_txt2c

# Numerical parameters to c format
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2000/12/28 12:52:13  peterg
## *** empty log message ***
##
## Revision 1.5  1997/06/13 09:42:25  peterg
## Auto change of () to []
##
# Revision 1.4  1997/05/15  08:33:07  peterg
# Declare state array (x).
#
# Revision 1.3  1997/05/03  15:01:42  peterg
# Don't write out RCS headers.
#
# Revision 1.2  1997/05/01  08:35:18  peterg
# # is now the comment symbol in the .txt file
#
# Revision 1.1  1997/05/01  08:25:31  peterg
# Initial revision
#
###############################################################

system=$1
representation = $2

# Inform user
echo "Creating $1_numpar.c"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_numpar.c
echo "Parameter file for system $1 ($1_numpar.c)"   >> $1_numpar.c
echo "This file provides the system numerical parameters in c form"  >> $1_numpar.c
echo "Generated by MTT at `date`"  >> $1_numpar.c
echo '*/' >> $1_numpar.c
echo  >> $1_numpar.c

echo "extern double x[MTTNX1];"  >> $1_numpar.c
echo "#include \"$1_sympar.c\""  >> $1_numpar.c
echo "$1_numpar()" >> $1_numpar.c
echo '{' >> $1_numpar.c

#Write out the variables in c format.
sed 's/#C-CODE //'< $1_numpar.txt |\
gawk -F#  '{
  if (NF<2) print $1
  if (NF>1)  print $1 "/* " $2 " */"
}' | sed 's/(\([0-9]*\))/[\1]/'  >> $1_numpar.c

echo '}'  >> $1_numpar.c


Added mtt/bin/trans/numpar_txt2m version [73ccf44327].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: numpar_txt2m
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:52:22  peterg
## *** empty log message ***
##
## Revision 1.3  1998/07/25 18:26:33  peterg
## *** empty log message ***
##
# Revision 1.2  1997/05/01  08:24:38  peterg
# Now uses # as the comment symbol in the .txt file
#
# Revision 1.1  1997/05/01  07:45:17  peterg
# Initial revision
#
###############################################################

# Inform user
echo Creating $1_numpar.m

#Create the numpar file complete with headers.
lang_header $1 numpar m '' MTTpar > $1_numpar.m

# Global variable list
#echo  >>  $1_numpar.m
#echo "# Global variable list" >>  $1_numpar.m
#sympar2global_txt2m $1 >> $1_numpar.m

#Write out the variables in m format.
gawk -F#  '{
  if (NF==1) print $1
  if (NF==2)  print $1 "# " $2
}' $1_numpar.txt |\
sed 's/double/global/' >> $1_numpar.m


Added mtt/bin/trans/obs_r2m version [1411db277c].









































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: obs_r2m
# Reduce GPC obs function to matlab
# P.J.Gawthrop 18 May 1991, 12 Jan 1994, April 1994, Dec 1994, July 1995
# Copyright (c) P.J.Gawthrop 1991, 1994.

# Inform user
echo Creating $1_obs.m

# Remove the old log file
rm -f obs_r2m.log
rm -f $1_obs.m?
rm -f $1_obsa.m

# Is the system affine (look in the _obs.r file
affine=`grep 'affine :=' $1_obs.r | gawk '{print $3}' | sed 's/;//'`


# Use reduce to accomplish the transformation
$SYMBOLIC >obs_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Set default values - reset by obspar file.
MTTGPCNy := 2;
MTTGPCNu := 0;

%Read the parameters file
in "$1_obspar.r";

%Read the simplification file
in "$1_simp.r";

%Read the reduce state-space equations   file
in "$1_obs.r";


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
OFF Nat;

ON NERO;        % Suppress zero elements

% Matrix output function
in"$MTTPATH/trans/matlab_matrix.r";

OUT "$1_obs.m2";

write "% Set up the State variables";
FOR i := 1:MTTNx DO
BEGIN
  write "mttx", i, " = x(", i, ");";
END;

IF affine=0 THEN 
BEGIN
write "%"; 
write "% Set up the inputs and input derivatives";
FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ",1);";
    FOR j := 1:MTTGPCNu DO
    BEGIN
      write "mttu", i,j, " = u(", i, ",", j+1, ");";
    END;
  END;

%write "%"; 
%write "% Set up the Y matrix";
%write "Y = zeros(", mtt_matrix_n, ",1);";
END;


SHUT "$1_obs.m2";

IF affine=1 THEN 
BEGIN
  GENTRANOUT "$1_obs.m3";
  MTT_Matrix := MTTObs_o$ 
  MTT_Matrix_name := "MTTO_o"$
  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN O_o := mtt_matrix;

  MTT_Matrix := MTTObs_h$ 
  MTT_Matrix_name := "MTTO_h"$
  MTT_Matrix_n := (MTTGPCNy+1)*MTTNy$
  MTT_Matrix_m := (MTTGPCNu+1)*MTTNu$
  matlab_Matrix()$
  GENTRAN O_h := mtt_matrix;

  GENTRANSHUT "$1_obs.m3";
END
ELSE
BEGIN
  GENTRANOUT "$1_obs.m3";
  mtt_matrix := MTTYY$
  mtt_matrix_n := MTTNY*(MTTGPCNy+1)$
  mtt_matrix_m := 1$
  mtt_matrix_name := Y$
  matlab_matrix(); 
  GENTRAN YY := mtt_matrix;
  GENTRANSHUT "$1_obs.m3";
END;

EOF

if [ "$affine" = "1" ]; then
    lang_header $1 obs m x [o_o,o_h] > $1_obs.m1
else
    lang_header $1 obs m x,u yy > $1_obs.m1
fi

# Put together the pieces
matlab_tidy $1_obs.m2
matlab_tidy $1_obs.m3
cat   $1_obs.m? >$1_obs.m

rm -f $1_obs.m?







Added mtt/bin/trans/obs_r2tex version [f36c171b61].





























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: obs_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/04/07 08:30:20  peterg
## Initial revision
##
# Revision 1.3  1997/06/13  13:50:11  peterg
# Matrices in amstex format
#
# Revision 1.2  1997/04/18  12:54:00  peterg
# No longer does labels.
#
# Revision 1.1  1996/08/19  15:19:23  peter
# Initial revision
#
###############################################################


# Inform user
echo Creating $1_obs.tex

# Remove the old log file
rm -f obs_r2tex.log

# Use reduce to accomplish the transformation
reduce >obs_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the obs file
in "$1_obs.r";

%Read the Obs function parameters
in "$1_obspar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification parameters
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;

OUT "$1_obs.tex";

% Write the affine form
IF affine=1 THEN 
BEGIN
  MTT_Matrix := MTTObs_o$ 
  MTT_Matrix_name := "MTTO_o"$
  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
  MTT_Matrix_m := 1$
  LaTeX_Matrix()$

  MTT_Matrix := MTTObs_h$ 
  MTT_Matrix_name := "MTTO_h"$
  MTT_Matrix_n := (MTTGPCNy+1)*MTTNy$
  MTT_Matrix_m := (MTTGPCNu+1)*MTTNu$
  LaTeX_Matrix()$
END
ELSE
BEGIN
% Write the obs vector (YY)
  MTT_Matrix := MTTYY$ 
  MTT_Matrix_name := "MTTO"$
  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
  MTT_Matrix_m := 1$
  LaTeX_Matrix()$
END;

SHUT "$1_obs.tex";
quit;
EOF

Added mtt/bin/trans/octave_ode2odes version [abe17462de].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: octave_ode2odes
# Runs the Octave script $1_ode2odeso.m
# Copyright (c) P.J.Gawthrop 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2005/04/26 22:52:26  geraint
## The Octave load/save -ascii option is deprecated in favour of -text
##
## Revision 1.5  2002/05/07 10:13:48  gawthrop
## Files marked by update as out of sync
##
## Revision 1.4  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.3  2000/05/19 17:47:56  peterg
## Agument to state
##
## Revision 1.2  2000/05/11 13:43:14  peterg
## No change
##
## Revision 1.1  1999/03/15 23:27:16  peterg
## Initial revision
##
###############################################################


echo Creating $1_odes.dat2
$MATRIX  <<EOF >octave_ode2odes.log 2>mtt_error.txt
  ## Set up the simulation parameters
  par = $1_numpar; 
  x_0  =  $1_state(par);
  simpar = $1_simpar
  mtt_data = $1_ode2odes(x_0,par,simpar); 
  if iscomplex(mtt_data)
    mtt_error("octave_ode2odes: Simulated data is complex - something is wrong!");
    mtt_data = real(mtt_data);
  endif;
  save -text $1_odes.dat2 mtt_data
EOF

mtt_error mtt_error.txt

Added mtt/bin/trans/ode2obs_r version [117332d406].






























































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2obs_r
# Odrinary differential equations to observer function equations
# P.J.Gawthrop 14 June 1991, 8 Aug 1991, 2 April 1992, 14 April 1994, 28 Dec 94,
#               12th July 1995, April 1996
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1998/04/07 08:12:12  peterg
## Added affine form.
##
## Revision 1.4  1998/04/07 05:45:12  peterg
## Reverted to an older version due to untraceable bug in new version
##
## Revision 1.3  1996/08/25 10:07:05  peter
## Remove a du state ment causaing touble
##      - but needs more work.
##
## Revision 1.2  1996/08/25 08:38:14  peter
## Error handling added.
##
## Revision 1.1  1996/08/25 08:37:44  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_obs.r

# Remove the old log file
rm -f ode2obs_r.log

# Use reduce to accomplish the transformation
reduce >ode2obs_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;
ON NERO;

in "$1_def.r";
MTTdxs := MTTdX;  %Save the symbolic form of dX

%Set default values - reset by obspar file.
MTTGPCNy := 2;
MTTGPCNu := 0;

%%in "$1_sympar.r";
in "$1_ode.r";
%%in "$1_simp.r";

% Read the obs form parameters.
in "$1_obspar.r";

%Create the U vector of input derivatives.
MTTNuu := (MTTGPCNu+1)*MTTNu;
MTTNuu1 := MTTGPCNu*MTTNu;


%FOR i := 1:MTTNu DO
%  MTTUU(i,1) := MTTU(i,1);
%END;
%
%IF MTTGPCNu>0 THEN
%BEGIN
%  FOR i := 1:MTTNu DO
%    MTTUU(i+MTTNu,1) := MTTdU(i,1);
%  END;
%END;

MTTU := MTTU;
MTTdU := MTTdU; % ---- removed temporarily, needs def file change? 

%Create the Y vector of output derivatives.
MTTNyy := (MTTGPCNy+1)*MTTNy;
Matrix MTTYY(MTTNyy,1);

FOR i := 1:MTTNy DO
  MTTYY(i,1) := MTTY(i,1);
END;

l := MTTNy;
FOR i := 1:MTTGPCNy DO
    FOR j := 1:MTTNy DO
    BEGIN
      l := l+1;
      MTTYY(l,1) := 0;
      FOR k := 1:MTTNx DO %Derivatives wrt x
      BEGIN
        xk := MTTX(k,1);
        MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l-MTTNy,1), xk, 1)*MTTdX(k,1);
      END;
      IF MTTGPCNu>0 THEN
      FOR k := 1:MTTGPCNu DO %Non-zero derivatives of u
      BEGIN
        FOR kk := 1:MTTNu DO
        BEGIN
          uk := MTTUU(kk,k);
          MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l,1), uk, 1)*MTTUU(1,k+1);
        END;
      END;
    END;
END;

%%Create O_x - derivative of YY wrt x
%Matrix MTTO_x(MTTNyy,MTTNx);
%FOR j := 1:MTTNx DO
%  BEGIN
%  xj := MTTX(j,1);
%  FOR i := 1:MTTNyy DO
%    BEGIN
%    MTTO_x(i,j) := df(MTTYY(i,1), xj);
%    END;
%  END;

%%Create O_u - derivative of YY wrt u (Assumes GPC Nu = 0)
%MTTNNu := (MTTGPCNu+1)*MTTNu;
%Matrix MTTO_u(MTTNyy,MTTNNu);
%FOR j := 1:MTTNNu DO
%  BEGIN
%  uj := MTTu(j,1);     
%  FOR i := 1:MTTNyy DO
%    BEGIN
%    MTTO_u(i,j) := df(MTTYY(i,1), uj);
%    END;
%  END;


%%Create O_uu - derivative of O_u wrt u (Assumes GPC Nu = 0)
%%This is a multi-dimensional matrix kth elements stacked sideways.
%Matrix MTTO_uu(MTTNyy,MTTNNu*MTTNNu);
%FOR k := 1:MTTNNu DO
%  BEGIN
%  uk := MTTu(k,1);     
%  FOR j := 1:MTTNNu DO
%    BEGIN
%    FOR i := 1:MTTNyy DO
%      BEGIN
%      jk := j+(k-1)*MTTNu;
%      MTTO_uu(i,jk) := df(MTTO_u(i,j), uk);
%      END;
%    END;
%  END;

%%Create O_ux - derivative of O_u wrt x 
%%This is a multi-dimensional matrix kth elements stacked sideways.
%Matrix MTTO_ux(MTTNyy,MTTNu*MTTNx);
%FOR k := 1:MTTNx DO
%  BEGIN
%  xk := MTTx(k,1);     
%  FOR j := 1:MTTNu DO
%    BEGIN
%    FOR i := 1:MTTNyy DO
%      BEGIN
%      jk := j+(k-1)*MTTNu;
%      MTTO_ux(i,jk) := df(MTTO_u(i,j), xk);
%      END;
%    END;
%  END;


% Try and split the obs function into affine form (O(x,u) = o(x) + h(x)u)
affine := 1;
MTTNuu := (MTTGPCNu+1)*MTTNu;
write "1 affine := ", affine, ";";

%IF (affine=1) THEN
%BEGIN
  MATRIX MTTObs_o(MTTNyy,1);
  MATRIX MTTObs_h(MTTNyy,MTTNuu);
write "2 affine := ", affine, ";";
  FOR i := 1:MTTNyy DO
  BEGIN
write "3 affine := ", affine, ";";
    MTTObs_o(i,1) := MTTYY(i,1);
    k := 0;
    FOR j := 1:MTTNu DO
    FOR jj := 0:MTTGPCNu DO
    BEGIN
      k := k+1;
      %Expand as polynomial in u_j^[jj]
      coeffs := coeff(MTTObs_o(i,1), MTTUU(j,jj+1));
      MTTObs_o(i,1) := first(coeffs);
      IF length(coeffs)>1 THEN
        MTTObs_h(i,k) := second(coeffs);
      IF length(coeffs)>2 THEN 
        affine := -1;
    END;
  END;
%END;


%%Create the _obs.r file
OUT "$1_obs.r";

IF affine=1 THEN
  write "affine := 1; % The O function is affine in u"
ELSE
  write "affine := 0; % The O function is not affine in u";


write "% The matrix sizes";
write "MTTNyy := ", MTTNyy, ";";
write "MTTNuu := ", MTTNuu, ";";

mtt_matrix := MTTYY$
mtt_matrix_n := MTTNyy$
mtt_matrix_m := 1$
mtt_matrix_name := "MTTYY"$
reduce_matrix();

IF affine=1 THEN
BEGIN
  mtt_matrix := MTTObs_o$
  mtt_matrix_n := MTTNyy$
  mtt_matrix_m := 1$
  mtt_matrix_name := "MTTObs_o"$
  reduce_matrix();

  mtt_matrix := MTTObs_h$
  mtt_matrix_n := MTTNyy$
  mtt_matrix_m := MTTNuu$
  mtt_matrix_name := "MTTObs_h"$
  reduce_matrix();
END;

%MTTO_x := MTTO_x;
%MTTO_u := MTTO_u;
%MTTO_uu := MTTO_uu;
%MTTO_ux := MTTO_ux;

write ";END;";

SHUT "$1_obs.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r ode2obs_r.log

Added mtt/bin/trans/ode2odes_m version [e593903528].






































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odes_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  1998/06/27 14:49:16  peterg
## No change
##
## Revision 1.16  1998/06/25 08:47:23  peterg
## Put correct arguments for _input -- (x,t)
##
## Revision 1.15  1998/05/21 16:20:27  peterg
## Modified to include explicit algebraic loop solution
##
## Revision 1.14  1998/05/19 19:48:02  peterg
## Read the simpar file now.
##
## Revision 1.13  1998/05/14 08:05:10  peterg
## Put back under RCS
##
## Revision 1.12  1998/02/25 18:02:39  peterg
## Removed the argument passing stuff .
## Replaced by the simpar.m method.
##
## Revision 1.11  1997/08/29 07:56:54  peterg
## Minor updates
##
# Revision 1.10  1997/01/07  09:16:03  peterg
# Added step_factor parameter - gives that number of integration steps
# per sample.
#
## Revision 1.9  1997/01/06 21:36:44  peterg
## Fixed bug mtt_error --> mtt_error.txt
## Replaced lsode by Euler integration.
##
## Revision 1.8  1996/09/13 17:54:08  peter
## Now writes default $PARAMS to $1_args.m - $1_ode may use it.
##
## Revision 1.7  1996/09/12 18:41:48  peter
## Standard error handling added.
##
## Revision 1.6  1996/08/24 14:11:04  peter
## Global parameter passing.
##
## Revision 1.5  1996/08/18 12:01:26  peter
## Unified format of time responses.
##
## Revision 1.4  1996/08/16 13:04:46  peter
## Fixed problem with more than one output (y vector).
##
## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odes.m
echo Creating $1_odeso.m

rm -f ode2odes_m.log
rm -f mtt_error.txt

#if [ "$2" = "" ]; 
#then
#  PARAMS='T=[0:0.1:10]; x0=zeros(nx,1);'
#  echo Using default parameter $PARAMS
#  echo $PARAMS>$1_args.m
#else
#  PARAMS=$2;
#fi

# PARAMS="$PARAMS ;"


$MATRIX --verbose << EOF > ode2odes_m.log 2>mtt_error.txt

  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;

  %Read in parameters
  $1_numpar; 

  %Read in state
  x = $1_state;

  %Set the initial output
  %if ny>0
  %  y = $1_odeo(x,0);
  %end; 
 
  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:1:100]
  end;

  if exist('METHOD')==0
    METHOD = 'Euler'
  end;

  if exist('x')==0
    x = zeros(nx,1);
   end;

  % xx is the composite vector containing x and the internal inputs.
  xx = [x; zeros(nyz,1)];

  [n,m]=size(T);
  if m>n
    T=T';
  end;

method = tolower(METHOD)

if nx>0
  if strcmp(method,'lsode')
    X = lsode('$1_ode', x, T);
  elseif strcmp(method,'euler')
    %Euler integration
    disp("Euler")
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    for t=T'
      X = [X; xx'];
      ts = t;
      for i=1:STEPFACTOR
        x = xx(1:nx);
        u = $1_input(xx,ts);
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = x + dx*dt;
        xx(1:nx) = x;
      end;
    end;
  elseif strcmp(method,'implicitl')
    %Euler integration
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    u = $1_input(x,u,t);
    A = $1_smx(x,u); 
    inverse = inv(eye(nx) - dt*A);
    for t=T'
      X = [X; xx'];
      ts = t;
      u = $1_input(x,t);
      for i=1:STEPFACTOR
        x = xx(1:nx);
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = inverse*(x + dt*(dx - A*x));
        xx(1:nx) = x;
      end;
    end;
  elseif strcmp(method,'implicit')
    %Euler integration
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    One = eye(nx);
    for t=T'
      X = [X; xx'];
      ts = t;
      for i=1:STEPFACTOR
        x = xx(1:nx);
        u = $1_input(x,t);
    	A = $1_smx(x,u); 
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = (One-A*dt)\(x + dt*(dx - A*x));
        xx(1:nx) = x;
      end;
    end;
  else
    error('Method %s not available here', METHOD);
    return;
  end;
  write_matrix([T,X], '$1_odes');
else
  X = zeros(size(T));
end;

if ny>0 % compute y and print it
  i = 0; Y=[];
  for t=T'
    i = i+1; X(i,:);
    u = $1_input(x,t);
    y = $1_odeo(X(i,:)',u,t);
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_odeso');
end;


EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt







Added mtt/bin/trans/ode2odes_r2c version [3539b59c2d].














































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odes_r2c
# Reduce ordinary differential equations to  differential-algebraic 
# equations solution in the form of a c program.

# Euler integration of the state is included.

# NB Arrays should are  defined to be one larger than expected 
# - the 0 element is not used.

# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  1998/05/15 07:47:23  peterg
## Includes sign.c by default
##
## Revision 1.16  1998/05/14 08:25:52  peterg
## Corrected time skew.
##
## Revision 1.15  1998/05/14 08:20:29  peterg
## Start time at DT - the result at time zero is computed outside the
## loop
##
## Revision 1.14  1998/05/13 08:57:27  peterg
## Now uses simpar.h in place of odes.h
##
## Revision 1.13  1998/02/24 13:34:45  peterg
## Back under RCS
##
# Revision 1.12  1997/05/15  08:39:56  peterg
# Don't initialise states - now done in numpar file.
#
# Revision 1.11  1997/05/12  16:00:54  peterg
# Removed itime again.,
#
# Revision 1.10  1997/05/10  10:05:15  peterg
# Put _input in inner loop in front of call to _ode
#
## Revision 1.9  1997/05/10 09:54:34  peterg
## Moved _input call to after the inner integration loop.
##
## Revision 1.8  1997/05/10 08:12:23  peterg
## Put second argument into _input.
##
## Revision 1.7  1997/05/10 07:01:15  peterg
## _input called in outer loop only.
## time updated in outer loop only.
## Integer time (itime) introduced and updated in outer loop - maybe
## useful for discrete events.
## Integer time (itime) passed to _input.
##
## Revision 1.6  1997/05/06 13:53:32  peterg
## Now uses the preprocessor to declare sizes -- MTTNX etc
##
# Revision 1.5  1997/05/01  13:50:11  peterg
# Replaced float by double.
#
# Revision 1.4  1997/05/01  13:43:44  peterg
# Changed double to float.
#
# Revision 1.3  1997/05/01  11:15:33  peterg
# Back under RCS
#
# Revision 1.2  1997/03/20  14:36:56  peterg
# Includes the sympar.h file
#
## Revision 1.1  1997/01/21 22:54:54  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_odes.c

# Remove the old log file
rm -f ode_r2c.log

# Use reduce to accomplish the transformation
reduce >ode2odes_r2c.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
%%in "$1_sympar.r";

ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
%OFF Nat;

ON NERO;        % Suppress zero elements

%Generate the Header part
OUT "$1_odes.c";

write "/*"$
write "Program to solve ode for system $1"$
write "NB Arrays are defined to be one larger than expected"$
write " - the 0 element is not used."$

write "File $1_odes.c"$
write "Generated by MTT"$
write "*/"$
write " "$


%Program heading
write "#define MTTNX ", MTTNx $
write "#define MTTNY ", MTTNy $
write "#define MTTNU ", MTTNu $
write "#define MTTNX1 ", MTTNx+1 $
write "#define MTTNY1 ", MTTNy+1 $
write "#define MTTNU1 ", MTTNu+1 $
write "#define MTTNX2 ", MTTNx+2 $
write "#define MTTNY2 ", MTTNy+2 $
write "#define MTTNU2 ", MTTNu+2 $

write "#include <stdio.h>"$
write "#include <math.h>"$
write "#include ""sign.c"" "$
write "#include ""$1_simpar.h"" "$
write "#include ""$1_ode.c"" "$
write "#include ""$1_input.c"" "$
write "#include ""$1_numpar.c"" "$
write "#include ""$1_state.c"" "$

%External (global) variable list
write "#include ""$1_sympar.h"" "$


write "/* Declare standard arrays */"$
write "double y[MTTNY1]; /* $1_ode output */"$
write "double dx[MTTNX1]; /* $1_ode state derivative */"$ 
write "double x[MTTNX1]; /* $1_ode state */"$ 
write "double u[MTTNU1]; /* $1_ode input */"$


write "/* Files */ "$
write "  FILE *fopen(), *fps, *fpso;"$

write "main()"$
write "  "$
write "{"$



write "/* Counters etc*/ "$
write "  double time;"$
write "  double dt;"$
write "  int i;"$
write "  int k;"$

write "/*functions */ "$
write "  extern  $1_numpar();"$

%Open the output files
write "/* %Open the output file */"$
write "fps = fopen(""$1_odes.m"", ""w"");  "$
write "fpso = fopen(""$1_odeso.m"", ""w"");  "$

%Set up user-defined constants
write "/* Set up user-defined constants */"$
write "  $1_numpar();"$

%Set up initial state
write "/* Set up initial state */"$
write "  $1_state();"$

%Initialise main (Euler) integration loop
write "/* Initialise main (Euler) integration loop */"$
write "  time = 0;"$
write "  dt = DT/STEPFACTOR;"$
%% write "  for (i=1; i<=MTTNX; i++)"$
%% write "      x[i] = 0.0;"$

%Set up system inputs
write "/* Set up system inputs */"$
write "  for (i=1; i<=", MTTNu, "; i++)"$
write "      u[i] = 1.0;"$

write "  $1_input(0.0);"$

write "    fprintf(fps, ""function data = ", "$1_odes \n"");"$
write "    fprintf(fps, ""data = [\n"");"$
write "    fprintf(fpso, ""function data = ", "$1_odeso \n"");"$
write "    fprintf(fpso, ""data = [\n"");"$

% Compute the first output
write "/* Compute the first output */"$
write "  $1_ode(y,dx,x,u);"$

%Main (Euler) integration loop
write "/* Main (Euler) integration loop */"$

write "  while (time<(LAST-DT))"$
write "  {"$

%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$
write "      fprintf(fpso, ""%5.4g "", y[i]);"$
write "    fprintf(fpso, ""\n"");"$

%Write to state to file
write "/* Write to state file */"$
write "    fprintf(fps, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNX; i++)"$
write "      fprintf(fps, ""%5.4g "", x[i]);"$
write "    fprintf(fps, ""\n"");"$

write "      time = time + DT;"$

write "/* Inner integration loop */"$
write "    for (k=1; k<=STEPFACTOR; k++)"$
write "    {"$
write "      for (i=1; i<=MTTNX; i++)"$
write "        x[i] = x[i] + dx[i]*dt;"$

write "      /* Set up system inputs */"$
write "      $1_input(time);"$
write "      $1_ode();"$
write "    }"$

write "  }"$

%Write to files
%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$
write "      fprintf(fpso, ""%5.4g "", y[i]);"$
write "    fprintf(fpso, ""\n"");"$

%Write to state to file
write "/* Write to state file */"$
write "    fprintf(fps, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNX; i++)"$
write "      fprintf(fps, ""%5.4g "", x[i]);"$
write "    fprintf(fps, ""\n"");"$


write "  fprintf(fps, ""];\n"");"$
write "  fprintf(fpso, ""];\n"");"$

write "  return 0;"$
write "}"$


SHUT "$1_odes.c";


EOF



Added mtt/bin/trans/ode2odess_m version [4c1d52ada1].
















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odess_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/10/17 11:07:59  peterg
## *** empty log message ***
##
## Revision 1.3  1998/05/19 19:27:04  peterg
## Zapped all the parameter stuff
##
## Revision 1.2  1996/09/13 19:40:51  peter
## Fixed problem with default paramaters.
##
## Revision 1.1  1996/09/12 19:26:57  peter
## Initial revision
##
## Revision 1.4  1996/08/16 13:04:46  peter
## Fixed problem with more than one output (y vector).
##
## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odess.m
rm -f ode2odess_m.log

Nx=`mtt_getsize $1 x` # States
Nxx=`mtt_getsize $1 xx` # States x States
Nu=`mtt_getsize $1 u` # Inputs 
Ny=`mtt_getsize $1 y` # Inputs 

$MATRIX << EOF >  ode2odess_m.log 2>mtt_error.txt

  %Read in parameters
  par = $1_numpar;

   %Read in simulation parameters
  simpar=$1_simpar;
  T = [0:simpar.dt:simpar.last];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:0.1:1]
  end;

  if exist('x0')==0
    x0 = zeros($Nx,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

global t;
function dx=f(x)
  global t
  par = $1_numpar;
  u = $1_input(x,zeros($Ny,1),t,par);
  dx = $1_ode(x,u,t,par);;
endfunction;

i=0;
x = x0;
for t=T'
  u = $1_input(x,zeros($Ny,1),t,par);
  y(i) = $1_odeo(x,u,t,par)';
  mtt_write(t,x,y,$Nx,$Ny);   # Write it out
  x = fsolve('f',x)';
end;

i=0;
for t=T'
  i=i+1;
end;

write_matrix([T,x], '$1_odess');
write_matrix([T,y], '$1_odesso');

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt





Added mtt/bin/trans/ode2odess_m2dat2 version [13554ba921].













































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odess_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/10/17 12:55:29  peterg
## Initial revision
##
## Revision 1.4  2000/10/17 11:07:59  peterg
## *** empty log message ***
##
## Revision 1.3  1998/05/19 19:27:04  peterg
## Zapped all the parameter stuff
##
## Revision 1.2  1996/09/13 19:40:51  peter
## Fixed problem with default paramaters.
##
## Revision 1.1  1996/09/12 19:26:57  peter
## Initial revision
##
## Revision 1.4  1996/08/16 13:04:46  peter
## Fixed problem with more than one output (y vector).
##
## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odess.dat2
rm -f ode2odess_m.log

Nx=`mtt_getsize $1 x` # States
Nxx=`mtt_getsize $1 xx` # States x States
Nu=`mtt_getsize $1 u` # Inputs 
Ny=`mtt_getsize $1 y` # Inputs 

$MATRIX << EOF  >ode2odess_m2dat2.log 2>mtt_error.txt

   global MTT_data # Where mtt_write puts its stuff
  %Read in parameters
  par = $1_numpar;

   %Read in simulation parameters
  simpar=$1_simpar;
  T = [0:simpar.dt:simpar.last];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:0.1:1]
  end;

  if exist('x0')==0
    x0 = zeros($Nx,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

global t;
function dx=f(x)
  global t
  par = $1_numpar;
  u = $1_input(x,zeros($Ny,1),t,par);
  dx = $1_ode(x,u,t,par);;
endfunction;

x = x0;
for t=T'
  u = $1_input(x,zeros($Ny,1),t,par);
  x = fsolve('f',x);
  y = $1_odeo(x,u,t,par);
  mtt_write(t,x,y,$Nx,$Ny);   # Write it out
end; 

save -text $1_odess.dat2 MTT_data

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt





Added mtt/bin/trans/ode2smx_lang version [564d3a89c6].



























































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2smx_lang
# ODE to state matrix (with explicit state values) conversion
# P.J.Gawthrop  6th September 1991, May 1994, July 1998
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  1998/11/26 10:32:34  peterg
## Include subs.r
##
## Revision 1.10  1998/11/17 17:10:22  peterg
## Read in the constitutive relationship file as well
##
## Revision 1.9  1998/08/27 07:06:25  peterg
## Just genrate xj once.
##
## Revision 1.8  1998/08/27 07:04:44  peterg
## Cleared out mttx array ans use mkid instead.
##
## Revision 1.7  1998/08/27 06:48:20  peterg
## Changed mttxx to mttx - in implicit integration smx is called once
## with x in the linearisation the same as x in the current state
##
## Revision 1.6  1998/08/26 18:25:45  peterg
## SMX now generates both A and Ax
##
## Revision 1.5  1998/08/15 13:51:56  peterg
## smx is now I-Adt NOT A
##
## Revision 1.4  1998/08/13 09:03:35  peterg
## *** empty log message ***
##
## Revision 1.3  1998/07/30 10:49:55  peterg
## Removed zeroing.
##
## Revision 1.2  1998/07/30 10:49:02  peterg
## Put [] round output of zeros.
##
## Revision 1.1  1998/07/19 16:59:56  peterg
## Initial revision
##
###############################################################

# Language
if [ -n "$2" ]; then
    lang=$2
else
    lang="r"
fi


# Inform user
echo Creating $1_smx.$lang
#echo Creating $1_smxx.$lang
#echo Creating $1_smxtx.$lang

# Remove the old log file
rm -f ode2smx_r.log

rm -f $1_smx.$lang
rm -f $1_smxx.$lang
rm -f $1_smxtx.$lang

# Use reduce to accomplish the transformation
reduce << EOF  >ode2smx_lang.log

lang := $lang;

in "$1_subs.r";
in "$1_def.r";
in "$1_ode.r";
in "$1_cr.r";

clear mttx; % Dont need this now - use mkid instead

OFF Echo;

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'Pascal;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_t;

% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";


%Set up output according to the language.
 OFF NAT;
 GENTRANOUT "$1_smx.$lang";

% Set up output according to the language.
    IF (lang = r) THEN 
    BEGIN
      write "matrix mtta(", mttnx, ",", mttnx, ");";    
      write "matrix mttb(", mttnx, ",", mttnu, ");";    
      write "matrix mttc(", mttny, ",", mttnx, ");";    
      write "matrix mttd(", mttny, ",", mttnu, ");";    
    END;

% find MTTA : the A matrix
  FOR i := 1:MTTNx DO
  BEGIN
    mttAAx_i := 0;
%%    xi := mkid(mttx,i);
    FOR j := 1:MTTNx DO
    BEGIN
      xj := mkid(mttx,j);
      a_ij := df(MTTdx(i,1), xj, 1);
%%      a_ji := df(MTTdx(j,1), xi, 1);
      IF i=j THEN
      BEGIN
        aa_ij := 1 - mttdt*a_ij;
%%        aa_ji := aa_ij;
      END
      ELSE
      BEGIN
        aa_ij := -mttdt*a_ij;
%%        aa_ji := -mttdt*a_ji;
      END;
      IF (aa_ij NEQ 0) THEN
        GENTRAN mtta(i,j) ::=: aa_ij;
      mttAAx_i := mttAAx_i + aa_ij*xj;
      %%%mttAAtx(i,1) := mttAAtx(i,1) + aa_ji*mkid(mttx,j);
    END;
    IF (mttAAx_i NEQ 0) THEN
      GENTRAN mttax(i) ::=: mttAAx_i;
  END;



%% Find MTTB : the B matrix
%  FOR j := 1:MTTNu DO
%    BEGIN
%    uj := MTTU(j,1);
%    FOR i := 1:MTTNx DO
%      WriteElement("mttb",i,j,df(MTTdx(i,1), uj, 1));
%    END;
%
%% Find MTTC : the C matrix
%  FOR i := 1:MTTNy DO
%    FOR j := 1:MTTNx DO
%    BEGIN
%      xj := MTTX(j,1);
%      WriteElement("mttc",i,j,df(MTTY(i,1), xj, 1));
%    END;
%
%% Find MTTD : the D matrix
%  FOR i := 1:MTTNy DO
%    FOR j := 1:MTTNu DO
%    BEGIN
%      xj := MTTU(j,1);
%      WriteElement("mttd",i,j,df(MTTY(i,1), xj, 1));
%    END;

%Shut the  output according to the language.
 GENTRANSHUT "$1_smx.$lang";


%% The AAx matrix;
%GENTRANOUT "$1_smxx.$lang";
%FOR i := 1:MTTNx DO
%BEGIN
%  ax_i := mttAAx(i,1);
%  IF (ax_i NEQ 0) THEN
%    GENTRAN mttax(i) ::=: ax_i;
%END
%GENTRANSHUT "$1_smxx.$lang";
%
%% The AAtx matrix;
%GENTRANOUT "$1_smxtx.$lang";
%FOR i := 1:MTTNx DO
%BEGIN
%  atx_i := mttAAtx(i,1);
%  IF (atx_i NEQ 0) THEN
%    GENTRAN mttax(i) ::=: atx_i;
%END
%GENTRANSHUT "$1_smxtx.$lang";

EOF

if [ "$lang" = "m" ]; then
  mv $1_smx.$lang  mtt_junk
#  lang_header $1 smx m 'mttx,mttu,mttdt' '[mtta,mttax]' > $1_smx.m
  mtt_header $1 $2 m
  cat mtt_junk | mtt_p2m >> $1_smx.m
  rm -f mtt_junk

#  mv $1_smxx.$lang  mtt_junk
#  lang_header $1 smxx m 'mttx,mttu,mttxx,mttdt' '[mttax]' > $1_smxx.m
#  cat mtt_junk | mtt_p2m >> $1_smxx.m
#  rm -f mtt_junk
#
#  mv $1_smxtx.$lang  mtt_junk
#  lang_header $1 smxtx m 'mttx,mttu,mttxx,mttdt' '[mttax]' > $1_smxtx.m
#  cat mtt_junk | mtt_p2m >> $1_smxtx.m
#  rm -f mtt_junk
#
#
fi

# Now invoke the standard error handling.
mtt_error_r ode2smx_lang.log




Added mtt/bin/trans/ode_r2c version [572667c334].






























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2c
# Reduce ordinary differential equations to c differential-algebraic 
# equations

# Euler integration of the state is included.

# NB Arrays should be defined to be one larger than expected 
# - the 0 element is not used.

# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1997/05/01 13:50:55  peterg
## Replaced float by double.
##
# Revision 1.4  1997/05/01  13:44:19  peterg
# Changed double to float.
#
# Revision 1.3  1997/03/20  14:51:11  peterg
# Includes the sympar.c file.
#
# Revision 1.2  1997/01/21  22:57:17  peterg
# Various bug fixes.
#
## Revision 1.1  1997/01/21 10:52:23  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_ode.c

# Remove the old  files
rm -f  $1_ode.c1 $1_ode.c2 $1_ode.c

# Remove the old log file
rm -f ode_r2c.log

# Use reduce to accomplish the transformation
reduce >ode_r2c.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the reduce state-space equations   file
in "$1_ode.r";


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
%OFF Nat;

ON NERO;        % Suppress zero elements


%Generate the Header part
OUT "$1_ode.c1";

write "/*"$
write "Differential algebraic eqns in c form for system $1"$
write "NB Arrays should be defined to be one larger than expected"$
write " - the 0 element is not used."$

write "File $1_ode.c"$
write "Generated by MTT"$
write "*/"$
write " "$


%Function heading - c style

write "void $1_ode()"$

write "  "$
write "{"$

write "/* Declare standard arrays */"$
write "  extern double y[", MTTNy+1, "]; /* $1_ode output */"$
write "  extern double dx[", MTTNx+1, "]; /* $1_ode state derivative */"$ 
write "  extern double x[", MTTNx+1, "]; /* $1_ode state */"$ 
write "  extern double u[", MTTNu+1, "]; /* $1_ode input */"$

%Declare the dummy variables t0--t9
write "/* Dummy variable list */ "$
write "  double t0;"$
FOR i := 1:9 DO
BEGIN
  write "  double t", i, ";"$
END$

%Declarations$
write "/* State variable list */ "$
FOR i := 1:MTTNx DO
BEGIN
  write "  double mttx", i, ";"$
END$

write "/* Input variable list */ "$
FOR i := 1:MTTNu DO
BEGIN
  write "  double mttu", i, ";"$
END$

write "/* Counter */ "$
write "  int i;"$

write "/* Parameter  list */ "$
write "#include ", """$1_sympar.c"""$

write "  "$
write "    /*====== Set up the state variables ======*/"$
FOR i := 1:MTTNx DO
BEGIN
  write "    mttx", i, " = x[", i, "];"$
END$

write "  "$
write "    /*====== Set up the input variables ======*/"$
IF MTTNu>0 THEN
BEGIN
  FOR i := 1:MTTNu DO
  BEGIN
    write "    mttu", i, " = u[", i, "];"$
  END$
END$


write "  "$
write "    /*====== Compute the state derivative and output ======*/"$

SHUT "$1_ode.c1";

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'C;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;
ON DOUBLE;

% let it know that sign is a function
GENTRAN DECLARE sign : function;
GENTRAN DECLARE r_switch : function;
GENTRAN DECLARE i_switch : function;

GENTRANOUT "$1_ode.c2";
%Do the translation
%State
IF MTTNx>0 THEN
BEGIN
  FOR i := 1:MTTNx DO
  BEGIN
        GENTRAN dx(i) ::=: mttdx(i,1)$
  END
END$

%Output
IF MTTNy>0 THEN
BEGIN
  FOR i := 1:MTTNy DO
  BEGIN
        GENTRAN y(i) ::=: mtty(i,1)$
  END
END$


GENTRANSHUT "$1_ode.c2";

EOF

echo '}' > $1_ode.c3
cat $1_ode.c1 $1_ode.c2 $1_ode.c3> $1_ode.c


Added mtt/bin/trans/ode_r2lang version [7b0000767e].






















































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2lang
# Reduce ODE to general language ODE
# Based on obsolete ode_r2m  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95, May 1998
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/07/19 16:22:29  peterg
## Changed header to inculde mttu
##
## Revision 1.2  1998/06/21 10:40:58  peterg
## Added fsolve error message.
##
## Revision 1.1  1998/05/23 16:17:14  peterg
## Initial revision
##
###############################################################

# Set up the language specific stuff
language=$2

case $language in
    m)
	ext='m';
	codegenerator='PASCAL'
	Lc='#';
	Rc='#';
	Lb='(';
	Rb=')';
	;;
    c)
	ext='c';
	codegenerator='C'
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    java)
	ext='java';
	codegenerator='C'
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
       *)
       echo Language $2 not supported - sorry; exit 1
esac

#Inform user
echo Creating $1_ode.$ext
echo Creating $1_odea.$ext
echo Creating $1_odeo.$ext


# Remove the old log file
rm -f ode_r2lang.log

#Remove the temporary files
rm -f $1_ode.$ext.1
rm -f $1_odea.$ext.1
rm -f $1_odeo.$ext.1

# Use reduce to accomplish the transformation
$SYMBOLIC  << EOF #>ode_r2lang.log

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  ODE   file
in "$1_ode.r";


% Set up the code generator
% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := '$codegenerator;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_temp;

% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
in "$1_sympar.r";

% The body of the ode function
  GENTRANOUT "$1_ode.$ext.1";
  mtt_matrix := MTTdX$
  mtt_matrix_n := MTTNx$
  mtt_matrix_m := 1$
  mtt_matrix_name := 'MTTdX$
  lang_matrix()$ 
  GENTRANSHUT "$1_ode.$ext.1";
  
% The algebraic equations (if any)
  GENTRANOUT "$1_odea.$ext.1";
  mtt_matrix := MTTYz$
  mtt_matrix_n := MTTNYz$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTYz$
  lang_matrix()$ 
  GENTRANSHUT "$1_odea.$ext.1";


% Now do the y = g(x,t) function.
% The body of the odeo function
  GENTRANOUT "$1_odeo.$ext.1";
  mtt_matrix := MTTy$
  mtt_matrix_n := MTTNy$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTy$
  lang_matrix()$ 
  GENTRANSHUT "$1_odeo.$ext.1";

EOF

# Create the ode.$ext function
lang_header $1 ode $ext 'mttx,mttu,t' mttdx > $1_ode.$ext

# Algebraic bits
$MATRIX -q  <<EOF  >> $1_ode.$ext
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
if nyz>0
  printf("global mttxx mttt;\n");
  printf("mttxx = mttx; mttt=t;\n");

  printf("$Lc====== Extract the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx);
  end;
  printf("\n");

  printf("[mttui,info] = fsolve('$1_odea',mttui);\n");
  printf("if (info!=1)\n"); 
  printf("  error('fsolve has not converged')\n");
  printf("end\n");
  printf("\n");

  printf("$Lc====== Set up the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");

  printf("$Lc====== Put internal input variables at end of state derivative ======$Rc\n");
  for i = 1:nyz
    printf(" mttdx$Lb%i$Rb = mttui%i;\n",i+nx,i);
  end;
  printf("\n");
end;

EOF

cat <<EOF >> $1_ode.$ext

$Lc The differential equations $Rc
EOF

sed 's/mtt_matrix/mttdx/' $1_ode.$ext.1 >> $1_ode.$ext

# Java terminating }
if [ "$language" = "java" ]; then
cat <<EOF     >> $1_ode.$ext
}
EOF
fi


# Create the odea.$ext function
lang_header $1 odea $ext 'mttui' mttyz 'global mttxx mttt; mttx = mttxx; t=mttt;' > $1_odea.$ext

$MATRIX -q  <<EOF  >> $1_odea.$ext
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
if nyz>0
  printf("$Lc====== Set up the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");
end;
EOF

cat <<EOF >> $1_odea.$ext

% The algebraic equations
EOF
sed 's/mtt_matrix/mttyz/' $1_odea.$ext.1 >> $1_odea.$ext


# Create the odeo.$ext function
lang_header $1 odeo $ext 'mttx,mttu,t' mtty > $1_odeo.$ext

$MATRIX -q  <<EOF  >> $1_odeo.$ext
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
if nyz>0
  printf("$Lc====== Extract the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx);
  end;
  printf("\n");

  printf("$Lc====== Set up the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");
end;

EOF


cat <<EOF >> $1_odeo.$ext

% The output equations
EOF
sed 's/mtt_matrix/mtty/' $1_odeo.$ext.1 >> $1_odeo.$ext

# Convert from Pascal syntax to Octave syntax
mv $1_ode.m mtt_junk; mtt_p2m<mtt_junk > $1_ode.m
mv $1_odeo.m mtt_junk; mtt_p2m<mtt_junk > $1_odeo.m
mv $1_odea.m mtt_junk; mtt_p2m<mtt_junk > $1_odea.m




Added mtt/bin/trans/ode_r2m version [574a94f900].



























































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2m
# Reduce ODE to matlab  ODE  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95.
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.13  1998/05/21 16:19:54  peterg
## Modified to include explicit algebraic loop solution
##
## Revision 1.12  1998/05/21 12:55:48  peterg
## Put in algebraic equation stuff
##
## Revision 1.11  1998/05/21 08:05:23  peterg
## Back under RCS
##
## Revision 1.10  1998/04/14 07:25:02  peterg
## _input now has arguments (x,t)
##
## Revision 1.9  1998/03/30 14:18:07  peterg
## Removed NERO command
##
## Revision 1.8  1998/02/25 18:03:49  peterg
## Removed the argument reading bits.
##
## Revision 1.7  1997/08/29 07:58:17  peterg
## Changed MTT to mtt in the .m files.
##
# Revision 1.6  1997/01/05  19:34:35  peterg
# Don't write globals which are already assigned to a number.
#
## Revision 1.5  1996/09/13 19:41:39  peter
## *** empty log message ***
##
## Revision 1.4  1996/09/12 18:33:32  peter
## Put back under rcs
##
## Revision 1.3  1996/08/30 11:04:28  peter
## Changed line length to 500.
##
## Revision 1.2  1996/08/24 14:09:41  peter
## Global parameter passing.
##
## Revision 1.1  1996/08/18 12:03:49  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_ode.m
echo Creating $1_odea.m
echo Creating $1_odeo.m


# Remove the old log file
rm -f ode_r2m.log

#Remove the temporary files
rm -f $1_ode.mc
rm -f $1_ode.m1
rm -f $1_ode.m2
rm -f $1_ode.m3
rm -f $1_ode.m4
rm -f $1_odea.m1;
rm -f $1_odeo.m1;

# Use reduce to accomplish the transformation
reduce >ode_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  ODE   file
in "$1_ode.r";

% Matrix output function
in"$MTTPATH/trans/matlab_matrix.r";


%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
in "$1_sympar.r";

%ON NERO;        % Suppress zero elements

%Define the common part of the functions.

PROCEDURE common;
BEGIN
  write "% Read in the input";
  write "u = $1_input(x,t)";

  write "% Read in the definitions";
  write "[nx,ny,nu,nz,nyz] = $1_def";

%  write "% Read in the arguments";
%  write "$1_args";
  
  write "% Set up the State variables";
  FOR i := 1:MTTNx DO
  BEGIN
    write "mttx", i, " = x(", i, ");";
  END;
  
  write "% Set up the Input variables";
  IF MTTNu>0 THEN
  FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ");";
  END;

END;

% The common part
OUT "$1_ode.mc";
common();
SHUT "$1_ode.mc";

% Set up internal inputs (if any)
OUT "$1_ode.m3";
  write "% Set up the Internal Input variables";
  IF MTTNyz>0 THEN
  FOR i := 1:MTTNyz DO
  BEGIN
    write "mttui", i, " = mttui(", i, ");";
  END;
SHUT "$1_ode.m3";

OUT "$1_ode.m4";
  write "% Set up the Internal Input variables (saved in the state vector)";
  IF MTTNyz>0 THEN
  FOR i := 1:MTTNyz DO
  BEGIN
    write "mttui(", i, ") = x(", i+MTTNx, ");";
  END;
SHUT "$1_ode.m4";

% The body of the ode function
  GENTRANOUT "$1_ode.m1";
  mtt_matrix := MTTdX$
  mtt_matrix_n := MTTNx$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTdX$
  matlab_matrix(); 
  GENTRAN MTTdx := mtt_matrix;
  GENTRANSHUT "$1_ode.m1";
  
% The algebraic equations (if any)
  GENTRANOUT "$1_odea.m1";
  mtt_matrix := MTTYz$
  mtt_matrix_n := MTTNYz$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTYz$
  matlab_matrix(); 
  GENTRAN MTTYz := mtt_matrix;
  GENTRANSHUT "$1_odea.m1";

 
%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 10000$
OFF period$

MTTdx := MTTdx;


SHUT "$1_ode.m";

OUT "$1_odea.m";
write "function zero = $1_odea(x,t);";
write "% zero = $1_odea(x,t);";
write "%Algebraic equations in octave form for system $1;;";
write "%File $1_odea.m;;";
write "%Generated by MTT;;";

%Write algebraic equations if any ...
zero := MTTYz;
SHUT "$1_odea.m";

% Now do the y = g(x,t) function.
% The body of the odeo function
  GENTRANOUT "$1_odeo.m1";
  mtt_matrix := MTTy$
  mtt_matrix_n := MTTNy$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTy$
  matlab_matrix(); 
  GENTRAN MTTy := mtt_matrix;
  GENTRANSHUT "$1_odeo.m1";


EOF

# Create the ode.m function
cat <<EOF > $1_ode.m
function mttdx = $1_ode(x,t);
% mttdx = $1_ode(x,t);
%ODE in Octave form for system $1;
%File $1_ode.m;
%Generated by MTT on `date`;
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_ode.m

#Common bit
cat $1_ode.mc >> $1_ode.m

#Extract internal input from state vector
cat $1_ode.m4 >> $1_ode.m

cat <<EOF >> $1_ode.m
% Solve the algebraic equations (if any)
if nyz>0
  global xx tt;
  xx = x; tt=t;
  MTTui = fsolve('$1_odea',mttui);
else
 mttui = [];
end
EOF

cat $1_ode.m3 >> $1_ode.m

cat <<EOF >> $1_ode.m

% The differential equations
EOF
cat $1_ode.m1 >> $1_ode.m

cat <<EOF >> $1_ode.m

% Append the internal inputs to the state derivative
mttdx = [mttdx; mttui];
EOF


# Create the odea.m function
cat <<EOF > $1_odea.m
function mttyz = $1_odea(mttui);
% mttyz = $1_odea(mttui);
%Algebraic equations in Octave form for system $1;
%File $1_odea.m;
%Generated by mtt on `date`;
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_odea.m

cat <<EOF >> $1_odea.m

global xx tt;
x = xx; t=tt;
EOF

#Common bit
cat $1_ode.mc >> $1_odea.m

# Internal inputs
cat $1_ode.m3 >> $1_odea.m

cat <<EOF >> $1_odea.m

% The algebraic equations
EOF
cat $1_odea.m1 >> $1_odea.m

# Create the odeo.m function
cat <<EOF > $1_odeo.m
function mtty = $1_odeo(x,t);
% mtty = $1_odeo(x,t);
%Algebraic equations in Octave form for system $1;
%File $1_odeo.m;
%Generated by MTT  on `date`;
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_odeo.m


#Common bit
cat $1_ode.mc >> $1_odeo.m

#Extract internal input from state vector
cat $1_ode.m4 >> $1_odeo.m

# Internal inputs
cat $1_ode.m3 >> $1_odeo.m

cat <<EOF >> $1_odeo.m

% The output equations
EOF
cat $1_odeo.m1 >> $1_odeo.m







Added mtt/bin/trans/ode_r2tex version [d72a266090].


























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2tex
# Reduce differential-algebraic to LaTex differential-algebraic equations.
# P.J.Gawthrop 10th May 1991, April 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/01/23 15:51:01  peterg
## Repleace eqnarray by equation + aligned -- this works with Latex2html
##
## Revision 1.2  1996/12/20 08:59:10  peterg
## Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
## conversion.
##
## Revision 1.1  1996/12/20 08:53:57  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_ode.tex

# Remove the old log file
rm -f ode_r2tex.log

# Use reduce to accomplish the transformation
reduce >ode_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the differential-algebraic equations file
in "$1_ode.r";

%Read the symbolic parameter file
%%in "$1_sympar.r";



OFF Echo;
OFF Nat;

%Read the substitution file
IN "$1_subs.r";

%Read the simplifying expressions file
IN "$1_simp.r";

OUT "$1_ode.tex";

%Write out the  differential-algebraic equations.

write "%File: $1_ode.tex";

write "%ordinary differential equations";
write "% Generated by MTT";

IF MTTNx>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_ode_x}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNx DO
  BEGIN
	write "\dot MTTX", Row, " &= ";
	write "{";
	write MTTdx(Row,1);
	write "}";
        IF Row<MTTNx THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;

IF MTTNyz>0 THEN
BEGIN
  write"\begin{equation}";
  write"\begin{aligned}";
FOR Row := 1:MTTNyz DO
  BEGIN
	write "0 &= ";
	write "{";
	write MTTyz(Row,1);
	write "}";
        IF Row<MTTNyz THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;

IF MTTNy>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_ode_y}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNy DO
  BEGIN
	write "MTTy", Row, " &= ";
	write "{";
	write MTTy(Row,1);
	write "}";
        IF Row<MTTNy THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;





SHUT "$1_ode.tex";
quit;
EOF

Added mtt/bin/trans/odes_dat2sdat version [10897a37e0].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: odeso_dat2sdat

# Structure file - dat to sdat conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/12/28 12:38:24  peterg
## Put under RCS
##
## Revision 1.1  1999/03/28 21:29:40  peterg
## Initial revision
##
###############################################################



# Inform user
echo "Creating $1_odeso.sdat"

dat2sdat $1 odes | dat2siag > $1_odes.sdat

Added mtt/bin/trans/odeso_dat2sdat version [055c2bffbd].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: odeso_dat2sdat

# Structure file - dat to sdat conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/03/28 21:29:40  peterg
## Initial revision
##
###############################################################



# Inform user
echo "Creating $1_odeso.sdat"

dat2sdat $1 odeso | dat2siag > $1_odeso.sdat

Added mtt/bin/trans/p/README version [4d29246b85].


















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Some of the files in this directory are derived from the NUMERICAL
RECIPES PASCAL SHAREWARE DISKETTE. Please note that any use of these
filse may be subject to the following notice:


             NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE

The entire contents of this diskette are
Copyright (C) 1986 by Numerical Recipes Software.

HERE ARE ANSWERS TO YOUR IMMEDIATE QUESTIONS:

** What is this diskette?  ** This NUMERICAL  RECIPES PASCAL SHAREWARE
DISKETTE contains Pascal procedures originally published as the Pascal
Appendix to the FORTRAN book NUMERICAL RECIPES: THE  ART OF SCIENTIFIC
COMPUTING (Cambridge University Press, 1986), and test driver programs
originally published as the  NUMERICAL  RECIPES EXAMPLE BOOK  (PASCAL)
(Cambridge University Press, 1986).

** What kinds of procedures  are these Numerical Recipes? **  They are
practically a complete library for  scientific computation.  Numbering
more than  200,  their scope  includes   integration,  linear algebra,
differential  equations, Fourier methods,  data analysis,  statistics,
lots of special functions, random   numbers,  sorting, root   finding,
optimization, and much more.

** Do I really get this whole library for FREE? ** Yes, providing that
you follow these  simple  rules:   (1) You must   read and accept  the
disclaimer of warranty at the end of this  document.  (2) You must not
expect any  user support from  Numerical Recipes Software,   Cambridge
University Press, or the authors of  the Numerical Recipes books.  (3)
You must not copy  or redistribute any  of  the programs or procedures
for commercial purposes.  You CAN make copies of the programs for your
friends  and    colleagues, providing   that you  include   this  file
(especially its copyright notice and  disclaimer of warranty) with any
copy that you make.

** What's  the  catch, then?  **    None at  all.   Many  thousands of
satisfied users paid more than $20 to purchase exactly the programs on
this disk,  which were sold   by Cambridge  University  Press (C.U.P.)
between 1986 and 1989.  C.U.P.  now sells a  revised  version  of  the
Numerical  Recipes program library,  whose   Pascal  style   is   much
improved, but whose basic algorithmic  workings are identical  to this
disk.  Rather  than  let  the older version go  to waste,  its authors
decided to make it available to the shareware community of users.

** How can I figure out what the procedures do? ** One way is  to read
the brief descriptions of all the programs in the  file NRINFO.DOC.  A
better  way is to  look  at the  book   Numerical Recipes: The  Art of
Scientific Computing  in   any  one of its  three  editions  (FORTRAN,
Pascal, or  C).  If you  don't  want to buy this book   from Cambridge
University Press   (see the file  NRINFO.DOC),  you  can  find   it in
libraries.  Or, take  a pencil and   a small  piece  of paper  into  a
bookstore that carries the book and take  notes  on which programs you
might find interesting.

** How do I figure out how to use  the procedures? **  Again, you have
several  options.   All  the   procedures  (named   *.PAS)  come  with
demonstration  programs  (named *.DEM).   These demonstration programs
are included on this shareware diskette.  (When sold, they are sold as
a separate  diskette.)  Usually  you can figure    out how  to   use a
procedure by figuring out its .DEM program.  Another way is to look at
the Numerical Recipes book in a library or bookstore.

** Aren't you just trying to get me to  buy the book?  **  Think of it
this way: Most shareware comes with the requirement that if you use it
more than casually, you are  required to become  a registered user and
pay a fee.  We are not requiring any  fee at all.   We think that  you
will  be able to  use MOST of the procedures  on this diskette without
the Numerical Recipes book.  If you become a more-than-casual user, or
if you look at the book in a bookstore, we  are betting  that you will
WANT to buy it,  and  perhaps  then  want to purchase  the revised and
improved versions of the programs, also.   But it is completely  up to
you.

** OK, what if I do want to get the book? ** Call Cambridge University
Press at their  toll-free  number,  800-872-7423.  (In  New York  call
800-227-0247 or 914-937-9600.)  Ask for "Numerical Recipes in Pascal",
ISBN  number  0-521-37516-9.  We think  you'll like it.  (Over 100,000
copies of the book are in print, in FORTRAN, Pascal, and C.)

** What  are the files  on this diskette? **  All  the  procedures, in
Pascal source  code, are  in   the ZIP   file NRPAS13.ZIP.   You   use
PKUNZIP.EXE to decompress them.  (For  info  just execute PKUNZIP with
no  command  line  arguments.)  All  the  demonstration  programs  are
similarly in NRPEX10.ZIP (PEX means Pascal EXamples).  Some data files
used by the procedures and demonstrations programs are in NRPDATA.ZIP.
The files NRPAS13.LST and NRPEX10.LST each list the names of the files
in their corresponding ZIP file.   The short file  MODFILE.PAS is used
by many of the  procedures to customize  to your particular variety of
Pascal  compiler; feel free to modify  it, if  you need to.  The  file
NRINFO.DOC tells about the book Numerical Recipes in Pascal and  gives
a   brief description of  all the  procedures.   The  file you are now
reading is NRREADME.DOC.

Good luck, and happy number-crunching!

                       DISCLAIMER OF WARRANTY
                       ---------- -- -------- 
THE PROGRAMS AND  PROCEDURES  ON  THIS DISKETTE  ARE PROVIDED "AS  IS"
WITHOUT  WARRANTY OF  ANY KIND.   WE  MAKE NO  WARRANTIES, EXPRESS  OR
IMPLIED, THAT THE PROGRAMS  AND PROCEDURES ARE FREE  OF ERROR, OR  ARE
CONSISTENT WITH ANY  PARTICULAR  STANDARD OF MERCHANTABILITY,  OR THAT
THEY WILL MEET YOUR REQUIREMENTS FOR ANY PARTICULAR APPLICATION.  THEY
SHOULD NOT BE RELIED ON FOR SOLVING A PROBLEM WHOSE INCORRECT SOLUTION
COULD RESULT IN INJURY TO A PERSON OR LOSS OF PROPERTY.  IF YOU DO USE
THE PROGRAMS OR PROCEDURES IN SUCH A MANNER, IT  IS AT YOUR OWN  RISK.
THE AUTHORS   AND  PUBLISHER   DISCLAIM ALL LIABILITY    FOR   DIRECT,
INCIDENTAL, OR  CONSEQUENTIAL DAMAGES RESULTING FROM YOUR  USE  OF THE
PROGRAMS OR PROCEDURES ON THIS DISKETTE.  ANY LIABILITY  OF THE PERSON
OR PERSONS FROM WHOM YOU DIRECTLY OR INDIRECTLY OBTAINED THIS DISKETTE
WILL BE LIMITED EXCLUSIVELY  TO PRODUCT REPLACEMENT OF DISKETTES  WITH
MANUFACTURING DEFECTS.

Added mtt/bin/trans/p/mtt_euler.p version [6de6bf5883].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_euler(VAR x_out, x,dx : StateVector;
			dt	    : REAL;
			Nx	    : INTEGER;
			Open	    : StateVector);

VAR i : INTEGER;
   
BEGIN{mtt_euler}
   FOR i := 1 TO Nx DO
   BEGIN
      IF Open[i]>0.5 THEN{Open switch}
	 x_out[i] := 0.0
      ELSE
	 x_out[i] := x[i] + dx[i]*dt;
   END;
END;{mtt_euler}

Added mtt/bin/trans/p/mtt_getargs.p version [8b9348a180].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{ Substitute for p2c PASCAL_MAIN
   Copies pogramme arguments in to mtt_parameters array
   This c code is embedded in a pascal routine in a p2c compatible way
}

{EMBED
Static Void  PASCAL_MAIN(argc, argv)
int argc;
char *argv[];

\[
 int i;
 mttnpar = argc-1;
 if (mttnpar>0) \[
   for (i=0;i<MTT_Nx;i++)\[
     x[i] = strtod(argv[i+1],0);
  \]
   for (i=0;i<MTT_Npar;i++)\[
     par[i] = strtod(argv[i+MTT_Nx+1],0);
  \]
 simpar.first=strtod(argv[MTT_Nx+MTT_Npar+1],0);
 simpar.dt=strtod(argv[MTT_Nx+MTT_Npar+2],0);
 simpar.last=strtod(argv[MTT_Nx+MTT_Npar+3],0);
 \]
\]
}

Added mtt/bin/trans/p/mtt_implicit.p version [e4c58449c4].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_implicit(VAR xnew	: StateVector;
			   x,dx	: StateVector;
			   AA	: StateMatrix;
			   AAx	: StateVector;
			   dt	: REAL;
			   Nx	: INTEGER;
			   open	: StateVector);

VAR
   i,ii,j,jj,Nxsub : INTEGER;
   BB,xsub   : StateVector;
   AAsub     : StateMatrix;
   
(*$I $MTTPATH/trans/p/mtt_solve.p *)

BEGIN{mtt_implicit}
   ii := 0;
   FOR i := 1 TO  Nx DO {BB is (1-A*dt)*x +dx*dt}
   BEGIN
      IF open[i]<0.5 THEN
      BEGIN
	 ii := ii+1; jj := 0;
	 BB[ii] := AAx[i] + dt*dx[i];
	 FOR j := 1 TO Nx DO
	    IF open[j]<0.5 THEN
	    BEGIN
	       jj := jj+1;
	       AAsub[ii,jj] := AA[i,j];
	    END;
      END;
   END;

   Nxsub := ii; {New size}
   mtt_solve(xsub,AAsub,BB,Nxsub); {Solve AAx=BB}

   ii := 0;
   FOR i := 1 TO Nx DO
      BEGIN
	 IF open[i]<0.5 THEN
	 BEGIN
	    ii := ii+1; 
	    xnew[i] := xsub[ii];
	 END
	 ELSE
	 xnew[i] := 0.0;
      END;
END;{mtt_implicit}			  

Added mtt/bin/trans/p/mtt_lubksb.p version [c3d7f1be65].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_lubksb(a: StateMatrix; n: INTEGER; indx: StateVector; VAR b: StateVector);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }

{
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/08/17 12:58:16  peterg
## Initial revision
##
###############################################################
}


(* Programs using LUBKSB must define the types
TYPE
   glnarray = ARRAY [1..n] OF real;
   glindx = ARRAY [1..n] OF integer;
   glnpbynp = ARRAY [1..np,1..np] OF real;
in the main routine *)
VAR
   j,ip,ii,i: integer;
   sum: real;
BEGIN
   ii := 0;
   FOR i := 1 TO n DO BEGIN
      ip := indx[i];
      sum := b[ip];
      b[ip] := b[i];
      IF  (ii <> 0) THEN BEGIN
         FOR j := ii TO i-1 DO BEGIN
            sum := sum-a[i,j]*b[j]
         END
      END ELSE IF (sum <> 0.0) THEN BEGIN
         ii := i
      END;
      b[i] := sum
   END;
   FOR i := n DOWNTO 1 DO BEGIN
      sum := b[i];
      IF (i < n) THEN BEGIN
         FOR j := i+1 TO n DO BEGIN
            sum := sum-a[i,j]*b[j]
         END
      END;
      b[i] := sum/a[i,i]
   END
END;

Added mtt/bin/trans/p/mtt_ludcmp.p version [46fed2d80a].





















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_ludcmp(VAR a: StateMatrix; n: integer;
		     VAR indx: StateVector; VAR d: real);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }

{
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/08/14 07:58:13  peterg
## Initial revision
##
###############################################################
}

(* Programs using LUDCMP must define the types
TYPE
   glnpbynp = ARRAY [1..np,1..np] OF real;
   glnarray = ARRAY [1..n] OF real;
   glindx = ARRAY [1..n] OF integer;
in the main routine. *)

CONST
   tiny=1.0e-20;

VAR
   k,j,imax,i: integer;
   sum,dum,big: real;
   vv: glnarray;

BEGIN
   d := 1.0;
   FOR i := 1 TO n DO BEGIN
      big := 0.0;
      FOR j := 1 TO n DO IF (abs(a[i,j]) > big) THEN big := abs(a[i,j]);
      IF (big = 0.0) THEN BEGIN
         writeln('pause in LUDCMP - singular matrix'); readln
      END;
      vv[i] := 1.0/big
   END;
   FOR j := 1 TO n DO BEGIN
      FOR i := 1 TO j-1 DO BEGIN
         sum := a[i,j];
         FOR k := 1 TO i-1 DO BEGIN
            sum := sum-a[i,k]*a[k,j]
         END;
         a[i,j] := sum
      END;
      big := 0.0;
      FOR i := j TO n DO BEGIN
         sum := a[i,j];
         FOR k := 1 TO j-1 DO BEGIN
            sum := sum-a[i,k]*a[k,j]
         END;
         a[i,j] := sum;
         dum := vv[i]*abs(sum);
         IF (dum > big) THEN BEGIN
            big := dum;
            imax := i
         END
      END;
      IF (j <> imax) THEN BEGIN
         FOR k := 1 TO n DO BEGIN
            dum := a[imax,k];
            a[imax,k] := a[j,k];
            a[j,k] := dum
         END;
         d := -d;
         vv[imax] := vv[j]
      END;
      indx[j] := imax;
      IF (a[j,j] = 0.0) THEN a[j,j] := tiny;
      IF (j <> n) THEN BEGIN
         dum := 1.0/a[j,j];
         FOR i := j+1 TO n DO BEGIN
            a[i,j] := a[i,j]*dum
         END
      END
   END;
END;

Added mtt/bin/trans/p/mtt_par_update.p version [5ebd9ad207].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_numpar_update(VAR new_numpar : ParameterVector;
				   old_numpar : ParameterVector);
VAR i : INTEGER;
   
BEGIN {mtt_numpar_update}

   for i:=1 TO MTT_Npar DO {copy values}
      new_numpar[i] := old_numpar[i];
   
   WHILE NOT eof(numparfile) DO {read and update values}
      IF NOT (numparfile^ = chr("#")) THEN
      BEGIN
	 read(numparfile,i); read(numparfile,new_numpar[i]);
      END
      ELSE
	 readln(numparfile);
   
END {mtt_numpar_update};

PROCEDURE mtt_state_update(VAR new_state : StateVector;
			       old_state : StateVector);

VAR i : INTEGER;
   
BEGIN {mtt_state_update}

   for i:=1 TO MTT_Nx DO {copy values}
      new_state[i] := old_state[i];

   WHILE NOT eof(statefile) DO {read and update values}
      IF NOT (statefile^ = chr("#")) THEN
      BEGIN
	 read(statefile,i); read(statefile,new_state[i]);
      END
      ELSE
	 readln(statefile);
      
END {mtt_state_update};

PROCEDURE mtt_simpar_update(VAR dt : REAL);
BEGIN {mtt_simpar_update}

   WHILE NOT eof(simparfile) DO {read and update values}
   BEGIN
      IF NOT (simparfile^ = chr("#")) THEN
	 read(simparfile,dt);
      readln(simparfile); 
   END
END {mtt_simpar_update};

Added mtt/bin/trans/p/mtt_solve.p version [284b083bf3].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_solve(VAR x : StateVector;
			A : StateMatrix;
			B : StateVector;
			n : integer);

{

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.3  1999/10/26 23:44:36  peterg
% % Now packages up mtt_solve_lud OR mtt_solve_svd
% %
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

VAR
   i	     : integer;
   wmax,wmin : real;
   w	     : StateVector ;
   v	     : StateMatrix;


(*$I $MTTPATH/trans/p/mtt_solve_lud.p *)
(* I $MTTPATH/trans/p/mtt_solve_svd.p *)

BEGIN{mtt_solve}
      mtt_solve_lud(x,A,B,N);
      (*** mtt_solve_svd(x,A,B,N); ***)
END{mtt_solve};

Added mtt/bin/trans/p/mtt_solve_lu.p version [a11985cf48].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_solve_lu.p(VAR x     : StateVector;
			A     : StateMatrix;
		    VAR B     : StateVector;
			n     : integer;
			Small : real);

{
Linear equation solution via LU factorisation}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

VAR
   i	     : integer;
   wmax,wmin : real;
   w	     : StateVector ;
   v	     : StateMatrix;

(*$I svdcmp.p *)
(*$I svbksb.p *)

BEGIN{mtt_solve}
(* decompose matrix A using SVD *)
   svdcmp(A,n,n,w,v);
   
(* find maximum singular value *)
   wmax := 0.0;
   FOR i := 1 to n DO BEGIN
      IF  (w[i] > wmax) THEN  wmax := w[i]
   END;
   
(* define "small" *)
   wmin := wmax*Small;
   
(* zero the "small" singular values *)
   FOR i := 1 to n DO BEGIN
      IF  (w[i] < wmin) THEN  w[i] := 0.0
   END;
   
(* backsubstitute for B *)
      svbksb(A,w,v,n,n,B,x);
   
END{mtt_solve};

Added mtt/bin/trans/p/mtt_solve_lud.p version [ec0698602b].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_solve_lud(VAR x     : StateVector;
			A     : StateMatrix;
		        B     : StateVector;
			n     : integer);

{
Linear equation solution via LU factorisation

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.3  1999/10/26 23:37:20  peterg
% % Put include files here.
% %
% % Revision 1.2  1998/08/17 15:56:10  peterg
% % Uses LU decomposition - much faster than SVD when N>100
% %
% % Revision 1.1  1998/08/17 12:52:16  peterg
% % Initial revision
% %
% % Revision 1.1  1998/08/17 12:41:37  peterg
% % Initial revision
% %
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

VAR
   i	 : integer;
   d	 : real;
   Index : StateVector;


(*$I $MTTPATH/trans/p/mtt_ludcmp.p *)
(*$I $MTTPATH/trans/p/mtt_lubksb.p *)

BEGIN{mtt_solve_lud}
   (* decompose matrix A using LU decomposition *)
   mtt_ludcmp(A,n,Index,d);
   
   (* backsubstitute for B *)
   mtt_lubksb(A,n,Index,B);

   (* x now lives in B *)
   FOR i := 1 TO n DO
      x[i] := B[i];
   
END{mtt_solve_lud};






Added mtt/bin/trans/p/mtt_solve_svd.p version [4ad1314c58].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_solve_svd(VAR x : StateVector;
			    A : StateMatrix;
			VAR B : StateVector;
			    n : integer);

{Solve linear equation via svd}

{

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  1998/08/17 12:40:25  peterg
% % Renamed mtt_solve to mtt_solve_svd
% % -- now also have mtt_solve_lu
% %
% % Revision 1.1  1998/08/17 12:38:52  peterg
% % Initial revision
% %
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

CONST
   Small =  1e-6; (* Criteroion for small svd *)
VAR
   i	     : integer;
   wmax,wmin : real;
   w	     : StateVector ;
   v	     : StateMatrix;

(*$I svdcmp.p *)
(*$I svbksb.p *)

BEGIN{mtt_solve}
(* decompose matrix A using SVD *)
   svdcmp(A,n,n,w,v);
   
(* find maximum singular value *)
   wmax := 0.0;
   FOR i := 1 to n DO BEGIN
      IF  (w[i] > wmax) THEN  wmax := w[i]
   END;
   
(* define "small" *)
   wmin := wmax*Small;
   
(* zero the "small" singular values *)
   FOR i := 1 to n DO BEGIN
      IF  (w[i] < wmin) THEN  w[i] := 0.0
   END;
   
(* backsubstitute for B *)
      svbksb(A,w,v,n,n,B,x);
   
END{mtt_solve};

Added mtt/bin/trans/p/mtt_sparse.p version [c94532268f].





























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_sparse(	 b	 : glnarray;
			 n,iters : INTEGER;
		     VAR x	 : glnarray);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }
{*
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1998/08/15 13:49:19  peterg
## iters now passed as an argument.
##
## Revision 1.4  1998/08/15 09:33:25  peterg
## Deleted the commented out stuff
##
## Revision 1.3  1998/08/15 09:30:05  peterg
## Commented out the cariabel iteration stuff
##
## Revision 1.2  1998/08/15 08:26:30  peterg
## This is variable interations version - now going on to fixed
## iterations
##
## Revision 1.1  1998/08/13 14:58:35  peterg
## Initial revision
##
## Revision 1.1  1998/08/13 08:40:40  peterg
## Initial revision
##
###############################################################
*}

(* Programs using routine SPARSE must define the type
TYPE
   glnarray = ARRAY [1..n] OF real;
in the main routine. They must also provide two routines,
PROCEDURE asub(x: glnarray; VAR y: glnarray; n: integer);
and
PROCEDURE atsub(x: glnarray; VAR z: glnarray; n: integer);
which calculate A*x and (A transpose)*x *)
   
VAR
   j,iter,irst: integer;
   rp,gg,gam,eps2,dgg,bsq,anum,aden: real;
   g,h,xi,xj: glnarray;
   
BEGIN {mtt_sparse}
   mtt_asub(x,xi,n);
   rp := 0.0;
   bsq := 0.0;
   FOR j := 1 TO n DO BEGIN
      xi[j] := xi[j]-b[j];
   END;
   mtt_atsub(xi,g,n);
   FOR j := 1 TO n DO BEGIN
      g[j] := -g[j];
      h[j] := g[j]
   END;
   FOR iter := 1 TO iters DO BEGIN
      mtt_asub(h,xi,n);
      anum := 0.0;
      aden := 0.0;
      FOR j := 1 TO n DO BEGIN
         anum := anum+g[j]*h[j];
         aden := aden+sqr(xi[j])
      END;
      anum := anum/aden;
      FOR j := 1 TO n DO BEGIN
         xi[j] := x[j];
         x[j] := x[j]+anum*h[j]
      END;
      mtt_asub(x,xj,n);
      FOR j := 1 TO n DO BEGIN
         xj[j] := xj[j]-b[j];
      END;
      mtt_atsub(xj,xi,n);
      gg := 0.0;
      dgg := 0.0;
      FOR j := 1 TO n DO BEGIN
         gg := gg+sqr(g[j]);
         dgg := dgg+(xi[j]+g[j])*xi[j]
      END;
      gam := dgg/gg;
      FOR j := 1 TO n DO BEGIN
         g[j] := -xi[j];
         h[j] := g[j]+gam*h[j]
      END
   END;
END {mtt_sparse};

Added mtt/bin/trans/p/mtt_update.p version [36e3f6e075].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_update(VAR xnew	    : StateVector;
		         dx,x,AAx   : StateVector;
		     VAR AA	    : StateMatrix;
			 DT	    : REAL;
			 STEPFACTOR : INTEGER;
			 Nx	    : INTEGER;
			 METHOD	    : IntegrationMethod);

{
 ###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1998/08/15 13:48:35  peterg
## New update methods
##
## Revision 1.4  1998/08/14 10:54:58  peterg
## Use sparse computation where possible
##
###############################################################
}

CONST
   Small = 0.000001;
   
VAR
   i,j : INTEGER;
   BB  : StateVector;
   DDT : REAL;
   
(*$I mtt_solve_lud.p *)
(*$I mtt_sparse.p *)
   
BEGIN{mtt_update}
   
   IF Method=1 THEN {Euler}
   BEGIN{Euler}
      DDT := DT/STEPFACTOR;
	 FOR i := 1 TO  Nx DO
	    xnew[i] := xnew[i] + dx[i]*DDT;
   END {Euler}
   ELSE IF (Method=2) OR (METHOD=3) OR (METHOD=4) THEN {Implicit}
      BEGIN {Implicit methods}
	 
	 FOR i := 1 TO  Nx DO {BB is (1-A*dt)*x +dx*dt}
	    BB[i] := AAx[i] + DT*dx[i];

	 {Solve the equation AAx = B}
	 IF (Method=2) OR (METHOD=3) THEN {Use SVD}
	    mtt_solve_lud(xnew,AA,BB,Nx)
	 ELSE {Sparse CG solution}
	    mtt_sparse(BB,Nx,STEPFACTOR,xnew);
      END{Implicit methods}
      ELSE
	 Writeln("Method >4 is not defined");
   
END{mtt_update};




Added mtt/bin/trans/p/mtt_write.p version [0a11e8a899].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE mtt_write(t	  : REAL;
		    x	  : StateVector;
		    y	  : OutputVector;
		    nx,ny : INTEGER);

{*
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
      Pascal function mtt_write
      P.J. Gawthrop July 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1999/03/15 21:57:38  peterg
## Removed the # symbol
##
## Revision 1.4  1998/11/26 13:31:30  peterg
## Put missing space after 2nd t
##
## Revision 1.3  1998/07/25 20:41:38  peterg
## Spaces between numbers
##
## Revision 1.2  1998/07/25 14:04:14  peterg
## Changed format
##
## Revision 1.1  1998/07/25 09:47:25  peterg
## Initial revision
##
###############################################################


*}

CONST TAB=9;
 
VAR
   i : INTEGER;
   
BEGIN
   write(t,chr(TAB));
   FOR i := 1 TO ny DO
      write(y[i],chr(TAB));

   write(t,chr(TAB));
   FOR i := 1 TO nx DO
      write(x[i],chr(TAB));
   writeln;
END;
   

Added mtt/bin/trans/p/sign.p version [52b4a0069f].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
FUNCTION sign(x	: REAL) : REAL;
{ This useful function is missing from Pascal }

BEGIN
   IF X>=0 THEN
      sign := 1
   ELSE
      sign := -1;
END; { sign }

Added mtt/bin/trans/p/sparse.p version [a1c1b1b77d].




























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE sparse(b: glnarray; n: integer; VAR x: glnarray; VAR rsq: real);
{*
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################
*}

(* Programs using routine SPARSE must define the type
TYPE
   glnarray = ARRAY [1..n] OF real;
in the main routine. They must also provide two routines,
PROCEDURE asub(x: glnarray; VAR y: glnarray; n: integer);
and
PROCEDURE atsub(x: glnarray; VAR z: glnarray; n: integer);
which calculate A*x and (A transpose)*x *)
LABEL 1,99;
CONST
   eps=1.0e-6;
VAR
   j,iter,irst: integer;
   rp,gg,gam,eps2,dgg,bsq,anum,aden: real;
   g,h,xi,xj: glnarray;
BEGIN
   eps2 := n*sqr(eps);
   irst := 0;
1:   irst := irst+1;
   asub(x,xi,n);
   rp := 0.0;
   bsq := 0.0;
   FOR j := 1 TO n DO BEGIN
      bsq := bsq+sqr(b[j]);
      xi[j] := xi[j]-b[j];
      rp := rp+sqr(xi[j])
   END;
   atsub(xi,g,n);
   FOR j := 1 TO n DO BEGIN
      g[j] := -g[j];
      h[j] := g[j]
   END;
   FOR iter := 1 TO 10*n DO BEGIN
      asub(h,xi,n);
      anum := 0.0;
      aden := 0.0;
      FOR j := 1 TO n DO BEGIN
         anum := anum+g[j]*h[j];
         aden := aden+sqr(xi[j])
      END;
      IF (aden = 0.0) THEN BEGIN
         writeln('pause in routine SPARSE');
         writeln('very singular matrix'); readln
      END;
      anum := anum/aden;
      FOR j := 1 TO n DO BEGIN
         xi[j] := x[j];
         x[j] := x[j]+anum*h[j]
      END;
      asub(x,xj,n);
      rsq := 0.0;
      FOR j := 1 TO n DO BEGIN
         xj[j] := xj[j]-b[j];
         rsq := rsq+sqr(xj[j])
      END;
      IF ((rsq = rp) OR (rsq <= bsq*eps2)) THEN GOTO 99;
      IF (rsq > rp) THEN BEGIN
         FOR j := 1 TO n DO BEGIN
            x[j] := xi[j]
         END;
         IF (irst >= 3) THEN GOTO 99;
         GOTO 1
      END;
      rp := rsq;
      atsub(xj,xi,n);
      gg := 0.0;
      dgg := 0.0;
      FOR j := 1 TO n DO BEGIN
         gg := gg+sqr(g[j]);
         dgg := dgg+(xi[j]+g[j])*xi[j]
      END;
      IF (gg = 0.0) THEN GOTO 99;
      gam := dgg/gg;
      FOR j := 1 TO n DO BEGIN
         g[j] := -xi[j];
         h[j] := g[j]+gam*h[j]
      END
   END;
   writeln('pause in routine SPARSE');
   writeln('too many iterations'); readln;
99:   END;

Added mtt/bin/trans/p/svbksb.p version [d97150a209].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE svbksb(u: glmpbynp; w: glnparray; v: glnpbynp;
       m,n: integer; b: glmparray; VAR x: glnparray);
{

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  1998/08/12 11:09:54  peterg
% % Taken from NR share library nrpas13 as  SVBKSB.PAS
% % and renamed  svbksb.p
% %
% % Revision 1.1  1998/08/12 11:09:02  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }


(* Programs using SVBKSB must define the types
TYPE
   glnparray = ARRAY [1..np] OF real;
   glmparray = ARRAY [1..mp] OF real;
   glnpbynp = ARRAY [1..np,1..np] OF real;
   glmpbynp = ARRAY [1..mp,1..np] OF real;
in the main routine. *)
VAR
   jj,j,i: integer;
   s: real;
   tmp: glnparray;
BEGIN
   FOR j := 1 TO n DO BEGIN
      s := 0.0;
      IF (w[j] <> 0.0) THEN BEGIN
         FOR i := 1 TO m DO BEGIN
            s := s+u[i,j]*b[i]
         END;
         s := s/w[j]
      END;
      tmp[j] := s
   END;
   FOR j := 1 TO n DO BEGIN
      s := 0.0;
      FOR jj := 1 TO n DO BEGIN
         s := s+v[j,jj]*tmp[jj];
      END;
      x[j] := s
   END
END;

Added mtt/bin/trans/p/svdcmp.p version [33402da454].

























































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE svdcmp(VAR a: glmpbynp; m,n: integer;
		 VAR w: glnparray; VAR v: glnpbynp);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }

{
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.4  1998/08/12 11:26:39  peterg
% % Zapped unnecessary np and mp arguments
% %
% % Revision 1.3  1998/08/12 11:08:03  peterg
% % Put in pythag routine to compute z = sqrt(y^2 + z^2) (as in book)
% % Save loop index l as ll when jumping from loop - using l itself is
% % undefined
% %
% % Revision 1.2  1998/08/12 11:05:33  peterg
% % Taken from NR share library nrpas13 as SVDCMP.PAS
% % and renamed svdcmp.p
% %
% % Revision 1.1  1998/08/12 11:03:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}


(* Programs using routine SVDCMP must define the types
TYPE
   glnparray = ARRAY [1..np] OF real;
   glmpbynp = ARRAY [1..mp,1..np] OF real;
   glnpbynp = ARRAY [1..np,1..np] OF real;
in the main routine. *)
LABEL 1,2,3;
CONST
   nmax=100;
VAR
   nm,l,k,j,jj,its,i,ll	       : integer;
   z,y,x,scale,s,h,g,f,c,anorm : real;
   rv1			       : ARRAY [1..nmax] OF real;
			  
FUNCTION pythag(a,b : real): real;
VAR p,at,bt : REAL;
BEGIN
   at:=abs(a);
   bt:=abs(b);
   IF at>bt THEN
      p:= at*sqrt(1.0+sqr(bt/at))
   ELSE
      IF bt=0.0 THEN
	 p := 0.0
      ELSE
	 p := bt*sqrt(1.0+sqr(at/bt));
   pythag := p;
END{pythag};
			   
   
FUNCTION sign(a,b : real): real;
   BEGIN
      IF (b >= 0.0) THEN sign := abs(a) ELSE sign := -abs(a)
   END;
FUNCTION max(a,b: real): real;
   BEGIN
      IF (a > b) THEN max := a ELSE max := b
   END;
BEGIN
   g := 0.0;
   scale := 0.0;
   anorm := 0.0;
   FOR i := 1 TO n DO BEGIN
      l := i+1;
      rv1[i] := scale*g;
      g := 0.0;
      s := 0.0;
      scale := 0.0;
      IF (i <= m) THEN BEGIN
         FOR k := i TO m DO BEGIN
            scale := scale+abs(a[k,i])
         END;
         IF (scale <> 0.0) THEN BEGIN
            FOR k := i TO m DO BEGIN
               a[k,i] := a[k,i]/scale;
               s := s+a[k,i]*a[k,i]
            END;
            f := a[i,i];
            g := -sign(sqrt(s),f);
            h := f*g-s;
            a[i,i] := f-g;
            IF (i <> n) THEN BEGIN
               FOR j := l TO n DO BEGIN
                  s := 0.0;
                  FOR k := i TO m DO BEGIN
                     s := s+a[k,i]*a[k,j]
                  END;
                  f := s/h;
                  FOR k := i TO m DO BEGIN
                     a[k,j] := a[k,j]+
                        f*a[k,i]
                  END
               END
            END;
            FOR k := i TO m DO BEGIN
               a[k,i] := scale*a[k,i]
            END
         END
      END;
      w[i] := scale*g;
      g := 0.0;
      s := 0.0;
      scale := 0.0;
      IF ((i <= m) AND (i <> n)) THEN BEGIN
         FOR k := l TO n DO BEGIN
            scale := scale+abs(a[i,k])
         END;
         IF (scale <> 0.0) THEN BEGIN
            FOR k := l TO n DO BEGIN
               a[i,k] := a[i,k]/scale;
               s := s+a[i,k]*a[i,k]
            END;
            f := a[i,l];
            g := -sign(sqrt(s),f);
            h := f*g-s;
            a[i,l] := f-g;
            FOR k := l TO n DO BEGIN
               rv1[k] := a[i,k]/h
            END;
            IF (i <> m) THEN BEGIN
               FOR j := l TO m DO BEGIN
                  s := 0.0;
                  FOR k := l TO n DO BEGIN
                     s := s+a[j,k]*a[i,k]
                  END;
                  FOR k := l TO n DO BEGIN
                     a[j,k] := a[j,k]
                        +s*rv1[k]
                  END
               END
            END;
            FOR k := l TO n DO BEGIN
               a[i,k] := scale*a[i,k]
            END
         END
      END;
      anorm := max(anorm,(abs(w[i])+abs(rv1[i])));
   END;
   FOR i := n DOWNTO 1 DO BEGIN
      IF (i < n) THEN BEGIN
         IF (g <> 0.0) THEN BEGIN
            FOR j := l TO n DO BEGIN
	       v[j,i] := (a[i,j]/a[i,l])/g;
	    END;
            FOR j := l TO n DO BEGIN
               s := 0.0;
               FOR k := l TO n DO BEGIN
                  s := s+a[i,k]*v[k,j]
               END;
               FOR k := l TO n DO BEGIN
                  v[k,j] := v[k,j]+s*v[k,i]
               END
            END
         END;
         FOR j := l TO n DO BEGIN
            v[i,j] := 0.0;
            v[j,i] := 0.0
         END
      END;
      v[i,i] := 1.0;
      g := rv1[i];
      l := i
   END;
   FOR i := n DOWNTO 1 DO BEGIN
      l := i+1;
      g := w[i];
      IF (i < n) THEN BEGIN
         FOR j := l TO n DO BEGIN
            a[i,j] := 0.0
         END
      END;
      IF (g <> 0.0) THEN BEGIN
         g := 1.0/g;
         IF (i <> n) THEN BEGIN
            FOR j := l TO n DO BEGIN
               s := 0.0;
               FOR k := l TO m DO BEGIN
                  s := s+a[k,i]*a[k,j]
               END;
               f := (s/a[i,i])*g;
               FOR k := i TO m DO BEGIN
                  a[k,j] := a[k,j]+f*a[k,i]
               END
            END
         END;
         FOR j := i TO m DO BEGIN
            a[j,i] := a[j,i]*g
         END
      END ELSE BEGIN
         FOR j := i TO m DO BEGIN
            a[j,i] := 0.0
         END
      END;
      a[i,i] := a[i,i]+1.0
   END;
   FOR k := n DOWNTO 1 DO BEGIN
      FOR its := 1 TO 30 DO BEGIN
         FOR l := k DOWNTO 1 DO BEGIN
            nm := l-1;
            IF ((abs(rv1[l])+anorm) = anorm) THEN
	       BEGIN
		  ll:=l;
		  GOTO 2;
	       END;
	    IF nm>0 THEN {* Put in by me - see book *}
	       IF ((abs(w[nm])+anorm) = anorm) THEN
		  BEGIN
		     ll:=l;
		     GOTO 1
		  END;
         END;
1:         c := 0.0;
         s := 1.0;
         FOR i := ll TO k DO BEGIN
            f := s*rv1[i];
            IF ((abs(f)+anorm) <> anorm) THEN BEGIN
	       g := w[i];
	       {**h := sqrt(f*f+g*g);**}
	       h := pythag(f,g);
               w[i] := h;
               h := 1.0/h;
               c := (g*h);
               s := -(f*h);
               FOR j := 1 TO m DO BEGIN
                  y := a[j,nm];
                  z := a[j,i];
                  a[j,nm] := (y*c)+(z*s);
                  a[j,i] := -(y*s)+(z*c)
               END
            END
         END;
2:         z := w[k];
         IF (ll = k) THEN BEGIN
            IF (z < 0.0) THEN BEGIN
               w[k] := -z;
               FOR j := 1 TO n DO BEGIN
               v[j,k] := -v[j,k]
            END
         END;
         GOTO 3
         END;
         IF (its = 30) THEN BEGIN
            writeln ('no convergence in 30 SVDCMP iterations'); readln
	 END;
         x := w[l];
         nm := k-1;
         y := w[nm];
         g := rv1[nm];
         h := rv1[k];
         f := ((y-z)*(y+z)+(g-h)*(g+h))/(2.0*h*y);
	 {***g := sqrt(f*f+1.0); writeln(g);***}
	 g := pythag(f,1.0);
         f := ((x-z)*(x+z)+h*((y/(f+sign(g,f)))-h))/x;
         c := 1.0;
         s := 1.0;
         FOR j := ll TO nm DO BEGIN
            i := j+1;
            g := rv1[i];
            y := w[i];
            h := s*g;
            g := c*g;
            {**z := sqrt(f*f+h*h);**}
	    z := pythag(f,h);
            rv1[j] := z;
            c := f/z;
            s := h/z;
            f := (x*c)+(g*s);
            g := -(x*s)+(g*c);
            h := y*s;
            y := y*c;
            FOR jj := 1 TO n DO BEGIN
               x := v[jj,j];
               z := v[jj,i];
               v[jj,j] := (x*c)+(z*s);
               v[jj,i] := -(x*s)+(z*c)
            END;
            {**z := sqrt(f*f+h*h);**}
	    z := pythag(f,h);
            w[j] := z;
            IF (z <> 0.0) THEN BEGIN
               z := 1.0/z;
               c := f*z;
               s := h*z
            END;
            f := (c*g)+(s*y);
            x := -(s*g)+(c*y);
            FOR jj := 1 TO m DO BEGIN
               y := a[jj,j];
               z := a[jj,i];
               a[jj,j] := (y*c)+(z*s);
               a[jj,i] := -(y*s)+(z*c)
            END
         END;
         rv1[l] := 0.0;
         rv1[k] := f;
         w[k] := x
      END;
3:   END
END;

Added mtt/bin/trans/p/zero_input.p version [c982d1d936].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
PROCEDURE zero_input(VAR x : InputVector;
			 N : INTEGER);
VAR i : INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      x[i] := 0.0;
END;


Added mtt/bin/trans/p/zero_matrix.p version [799bc2655a].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE zero_matrix(VAR A : StateMatrix;
			  N : INTEGER);
VAR i,j	:  INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      FOR j:=1 TO N DO
	 A[i,j] := 0.0;
END;


Added mtt/bin/trans/p/zero_state.p version [e67a8f8538].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
PROCEDURE zero_state(VAR x : StateVector;
			 N : INTEGER);
VAR i : INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      x[i] := 0.0;
END;


Added mtt/bin/trans/p/zero_vector.p version [51fb965f2c].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
PROCEDURE zero_vector(VAR x : StateVector;
			  N : INTEGER);
VAR i : INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      x[i] := 0.0;
END;


Added mtt/bin/trans/p/zeros.p version [e8ec334d34].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
PROCEDURE zeros(VAR A	: StateMatrix;
		    N	: INTEGER);
VAR i,j	:  INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      FOR j:=1 TO N DO
	 A[i,j] = 0.0;
END;


Added mtt/bin/trans/p2oct version [3ed0dbadda].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2cr_txt2txt

# Label file to constitutive relationship conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/02/07 15:48:33  peterg
## Initial revision
##
## Revision 1.3  1998/07/29 11:09:39  peterg
## Now matches ^$1$ not $1!
##
## Revision 1.2  1998/03/08 21:02:55  peterg
## Now does multiple crs.
##
# Revision 1.1  1997/03/20  12:23:21  peterg
# Initial revision
#
###############################################################



# Inform user
echo "Creating $1_cr.txt"

rm -f mtt_error


# This is the main transformation using gawk 
# And remove crs with same name as system
gawk -f $MTTPATH/trans/awk/lbl2cr.awk $1_lbl.txt  2>mtt_error.txt |\
grep -v "^$1$" \
> $1_cr.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Added mtt/bin/trans/rbg2abg_m version [94d244aa2c].























































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg2abg_m
#
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.21  2004/09/12 22:27:27  geraint
## Appended 't' to fopen mode string to open in text mode.
##
## Revision 1.20  2004/02/19 12:05:49  gawthrop
## Fix prob. when no bonds
##
## Revision 1.19  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.18  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.17  2000/12/05 12:04:03  peterg
## Changed function name to name()
##
## Revision 1.16  2000/12/05 09:04:08  peterg
## Fixed function () compatibility problem.
##
## Revision 1.15  2000/11/03 14:53:33  peterg
## Copy NOTPAR as well
##
## Revision 1.14  2000/09/14 08:41:35  peterg
## Strip off the additional direction info from rbonds
##
## Revision 1.13  2000/03/16 12:53:26  peterg
## Added copy of the %VAR declarations
## Put in the endfunction statement
##
## Revision 1.12  1998/07/28 19:07:48  peterg
## Writes out N_ports as well as n_ports
##
## Revision 1.11  1998/07/25 16:14:44  peterg
## *** empty log message ***
##
## Revision 1.10  1998/07/08 15:34:56  peterg
## Sorted out error exit status
##
## Revision 1.9  1998/07/08 08:24:26  peterg
## Added -I option -- if set prints out the indormation messages
##
## Revision 1.8  1998/02/19 08:57:02  peterg
## Fixed mtt-info bug -- confused filename with number
##
## Revision 1.7  1997/08/05 08:38:23  peterg
## Added n-ports to the argument list in the comment.
##
## Revision 1.6  1996/12/04 21:52:01  peterg
## Uses filenum and fopen instead of filename.
##
## Revision 1.5  1996/08/25 09:20:32  peter
## General error handling.
##
## Revision 1.4  1996/08/24 17:57:41  peter
## Removed `touch mtt_info.txt'
##
## Revision 1.3  1996/08/24 14:58:56  peter
## Fixed missprint - mtt_err --> mtt_error
##
## Revision 1.2  1996/08/24 14:33:07  peter
## Error handling included.
##
## Revision 1.1  1996/08/05 12:22:16  peter
## Initial revision
##
###############################################################

# Raw bond graph to structured acausal bond graph: mfile format
# The structured BG is described by four matrices:
#   junctions: describes the junctions -
#     Column 1   Index of component (see components)
#     Column 2.. Indices of bonds on junction (see jbonds)
#                  rows may be padded with zeros
#
#   jbonds:    describes the true bonds -
#     Column 1     Index of component (see components)
#     Column 2     Direction
#                    1 away from junction
#                   -1 towards junction
#     Column 3     Causality 
#                     1 stroke at arrow end
#                    -1 stroke at other end
#                     0 no stroke (ie acausal)
#     Columns 4:5  x,y coordinates of non-arrow end (in Fig)
#     Columns 6:7  x,y coordinates of arrow end (in Fig)
#
#   mbonds:    describes the modulation bonds -
#     Column 1     Index of component at non-arrow end
#     Column 2     Index of component at arrow end
#     Columns 4:5  x,y coordinates of non-arrow end (in Fig)
#     Columns 6:7  x,y coordinates of arrow end (in Fig)
#
#   components: describes the comonents -
#     Column 1     Type of component
#                    0  0-junction
#                    1  1-junction
#                    2  R component
#                    3  C component
#                    4  I component
#                    11 TF component
#                    12 GY component
#                    13 A  component
#     Column 2     Flag for explicit junction
#                    4  Explicit component (4 means text type)
#                    0  Implicit component
#     Column 3-14    fig file information (see fig documentation)
#
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-nounits )
                units=no;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

## Set up some vars
sys=$1
lbl_file=${sys}_lbl.txt
abg_file=${sys}_abg.m

# Remove the old log file
rm -f rbg2abg_m.log
rm -f ${abg_file}

#Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log  2>mtt_error.txt << EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');

  %Convert from the fig version of the bonds to a structured version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg
  [n_ports, junk] = size(port_list)
 
  N_ports = 0;
  for i=1:n_ports		# Count the true number of ports.
    [subport,n_sub] = split_port(port_list(i,:), ',');
    N_ports = N_ports+n_sub;
  end;
 
  [n_bonds,m_bonds] = size(rbonds);
  if n_bonds>0
    rbonds = rbonds(:,1:6);  # Strip  the directional information
  endif

  [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, ...
                               infofile,errorfile);

  %Write the function m-file for the causal bond graph
  write_abg(name,bonds,components,n_vector_bonds);    
EOF

## Sets the units for the abg file
test_units()
{ 
  grep '^[\s]*[#|%]UNITS' < ${lbl_file} >/dev/null
  if [ $? = "0" ]; then 
    grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
    gawk '{
      printf("mtt_units.sh %s %s %s %s %s\n", sys, $2, $3, $4, $5)
    }' sys=${sys}  | sh | grep ERROR
    if [ $? = "0" ]; then
      echo "    " *MTT_ERRROR: domains and units are not OK - exiting
      exit 1  
    else
      echo "    " domains and units are OK 
    fi
  else
    echo "  no domains or units declared"
  fi
} 

check_ports_exist()
{
 declared_ports=`grep '^[\s]*[#|%]UNITS' < ${lbl_file} | gawk '{print $2}'`
  for declared_port in $declared_ports; do
    grep "${sys}\.ports\.${declared_port}\.type" ${abg_file} >/dev/null
    if [ $? = "1" ]; then
      echo "*MTT_ERRROR: Units declared for non-existent port ${declared_port}"
      exit 1
    fi
  done
}

set_units()
{ 
  grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
  gawk '{
    printf("  %s.ports.%s.domain = \"%s\";\n", sys, $2, $3);
    printf("  %s.ports.%s.units.effort = \"%s\";\n", sys, $2, $4);
    printf("  %s.ports.%s.units.flow = \"%s\";\n", sys, $2, $5);
  }' sys=${sys}
} 

if [ -z "$units" ]; then
  echo Checking port domains and units
  check_ports_exist;
  test_units;
  echo "## Port domain and units" >> ${abg_file}
  set_units >> ${abg_file}
fi

# Append any VAR declarations
if [ -f "$1_lbl.txt" ]; then
  echo "## Explicit variable declarations" >> ${abg_file}
  grep '^[\s]*[%|#][V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
  grep '^[\s]*[%|#]NOT[V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
fi

## Close off the function
echo "endfunction" >> ${abg_file}

## Errors and info
if [ "$info" = "info" ]; then
  cat mtt_info.txt    
fi

if mtt_error mtt_error.txt
then
    exit 0
else
    exit 1
fi

Added mtt/bin/trans/rbg2ibg_m version [22334b9ac4].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg2ibg_m
# Based on rbg2abg_m

while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-I)
	    info=info;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Set up some vars
sys=$1
ibg=${sys}_ibg.m
err=mtt_error.txt
log=rbg2ibg_m.log

# Remove the old log file
rm -f ${ibg}
rm -f ${log}

# Inform user
echo Creating ${ibg}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');
  
  ## Interpret the connections from the fig version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg;
  [n_ports, junk] = size(port_list);
  
  ## Strip the directional information
  rbonds = rbonds(:,1:6);
  
  [bonds] = ...
      rbg2ibg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, ...
	      infofile,errorfile);
  
  ## Write the intermediate bond graph m-file
  write_ibg(name,bonds);
EOF

# Errors and info
if [ "$info" = "info" ]; then
    cat mtt_info.txt
fi

if mtt_error mtt_error.txt; then
    exit 0
else
    exit 1
fi

Added mtt/bin/trans/rbg_fig2m version [fe3a6b77ac].






















































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg_fig2m
# Raw  bond-graph conversion from fig to matlab
# P.J.Gawthrop May 1996
# Modified June 1996 to handle xfig version 3
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2005/08/05 15:35:17  gawthrop
## Fixed _ in ports
##
## Revision 1.13  2005/03/15 15:03:55  gawthrop
## Now works for Hierarchical systems
##
## Revision 1.12  2005/03/15 12:49:28  gawthrop
## Handle descriptive (inc maths) text as well
##
## Revision 1.11  2005/03/15 12:03:48  gawthrop
## New labg.fig rep - pretty LaTeX figures.
##
## Revision 1.10  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.9  2002/01/11 03:44:19  geraint
## Breaks compounds objects into individual components. Eliminates "incorrect object code error" in cbg.ps when component is not causally complete.
##
## Revision 1.8  2001/10/15 14:25:44  gawthrop
## Now handles white space at the end of component names
## Converts ports lables [1:5] into [1,2,3,4,5]
##
## Revision 1.7  2001/07/24 22:42:59  geraint
## Fixes problem when lbl.txt does not end with newline.
##
## Revision 1.6  2001/05/24 07:48:17  gawthrop
## Include artwork in the cbg.fig file
##
## Revision 1.5  2001/03/23 14:56:21  gawthrop
## Now puts space after header fields + write _port.fig
##
## Revision 1.4  2000/09/14 08:41:51  peterg
## *** empty log message ***
##
## Revision 1.3  1997/03/19 09:50:24  peterg
## Now creates the sabg (stripped abg) file.
##
# Revision 1.2  1996/08/30  10:17:41  peter
# New path for awk script.
#
## Revision 1.1  1996/08/05 20:13:33  peter
## Initial revision
##
###############################################################

cmp2latex() {
  gawk '{
  ## 
  ## Zap trailing \001
  A = substr($0,1,length($0)-4);

  ## Find before and after:
  N=split(A,B,":");

  ## Split into fields
  M=split(B[1],C);

  ## Dont modify port labels (except for _ -> \_)
  if(index(C[M],"[")==1){
       for (i=1;i<M;i++){
         if (C[i]=="_")
           C[i] = "\\\\_";
         printf("%s ",C[i]);
       }
       printf("%s\\001\n",C[M]);
   }
  else{
     ## Set special flag
     FlagCol = 9
     C[FlagCol] = 6;

     ## Write out modified version
     for (i=1;i<M;i++)
       printf("%s ",C[i]);

    if (N==1)
      printf("\\\\B{%s}\\001\n",C[M]);
    if (N==2)
      if(index(B[2],"[")==1){
        gsub(/_/,"\\\\_",B[2]);
        printf("\\\\B{%s}:%s\\001\n",C[M],B[2]);
      }
      else
        printf("\\\\BB{%s}{%s}\\001\n",C[M],B[2]);
   }
  }'  
}

art2latex() {
  gawk '{
  ## Is it text?
  is_text="4";
  if ($1!=is_text)
    print $0
  else
  {
  ## Zap trailing \001
  B = substr($0,1,length($0)-4);

  ## Split into fields
  M=split(B,C);

  ## Set special flag
  FlagCol = 9
  C[FlagCol] = 6;

  ## Write out modified version
  N = 14;
  for (i=1;i<N;i++)
    printf("%s ",C[i]);

  for (i=N;i<=M;i++) {
    if ( (index(C[i],"_")>0)&&(index(C[i],"$")==0) )
      C[i] = sprintf("$%s$", C[i]);
    printf(" %s",C[i]);
  }

  printf("\\001\n");

  }
  }'  
}


# Inform user
echo "Creating $1_rbg.m"
echo "Creating $1_cmp.m"
echo "Creating $1_head.fig"
echo "Creating $1_fig.fig"
echo "Creating $1_cmp.fig"
echo "Creating $1_port.fig"
echo "Creating $1_sabg.fig"
echo "Creating $1_art.fig"
echo "Creating $1_labg.fig"


# Remove some files that I'm going to append to.
rm -f $1_fig.fig
rm -f $1_head.fig
rm -f $1_cmp.fig
rm -f $1_port.fig
rm -f $1_bnd.fig
rm -f $1_art.fig

# Create blank files
touch $1_fig.fig
touch $1_head.fig
touch $1_cmp.fig
touch $1_port.fig
touch $1_bnd.fig
touch $1_art.fig

# Deletes trailing white space in component names
# and break compound objects
sed 's/[	 ]*\\001/\\001/' < $1_abg.fig |\
grep -v "^6 [0-9 ]*" | grep -v "^-6$" >$1_abg.mtt1

# Replace [1:5] with [1,2,3,4,5]
gawk '{
   if (match($14, /\[1:[0-9]*\]/)){
    range = substr($14,2,length($14)-6);
    split(range,a,":");
    str = "1";
    for (i=2;i<=a[2];i++) str = sprintf("%s,%i", str, i);
    sub(/1:[0-9]*/, str, $14);
   }
    print $0
}' < $1_abg.mtt1 > $1_abg.mtt2


# The following horrible sed thing is to replace tab by ----
# this is because I can't get sed to recognise tabs even if FS=" ".
echo "" > $1_abg.mtt3
sed 's/	/---- /'<$1_abg.mtt2 >> $1_abg.mtt3

# This is the main transformation using awk
cat $1_lbl.txt $1_abg.mtt3 |  gawk -f $MTTPATH/trans/awk/rbg_fig2m.awk $1 no_alpha_sort=$2

rm -f $1_abg.mtt

#Create the stripped abg file
cat $1_head.fig $1_bnd.fig $1_cmp.fig> $1_sabg.fig

#Create the latexed abg file
##latex_tidy $1_art.fig
art2latex< $1_art.fig  >$1_lart.fig
cmp2latex<$1_cmp.fig  >$1_lcmp.fig
cat $1_head.fig $1_bnd.fig $1_lcmp.fig | sed 's/---- /	/' > $1_labg.fig
strip_comments < $1_lart.fig | sed 's/---- /	/' >> $1_labg.fig






Added mtt/bin/trans/rcs_header.m version [48ce935dee].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Added mtt/bin/trans/rcs_header.sh version [0521c8429a].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

Added mtt/bin/trans/rdae2dae_r version [96eb754660].




























































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rdae2dae_r
# Reduce equations to raw differential-algebraic equation conversion
# P.J.Gawthrop  8th May 1991, May 1994, June 1996
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2001/04/11 09:44:26  gawthrop
## Fixed cc and c problems to do with pow(x,y) and integers
## mtt/lib/reduce/fix_c.r is included in rdae2dae and cse2smx_lang for
## -c, -cc and -oct options
##
## Revision 1.6  2001/02/03 13:40:45  gawthrop
## Added explicit MTTNu
##
## Revision 1.5  2000/12/28 12:39:02  peterg
## Put under RCS
##
## Revision 1.4  2000/09/04 08:42:53  peterg
## Put in extra echo to space output
##
## Revision 1.3  2000/09/02 15:55:11  peterg
## Now doesn't include def files in da files
##
## Revision 1.2  2000/09/01 13:36:15  peterg
## Added -partition option
##
## Revision 1.1  2000/09/01 12:14:44  peterg
## Initial revision
##
## Revision 1.3  1998/03/07 12:57:19  peterg
## Fixed logname bug
##
## Revision 1.2  1998/03/07 12:51:20  peterg
## This is the new version of ese2dae - it does not do the CRs at this
## stage to give reduce an easier time.
##
## rese2ese_r does the constitutive relationship bit
##
## Revision 1.1  1998/03/07 12:49:31  peterg
## Initial revision
##
## Revision 1.12  1998/01/31 16:22:59  peterg
## Added IF MTTNx>0 THEN and IF MTTNy>0 THEN before the relevant
## assignements of MTTdX and MTTY to themselves.
##
## Revision 1.11  1997/09/18 09:45:08  peterg
## Canged the comment about linux reduce -- reduce reads this for some
## reason.
##
## Revision 1.10  1997/09/15 14:21:18  peterg
## Reads ese file twice to avoid a bug in Linux reduce !!!???
##
## Revision 1.9  1997/08/30 09:59:31  peterg
## Changed mehtod of writing out mtty to avoid a strange segmentation violation.
## Now uses MTTY := MTTY; approach.
##
## Revision 1.8  1997/04/23 09:31:20  peterg
## Now reads in the (top level) def file in the generated reduce code.
##
# Revision 1.7  1997/04/23  09:23:15  peterg
# Two argument version in preparation for heirarchical version
#
# Revision 1.6  1996/11/21  15:47:48  peterg
# Now inputs _params.r not _sympar.r
#
## Revision 1.5  1996/11/02 10:17:35  peterg
## Removed default constitutive relationship input.
##
# Revision 1.4  1996/09/12  12:10:05  peter
# Now reads the default constitutive relationship file.
#
## Revision 1.3  1996/08/25 09:43:26  peter
## General error handling.
##
## Revision 1.2  1996/08/25 08:31:28  peter
## Error handling added.
##
###############################################################


while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
	-fixcc )
                include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'`
                blurb2='fixing c and cc code';
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

#Create the top-level system name
topname=$1

#Create the system names
if [ -z "$2" ]; 
    then
	sysname=$topname;
    else
	sysname=$1_$2;
fi

defname=$topname"_def.r"
crname=$topname"_cr.r"
subsname=$topname"_subs.r"
rdaename=$sysname"_rdae.r"
daename=$sysname"_dae.r"
logname="rdae2dae.log"

# Inform user
echo Creating $daename $blurb $blurb2

# Remove the old log file
rm -f $logname

# Use symbolic algebra to accomplish the transformation
$SYMBOLIC >$logname  << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

% CRs
in "$crname";

% Raw dae
in "$rdaename";

% Substitution
in "$subsname";

% Fix c code if required
$include


OFF Echo;
OFF Nat;

%Create the output file
OUT "$daename";

%write "in ""$defname""";

write "MTTNu := ", MTTNu;
write "MTTNx := ", MTTNx;
write "MTTNz := ", MTTNz;
write "MTTNy := ", MTTNy;
write "MTTNyz := ", MTTNyz;

% State
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Nonstate
MTT_Matrix := MTTZ$ 
MTT_Matrix_name := "MTTZ"$
MTT_Matrix_n := MTTNz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTy$ 
MTT_Matrix_name := "MTTy"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Zero outputs
MTT_Matrix := MTTYz$ 
MTT_Matrix_name := "MTTYz"$
MTT_Matrix_n := MTTNyz$
MTT_Matrix_m := 1$
Reduce_Matrix()$
SHUT "$daename";
quit;

EOF

#if [ -n "$partition" ]; then
#  rm -f mtt_junk
#  # Now for the subsystems
#  # Find subsystems
#  subsystems=`mtt_get_subsystems $1`
#
#  for subsystem in $subsystems; do
#  echo Doing $subsystem
#  ucname="MTT_"$subsystem"_uc"
#
#  Nu=`mtt_getsize -internal $subsystem u`
#  echo Nu $Nu
#
#  # Use symbolic algebra to accomplish the transformation
#  $SYMBOLIC >$logname  << EOF
#
#  %Read the formatting function
#  in "$MTTPATH/trans/reduce_matrix.r";
#
#  % Definitions
#  in "$defname";
#
#  % Elementary system equations
#  in "$rdaename";
#
#  OFF Echo;
#  OFF Nat;
# 
#  %Create the output file
#  OUT "mtt_junk";
#  % Connecting inputs
#  MTT_Matrix := $ucname $
#  MTT_Matrix_name := "$ucname" $
#  MTT_Matrix_n := $Nu $
#  MTT_Matrix_m := 1$
#  Reduce_Matrix()$
#
#  shut "mtt_junk";
#EOF
#  echo >> $1_dae.r
#  echo %Connections for subsystem $subsystem  >> $1_dae.r
#  echo >> $1_dae.r
#
#  cat mtt_junk >> $1_dae.r
#  rm -rf mtt_junk
#  done
#fi

echo "END;" >> $1_dae.r

# Now invoke the standard error handling.
mtt_error_r $logname

Added mtt/bin/trans/reduce_matrix.r version [80a2f375d5].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in reduce form
% P.J.Gawthrop  January 22 1998
% Copyright (c) P.J.Gawthrop, 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/01/22 10:39:01  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




PROCEDURE Reduce_Matrix;
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
     write "clear ", MTT_Matrix_name, ";";
     write "MATRIX ", MTT_Matrix_name, "(", MTT_Matrix_n, ",",
                                            MTT_Matrix_m, ");";
    
    FOR i := 1:MTT_Matrix_n DO
      FOR j := 1:MTT_Matrix_m DO IF MTT_Matrix(i,j) NEQ 0 THEN
        write MTT_Matrix_name, "(", i, ",", j, ") := ",
                                            MTT_Matrix(i,j), ";";
    END;
END;

END;;

Added mtt/bin/trans/rep_txt2sh version [6825c9a064].


















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rep_txt2sh
# Executes shell commands for report.

# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2002/05/01 14:07:44  gawthrop
## Added -dr foo (reads files from foo) dir.
##
## Revision 1.6  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.5  2000/11/27 10:13:25  peterg
## Now passes though options as second argument
##
## Revision 1.4  1998/04/14 18:17:15  peterg
## More messages about Makefile
##
## Revision 1.3  1998/04/14 18:01:04  peterg
## Now executes a Makefile (if it exists)
##
# Revision 1.2  1997/12/06  14:27:53  peterg
# No changes.
#
## Revision 1.1  1997/08/26 09:06:11  peterg
## Initial revision
##
###############################################################

# Execute a make if Makefile exists
if [ -f Makefile ]; then
  echo Executing the Makefile
  make    
  echo Done executing the Makefile
  echo
fi

## Get switches (if any)
mtt_switches=$2

# Inform user
echo "Creating representations for $1_rep.tex"

# Check for old (2 arg) version and update if necessary
mtt_count=`strip_comments < $1_rep.txt | grep -c 'mtt '`
if [ "$mtt_count" = "0" ]; then
  echo 'Hmm .. seems to be an old format. creating new file'
  echo "Old version saved as $1_rep.txt.SAVE"
  mv $1_rep.txt $1_rep.txt.SAVE
  strip_comments < $1_rep.txt.SAVE |\
  gawk '{print "mtt", sys, $1, $2}' sys="$1" >$1_rep.txt
fi


# Execute the commands - quietly and untidily!
# But use switches
# | sed "s/mtt /mtt -q -u $mtt_switches /" #| tee -a JUNK  | sh

strip_comments< $1_rep.txt | gawk '
{
  ## Add in the external switches
  sub("mtt", sprintf("mtt %s", mtt_switches));
      
  ## Count the switches (noting that -i -dr -dw and -de have an argument)
  ## and make up a string (switches) containing them
  Switches=0; switches = "";
  for (i=2;i<=NF;i++) {
    if (match($i,"-")==1) {
      Switches++;
      switches=sprintf("%s%s", switches, $i);
    }
    if (match($i,"-i")==1) {
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dr")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dw")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-de")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
  }
  System = $(Switches+2)
  Representation = $(Switches+3);
  Multiple = "odes odeso sms smso daes daeso";
  Language = $(Switches+4);

  args = $(Switches+5);
  if ( (length(args)>0)&&(match(Language,"ps")>0)) {
    __Args = sprintf("-%s", gensub(/_/, "-", "g", args) );
  }
  else
  {
  __Args = "";
  }

  ## mtt command
  printf("%s\n", $0);

  ## Add in the main mtt switches
  __Args = sprintf("%s%s", switches, __Args);
 
  ## Zap -q -u
  gsub("-[qu]","", __Args);

  ## Zap blanks
  gsub(" ","", __Args);

  ## copy result to long name file
  SysRepLang = sprintf("%s_%s.%s", System, Representation, Language);
  if (length(__Args)==0)
    __Args = "-noargs";
  SysRepArgLang = sprintf("%s_%s%s.%s", System, Representation, __Args, Language);
  printf("echo Creating %s\n", SysRepArgLang);
  printf("cp %s %s\n", SysRepLang, SysRepArgLang);

}' mtt_switches="${mtt_switches}"  | sh

echo "Done creating representations for $1_rep.tex"




Added mtt/bin/trans/rep_txt2tex version [a95f4950eb].































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rep_txt2tex
# Converts the text file dercribing a report to a report.
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2003/08/19 15:40:25  gawthrop
## Fix _ prob in section headers.
##
## Revision 1.5  2003/08/19 13:10:47  gawthrop
## More arg stuff
##
## Revision 1.4  2002/05/09 16:07:54  gawthrop
## Now handles multiple options whis .tex files as well
##
## Revision 1.3  2002/05/01 14:07:05  gawthrop
## Added -dr foo (reads files from foo) dir.
##
## Revision 1.2  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.1  2000/12/27 15:57:31  peterg
## Initial revision
##
## Revision 1.15  2000/04/06 10:57:12  peterg
## Removed debug line
##
## Revision 1.14  2000/04/06 10:51:14  peterg
## replaces $PWD by `pwd` for sh compatibility
##
## Revision 1.13  1999/10/19 23:47:27  peterg
## Rewrote for the extra representations - but with .ps at the end
## Need to retrofit old desc files using multiple figures
##
## Revision 1.12  1999/10/19 03:33:01  peterg
## Temporaraly removed argument stripping
##
## Revision 1.11  1999/02/17 02:00:29  peterg
## Absolute pathname for files.
## Indirect include via \input
##
## Revision 1.10  1998/08/25 12:45:27  peterg
## Added icad to languages
##
## Revision 1.9  1998/03/09 13:26:22  peterg
## Removed `system' from part and section headers.
##
## Revision 1.8  1998/02/09 08:59:35  peterg
## Minor debugging lines removed.
##
## Revision 1.7  1998/01/29 19:32:33  peterg
## Removed a spurious X from the file -- tried to run  the X server !!!
##
## Revision 1.6  1997/12/04 22:08:52  peterg
## Handles multiple odes.ps files
##
## Revision 1.5  1997/12/04 17:05:57  peterg
## Now handles multiple odeso.ps files
##
## Revision 1.4  1997/08/25 09:15:48  peterg
## Don't do sections for unrecognised languages.
##
# Revision 1.3  1997/06/27  13:28:25  peterg
# New version using explicit command line arguments in the text file
#
## Revision 1.2  1997/05/19 16:11:36  peterg
## Modified section headers.
##
# Revision 1.1  1996/08/18  20:00:38  peter
# Initial revision
#
###############################################################

documenttype=$2; 
mtt_switches=$4

## Remove -u and -q
mtt_switches=`echo ${mtt_switches} | sed 's/-[qu]//g'`

if [  "$documenttype" = "book" ]; then # do book version
  # Inform user
  echo "Creating $1_rep.tex (directory version)"
  strip_comments < $1_rep.txt|\
  gawk '
BEGIN{
oldpart = ""
}
{
  # Find directory name.
  for (i=1;i<NF;i++){
    if ($i=="-d") 
       directory=$(i+1);
  }
  # Find next to last name
  N=split(directory,a,"/");
  if (N>1) 
    part = a[N-1];
  if (length(part)>0)
    if (part!=oldpart)
      printf("\\part{\\textbf{%s}}\n", part);
  oldpart=part;
  printf("\\chapter{\\textbf{%s}}\n", $(NF-2));
  printf("\\label{chap:%s(%s)}\n", $(NF-2), directory);
  printf("\\input{%s/%s_rep}\n\n", directory, $(NF-2));
  }' > $1_rep.tex


else # do article and section version

if [ -z "$3" ]; then
  directory="";
else
  directory=$3/;
fi

# Inform user
echo "Creating $1_rep.tex"

# Create the LaTeX file
strip_comments <$1_rep.txt |\
gawk '
{
  ## Add in the external switches
  sub("mtt", sprintf("mtt %s", mtt_switches));
  
  ## Count the switches (noting that -i -dr -dw and -de have an argument)
  ## and make up a string (switches) containing them
  Switches=0; switches = "";
  for (i=2;i<=NF;i++) {
    if (match($i,"-")==1) {
      Switches++;
      switches=sprintf("%s%s", switches, $i);
    }
    if (match($i,"-i")==1) {
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dr")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dw")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-de")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
  }
  print "%%%" switches
  System = $(Switches+2)
  Representation = $(Switches+3);
  Multiple = "odes odeso sms smso daes daeso";
  Language = $(Switches+4);
  Languages = "tex txt r m c h ps icad";
  args = $(Switches+5);
  quote = "\047";
  args = gensub(quote, "", "g",  args);
  args = gensub(/"/, "", "g",  args);
#  args = substr(Args,2,length(Args)-2);
#  if ( (length(Args)>0)&&(match(Multiple,Representation)>0)) {
  if ( (length(args)>0)&&(match(Language,"ps")>0)) {
    _Args = sprintf("-%s", args); 
    __Args = sprintf("-%s", gensub(/_/, "_", "g", args) );
    ___Args = sprintf("-%s", gensub(/,/, "-", "g", args) );
  }
  else
  {
  _Args = "";
  __Args = "";
  ___Args = "";
  }

  ## Add in the mtt args
  __Args = sprintf("%s%s", switches, __Args);

  ## Treat no arguments as -noargs
  if (length(__Args)==0){
    __Args = "-noargs";
    header_args = "";
  }
  else {
    header_args = __Args;
    gsub("-", " -", header_args);
    gsub(/_/, "\\_", header_args);
    header_args = sprintf("(%s)", header_args); 
  }

print "%%" __Args "%%"
#  print "DEBUG", Language, args, _Args, __Args
  RepLang = sprintf("%s%s.%s", Representation, __Args, Language);
  SysRepLang = sprintf("%s_%s", System, RepLang);
  SysRepLangArgs = sprintf("%s_%s", System, RepLang, __Args);
  SysRep = sprintf("%s_%s%s", System, Representation, __Args);
  filename = gensub(/,/, "-", "g", SysRep);
  FileName = sprintf("%s/%s", PWD, filename);
  section_head = sprintf("\\textbf{%s\\_%s.%s} \\emph{%s}",
   System,Representation,Language, header_args);
   
# section headings
    if (match(Languages,Language)>0) {
    print "\n\n\\section{" section_head "}";
    print "\\label{sec:" SysRepLangArgs "}";
    print "\\index{\\textbf{" System "} -- " Representation "}";
    
    print "\n\nMTT command:";
    print "\\begin{verbatim}";
      for (i=1;i<=NF;i++) printf("%s ", $i);
    print "\n\\end{verbatim}";
    }

# tex files
    if( match("tex",Language)>0) {
      printf("  \\input{%s}\n", FileName);
#      command = sprintf("sed s!fig{!fig{%s! < %s_%s.%s", Directory, System, Representation, Language);
#      system(command);    
}

# text files
    if( match("txt r m c h icad",Language)>0) {
      print "  \\begin{verbatim}";
      command = sprintf("cat %s.txt", filename);
      system(command);
      print "  \\end{verbatim}";  
    }
# ps files
    if( match("ps",Language)>0) {
      printf("This representation is given as Figure \\Ref{fig:%s}.\n", SysRepLangArgs);
      Label = sprintf("%s", SysRepLangArgs);
      Caption = sprintf("System \\textbf{%s}, representation %s (%s)", System, Representation, __Args);
      printf("\\fig{%s}\n    {%s}\n    {0.9}\n    {%s}\n",FileName,Label,Caption);
  }
}
END {

}' mtt_switches="${mtt_switches}" System=$1 Directory=$directory PWD=`pwd` > $1_rep.tex

fi

Added mtt/bin/trans/reps_txt2tk version [05813b0e5a].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: reps_txt2tk
# Creates tk/tcl file for xmtt.
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/12/28 12:39:34  peterg
## Put under RCS
##
## Revision 1.4  2000/04/05 07:37:27  peterg
## *** empty log message ***
##
## Revision 1.3  1999/08/18 06:15:48  peterg
## Stripped down to just representations menu - see mtt_make_menu
##
## Revision 1.2  1999/03/09 00:03:19  peterg
## Revisions for xmtt
##
## Revision 1.1  1998/10/20 08:13:14  peterg
## Initial revision
##
###############################################################

sep='|'; # Separates the languages from the rest.

# Create reps menu
gawk --field-separator=$sep '{
  
# Find the rep and the title
  split($1,REP," ");
  rep=REP[1];
# find the languages
  N=split($2,LANG," ");

# Important representation?
 if (index(rep,"*")) {
    # Zap *
    rep=substr(rep,1,length(rep)-1);
    sub(/\*/,"",$1);
    printf("\n# Menus for representation %s\n", rep)
    printf(".rep.rep add  cascade -label \"%s\" -menu .rep.rep.%s\n", $1, rep);
    printf("menu .rep.rep.%s\n", rep);
    for (i=1;i<=N;i++) {
      lang = LANG[i];
      printf(" set mtt {mtt_pause $args $system %s %s} \n", rep, lang); 
      title = sprintf("Output_log_for_representation_%s_(language_%s)", rep, lang);
      printf(".rep.rep.%s add  command -label  \"%s\" ", rep, lang);
      printf(" -command  \"exec xterm -title %s -e $mtt  &\" \n", title); 
   }
 }
 else {
    printf("\n# Menus for representation %s\n", rep)
    printf(".repall.repall add  cascade  -label \"%s\" -menu .repall.repall.%s\n", $1, rep);
    printf("menu .repall.repall.%s\n", rep);
    for (i=1;i<=N;i++) {
      printf(" set mtt {mtt $args $system %s %s; mtt_pause} \n", rep, LANG[i]); 
      printf(".repall.repall.%s add  command -label  \"%s\" ", rep, LANG[i]);
      printf(" -command  \"exec echo $mtt &; exec $mtt &\" \n"); 
   }
 }
}'

Added mtt/bin/trans/rest version [2530ab00f0].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rest
# Gives remainder of space seperated string
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/10/10 07:44:20  peterg
## Initial revision
##
###############################################################

echo $1 | cut -d ' ' -f 2-

Added mtt/bin/trans/simpar_txt2h version [fe5f9ab6b8].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: simpar_txt2h

# Numerical parameters to c format
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/05/13 08:56:28  peterg
## Initial revision
##
###############################################################


system=$1


# Inform user
echo "Creating $1_simpar.h"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_simpar.h
echo "Simulation parameter file for system $1 ($1_simpar.h)"   >> $1_simpar.h
echo "This file provides the system simulation parameters in c form"  >> $1_simpar.h
echo "Generated by MTT at `date`"  >> $1_simpar.h
echo "from $1_simpar.txt"  >> $1_simpar.h
echo '*/' >> $1_simpar.h
echo  >> $1_simpar.h

# Now do the parameters

sed 's/ //g' $1_simpar.txt |\
 gawk -F '=' '/=/ {print "#define", $1, $2}'   >> $1_simpar.h






Added mtt/bin/trans/sm2can_r version [27a5fb1925].





















































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2can_r
# state matrices to various canonical forms.
# P.J.Gawthrop  12 Jan 1997
# Copyright (c) P.J.Gawthrop 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Inform user
echo Creating $1_can.r -- NOTE this is for SISO systems only.

# Remove the old log file
rm -f sm2can_r.log

# Use reduce to accomplish the transformation
reduce >sm2can_r.log << EOF

in "$1_def.r";
in "$1_sm.r";
in "$1_tf.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;

% Find the controllability and observibility matrices.
MATRIX MTTCon(MTTNx,MTTNX);
MTTAB := MTTB;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon(i,j) := MTTAB(i,1);
   MTTAB := MTTA*MTTAB;
  END;

MATRIX MTTObs(MTTNx,MTTNX);
MTTCA := MTTC;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA;
  END;

%Canonical forms:
% This statement makes Gs a scalar transfer function
Gs := MTTtf(1,1);

% Numerator and denominator polynomials
bs := num(gs);
as := den(gs);

% extract coeficients and divide by coeff of s^n
% reverse operator puts list with highest oder coeffs first
ai := reverse(coeff(as,s));
a0 := first(ai);
MTTn := length(ai) - 1;


% Normalised coeficients;
ai := reverse(coeff(as/a0,s));
bi := reverse(coeff(bs/a0,s));
MTTm := length(bi)-1;

% Zap the (unity) first element of ai list;
ai := rest(ai);

% System in controller form
% MTTA_c matrix
matrix MTTA_c(MTTn,MTTn);

% First row is ai coefficients
for i := 1:MTTn do
  MTTA_c(1,i) := -part(ai,i);

% (MTTn-1)x(MTTn-1) unit matrix in lower left-land corner (if n>1)
if MTTn>1 then
  for i := 1:MTTn-1 do
    MTTA_c(i+1,i) := 1;

% B_c vector;
matrix MTTB_c(MTTn,1);
MTTB_c(1,1) := 1;

% C_c vector;
matrix MTTC_c(1,MTTn);
for i := 1:MTTm+1 do
  MTTC_c(1,i+MTTn-MTTm-1) := part(bi,i);

% D_c
MTTD_c := MTTD;

%Observable form.
MTTA_o := tp(MTTA_c);
MTTB_o := tp(MTTC_c);
MTTC_o := tp(MTTB_c);
MTTD_o := MTTD;

%Controllability matrix of controllable form
MATRIX MTTCon_c(MTTNx,MTTNX);
MTTAB := MTTB_c;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon_c(i,j) := MTTAB(i,1);
   MTTAB := MTTA_c*MTTAB;
  END;

% Transformation matrix;
MTTT_c := MTTCon_c*MTTCon^(-1);

%Observability matrix of observer form
MATRIX MTTObs_o(MTTNx,MTTNX);
MTTCA := MTTC_o;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs_o(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA_o;
  END;

% Transformation matrix;
MTTT_o := MTTObs^(-1)*MTTObs_o;

%%%%  Controller design %%%%%

% gain in controller form:
matrix MTTk_c(1,mttn);
matrix alpha_c(9,1);
alpha_c(1,1) := alpha_c1;
alpha_c(2,1) := alpha_c2;
alpha_c(3,1) := alpha_c3;
alpha_c(4,1) := alpha_c4;
alpha_c(5,1) := alpha_c5;
alpha_c(6,1) := alpha_c6;
alpha_c(7,1) := alpha_c7;
alpha_c(8,1) := alpha_c8;
alpha_c(9,1) := alpha_c9;


for i := 1:MTTNx do
 MTTk_c(1,i) := alpha_c(i,1) - part(ai,i);

% Gain in physical form
MTTk := MTTk_c*MTTT_c;

%%%%  Observer design %%%%%
% gain in Observer form:
matrix MTTl_o(MTTn,1);
matrix alpha_o(9,1);
alpha_o(1,1) := alpha_o1;
alpha_o(2,1) := alpha_o2;
alpha_o(3,1) := alpha_o3;
alpha_o(4,1) := alpha_o4;
alpha_o(5,1) := alpha_o5;
alpha_o(6,1) := alpha_o6;
alpha_o(7,1) := alpha_o7;
alpha_o(8,1) := alpha_o8;
alpha_o(9,1) := alpha_o9;

for i := 1:MTTNx DO
 MTTL_o(i,1) := alpha_o(i,1) - part(ai,i);

% Gain in physical form
MTTL := MTTT_o*MTTL_o;

% Steady-state stuff
% Create the matrix [A B; C D];
matrix ABCD(MTTn+1,MTTn+1);
for i := 1:MTTNx do
  for j := 1:MTTNx do
    ABCD(i,j) := MTTA(i,j);

for i :=1:MTTNx do
  ABCD(i,MTTNx+1) := MTTB(i,1);

for j := 1:MTTNx do
  ABCD(MTTNx+1,j) := MTTC(1,j);

ABCD(MTTNx+1,MTTNx+1) := MTTD(1,1);

matrix zero_one(MTTNx+1,1);
zero_one(MTTNx+1,1) := 1;

%Find N vector
Nxu := ABCD^(-1)*zero_one;

%Extract the parts
MATRIX MTTX_r(MTTNx,1);
FOR i := 1:MTTNx DO
  MTTX_r(i,1) := Nxu(i,1);

MTTu_r := Nxu(MTTNx+1,1);


% Compensator

matrix zero(MTTNx,1);
%State matrices
MTTA_comp := MTTA - MTTL*MTTC - MTTB*MTTK;
MTTB_comp := -MTTL;
MTTC_comp := -MTTK;

%Transfer function
%Ds := C_d*((s*MTTI - A_d)^(-1))*B_d;
%MTTTFC := Ds;

%Create the output file
OUT "$1_can.r";

%Write out the matrices.

% Controllable form
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
Reduce_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
Reduce_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  -Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Observer Gain matrix - observer form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$


% Controllable form
MTT_Matrix := MTTA_comp$ 
MTT_Matrix_name := "MTTA_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_comp$ 
MTT_Matrix_name := "MTTB_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
Reduce_Matrix()$

MTT_Matrix := MTTC_comp$ 
MTT_Matrix_name := "MTTC_comp"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


KX := MTTK*MTTX_r;
MTTu_r := MTTu_r + KX(1,1);



MTTu_r := MTTu_r;
write "END;";

SHUT "$1_can.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r sm2can_r.log

Added mtt/bin/trans/sm2ir_m version [1eb0d56a1a].

















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2ir_m

# Transforms descriptor matrix rep to step response


# Copyright (c) P.J.Gawthrop, 1996.


echo Creating $1_ir.m
echo Creating $1_iro.m
rm -f sm2ir_m.log
rm -f $1_ir.m
rm -f $1_iro.m
rm -f mtt_error

# if [ "$2" = "" ]; 
# then
#   PARAMS='T=[0:0.1:10];u0=ones(nu,1);x0=zeros(nx,1);'
#   echo Using default parameter $PARAMS
# else
#   PARAMS=$2;
# fi

# PARAMS="$PARAMS ;"

$MATRIX << EOF > sm2ir_m.log 2>mtt_error.txt

  % Read in the numeric system parameters
  mttpar = $1_numpar;

 % Read in the simulation parameters
  simpar = $1_simpar;

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  T=[0:simpar.dt:simpar.last]';

  if exist('u0')==0
    u0 = ones(nu,1);
  end;

  if exist('x0')==0
    x0 = zeros(nx,1);
  end;


  [n,m]=size(T);
  if m>n
    T=T';
  end;

  [A,B,C,D] = $1_sm(mttpar);
  [y,x] = sm2ir(A,B,C,D,T,u0,x0);

  if nx>0
    write_matrix([T x], '$1_ir');
  end;
  if ny>0
    write_matrix([T y], '$1_iro');
  end;

EOF

# Write info
touch mtt_info.txt
cat mtt_info.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Added mtt/bin/trans/sm2smc_r version [78545ed4d4].




































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2smc_r
# state matrices to controller canonical form + related matrices
# P.J.Gawthrop  12 Jan 1997
# Copyright (c) P.J.Gawthrop 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/22 13:17:37  peterg
## Initial revision
##
###############################################################
Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi


# Inform user
echo Creating $1_smc.r $blurb

# Remove the old log file
rm -f sm2smc_r.log

# Use reduce to accomplish the transformation
reduce >sm2smc_r.log << EOF

in "$1_def.r";
in "$1_sm.r";
in "$1_tf.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;

% Find the controllability matrix
MATRIX MTTCon(MTTNx,MTTNX);
MTTAB := MTTB;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon(i,j) := MTTAB(i,1);
   MTTAB := MTTA*MTTAB;
  END;


%Canonical forms:
% This statement makes Gs a scalar transfer function
Gs := MTTtf(1,1);

% Numerator and denominator polynomials
bs := num(gs);
as := den(gs);

% extract coeficients and divide by coeff of s^n
% reverse operator puts list with highest oder coeffs first
ai := reverse(coeff(as,s));
a0 := first(ai);
MTTn := length(ai) - 1;


% Normalised coeficients;
ai := reverse(coeff(as/a0,s));
bi := reverse(coeff(bs/a0,s));
MTTm := length(bi)-1;

% Zap the (unity) first element of ai list;
ai := rest(ai);

% System in controller form
% MTTA_c matrix
matrix MTTA_c(MTTn,MTTn);

% First row is ai coefficients
for i := 1:MTTn do
  MTTA_c(1,i) := -part(ai,i);

% (MTTn-1)x(MTTn-1) unit matrix in lower left-land corner (if n>1)
if MTTn>1 then
  for i := 1:MTTn-1 do
    MTTA_c(i+1,i) := 1;

% B_c vector;
matrix MTTB_c(MTTn,1);
MTTB_c(1,1) := 1;

% C_c vector;
matrix MTTC_c(1,MTTn);
for i := 1:MTTm+1 do
  MTTC_c(1,i+MTTn-MTTm-1) := part(bi,i);

% D_c
MTTD_c := MTTD;

%Controllability matrix of controllable form
MATRIX MTTCon_c(MTTNx,MTTNX);
MTTAB := MTTB_c;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon_c(i,j) := MTTAB(i,1);
   MTTAB := MTTA_c*MTTAB;
  END;

% Transformation matrix;
MTTT_c := MTTCon_c*MTTCon^(-1);



%Create the output file
OUT "$1_smc.r";

%Write out the matrices.

% Controllable form
write "%  - Controller form";
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTD_c$ 
MTT_Matrix_name := "MTTD_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := 1$
Reduce_Matrix()$


write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "END;";

SHUT "$1_smc.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r sm2smc_r.log

Added mtt/bin/trans/sm2smo_r version [f17cab7b54].





































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2smo_r
# state matrices to cobserver form
# P.J.Gawthrop  12 Jan 1997
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/09/11 10:53:54  peterg
## Uses 1st io of mimo to create siso
##
## Revision 1.2  1998/01/22 13:25:22  peterg
## Added END;; to output file.
##
## Revision 1.1  1998/01/22 13:16:43  peterg
## Initial revision
##
###############################################################

Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi
# Inform user
echo Creating $1_smo.r $blurb

# Remove the old log file
rm -f sm2smo_r.log

# Use reduce to accomplish the transformation
reduce >sm2smo_r.log << EOF

in "$1_def.r";
in "$1_sm.r";
in "$1_tf.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;

% Find  observibility matrix.
MATRIX MTTObs(MTTNx,MTTNX);
MTTCA := MTTC;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA;
  END;

%Canonical forms:
% This statement makes Gs a scalar transfer function
Gs := MTTtf(1,1);

% Numerator and denominator polynomials
bs := num(gs);
as := den(gs);

% extract coeficients and divide by coeff of s^n
% reverse operator puts list with highest oder coeffs first
ai := reverse(coeff(as,s));
a0 := first(ai);
MTTn := length(ai) - 1;


% Normalised coeficients;
ai := reverse(coeff(as/a0,s));
bi := reverse(coeff(bs/a0,s));
MTTm := length(bi)-1;

% Zap the (unity) first element of ai list;
ai := rest(ai);

% System in observer form
% MTTA_o matrix
matrix MTTA_o(MTTNx,MTTNx);

% First column is ai coefficients
for i := 1:MTTNx do
  MTTA_o(i,1) := -part(ai,i);

% (MTTNx-1)x(MTTNx-1) unit matrix in upper right-hand corner (if n>1)
if MTTNx>1 then
  for i := 1:MTTNx-1 do
    MTTA_o(i,i+1) := 1;

% C_o vector;
matrix MTTC_o(1,MTTNx);
  MTTC_o(1,1) := 1;
MTTC_o;
% B_o vector;
matrix MTTB_o(MTTNx,1);
for i := 1:MTTm+1 do
  MTTB_o(i+MTTNx-MTTm-1,1) := part(bi,i);

% D_o
MTTD_o := MTTD;

%Observability matrix of observer form
MATRIX MTTObs_o(MTTNx,MTTNX);
MTTCA := MTTC_o;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs_o(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA_o;
  END;

% Transformation matrix;
MTTT_o := MTTObs^(-1)*MTTObs_o;


%Create the output file
OUT "$1_smo.r";

%Write out the matrices.

% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTD_o$ 
MTT_Matrix_name := "MTTD_o"$
MTT_Matrix_n := 1$
MTT_Matrix_m := 1$
Reduce_Matrix()$

write "%  -Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "END;;";
SHUT "$1_smo.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r sm2smo_r.log

Added mtt/bin/trans/sm2sr_m version [9750108aef].



























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2sr_m

# Transforms descriptor matrix rep to step response


# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.16  1998/08/11 13:31:05  peterg
## Lowercase mttLAST etc
##
## Revision 1.15  1998/07/27 20:31:40  peterg
## New simpar version
##
## Revision 1.14  1998/07/25 10:00:48  peterg
## *** empty log message ***
##
## Revision 1.13  1997/06/13 12:52:18  peterg
## Removed extra ; from $PARAMS
##
# Revision 1.12  1996/09/12  18:45:31  peter
# Back to rcs.
#
# Revision 1.11  1996/08/24  14:02:39  peter
# Included glabal parameter passing.
# Proper error handling.
#
## Revision 1.10  1996/08/19 15:34:14  peter
## Now based on state - not descriptor matrices.
##
## Revision 1.9  1996/08/18 12:01:45  peter
## Unified format of time responses.
##
## Revision 1.8  1996/08/15 16:23:39  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.7  1996/08/15 11:54:32  peter
## Now has optional initial condition.
##
## Revision 1.6  1996/08/14 09:15:02  peter
## Now encapsulates the data into an m file
## Name changed
##
## Revision 1.5  1996/08/12 20:19:06  peter
## Fiddled about with parameter passing - still not right
##
## Revision 1.4  1996/08/11 19:48:04  peter
## Parameter passing added.
##
## Revision 1.3  1996/08/11 10:38:30  peter
## Minor debugging changes.
##
## Revision 1.2  1996/08/11 10:06:50  peter
## Now allows e format and NaN numbers.
##
## Revision 1.1  1996/08/11 09:45:46  peter
## Initial revision
##
###############################################################

echo Creating $1_sr.m
echo Creating $1_sro.m
rm -f sm2sr_m.log
rm -f $1_sr.m
rm -f $1_sro.m
rm -f mtt_error


# PARAMS="$PARAMS ;"

$MATRIX << EOF > sm2sr_m.log 2>mtt_error.txt

  % Read in the numeric system parameters
  mttpar = $1_numpar;

  % Read in the simulation parameters
  simpar = $1_simpar;

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.

  T=[0:simpar.dt:simpar.last]'

  if exist('u0')==0
    u0 = ones(nu,1);
  end;

  if exist('x0')==0
    x0 = zeros(nx,1);
  end;


  [n,m]=size(T);
  if m>n
    T=T';
  end;

  [A,B,C,D] = $1_sm(mttpar);
  [y,x] = sm2sr(A,B,C,D,T,u0,x0);

  if nx>0
    write_matrix([T x], '$1_sr');
  end;
  if ny>0
    write_matrix([T y], '$1_sro');
  end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt

Added mtt/bin/trans/sm_r2m version [30c0587225].


























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm_r2m
# Reduce constained state-space A,B,C,D and E matrices to Matlab
# P.J.Gawthrop July 1990, Feb 1991, May 1991, Sep 91, Dec 93, Jan 94, May 94.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1998/06/23 19:18:33  peterg
## Added optional state argument.
##
# Revision 1.6  1997/02/24  14:43:21  peterg
# Now ignores parameters that are numerical.
#
## Revision 1.5  1996/09/12 18:34:44  peter
## Back under rcs.
##
# Revision 1.4  1996/08/24  14:12:26  peter
# Global parameter passing.
#
## Revision 1.3  1996/08/19 18:38:43  peter
## Read in the numerical params etc ...
##
## Revision 1.2  1996/08/19 16:25:18  peter
## Fixed bug when Nx=0.
##
## Revision 1.1  1996/08/19 15:14:51  peter
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_sm.m

# Remove the old log file
rm -f sm_r2m.log

#Header
lang_header $1 sm m '' '[mtta,mttb,mttc,mttd]' >$1_sm.m

# Use reduce to accomplish the transformation
$SYMBOLIC >sm_r2m.log << EOF

%Read in the definitions file
IN "$1_def.r";

%Read the reduce state-space A,B,C and D matrices file
IN "$1_sm.r";

%Read in the parameter file
IN "$1_sympar.r";

OUT "$1_sm.m1";

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "mtta = zeros(", MTTNx, ",", MTTNx, ");";
write "mttb = zeros(", MTTNx, ",", MTTNu, ");";
write "mttc = zeros(", MTTNy, ",", MTTNx, ");";
write "mttd = zeros(", MTTNy, ",", MTTNu, ");";

ON NERO;	% Suppress zero elements.
mtta := mtta;
mttb := mttb;
mttc := mttc;
mttd := mttd;

OFF FORT;
write "";

SHUT "$1_sm.m1";
EOF

cat $1_sm.m1 >> $1_sm.m
#rm -f $1_sm.m1

Added mtt/bin/trans/sm_r2tex version [5fd0381795].





































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/27 16:01:35  peterg
## Initial revision
##
## Revision 1.4  1998/02/18 08:25:36  peterg
## Now uses latex_matrix for formatting
##
## Revision 1.3  1997/06/13 13:50:11  peterg
## Matrices in amstex format
##
# Revision 1.2  1997/04/18  12:54:00  peterg
# No longer does labels.
#
# Revision 1.1  1996/08/19  15:19:23  peter
# Initial revision
#
###############################################################


# Inform user
echo Creating $1_$2.tex

# Remove the old log file
rm -f sm_r2tex.log

# Use reduce to accomplish the transformation
reduce >sm_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the constrained-state matrices file
in "$1_$2.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

MATRIX MTT_Matrix(MTTNx,MTTNx);

OUT "$1_$2.tex";

%Write out the state matrices.
write "%state  matrices $1";
write "%File: $1_$2.tex";
write"";

MTT_Matrix := MTTA$ 
MTT_Matrix_name := "MTTA"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB$ 
MTT_Matrix_name := "MTTB"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC$ 
MTT_Matrix_name := "MTTC"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD $
MTT_Matrix_name := "MTTD"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

SHUT "$1_$2.tex";
quit;
EOF

Added mtt/bin/trans/smc2ssk_r version [06844ee033].






















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smc2ssk_r
# controller-form state matrices to controller gain k
# P.J.Gawthrop  Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/02/09 14:16:52  peterg
## Writes end statement to the o/p file
##
## Revision 1.2  1998/01/23 09:30:36  peterg
## Fixed a sign error - the coeficients of a(s) appear with - signs in
## the A_c matrix!
##
## Revision 1.1  1998/01/22 13:16:16  peterg
## Initial revision
##
###############################################################

Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi

# Inform user
echo Creating $1_ssk.r $blurb

# Remove the old log file
rm -f smc2ssk_r.log

# Use reduce to accomplish the transformation
reduce >smc2ssk_r.log << EOF

in "$1_def.r";
in "$1_smc.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;


%%%%  Controller design %%%%%

% gain in controller form:
matrix MTTk_c(1,MTTNx);

matrix alpha_c(9,1);
alpha_c(1,1) := alpha_c1;
alpha_c(2,1) := alpha_c2;
alpha_c(3,1) := alpha_c3;
alpha_c(4,1) := alpha_c4;
alpha_c(5,1) := alpha_c5;
alpha_c(6,1) := alpha_c6;
alpha_c(7,1) := alpha_c7;
alpha_c(8,1) := alpha_c8;
alpha_c(9,1) := alpha_c9;


for i := 1:MTTNx do
 MTTk_c(1,i) := alpha_c(i,1) + MTTA_c(1,i);

% Gain in physical form
MTTk := MTTk_c*MTTT_c;


%Create the output file
OUT "$1_ssk.r";

%Write out the matrices.

write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "END;";

SHUT "$1_ssk.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r smc2ssk_r.log

Added mtt/bin/trans/smc_r2tex version [0a9685fd8a].



















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smc_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/08/24 11:43:42  peterg
## Include subs file
##
## Revision 1.1  1998/01/22 13:25:55  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_smc.tex

# Remove the old log file
rm -f smc_r2tex.log

# Use reduce to accomplish the transformation
$SYMBOLIC >smc_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the smconical-form matrices file
in "$1_smc.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_smc.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_smc.tex";
write"";


% Controllable form
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD_c$ 
MTT_Matrix_name := "MTTD_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


SHUT "$1_smc.tex";
quit;
EOF

Added mtt/bin/trans/smo2ssl_r version [a8920b8d83].












































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smo2ssl_r
# observer-form state matrices to Kobserver gain
# P.J.Gawthrop  Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/23 09:31:03  peterg
## Initial revision
##
###############################################################

Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi


# Inform user
echo Creating $1_ssl.r $blurb

# Remove the old log file
rm -f smo2ssl_r.log

# Use reduce to accomplish the transformation
reduce >smo2ssl_r.log << EOF

in "$1_def.r";
in "$1_smo.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

OFF Echo;
OFF Nat;


%%%%  Observer design %%%%%
% gain in Observer form:
matrix MTTl_o(MTTNx,1);
matrix alpha_o(9,1);
alpha_o(1,1) := alpha_o1;
alpha_o(2,1) := alpha_o2;
alpha_o(3,1) := alpha_o3;
alpha_o(4,1) := alpha_o4;
alpha_o(5,1) := alpha_o5;
alpha_o(6,1) := alpha_o6;
alpha_o(7,1) := alpha_o7;
alpha_o(8,1) := alpha_o8;
alpha_o(9,1) := alpha_o9;

for i := 1:MTTNx DO
 MTTL_o(i,1) := alpha_o(i,1) + MTTA_o(i,1);

% Gain in physical form
MTTL := MTTT_o*MTTL_o;

%Create the output file
OUT "$1_ssl.r";

%Write out the matrices.


write "%  - Observer Gain matrix - observer form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$

write "END;";

SHUT "$1_ssl.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r smo2ssl_r.log

Added mtt/bin/trans/smo_r2tex version [b9ffb95882].

















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smo_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/22 13:17:14  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_smo.tex

# Remove the old log file
rm -f smo_r2tex.log

# Use reduce to accomplish the transformation
reduce >smo_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the observer-form matrices file
in "$1_smo.r";


%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_smo.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_smo.tex";
write"";


% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD_o$ 
MTT_Matrix_name := "MTTD_o"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

write "%  - Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


SHUT "$1_smo.tex";
quit;
EOF

Added mtt/bin/trans/sort_sympar version [7f751591a5].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sort_sympar
# Sorts the symbolic parameters in a nice way.
# P.J.Gawthrop March 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/03/07 15:15:53  peterg
## Initial revision
##
###############################################################


# Step 1: sort by variable name
# Step 2: put all varables with same name on same line


sort -k 1,1  | \
gawk '{
    var = $1; sys = $2;
    if (var==oldvar) {
      oldsys=sprintf("%s,%s",oldsys,sys)
    }
    else{
      if (length(oldvar)>0) print oldvar "\t" oldsys;
      oldvar=var; oldsys=sys
    }
}
END{
    print oldvar "\t" oldsys;
}' 

Added mtt/bin/trans/ss_r2m version [dec8c0a922].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ss_r2m
# Reduce steady-state values to Fortran
# P.J.Gawthrop 10 July 1990, Dec 1993, Jan 1994, May 1994.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1993, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

#Inform user
echo Creating $1_ss.m
# Remove the old log file
rm -f ss_r2m.log

# Usv reduce to accomplish the transformation
reduce >ss_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the reduce steady-state values file
in "$1_ss.r";

%Read in the parameter file
in "$1_sympar.r";

ON BigFloat, numval;
PRECISION 16; %Compatible with Matlab

OUT "$1_ss.m";
%Headings - Matlab style
%(Note. The ;; are deleted by for2mat)

IF MTTNvar>0 THEN
BEGIN
  write "function [MTTX0,MTTY0,MTTU0] = $1_ss(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
                  ELSE write MTTVar(i,1), ");;";
  END;
END
ELSE write "function [MTTX0,MTTY0,MTTU0] = $1_ss;;";


IF MTTNvar>0 THEN
BEGIN
  write "%function [MTTX0,MTTY0,MTTU0] = $1_ss(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write "%", MTTVar(i,1), ",..."
                  ELSE write "%", MTTVar(i,1), ");;";
  END;
END
ELSE write "%function [MTTX0,MTTY0,MTTU0] = $1_ss;;";


write "%Steady-state values for system $1";
write "%File $1_ss.m";
write "%Generated by MTT";


ON NERO;	% Suppress zero elements.

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "MTTX0 = zeros(", MTTNx, ",1)";
write "MTTy0 = zeros(", MTTNy, ",1)";
write "MTTu0 = zeros(", MTTNu, ",1)";


MTTX0 := MTTX0;
MTTY0 := MTTY0;
MTTU0 := MTTU0;

SHUT "$1_ss.m";

Added mtt/bin/trans/ss_r2tex version [5d4b26acd7].






























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ss_r2tex
# Reduce transfer-function matrices to LaTex transfer-function matrices.
# P.J.Gawthrop 9 June 1990, 8 July 1990, May 1994
# Copyright (c) P.J.Gawthrop, 1990, 1994.



# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  1998/02/24 09:21:36  peterg
# %% Put under rcs
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


#Unform user
echo Creating $1_ss.tex

# Remove the old log file
rm -f ss_r2tex.log

# Use reduce to accomplish the transformation
reduce >ss_r2tex.log << EOF


%Read the definitions file
in "$1_def.r";

%Read the parameter file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplifiy file
in "$1_simp.r";

%Read the CR file
in "$1_cr.r";

%Read the steady-state file
in "$1_ss.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
%ON Rounded;
%Precision 5;

OUT "$1_ss.tex";
write "%  - X0";
MTT_Matrix := MTTX$ 
MTT_Matrix_name := "MTTX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

write "%  - U";
MTT_Matrix := MTTU$ 
MTT_Matrix_name := "MTTU"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := 1$
LaTeX_Matrix()$


write "%  - Y";
MTT_Matrix := MTTY$ 
MTT_Matrix_name := "MTTY"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

write "%  - dX";
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

SHUT "$1_ss.tex";
quit;
EOF

Added mtt/bin/trans/ssk2ctf_r version [5b4425092f].












































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh 
     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ssk2ctf_r
# Controller gain k and observer gain l to controller TF
# P.J.Gawthrop  Feb 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/02/09 14:04:00  peterg
## Renamed matrix to cTF;
##
## Revision 1.1  1998/02/09 13:54:34  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_ctf.r

# Remove the old log file
rm -f ssk2ctf_r.log

# Use reduce to accomplish the transformation
reduce >ssk2ctf_r.log << EOF

in "$1_def.r";
in "$1_ssk.r";
in "$1_ssl.r";
in "$1_sm.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;



%State matrices of the compensator
A_d := MTTA - MTTL*MTTC - MTTB*MTTK;
B_d := -MTTL;
C_d := -MTTK;
D_d := 0;

%Transfer function
MTTcTF := C_d*((s*MTTI - A_d)^(-1))*B_d;

%Create the output file
OUT "$1_ctf.r"; 
%Write out the matrices.

write "%  - Compensator TF";
MTT_Matrix := MTTcTF$
MTT_Matrix_name := "MTTcTF"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$


SHUT "$1_ctf.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r ssk2ctf_r.log

Added mtt/bin/trans/ssk_r2tex version [ef5e08d779].



















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ssk_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/08/24 11:42:46  peterg
## Read subs file
##
## Revision 1.1  1998/01/22 13:16:30  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_ssk.tex

# Remove the old log file
rm -f ssk_r2tex.log

# Use reduce to accomplish the transformation
reduce >ssk_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the smconical-form matrices file
in "$1_ssk.r";


%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_ssk.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_ssk.tex";
write"";


write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Latex_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Latex_Matrix()$

SHUT "$1_ssk.tex";
quit;
EOF

Added mtt/bin/trans/ssl_r2tex version [81b2f09222].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ssl_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/22 13:16:30  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_ssl.tex

# Remove the old log file
rm -f ssl_r2tex.log

# Use reduce to accomplish the transformation
reduce >ssl_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the obsever gains file
in "$1_ssl.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_ssl.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_ssl.tex";
write"";


write "%  - Gain matrix - controller form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Latex_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Latex_Matrix()$

SHUT "$1_ssl.tex";
quit;
EOF

Added mtt/bin/trans/sspar2ss_r version [a39bc5aea4].

















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sspar2ss_r
# Reduce steady steady-state parameter file to reduce steady-state:
#	X0, and Y0 and U0;
# P.J.Gawthrop 10 July 1990, 22 April 1991, Dec 1993, April 1994
# Copyright (c) P.J.Gawthrop, 1990, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/11/18 11:42:55  peterg
## Added "IF MTTNx>0 THEN" to avoid error message when no states
##
## Revision 1.2  1998/07/22 15:47:28  peterg
## Now operates on ordinary differential equation file.
##
## Revision 1.1  1996/08/25 09:52:20  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_ss.r

# Remove the old log file
rm -f sspar2ss_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >sspar2ss_r.log << EOF

%Read the definition file
in "$1_def.r";

%Read the constitutive relationships (May be used in rss file). 
%in "$1_cr.r";

%Read the steady-state values 
in "$1_sspar.r";

%Read in the constrained-state equation
%in "$1_cse.r";

%Read in the ode
in "$1_ode.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

OFF Echo;
OFF Nat;
OUT "$1_ss.r";

IF MTTNx>0 THEN
  MTTdx:= MTTdx;

%Write out the steady-state values (if any)
write "%Steady-state values";


% State
MTT_Matrix := MTTX$ 
MTT_Matrix_name := "MTTx"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% State derivative
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Nonstate
MTT_Matrix := MTTZ$ 
MTT_Matrix_name := "MTTZ"$
MTT_Matrix_n := MTTNz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTy$ 
MTT_Matrix_name := "MTTy"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Zero outputs
MTT_Matrix := MTTYz$ 
MTT_Matrix_name := "MTTYz"$
MTT_Matrix_n := MTTNyz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Input
MTT_Matrix := MTTu$ 
MTT_Matrix_name := "MTTu"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := 1$
Reduce_Matrix()$


%Write them out by component - but only if values have been set
%(This assumes that if element 1 not set then the rest aren't either)
%ON Rounded; %Make numbers have dec. points-- nice for c
%
%clear MTTx1;
%IF MTTNx>0 THEN
%IF MTTX0(1,1) NEQ MTTX1 THEN
%FOR i := 1:MTTNx DO
%BEGIN
%  write "MTTx", i, " := ", MTTX0(i,1);
%END;
%
%clear MTTu1;
%IF MTTNu>0 THEN
%IF MTTu0(1,1) NEQ MTTu1 THEN
%FOR i := 1:MTTNu DO
%BEGIN
%  write "MTTu", i, " := ", MTTu0(i,1);
%END;
%
%%Derivatives are zero in the steady-state
%IF MTTNz>0 THEN
%FOR i := 1:MTTNz DO
%BEGIN
%  write "MTTdz", i, " := 0";
%END;

write "END;";

SHUT "$1_ss.r";
quit;
EOF

# Now invoke the standard error handling.
mtt_error_r sspar2ss_r.log

Added mtt/bin/trans/strip_comments version [429b584b4b].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################


# Bourne shell script: strip_comments
# Strips comments from mtt text files
# P.J.Gawthrop July 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/11/18 11:30:19  peterg
## Now strips blank lines as well
##
###############################################################


sed 's/%/#/' |\
gawk --field-separator '#' '{if (length($1)>0) print $1}'  |\
gawk '{if (NF>0) print $0}'

Added mtt/bin/trans/strip_notvars.sh version [898b1963cb].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

type=$1
name=$2
file=$3

notvar="[%|#]NOT[V|P]AR"
grep ${notvar} ${type}_lbl.txt |\
    gawk '{ printf ("%s\t%s\n", $2, name) }' name=${name} \
    >> ${file}
 
grep -i pi ${type}_lbl.txt |\
    gawk '{ printf ("pi\t%s\n", name) }' name=${name} \
    >> ${file}

Added mtt/bin/trans/strip_pars.sh version [7d64e8b718].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
infile=$1
name=$2



var="[%|#][V|P]AR"
grep ${var} ${infile} |\
    gawk '{ printf ("%s\t%s\n", $2, name) }' name=${name} \
 

Added mtt/bin/trans/struc2gnuplot_txt2wish version [1d1598cc62].










































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# -*-tcl-*-

sys=$1

out=${sys}_gnuplot.wish

struc=${sys}_struc.txt
dat2=${sys}_odes.dat2

Nx=`mtt_getsize ${sys} x`
Ny=`mtt_getsize ${sys} y`

## write header
cat <<EOF > ${out}
#!/bin/sh
# -*-tcl-*- Next line replaces shell with wish\\
exec wish "\$0" "\$@"

## main window
wm title . "MTT: ${sys}"

# menu bar
canvas .menubar

menubutton .menubar.file -text "File" -underline 0 -menu .menubar.file.menu
menu .menubar.file.menu
.menubar.file.menu add command -label "Open    (Gnuplot template)" -underline 0   -command open_plotfile
.menubar.file.menu add command -label "Save    (Gnuplot template)" -underline 0   -command save_plotfile
.menubar.file.menu add separator
.menubar.file.menu add command -label "Print     (PostScript)"   -underline 0   -command print_postscript
.menubar.file.menu add separator
.menubar.file.menu add command -label "Quit"			  -underline 0   -command exit

menubutton .menubar.edit -text "Edit" -underline 0 -menu .menubar.edit.menu
menu .menubar.edit.menu
.menubar.edit.menu add cascade -label "Axes"         -underline 0 -menu .menubar.edit.menu.axes
.menubar.edit.menu add cascade -label "Contour (3D)" -underline 0 -menu .menubar.edit.menu.contour
.menubar.edit.menu add cascade -label "Data style"   -underline 0 -menu .menubar.edit.menu.datastyle
.menubar.edit.menu add cascade -label "Grid"         -underline 0 -menu .menubar.edit.menu.grid
.menubar.edit.menu add cascade -label "Key"          -underline 0 -menu .menubar.edit.menu.key
.menubar.edit.menu add cascade -label "Timestamp"    -underline 0 -menu .menubar.edit.menu.time

menu .menubar.edit.menu.axes
.menubar.edit.menu.axes add command -label "Cartesian" -underline 0 -command { do_cmd "set nopolar ; replot" }
.menubar.edit.menu.axes add command -label "Polar"     -underline 0 -command { do_cmd "set   polar ; replot" }
.menubar.edit.menu.axes add cascade -label "Ranges"    -underline 0 -menu .menubar.edit.menu.axes.range

menu .menubar.edit.menu.axes.range
.menubar.edit.menu.axes.range add command -label "Set X"   -underline 4 -command { do_cmd "set xrange \[[get_value "X axis range? min:max" "*:*"]\] ; replot" }
.menubar.edit.menu.axes.range add command -label "Set Y"   -underline 4 -command { do_cmd "set yrange \[[get_value "Y axis range? min:max" "*:*"]\] ; replot" }
.menubar.edit.menu.axes.range add command -label "Set Z"   -underline 4 -command { do_cmd "set zrange \[[get_value "Z axis range? min:max" "*:*"]\] ; replot" }

menu .menubar.edit.menu.contour
.menubar.edit.menu.contour add command -label "Show Contour" -underline 0 -command { do_cmd "set   dgrid3d ; set   contour ; replot" }
.menubar.edit.menu.contour add command -label "Hide Contour" -underline 0 -command { do_cmd "set nodgrid3d ; set nocontour ; replot" }
.menubar.edit.menu.contour add cascade -label "Surface"      -underline 0 -menu .menubar.edit.menu.contour.surface

menu .menubar.edit.menu.contour.surface
.menubar.edit.menu.contour.surface add command -label "Show Surface" -underline 0 -command { do_cmd "set   surface ; replot" }
.menubar.edit.menu.contour.surface add command -label "Hide Surface" -underline 0 -command { do_cmd "set nosurface ; replot" }

menu .menubar.edit.menu.datastyle
.menubar.edit.menu.datastyle add command -label "Dots"    -underline 0 -command { do_cmd "set data style dots   ; replot" }
.menubar.edit.menu.datastyle add command -label "Lines"   -underline 0 -command { do_cmd "set data style lines  ; replot" }
.menubar.edit.menu.datastyle add command -label "Points"  -underline 0 -command { do_cmd "set data style points ; replot" }

menu .menubar.edit.menu.grid
.menubar.edit.menu.grid add cascade -label "Show Grid" -underline 0 -menu .menubar.edit.menu.grid.show
.menubar.edit.menu.grid add cascade -label "Hide Grid" -underline 0 -menu .menubar.edit.menu.grid.hide

menu .menubar.edit.menu.grid.show
.menubar.edit.menu.grid.show add command -label "Show all ticks" -underline 5 -command { do_cmd "set grid xtics ytics ztics ; replot" }
.menubar.edit.menu.grid.show add command -label "Show X ticks" -underline 5 -command { do_cmd "set grid xtics ; replot" }
.menubar.edit.menu.grid.show add command -label "Show Y ticks" -underline 5 -command { do_cmd "set grid ytics ; replot" }
.menubar.edit.menu.grid.show add command -label "Show Z ticks" -underline 5 -command { do_cmd "set grid ztics ; replot" }

menu .menubar.edit.menu.grid.hide
.menubar.edit.menu.grid.hide add command -label "Hide all ticks" -underline 5 -command { do_cmd "set grid noxtics noytics noztics ; replot" }
.menubar.edit.menu.grid.hide add command -label "Hide X ticks" -underline 5 -command { do_cmd "set grid noxtics ; replot" }
.menubar.edit.menu.grid.hide add command -label "Hode Y ticks" -underline 5 -command { do_cmd "set grid noytics ; replot" }
.menubar.edit.menu.grid.hide add command -label "Hide Z ticks" -underline 5 -command { do_cmd "set grid noztics ; replot" }

menu .menubar.edit.menu.key
.menubar.edit.menu.key add command -label "Show Key"   -underline 0 -command { do_cmd "set   key ; replot" }
.menubar.edit.menu.key add command -label "Hide Key"   -underline 0 -command { do_cmd "set nokey ; replot" }
.menubar.edit.menu.key add cascade -label "Position"   -underline 0 -menu .menubar.edit.menu.key.posn

menu .menubar.edit.menu.key.posn
.menubar.edit.menu.key.posn add command -label "Left"    -underline 0 -command { do_cmd "set key left    ; replot" }
.menubar.edit.menu.key.posn add command -label "Right"   -underline 0 -command { do_cmd "set key right   ; replot" }
.menubar.edit.menu.key.posn add command -label "Top"     -underline 0 -command { do_cmd "set key top     ; replot" }
.menubar.edit.menu.key.posn add command -label "Bottom"  -underline 0 -command { do_cmd "set key bottom  ; replot" }
.menubar.edit.menu.key.posn add command -label "Outside" -underline 0 -command { do_cmd "set key outside ; replot" }
.menubar.edit.menu.key.posn add command -label "Below"   -underline 3 -command { do_cmd "set key below   ; replot" }

menu .menubar.edit.menu.time
.menubar.edit.menu.time add command -label "Show Timestamp"   -underline 0 -command { do_cmd "set   timestamp ; replot" }
.menubar.edit.menu.time add command -label "Hide Timestamp"   -underline 0 -command { do_cmd "set notimestamp ; replot" }

menubutton .menubar.tool -text "Tools" -underline 0 -menu .menubar.tool.menu
menu .menubar.tool.menu
.menubar.tool.menu add cascade -label "gnuplot command" -underline 0 -menu .menubar.tool.menu.gcmd
.menubar.tool.menu add cascade -label "Sort List" -underline 0 -menu .menubar.tool.menu.sort
.menubar.tool.menu add command -label "X-MTT"     -underline 0 -command { exec xmtt & }

menu .menubar.tool.menu.gcmd
.menubar.tool.menu.gcmd add command -label "Show Command" -underline 0 -command show_gnuplot_prompt
.menubar.tool.menu.gcmd add command -label "Hide Command" -underline 0 -command hide_gnuplot_prompt

menu .menubar.tool.menu.sort
.menubar.tool.menu.sort add command -label "Left to Right" -underline 0 -command {
    set sortorder "normal"
    set xl [sort_list \$xl \$sortorder ]
    set yl [sort_list \$yl \$sortorder ]
}
.menubar.tool.menu.sort add command -label "Right to Left" -underline 0 -command {
    set sortorder "reverse"
    set xl [sort_list \$xl \$sortorder]
    set yl [sort_list \$yl \$sortorder]
}

button .menubar.quit  -text "Quit" -relief flat -command exit 

pack .menubar.file    -expand false -fill x -side left
pack .menubar.edit    -expand false -fill x -side left
pack .menubar.tool    -expand false -fill x -side left
pack .menubar.quit    -expand false -fill x -side right

# list bar
canvas .listbar

radiobutton .listbar.states  -text "States"   -value states  -variable view -command { .parameters.list configure -listvar xl }
radiobutton .listbar.outputs -text "Outputs"  -value outputs -variable view -command { .parameters.list configure -listvar yl }

checkbutton .listbar.sort -text "Toggle Sort" -relief flat -indicatoron false -onvalue "reverse" -offvalue "normal" -variable sortorder -command {    
    set xl [sort_list \$xl \$sortorder ]
    set yl [sort_list \$yl \$sortorder ]
}

pack .listbar.states  -expand false -fill x -side left
pack .listbar.outputs -expand false -fill x -side left
pack .listbar.sort    -expand false -fill x -side right

# side bar
canvas .plotbar

tk_optionMenu .plotbar.select select  "Select X" "Select Y" "Select Z"

tk_optionMenu .plotbar.dim   dimension "2D" "3D"

tk_optionMenu .plotbar.plot  plottype "Single" "Multi"

pack .plotbar.dim     -expand true -fill x -side right
pack .plotbar.plot    -expand true -fill x -side right
pack .plotbar.select  -expand true -fill x -side right

# button bar
canvas .buttonbar

button .buttonbar.replot -text "Refresh"   -relief raised -command { do_cmd "replot" }

button .buttonbar.newwin -text "New Plot"  -relief raised -command {
    set windownum [expr 1 + \$windownum]
    do_cmd "set term x11 \$windownum"
}

pack .buttonbar.newwin  -expand true -side right -fill x
pack .buttonbar.replot  -expand true -side right -fill x

# rotation bar
canvas .rotationbar
scale .rotationbar.xrot  -label "Rotate X" -orient h -from "0" -to "180" -command { do_rotate_3d "xrot" }
scale .rotationbar.zrot  -label "Rotate Z" -orient h -from "0" -to "360" -command { do_rotate_3d "zrot" }
pack .rotationbar.xrot  -side left -fill x -expand true
pack .rotationbar.zrot  -side left -fill x -expand true
.rotationbar.xrot set 30
.rotationbar.zrot set 60


proc "enable_rotationbar" "" {
}
proc "disable_rotationbar" "" {
}

## parameter list canvas
canvas		.parameters
listbox		.parameters.list -background oldlace -foreground black
scrollbar	.parameters.yscrollbar	-orient v

## configure scrollbars
.parameters.yscrollbar configure -command ".parameters.list yview"
.parameters.list configure -yscrollcommand ".parameters.yscrollbar set"

## bind lists
bind .parameters.list <<ListboxSelect>> {
    set parameter [ .parameters.list get anchor ]
    plot \$parameter
    set select "Select Y"
}

proc "reverse_name" "name" {
    set delim "_"
    set split_name [split \$name \$delim]
    set reversed_name [lindex \$split_name 0]
    for {set i 1} {\$i<[llength \$split_name]} {incr i} {
        set reversed_name [lindex \$split_name \$i]\$delim\$reversed_name
    }
    return \$reversed_name
}

proc "reverse_sort" "list" {
    set temp_list {}
    set delim " "
    foreach name [split \$list \$delim] {
	set temp_list \$temp_list\$delim[reverse_name \$name]
    }
    set temp_list [lsort -ascii \$temp_list]
    set list {}
    foreach name [split \$temp_list \$delim] {
	set list \$list\$delim[reverse_name \$name]
    }
    return \$list
}

proc "sort_list" "list sortorder" {
    switch -- \$sortorder {
	normal	{ return [lsort -ascii \$list] }
	reverse { return [reverse_sort \$list] }
    }
}

EOF

## create states and outputs lists
gawk '
($1 == "state") {
    name=sys"__";
    label=$4;
    sub (name, "", label);
    printf "lappend xl %s\n", label
}
($1 == "output") {
    name=sys"__";
    label=$4;
    sub (name, "", label);
    printf "lappend yl %s\n", label
}' sys=${sys} ${struc} >> ${out}

cat <<EOF >> ${out}
lappend xl Time
lappend yl Time
.parameters.list configure -listvar yl

pack .menubar			-expand false -fill x    -side top
pack .listbar			-expand false -fill x    -side top
pack .rotationbar		-expand false -fill x    -side bottom
pack .plotbar			-expand false -fill x    -side bottom
pack .buttonbar			-expand false -fill x    -side bottom
pack .parameters.yscrollbar	-expand false -fill y    -side right
pack .parameters.list		-expand true  -fill both -side left
pack .parameters		-expand true  -fill both

## map names to column numbers
proc "get_state_column" "title" {
    switch -- \$title {
EOF

	gawk '($1 == "state") {
	    name=sys"__";
	    label=$4;
	    sub (name, "", label);
	    printf "\t\t%s\t{ return %d }\n", label, $2+2+Ny;
	}
	' Ny=${Ny} sys=${sys} ${struc} >> ${out}
	
cat <<EOF >> ${out}
    }
}
    
proc "get_output_column" "title" {
    switch -- \$title {
EOF

	gawk '($1 == "output") {
	    name=sys"__";
	    label=$4;
	    sub (name, "", label);
	    printf "\t\t%s\t{ return %d }\n", label, $2+1;
	}    
	' Ny=${Ny} sys=${sys} ${struc} >> ${out}

cat <<EOF >> ${out}
    }
}

proc "plot" "title" {
    global dimension
    global select
    global view
    global xcolumn
    global ycolumn
    global zcolumn
    global xtitle
    global ytitle
    global ztitle
    if {"\$title" == "Time"} {
	set column 1
    } else {
	switch -- \$view {
	    states	{ set column [get_state_column  \$title] }
	    outputs	{ set column [get_output_column \$title] }
	}
    } 
    switch -- \$select {
	"Select X" {
	    set xcolumn \$column
	    set xtitle  \$title
	}
	"Select Y" {
	    set ycolumn \$column
	    set ytitle  \$title
	}
	"Select Z" {
	    set zcolumn \$column
	    set ztitle  \$title
	    set dimension "3D"
	}
    }
    plot_var
}

## call gnuplot
proc "plot_var" "" {
    global xcolumn
    global ycolumn
    global zcolumn
    global xtitle
    global ytitle
    global ztitle
    global dimension
    global plottype
    global lastplot
    switch -- \$dimension {
	2D	{
	    disable_rotationbar
	    switch -- \$plottype {
		Single	{
		    do_cmd "set xlabel '\$xtitle'"
		    do_cmd "set ylabel '\$ytitle'"
		    do_cmd "set nokey"
		    do_cmd "plot '${dat2}' using \$xcolumn:\$ycolumn title 'y:\$ytitle  x:\$xtitle' "
		}
		Multi	{
		    do_cmd "set xlabel ''"
		    do_cmd "set ylabel ''"
		    do_cmd "set key"
		    if {"\$lastplot" != "2D"} {
			do_cmd "plot '${dat2}' using \$xcolumn:\$ycolumn title 'y:\$ytitle  x:\$xtitle' "
		    } else {
			do_cmd "replot '${dat2}' using \$xcolumn:\$ycolumn title 'y:\$ytitle  x:\$xtitle' "	    
		    }
		}
	    }
	}
	3D	{
	    enable_rotationbar
	    switch -- \$plottype {
		Single	{
		    do_cmd "set xlabel '\$xtitle'"
		    do_cmd "set ylabel '\$ytitle'"
		    do_cmd "set zlabel '\$ztitle'"
		    do_cmd "set nokey"
		    do_cmd "splot '${dat2}' using \$xcolumn:\$ycolumn:\$zcolumn title 'z:\$ztitle  y:\$ytitle  x:\$xtitle' "
		}
		Multi	{
		    do_cmd "set xlabel ''"
		    do_cmd "set ylabel ''"
		    do_cmd "set zlabel ''"
		    do_cmd "set key"
		    if {"\$lastplot" != "3D"} {
			do_cmd "splot '${dat2}' using \$xcolumn:\$ycolumn:\$zcolumn title 'z:\$ztitle  y:\$ytitle  x:\$xtitle' "
		    } else {
			do_cmd "replot '${dat2}' using \$xcolumn:\$ycolumn:\$zcolumn title 'z:\$ztitle  y:\$ytitle  x:\$xtitle' "
		    }
		}
	    }
	}
    }
    set lastplot \$dimension
}
## open gnuplot plot file
proc "open_plotfile" "" {
    global parameter
    if {"\$parameter"==""} {
	set name "${sys}.plt"
    } else {
	set name "\$parameter.plt"
    }
    set filename [tk_getOpenFile\
	-initialdir ".."\
	-initialfile "\$name"\
	-defaultextension ".plt"\
	-filetypes {
	    {{Gnuplot} {.plt}}
	    {{All files} {*}}
	}
    ]
    do_cmd "load '\$filename'"
}

## save gnuplot plot file
proc "save_plotfile" "" {
    global parameter
    if {"\$parameter"==""} {
	set name "${sys}.plt"
    } else {
	set name "\$parameter.plt"
    }
    set filename [tk_getSaveFile\
	-initialdir ".."\
	-initialfile "\$name"\
	-defaultextension ".plt"\
	-filetypes {
	    {{Gnuplot} {.plt}}
	    {{All files} {*}}
	}
    ]
    do_cmd "save '\$filename'"
}

## print output to postscript
proc "print_postscript" "" {
    global parameter
    global windownum
    set filename [tk_getSaveFile\
		      -initialdir ".."\
		      -initialfile "\$parameter.ps"\
		      -defaultextension ".ps"\
		      -filetypes {
			  {{Postscript} {.ps}}
			  {{All files} {*}}
		      }
		 ]
    if {\$filename != ""} {
	do_cmd "set term postscript"
	do_cmd "set output '\$filename'"
	do_cmd "replot"
	do_cmd "set term x11 \$windownum"
	tk_dialog ".printed" "Graph Printed!" "PostScript saved as \$filename" "" "0" "Close"
    }
}

proc "get_value" "string initial" {
    frame .f
    frame .f.buttons
    global get_value_retval
    global get_value_status
    set get_value_retval ""
    set get_value_status ""

    button	.f.buttons.ok		-text "ok"	-command {
	set get_value_status "ok"
	set get_value_retval [.f.entry get ]
	destroy .f
    }
    button	.f.buttons.cancel	-text "Cancel"	-command {
	set get_value_status "cancel"
	destroy .f
    }
    entry	.f.entry
    label	.f.label	-text "\$string"

    .f.entry insert 0 "\$initial"
    bind .f.entry <<Return>> {
	set get_value_status "ok"
	set get_value_retval [.f.entry get ]
	destroy .f
    }

    pack .f.buttons.ok		-side left   -expand false
    pack .f.buttons.cancel	-side left   -expand false
    pack .f.label		-side top    -expand false
    pack .f.entry		-side top    -expand false
    pack .f.buttons		-side top    -expand false
    place .f -in .parameters -relx 0 -rely 0 -relwidth 1 -relheight 1 -anchor nw -bordermode outside
    tkwait variable get_value_retval
    if {"\$get_value_status" == "ok"} {
	return "\$get_value_retval"
    } else {
	return ""
    }
}

proc "get_scale" "string min max" {
    frame .f
    frame .f.buttons
    global get_scale_retval
    global get_scale_status
    set get_scale_retval ""
    set get_scale_status ""

    button	.f.buttons.ok		-text "ok"	-command {
	set get_scale_status "ok"
	set get_scale_retval [.f.scale get ]
	destroy .f
    }
    button	.f.buttons.cancel	-text "Cancel"	-command {
	set get_scale_status "cancel"
	destroy .f
    }
    scale	.f.scale	-orient h	-label "\$string"	-from "\$min"	-to "\$max"

    pack .f.buttons.ok		-side left   -expand false
    pack .f.buttons.cancel	-side left   -expand false
    pack .f.scale		-side top    -expand false
    pack .f.buttons		-side top    -expand false
    place .f -in .parameters -relx 0 -rely 0 -relwidth 1 -relheight 1 -anchor nw -bordermode outside
    tkwait variable get_value_retval
    if {"\$get_scale_status" == "ok"} {
	return "\$get_scale_retval"
    } else {
	return ""
    }
}

proc "do_rotate_3d" "var val" {
    switch -- \$var {
	xrot	{
	    do_cmd "set view \$val,,, ; replot"
	}
	zrot	{
	    do_cmd "set view ,\$val,, ; replot"
	}
    }
}

proc "show_gnuplot_prompt" "" {
    global gnuplot_command
    destroy .gcmd
    canvas .gcmd
    label .gcmd.l -text ">"
    entry .gcmd.e -textvariable gnuplot_command
    button .gcmd.b -text "<-" -relief flat -command { set gnuplot_command "" }
    pack .gcmd.b -side right
    pack .gcmd.l -side left
    pack .gcmd.e -side top    -fill x -expand true
    pack .gcmd -expand false -fill x -side bottom -before .rotationbar
    focus .gcmd.e
    bind .gcmd.e <<Return>> {
	do_cmd "[.gcmd.e get]"
    }
}
proc "hide_gnuplot_prompt" "" {
    destroy .gcmd
}

proc "do_cmd" "string" {
    global gnuplot_command
    set gnuplot_command "\$string"
    puts "\$string"
}

event add <<Return>> <Return>
    
# Defaults
set parameter ""
set windownum 0
set view outputs
set lastplot ""
set select "Select Y"
set xcolumn 1 ; set xtitle "Time"
set ycolumn 1 ; set ytitle "Time"
set zcolumn 1 ; set ztitle "Time"

do_cmd "set mouse"
do_cmd "set timestamp"
do_cmd "set grid"
do_cmd "set nopolar"
do_cmd "set term X11 0"
do_cmd "set key"
do_cmd "set data style lines"

EOF
chmod +x ${out}

Added mtt/bin/trans/struc2input_txt2txt version [016a2f4250].



































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2input_txt2txt
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15  2000/12/28 12:44:31  peterg
## *** empty log message ***
##
## Revision 1.14  2000/10/16 08:28:56  peterg
## Tidied up:
## SS broken due to incorrect ss.r file
## Switches??
##
## Revision 1.13  2000/03/03 11:33:19  peterg
## *** empty log message ***
##
## Revision 1.12  1998/08/10 14:29:05  peterg
## Removed -s (switches) stuff
##
## Revision 1.11  1998/08/10 14:23:58  peterg
## Added -ss option
##
## Revision 1.10  1998/07/27 11:10:38  peterg
## Put in octave-mode line for Emacs
##
## Revision 1.9  1998/07/25 20:10:37  peterg
## lower case mttu
##
## Revision 1.8  1998/07/25 09:42:09  peterg
## Just sets finrst input to 1 - rest to zero
##
## Revision 1.7  1998/07/25 08:05:41  peterg
## Reverted to original default - not using SS mechanism
##
## Revision 1.6  1998/02/24 10:14:56  peterg
## Now defaults to the steady-state values
##
## Revision 1.5  1998/02/04 12:26:47  peterg
## Simplified output format
##
## Revision 1.4  1998/02/04 11:45:05  peterg
## Less verbose comments.
##
## Revision 1.3  1998/01/29 17:06:21  peterg
## Better annotation of each input
##
## Revision 1.2  1997/05/15 09:44:12  peterg
## Put switches into the input file.
##
# Revision 1.1  1997/05/03  14:55:17  peterg
# Initial revision
#
###############################################################

#Look for a command line argument
# By default, don't look for BG switches

while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-ss )
		steadystate_computation=yes ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Default input
default='1.0'

#Create the input file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_input.txt
echo "# Input specification ($1_input.txt)" >> $1_input.txt
echo "# Generated by MTT at `date`" >> $1_input.txt
cat $MTTPATH/trans/rcs_header.sh  >> $1_input.txt
echo "# Set the inputs"  >> $1_input.txt

if [ -n "$steadystate_computation" ]; then 
# Compute inputs from ss.r file
# Inform user
echo Creating $1_input.txt - compute from steady-state information

cat $1_ss.r  $1_struc.txt | sed 's/\$//' |\
gawk '{
  if(match($1,"MTTu")>0) {
    j++
    split($0,a,"=");
    u[j]=a[2];
  }
    
  if($1=="input") {
    i++; 
    if (length(u[i])==0) u[i]="0.0;";
    # print  "u(" i ") =\t", u[i], " \# " $4 " (" $3 ")"
    printf("%s =\t%s # MTT initial value from steady state\n", $4, u[i]);
  }
}'  >> $1_input.txt
else
#Write out the defaults -- unit inputs
echo Creating $1_input.txt - using defaults

gawk '{
  if ($1=="input") {
      if ($2==1)
        printf("%s = \t%s; # MTT initial value\n", $4, default)
      else
        printf("%s = \t%s; # MTT initial value\n", $4, "0.0")
  }
}' Nu=$Nu  default=$default <$1_struc.txt >> $1_input.txt
fi

#Set some switches
#  echo  >> $1_input.txt
#  echo "# Set the switches"  >> $1_input.txt
#  strip_comments<$1_switch.txt |\
#  gawk '{if (length($1)>0) print  tolower($1) "= (t>=0);"}'  >> $1_input.txt



Added mtt/bin/trans/struc2sspar_txt2r version [81e9931607].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2sspar_txt2txt
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1998


# Inform user
echo Creating $1_sspar.r


#Write out the default ss values (0)
#Create the sspar file complete with headers.
echo "% Steady-state parameter file ($1_sspar.r)" > $1_sspar.r
echo "% Generated by MTT at `date`" >> $1_sspar.r
cat $MTTPATH/trans/rcs_header.m  >> $1_sspar.r

echo  >> $1_sspar.r

echo "% Steady-state states" >> $1_sspar.r
gawk '{
  if ($1=="state") 
    print "MTTX" $2 " := \t0; % " $4 " (" $3 ")"
}' \
 $1_struc.txt >> $1_sspar.r


echo "% Steady-state inputs" >> $1_sspar.r
gawk '{
  if ($1=="input") 
    print "MTTU" $2 " := \t0; % " $4 " (" $3 ")"
}' \
 $1_struc.txt >> $1_sspar.r


echo ";;END;" >> $1_sspar.r


Added mtt/bin/trans/struc2state_txt2txt version [5418171295].









































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2state_txt2txt
# Creates the default state file for the system (txt)

# Copyright (c) P.J.Gawthrop 1998


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.10  2000/10/16 08:20:23  peterg
# %% New version with direct naming.
# %% Note ss version is broken - ss.r file in wrong format
# %%
# %% Revision 1.9  2000/10/10 21:03:06  peterg
# %% *** empty log message ***
# %%
# %% Revision 1.8  1998/08/10 13:57:33  peterg
# %% Removed debugging lines
# %%
# %% Revision 1.7  1998/08/10 13:55:11  peterg
# %% Added option of computing from ss values
# %%
# %% Revision 1.6  1998/07/27 20:32:11  peterg
# %% Octave mode forced
# %%
# %% Revision 1.5  1998/07/25 20:10:01  peterg
# %% Lower case mttx
# %%
# %% Revision 1.4  1998/07/25 09:42:37  peterg
# %% Now writes out an array
# %%
# %% Revision 1.3  1998/07/25 08:11:35  peterg
# %% No longer used the SS method - just sets zero states
# %%
# %% Revision 1.2  1998/07/21 16:54:15  peterg
# %% Changed erroneous header
# %%
# %% Revision 1.1  1998/06/27 15:06:40  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-ss )
		steadystate_computation=yes ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Default state
default='0.0'

#Create the state file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_state.txt
echo "# Initial state  file ($1_state.txt)" >> $1_state.txt
echo "# Generated by MTT at `date`" >> $1_state.txt
cat $MTTPATH/trans/rcs_header.sh  >> $1_state.txt

#Write out the defaults -- states to steady-state values
echo "# Set the states"  >> $1_state.txt

if [ -n "$steadystate_computation" ]; then 
# Compute state from ss.r file
# Inform user
echo Creating $1_state.txt - compute from steady-state information

cat $1_ss.r  $1_struc.txt | sed 's/\$//' |\
gawk '{
  if(match($1,"MTTx")>0) {
    j++
    split($0,a,"=");
    x[j]=a[2];
  }
    
  if($1=="state") {
    i++; 
    # print  "x(" i ") =\t", x[i], " \# " $4 " (" $3 ")"
    printf("%s =\t%s; # MTT initial value\n", $4, x[i]);
  }
}'  >> $1_state.txt
else
# Set states to zero
# Inform user
echo Creating $1_state.txt - default states to $default

gawk '{
  if ($1=="state") printf("%s \t= %s; # MTT initial value\n", $4, default)
}' default=$default <$1_struc.txt >> $1_state.txt
    
fi


Added mtt/bin/trans/struc2switch_txt version [05163357ae].



































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2switch_txt

# Structure file - generate a file for switching on states
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2001/08/02 03:01:08  geraint
## Stopped initialisation of mttopen from over-writing logic.txt contents.
##  - comment removed from "sort" input (which put it last) because
## initialisation is inserted in place of the comment by switch_txt2m.
##
## Revision 1.5  2000/10/17 09:20:00  peterg
## *** empty log message ***
##
## Revision 1.4  1998/07/26 10:28:30  peterg
## Added a header line to avoid empty file and to trigger
## switch_txt2m to write initial stuff.
##
## Revision 1.3  1998/07/25 18:50:53  peterg
## Lower case names
##
## Revision 1.2  1997/06/03 15:17:09  peterg
## Changed label to MTT_SWITCH
##
# Revision 1.1  1997/05/13  16:58:59  peterg
# Initial revision
#
###############################################################




echo Creating  $1_switch.txt

rm -f $1_switch.txt
echo "# These are the switches deduced from ISW and CSW components"\
 > $1_switch.txt

# This is the main transformation using awk
gawk '{ 
   if ($1=="state") {i++; if ($3=="MTT_SWITCH")  print tolower($4) "\t" i};
}
END{
}
' < $1_struc.txt| sort >> $1_switch.txt

strip_comments < $1_switch.txt | wc -l | gawk '{print $1 " switches found"}'








Added mtt/bin/trans/struc_txt2m version [a49d581f14].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2m

# Structure file - txt to m conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  2001/10/15 14:20:27  gawthrop
## Now handles the cases where ny or nx or nu are zero
##
## Revision 1.2  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.1.2.1  2001/03/06 03:52:15  geraint
## Put back struc_txt2m - required by mtt2sys.
##
###############################################################



# Inform user
echo "Creating $1_struc.m"

rm -f mtt_error

#Write some file headers
echo "function [input_name,output_name,state_name] = $1_struc" > $1_struc.m
echo "%% Usage: [input_name,output_name,state_name] = $1_struc" >> $1_struc.m
echo "%% Structure file ($1_struc.m)" >> $1_struc.m
echo "%% Generated by MTT at `date`" >> $1_struc.m

cat  >> $1_struc.m <<EOF

## Default to null strings
 input_name = "";
 output_name = "";
 state_name  = "";
EOF



# This is the main transformation using awk
gawk '
function header(what){
  print what "_name = [";
}

function footer(what){
  print "];";
}

BEGIN{
Which="";
apostrophe = "\047";
}
{
  if ($1!=Which) {
    if (Which!="") footer(Which);
    header($1);
  }
  print  apostrophe $4 "_" $3 apostrophe;
  Which = $1;
}
END{
  footer(Which)
}
'  SYSTEM=$1  < $1_struc.txt >> $1_struc.m 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Added mtt/bin/trans/struc_txt2mstruc version [501cce0f76].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2m

# Structure file - txt to m-structure conversion
# Copyright (C) 2003 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

sys=$1
infile=${sys}_struc.txt
fun=${sys}_mstruc
outfile=${fun}.m

#Inform user
echo Creating ${outfile}

create_header() {
    cat <<EOF
function [struc] = ${fun};
## Usage [struc] = ${fun};
## Created by mtt on `date`
EOF
}
create_structure() {
cat ${infile} | strip_comments | gawk 'BEGIN{
printf("  struc.input.name = \"\";\n");
printf("  struc.output.name = \"\";\n");
printf("  struc.state.name = \"\";\n");

printf("  struc.input.full_name = \"\";\n");
printf("  struc.output.full_name = \"\";\n");
printf("  struc.state.full_name = \"\";\n");

printf("  struc.input.causality = \"\";\n");
printf("  struc.output.causality = \"\";\n");
printf("  struc.state.causality = \"\";\n");
}
{
printf("  struc.%s.name = [ struc.%s.name; \"%s\"];\n", $1, $1, $3)
printf("  struc.%s.full_name = [ struc.%s.full_name; \"%s\"];\n", $1, $1, $4)
printf("  struc.%s.causality = [ struc.%s.causality; \"%s\"];\n", $1, $1, $6)
printf("  struc.repetitions(%i) = %i;\n", $2, $5)

}'
}

create_footer() {
    cat<<EOF
endfunction
EOF
}


create_header     >${outfile}
create_structure >>${outfile}
create_footer    >>${outfile}

Added mtt/bin/trans/struc_txt2tex version [d8af09e179].


































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2tex

# Structure file - text to TeX table conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:46:59  peterg
## Put under RCS
##
# Revision 1.3  1997/12/06  19:10:41  peterg
# Reverted to tabular --- from supertabular
#
# Revision 1.2  1997/04/15  11:17:58  peterg
# Uses supertabular for long tables.
#
# Revision 1.1  1997/04/15  09:49:04  peterg
# Initial revision
#
###############################################################


# Inform user
echo "Creating $1_struc.tex"

rm -f mtt_error

#Write some file headers
echo "%% Structure file ($1_struc.txt)" > $1_struc.tex
echo "%% Generated by MTT at `date`" >> $1_struc.tex

# This is the main transformation using awk
sed 's/_/\\_/g' < $1_struc.txt |  gawk '
function header(what){
  print "  \\centering";
 print "  \\tablefirsthead{\\hline %";
  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM "} \\\\";
  print "    \\hline";
  print "     & Component & System & Repetition \\\\";
  print "    \\hline}";

  print "  \\tablehead{\\hline %";
  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM " (continued)} \\\\";
  print "    \\hline";
  print "     & Component & System & Repetition \\\\";
  print "    \\hline}";

  print "  \\tabletail{\\hline}";
  print "  \\begin{supertabular}{|l|l|l|l|}";
}
#function header(what){
#  print "\\begin{table}[htbp]";
#  print "  \\centering";
#  print "  \\begin{tabular}{|l|l|l|l|}";  print "    \\hline";
#  print "     & Component & System & Repetition \\\\";
#  print "    \\hline";
#}
function footer(what){
  print "    \\hline";
  print "  \\end{supertabular}";
#  print "  \\end{tabular}";
#  print "  \\caption{" what "}";
#  print "\\end{table}";
  print "   \\bigskip";
  print "   \\bigskip";
}

BEGIN{
Which=""
}
{
  if ($1!=Which) {
    if (Which!="") footer(Which);
    header($1);
  }
  print $2, "&", $3,"&", $4, "&", $5, "\\\\";
  Which = $1;
}
END{
  footer(Which)
}
'  SYSTEM=$1  >> $1_struc.tex 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Added mtt/bin/trans/sub2subs version [41189e212e].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sub2subs
# Generates a list of all subsystems associated with system $1

# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

# echo the name of the subsystems one level down
sh $1\_sub.sh "echo  " 

# Create the corresponding subsystems --  quietly!
#(sh $1\_sub.sh "mtt -q  " " sub sh") #>/dev/null
(sh $1\_sub.sh " cmp2sub_m2sh  " " ") >/dev/null


# Recursively execute the subsystem files
sh $1\_sub.sh "sub2subs " 







Added mtt/bin/trans/sub_sh2tex version [664edf4220].


































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sub_sh2tex
# Converts _sub_sh files to a latex itemized list.
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2004/08/26 16:15:40  geraint
## Counts abg.m instead of fig files so that dia models are also included.
##
## Revision 1.5  2004/02/10 16:11:01  gawthrop
## Removed debug
##
## Revision 1.4  2004/02/10 10:22:10  gawthrop
## Do proper arithmetic via let
## Three levels of output
## enumerate, not itemize
##
## Revision 1.3  2004/02/10 10:13:05  gawthrop
## Handles #SUMMARY correctely
## Refined count of subsystems within fig file (avoilds ports with same
## name as system
##
## Revision 1.2  2004/02/10 09:51:07  gawthrop
## Updated obsolete path name.
##
## Revision 1.1  2000/12/27 16:04:08  peterg
## Initial revision
##
## Revision 1.7  1998/02/04 10:59:37  peterg
## Tidied up.
##
# Revision 1.6  1997/09/08  19:42:37  peterg
# Replaced copy by compcopy
#
## Revision 1.5  1997/08/15 11:20:13  peterg
## Explicitly copies compound components (if not already there)
##
# Revision 1.4  1997/06/24  08:28:26  peterg
# Now takes %SUMMARY description from the label file
# Appends count of number of subsystems at that level
#
## Revision 1.3  1997/05/21 10:07:36  peterg
## Fixed \ probs for GNU sh/echo
##
## Revision 1.2  1997/05/19 16:46:17  peterg
## *** empty log message ***
##
# Revision 1.1  1997/05/19  11:29:44  peterg
# Initial revision
#
###############################################################


#Useful strings
quote="'";
listtype="enumerate"

# Maximum list depth 
# Just go to 3 levels
maxlevel=3; 

#Look for a command line argument
labels=''; arg='';
while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-l )
		labels='yes'; arg='-l' ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


system=$1
filename=$2 


if [ -z "$3" ]; then
    level=0;
else
    level=$4;
fi
echo "level: $level"
#Top-level commands
if [ -z "$2" ]; then
  filename="$1_sub.tex"

  # Inform user
  echo "Creating $filename"

  #Write some file headers
  echo "% Subsystem file for system $system ($filename)"   > $filename
  echo "% Generated by MTT at `date`"  >> $filename
  echo  >> $filename
fi

# Write list item if not at the top level.
if [ -n "$2" ]; then
  #Set up some names
  filename=$2
  abgfile=$3_abg.m
  lblfile=$1_lbl.txt
  summary='[%|#]SUMMARY'

  #Get the system description, copying where necesary
  mtt -q -u compcopy $system $MTT_LIB/comp/compound
  # mtt -q -u $system lbl txt
  desc=`grep $summary $lblfile | sed "s/$summary//"`

  #Count the number of subsystems
  subs=`grep -c " $system" $abgfile`

  if [ "$labels" = "yes" ]; then
    echo '  \item '$desc ' ('$subs') Section \Ref{sec:'$system'}' >> $filename
  else
    echo '  \item' $desc ' ('$subs')'   >> $filename
  fi
fi

# Create the subsystem sh files (if not too deep)
if [ "$level" != "$maxlevel" ]; then
    mtt -q -u  -l 1 $system sub sh

    # Write the list of subsystems (if they exist).
    n_subsystems=`grep -c '$1' $1_sub.sh`

    if [ "$n_subsystems" != "0" ]; then
	cat <<EOF >> $filename
	    \begin{$listtype}
EOF
	# Recursively generate the subsystems
        level1=$(( $level + 1 ))
	sh $system\_sub.sh "sub_sh2tex $arg " " $filename $system $level1" 
	cat <<EOF >> $filename
	    \end{$listtype}
EOF
#else
#    cat  <<EOF >> $filename
#         No subsystems.
#EOF
fi
fi








Added mtt/bin/trans/switch_txt2m version [1b58ea9614].




























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: switch_txt2m

# Convert switch file from txt to m
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15  2000/12/04 08:23:25  peterg
## Put logic in-line - avoids the if statements
##
## Revision 1.14  2000/11/09 10:29:21  peterg
## open --> mtt_open
##
## Revision 1.13  2000/11/09 10:19:12  peterg
## Explicitly write out the open switches ....
##
## Revision 1.12  2000/11/09 09:52:07  peterg
## Removed [] from zero_state output
##
## Revision 1.11  2000/10/17 09:55:55  peterg
## Now writes to standard output
## Write the name, not the array
##
## Revision 1.10  2000/10/17 09:04:12  peterg
## *** empty log message ***
##
## Revision 1.9  1999/08/02 12:44:21  peterg
## zero_vector --> zero_state.
##
## Revision 1.8  1999/04/20 00:55:40  peterg
## Changed <= to < in switchopen.m
## Removed switch.m generation - redundant
##
## Revision 1.7  1999/04/02 06:30:37  peterg
## New _switchopen
## Removed switcha
##
## Revision 1.6  1998/10/01 18:20:50  peterg
## Split up the three if conditions on the switch and state value into
## three separate ifs. This is because p2c seems to generate incorrect
## code id just the one if is used (???).
##
## Revision 1.5  1998/10/01 16:05:34  peterg
## Separate switch.m file for euler and implicit integration
##
###############################################################


# Find system constants
Nx=`mtt_getsize $1 x` # States

#Write some file headers
#lang_header $1 switch m 'mttx' '[mttx]' > $1_switch.m

#echo Creating  $1_switch.m
# Set states to zero
# gawk '{
#   if ($1=="#"){
#     printf("#== Switches set element of state vector to zero ==#\n")
#   }
#   else{
#   printf("\n#== Switch: %s ==#\n",$1)
#   printf("if (%s==0.0) \n", $1);
#   printf("  mttx(%s)=0.0;\n", $2);
#   printf("end;\n");
#   printf("if (%s<0.0)\n",$1);
#   printf("  if (mttx(%s)<=0.0)\n",$2);
#   printf("    mttx(%s)=0.0;\n", $2);
#   printf("  end;\n");
#   printf("end;\n");

#   }
# }' Nx=$Nx < $1_switch.txt >> $1_switch.m

## Set index version
#echo Creating  $1_switchopen.m

#Write some file headers
#lang_header $1 switchopen m 'mttx' '[open]' > $1_switchopen.m

## Add the switching logic
#cat  >> $1_switchopen.m <<EOF

## User defined logic (from $1_logic.m)

#EOF
#cat $1_logic.txt >> $1_switchopen.m

# Set states to zero
gawk '{
  if ($1=="#"){
    printf("#== mttopen - boolean vector of open switches ==#\n")
    for (i=1;i<=Nx;i++)
     printf("mttopen(%i) = 0; # Default to not open\n", i);
  }
  else{
  printf("\n#== Switch: %s ==#\n",$1)
   printf("mttopen(%s) = (abs(%s_logic)<0.5)||((%s_logic<0.0)&&(%s<0.0));\n", $2, $1, $1, $1);
#   printf("if (%s_logic==0.0) \n", $1);
#   printf("  mttopen(%s) = 1;\n", $2);
#   printf("end;\n");
#   printf("if (%s_logic<0.0)\n",$1);
#   printf("  if (%s<0.0)\n",$1);
#   printf("    mttopen(%s) = 1;\n", $2);
#   printf("  end;\n");
#   printf("end;\n");

  }
}' Nx=$Nx < $1_switch.txt #>> $1_switchopen.m

#echo Creating  $1_switcha.m

# Implicit integration version
#Write some file headers
# lang_header $1 switcha m 'mttAA,mttx' '[mttAA]' > $1_switcha.m
# gawk '{
#   if ($1=="#"){
#     printf("#== Switches set row and column of A matrix to zero ==#\n")
#   }
#   else{
#   printf("#== Switch: %s ==#\n",$1)
#   printf("if (%s==0.0) \n", $1);
#   printf("  for  MTTi=1:%s\n",Nx)
#   printf("    mttAA(MTTi,%s)=0.0;\n", $2)
#   printf("    mttAA(%s,MTTi)=0.0;\n", $2)
#   printf("  end;\n");
#   printf("  mttAA(%s,%s) = 1.0;\n", $2,$2);
#   printf("end;\n\n")
# 
#   printf("if (%s<0.0)\n",$1);
#   printf("  if (mttx(%s)<=0.0)\n",$2);
#   printf("    for  MTTi=1:%s\n",Nx)
#   printf("      mttAA(MTTi,%s)=0.0;\n", $2)
#   printf("      mttAA(%s,MTTi)=0.0;\n", $2)
#   printf("    end;\n");
#   printf("    mttAA(%s,%s) = 1.0;\n", $2,$2);
#   printf("  end;\n");
#   printf("end;\n");
# 
#   }
# }' Nx=$Nx < $1_switch.txt >> $1_switcha.m



Added mtt/bin/trans/sympar2global_txt2lang version [3d88bdddde].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2global_txt2lang

# Symbolic parameters to default paramers in computer language
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/11/18 11:55:51  peterg
## Now uses sympar2global_txt2m for the m bit
##
## Revision 1.5  1998/07/26 11:00:18  peterg
## Put in exits-- this all needs a good clean
##
## Revision 1.4  1998/07/26 10:50:30  peterg
## Corrected bug.
##
## Revision 1.3  1998/07/26 10:48:18  peterg
## Now strips comments
##
## Revision 1.2  1998/07/25 18:49:00  peterg
## Now uses extended sympars -- sympar + switches
##
## Revision 1.1  1998/06/15 15:24:33  peterg
## Initial revision
##
###############################################################

# Set up language stuff.
language=$2

case $language in
    m)
	Lc='#';
	Rc='#';
	;;
    c)
	Lc='/*';
	Rc='*/';
	;;
    java)
	Lc='/*';
	Rc='*/';
	;;
    *)
	echo Language $2 not supported - sorry; exit 1
esac

cat <<EOF

$Lc====== Set up the global variables ======$Rc
EOF
# Matlab bit
#Write out the variables in matlab global format
if [ "$language" = "m" ]; then
  sympar2global_txt2m $1
exit
fi

if [ "$language" = "c" ]; then
  strip_comments <$1_sympars.txt  |\
    gawk '{
      i++; print "extern double", tolower($1) ";";
    }'
exit
fi

if [ "$language" = "java" ]; then
cat <<EOF
    $1_numpar p;
    private p = new $1_numpar();
EOF 
  strip_comments <$1_sympars.txt  |\
      gawk '{
        i++; print "  float " tolower($1) " = p." tolower($1) ";";
      }'
fi

echo

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Added mtt/bin/trans/sympar2global_txt2m version [e8df2e195f].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2global_txt2m

# Symbolic parameters to default paramers (m)
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/11/18 15:07:37  peterg
## Space after all globals
##
## Revision 1.5  1998/11/18 11:34:24  peterg
## Cleaned up to:
##   work properly for no globals
##   no need to repeat las global
##
## Revision 1.4  1998/07/26 10:44:08  peterg
## Now strips comment lines first
##
## Revision 1.3  1998/07/25 18:27:45  peterg
## now uses the (extended with switch) sympars.txt file
##
## Revision 1.2  1998/03/22 11:13:27  peterg
## Back under RCS
##
# Revision 1.1  1997/04/16  11:37:22  peterg
# Initial revision
#
###############################################################


#Write out the variables in matlab global format
strip_comments <$1_sympars.txt  |\
gawk '
{i++; 
  if ((i==1)&&(NF>0)) {
    printf ("global");
    globals_exist=1
  }
  if (NF>0)
    printf (" ...\n     %s", tolower($1));
}
END{
  if (globals_exist)
    print " ;"
}' 

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Added mtt/bin/trans/sympar2numpar_r2c version [d052149f27].


































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2numpar_r2m
# Creates the deafault numerical parameters file for the system

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1997/01/21 11:36:26  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_numpar.c

# Remove the old log file
rm -f sympar2numpar_r2c.log

# Use reduce to accomplish the transformation
reduce >sympar2numpar_r2c.log 2>mtt_error.txt << EOF

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
IN "$1_sympar.r";

OUT "$1_numpar1.c";

IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE  
      BEGIN
        write "extern float ", MTTVar(i,1)$
      END;
END; 


IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
    THEN 
    BEGIN
     write "/* Variable ", i, " has already been set to ",   MTTVar(i,1), "*/";
    END
    ELSE
    BEGIN
      write MTTVar(i,1), "  = 1;	/* Default value */";
    END;
END;


SHUT "$1_numpar1.c";

EOF

matlab_tidy $1_numpar1.c

#Create the numpar file complete with headers.
echo "/*" > $1_numpar.c
echo "%% Numerical parameter file ($1_numpar.c)" >> $1_numpar.c
echo "%% Generated by MTT at `date`" >> $1_numpar.c
echo "*/" >> $1_numpar.c

echo "$1_numpar()"  >> $1_numpar.c
echo "{" >> $1_numpar.c
echo "  extern $1_params();" >> $1_numpar.c

cat $1_numpar1.c >> $1_numpar.c

echo "/*" >> $1_numpar.c
echo '%% Input the user-defined parameters'  >> $1_numpar.c
echo "*/" >> $1_numpar.c

echo "$1_params;"   >> $1_numpar.c
echo "};" >> $1_numpar.c

rm $1_numpar1.c

# Now invoke the standard error handling.
mtt_error_r sympar2numpar_r2c.log

Added mtt/bin/trans/sympar2numpar_r2m version [0368596f7d].










































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2numpar_r2m
# Creates the deafault numerical parameters file for the system

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.9  1996/09/12 19:26:05  peter
## Input _params file.
##
## Revision 1.8  1996/08/30 19:37:43  peter
## Moved headers in shell script.
##
## Revision 1.7  1996/08/24 14:11:56  peter
## Global parameter passing.
##
## Revision 1.6  1996/08/20 08:21:24  peter
## *** empty log message ***
##
## Revision 1.5  1996/08/16 14:27:25  peter
## Make a dummy function when no parameters (MTTNVar=0).
##
## Revision 1.4  1996/08/15 12:46:59  peter
## Removed a spuriuos echo.
##
## Revision 1.3  1996/08/12 20:20:59  peter
## Explicit parameters via out put list.
## Parameter conversion stuff deleted.
##
## Revision 1.2  1996/08/11 10:41:52  peter
## Fixed various bugs.
##
## Revision 1.1  1996/08/11 08:48:07  peter
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_numpar.m

# Remove the old log file
rm -f sympar2numpar_r2m.log

# Use reduce to accomplish the transformation
reduce >sympar2numpar_r2m.log << EOF

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
IN "$1_sympar.r";

OUT "$1_numpar1.m";

IF MTTNvar>0 THEN
BEGIN
  write "global ...;;";
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE  
      BEGIN
       IF i<MTTNvar THEN write MTTVar(i,1), " ..."
                    ELSE write MTTVar(i,1), ";";
      END;
END; 


IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
    THEN 
    BEGIN
     write "% Variable ", i, " has already been set to ",   MTTVar(i,1);
    END
    ELSE
    BEGIN
      write MTTVar(i,1), "  = 1;	% Default value";
    END;
END;

if MTTNVar=0 THEN
  write "foo=0";

SHUT "$1_numpar1.m";

EOF

matlab_tidy $1_numpar1.m

#Create the numpar file complete with headers.
echo "%% Numerical parameter file ($1_numpar.m)" > $1_numpar.m
echo "%% Generated by MTT at `date`" >> $1_numpar.m
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_numpar.m
cat $1_numpar1.m >> $1_numpar.m

echo '%% Input the user-defined parameters'  >> $1_numpar.m
echo "$1_params;"   >> $1_numpar.m


rm $1_numpar1.m


# Now invoke the standard error handling.
mtt_error_r sympar2numpar_r2m.log



















Added mtt/bin/trans/sympar2numpar_txt2txt version [6787c03295].

























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2numpar_txt2txt
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.13  2000/10/16 08:09:25  peterg
## Tidied up.
##
## Revision 1.12  1999/03/02 22:01:21  peterg
## *** empty log message ***
##
## Revision 1.11  1998/06/15 15:14:46  peterg
## Don't print if blank line
##
## Revision 1.10  1998/03/07 15:27:20  peterg
## Don't do initial states.
##
## Revision 1.9  1998/02/04 12:24:35  peterg
## Simplified output format
##
## Revision 1.8  1998/01/29 17:06:36  peterg
## Better annotation
##
## Revision 1.7  1997/09/18 17:10:18  peterg
## Changed comments pertaining to the parameters to use the new column 2
## of the sympar file (the system type).
## Added blank line to separate parmeters from states.
## (Done in the Chester Court Hotel).
##
## Revision 1.6  1997/06/13 09:34:39  peterg
## changed [] to ()
##
# Revision 1.5  1997/05/15  08:30:14  peterg
# Now write default states (using _struc file).
#
# Revision 1.4  1997/05/15  07:19:19  peterg
# Put back "tolower"
#
# Revision 1.3  1997/05/15  07:13:31  peterg
# Removed "tolower" function.
#
# Revision 1.2  1997/05/01  08:19:04  peterg
# # is now used as the comment symbol
#
# Revision 1.1  1997/05/01  07:35:48  peterg
# Initial revision
#
###############################################################

# Inform user
echo Creating $1_numpar.txt

#Create the numpar file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_numpar.txt
echo "# Numerical parameter file ($1_numpar.txt)" >> $1_numpar.txt
echo "# Generated by MTT at `date`" >> $1_numpar.txt
cat $MTTPATH/trans/rcs_header.txt  >> $1_numpar.txt

#Write out the variables
echo "# Parameters" >> $1_numpar.txt
strip_comments <$1_sympar.txt |\
gawk '{i++; if (NF>0) print tolower($1) " = \t1.0; \# " $2}'\
  >> $1_numpar.txt

#Write out the initial states
#echo  >> $1_numpar.txt
#echo "# Initial states" >> $1_numpar.txt
#gawk '{
#  if ($1=="state") 
#    print "x(" $2 ") = \t0.0; \# " $4 " (" $3 ")"
#}' \
# $1_struc.txt >> $1_numpar.txt





Added mtt/bin/trans/sympar2par_txt2m version [ea07b68f51].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2par_txt2m

# Symbolic parameters parameter conversion
# Used in lang_header
# Copyright (C) 2000 by Peter J. Gawthrop

Lb=${5:-'('}
Rb=${6:-')'}

case $2 in
    zero)
	  strip_comments <$1_sympar.txt  |\
          gawk '{
          i++; printf("  %s %s = 0.0;\n",  tolower($1));
          }' 
	;;
    set)
	  strip_comments <$1_sympar.txt  |\
         gawk '{
           i++; printf("  %s mttpar(%i) \t= %s;\n", i, tolower($1));
         }' 
        ;;
    *)
         strip_comments <$1_sympar.txt  |\
         gawk '{
           i++; printf("  %s %s \t= mttpar%c%i%s%c;\n", decl, tolower($1), Lb, i, minusone, Rb);
         }' decl="$3" minusone="$4" Lb=$Lb Rb=$Rb
	;;
esac




Added mtt/bin/trans/sympar2params_txt2c version [b4d5f24a4d].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2params_txt2c

# Symbolic parameters to default paramers (c)
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1997/03/20 15:17:45  peterg
## All variables are in lower case.
##
# Revision 1.1  1997/03/20  10:25:55  peterg
# Initial revision
#
###############################################################



# Inform user
echo "Creating $1_params.c"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_params.c
echo "Parameter file for system $1 ($1_params.c)"   >> $1_params.c
echo "This file provides the system params for simulation:"  >> $1_params.c
echo "Generated by MTT at `date`"  >> $1_params.c
echo "These default parameters should be changed by the user"  >> $1_params.c
echo '*/' >> $1_params.c
echo  >> $1_params.c


cat $MTTPATH/trans/rcs_header.c >> $1_params.c
echo  >> $1_params.c


echo "#include \"$1_sympar.c\""  >> $1_params.c
echo "$1_params()" >> $1_params.c
echo '{' >> $1_params.c

#Write out the variables in c format.
gawk '{i++; print tolower($1) " = \t1.0;"}' $1_sympar.txt  >> $1_params.c
echo '}' >> $1_params.c

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Added mtt/bin/trans/sympar2params_txt2m version [cb4bac324f].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2params_txt2m

# Symbolic parameters to default paramers (m)
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1997/04/17 11:18:34  peterg
## Write out the RCS header first!
##
# Revision 1.2  1997/04/16  11:40:31  peterg
# Added global variables.
#
# Revision 1.1  1997/04/16  11:31:41  peterg
# Initial revision
#
###############################################################



# Inform user
echo "Creating $1_params.m"

rm -f mtt_error

#Write some file headers
echo "% Parameter file for system $1 ($1_params.m)"   > $1_params.m
echo "% This file provides the system params for simulation:"  >> $1_params.m
echo "% Generated by MTT at `date`"  >> $1_params.m
echo "% These default parameters should be changed by the user"  >> $1_params.m
echo  >> $1_params.m

cat $MTTPATH/trans/rcs_header.m >> $1_params.m
echo  >> $1_params.m


#Write out the global variables
sympar2global_txt2m $1 >> $1_params.m


#Write out the variables in c format.
gawk '{i++; print tolower($1) " = \t1.0;"}' $1_sympar.txt  >> $1_params.m

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Added mtt/bin/trans/sympar2rtxi_txt2cc version [163d3be99c].






























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

sys=$1
struc=${sys}_struc.txt
sympar=${sys}_sympar.txt
RTXI_H="${sys}_rtxi.h"
RTXI_CC="${sys}_rtxi.cc"
program=$(basename $0)
date=$(date)

cat <<EOF > ${RTXI_CC}
// -*-c++-*- Put Emacs into c++-mode

// Generated from $sympar and $struc by MTT
// using $program
// at $date

#include <${RTXI_H}>

extern "C" Plugin::Object *createRTXIPlugin(void) {
  return new ${sys}();
}

static DefaultGUIModel::variable_t vars[] = {
EOF

gawk '
  ($1=="input") {
    printf("  {\n");
    printf("    \"%s\",\n", $3);
    printf("    \"%s\",\n", $6);
    printf("    DefaultGUIModel::INPUT,\n");
    printf("  },\n");
  }
  ($1=="output") {
    printf("  {\n");
    printf("    \"%s\",\n", $3);
    printf("    \"%s\",\n", $6);
    printf("    DefaultGUIModel::OUTPUT,\n");
    printf("  },\n");
  }
' ${struc} >> ${RTXI_CC}

gawk '
  {
    printf("  {\n");
    printf("    \"%s\",\n", $1);
    printf("    \"\",\n");
    printf("    DefaultGUIModel::PARAMETER |");
    printf(" DefaultGUIModel::DOUBLE,\n");
    printf("  },\n");
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
};

static size_t num_vars = sizeof(vars)/sizeof(DefaultGUIModel::variable_t);
// TODO: initialise from numpar
static double
EOF

gawk '
  { printf("  %s=0.0,", $1); }
  END { printf ";" }
' $sympar |\
    sed -e 's/,;/;\n/' |\
    sed -e 's/,/,\n/' >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
static long i_count = 0;

${sys}::${sys}(void)
  : DefaultGUIModel("${sys}",::vars,::num_vars),
EOF

gawk '
  { printf("  %s(0.0),", $1); }
  END { printf ";" }
' $sympar |\
    sed -e 's/,;/\n/' |\
    sed -e 's/,/,\n/' >> ${RTXI_CC}


cat <<EOF >> ${RTXI_CC}
{
  doUpdate(INIT);
  refresh();
}

${sys}::~${sys}(void) {}

// ${sys}::execute(void) is defined in ${sys}_ode2odes.cc

void ${sys}::update(DefaultGUIModel::update_flags_t flag) {
  setCaption("${sys}");
  switch(flag) {
    case INIT:
EOF

gawk '
  {
    printf("      setParameter(\"%s\",QString::number(%s));\n",
	 $1, $1);
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
      break;
    case MODIFY:
EOF

gawk '
  {
    printf("      getParameter(\"%s\").toDouble();\n", $1);
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
      break;
    default:
      break;
  }
}
EOF

Added mtt/bin/trans/sympar2rtxi_txt2h version [7eba5b84fa].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

sys=$1
sympar=${sys}_sympar.txt
RTXI_H="${sys}_rtxi.h"
program=$(basename $0)
date=$(date)

cat <<EOF > ${RTXI_H}
// -*-c++-*- Put Emacs into c++-mode

// Generated from $sympar by MTT
// using $program
// at $date

#include <rt.h>
#include <default_gui_model.h>

class $sys : public DefaultGUIModel
{

public:
  
  $sys(void);
  virtual ~$sys(void);
  
  virtual void execute(void);

protected:

  virtual void update(DefaultGUIModel::update_flags_t);

private:

EOF

gawk '
	{ printf("  double %s;\n", $1); }
' $sympar >> ${RTXI_H}

cat <<EOF >> ${RTXI_H}
};
EOF

Added mtt/bin/trans/sympar_r2c version [4377d90700].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_r2c
# Convert symbolic parameters to a c declaration list

# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.1  1997/03/01  11:20:36  peterg
# Initial revision
###############################################################

# Inform user
echo Creating $1_sympar.c

# Remove the old log file
rm -f sympar_r2c.log

# Use reduce to accomplish the transformation
reduce >sympar_r2c.log << EOF


%Read the symbolic parameters file
in "$1_sympar.r";


%Generate the global variable list.
OUT "$1_sympar.c";
%External (global) variable list

write "/* Symbolic paramaters for system $1 */ "$
write "/* Generated by MTT */ "$
write "/* External (global) variable list */ "$

IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE
      BEGIN
         write "extern double ", MTTVar(i,1), ";"$
      END$
END$
SHUT "$1_sympar.c";


EOF

Added mtt/bin/trans/sympar_txt2c version [8c103e49d4].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2c

# Label file to symbolic parameters conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1997/05/15 07:19:56  peterg
## Put back "tolower"
##
# Revision 1.2  1997/05/15  07:10:56  peterg
# removed "tolower" function
#
# Revision 1.1  1997/05/15  07:10:09  peterg
# Initial revision
#
# Revision 1.3  1997/03/19  16:39:12  peterg
# Put in the correct date.
#
# Revision 1.2  1997/03/18  17:56:35  peterg
# Cosmetic changes.
#
###############################################################


# Inform user
echo "Creating $1_sympar.c"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_sympar.c
echo "Symbolic parameter file ($1_sympar.c)" >> $1_sympar.c
echo "Generated by MTT at `date`"  >> $1_sympar.c
echo '*/' >> $1_sympar.c
echo  >> $1_sympar.c


#Write out the variables in c format.
gawk '{i++; print "extern double", tolower($1) ";"}' $1_sympar.txt \
      >> $1_sympar.c


# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Added mtt/bin/trans/sympar_txt2declare version [1d77607037].




























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2declare

# Symbolic parameters to variable declaration
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/10/11 09:08:20  peterg
## Initial revision
##

###############################################################

sys=$1
language=$2

case $language in
    p)
        first="VAR";
        delim=", ";
        last=': REAL;';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

# Start
cat<<EOF
$first
EOF
#Write out the variables 
strip_comments < $sys"_sympar.txt" |\
gawk '{
  i++; 
  var[i] = tolower($1);
}
END{
  n = i;
  for (i=1; i<n; i++){
    printf("%s%s",var[i], delim);
    j++; 
    if (j>10){
    printf("\n"); j=0;
    }
  }
  printf("%s%s\n",var[n], last);

}' "delim=$delim" "last=$last" 


Added mtt/bin/trans/sympar_txt2m version [c51bec0783].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
## Converts sympar.txt to an m file which provides indices in the form
##  sympar.name = i


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Copyright (C) 2000 by Peter J. Gawthrop

echo Creating $1_sympar.m

lang_header -noglobals $1 sympar m "" sympar > $1_sympar.m

gawk '{
  printf("  sympar.%s \t= %i; # %s\n", $1, ++i, $2); 
}' < $1_sympar.txt >> $1_sympar.m

Added mtt/bin/trans/sympar_txt2r version [48a0e2e4e2].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2r

# Label file to symbolic parameters conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/02/17 17:03:54  peterg
## Fixed bug in writing out matrix declaration
##
## Revision 1.5  1998/02/16 12:14:21  peterg
## Corrected writing out of MTTVAR matrix - now does this id non-zero
## number of variables - not vv!
##
## Revision 1.4  1997/05/09 14:20:49  peterg
## Dont declare MTTVAR array when there are no variables.
##
# Revision 1.3  1997/03/19  16:39:12  peterg
# Put in the correct date.
#
# Revision 1.2  1997/03/18  17:56:35  peterg
# Cosmetic changes.
#
###############################################################


# Inform user
echo "Creating $1_sympar.r"

rm -f mtt_error

#Write some file headers
echo "%% Symbolic parameter file ($1_sympar.r)"  > $1_sympar.r
echo "%% Generated by MTT at `date`"  >> $1_sympar.r
echo  >> $1_sympar.r

#Count the lines in the file
lines=`grep -c  '.' $1_sympar.txt`

if [ "$lines" != "0" ]; then
    echo "MATRIX MTTVAR($lines,1);"   >> $1_sympar.r
fi
echo "MTTNVAR := $lines;"   >> $1_sympar.r
echo   >> $1_sympar.r

#Write out the variables in reduce format.
gawk '{i++; print "MTTVAR(" i ",1) := " $1 ";"}' $1_sympar.txt  >> $1_sympar.r

echo 'END;'  >> $1_sympar.r

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Added mtt/bin/trans/sympar_txt2tex version [937e1d805d].

































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2tex

# Sympar file - text to TeX table conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/27 16:04:46  peterg
## Initial revision
##
## Revision 1.2  1998/01/19 14:17:26  peterg
## Modified struc_txt2tex to make this.
##
## Revision 1.1  1998/01/19 14:16:39  peterg
## Initial revision
##
# Revision 1.3  1997/12/06  19:10:41  peterg
# Reverted to tabular --- from supertabular
#
# Revision 1.2  1997/04/15  11:17:58  peterg
# Uses supertabular for long tables.
#
# Revision 1.1  1997/04/15  09:49:04  peterg
# Initial revision
#
###############################################################


# Inform user
echo "Creating $1_sympar.tex"

rm -f mtt_error

#Write some file headers
echo "%% Parameter file ($1_sympar.txt)" > $1_sympar.tex
echo "%% Generated by MTT at `date`" >> $1_sympar.tex

# This is the main transformation using awk
sed 's/_/\\_/g' < $1_sympar.txt |  gawk '
#function header(what){
#  print "  \\centering";
# print "  \\tablefirsthead{\\hline %";
#  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM "} \\\\";
#  print "    \\hline";
#  print "     & Component & System & Repetition \\\\";
#  print "    \\hline}";
#
#  print "  \\tablehead{\\hline %";
#  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM " (continued)} \\\\";
#  print "    \\hline";
#  print "     & Component & System & Repetition \\\\";
#  print "    \\hline}";
#
#  print "  \\tabletail{\\hline}";
#  print "  \\begin{supertabular}{|l|l|l|l|}";
#}
function header(what){
  print "\\begin{table}[htbp]";
  print "  \\centering";
  print "  \\begin{tabular}{|l|l|}";  print "    \\hline";
  print "     Parameter & System\\\\";
  print "    \\hline";
}
function footer(what){
  print "    \\hline";
  print "  \\end{tabular}";
  print "  \\caption{" what "}";
  print "\\end{table}";
  print "   \\bigskip";
  print "   \\bigskip";
}
BEGIN{
  header($1);
}
{
  print $1, "&", $2, "\\\\";
}
END{
  footer("Parameters")
}
'  SYSTEM=$1  >> $1_sympar.tex 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Added mtt/bin/trans/tex2doc version [378ed3e3b7].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: tex2doc
# Encapsulates a tex file in a document.

# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/12/28 12:48:53  peterg
## Put under RCS
##
# Revision 1.2  1996/08/30  10:19:11  peter
# New path for awk script.
#
## Revision 1.1  1996/08/18 20:00:20  peter
## Initial revision
##
###############################################################

# Inform user
echo "Creating $1_$2.doc"

# This is the main transformation using awk
gawk -f $MTTPATH/trans/awk/tex2doc.awk \
system_name=$1 representation=$2  > $1_$2.doc

Added mtt/bin/trans/tf_r2m version [2cb9afaa60].

























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: tf_r2m
# Reduce transfer-function matrices to Matlab MV toolbox matrices.
# P.J.Gawthrop 9 June 1990, 8 July 1990, Dec 993
# Copyright (c) P.J.Gawthrop, 1990, 1993.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/05/24 07:42:12  gawthrop
## Included and updated the missing tf_r2m
##
## Revision 1.1  1996/09/18 14:05:31  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_tf.m

# Remove the old log file
rm -f tf_r2m.log

# Use reduce to accomplish the transformation
reduce >tf_r2m.log << EOF

%Read the definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
%%in "$1_sympar.r";

%Read the transfer-function matrices file
OFF Exp; ON GCD; 
in "$1_tf.r";

OFF Echo;
%OFF Nat;
OFF factor;

%Find the largest degree numerator polynomial
NnMax := 0;
  FOR Row := 1:MTTNy DO
  BEGIN
    FOR Col := 1:MTTNu DO
    BEGIN
    Nn := length(coeff(num(MTTtf(Row,Col)),s));
    IF Nn>NnMax THEN NnMax := Nn;
    END;
  END;

NnMax;

%Find the largest degree denominator polynomial, and corresp indices
NdMax := 0;
  FOR Row := 1:MTTNy DO
  BEGIN
    FOR Col := 1:MTTNu DO
    BEGIN
    Nd := length(coeff(den(MTTtf(Row,Col)),s));
    IF Nd>NdMax THEN 
                BEGIN
                  NdMax := Nd; MaxRow := Row; MaxCol := Col;
                END
    END;
  END;

NdMax; MaxRow; MaxCol;

IF NnMax>NdMax THEN NMax := NnMax ELSE NMax := NdMax;
Nmax;

%Use any denominator with maximum degree as the common denominator
MTTden := den(MTTtf(MaxRow,MaxCol));

%Find the corresponding numerator
matrix MTTnum(MTTNy,MTTNu);
  FOR Row := 1:MTTNy DO
  BEGIN
    FOR Col := 1:MTTNu DO
    MTTnum(Row,Col) := num(MTTtf(Row,Col))*(MTTden/den(MTTtf(Row,Col)));
  END;
MTTnum := MTTnum;

%Put coefficients into matrices
matrix MTTdenco(1,Nmax);
MTTCoeff := Coeff(MTTden,s);
FOR i := 1:Nmax DO
BEGIN
  j := Nmax-i+1;
  IF j>length(MTTCoeff) THEN MTTdenco(1,i) := 0 
                        ELSE MTTdenco(1,i) := part(MTTCoeff,j);
END; 
MTTdenco := MTTdenco;

matrix MTTnumco(MTTNy,MTTNu*Nmax);
FOR MTTRow := 1:MTTNy DO
BEGIN
  FOR MTTCol := 1:MTTNu DO
  BEGIN
    MTTCoeff := Coeff(MTTnum(MTTRow,MTTCol),s);
    FOR MTTi := 1:Nmax DO
    BEGIN
      MTTj := Nmax-MTTi+1;
      MTTk := MTTi + (MTTCol-1)*Nmax;
      IF MTTj>length(MTTCoeff) THEN MTTnumco(MTTRow, MTTk) := 0 
                            ELSE MTTnumco(MTTRow, MTTk) := part(MTTCoeff,MTTj);
    END;
  END;
END;



OUT "$1_tf.m1";

write "mttden = zeros(1,", Nmax, ");";
write "mttnum =    zeros(", MTTNy, ",", Nmax*MTTNu, ");";

%Suppress zeros
ON NERO;

%Fortran switches - one line expressions
ON fort;
cardno!* := 1\$
fortwidth!* := 100\$
OFF period;

%Write out the matlab code
mttden := MTTdenco;
mttnum    := MTTnumco;
SHUT "$1_tf.m1";
quit;
EOF

#Headers
mtt_header $1 tf m > $1_tf.m

#Body
cat $1_tf.m1  >> $1_tf.m
echo '## END Code' >> $1_tf.m
rm -f $1_tf.m1

Added mtt/bin/trans/tf_r2tex version [f44882531a].












































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: tf_r2tex
# Reduce transfer-function matrices to LaTex transfer-function matrices.
# P.J.Gawthrop 9 June 1990, 8 July 1990, April 1994.
# Copyright (c) P.J.Gawthrop, 1990, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2014/04/18 00:36:40  gawthrop
## No parentheses.
##
## Revision 1.1  2000/12/27 16:05:29  peterg
## Initial revision
##
## Revision 1.2  1996/12/20 08:59:40  peterg
## Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
## conversion.
##
## Revision 1.1  1996/11/05 11:01:51  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_tf.tex

# Remove the old log file
rm -f tf_r2tex.log

# Use reduce to accomplish the transformation
reduce >tf_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the parameter file
%%in "$1_sympar.r";

%Read the formatting function
IF MTTNy=1 AND MTTNu=1 
  THEN
    in "$MTTPATH/trans/latex_matrix_no.r"
  ELSE
    in "$MTTPATH/trans/latex_matrix.r";

%Read the transfer-function matrices file
in "$1_tf.r";

%Read the substitution file
IN "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

OFF Echo;
OFF Nat;

OUT "$1_tf.tex";
MTT_Matrix := MTTTF$ 
MTT_Matrix_name := "MTTG"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

%%  FOR Row := 1:MTTNy DO
%%  BEGIN
%%    FOR Col := 1:MTTNu DO
%%    BEGIN
%%      numerator := num(MTTtf(Row,Col));
%%      denominator := den(MTTtf(Row,Col));
%%      cnumerator := coeff(numerator, s);
%%      cdenominator := coeff(denominator, s);
%%      write "!begin{equation} !label{eq_$1_tf", Row, Col, "}";
%%      IF MTTNy=1 AND MTTNu=1 
%%                          THEN
%%                          write "MTTTF(s) =  {"
%%                          ELSE
%%                          write "MTTTF", Row, Col, "(s) =  {";
%%      IF numerator = 0
%%       THEN write "0"
%%       ELSE 
%%       BEGIN
%%           FOR i := 1:Length(cnumerator) DO
%%           BEGIN
%%             cof := part(cnumerator,i);
%%               IF cof NEQ 0 THEN 
%%               BEGIN
%%                IF i>1 THEN write " + ";
%%                IF cof NEQ 1 THEN 
%%                 BEGIN
%%                 IF Terms(cof)>1 THEN write "(", cof, ")"
%%                                 ELSE write cof; 
%%                 END
%%                 ELSE IF i=1 THEN Write "1";
%%
%%               IF i=2 THEN write "s";
%%               IF i>2 THEN write "s^", i-1;
%%               END;
%%           END;
%%       END;
%%
%%       IF denominator NEQ 1 THEN
%%       BEGIN
%%       Write "!over";
%%           FOR i := 1:Length(cdenominator) DO
%%           BEGIN
%%           cof := part(cdenominator,i);
%%               IF cof NEQ 0 THEN 
%%               BEGIN
%%               IF i>1 THEN write " + ";
%%               IF cof NEQ 1 THEN 
%%               BEGIN
%%                 IF Terms(cof)>1 THEN write "(", cof, ")"
%%                                 ELSE write cof; 
%%               END
%%               ELSE IF i=1 THEN Write "1";
%%
%%             IF i=2 THEN write "s";
%%             IF i>2 THEN write "s^", i-1;
%%             END;
%%           END;
%%       END;
%%       write "}";
%%       write "!end{equation}";
%%    END;
%%  END;
%%
SHUT "$1_tf.tex";
quit;
EOF

Added mtt/bin/trans/tidy version [5d66b20135].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
mv $1 $1.old

cat $1.old |
#Clear out all (and extraneous) new lines
tr -d '\012'  |\

#Squash blanks
tr -s '\040' '\040' |\

#Put in new lines to replace $
tr '\044' '\012' |\

#Remove blanks after E
sed "s/E /E/g"  |\

#Put in $ at end of each line
sed "s/$/\$/" >$1

Added mtt/bin/trans/txt2m version [75f1960eab].



























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: txt2m
# Converts txt file to matlab file (for numpar and state)

# Copyright (c) P.J.Gawthrop 1998


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.19  2000/02/11 13:35:16  peterg
# %% Added the new MTTpar generation
# %%
# %% Revision 1.18  1999/11/14 22:22:17  peterg
# %% Removed checks for implicit - now done at command-line level.
# %%
# %% Revision 1.17  1999/11/04 04:54:24  peterg
# %% Removed recreation of smx file.
# %%
# %% Revision 1.16  1999/03/06 02:18:10  peterg
# %% Changed argument list.
# %%
# %% Revision 1.15  1999/02/16 21:44:38  peterg
# %% Revised smx generation
# %%
# %% Revision 1.14  1999/02/16 04:38:22  peterg
# %% Now forces creation of _smx file if METHOD=IMPLICIT in simpar.txt
# %%
# %% Revision 1.13  1998/08/31 11:43:37  peterg
# %% Now lower cases globals in numpar files
# %%
# %% Revision 1.12  1998/08/14 10:47:31  peterg
# %% Put ImplicitS sub before Implicit!!
# %%
# %% Revision 1.11  1998/08/14 10:43:44  peterg
# %% Added ImplicitS - sparse integration
# %%
# %% Revision 1.10  1998/08/11 13:27:51  peterg
# %% Lowercase mttLAST etc
# %%
# %% Revision 1.9  1998/07/30 15:07:17  peterg
# %% Added _ to the disallowed chars around t
# %%
# %% Revision 1.8  1998/07/30 12:52:38  peterg
# %% Adds ; to end of statements
# %% Translates ' to " before removal
# %%
# %% Revision 1.7  1998/07/30 09:32:33  peterg
# %% Replaces:
# %% 	euler by 1
# %% 	implicitl by 1
# %% 	implicit  by 3
# %%
# %% Revision 1.6  1998/07/27 18:59:11  peterg
# %% Added WMIN etc
# %%
# %% Revision 1.5  1998/07/26 11:54:20  peterg
# %% Added  mtt to variables
# %%
# %% Revision 1.4  1998/07/26 09:50:12  peterg
# %% More forgiving of txt sytax.
# %%
# %% -- can use () or ()
# %% -- can use mttx() or x()
# %% -- can use mttu() or u()
# %%
# %% Revision 1.3  1998/07/25 20:40:35  peterg
# %% All vars in lower case now
# %%
# %% Revision 1.2  1998/07/25 09:48:31  peterg
# %% Tidied up for Pascal version
# %%
# %% Revision 1.1  1998/02/25 22:10:25  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

system=$1
representation=$2

if [ "$representation" = "state" ]; then
    name='mttx';
    arg='';
fi
if [ "$representation" = "input" ]; then
    name='mttu';
    arg='(mttt,mttx,mtty)'
fi

# Inform user
echo Creating $1_$2.m

#Create the $2 file complete with headers.
case $representation in
    simpar)
      echo "% Script file  $1_$2.m" > $1_$2.m
      echo "%% $2 file ($1_$2.m)" >> $1_$2.m
      echo "%% Generated by MTT at `date`" >> $1_$2.m
      echo '% Dummy globals' >>  $1_$2.m
      echo 'global ...' >>  $1_$2.m
      echo 'mtt_dummy_global;' >>  $1_$2.m
      ;;
    numpar)
      echo "% Script file  $1_$2.m" > $1_$2.m
      echo "%% $2 file ($1_$2.m)" >> $1_$2.m
      echo "%% Generated by MTT at `date`" >> $1_$2.m
      echo "% Global variable list" >>  $1_$2.m
      sympar2global_txt2m $1 >> $1_$2.m
      ;;
    *)
      echo "function $name = $1_$2$arg" > $1_$2.m
      echo "%% $2 file ($1_$2.m)" >> $1_$2.m
      echo "%% Generated by MTT at `date`" >> $1_$2.m
      echo "% Global variable list" >>  $1_$2.m
      sympar2global_txt2m $1 >> $1_$2.m
      ;;
esac

#Write out the variables in m format.
cat  $1_$2.txt | grep -v METHOD |\
gawk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");
  if (N==2) {
    LHS = a[1];
    RHS = a[2];
    gsub(quote, doublequote, RHS);
    sub(/^[ 	]*LAST/, "mttLAST", LHS);
    sub(/^[ 	]*DT/, "mttDT", LHS);
    sub(/^[ 	]*STEPFACTOR/, "mttSTEPFACTOR", LHS);
    sub(/^[ 	]*METHOD/, "mttMETHOD", LHS);
    sub(/^[ 	]*WMIN/, "mttWMIN", LHS);
    sub(/^[ 	]*WMAX/, "mttWMAX", LHS);
    sub(/^[ 	]*WSTEPS/, "mttWSTEPS", LHS);
    sub(/^[ 	]*INPUT/, "mttinput", LHS);
    LHS = tolower(LHS);
    RHS = tolower(RHS);
    sub(/["]*euler["]*/, 1, RHS);   
    sub(/["]*implicit["]*/, 2, RHS);  
    statement = sprintf("%s= %s",LHS,RHS);
    if ( (match(statement,";")==0)&&\
         ((match(statement,"if ")==0))&&\
         ((match(statement,"for ")==0)) )
      statement = sprintf("%s;", statement);
  }
  else if (match($1,"global")==1) {
    statement = tolower($1); # Lower case globals as well
  }
  else
    statement = $1;

  if (NF<2) print statement
  if (NF>1)  print statement " # " $2
}' | sed\
     -e 's/\[\([0-9]*\)\]/(\1)/g' \
     -e 's/\([^a-zA-Z_]\)t\([^a-zA-Z_]\)/\1mttt\2/g' \
     -e 's/x(/mttx(/g' \
     -e 's/u(/mttu(/g' \
     -e 's/mttmtt/mtt/g' \
     -e 's/#/%/g' \
>> $1_$2.m


if [ "$2" = "numpar" ]; then
    gawk '{
       printf("  MTTpar(%i) \t= %s;\n",++i, tolower($1));
     }'< $1_sympar.txt  >>$1_numpar.m
fi








Added mtt/bin/trans/txt2tex version [18a439014a].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: txt2tex

# Generic textual inclusion as verbatim tex.

# P.J.Gawthrop March 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

if [ -z "$3" ]; then
   echo Usage: txt2tex system representation language
   exit 1
fi
# Inform user
echo "Creating $1_$2.tex"

rm -f mtt_error

#Write some file headers
echo "%% Tex file ($1_$2.txt)" > $1_$2.tex
echo "%% Generated by MTT at `date`" >> $1_$2.tex

cat <<EOF        >> $1_$2.tex
\begin{verbatim}
EOF
cat $1_$2.$3     >> $1_$2.tex
cat<<EOF         >> $1_$2.tex
\end{verbatim}
EOF




Added mtt/bin/trans/txt_matrix.r version [920388fb07].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in text form
% P.J.Gawthrop  Febrauary 1998
% Copyright (c) P.J.Gawthrop, 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


PROCEDURE txt_Matrix;
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
    FOR i := 1:MTT_Matrix_n DO
      IF MTT_Matrix_m>1 THEN
        BEGIN
        FOR j := 1:MTT_Matrix_m DO 
          write MTT_Matrix_name, "(", i, ",", j, ") = ",
                                            MTT_Matrix(i,j), ";";
        END
      ELSE
         write MTT_Matrix_name, "(", i, ") = ",
                                            MTT_Matrix(i,1), ";";
    END;
END;

END;;

Added mtt/bin/xmtt version [026c569d97].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: xmtt
#
# x-window version of MTT

# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/09/14 07:50:08  peterg
## *** empty log message ***
##
## Revision 1.4  1999/10/19 00:34:10  peterg
## *** empty log message ***
##
## Revision 1.3  1999/08/18 06:17:55  peterg
## Modular form
##
## Revision 1.2  1999/03/09 00:03:55  peterg
## Major revisions for release 3.5
##
## Revision 1.1  1998/10/20 08:15:17  peterg
## Initial revision
##
###############################################################

#Basic paths
dotfile="$HOME/.mtt"
xdotfile="${dotfile}/xmtt"

repfile="${xdotfile}/reps"
exfile="${xdotfile}/examples"
menufile=".xmtt_menu"

#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	--help|-h ) echo "usage:"
                    echo "  xmtt"
	            echo "  xmtt --update"
	            echo "  xmtt --example example_name"
	            echo "  xmtt --help"
		    exit;;

	--update|-u )    echo Creating representation list for mtt;
		         mtt2reps_txt> ${repfile};
		         echo Creating examples list for mtt;
		         mtt -q help examples> ${exfile};
                         exit;;

        --example|-e )   shift; example=$1;; 
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

if [ -n "${example}" ]; then
    mtt -q  copy ${example}; 
    cd ${example}; 
    xmtt
    exit
fi

## Make sure files exist
if [ -e "${xdotfile}" ]; then
    echo ${xdotfile} exists >/dev/null
else 
    echo Creating ${xdotfile}
    mkdir --parents ${xdotfile}
fi

if [ -e "${repfile}" ]; then
    echo ${repfile} exists >/dev/null
else 
    echo Creating ${repfile} and ${exfile}
    xmtt --update
    echo done.
fi

## Create the menu
mtt_make_menu > ${menufile}

## Use tk shell (wish)
name=`basename $PWD`
wish ${menufile} -name $name

Added mtt/cc/Makefile version [943d4cbedc].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+

CXX ?= g++

build: parse_m2cc.exe

.PHONY: FORCE
clean: FORCE
	@-rm -f parse_m2cc.exe

parse_m2cc.exe: parse_m2cc.cc
	@$(CXX) $< $(CFLAGS) -o $@ -I./include
	@strip $@

Added mtt/cc/def_m2h.sh version [e00c7a936e].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# $Id$
# $Log$
# Revision 1.3  2002/05/15 14:22:25  geraint
# Code for Simulink S-function target written direct to sfun.cc instead of
# calling .mexglx files. This eliminates the sfun dependency on Octave
# ColumnVectors. sys_sfun.cc should build directly on a MS Windows machine
# (can't test this yet).
#
# added sfun.zip target to create source code to export.
#
# Revision 1.2  2002/04/28 18:58:06  geraint
# Fixed [ 549658 ] awk should be gawk.
# Replaced calls to awk with call to gawk.
#
# Revision 1.1  2000/12/28 09:46:05  peterg
# put under RCS
#
# Revision 1.3  2000/12/05 12:13:52  peterg
# Changed function name to name()
#
# Revision 1.2  2000/12/04 12:04:46  peterg
# Changed $() to `` for sh compatibility -- geraint
#
# Revision 1.1  2000/12/04 12:02:23  peterg
# Initial revision
#
# Revision 1.1  2000/10/31 04:32:28  geraint
# Initial revision
#

SYS=$1
IN=${SYS}_def.m
SYM=${SYS}_sympar.txt
OUT=${SYS}_def.h

get_array_size ()
{
vec=$1
gawk -v vec=${vec} '($1 == vec && $2 == "=") { print $3 }' | sed s/\;//
}

 echo "/* ${SYS}_def.h, generated by MTT on `date` */"			>  ${OUT}
 echo ""								>> ${OUT}
 echo "#ifndef HAVE_${SYS}_DEF_H"					>> ${OUT}
 echo "#define HAVE_${SYS}_DEF_H"					>> ${OUT}
 echo ""								>> ${OUT}
 echo "const int MTTNU   = `cat ${IN} | get_array_size nu`;"		>> ${OUT}
 echo "const int MTTNX   = `cat ${IN} | get_array_size nx`;"		>> ${OUT}
 echo "const int MTTNY   = `cat ${IN} | get_array_size ny`;"		>> ${OUT}
 echo "const int MTTNZ   = `cat ${IN} | get_array_size nz`;"		>> ${OUT}
 echo "const int MTTNYZ  = `cat ${IN} | get_array_size nyz`;"		>> ${OUT}
 echo "const int MTTNPAR = `wc -l ${SYM} | gawk '{ print $1 }'`;"      	>> ${OUT}
 echo ""								>> ${OUT}
 echo "static int mttnu, mttnx, mttny, mttnyz, mttnz;"		       	>> ${OUT}
 echo ""								>> ${OUT}
 echo "#endif"								>> ${OUT}



Added mtt/cc/include/Bracket.hh version [5787729a17].































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* $Id$
 * $Log$
 * Revision 1.1.4.1  2001/06/30 03:26:20  geraint
 * gcc-3.0 compatibility.
 *
 * Revision 1.1  2000/12/28 09:47:29  peterg
 * put under RCS
 *
 * Revision 1.1  2000/10/31 04:29:11  geraint
 * Initial revision
 *
 */



#include <iostream>
#include <string>


using namespace std;

class Bracket
{
public:
  friend ostream &operator<< (ostream &str, Bracket *b);
  friend string  &operator<< (string  &str, Bracket *b);
  friend string  &operator+= (string  &str, Bracket *b);
  friend string   operator+  (string  &str, Bracket *b);
  virtual int get_nesting_depth (void)		= 0;

protected:
  Bracket (char left, char right)	  	{ _l = left; _r = right; }
  ostream &open  (ostream &str)			{ this->increment_nesting (); return str << this->_l; }
  string  &open  (string  &str)			{ this->increment_nesting (); return str += this->_l; }
  ostream &close (ostream &str)			{ this->decrement_nesting (); return str << this->_r; }
  string  &close (string  &str)			{ this->decrement_nesting (); return str += this->_r; }

protected:
  virtual int increment_nesting (void)		= 0;
  virtual int decrement_nesting (void)		= 0;
  virtual ostream &display (ostream &str)	= 0;
  virtual string  &display (string  &str)	= 0;

private:
  char _l, _r;
};



class Brace : public Bracket
{
public:
  int get_nesting_depth (void)			{ return   (this->nesting_depth);}
  string indentation (int n = nesting_depth)
  {
    string s = "";
    int i;
    for (i = 0; i < n; i++)
      s += "   ";
    return s;
  }

protected:
  Brace () : Bracket ('{', '}')			{ ; }
  int increment_nesting (void)			{ return ++(this->nesting_depth); }
  int decrement_nesting (void)			{ return --(this->nesting_depth); }
  ostream &open (ostream &str)
  {
    str << endl << this->indentation ();
    this->Bracket::open (str);
    str << endl << this->indentation ();
    return str;
  }
  string &open (string &str)
  {
    str += '\n' + this->indentation ();
    this->Bracket::open (str);
    str += '\n' + this->indentation ();
    return str;
  }
  ostream &close (ostream &str)
  {
    str << endl << this->indentation (nesting_depth - 1);
    this->Bracket::close (str);
    str << endl << this->indentation ();
    return str;
  }
  string &close (string &str)
  {
    str += '\n' + this->indentation (nesting_depth - 1);
    this->Bracket::close (str);
    str += '\n' + this->indentation ();
    return str;
  }

private:
  static int nesting_depth;
};
int Brace::nesting_depth;



class Paren : public Bracket
{
public:
  int get_nesting_depth (void)			{ return   (this->nesting_depth);}

protected:
  Paren () : Bracket ('(', ')')			{ ; }
  int increment_nesting (void)			{ return ++(this->nesting_depth); }
  int decrement_nesting (void)			{ return --(this->nesting_depth); }

private:
  static int nesting_depth;
};
int Paren::nesting_depth;



class SquareBracket : public Bracket
{
public:
  int get_nesting_depth (void)			{ return   (this->nesting_depth);}

protected:
  SquareBracket () : Bracket ('[', ']')	       	{ ; }
  int increment_nesting (void)			{ return ++(this->nesting_depth); }
  int decrement_nesting (void)			{ return --(this->nesting_depth); }

private:
  static int nesting_depth;
};
int SquareBracket::nesting_depth;



class LeftBrace : public Brace
{
public:
  ostream &display (ostream &str)		{ return this->open  (str); }
  string  &display (string  &str)		{ return this->open  (str); }
};



class RightBrace : public Brace
{
public:
  ostream &display (ostream &str)		{ return this->close (str); }
  string  &display (string  &str)		{ return this->close (str); }
};



class LeftParen : public Paren
{
public:
  ostream &display (ostream &str)		{ return this->open  (str); }
  string  &display (string  &str)		{ return this->open  (str); }
};



class RightParen : public Paren
{
public:
  ostream &display (ostream &str)		{ return this->close (str); }
  string  &display (string  &str)		{ return this->close (str); }
};



class LeftSquareBracket : public SquareBracket
{
public:
  ostream &display (ostream &str)		{ return this->open  (str); }
  string  &display (string  &str)		{ return this->open  (str); }
};



class Rightbrace : public SquareBracket
{
public:
  ostream &display (ostream &str)		{ return this->close (str); }
  string  &display (string  &str)		{ return this->close (str); }
};



ostream &operator<< (ostream &str, Bracket *b)
{
  b->display (str);
  return str;
}



string  &operator<< (string  &str, Bracket *b)
{
  string s;
  b->display (s);
  str += s;
  return str;
}



string  &operator+= (string  &str, Bracket *b)
{
  b->display (str);
  return str;
}



string   operator+  (string  &str, Bracket *b)
{
  string s;
  b->display (s);
  return (str + s);
}

Added mtt/cc/include/useful-functions.hh version [039f409770].

















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef HAVE_USEFUL_FUNCTIONS_HH
#define HAVE_USEFUL_FUNCTIONS_HH

/* Code generation directives */
#define STANDALONE 0
#define OCTAVEDLD  1
#define MATLABMEX  2
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET -1
#endif /* (! defined (CODEGENTARGET)) */

#ifndef __cplusplus
#define inline			/* strip */
#define cast_to_double	(double)
/*
typedef unsigned int bool;
const bool true = 1;
const bool false = 0;
*/
#else
#include <cmath>
#define cast_to_double	static_cast<double>
using std::pow;
#endif /* ! __cplusplus */

#ifdef M_PI
static double pi = M_PI;
static double Pi = M_PI;
static double PI = M_PI;
#else
static double pi = 3.1416;
static double Pi = pi;
static double PI = pi;
#endif

static inline double
max (const double x1, const double x2)
{
  return cast_to_double ((x1 >= x2) ? x1 : (x1 < x2) ? x2 : 0);
}

static inline double
min (const double x1, const double x2)
{
  return cast_to_double ((x1 <= x2) ? x1 : (x1 > x2) ? x2 : 0);
}

static inline double
nonsingular (const double x)
{
  return cast_to_double ((x == 0) ? 1.0e-30 : x);
}

static inline double
sign (const double x)
{
  return cast_to_double ((x > 0) ? +1 : (x < 0) ? -1 : 0);
}


/* Octave functions */
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == OCTAVEDLD))
#ifdef __cplusplus
static Matrix
ones (const int r = 1, const int c = 1)
{
  Matrix m (r, c, 1.0);
  return m;
}

static ColumnVector
nozeros (const ColumnVector v0, const double tol = 0.0)
{
  ColumnVector v (v0.length ());
  register int i, j;
  for (i = j = 0; i < v.length (); i++)
    if (tol < std::abs (v0 (i)))
      {
	v (j) = v0 (i);
	j++;
      }
  if (0 == j)
    {
      return *new ColumnVector ();
    }
  else
    {
      return (v.extract (0, --j));
    }
}

static ColumnVector
zeros (const int r)
{
  ColumnVector v (r, 0.0);
  return v;
}

static Matrix
zeros (const int r, const int c)
{
  Matrix m (r, c, 0.0);
  return m;
}
#endif /* __cplusplus */
#endif /* ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == OCTAVEDLD)) */



#endif /* HAVE_USEFUL_FUNCTIONS_HH */

Added mtt/cc/mtt_m2cc.sh version [d022332fbb].






















































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

SYS=$1
REP=$2
TARGET=${3:-cc}
PARSER=${4:-indent}

IN=${SYS}_${REP}.m
OUT=${SYS}_${REP}.${TARGET}
TMP=${SYS}_${REP}_m2cc.tmp

rep_declarations ()
{
(case ${REP} in
    simpar)
	cat <<EOF
  struct {
    double first;
    double dt;
    double last;
    int    stepfactor;
    int    wmin;
    int    wmax;
    int    wsteps;
    int    input;
  } mttsimpar;

EOF
	;;
    *)
	;;
esac)
echo ""
};

rep_footer ()
{
(case ${REP} in
    simpar)
	cat <<EOF
  mttsimpar_map(0)	= (double) mttsimpar.first;
  mttsimpar_map(1)	= (double) mttsimpar.last;
  mttsimpar_map(2)	= (double) mttsimpar.dt;
  mttsimpar_map(3)	= (double) mttsimpar.stepfactor;
  mttsimpar_map(4)	= (double) mttsimpar.wmin;
  mttsimpar_map(5)	= (double) mttsimpar.wmax;
  mttsimpar_map(6)	= (double) mttsimpar.wsteps;
  mttsimpar_map(7)	= (double) mttsimpar.input;
EOF
	;;
    *)
	;;
esac)
};

find_code ()
{
    file_in=${1:-${IN}}
    portion=${2:-"body"}
    head=`cat ${file_in} | gawk '($2 == "BEGIN" && $3 == "Code") { print NR }'`
    foot=`cat ${file_in} | gawk '($2 == "END"   && $3 == "Code") { print NR }'`
    case ${portion} in
	head)
	    start=0
	    end=${head}
	    ;;
	body)
	    start=${head}
	    end=${foot}
	    ;;
	foot)
	    start=${foot}
	    end=end
	    ;;
	*)
	    echo "Error in find_code: portion unknown"
	    return -1
	    ;;
    esac
    cat ${file_in} |\
    gawk --assign start=${start} --assign end=${end} '
	(start < NR && NR < end) { print $0 }'
};


strip_junk ()
{
case ${REP} in
    numpar)
	grep -v "mttpar = \[\]"
	;;
    switchopen)
	grep -v "\[open\] = zero"
	;;
    *)
	cat
	;;
esac
};

fix_comment_delimiter ()
{
    language=${1:-cc}
    case $language in
    # it would be preferable if we didn't use '%' as a delimiter
    # (a % b) gives the remainder of ((int)a / (int)b) in C/C++
	c)
	    sed 's/[%#]\(.*\)/\/* \1 *\//'
	    ;;
	cc | *)
	    sed 's/[%#]/\/\//g' | sed 's/\/\/\/\//\/\//g'
	    ;;
    esac
};

decrement_indices ()
{    
    # first section appends '-1' to container indices
    # to convert from FORTRAN-type numbering to C-type numbering
    # and C-type indices () to FORTRAN-type []
    sed 's/mtta(\([0-9][0-9]*\),\([0-9][0-9]*\))/mtta[\1-1,\2-1]/g'	|\
    sed 's/mttax(\([0-9][0-9]*\))/mttax[\1-1]/g'			|\
    sed 's/mttdx(\([0-9][0-9]*\))/mttdx[\1-1]/g'			|\
    sed 's/mttedx(\([0-9][0-9]*\))/mttedx[\1-1]/g'			|\
    sed 's/mttpar(\([0-9][0-9]*\))/mttpar[\1-1]/g'			|\
    sed 's/mttu(\([0-9][0-9]*\))/mttu[\1-1]/g'				|\
    sed 's/mttx(\([0-9][0-9]*\))/mttx[\1-1]/g'				|\
    sed 's/mtty(\([0-9][0-9]*\))/mtty[\1-1]/g'				|\
    sed 's/mttyz(\([0-9][0-9]*\))/mttyz[\1-1]/g'			|\
    sed 's/mttz(\([0-9][0-9]*\))/mttz[\1-1]/g'				|\
    sed 's/mttopen(\([0-9][0-9]*\))/mttopen[\1-1]/g'				|\
									 \
    # next sections tidy the code up a bit, but are not necessary
    sed 's/1\-1\([],]\)/0\1/g'       			       		|\
    sed 's/2\-1\([],]\)/1\1/g'       			       		|\
    sed 's/3\-1\([],]\)/2\1/g'       			       		|\
    sed 's/4\-1\([],]\)/3\1/g'       			       		|\
    sed 's/5\-1\([],]\)/4\1/g'       			       		|\
    sed 's/6\-1\([],]\)/5\1/g'       			       		|\
    sed 's/7\-1\([],]\)/6\1/g'       			       		|\
    sed 's/8\-1\([],]\)/7\1/g'       			       		|\
    sed 's/9\-1\([],]\)/8\1/g'       			       		|\
									 \
    sed 's/\([0-9]\)10\-1\([],]\)/\109\2/g'		       		|\
    sed 's/10\-1\([],]\)/9\1/g'     			       		|\
    sed 's/20\-1\([],]\)/19\1/g'	       		       		|\
    sed 's/30\-1\([],]\)/29\1/g'		       	       		|\
    sed 's/40\-1\([],]\)/39\1/g'			       		|\
    sed 's/50\-1\([],]\)/49\1/g'		               		|\
    sed 's/60\-1\([],]\)/59\1/g'		      	       		|\
    sed 's/70\-1\([],]\)/69\1/g'		       	       		|\
    sed 's/80\-1\([],]\)/79\1/g'		       	       		|\
    sed 's/90\-1\([],]\)/89\1/g'		       	       		|\
									 \
    sed 's/\([0-9]\)100\-1\([],]\)/\199\2/g'		       		|\
    sed 's/100\-1\([],]\)/99\1/g'   			       		|\
    sed 's/200\-1\([],]\)/199\1/g'	       		       		|\
    sed 's/300\-1\([],]\)/299\1/g'		       	       		|\
    sed 's/400\-1\([],]\)/399\1/g'			       		|\
    sed 's/500\-1\([],]\)/499\1/g'			       		|\
    sed 's/600\-1\([],]\)/599\1/g'			       		|\
    sed 's/700\-1\([],]\)/699\1/g'			       	       	|\
    sed 's/800\-1\([],]\)/799\1/g'			       		|\
    sed 's/900\-1\([],]\)/899\1/g'			       		|\
    sed 's/\([(,]\)0\([0-9]\)/\1\2/g'
};

c_to_fortran_paren ()
{
    tr "[]" "()"
}
	
fix_pow ()
{
    # matches number^number where number is one or more digits and one or zero decimal points
    # converts to pow (number, number)
    sed 's/\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)\^\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)/pow \(\1\2\3,\4\5\6\)/g'
};


echo Creating ${OUT}

case ${TARGET} in
    c)
	mtt_header ${SYS} ${REP} "c"	>  ${TMP}
	find_code ${TMP} head		>  ${OUT}
	find_code ${IN} body		|\
	    decrement_indices		|\
	    fix_comment_delimiter c	|\
	    fix_pow			|\
	    strip_junk			|\
	    ${PARSER}			>> ${OUT}
	find_code ${TMP} foot		>> ${OUT}
	rm ${TMP}
	;;
    cc | *)
	mtt_header ${SYS} ${REP} "oct"	>  ${TMP}
	find_code ${TMP} head		>  ${OUT}
	rep_declarations		>> ${OUT}
	find_code ${IN} body   		|\
	    decrement_indices		|\
	    c_to_fortran_paren		|\
	    fix_comment_delimiter cc	|\
	    fix_pow			|\
	    strip_junk			|\
	    ${PARSER}			>> ${OUT}
	rep_footer			>> ${OUT}
	find_code ${TMP} foot		>> ${OUT}
	rm ${TMP}
	;;
esac


Added mtt/cc/parse_m2cc.cc version [b1b04bdad9].









































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* $Id$
 * $Log$
 * Revision 1.4  2002/05/01 12:54:55  geraint
 * Now recognises keywords terminated with ; as well as ws.
 * Now recognises # as a comment when not terminated by ws.
 * i.e. CarnotCycle_input.txt now gets translated correctly!
 *
 * Revision 1.3  2001/07/13 04:54:04  geraint
 * Branch merge: numerical-algebraic-solution back to main.
 *
 * Revision 1.2.2.1  2001/06/30 03:26:17  geraint
 * gcc-3.0 compatibility.
 *
 * Revision 1.2  2001/03/19 02:28:53  geraint
 * Branch merge: merging-ode2odes-exe back to MAIN.
 *
 * Revision 1.1.2.2  2001/03/09 04:01:20  geraint
 * \ escapes newline.
 *
 * Revision 1.1.2.1  2001/03/09 02:59:26  geraint
 * got_comment: (char)c no longer compared to (int)EOF.
 *
 * Revision 1.1  2000/12/28 09:46:05  peterg
 * put under RCS
 *
 * Revision 1.1  2000/10/31 04:29:50  geraint
 * Initial revision
 *
 */


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <stack>
#include <string>



/*
 * Bracket.hh deals with nesting levels of parenthesis
 * just add Bracket pointer to string / stream
 */
#include "Bracket.hh"



using namespace std;

/*
 * use lbrace, etc. in expressions to automate nesting calculations
 */
LeftBrace	*lbrace = new LeftBrace;
RightBrace	*rbrace = new RightBrace;

LeftParen	*lparen = new LeftParen;
RightParen	*rparen = new RightParen;



/*
 * use brace nesting depth to determine indentation
 */
string indent (void) { return lbrace->indentation (); }



/*
 * map contains keyword to look for and function to call when found
 */
map <string, void (*)(void)> keyword;




/*
 * stack records current nest type
 * so that "end" can be handled correctly
 */
enum nest_type
{
  null,
  if_statement,
  switch_statement,
  while_statement
};

stack <enum nest_type> current_nest;



/*
 * assuming cin has '(' as next character
 * find the matching ')' and return the string contained within
 */
string get_test (void)
{
  const int entry_nesting = lparen->get_nesting_depth ();
  char c;
  string buf = "";
  cin.setf (ios::skipws);
  cin >> c;
  if ('(' != c)
    {
      cerr << "Sorry, test must be enclosed in ( )" << endl;
      cerr << "current character is " << c << endl;
      /*
       * replace this with a call to get_expression maybe?
       */
      exit (-1);
    }
  else
    {
      buf += lparen;
    }
  cin.unsetf (ios::skipws);
  while (entry_nesting != lparen->get_nesting_depth ()) {
    cin >> c;
    switch (c)
      {	
      case '(':
	buf += lparen;
	break;
      case ')':
	buf += rparen;
	break;
      case EOF:
	cerr << "Oops! EOF reached" << endl;
	exit (-1);
      default:
	buf += c;
	break;
      }
  }
  return buf;
}



/*
 * functions to be called upon detection of keyword
 */
void got_if (void)
{
  current_nest.push (if_statement);
  cout << "if ";
  cout << get_test ();
  cout << lbrace;
}

void got_else (void)
{
  cout << rbrace;
  cout << "else";
  cout << lbrace;
}

void got_elseif (void)
{
  cout << rbrace;
  got_if ();
} 

void got_switch (void)
{
  current_nest.push (switch_statement);
  cout << "switch ";
  cout << get_test ();
  cout << lbrace;
  /*
   * open a second brace so that each "case" can be enclosed
   */
  cout << lbrace;
}

void got_case (void)
{
  cout << rbrace;
  cout << "case ";
  cout << get_test ();
  cout << ':';
  cout << lbrace;
}

void got_otherwise (void)
{
  cout << rbrace;
  cout << "default:";
  cout << lbrace;
}

void got_while (void)
{
  current_nest.push (while_statement);
  cout << "while ";
  cout << get_test ();
  cout << lbrace;
}

void got_end (void)
{
  enum nest_type n = current_nest.top ();
  switch (n)
    {
    case if_statement:
    case while_statement:
      cout << rbrace;      
      break;
    case switch_statement:
      cout << rbrace
	   << rbrace;
      break;
    default:
      cerr << "Oops! Unmatched end ... aborting" << endl;
      exit (-1);
      break;
    }
  current_nest.pop ();
}

void got_comment (void)
{
  /*
   * get remainder of line in case there are any commented keywords
   */
  char c;
  cout << " // ";
  cin >> c;
  do {
    cout << c;
  } while (c != '\n' && cin >> c);
  cout << endl
       << indent () << ';' << endl
       << indent ();
}
  


/*
 * map contains keyword to look for and functions to call when found
 * functions must be of the form "void f (void) {...;}"
 * new structures should also be added to enum nest_type
 */
void set_keyword (void)
{
  // if
  keyword ["if"]		= got_if;
  keyword ["else"]		= got_else;
  keyword ["elseif"]		= got_elseif;
  keyword ["endif"]		= got_end;

  // switch
  keyword ["switch"]		= got_switch;
  keyword ["case"]		= got_case;
  keyword ["otherwise"] 	= got_otherwise;
  keyword ["endswitch"] 	= got_end;

  // while
  keyword ["while"]		= got_while;
  keyword ["endwhile"]		= got_end;

  // general
  keyword ["end"]		= got_end;

  /*
   * this won't work inside a string
   * or if there is no space around the delimiter
   */
  keyword ["#"]			= got_comment;
  keyword ["//"]		= got_comment;
  
/*
 * unimplemented keywords
 *
 keyword ["for"]		= got_for;
 keyword ["endfor"]		= got_end;
 keyword ["break"]		= got_break;
 keyword ["continue"]		= got_continue;
*/
}



/* read in one character at a time looking for tokens (delimited by whitespace)
 * if the token is a keyword, call the appropriate function
 */
int main (void)
{
  set_keyword ();
  string buf = "";
  char c;
  cin.unsetf (ios::skipws);
  while (cin >> c)
    {
      switch (c)
	{
	case EOF:
	  return 0;
	case ' ':
	case '\t':
	  if (keyword [buf])
	    {
	      keyword [buf]();
	    }
	  else
	    {
	      if (! lbrace->get_nesting_depth ())
		{
		  buf += c;
		}
	      cout << buf;
	    }
	  buf = "";
	  break;
	case ';':
	case '\n':
	  if (keyword [buf])
	    {
	      /*
	       * keyword found, call function
	       */
	      keyword [buf] ();
	    }
	  else
	    {
	      cout << buf
		/*
		 * keep newline in case this line has an EOL-comment
		 */
		   << endl
		/*
		 * EOL is end-of-statement in Octave, add ;
		 */
		   << indent () << ';' << endl
		   << indent ();
	    }
	  buf = "";
	  break;
	case '#':
	  if (keyword [buf])
	    {
	      /*
	       * keyword found, call function
	       */
	      keyword [buf] ();
	    }
	  else
	    {
	      cout << buf
		/*
		 * keep newline in case this line has an EOL-comment
		 */
		   << endl
		/*
		 * EOL is end-of-statement in Octave, add ;
		 */
		   << indent () << ';' << endl
		   << indent ();
	    }
	  keyword ["#"] ();
	  buf = "";
	  break;

	case '\\':
	  cin >> c;
	  if ('\n' == c)
	    {
	      buf += '\n';
	    }
	  else
	    {
	      buf += '\\';
	      buf += c;
	    }
	  break;
	default:
	  buf += c;
	}
      if (lbrace->get_nesting_depth ())
	{
	  cout.setf (ios::skipws);
	}
      else
	{
	  cout.unsetf (ios::skipws);
	}
    }
  return 0;
}


Added mtt/cc/sympar_txt2h.sh version [b45a52ff91].









































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# $Id$
# $Log$
# Revision 1.9  2004/08/29 03:18:11  geraint
# Do not write temporary variables if NUM_OF_TMP_VAR = 0.
#
# Revision 1.8  2002/09/16 08:08:01  geraint
# Merged changes from global-optimisation branch.
#
# Revision 1.7.2.1  2002/09/04 10:44:59  geraint
# Added option to specify number of tmp variables declared (-ntmpvar <N>).
#
# Revision 1.7  2002/07/10 11:53:32  geraint
# Replaced shell loop with template expansion - perceptibly quicker generation of sympar.h.
#
# Revision 1.6  2002/05/19 13:01:22  geraint
# Numerical solution of algebraic equations implemented for S-function target.
#
# Equation solving requires the Matlab Optimization Toolbox to be installed.
#
# Code has been changed from C++ to C to allow mex files to be built with LCC,
# the compiler bundled with Matlab.
#
# Parameters are now obtained from numpar.c instead of a dialogue box.
#
# `mtt <sys> sfun zip` creates all necessary files for building the model mex files.
#
# Revision 1.5  2002/04/28 18:58:06  geraint
# Fixed [ 549658 ] awk should be gawk.
# Replaced calls to awk with call to gawk.
#
# Revision 1.4  2001/08/24 21:41:04  geraint
# Fixed problem with declaration when there are no numerical parameters.
#
# Revision 1.3  2001/03/19 02:28:53  geraint
# Branch merge: merging-ode2odes-exe back to MAIN.
#
# Revision 1.2.2.1  2001/03/16 03:56:54  geraint
# Convert variable names to lower case.
#
# Revision 1.2  2001/02/05 13:03:19  geraint
# Restrict scope of variables to file (static).
# Warn GCC that variables may be unused.
#
# Revision 1.7  2001/01/09 15:43:50  geraint
# Warn gcc that variables may be unused.
#
# Revision 1.6  2001/01/08 05:47:56  geraint
# Restrict scope of variables to file (static)
#
# Revision 1.5  2000/12/05 12:44:55  peterg
# Changed $() to ``
#
# Revision 1.4  2000/12/05 12:16:02  peterg
# Changed function name to name()
#
# Revision 1.3  2000/12/04 11:05:01  peterg
# Removed () -- geraint
#
# Revision 1.2  2000/11/07 17:29:27  peterg
# Changed echo
#
# Revision 1.1  2000/11/07 17:28:53  peterg
# Initial revision
#
# Revision 1.1  2000/10/31 04:32:02  geraint
# Initial revision
#

SYS=$1

if [ $# -gt 1 ]
then
  NUM_OF_TMP_VAR=$2;
  shift; shift;
else
  NUM_OF_TMP_VAR=500
  shift;
fi
TMP_VAR_NAMES="mtt_tmp mtt_o $*"

IN=${SYS}_sympar.txt
OUT=${SYS}_sympar.h

declare_sys_param ()
{
cat ${IN} | gawk '(NF>0){printf ("static double %s MTT_UNUSED;\t/* %s\t*/\n", tolower($1), $2)}'
}

declare_temp_vars ()
{
for name in ${TMP_VAR_NAMES}
do
    echo ""

    cat <<EOF | head -$(expr ${NUM_OF_TMP_VAR} + 1)
static double ${name}0 MTT_UNUSED;
static double ${name}1 MTT_UNUSED;
static double ${name}2 MTT_UNUSED;
static double ${name}3 MTT_UNUSED;
static double ${name}4 MTT_UNUSED;
static double ${name}5 MTT_UNUSED;
static double ${name}6 MTT_UNUSED;
static double ${name}7 MTT_UNUSED;
static double ${name}8 MTT_UNUSED;
static double ${name}9 MTT_UNUSED;
static double ${name}10 MTT_UNUSED;
static double ${name}11 MTT_UNUSED;
static double ${name}12 MTT_UNUSED;
static double ${name}13 MTT_UNUSED;
static double ${name}14 MTT_UNUSED;
static double ${name}15 MTT_UNUSED;
static double ${name}16 MTT_UNUSED;
static double ${name}17 MTT_UNUSED;
static double ${name}18 MTT_UNUSED;
static double ${name}19 MTT_UNUSED;
static double ${name}20 MTT_UNUSED;
static double ${name}21 MTT_UNUSED;
static double ${name}22 MTT_UNUSED;
static double ${name}23 MTT_UNUSED;
static double ${name}24 MTT_UNUSED;
static double ${name}25 MTT_UNUSED;
static double ${name}26 MTT_UNUSED;
static double ${name}27 MTT_UNUSED;
static double ${name}28 MTT_UNUSED;
static double ${name}29 MTT_UNUSED;
static double ${name}30 MTT_UNUSED;
static double ${name}31 MTT_UNUSED;
static double ${name}32 MTT_UNUSED;
static double ${name}33 MTT_UNUSED;
static double ${name}34 MTT_UNUSED;
static double ${name}35 MTT_UNUSED;
static double ${name}36 MTT_UNUSED;
static double ${name}37 MTT_UNUSED;
static double ${name}38 MTT_UNUSED;
static double ${name}39 MTT_UNUSED;
static double ${name}40 MTT_UNUSED;
static double ${name}41 MTT_UNUSED;
static double ${name}42 MTT_UNUSED;
static double ${name}43 MTT_UNUSED;
static double ${name}44 MTT_UNUSED;
static double ${name}45 MTT_UNUSED;
static double ${name}46 MTT_UNUSED;
static double ${name}47 MTT_UNUSED;
static double ${name}48 MTT_UNUSED;
static double ${name}49 MTT_UNUSED;
static double ${name}50 MTT_UNUSED;
static double ${name}51 MTT_UNUSED;
static double ${name}52 MTT_UNUSED;
static double ${name}53 MTT_UNUSED;
static double ${name}54 MTT_UNUSED;
static double ${name}55 MTT_UNUSED;
static double ${name}56 MTT_UNUSED;
static double ${name}57 MTT_UNUSED;
static double ${name}58 MTT_UNUSED;
static double ${name}59 MTT_UNUSED;
static double ${name}60 MTT_UNUSED;
static double ${name}61 MTT_UNUSED;
static double ${name}62 MTT_UNUSED;
static double ${name}63 MTT_UNUSED;
static double ${name}64 MTT_UNUSED;
static double ${name}65 MTT_UNUSED;
static double ${name}66 MTT_UNUSED;
static double ${name}67 MTT_UNUSED;
static double ${name}68 MTT_UNUSED;
static double ${name}69 MTT_UNUSED;
static double ${name}70 MTT_UNUSED;
static double ${name}71 MTT_UNUSED;
static double ${name}72 MTT_UNUSED;
static double ${name}73 MTT_UNUSED;
static double ${name}74 MTT_UNUSED;
static double ${name}75 MTT_UNUSED;
static double ${name}76 MTT_UNUSED;
static double ${name}77 MTT_UNUSED;
static double ${name}78 MTT_UNUSED;
static double ${name}79 MTT_UNUSED;
static double ${name}80 MTT_UNUSED;
static double ${name}81 MTT_UNUSED;
static double ${name}82 MTT_UNUSED;
static double ${name}83 MTT_UNUSED;
static double ${name}84 MTT_UNUSED;
static double ${name}85 MTT_UNUSED;
static double ${name}86 MTT_UNUSED;
static double ${name}87 MTT_UNUSED;
static double ${name}88 MTT_UNUSED;
static double ${name}89 MTT_UNUSED;
static double ${name}90 MTT_UNUSED;
static double ${name}91 MTT_UNUSED;
static double ${name}92 MTT_UNUSED;
static double ${name}93 MTT_UNUSED;
static double ${name}94 MTT_UNUSED;
static double ${name}95 MTT_UNUSED;
static double ${name}96 MTT_UNUSED;
static double ${name}97 MTT_UNUSED;
static double ${name}98 MTT_UNUSED;
static double ${name}99 MTT_UNUSED;
static double ${name}100 MTT_UNUSED;
static double ${name}101 MTT_UNUSED;
static double ${name}102 MTT_UNUSED;
static double ${name}103 MTT_UNUSED;
static double ${name}104 MTT_UNUSED;
static double ${name}105 MTT_UNUSED;
static double ${name}106 MTT_UNUSED;
static double ${name}107 MTT_UNUSED;
static double ${name}108 MTT_UNUSED;
static double ${name}109 MTT_UNUSED;
static double ${name}110 MTT_UNUSED;
static double ${name}111 MTT_UNUSED;
static double ${name}112 MTT_UNUSED;
static double ${name}113 MTT_UNUSED;
static double ${name}114 MTT_UNUSED;
static double ${name}115 MTT_UNUSED;
static double ${name}116 MTT_UNUSED;
static double ${name}117 MTT_UNUSED;
static double ${name}118 MTT_UNUSED;
static double ${name}119 MTT_UNUSED;
static double ${name}120 MTT_UNUSED;
static double ${name}121 MTT_UNUSED;
static double ${name}122 MTT_UNUSED;
static double ${name}123 MTT_UNUSED;
static double ${name}124 MTT_UNUSED;
static double ${name}125 MTT_UNUSED;
static double ${name}126 MTT_UNUSED;
static double ${name}127 MTT_UNUSED;
static double ${name}128 MTT_UNUSED;
static double ${name}129 MTT_UNUSED;
static double ${name}130 MTT_UNUSED;
static double ${name}131 MTT_UNUSED;
static double ${name}132 MTT_UNUSED;
static double ${name}133 MTT_UNUSED;
static double ${name}134 MTT_UNUSED;
static double ${name}135 MTT_UNUSED;
static double ${name}136 MTT_UNUSED;
static double ${name}137 MTT_UNUSED;
static double ${name}138 MTT_UNUSED;
static double ${name}139 MTT_UNUSED;
static double ${name}140 MTT_UNUSED;
static double ${name}141 MTT_UNUSED;
static double ${name}142 MTT_UNUSED;
static double ${name}143 MTT_UNUSED;
static double ${name}144 MTT_UNUSED;
static double ${name}145 MTT_UNUSED;
static double ${name}146 MTT_UNUSED;
static double ${name}147 MTT_UNUSED;
static double ${name}148 MTT_UNUSED;
static double ${name}149 MTT_UNUSED;
static double ${name}150 MTT_UNUSED;
static double ${name}151 MTT_UNUSED;
static double ${name}152 MTT_UNUSED;
static double ${name}153 MTT_UNUSED;
static double ${name}154 MTT_UNUSED;
static double ${name}155 MTT_UNUSED;
static double ${name}156 MTT_UNUSED;
static double ${name}157 MTT_UNUSED;
static double ${name}158 MTT_UNUSED;
static double ${name}159 MTT_UNUSED;
static double ${name}160 MTT_UNUSED;
static double ${name}161 MTT_UNUSED;
static double ${name}162 MTT_UNUSED;
static double ${name}163 MTT_UNUSED;
static double ${name}164 MTT_UNUSED;
static double ${name}165 MTT_UNUSED;
static double ${name}166 MTT_UNUSED;
static double ${name}167 MTT_UNUSED;
static double ${name}168 MTT_UNUSED;
static double ${name}169 MTT_UNUSED;
static double ${name}170 MTT_UNUSED;
static double ${name}171 MTT_UNUSED;
static double ${name}172 MTT_UNUSED;
static double ${name}173 MTT_UNUSED;
static double ${name}174 MTT_UNUSED;
static double ${name}175 MTT_UNUSED;
static double ${name}176 MTT_UNUSED;
static double ${name}177 MTT_UNUSED;
static double ${name}178 MTT_UNUSED;
static double ${name}179 MTT_UNUSED;
static double ${name}180 MTT_UNUSED;
static double ${name}181 MTT_UNUSED;
static double ${name}182 MTT_UNUSED;
static double ${name}183 MTT_UNUSED;
static double ${name}184 MTT_UNUSED;
static double ${name}185 MTT_UNUSED;
static double ${name}186 MTT_UNUSED;
static double ${name}187 MTT_UNUSED;
static double ${name}188 MTT_UNUSED;
static double ${name}189 MTT_UNUSED;
static double ${name}190 MTT_UNUSED;
static double ${name}191 MTT_UNUSED;
static double ${name}192 MTT_UNUSED;
static double ${name}193 MTT_UNUSED;
static double ${name}194 MTT_UNUSED;
static double ${name}195 MTT_UNUSED;
static double ${name}196 MTT_UNUSED;
static double ${name}197 MTT_UNUSED;
static double ${name}198 MTT_UNUSED;
static double ${name}199 MTT_UNUSED;
static double ${name}200 MTT_UNUSED;
static double ${name}201 MTT_UNUSED;
static double ${name}202 MTT_UNUSED;
static double ${name}203 MTT_UNUSED;
static double ${name}204 MTT_UNUSED;
static double ${name}205 MTT_UNUSED;
static double ${name}206 MTT_UNUSED;
static double ${name}207 MTT_UNUSED;
static double ${name}208 MTT_UNUSED;
static double ${name}209 MTT_UNUSED;
static double ${name}210 MTT_UNUSED;
static double ${name}211 MTT_UNUSED;
static double ${name}212 MTT_UNUSED;
static double ${name}213 MTT_UNUSED;
static double ${name}214 MTT_UNUSED;
static double ${name}215 MTT_UNUSED;
static double ${name}216 MTT_UNUSED;
static double ${name}217 MTT_UNUSED;
static double ${name}218 MTT_UNUSED;
static double ${name}219 MTT_UNUSED;
static double ${name}220 MTT_UNUSED;
static double ${name}221 MTT_UNUSED;
static double ${name}222 MTT_UNUSED;
static double ${name}223 MTT_UNUSED;
static double ${name}224 MTT_UNUSED;
static double ${name}225 MTT_UNUSED;
static double ${name}226 MTT_UNUSED;
static double ${name}227 MTT_UNUSED;
static double ${name}228 MTT_UNUSED;
static double ${name}229 MTT_UNUSED;
static double ${name}230 MTT_UNUSED;
static double ${name}231 MTT_UNUSED;
static double ${name}232 MTT_UNUSED;
static double ${name}233 MTT_UNUSED;
static double ${name}234 MTT_UNUSED;
static double ${name}235 MTT_UNUSED;
static double ${name}236 MTT_UNUSED;
static double ${name}237 MTT_UNUSED;
static double ${name}238 MTT_UNUSED;
static double ${name}239 MTT_UNUSED;
static double ${name}240 MTT_UNUSED;
static double ${name}241 MTT_UNUSED;
static double ${name}242 MTT_UNUSED;
static double ${name}243 MTT_UNUSED;
static double ${name}244 MTT_UNUSED;
static double ${name}245 MTT_UNUSED;
static double ${name}246 MTT_UNUSED;
static double ${name}247 MTT_UNUSED;
static double ${name}248 MTT_UNUSED;
static double ${name}249 MTT_UNUSED;
static double ${name}250 MTT_UNUSED;
static double ${name}251 MTT_UNUSED;
static double ${name}252 MTT_UNUSED;
static double ${name}253 MTT_UNUSED;
static double ${name}254 MTT_UNUSED;
static double ${name}255 MTT_UNUSED;
static double ${name}256 MTT_UNUSED;
static double ${name}257 MTT_UNUSED;
static double ${name}258 MTT_UNUSED;
static double ${name}259 MTT_UNUSED;
static double ${name}260 MTT_UNUSED;
static double ${name}261 MTT_UNUSED;
static double ${name}262 MTT_UNUSED;
static double ${name}263 MTT_UNUSED;
static double ${name}264 MTT_UNUSED;
static double ${name}265 MTT_UNUSED;
static double ${name}266 MTT_UNUSED;
static double ${name}267 MTT_UNUSED;
static double ${name}268 MTT_UNUSED;
static double ${name}269 MTT_UNUSED;
static double ${name}270 MTT_UNUSED;
static double ${name}271 MTT_UNUSED;
static double ${name}272 MTT_UNUSED;
static double ${name}273 MTT_UNUSED;
static double ${name}274 MTT_UNUSED;
static double ${name}275 MTT_UNUSED;
static double ${name}276 MTT_UNUSED;
static double ${name}277 MTT_UNUSED;
static double ${name}278 MTT_UNUSED;
static double ${name}279 MTT_UNUSED;
static double ${name}280 MTT_UNUSED;
static double ${name}281 MTT_UNUSED;
static double ${name}282 MTT_UNUSED;
static double ${name}283 MTT_UNUSED;
static double ${name}284 MTT_UNUSED;
static double ${name}285 MTT_UNUSED;
static double ${name}286 MTT_UNUSED;
static double ${name}287 MTT_UNUSED;
static double ${name}288 MTT_UNUSED;
static double ${name}289 MTT_UNUSED;
static double ${name}290 MTT_UNUSED;
static double ${name}291 MTT_UNUSED;
static double ${name}292 MTT_UNUSED;
static double ${name}293 MTT_UNUSED;
static double ${name}294 MTT_UNUSED;
static double ${name}295 MTT_UNUSED;
static double ${name}296 MTT_UNUSED;
static double ${name}297 MTT_UNUSED;
static double ${name}298 MTT_UNUSED;
static double ${name}299 MTT_UNUSED;
static double ${name}300 MTT_UNUSED;
static double ${name}301 MTT_UNUSED;
static double ${name}302 MTT_UNUSED;
static double ${name}303 MTT_UNUSED;
static double ${name}304 MTT_UNUSED;
static double ${name}305 MTT_UNUSED;
static double ${name}306 MTT_UNUSED;
static double ${name}307 MTT_UNUSED;
static double ${name}308 MTT_UNUSED;
static double ${name}309 MTT_UNUSED;
static double ${name}310 MTT_UNUSED;
static double ${name}311 MTT_UNUSED;
static double ${name}312 MTT_UNUSED;
static double ${name}313 MTT_UNUSED;
static double ${name}314 MTT_UNUSED;
static double ${name}315 MTT_UNUSED;
static double ${name}316 MTT_UNUSED;
static double ${name}317 MTT_UNUSED;
static double ${name}318 MTT_UNUSED;
static double ${name}319 MTT_UNUSED;
static double ${name}320 MTT_UNUSED;
static double ${name}321 MTT_UNUSED;
static double ${name}322 MTT_UNUSED;
static double ${name}323 MTT_UNUSED;
static double ${name}324 MTT_UNUSED;
static double ${name}325 MTT_UNUSED;
static double ${name}326 MTT_UNUSED;
static double ${name}327 MTT_UNUSED;
static double ${name}328 MTT_UNUSED;
static double ${name}329 MTT_UNUSED;
static double ${name}330 MTT_UNUSED;
static double ${name}331 MTT_UNUSED;
static double ${name}332 MTT_UNUSED;
static double ${name}333 MTT_UNUSED;
static double ${name}334 MTT_UNUSED;
static double ${name}335 MTT_UNUSED;
static double ${name}336 MTT_UNUSED;
static double ${name}337 MTT_UNUSED;
static double ${name}338 MTT_UNUSED;
static double ${name}339 MTT_UNUSED;
static double ${name}340 MTT_UNUSED;
static double ${name}341 MTT_UNUSED;
static double ${name}342 MTT_UNUSED;
static double ${name}343 MTT_UNUSED;
static double ${name}344 MTT_UNUSED;
static double ${name}345 MTT_UNUSED;
static double ${name}346 MTT_UNUSED;
static double ${name}347 MTT_UNUSED;
static double ${name}348 MTT_UNUSED;
static double ${name}349 MTT_UNUSED;
static double ${name}350 MTT_UNUSED;
static double ${name}351 MTT_UNUSED;
static double ${name}352 MTT_UNUSED;
static double ${name}353 MTT_UNUSED;
static double ${name}354 MTT_UNUSED;
static double ${name}355 MTT_UNUSED;
static double ${name}356 MTT_UNUSED;
static double ${name}357 MTT_UNUSED;
static double ${name}358 MTT_UNUSED;
static double ${name}359 MTT_UNUSED;
static double ${name}360 MTT_UNUSED;
static double ${name}361 MTT_UNUSED;
static double ${name}362 MTT_UNUSED;
static double ${name}363 MTT_UNUSED;
static double ${name}364 MTT_UNUSED;
static double ${name}365 MTT_UNUSED;
static double ${name}366 MTT_UNUSED;
static double ${name}367 MTT_UNUSED;
static double ${name}368 MTT_UNUSED;
static double ${name}369 MTT_UNUSED;
static double ${name}370 MTT_UNUSED;
static double ${name}371 MTT_UNUSED;
static double ${name}372 MTT_UNUSED;
static double ${name}373 MTT_UNUSED;
static double ${name}374 MTT_UNUSED;
static double ${name}375 MTT_UNUSED;
static double ${name}376 MTT_UNUSED;
static double ${name}377 MTT_UNUSED;
static double ${name}378 MTT_UNUSED;
static double ${name}379 MTT_UNUSED;
static double ${name}380 MTT_UNUSED;
static double ${name}381 MTT_UNUSED;
static double ${name}382 MTT_UNUSED;
static double ${name}383 MTT_UNUSED;
static double ${name}384 MTT_UNUSED;
static double ${name}385 MTT_UNUSED;
static double ${name}386 MTT_UNUSED;
static double ${name}387 MTT_UNUSED;
static double ${name}388 MTT_UNUSED;
static double ${name}389 MTT_UNUSED;
static double ${name}390 MTT_UNUSED;
static double ${name}391 MTT_UNUSED;
static double ${name}392 MTT_UNUSED;
static double ${name}393 MTT_UNUSED;
static double ${name}394 MTT_UNUSED;
static double ${name}395 MTT_UNUSED;
static double ${name}396 MTT_UNUSED;
static double ${name}397 MTT_UNUSED;
static double ${name}398 MTT_UNUSED;
static double ${name}399 MTT_UNUSED;
static double ${name}400 MTT_UNUSED;
static double ${name}401 MTT_UNUSED;
static double ${name}402 MTT_UNUSED;
static double ${name}403 MTT_UNUSED;
static double ${name}404 MTT_UNUSED;
static double ${name}405 MTT_UNUSED;
static double ${name}406 MTT_UNUSED;
static double ${name}407 MTT_UNUSED;
static double ${name}408 MTT_UNUSED;
static double ${name}409 MTT_UNUSED;
static double ${name}410 MTT_UNUSED;
static double ${name}411 MTT_UNUSED;
static double ${name}412 MTT_UNUSED;
static double ${name}413 MTT_UNUSED;
static double ${name}414 MTT_UNUSED;
static double ${name}415 MTT_UNUSED;
static double ${name}416 MTT_UNUSED;
static double ${name}417 MTT_UNUSED;
static double ${name}418 MTT_UNUSED;
static double ${name}419 MTT_UNUSED;
static double ${name}420 MTT_UNUSED;
static double ${name}421 MTT_UNUSED;
static double ${name}422 MTT_UNUSED;
static double ${name}423 MTT_UNUSED;
static double ${name}424 MTT_UNUSED;
static double ${name}425 MTT_UNUSED;
static double ${name}426 MTT_UNUSED;
static double ${name}427 MTT_UNUSED;
static double ${name}428 MTT_UNUSED;
static double ${name}429 MTT_UNUSED;
static double ${name}430 MTT_UNUSED;
static double ${name}431 MTT_UNUSED;
static double ${name}432 MTT_UNUSED;
static double ${name}433 MTT_UNUSED;
static double ${name}434 MTT_UNUSED;
static double ${name}435 MTT_UNUSED;
static double ${name}436 MTT_UNUSED;
static double ${name}437 MTT_UNUSED;
static double ${name}438 MTT_UNUSED;
static double ${name}439 MTT_UNUSED;
static double ${name}440 MTT_UNUSED;
static double ${name}441 MTT_UNUSED;
static double ${name}442 MTT_UNUSED;
static double ${name}443 MTT_UNUSED;
static double ${name}444 MTT_UNUSED;
static double ${name}445 MTT_UNUSED;
static double ${name}446 MTT_UNUSED;
static double ${name}447 MTT_UNUSED;
static double ${name}448 MTT_UNUSED;
static double ${name}449 MTT_UNUSED;
static double ${name}450 MTT_UNUSED;
static double ${name}451 MTT_UNUSED;
static double ${name}452 MTT_UNUSED;
static double ${name}453 MTT_UNUSED;
static double ${name}454 MTT_UNUSED;
static double ${name}455 MTT_UNUSED;
static double ${name}456 MTT_UNUSED;
static double ${name}457 MTT_UNUSED;
static double ${name}458 MTT_UNUSED;
static double ${name}459 MTT_UNUSED;
static double ${name}460 MTT_UNUSED;
static double ${name}461 MTT_UNUSED;
static double ${name}462 MTT_UNUSED;
static double ${name}463 MTT_UNUSED;
static double ${name}464 MTT_UNUSED;
static double ${name}465 MTT_UNUSED;
static double ${name}466 MTT_UNUSED;
static double ${name}467 MTT_UNUSED;
static double ${name}468 MTT_UNUSED;
static double ${name}469 MTT_UNUSED;
static double ${name}470 MTT_UNUSED;
static double ${name}471 MTT_UNUSED;
static double ${name}472 MTT_UNUSED;
static double ${name}473 MTT_UNUSED;
static double ${name}474 MTT_UNUSED;
static double ${name}475 MTT_UNUSED;
static double ${name}476 MTT_UNUSED;
static double ${name}477 MTT_UNUSED;
static double ${name}478 MTT_UNUSED;
static double ${name}479 MTT_UNUSED;
static double ${name}480 MTT_UNUSED;
static double ${name}481 MTT_UNUSED;
static double ${name}482 MTT_UNUSED;
static double ${name}483 MTT_UNUSED;
static double ${name}484 MTT_UNUSED;
static double ${name}485 MTT_UNUSED;
static double ${name}486 MTT_UNUSED;
static double ${name}487 MTT_UNUSED;
static double ${name}488 MTT_UNUSED;
static double ${name}489 MTT_UNUSED;
static double ${name}490 MTT_UNUSED;
static double ${name}491 MTT_UNUSED;
static double ${name}492 MTT_UNUSED;
static double ${name}493 MTT_UNUSED;
static double ${name}494 MTT_UNUSED;
static double ${name}495 MTT_UNUSED;
static double ${name}496 MTT_UNUSED;
static double ${name}497 MTT_UNUSED;
static double ${name}498 MTT_UNUSED;
static double ${name}499 MTT_UNUSED;
static double ${name}500 MTT_UNUSED;
static double ${name}501 MTT_UNUSED;
static double ${name}502 MTT_UNUSED;
static double ${name}503 MTT_UNUSED;
static double ${name}504 MTT_UNUSED;
static double ${name}505 MTT_UNUSED;
static double ${name}506 MTT_UNUSED;
static double ${name}507 MTT_UNUSED;
static double ${name}508 MTT_UNUSED;
static double ${name}509 MTT_UNUSED;
static double ${name}510 MTT_UNUSED;
static double ${name}511 MTT_UNUSED;
static double ${name}512 MTT_UNUSED;
static double ${name}513 MTT_UNUSED;
static double ${name}514 MTT_UNUSED;
static double ${name}515 MTT_UNUSED;
static double ${name}516 MTT_UNUSED;
static double ${name}517 MTT_UNUSED;
static double ${name}518 MTT_UNUSED;
static double ${name}519 MTT_UNUSED;
static double ${name}520 MTT_UNUSED;
static double ${name}521 MTT_UNUSED;
static double ${name}522 MTT_UNUSED;
static double ${name}523 MTT_UNUSED;
static double ${name}524 MTT_UNUSED;
static double ${name}525 MTT_UNUSED;
static double ${name}526 MTT_UNUSED;
static double ${name}527 MTT_UNUSED;
static double ${name}528 MTT_UNUSED;
static double ${name}529 MTT_UNUSED;
static double ${name}530 MTT_UNUSED;
static double ${name}531 MTT_UNUSED;
static double ${name}532 MTT_UNUSED;
static double ${name}533 MTT_UNUSED;
static double ${name}534 MTT_UNUSED;
static double ${name}535 MTT_UNUSED;
static double ${name}536 MTT_UNUSED;
static double ${name}537 MTT_UNUSED;
static double ${name}538 MTT_UNUSED;
static double ${name}539 MTT_UNUSED;
static double ${name}540 MTT_UNUSED;
static double ${name}541 MTT_UNUSED;
static double ${name}542 MTT_UNUSED;
static double ${name}543 MTT_UNUSED;
static double ${name}544 MTT_UNUSED;
static double ${name}545 MTT_UNUSED;
static double ${name}546 MTT_UNUSED;
static double ${name}547 MTT_UNUSED;
static double ${name}548 MTT_UNUSED;
static double ${name}549 MTT_UNUSED;
static double ${name}550 MTT_UNUSED;
static double ${name}551 MTT_UNUSED;
static double ${name}552 MTT_UNUSED;
static double ${name}553 MTT_UNUSED;
static double ${name}554 MTT_UNUSED;
static double ${name}555 MTT_UNUSED;
static double ${name}556 MTT_UNUSED;
static double ${name}557 MTT_UNUSED;
static double ${name}558 MTT_UNUSED;
static double ${name}559 MTT_UNUSED;
static double ${name}560 MTT_UNUSED;
static double ${name}561 MTT_UNUSED;
static double ${name}562 MTT_UNUSED;
static double ${name}563 MTT_UNUSED;
static double ${name}564 MTT_UNUSED;
static double ${name}565 MTT_UNUSED;
static double ${name}566 MTT_UNUSED;
static double ${name}567 MTT_UNUSED;
static double ${name}568 MTT_UNUSED;
static double ${name}569 MTT_UNUSED;
static double ${name}570 MTT_UNUSED;
static double ${name}571 MTT_UNUSED;
static double ${name}572 MTT_UNUSED;
static double ${name}573 MTT_UNUSED;
static double ${name}574 MTT_UNUSED;
static double ${name}575 MTT_UNUSED;
static double ${name}576 MTT_UNUSED;
static double ${name}577 MTT_UNUSED;
static double ${name}578 MTT_UNUSED;
static double ${name}579 MTT_UNUSED;
static double ${name}580 MTT_UNUSED;
static double ${name}581 MTT_UNUSED;
static double ${name}582 MTT_UNUSED;
static double ${name}583 MTT_UNUSED;
static double ${name}584 MTT_UNUSED;
static double ${name}585 MTT_UNUSED;
static double ${name}586 MTT_UNUSED;
static double ${name}587 MTT_UNUSED;
static double ${name}588 MTT_UNUSED;
static double ${name}589 MTT_UNUSED;
static double ${name}590 MTT_UNUSED;
static double ${name}591 MTT_UNUSED;
static double ${name}592 MTT_UNUSED;
static double ${name}593 MTT_UNUSED;
static double ${name}594 MTT_UNUSED;
static double ${name}595 MTT_UNUSED;
static double ${name}596 MTT_UNUSED;
static double ${name}597 MTT_UNUSED;
static double ${name}598 MTT_UNUSED;
static double ${name}599 MTT_UNUSED;
static double ${name}600 MTT_UNUSED;
static double ${name}601 MTT_UNUSED;
static double ${name}602 MTT_UNUSED;
static double ${name}603 MTT_UNUSED;
static double ${name}604 MTT_UNUSED;
static double ${name}605 MTT_UNUSED;
static double ${name}606 MTT_UNUSED;
static double ${name}607 MTT_UNUSED;
static double ${name}608 MTT_UNUSED;
static double ${name}609 MTT_UNUSED;
static double ${name}610 MTT_UNUSED;
static double ${name}611 MTT_UNUSED;
static double ${name}612 MTT_UNUSED;
static double ${name}613 MTT_UNUSED;
static double ${name}614 MTT_UNUSED;
static double ${name}615 MTT_UNUSED;
static double ${name}616 MTT_UNUSED;
static double ${name}617 MTT_UNUSED;
static double ${name}618 MTT_UNUSED;
static double ${name}619 MTT_UNUSED;
static double ${name}620 MTT_UNUSED;
static double ${name}621 MTT_UNUSED;
static double ${name}622 MTT_UNUSED;
static double ${name}623 MTT_UNUSED;
static double ${name}624 MTT_UNUSED;
static double ${name}625 MTT_UNUSED;
static double ${name}626 MTT_UNUSED;
static double ${name}627 MTT_UNUSED;
static double ${name}628 MTT_UNUSED;
static double ${name}629 MTT_UNUSED;
static double ${name}630 MTT_UNUSED;
static double ${name}631 MTT_UNUSED;
static double ${name}632 MTT_UNUSED;
static double ${name}633 MTT_UNUSED;
static double ${name}634 MTT_UNUSED;
static double ${name}635 MTT_UNUSED;
static double ${name}636 MTT_UNUSED;
static double ${name}637 MTT_UNUSED;
static double ${name}638 MTT_UNUSED;
static double ${name}639 MTT_UNUSED;
static double ${name}640 MTT_UNUSED;
static double ${name}641 MTT_UNUSED;
static double ${name}642 MTT_UNUSED;
static double ${name}643 MTT_UNUSED;
static double ${name}644 MTT_UNUSED;
static double ${name}645 MTT_UNUSED;
static double ${name}646 MTT_UNUSED;
static double ${name}647 MTT_UNUSED;
static double ${name}648 MTT_UNUSED;
static double ${name}649 MTT_UNUSED;
static double ${name}650 MTT_UNUSED;
static double ${name}651 MTT_UNUSED;
static double ${name}652 MTT_UNUSED;
static double ${name}653 MTT_UNUSED;
static double ${name}654 MTT_UNUSED;
static double ${name}655 MTT_UNUSED;
static double ${name}656 MTT_UNUSED;
static double ${name}657 MTT_UNUSED;
static double ${name}658 MTT_UNUSED;
static double ${name}659 MTT_UNUSED;
static double ${name}660 MTT_UNUSED;
static double ${name}661 MTT_UNUSED;
static double ${name}662 MTT_UNUSED;
static double ${name}663 MTT_UNUSED;
static double ${name}664 MTT_UNUSED;
static double ${name}665 MTT_UNUSED;
static double ${name}666 MTT_UNUSED;
static double ${name}667 MTT_UNUSED;
static double ${name}668 MTT_UNUSED;
static double ${name}669 MTT_UNUSED;
static double ${name}670 MTT_UNUSED;
static double ${name}671 MTT_UNUSED;
static double ${name}672 MTT_UNUSED;
static double ${name}673 MTT_UNUSED;
static double ${name}674 MTT_UNUSED;
static double ${name}675 MTT_UNUSED;
static double ${name}676 MTT_UNUSED;
static double ${name}677 MTT_UNUSED;
static double ${name}678 MTT_UNUSED;
static double ${name}679 MTT_UNUSED;
static double ${name}680 MTT_UNUSED;
static double ${name}681 MTT_UNUSED;
static double ${name}682 MTT_UNUSED;
static double ${name}683 MTT_UNUSED;
static double ${name}684 MTT_UNUSED;
static double ${name}685 MTT_UNUSED;
static double ${name}686 MTT_UNUSED;
static double ${name}687 MTT_UNUSED;
static double ${name}688 MTT_UNUSED;
static double ${name}689 MTT_UNUSED;
static double ${name}690 MTT_UNUSED;
static double ${name}691 MTT_UNUSED;
static double ${name}692 MTT_UNUSED;
static double ${name}693 MTT_UNUSED;
static double ${name}694 MTT_UNUSED;
static double ${name}695 MTT_UNUSED;
static double ${name}696 MTT_UNUSED;
static double ${name}697 MTT_UNUSED;
static double ${name}698 MTT_UNUSED;
static double ${name}699 MTT_UNUSED;
static double ${name}700 MTT_UNUSED;
static double ${name}701 MTT_UNUSED;
static double ${name}702 MTT_UNUSED;
static double ${name}703 MTT_UNUSED;
static double ${name}704 MTT_UNUSED;
static double ${name}705 MTT_UNUSED;
static double ${name}706 MTT_UNUSED;
static double ${name}707 MTT_UNUSED;
static double ${name}708 MTT_UNUSED;
static double ${name}709 MTT_UNUSED;
static double ${name}710 MTT_UNUSED;
static double ${name}711 MTT_UNUSED;
static double ${name}712 MTT_UNUSED;
static double ${name}713 MTT_UNUSED;
static double ${name}714 MTT_UNUSED;
static double ${name}715 MTT_UNUSED;
static double ${name}716 MTT_UNUSED;
static double ${name}717 MTT_UNUSED;
static double ${name}718 MTT_UNUSED;
static double ${name}719 MTT_UNUSED;
static double ${name}720 MTT_UNUSED;
static double ${name}721 MTT_UNUSED;
static double ${name}722 MTT_UNUSED;
static double ${name}723 MTT_UNUSED;
static double ${name}724 MTT_UNUSED;
static double ${name}725 MTT_UNUSED;
static double ${name}726 MTT_UNUSED;
static double ${name}727 MTT_UNUSED;
static double ${name}728 MTT_UNUSED;
static double ${name}729 MTT_UNUSED;
static double ${name}730 MTT_UNUSED;
static double ${name}731 MTT_UNUSED;
static double ${name}732 MTT_UNUSED;
static double ${name}733 MTT_UNUSED;
static double ${name}734 MTT_UNUSED;
static double ${name}735 MTT_UNUSED;
static double ${name}736 MTT_UNUSED;
static double ${name}737 MTT_UNUSED;
static double ${name}738 MTT_UNUSED;
static double ${name}739 MTT_UNUSED;
static double ${name}740 MTT_UNUSED;
static double ${name}741 MTT_UNUSED;
static double ${name}742 MTT_UNUSED;
static double ${name}743 MTT_UNUSED;
static double ${name}744 MTT_UNUSED;
static double ${name}745 MTT_UNUSED;
static double ${name}746 MTT_UNUSED;
static double ${name}747 MTT_UNUSED;
static double ${name}748 MTT_UNUSED;
static double ${name}749 MTT_UNUSED;
static double ${name}750 MTT_UNUSED;
static double ${name}751 MTT_UNUSED;
static double ${name}752 MTT_UNUSED;
static double ${name}753 MTT_UNUSED;
static double ${name}754 MTT_UNUSED;
static double ${name}755 MTT_UNUSED;
static double ${name}756 MTT_UNUSED;
static double ${name}757 MTT_UNUSED;
static double ${name}758 MTT_UNUSED;
static double ${name}759 MTT_UNUSED;
static double ${name}760 MTT_UNUSED;
static double ${name}761 MTT_UNUSED;
static double ${name}762 MTT_UNUSED;
static double ${name}763 MTT_UNUSED;
static double ${name}764 MTT_UNUSED;
static double ${name}765 MTT_UNUSED;
static double ${name}766 MTT_UNUSED;
static double ${name}767 MTT_UNUSED;
static double ${name}768 MTT_UNUSED;
static double ${name}769 MTT_UNUSED;
static double ${name}770 MTT_UNUSED;
static double ${name}771 MTT_UNUSED;
static double ${name}772 MTT_UNUSED;
static double ${name}773 MTT_UNUSED;
static double ${name}774 MTT_UNUSED;
static double ${name}775 MTT_UNUSED;
static double ${name}776 MTT_UNUSED;
static double ${name}777 MTT_UNUSED;
static double ${name}778 MTT_UNUSED;
static double ${name}779 MTT_UNUSED;
static double ${name}780 MTT_UNUSED;
static double ${name}781 MTT_UNUSED;
static double ${name}782 MTT_UNUSED;
static double ${name}783 MTT_UNUSED;
static double ${name}784 MTT_UNUSED;
static double ${name}785 MTT_UNUSED;
static double ${name}786 MTT_UNUSED;
static double ${name}787 MTT_UNUSED;
static double ${name}788 MTT_UNUSED;
static double ${name}789 MTT_UNUSED;
static double ${name}790 MTT_UNUSED;
static double ${name}791 MTT_UNUSED;
static double ${name}792 MTT_UNUSED;
static double ${name}793 MTT_UNUSED;
static double ${name}794 MTT_UNUSED;
static double ${name}795 MTT_UNUSED;
static double ${name}796 MTT_UNUSED;
static double ${name}797 MTT_UNUSED;
static double ${name}798 MTT_UNUSED;
static double ${name}799 MTT_UNUSED;
static double ${name}800 MTT_UNUSED;
static double ${name}801 MTT_UNUSED;
static double ${name}802 MTT_UNUSED;
static double ${name}803 MTT_UNUSED;
static double ${name}804 MTT_UNUSED;
static double ${name}805 MTT_UNUSED;
static double ${name}806 MTT_UNUSED;
static double ${name}807 MTT_UNUSED;
static double ${name}808 MTT_UNUSED;
static double ${name}809 MTT_UNUSED;
static double ${name}810 MTT_UNUSED;
static double ${name}811 MTT_UNUSED;
static double ${name}812 MTT_UNUSED;
static double ${name}813 MTT_UNUSED;
static double ${name}814 MTT_UNUSED;
static double ${name}815 MTT_UNUSED;
static double ${name}816 MTT_UNUSED;
static double ${name}817 MTT_UNUSED;
static double ${name}818 MTT_UNUSED;
static double ${name}819 MTT_UNUSED;
static double ${name}820 MTT_UNUSED;
static double ${name}821 MTT_UNUSED;
static double ${name}822 MTT_UNUSED;
static double ${name}823 MTT_UNUSED;
static double ${name}824 MTT_UNUSED;
static double ${name}825 MTT_UNUSED;
static double ${name}826 MTT_UNUSED;
static double ${name}827 MTT_UNUSED;
static double ${name}828 MTT_UNUSED;
static double ${name}829 MTT_UNUSED;
static double ${name}830 MTT_UNUSED;
static double ${name}831 MTT_UNUSED;
static double ${name}832 MTT_UNUSED;
static double ${name}833 MTT_UNUSED;
static double ${name}834 MTT_UNUSED;
static double ${name}835 MTT_UNUSED;
static double ${name}836 MTT_UNUSED;
static double ${name}837 MTT_UNUSED;
static double ${name}838 MTT_UNUSED;
static double ${name}839 MTT_UNUSED;
static double ${name}840 MTT_UNUSED;
static double ${name}841 MTT_UNUSED;
static double ${name}842 MTT_UNUSED;
static double ${name}843 MTT_UNUSED;
static double ${name}844 MTT_UNUSED;
static double ${name}845 MTT_UNUSED;
static double ${name}846 MTT_UNUSED;
static double ${name}847 MTT_UNUSED;
static double ${name}848 MTT_UNUSED;
static double ${name}849 MTT_UNUSED;
static double ${name}850 MTT_UNUSED;
static double ${name}851 MTT_UNUSED;
static double ${name}852 MTT_UNUSED;
static double ${name}853 MTT_UNUSED;
static double ${name}854 MTT_UNUSED;
static double ${name}855 MTT_UNUSED;
static double ${name}856 MTT_UNUSED;
static double ${name}857 MTT_UNUSED;
static double ${name}858 MTT_UNUSED;
static double ${name}859 MTT_UNUSED;
static double ${name}860 MTT_UNUSED;
static double ${name}861 MTT_UNUSED;
static double ${name}862 MTT_UNUSED;
static double ${name}863 MTT_UNUSED;
static double ${name}864 MTT_UNUSED;
static double ${name}865 MTT_UNUSED;
static double ${name}866 MTT_UNUSED;
static double ${name}867 MTT_UNUSED;
static double ${name}868 MTT_UNUSED;
static double ${name}869 MTT_UNUSED;
static double ${name}870 MTT_UNUSED;
static double ${name}871 MTT_UNUSED;
static double ${name}872 MTT_UNUSED;
static double ${name}873 MTT_UNUSED;
static double ${name}874 MTT_UNUSED;
static double ${name}875 MTT_UNUSED;
static double ${name}876 MTT_UNUSED;
static double ${name}877 MTT_UNUSED;
static double ${name}878 MTT_UNUSED;
static double ${name}879 MTT_UNUSED;
static double ${name}880 MTT_UNUSED;
static double ${name}881 MTT_UNUSED;
static double ${name}882 MTT_UNUSED;
static double ${name}883 MTT_UNUSED;
static double ${name}884 MTT_UNUSED;
static double ${name}885 MTT_UNUSED;
static double ${name}886 MTT_UNUSED;
static double ${name}887 MTT_UNUSED;
static double ${name}888 MTT_UNUSED;
static double ${name}889 MTT_UNUSED;
static double ${name}890 MTT_UNUSED;
static double ${name}891 MTT_UNUSED;
static double ${name}892 MTT_UNUSED;
static double ${name}893 MTT_UNUSED;
static double ${name}894 MTT_UNUSED;
static double ${name}895 MTT_UNUSED;
static double ${name}896 MTT_UNUSED;
static double ${name}897 MTT_UNUSED;
static double ${name}898 MTT_UNUSED;
static double ${name}899 MTT_UNUSED;
static double ${name}900 MTT_UNUSED;
static double ${name}901 MTT_UNUSED;
static double ${name}902 MTT_UNUSED;
static double ${name}903 MTT_UNUSED;
static double ${name}904 MTT_UNUSED;
static double ${name}905 MTT_UNUSED;
static double ${name}906 MTT_UNUSED;
static double ${name}907 MTT_UNUSED;
static double ${name}908 MTT_UNUSED;
static double ${name}909 MTT_UNUSED;
static double ${name}910 MTT_UNUSED;
static double ${name}911 MTT_UNUSED;
static double ${name}912 MTT_UNUSED;
static double ${name}913 MTT_UNUSED;
static double ${name}914 MTT_UNUSED;
static double ${name}915 MTT_UNUSED;
static double ${name}916 MTT_UNUSED;
static double ${name}917 MTT_UNUSED;
static double ${name}918 MTT_UNUSED;
static double ${name}919 MTT_UNUSED;
static double ${name}920 MTT_UNUSED;
static double ${name}921 MTT_UNUSED;
static double ${name}922 MTT_UNUSED;
static double ${name}923 MTT_UNUSED;
static double ${name}924 MTT_UNUSED;
static double ${name}925 MTT_UNUSED;
static double ${name}926 MTT_UNUSED;
static double ${name}927 MTT_UNUSED;
static double ${name}928 MTT_UNUSED;
static double ${name}929 MTT_UNUSED;
static double ${name}930 MTT_UNUSED;
static double ${name}931 MTT_UNUSED;
static double ${name}932 MTT_UNUSED;
static double ${name}933 MTT_UNUSED;
static double ${name}934 MTT_UNUSED;
static double ${name}935 MTT_UNUSED;
static double ${name}936 MTT_UNUSED;
static double ${name}937 MTT_UNUSED;
static double ${name}938 MTT_UNUSED;
static double ${name}939 MTT_UNUSED;
static double ${name}940 MTT_UNUSED;
static double ${name}941 MTT_UNUSED;
static double ${name}942 MTT_UNUSED;
static double ${name}943 MTT_UNUSED;
static double ${name}944 MTT_UNUSED;
static double ${name}945 MTT_UNUSED;
static double ${name}946 MTT_UNUSED;
static double ${name}947 MTT_UNUSED;
static double ${name}948 MTT_UNUSED;
static double ${name}949 MTT_UNUSED;
static double ${name}950 MTT_UNUSED;
static double ${name}951 MTT_UNUSED;
static double ${name}952 MTT_UNUSED;
static double ${name}953 MTT_UNUSED;
static double ${name}954 MTT_UNUSED;
static double ${name}955 MTT_UNUSED;
static double ${name}956 MTT_UNUSED;
static double ${name}957 MTT_UNUSED;
static double ${name}958 MTT_UNUSED;
static double ${name}959 MTT_UNUSED;
static double ${name}960 MTT_UNUSED;
static double ${name}961 MTT_UNUSED;
static double ${name}962 MTT_UNUSED;
static double ${name}963 MTT_UNUSED;
static double ${name}964 MTT_UNUSED;
static double ${name}965 MTT_UNUSED;
static double ${name}966 MTT_UNUSED;
static double ${name}967 MTT_UNUSED;
static double ${name}968 MTT_UNUSED;
static double ${name}969 MTT_UNUSED;
static double ${name}970 MTT_UNUSED;
static double ${name}971 MTT_UNUSED;
static double ${name}972 MTT_UNUSED;
static double ${name}973 MTT_UNUSED;
static double ${name}974 MTT_UNUSED;
static double ${name}975 MTT_UNUSED;
static double ${name}976 MTT_UNUSED;
static double ${name}977 MTT_UNUSED;
static double ${name}978 MTT_UNUSED;
static double ${name}979 MTT_UNUSED;
static double ${name}980 MTT_UNUSED;
static double ${name}981 MTT_UNUSED;
static double ${name}982 MTT_UNUSED;
static double ${name}983 MTT_UNUSED;
static double ${name}984 MTT_UNUSED;
static double ${name}985 MTT_UNUSED;
static double ${name}986 MTT_UNUSED;
static double ${name}987 MTT_UNUSED;
static double ${name}988 MTT_UNUSED;
static double ${name}989 MTT_UNUSED;
static double ${name}990 MTT_UNUSED;
static double ${name}991 MTT_UNUSED;
static double ${name}992 MTT_UNUSED;
static double ${name}993 MTT_UNUSED;
static double ${name}994 MTT_UNUSED;
static double ${name}995 MTT_UNUSED;
static double ${name}996 MTT_UNUSED;
static double ${name}997 MTT_UNUSED;
static double ${name}998 MTT_UNUSED;
static double ${name}999 MTT_UNUSED;
static double ${name}1000 MTT_UNUSED;
EOF

    if [ ${NUM_OF_TMP_VAR} -gt 1000 ]; then
	i=1001
	while [ ${i} -le ${NUM_OF_TMP_VAR} ]
	do
	  echo "static double ${name}${i} MTT_UNUSED;"
	  i=`expr ${i} + 1`
	done
    fi
done
}

echo Creating ${OUT}
cat <<EOF > ${OUT}
#ifndef MTT_UNUSED
#ifdef __GNUC__
#define MTT_UNUSED __attribute__ ((__unused__))
#else
#define MTT_UNUSED
#endif
#endif

EOF

declare_sys_param	>> ${OUT}
if [ ${NUM_OF_TMP_VAR} -gt 0 ]; then
    declare_temp_vars	>> ${OUT}
fi


Added mtt/debian/README.Debian version [6a919df6b7].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
mtt for Debian
--------------

Model Transformation Tools is hosted on Sourceforge
http://sourceforge.net/projects/mtt

 -- Geraint <geraint@users.sf.net>, Sun, 28 Apr 2002 00:11:29 +0000

Added mtt/debian/changelog version [ece406bdfc].







1
2
3
4
5
6
+
+
+
+
+
+
mtt (4.9+2002.04.27-1) unstable; urgency=low

  * Initial Release.

 -- Geraint <geraint@users.sf.net>  Sun, 28 Apr 2002 00:11:29 +0000

Added mtt/debian/compat version [607ad8c0db].


1
+
7

Added mtt/debian/conffiles version [a332b076b5].


1
+
/etc/mtt.conf

Added mtt/debian/conffiles.ex version [b3b38e0609].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
#
# If you want to use this conffile, remove all comments and put files that
# you want dpkg to process here using their absolute pathnames.
# See the policy manual
#
# for example:
# /etc/mtt/mtt.conf

Added mtt/debian/control version [cf54707222].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Source: mtt
Section: contrib/math
Priority: optional
Maintainer: Geraint <geraint@users.sourceforge.net>
Build-Depends: debhelper (>> 3.0.0)
Standards-Version: 3.5.2

Package: mtt
Architecture: all
Depends: gawk, octave, units, xfig, perl
Recommends: mtt-examples, blas-dev, fftw-dev, c-compiler, dia, g++, gnuplot, info-browser, lapack-dev, latex2html, libkpathsea-dev, libncurses5-dev, libreadline4-dev, libxml-dom-perl, pdf-viewer, postscript-viewer, octave-pkg-dev, octave-info, texlive, texlive-latex-extra, transfig, xterm, www-browser, wish
Suggests: scigraphica, zip
Description: Model Transformation Tools.
 A set of tools for modelling dynamic physical systems using the bond-graph methodology and transforming these models into representations suitable for analysis, control and simulation. These tools use, and generate m files for, GNU Octave.
 .
 The MTT homepage is located at http://mtt.sourceforge.net. An on-line manual is available at http://mtt.sourceforge.net/doc.
 .
 MTT uses the non-free symbolic algebra tool Reduce to perform some transformations and it is highly recommended that this software is installed. Details of Reduce can be found at http://www.reduce-algebra.com
 .

Added mtt/debian/copyright version [b94b7f6de3].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This package was debianized by Geraint <geraint@users.sf.net> on
Sun, 28 Apr 2002 00:11:29 +0000.

It was downloaded from http://sourceforge.net/projects/mtt

Upstream Author(s): Peter Gawthrop <mtt@gawthrop.net>

Copyright:

mtt is copyright (c) 1989-2004 by Peter J. Gawthrop.

You are free to distribute this software under the terms of the
GNU General Public License (GPL).

On Debian systems, the complete text of the GNU General Public License
can be found in /usr/share/common-licenses/GPL.

Added mtt/debian/cron.d.ex version [daf97cc67d].





1
2
3
4
+
+
+
+
#
# Regular cron jobs for the mtt package
#
0 4	* * *	root	mtt_maintenance

Added mtt/debian/dirs version [b541042ac0].



1
2
+
+
usr/bin

Added mtt/debian/docs version [a7ffc6f8bf].

Added mtt/debian/emacsen-install.ex version [40ed5db3df].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh -e
# /usr/lib/emacsen-common/packages/install/mtt

# Written by Jim Van Zandt <jrv@vanzandt.mv.com>, borrowing heavily
# from the install scripts for gettext by Santiago Vila
# <sanvila@ctv.es> and octave by Dirk Eddelbuettel <edd@debian.org>.

FLAVOR=$1
PACKAGE=mtt

if [ ${FLAVOR} = emacs ]; then exit 0; fi

echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}

#FLAVORTEST=`echo $FLAVOR | cut -c-6`
#if [ ${FLAVORTEST} = xemacs ] ; then
#    SITEFLAG="-no-site-file"
#else
#    SITEFLAG="--no-site-file"
#fi
FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}

# Install-info-altdir does not actually exist. 
# Maybe somebody will write it.
if test -x /usr/sbin/install-info-altdir; then
    echo install/${PACKAGE}: install Info links for ${FLAVOR}
    install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/info/${PACKAGE}.info.gz
fi

install -m 755 -d ${ELCDIR}
cd ${ELDIR}
FILES=`echo *.el`
cp ${FILES} ${ELCDIR}
cd ${ELCDIR}

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF
${FLAVOR} ${FLAGS} ${FILES}
rm -f *.el path.el

exit 0

Added mtt/debian/emacsen-remove.ex version [b07e6b425f].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh -e
# /usr/lib/emacsen-common/packages/remove/mtt

FLAVOR=$1
PACKAGE=mtt

if [ ${FLAVOR} != emacs ]; then
    if test -x /usr/sbin/install-info-altdir; then
        echo remove/${PACKAGE}: removing Info links for ${FLAVOR}
        install-info-altdir --quiet --remove --dirname=${FLAVOR} /usr/info/mtt.info.gz
    fi

    echo remove/${PACKAGE}: purging byte-compiled files for ${FLAVOR}
    rm -rf /usr/share/${FLAVOR}/site-lisp/${PACKAGE}
fi

Added mtt/debian/emacsen-startup.ex version [50263110bb].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
;; -*-emacs-lisp-*-
;;
;; Emacs startup file for the Debian GNU/Linux mtt package
;;
;; Originally contributed by Nils Naumann <naumann@unileoben.ac.at>
;; Modified by Dirk Eddelbuettel <edd@debian.org>
;; Adapted for dh-make by Jim Van Zandt <jrv@vanzandt.mv.com>

;; The mtt package follows the Debian/GNU Linux 'emacsen' policy and
;; byte-compiles its elisp files for each 'emacs flavor' (emacs19,
;; xemacs19, emacs20, xemacs20...).  The compiled code is then
;; installed in a subdirectory of the respective site-lisp directory.
;; We have to add this to the load-path:
(setq load-path (cons (concat "/usr/share/"
                              (symbol-name flavor)
			      "/site-lisp/mtt") load-path))


Added mtt/debian/ex.package.doc-base version [8bae181fd3].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Document: mtt
Title: Debian mtt Manual
Author: <insert document author here>
Abstract: This manual describes what mtt is
 and how it can be used to
 manage online manuals on Debian systems.
Section: unknown

Format: debiandoc-sgml
Files: /usr/share/doc/mtt/mtt.sgml.gz

Format: postscript
Files: /usr/share/doc/mtt/mtt.ps.gz

Format: text
Files: /usr/share/doc/mtt/mtt.text.gz

Format: HTML
Index: /usr/share/doc/mtt/html/index.html
Files: /usr/share/doc/mtt/html/*.html

  

Added mtt/debian/init.d.ex version [8fc1c7354e].







































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#
# This file was automatically customized by dh-make on Sun, 28 Apr 2002 00:11:29 +0000

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mtt
NAME=mtt
DESC=mtt

test -f $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo "$NAME."
	;;
  #reload)
	#
	#	If the daemon can reload its config files on the fly
	#	for example by sending it SIGHUP, do it here.
	#
	#	If the daemon responds to changes in its config file
	#	directly anyway, make this a do-nothing entry.
	#
	# echo "Reloading $DESC configuration files."
	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
	#	/var/run/$NAME.pid --exec $DAEMON
  #;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0

Added mtt/debian/manpage.1.ex version [f2432fd683].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MTT SECTION "April 28, 2002"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mtt \- program to do something
.SH SYNOPSIS
.B mtt
.RI [ options ] " files" ...
.br
.B bar
.RI [ options ] " files" ...
.SH DESCRIPTION
This manual page documents briefly the
.B mtt
and
.B bar
commands.
This manual page was written for the Debian distribution
because the original program does not have a manual page.
Instead, it has documentation in the GNU Info format; see below.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
.\" respectively.
\fBmtt\fP is a program that...
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH SEE ALSO
.BR bar (1),
.BR baz (1).
.br
The programs are documented fully by
.IR "The Rise and Fall of a Fooish Bar" ,
available via the Info system.
.SH AUTHOR
This manual page was written by Geraint <geraint@users.sf.net>,
for the Debian GNU/Linux system (but may be used by others).

Added mtt/debian/manpage.sgml.ex version [92a84a8c20].

























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Process this file with docbook-to-man to generate an nroff manual
     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
     less'.  A typical entry in a Makefile or Makefile.am is:

manpage.1: manpage.sgml
	docbook-to-man $< > $@

    
	The docbook-to-man binary is found in the docbook-to-man package.
	Please remember that if you create the nroff version in one of the
	debian/rules file targets (such as build), you will need to include
	docbook-to-man in your Build-Depends control field.

  -->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
  <!ENTITY dhsurname   "<surname>SURNAME</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>April 28, 2002</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>SECTION</manvolnum>">
  <!ENTITY dhemail     "<email>geraint@users.sf.net</email>">
  <!ENTITY dhusername  "Geraint">
  <!ENTITY dhucpackage "<refentrytitle>MTT</refentrytitle>">
  <!ENTITY dhpackage   "mtt">

  <!ENTITY debian      "<productname>Debian</productname>">
  <!ENTITY gnu         "<acronym>GNU</acronym>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2001</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>&dhpackage;</refname>

    <refpurpose>program to do something</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&dhpackage;</command>

      <arg><option>-e <replaceable>this</replaceable></option></arg>

      <arg><option>--example <replaceable>that</replaceable></option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>This manual page documents briefly the
      <command>&dhpackage;</command> and <command>bar</command>
      commands.</para>

    <para>This manual page was written for the &debian; distribution
      because the original program does not have a manual page.
      Instead, it has documentation in the &gnu;
      <application>Info</application> format; see below.</para>

    <para><command>&dhpackage;</command> is a program that...</para>

  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <para>These programs follow the usual GNU command line syntax,
      with long options starting with two dashes (`-').  A summary of
      options is included below.  For a complete description, see the
      <application>Info</application> files.</para>

    <variablelist>
      <varlistentry>
        <term><option>-h</option>
          <option>--help</option>
        </term>
        <listitem>
          <para>Show summary of options.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-v</option>
          <option>--version</option>
        </term>
        <listitem>
          <para>Show version of program.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>bar (1), baz (1).</para>

    <para>The programs are documented fully by <citetitle>The Rise and
      Fall of a Fooish Bar</citetitle> available via the
      <application>Info</application> system.</para>
  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (but may be used by others).  Permission is
      granted to copy, distribute and/or modify this document under
      the terms of the <acronym>GNU</acronym> Free Documentation
      License, Version 1.1 or any later version published by the Free
      Software Foundation; with no Invariant Sections, no Front-Cover
      Texts and no Back-Cover Texts.</para>

  </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->


Added mtt/debian/menu version [a9480c714d].







1
2
3
4
5
6
+
+
+
+
+
+
?package(mtt):needs="X11"\
	section="Apps/Math"\
	title="Xmtt"\
	longtitle="Model Transformation Tools for X"\
	hint="Model Transformation Tools for X"\
	command="x-terminal-emulator -e /usr/bin/xmtt"

Added mtt/debian/menu.ex version [5506fac571].





1
2
3
4
+
+
+
+
?package(mtt):needs=X11|text|vc|wm section=Apps/see-menu-manual\
  title="mtt" command="/usr/bin/mtt"
?package(mtt):needs=X11|text|vc|wm section=Apps/see-menu-manual\
  title="xmtt" command="/usr/bin/xmtt"

Added mtt/debian/mtt.1 version [acff8162e2].




















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MTT 1 "April 27, 2002"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mtt \- Model Transformation Tools
.SH SYNOPSIS
.B mtt
.RI [ options ] " system representation language" 
.br
.B xmtt
.RI [ --update ]
.SH DESCRIPTION
This manual page documents briefly the
.B mtt
and
.B xmtt
commands.
Detailed documentation is available in info or html format by issuing
the command
.B mtt info
for info format or
.B mtt hinfo
for html.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
.\" respectively.
\fBmtt\fP is a  set of tools for modelling dynamic physical systems using the bond-graph methodology and transforming these models into representations suitable for analysis, control and simulation. These tools use, and generate m files for, GNU Octave. 
.SH OPTIONS
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-q
quiet mode -- suppress MTT banner
.TP
.B \-A
solve algebraic equations symbolically
.TP
.B \-D
debug -- leave log files etc
.TP
.B \-I
prints more information
.TP
.B \-abg
start at abg.m representation
.TP
.B \-c
c-code generation
.TP
.B \-cc
C++ code generation
.TP
.B \-cr
Use cr before resolving equations
.TP
.B \-d  <dir>
use directory <dir>
.TP
.B \-dc
Maximise derivative (not integral) causality
.TP
.B \-dc
Maximise derivative (not integral) causality
.TP
.B \-i <implicit|euler|rk4|dassl>
Use implicit, euler, rk4 or dassl integration
.TP
.B \-ae <reduce|hybrd|dassl|hooke>
Solve algebraic equations with specified solver
.TP
.B \-o
ode is same as dae
.TP
.B \-oct
use oct files in place of m files where appropriate
.TP
.B \-opt
optimise code generation
.TP
.B \-p
print environment variables
.TP
.B \-partition
 partition hierachical system
.TP
.B \-pdf
generate pdf in place of ps
.TP
.B \-r
reset time stamp on representation
.TP
.B \-s
generate sensitivity BG (use mtt -s sSys rep lang)
.TP
.B \-ss
use steady-state info to initialise simulations
.TP
.B \-stdin
read input data from standard input for  simulations
.TP
.B \-sub <subsystem>
operate on this subsystem
.TP
.B \-t
tidy mode (default)
.TP
.B \-trace
Just indicate what mtt will do - but do not do it
.TP
.B \-u
untidy mode (leaves files in current dir)
.TP
.B \-v
verbose mode (multiple uses of -v increase the verbosity level)
.TP
.B \-viewlevel <N>
View N levels of hierachy
.TP
.B \-\-version
print version and exit
.TP
.B \-\-versions
print version of mtt and components and exit

The programs are documented fully by
.IR "mtt: Model Transformation Tools" ,
available via the Info system.
.SH FILES
/etc/mtt.conf
.SH AUTHOR
This manual page was written by Geraint <geraint@users.sf.net>,
for the Debian GNU/Linux system (but may be used by others).

Added mtt/debian/mtt.doc-base version [3073d9efcc].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Document: mtt
Title: Model Transformation Tools (MTT) Manual
Author: Peter Gawthrop, Geraint Bevan
Abstract: This manual describes Model Transformation Tools (MTT),
 a set of tools for modelling dynamic physical systems using the bond-graph
 methodology and transforming these models into representations suitable for
 analysis, control and simulation.
 These tools use, and generate m files for, GNU Octave.
Section: Apps/Math

Format: postscript
Files: /usr/share/doc/mtt/mtt.ps.gz

Format: PDF
Files: /usr/share/doc/mtt/mtt.pdf.gz

Format: HTML
Index: /usr/share/doc/mtt/mtt.html
Files: /usr/share/doc/mtt/*.html

  

Added mtt/debian/package.doc-base version [483b9b6fed].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Document: mtt
Title: Debian mtt Manual
Author: Peter Gawthrop
Abstract: This manual describes mtt,
 a set of tools for modelling dynamic physical systems
 using the bond-graph methodology and transforming these
 models into representations suitable for analysis, control
 and simulation. These tools use, and generate m files for,
 GNU Octave. 
Section: math

Format: postscript
Files: /usr/share/doc/mtt/mtt.ps.gz

Format: HTML
Index: /usr/share/doc/mtt/html/mtt.html
Files: /usr/share/doc/mtt/html/*.html

  

Added mtt/debian/postinst version [9236a7d0d3].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# postinst script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

case "$1" in
    configure)
	install-info --menuentry=MTT \
	    --description="Model Transformation Tools" \
	    --section "[Mm]ath" Mathematics \
	    /usr/share/info/mtt.info.gz
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/debian/postinst.ex version [6ec4ce5c20].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# postinst script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

case "$1" in
    configure)

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/debian/postrm.ex version [c13738ff9e].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# postrm script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
       purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)


        ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

Added mtt/debian/preinst.ex version [73f98ab897].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# preinst script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
#
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    install|upgrade)
#        if [ "$1" = "upgrade" ]
#        then
#            start-stop-daemon --stop --quiet --oknodo  \
#                --pidfile /var/run/mtt.pid  \
#                --exec /usr/sbin/mtt 2>/dev/null || true
#        fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/debian/prerm version [a145bc4b8a].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# prerm script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    remove|upgrade|deconfigure)
	install-info --quiet --remove /usr/share/info/mtt.info.gz
        ;;
    failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/debian/prerm.ex version [4a73a2963c].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# prerm script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    remove|upgrade|deconfigure)
#       install-info --quiet --remove /usr/info/mtt.info.gz
        ;;
    failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/debian/rules version [e44338ab99].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This is the debhelper compatibility version to use.
export DH_COMPAT=3



ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.

	touch configure-stamp


build: build-stamp

build-stamp: configure-stamp 
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE) build build-doc
	#/usr/bin/docbook-to-man debian/mtt.sgml > mtt.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/mtt.
	$(MAKE) install install-doc install-xfig DESTDIR=$(CURDIR)/debian/mtt


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installcron
	dh_installman debian/mtt.1
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs 
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
#	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

Added mtt/debian/watch.ex version [5598e47ae1].






1
2
3
4
5
+
+
+
+
+
# Example watch control file for uscan
# Rename this file to "watch" and then you can run the "uscan" command
# to check for upstream updates and more.
# Site		Directory		Pattern			Version	Script
sunsite.unc.edu	/pub/Linux/Incoming	mtt-(.*)\.tar\.gz	debian	uupdate

Added mtt/doc/Makefile version [1980671319].


































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#Makefile for MTT documentation

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/04/26 17:17:20  geraint
## Allow variables to be set outside Makefile.
##
## Revision 1.1  2001/06/04 08:18:52  gawthrop
## Putting documentation under CVS
##
## Revision 1.2  1998/07/02 18:40:07  peterg
## More on install option
##
## Revision 1.1  1998/05/14 09:19:52  peterg
## Initial revision
##
###############################################################


#MTTPATH = /home/peterg/mtt_new/mtt
#DOCPATH = /home/peterg/web-docs/software/MTT/doc
#INFOPATH = /usr/info

MTTPATH ?= /home/peterg/mtt_new/mtt
MTT_COMPONENTS ?= /home/eng4/peterg/mtt_new/mtt/lib/comp
MTT_EXAMPLES ?= /home/eng4/peterg/mtt_new/mtt/lib/examples
DOCPATH ?= /home/peterg/web-docs/software/MTT/doc
#INFOPATH = $(DOCPATH)
INFOPATH ?= /usr/info

all: mtt.info  mtt.html mtt.pdf mtt.ps.gz 

mtt.info: mtt.texi
	echo "Making info manual. Please wait ..."; makeinfo mtt.texi

mtt.dvi: mtt.texi
	echo "Making dvi manual. Please wait ..."; tex mtt.texi; tex mtt.texi

mtt.html: mtt.texi
	echo "Making html manual. Please wait ..."; texi2html -glossary  mtt.texi

mtt.ps.gz: mtt.dvi
	echo "Making ps manual. Please wait ..."; dvips -o mtt.ps mtt; gzip -f mtt.ps

mtt.pdf: mtt.texi
	echo "Making pdf manual. Please wait ..."; texi2pdf mtt.texi

Compound-Components_rep.ps: 
	(cd $(MTT_COMPONENTS); mtt Compound-Components rep ps)
	mv $(MTT_COMPONENTS)/Compound-Components_rep.ps .

Compound-Components_rep: 
	(cd $(MTT_COMPONENTS); mtt Compound-Components rep html)
	mv $(MTT_COMPONENTS)/Compound-Components_rep .

Examples_rep.ps: 
	(cd $(MTT_EXAMPLES); mtt Examples rep ps)
	mv $(MTT_EXAMPLES)/Examples_rep.ps .

Examples_rep: 
	(cd $(MTT_EXAMPLES); mtt Examples rep html)
	mv $(MTT_EXAMPLES)/Examples_rep .

clean:
	rm -f mtt.aux	    mtt.fns	  mtt.pg	mtt.tp
	rm -f mtt.cp	    mtt.pgs	  mtt.vr	mtt.ps
	rm -f mtt.cps	    mtt.vrs	  mtt.dvi       mtt.ps.gz
	rm -f mtt.ky	    mtt.fn	  mtt.log	mtt.toc	
	rm -f 		    mtt.ps        mtt.info-*    mtt.pdf
	rm -f mtt.html	    mtt_toc.html  mtt.info
	rm -f mtt.log       mtt.ky        mtt.toc

tidy:
	rm -f mtt.aux	    mtt.fns	  mtt.pg	mtt.tp
	rm -f mtt.cp	    mtt.pgs	  mtt.vr	
	rm -f mtt.cps	    mtt.vrs	  mtt.dvi       
	rm -f mtt.log       mtt.ky        mtt.toc


install-doc: mtt.html mtt.ps.gz  mtt.info
	cp mtt.info* $(INFOPATH)
	cp mtt*.html mtt.ps.gz  $(DOCPATH)
	chmod -R a+r $(DOCPATH)
	chmod a+x  $(DOCPATH)

install-components:  Compound-Components_rep.ps Compound-Components_rep
	mv Compound-Components_rep.ps $(DOCPATH)/../components
	mv Compound-Components_rep    $(DOCPATH)/../components
	chmod -R a+r $(DOCPATH)/../components
	chmod -R a+x $(DOCPATH)/../components/Compound-Components_re




Added mtt/doc/mtt.texi version [66bf14f795].
























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\input texinfo  
@c %**start of header
@setfilename mtt.info
@settitle MTT: Model Transformation Tools
@c %**end of header

@finalout

@c Here is what I use in the Info `dir' file:
@c * Mtt: (mtt).                Model transformation tools.



@comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@comment  Version control history
@comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@comment  $Id$
@comment  $Log$
@comment  Revision 1.32  2014/07/12 19:56:27  geraint
@comment  Fixed style of NO WARRANTY from @heading to @strong because texi2html complained about having a heading in an enumerate environment
@comment
@comment  Revision 1.31  2014/07/10 23:13:27  geraint
@comment  Fixed mtt.texi missing arguments and subsection level
@comment
@comment  Revision 1.30  2005/03/15 12:04:15  gawthrop
@comment  New labg.fig rep - pretty LaTeX figures.
@comment
@comment  Revision 1.29  2005/01/19 09:45:15  geraint
@comment  Fixed whitespace.
@comment
@comment  Revision 1.28  2005/01/06 16:03:55  geraint
@comment  Updated options list.
@comment
@comment  Revision 1.27  2005/01/06 14:42:33  geraint
@comment  Fixed explicit/implicit descriptions of forward/backward Euler.
@comment  Replaced -c examples with -cc.
@comment
@comment  Revision 1.26  2005/01/06 12:28:36  geraint
@comment  Minor typos.
@comment
@comment  Revision 1.25  2004/08/27 20:12:34  geraint
@comment  Added note about "none" as an option for units.
@comment
@comment  Revision 1.24  2004/08/13 01:39:24  geraint
@comment  Fixed variable names in diy makefile example (again)
@comment
@comment  Revision 1.23  2004/08/11 08:24:28  geraint
@comment  Replaced "gnuplot view" with "odeso gnuplot" in examples.
@comment
@comment  Revision 1.21  2004/07/23 11:05:26  geraint
@comment  Updated Reduce URL: http://www.reduce-algebra.com
@comment
@comment  Revision 1.20  2003/10/23 18:14:43  geraint
@comment  Added subsection with script for model-specific options.
@comment  Fixed typo in url to mtt.sf.net.
@comment
@comment  Revision 1.19  2003/10/10 22:22:18  geraint
@comment  typo.
@comment
@comment  Revision 1.18  2003/09/07 20:41:19  geraint
@comment  *** empty log message ***
@comment
@comment  Revision 1.17  2003/08/19 14:20:38  gawthrop
@comment  Version 5.0 of MTT
@comment  Remove xref errors (spurious spaces)
@comment
@comment  Revision 1.16  2003/08/19 14:11:23  gawthrop
@comment  Links to legal stuff
@comment
@comment  Revision 1.15  2003/08/19 14:01:45  gawthrop
@comment  Added legal appendices
@comment
@comment  Revision 1.14  2003/08/06 14:50:56  gawthrop
@comment  Describe the alias mechanism for invoking mtt options
@comment
@comment  Revision 1.13  2002/12/13 10:07:07  gawthrop
@comment  Added example in sh section of DIY reps
@comment
@comment  Revision 1.12  2002/09/19 08:09:31  gawthrop
@comment  Updated documentation documentation
@comment
@comment  Revision 1.11  2002/08/20 15:51:17  gawthrop
@comment  Update to work with ident DIY rep
@comment
@comment  Revision 1.10  2002/07/22 10:45:22  geraint
@comment  Fixed gnuplot rep so that it correctly re-runs the simulation if input files have changed.
@comment
@comment  Revision 1.9  2002/07/05 13:29:34  geraint
@comment  Added notes about generating dynamically linked functions for Octave and Matlab.
@comment
@comment  Revision 1.8  2002/07/04 21:34:12  geraint
@comment  Updated gnuplot view description to describe Tcl/Tk interface instead of obsolete txt method.
@comment
@comment  Revision 1.7  2002/04/23 09:51:54  gawthrop
@comment  Changed incorrect statement about searching for components.
@comment
@comment  Revision 1.6  2001/10/15 14:29:50  gawthrop
@comment  Added documentaton on  [1:N] style port labels
@comment
@comment  Revision 1.5  2001/07/23 03:35:29  geraint
@comment  Updated file structure (mtt/bin).
@comment
@comment  Revision 1.4  2001/07/23 03:25:02  geraint
@comment  Added notes on -ae hybrd, rk4, ode2odes.cc, .oct dependencies.
@comment
@comment  Revision 1.3  2001/07/13 03:02:38  geraint
@comment  Added notes on #ICD, gnuplot.txt and odes.sg rep.
@comment
@comment  Revision 1.2  2001/07/03 22:59:10  gawthrop
@comment  Fixed problems with argument passing for CRs
@comment
@comment  Revision 1.1  2001/06/04 08:18:52  gawthrop
@comment  Putting documentation under CVS
@comment
@comment  Revision 1.66  2000/12/05 14:20:55  peterg
@comment  Added the c++  anf m CR info.
@comment
@comment  Revision 1.65  2000/11/27 15:36:15  peterg
@comment  NOPAR --> NOTPAR
@comment
@comment  Revision 1.64  2000/11/16 14:22:48  peterg
@comment  added UNITS declaration
@comment
@comment  Revision 1.63  2000/11/03 14:41:08  peterg
@comment  Added PAR and NOPAR stuff
@comment
@comment  Revision 1.62  2000/10/17 17:53:34  peterg
@comment  Added some simulation details
@comment
@comment  Revision 1.61  2000/09/14 17:13:06  peterg
@comment  New options table
@comment
@comment  Revision 1.60  2000/09/14 17:09:20  peterg
@comment  Tidied up valid name sections
@comment  Tidied up defining represnetations table
@comment  Verion 4.6
@comment
@comment  Revision 1.59  2000/08/30 13:09:00  peterg
@comment  Updated option table
@comment
@comment  Revision 1.58  2000/08/01 13:30:19  peterg
@comment  Version 4.4
@comment  updated STEPFACTOR info
@comment  describes octave and OCST interfaces
@comment
@comment  Revision 1.57  2000/07/20 07:55:44  peterg
@comment  Version 4.3
@comment
@comment  Revision 1.56  2000/05/19 17:49:17  peterg
@comment  Extended the user defined representation section -- new nppp rep.
@comment
@comment  Revision 1.55  2000/03/16 13:53:31  peterg
@comment  Correct date
@comment
@comment  Revision 1.54  2000/03/15 21:22:57  peterg
@comment  Updated to 4.1 -- old style SS no longer supported
@comment
@comment  Revision 1.53  1999/12/22 05:33:10  peterg
@comment  Updated for 4.0
@comment
@comment  Revision 1.52  1999/11/23 00:25:11  peterg
@comment  Added the sensitivity reps
@comment
@comment  Revision 1.51  1999/11/16 04:43:47  peterg
@comment  Added start of sensitivity section
@comment
@comment  Revision 1.50  1999/11/16 00:30:35  peterg
@comment  Updated simulation section
@comment  Added vector components
@comment
@comment  Revision 1.49  1999/07/20 23:44:58  peterg
@comment  V 3.8
@comment
@comment  Revision 1.48  1999/07/19 03:08:33  peterg
@comment  Added documentation for (new) SS lbl fields
@comment
@comment  Revision 1.47  1999/03/09 01:42:22  peterg
@comment  Rearranged the User interface section
@comment
@comment  Revision 1.46  1999/03/09 01:18:01  peterg
@comment  Updated for 3.5 including xmtt
@comment
@comment  Revision 1.45  1999/03/03 02:39:26  peterg
@comment  Minor updates
@comment
@comment  Revision 1.44  1999/02/17 06:52:14  peterg
@comment  New level formula dor artwork
@comment
@comment  Revision 1.43  1998/11/25 16:49:24  peterg
@comment  Put in subs.r documentation (was called params.r)
@comment
@comment  Revision 1.42  1998/11/24 12:24:59  peterg
@comment  Added section on simulation output
@comment  Version 3.4
@comment
@comment  Revision 1.41  1998/09/02 12:04:15  peterg
@comment  Version 3.2
@comment
@comment  Revision 1.40  1998/08/27 08:36:39  peterg
@comment  Removed in. methods except Euler anf implicit
@comment
@comment  Revision 1.39  1998/08/18 10:44:28  peterg
@comment  Typo
@comment
@comment  Revision 1.38  1998/08/18 09:16:38  peterg
@comment  Version 3.1
@comment
@comment  Revision 1.37  1998/08/17 16:14:30  peterg
@comment  Version 3.1 - includes documentation on METHOD=IMPLICIT
@comment
@comment  Revision 1.36  1998/07/30 17:33:15  peterg
@comment  VERSION 3.0
@comment
@comment  Revision 1.35  1998/07/22 11:00:53  peterg
@comment  Correct date!
@comment
@comment  Revision 1.34  1998/07/22 11:00:13  peterg
@comment  Version to BAe
@comment
@comment  Revision 1.33  1998/07/17 19:32:19  peterg
@comment  Added more about aliases
@comment
@comment  Revision 1.32  1998/07/05 14:21:56  peterg
@comment  Further additions (Carlisle-Glasgow)
@comment
@comment  Revision 1.31  1998/07/04 11:35:57  peterg
@comment  Strarted new lbl description
@comment
@comment  Revision 1.30  1998/07/02 18:39:20  peterg
@comment  Started 3.0
@comment  Added alias and default sections.
@comment
@comment  Revision 1.29  1998/05/19 19:46:58  peterg
@comment  Added the odess description
@comment
@comment  Revision 1.28  1998/05/14 09:17:22  peterg
@comment  Added METHOD variable to the simpar file
@comment
@comment  Revision 1.27  1998/05/13 10:03:09  peterg
@comment  Added unknown/zero SS label documentation.
@comment
@comment  Revision 1.26  1998/04/29 15:12:46  peterg
@comment  Version 2.9.
@comment
@comment  Revision 1.25  1998/04/12 17:00:26  peterg
@comment  Added new port features: coerced direction and top-level behaviour.
@comment
@comment  Revision 1.24  1998/04/05 18:27:20  peterg
@comment  This was the 2.6 version
@comment
@comment Revision 1.23  1997/08/24  11:17:51  peterg
@comment This is the released  version 2.5
@comment
@comment  Revision 1.22  1997/08/23 19:38:53  peterg
@comment  Added simulation chapter.
@comment
@comment  Revision 1.21  1997/08/23 16:50:10  peterg
@comment  Added desc section.
@comment  Included named and vector ports
@comment  Completed list of representations.
@comment
@comment Revision 1.20  1997/06/16  15:39:24  peterg
@comment THis is the released 2.4 document.
@comment
@comment Revision 1.19  1997/06/16  09:48:23  peterg
@comment Back under revision control (elm)
@comment
@comment  Revision 1.18  1997/06/14 20:27:41  peterg
@comment  Added complex example section.
@comment
@comment  Revision 1.18  1997/06/13  14:51:07  peterg
@comment  Added report section
@comment 
@comment  Revision 1.17  1997/05/09 15:06:02  peterg
@comment  Changed to version 2.4.
@comment
@comment  Revision 1.16  1996/12/05 10:06:25  peterg
@comment  Modified .octaverc : 'true' --> 1
@comment
@comment  Revision 1.15  1996/11/20 19:02:28  peterg
@comment  Added some system admin stuff.
@comment  Added section on simple models.
@comment
@comment Revision 1.14  1996/11/12  13:19:04  peterg
@comment Put paths as section, not subsection.
@comment
@comment Revision 1.13  1996/11/11  16:53:14  peterg
@comment Added params documentation
@comment Sorted out table bug.
@comment
@comment  Revision 1.12  1996/11/10 20:29:31  peterg
@comment  Added section on help -- needs more
@comment
@comment  Revision 1.11  1996/11/09 21:15:28  peterg
@comment  Rewrite of quick start.
@comment  Update of file structure.
@comment
@comment  Revision 1.10  1996/11/09 20:25:54  peterg
@comment  Final v2.0.
@comment
@comment  Revision 1.9  1996/10/01 10:33:02  peter
@comment  Cleaned up cross references.
@comment
@comment  Revision 1.8  1996/10/01 09:31:00  peter
@comment  Added sections written in Hong Kong.
@comment
@comment  Revision 1.7  1996/09/16 09:49:47  peter
@comment  Added ese section
@comment
@comment  Revision 1.6  1996/09/16 08:33:53  peter
@comment  Added constitutive relationship section etc.
@comment
@comment  Revision 1.5  1996/09/15 20:20:56  peter
@comment  Added abg and rbg stuff
@comment
@comment  Revision 1.4  1996/08/30 19:07:40  peter
@comment  Added some admin stuff.
@comment
@comment  Revision 1.3  1996/08/30 07:50:16  peter
@comment  Added file structure section.
@comment
@comment  Revision 1.2  1996/08/22 14:28:50  peter
@comment  Added stuff about labels.
@comment
@comment  Revision 1.1  1996/08/22 11:52:59  peter
@comment  Initial revision
@comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


@ifinfo
This file documents MTT, a set of Model Transformation Tools.


Copyright (C) Peter J. Gawthrop 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
section entitled ``GNU General Public License'' is included exactly as
in the original, and provided that the entire resulting derived work is
distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that the section entitled ``GNU General Public License'' may be
included in a translation approved by the author instead of in the
original English.
@end ifinfo


@titlepage
@title MTT: Model Transformation Tools
@subtitle August 2003
@subtitle For version 5.0.
@author Peter Gawthrop, Geraint Bevan
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1996,1997,1998,1999,2000,2001,2002,2003 Peter J. Gawthrop

      Permission is granted to copy, distribute and/or modify this document
      under the terms of the GNU Free Documentation License, Version 1.2
      or any later version published by the Free Software Foundation;
      with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
	 Texts.  A copy of the license is included in the section entitled "GNU
      Free Documentation License".

General information about MTT is available at URL www.sf.net.  MTT is distributed
under the GNU GENERAL PUBLIC LICENSE (@pxref{Copying}). This manual is
distributed under the GNU Free Documentation License (@pxref{GNU Free
Documentation License}).

@example
http://mtt.sourceforge.net
@end example
@ifhtml
<A
HREF="http://mtt.sourceforge.net"> here</A>.
@end ifhtml

@end titlepage


@ifinfo
@node Top, Introduction, (dir), (dir)
@top MTT
@strong{MTT} is a set of Model Transformation Tools based on bond graphs.
@strong{MTT} implements the theory to be found in the book ``Metamodelling: Bond
Graphs and Dynamic Systems'' by Peter Gawthrop and Lorcan Smith
published by Prentice Hall in 1996 (ISBN 0-13-489824-9).

It implements two features not discussed in that book:
@itemize @bullet
@item 
bicausal bond graphs and
@item
hierarchical bond graphs.
@end itemize



@contents

@end ifinfo


@c @include intro.texi
@c Copyright (C) 1996 Peter J. Gawthrop
@c This is part of the MTT manual.
@c For copying conditions, see the file MTT.texi.

@menu
* Introduction::                
* User interface::              
* Creating Models::             
* Simulation::                  
* Sensitivity models::          
* Representations::             
* Extending MTT::               
* Documentation::               
* Languages::                   
* Language tools::              
* Administration::              
* Glossary::                    
* Index::                       

@detailmenu
 --- The Detailed Node Listing ---

Introduction

* What is a Representation?::   
* What is a Transformation?::   
* Bond graphs::                 What is a bond graph?                
* Variables::                   
* Bonds::                       
* Components::                  
* Algebraic loops::             
* Switched systems::            

Components

* Ports::                       
* Constitutive relationship::   
* Symbolic parameters::         
* Numeric parameters::          

User interface

* Menu-driven interface::       
* Command line interface::      
* Options::                     
* Utilities::                   

Options

* Available options::           
* Model-specific options::      

Available options

* Experimental options::        
* Deprecated options::          

Utilities

* Help::                        
* Copy::                        
* Clean::                       
* Version control::             

Help

* help representations::        
* help components::             
* help examples::               
* help crs::                    
* help <name>::                 

Creating Models

* Quick start::                 
* Creating simple models::      
* Creating complex models::     

Creating complex models

* Top level::                   

Simulation

* Steady-state solutions::      
* Simulation parameters::       
* Simulation input::            
* Simulation logic::            
* Simulation initial state::    
* Simulation code::             
* Simulation output::           

Steady-state solutions 

* Steady-state solutions - numerical(odess)::  
* Steady-state solutions - symbolic (ss)::  

Simulation parameters

* Euler integration::           
* Implicit integration::        
* Runge Kutta IV integration::  
* Hybrd algebraic solver::      

Simulation code

* Dynamically linked functions::  

Simulation output

* Viewing results with gnuplot::  
* Exporting results to SciGraphica::  

Representations

* Representation summary::      
* Defining representations::    
* Verbal description (desc)::   
* Acausal bond graph (abg)::    
* Acausal bond graph - LaTeX ready (labg)::  
* Stripped acausal bond graph (sabg)::  
* Labels (lbl)::                
* Structure (struc)::           
* Constitutive Relationship (cr)::  
* Parameters::                  
* Causal bond graph (cbg)::     
* Elementary system equations::  
* Differential-Algebraic Equations::  
* Constrained-state Equations::  
* Ordinary Differential Equations::  
* Descriptor matrices::         
* Report::                      

Acausal bond graph (abg)

* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      

Acausal bond graph - LaTeX ready (labg)

* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      

Language fig (abg.fig) 

* icon library::                
* bonds::                       
* strokes::                     
* components::                  
* Simple components::           
* SS components::               
* Simple components - implementation::  
* Compound components::         
* Named SS components::         
* Coerced bond direction::      
* Port labels::                 
* Vector port labels::          
* Port label defaults::         
* Vector components::           
* artwork::                     
* Valid names::                 

Simple components

* SS components::               
* Simple components - implementation::  

Compound components

* Named SS components::      

Language m (rbg.m)

* Transformation abg2rbg_fig2m::  

Language m (abg.m)

* Arrow-orientated causality::  
* Component-orientated causality::  
* Transformation rbg2abg_m::    

Stripped acausal bond graph (sabg)

* Language fig (sabg.fig)::     
* Stripped acausal bond graph (view)::  

Labels (lbl)

* SS component labels::         
* Other component labels::      
* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Parameter declarations::      
* Units declarations::          
* Interface Control Definition::  
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      
* Language tex (desc.tex)::     

Other component labels 

* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      

Aliases

* Port aliases::                
* Parameter aliases::           
* CR aliases::                  
* Component aliases::           

Old-style labels (lbl)

* SS component labels (old-style)::  
* Other component labels (old-style)::  
* Parameter passing (old-style)::  

Parameter passing (old-style)

* Language tex (desc.tex)::     

Structure (struc)

* Language txt (struc.txt)::    
* Language tex (struc.tex)::    
* Structure (view)::            

Constitutive relationship (cr)

* Predefined constitutive relationships::  
* DIY constitutive relationships::  
* Unresolved constitutive relationships::  
* Unresolved constitutive relationships - Octave::  
* Unresolved constitutive relationships - c++::  

Predefined constitutive relationships

* lin::                         
* exotherm::                    

Parameters

* Symbolic parameters (subs.r)::  
* Symbolic parameters for simplification (simp.r)::  
* Numeric parameters (numpar)::  

Numeric parameters (numpar)

* Text form (numpar.txt)::      

Causal bond graph (cbg)

* Language fig (cbg.fig)::      
* Language m (cbg.m)::          

Language m (cbg.m)

* Transformation abg2cbg_m::    

Elementary system equations (ese)

* Transformation cbg2ese_m2r::  

Differential-Algebraic Equations (dae)

* Differential-Algebraic Equations (reduce)::  
* Differential-Algebraic Equations (m)::  

Language reduce (dae.r)

* Transformation ese2dae_r::    

Language m (dae.m)

* Transformation dae_r2m::      

Constrained-state Equations (cse)

* Constrained-state Equations (reduce)::  
* Constrained-state Equations (view)::  

Language reduce (cse.r)

* Transformation dae2cse_r::    

Ordinary Differential Equations

* Ordinary Differential Equations (reduce)::  
* Ordinary Differential Equations (m)::  
* Ordinary Differential Equations (view)::  

Language reduce (ode.r)

* Transformation cse2ode_r::    

Language m (ode.m)

* Transformation ode_r2m::      

Descriptor matrices (dm)

* Descriptor matrices (reduce)::  
* Descriptor matrices (m)::     

Report (rep)

* Report (text)::               
* Report (view)::               

Extending MTT

* Makefiles::                   
* New (DIY) representations::   
* Component library::           

New (DIY) representations

* Makefile (DIY representations)::  
* Shell-script (DIY representations)::  
* Documentation (DIY representations)::  

Documentation

* Manual (Documentation)::      
* On-line documentation::       

On-line documentation

* Brief::                       
* Detailed::                    

Languages

* Fig::                         r
* m::                           
* Reduce::                      
* c::                           

Language tools

* Views::                       
* Xfig::                        
* Text editors::                
* Octave::                      
* LaTeX::                       

Octave

* Octave control system toolbox (OCST)::  
* Creating GNU Octave .oct files::  
* Creating Matlab .mex files::  
* Embedding MTT models in Simulink::  

Administration

* Software components::         
* REDUCE setup::                
* Octave setup::                
* Paths::                       
* File structure::              
* GNU Free Documentation License::  
* Copying::                     

Octave setup

* .octaverc::                   
* .oct file dependencies::      

Paths

* $MTTPATH::                    
* $MTT_COMPONENTS::             
* $MTT_CRS::                    
* $MTT_EXAMPLES::               
* $OCTAVE_PATH::                

@end detailmenu
@end menu

@node Introduction, User interface, Top, Top
@chapter Introduction

@cindex MTT, purpose of

@pindex MTT

@strong{MTT} is a set of Model Transformation Tools based on bond
graphs.  @strong{MTT} implements the theory to be found in the book
``Metamodelling: Bond Graphs and Dynamic Systems'' by Peter Gawthrop and
Lorcan Smith published by Prentice Hall in 1996 (ISBN 0-13-489824-9).

It implements two features not discussed in that book:
@itemize @bullet
@item 
bicausal bond graphs and
@item
hierarchical bond graphs.
@end itemize

In the context of software, it has been said that one good tool is worth many
packages. UNIX is a good example of this philosophy: the user can put together
applications from a range of ready made tools.
This manual describes the application of this philosophy to dynamic
system modeling embodied in @strong{MTT} - a set of Model Transformation Tools
each of which implements a single transformation between system
representations.


System representations have two attributes. 
@itemize @bullet
@item
 A Form: e.g. acausal bond graph, differential algebraic, linear
                state-space etc.
@item
A Language: e.g. Fig, Matlab, LaTeX, Reduce, postscript etc.
@end itemize

Transformations in @strong{MTT} are accomplished using appropriate software (e.g.
Octave/Matlab, Reduce) encapsulated in UNIX Bourne shell scripts. The
relationships between the tools are encoded in a Make File; thus the
user can specify a final representation and all the necessary
intermediate transformations are automatically generated.

@menu
* What is a Representation?::   
* What is a Transformation?::   
* Bond graphs::                 What is a bond graph?                
* Variables::                   
* Bonds::                       
* Components::                  
* Algebraic loops::             
* Switched systems::            
@end menu


@node What is a Representation?, What is a Transformation?, Introduction, Introduction
@section What is a representation?

@cindex Representations, what are they?

@pindex Representations

Physical systems have many representations. These include
@itemize @bullet
@item
a schematic diagram,
@item
a block diagram,
@item
a bunch of equations,
@item
a single differential(-algebraic) equation,
@item
simulation code,
@item
linearised state-space (or descriptor) equations,
@item
transfer function (of the linearised system),
@item
frequency response  (of the linearised system),
@item
etc...
@end itemize

Each of these representations is related to other representations by an
appropriate transformation (@pxref{What is a Transformation?}. In many cases, a
modeler is presented with a physical system and needs to make a
model. In particular, a model, in this context, is a representation of
the system appropriate to a particular use, for example:
@itemize @bullet
@item
simulation,
@item
control system design,
@item
optimisation
@item
etc.
@end itemize

Indeed, for a given physical system, the modeler would need to derive
a number of models. This process can be viewed as a series of steps;
each involving a transformation between representations (@pxref{What is a Transformation?}.


In this context, the following considerations are relevant.
@itemize @bullet
@item
There is a unique `core' representation of any system.
There are many routes  from this core representation, each leading to
an appropriate model.
There are many possible routes  to this core representation
from the physical system: the route chosen is a matter of convenience.
@item
Because the core representation is unique, it is easy to expand the
tool-box to include additional transformations from the physical system
to the core representation and additional transformations from the core
representation to the mode.
@item
Transformation_1 probably cannot, and certainly should not, be
completely automated.  Engineering insight, knowledge and experience is
essential to capture the essence (with respect to the particular use) of
the physical system whilst discarding irrelevant form.
@item
Representation_1 should be `close' in some sense to the Physical system.
@item
The core representation, and hence the representations leading to it,
must contain enough information to generate all of the required models.
@item
Representations must be easily extensible: it must be possible to add
extra components or attributes without restructuring the representation.
@end itemize

I happen to believe that Bond graphs (@pxref{Bond graphs}) provide the
most convenient and powerful basis for the core representation.

@node What is a Transformation?, Bond graphs, What is a Representation?, Introduction
@comment  node-name,  next,  previous,  up
@section What is a transformation?
@cindex Transformations


Each system representation  (@pxref{What is a Representation?} is related to other representations by an
appropriate transformation as follows:
@itemize @bullet 
@item
 Physical system
@item
 Transformation_1 ---> Representation_1
@item
 Transformation_2 ---> Representation_2
@item
 ...
@item
 Transformation_N ---> Core representation
@item
 Transformation_N+1 ---> Representation_N+1
@item
 Transformation_N+2 ---> Representation_N+2
@item
 ...
@item
 Transformation_N+M ---> Model
@end itemize
Thus modeling is seen as a sequence of transformations between
representations.



@node Bond graphs, Variables, What is a Transformation?, Introduction
@section What is a bond graph?

@cindex Bond graphs, what are they?

@pindex Bond graphs

Bond graphs provide a graphical high-level language for describing
dynamic systems in a precise and unambiguous fashion. 
They make a clear distinction between structure (how components are
connected together), and behavior (the particular constitutive
relationships, or physical laws, describing each component.

They can describe a range of physical systems including:
@itemize @bullet
@item
Electrical systems
@item
Mechanical systems
@item
Hydraulic systems
@item
Chemical process systems
@end itemize

More importantly, they can describe systems which contain subsystems
drawn from all of these domains in a uniform manner.

Bond graphs are made up of components (@pxref{Components}) connected by
bonds (@pxref{Bonds}) which define the relationship between
variables (@pxref{Variables}).

@node Variables, Bonds, Bond graphs, Introduction
@comment  node-name,  next,  previous,  up
@section Variables
@cindex Variables
In bond graph terminology there are four sorts of variables:
@itemize @bullet
@item  @emph{effort} variables
@item  @emph{flow} variables
@item  @emph{integrated effort} variables
@item  @emph{integrated flow} variables
@end itemize

Examples of  @emph{effort} variables are
@itemize @bullet
@item 
voltage
@item 
pressure
@item
force
@item
torque
@item
temperature
@end itemize

Examples of  @emph{flow} variables are
@itemize @bullet
@item 
current
@item 
volumetric flow rate
@item
velocity
@item
angular velocity
@item
heat flow
@end itemize



Examples of integrated  @emph{flow} variables are
@itemize @bullet
@item 
charge
@item 
volume
@item
momentum
@item
angular momentum
@item
heat
@end itemize



@node Bonds, Components, Variables, Introduction
@comment  node-name,  next,  previous,  up
@section Bonds
@cindex Bonds
Bonds connect components (@pxref{Components}) together. Each bond
carries two variables:
@itemize @bullet
@item an effort (@pxref{Variables}) variable and 
@item a flow (@pxref{Variables}) variable.
@end itemize
Each bond has three notations associated with it:
@itemize @bullet
@item a half-arrow,
@item a causal stroke and
@item a causal half-stroke.
@end itemize

The half-arrow indicates two things:
@itemize @bullet
@item the direction of power (or pseudo power) flow and
@item the side of the bond associated with the flow variable.
@end itemize

The causal stroke indicates two things:
@itemize @bullet
@item the effort variable is imposed at the same end as the stroke and
@item the flow variable is imposed at the opposite end to the stroke.
@end itemize

The causal half-stoke indicates one thing:
@itemize @bullet
@item if it is on the effort side of the bond, the effort variable is 
imposed at the same end as the stroke or
@item if it is on the flow side of the bond, the flow variable is 
imposed at the opposite end to the stroke.
@end itemize



@node Components, Algebraic loops, Bonds, Introduction
@comment  node-name,  next,  previous,  up
@section  Components
@cindex Components

Components provide the building blocks of a dynamic system when
connected by bonds (@pxref{bonds}).
Components have the following attributes:
@vtable @code
@item ports 
        provide the connections to other components (@pxref{Ports})
@item constitutive relationships
        define how the port-variables are related (@pxref{Constitutive
relationship})
@end vtable


@menu
* Ports::                       
* Constitutive relationship::   
* Symbolic parameters::         
* Numeric parameters::          
@end menu

@node Ports, Constitutive relationship, Components, Components
@comment  node-name,  next,  previous,  up
@subsection Ports
@cindex ports
Components have one or more ports. Each port carries two variables,
and effort and a flow variable (@pxref{Variables}). Any pair of ports
can be connected by a bond (@pxref{Bonds}); this connection is
equivalent to saying that the effort variables at each port are
identical and that the flow variables at each port are
identical.

Ports are implemented in @strong{MTT} using named SS components.
(@pxref{Named SS components}).

The direction of the named SS components.
(@pxref{Named SS components}) 
is coerced (@pxref{Coerced bond direction}) to have the same direction
as the bons connected to the corresponding port. Thus the direction of
the  direction of the named SS components has no significance unless the
component is at the top level.

@node Constitutive relationship, Symbolic parameters, Ports, Components
@comment  node-name,  next,  previous,  up
@subsection  Constitutive relationship
@cindex Constitutive Relationship

The constitutive relationship of a component defines how the port
variables are related. This relationship may be linear
or non-linear. This typically contains symbolic parameters
(@pxref{Symbolic parameters}) which may be replaced, for the purposes
of numerical analysis by numeric parameters
(@pxref{Numeric parameters}).

@node Symbolic parameters, Numeric parameters, Constitutive relationship, Components
@comment  node-name,  next,  previous,  up
@subsection Symbolic parameters
@cindex Symbolic parameters
The constitutive relationship of a system component (@pxref{Components})
typically contains  symbolic parameters. For example a resistor may have
a symbolic resistance r. It is convenient to leave such parameters as
symbols when viewing equations or when performing symbolic analysis such
as differentiation.

However, @strong{MTT} allows replacement of symbolic parameters by
numeric parameters (@pxref{Numeric parameters}) when appropriate.

@node Numeric parameters,  , Symbolic parameters, Components
@comment  node-name,  next,  previous,  up
@subsection Numeric parameters
@cindex Numeric parameters
Numerical parameters are needed to give specific values to symbolic
parameters (@pxref{Symbolic parameters}) for the purposes of numeric
analysis;
for example: simulation, graph plotting or use within a numerical
package such as Octave (@pxref{Octave}).


@node Algebraic loops, Switched systems, Components, Introduction
@section Algebraic loops
@cindex Algebraic loops
Following Chapter 3 of the book, algebraic loops appear as under-causal
components in the bond graph. It is up to the modeler to indicate how these loops
are to be resolved by adding appropriate SS elements.

In particular if zero junction is undercausal an SS:loop component (with
effort output indicated by a causal stroke) with the following label
file entry:
@example
  loop SS unknown,zero
@end example

For more information, refer to:
``Metamodelling: Bond Graphs and Dynamic Systems'' by Peter Gawthrop and
Lorcan Smith published by Prentice Hall in 1996 (ISBN 0-13-489824-9).

@node Switched systems,  , Algebraic loops, Introduction
@comment  node-name,  next,  previous,  up
@section Switched systems
@cindex Switched systems
@cindex Hybrid systems
@cindex logic

Some systems contain switch-like components. For example an electrical
system may contain on-off switches and diodes and a hydraulic system may
shut-off valves and non-return valves. 

Such systems are sometimes called hybrid systems. The modelling an
simulation of such systems is the subject of current research.
@strong{MTT} implements a simple pragmatic approach to the modelling and
simulation of such systems via two new Bond Graph components:
@vtable @code
@item ISW     
        a switched @code{I} component
@item CSW     
        a switched @code{C} component
@end vtable

These switches are user controlled through the logic representation
(@pxref{Simulation logic}).

@node User interface, Creating Models, Introduction, Top
@comment  node-name,  next,  previous,  up
@chapter User interface
@cindex User interface
@pindex User interface
There are two user interfaces to  @strong{MTT}: a command line interface
(@pxref{Command line interface}) and a menu-driven interface
(@pxref{Menu-driven interface}).

@menu
* Menu-driven interface::       
* Command line interface::      
* Options::                     
* Utilities::                   
@end menu

@node Menu-driven interface, Command line interface, User interface, User interface
@comment  node-name,  next,  previous,  up
@section Menu-driven interface
@cindex Menu-driven interface
@pindex Menu-driven interface
The Menu-driven interface for @strong{MTT} is invoked as:
@example
xmtt
@end example
This will bring up a menu which should be self explanatory :-).
Various messages will be echoed in the window from whence @strong{xMTT}
was invoked.

@node Command line interface, Options, Menu-driven interface, User interface
@comment  node-name,  next,  previous,  up
@section Command line interface
@cindex Command line interface
@pindex Command line interface
The command line interface for @strong{MTT} is of the form:
@example
mtt [options] <system_name> <representation> <language>
@end example
@vtable @code
@item [options]
        the (optional) option switches  (@pxref{Options})
@item <system_name>    
        the name of the system being transformed 
@item <representation>    
        the mnemonic for the system representation (@pxref{Representation summary})
@item <language>    
        the mnemonic for language for the representation (@pxref{Languages})
@end vtable
for example
@example
mtt rc rep view
@end example
creates a view of the report describing system rc and
@example
mtt rc sm m
@end example
creates an m file (suitlable for Octave or Matlab) containing state
matrices describing the system rc.
@node Options, Utilities, Command line interface, User interface
@comment  node-name,  next,  previous,  up
@section Options
@cindex options
@cindex alias options

@strong{MTT} has a number of optional switches to control its
operation. These are invoked immediately after `mtt' on the command
line; for example:
@example
mtt -o -ss -cc syst cbg view
@end example
invokes the @code{-o}, @code{-ss}, and @code{-cc} options.

If you wish to use an option  all the time, use the
alias function appropriate to the shell you are using. For example,
using bash:
@example
alias mtt='mtt -o -ss -cc'
@end example
Means that the previous example can be executed using
@example
mtt syst cbg view
@end example

@menu
* Available options::           
* Model-specific options::      
@end menu

@node Available options, Model-specific options, Options, Options
@comment  node-name,  next,  previous,  upThe available options are:
@subsection Available options
@vtable @code
@item 	-A
		solve algebraic equations symbolically
@item	-abg
		start at abg.m representation
@item	-ae <method>
	algebraic equation solver: reduce|hybrd|dassl|hooke
@item	-cc
		C++ code generation
@item	-cr
		use cr before resolving equations
@item	-D
		debug -- leave log files etc
@item	-d <dir>
	use directory <dir>
@item	-dc
		maximise derivative (not integral) causality
@item	-dr <dir>
	use files contained in <dir>
@item	-I
		prints more information
@item	-i <method>
	integration method: implicit|euler|rk4|dassl
@item	-o
		ode is same as dae
@item	-oct
		use oct files in place of m files where appropriate
@item	-opt
		optimise code generation (equivalent to -optl)
@item	-optl
		locally optimise code generation (line-by-line)
@item	-ntmpvar <N>
	declare <N> temporary variables (default=$num_tmp_var)
@item	-p
		print environment variables
@item	-partition
	partition hierachical system
@item	-pdf
		generate pdf in place of ps
@item	-q
		quiet mode -- suppress MTT banner
@item	-r
		reset time stamp on representation
@item	-s
		generate sensitivity BG (use mtt -s sSys rep lang)
@item	-ss
		use steady-state info to initialise simulations
@item	-stdin
		read input data from standard input for  simulations
@item	-sub <subsys>
	operate on subsystem <subsys>
@item	-t
		tidy mode (default)
@item	-trace
		just indicate what mtt will do - but do not do it
@item	-u
		untidy mode (leaves files in current dir)
@item	-v
		verbose mode (multiple uses increment the verbosity)
@item	--version
	print version and exit
@item	--versions
	print version of mtt and components and exit
@item	-viewlevel <N>
	view <N> levels of hierachy
@end vtable

@menu
* Experimental options::        
* Deprecated options::          
@end menu

@node Experimental options, Deprecated options, Available options, Available options
@comment  node-name,  next,  previous,  up
@subsubsection Experimental options
There are some experimental options. These have not yet been heavily tested and should be used with caution.
@vtable @code
@item	-optg
		globally optimise code generation (full vector)
@item	-make-sort
	use sorted equations (sese, generated by make)
@item	-no-reduce
	try not to use symbolic algebra
@item	-sort
		use sorted equations (sese, generated by seqn)
@end vtable

@node Deprecated options,  , Experimental options, Available options
@comment  node-name,  next,  previous,  up
@subsubsection Deprecated options
C code generation is now deprecated in favour of C++ generation
@vtable @code
@item	-c
		c-code generation
@end vtable

@node Model-specific options,  , Available options, Options
@subsection Model specific options
@cindex Model-specific options
It is often desirable to keep the options used to build a model associated with the directory in which the model is contained, along with information about compiler options or paths to component libraries. In these cases, it is convenient to create an executable shell script, say @code{call_mtt} which sets environment variables and options before calling mtt proper, for example:
@example
@verbatim
#! /bin/sh
# call_mtt: sets model specific environment and options

## Processor flags

# use 32 bit Reduce
export SYMBOLIC="reduce"

# set compiler debug and optimization options
export MTT_CXXFLAGS="${MTT_CXXFLAGS}\
        -Wall-Wno-unused -Wuninitialized\
        -O1 -march=pentiumpro -save-temps"

## Model flags

# use directory ../.. as base directory
export DIR=${DIR:-${PWD}/../..}

# additional components are in directory ../comp
export MTT_COMPONENTS="${MTT_COMPONENTS}:${DIR}/comp"

# additional constitutive relationships are in ../cr
export MTT_CRS="${MTT_CRS}:${DIR}/cr"

# C header files in ../cr/h
export MTT_CXXINCS="${MTT_CXXINCS} -I${DIR}/cr/h"

# call mtt with model specific options
exec ${MTTPATH}/mtt -cc -cr -i euler -D -optl -ntmpvar 1200 $*
@end verbatim
@end example

which may then be used in place of mtt on the command line,

@example
./call_mtt sys odeso gnuplot
@end example

@node Utilities,  , Options, User interface
@comment  node-name,  next,  previous,  up
@section Utilities
@cindex Utilities
@pindex Utilities
@strong{MTT} provides some utilities to help you keep track of model
building and to keep things clean and tidy. The commands, and there
purpose are:
@ftable @code
@item mtt help
        Lists the help/browser commands
@item mtt copy <system>
        Copies the system (ie directory and enclosed files) to the
current working directory.
@item mtt rename <old_name> <new_name>
        Renames all of the defining representations (@pxref{Defining
representations}) and textually changes each file appropriately.
@item mtt <system> clean
        Remove all files generated by @strong{MTT} associated with
system `system'.
@item mtt clean
        Remove all files generated by @strong{MTT} associated with
all systems within the current directory.
@item mtt system representation vc
        Apply version control to representation `representation' of
system `system'.
@item mtt system vc
        Apply version control to all representations (under version control)
system `system'.
@end ftable
These are described in more detail in the following sections.

@menu
* Help::                        
* Copy::                        
* Clean::                       
* Version control::             
@end menu

@node Help, Copy, Utilities, Utilities
@comment  node-name,  next,  previous,  up
@subsection Help
@cindex Help
@cindex browser
@strong{MTT} implements a browser to keep track of all the systems,
subsystems and constitutive relationships that you, and others may
write. It is invoked in the following ways:
@example
       mtt help representations
       mtt help components
       mtt help examples 
       mtt help crs
       mtt help representations <match_string>
       mtt help components <match_string>
       mtt help examples  <match_string>
       mtt help crs <match_string>
       mtt help <component_or_example_or_CR_name>
@end example

@menu
* help representations::        
* help components::             
* help examples::               
* help crs::                    
* help <name>::                 
@end menu

@node help representations, help components, Help, Help
@comment  node-name,  next,  previous,  up
@subsubsection help representations
@cindex help
@cindex representations

The command 
@example
mtt help representations
@end example
lists all of the representations  (@pxref{Representations}) available in
@strong{MTT}. These may change as the version number of @strong{MTT}
increases.

The command 
@example
mtt help representations <match_string>
@end example
lists those representation which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help representations descriptor
@end example
gives all representations containing the word @code{descriptor}.

@node help components, help examples, help representations, Help
@comment  node-name,  next,  previous,  up
@subsubsection help components
@cindex help
@cindex components

The command 
@example
mtt help components
@end example
lists all of the components  (@pxref{Components}) available in
@strong{MTT}. These may change as the version number of @strong{MTT}
increases.

The command 
@example
mtt help components <match_string>
@end example
lists those component which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help components source
@end example
gives all components containing the word @code{component}.

@node help examples, help crs, help components, Help
@comment  node-name,  next,  previous,  up
@subsubsection help examples
@cindex help
@cindex examples

This command provides a good way to get started in @strong{MTT}. having
found an interesting example, copy it to your working directory using
@example
mtt copy <example_name>
@end example
(@pxref{Copy})

@example
mtt help examples
@end example
lists all of the examples  available in
@strong{MTT}. 
This list will change as more examples are added.

The command 
@example
mtt help examples <match_string>
@end example
lists those component which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help examples pharmokinetic
@end example
gives all examples containing the word @code{pharmokinetic}.

@node help crs, help <name>, help examples, Help
@comment  node-name,  next,  previous,  up
@subsubsection help crs
@cindex help
@cindex crs

The command 
@example
mtt help crs
@end example
lists all of the constitutive relationships   (@pxref{Constitutive
relationship}) available in
@strong{MTT}. These may change as the version number of @strong{MTT}
increases.

The command 
@example
mtt help crs <match_string>
@end example
lists those constitutive relationships which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help crs sin
@end example
gives all crs containing the word @code{sin}.

@node help <name>,  , help crs, Help
@comment  node-name,  next,  previous,  up
@subsubsection help <name>
@cindex help
@cindex <name>

The command 
@example
mtt help <name>
@end example
gives a detailed description of the entity called @code{name}.

@node Copy, Clean, Help, Utilities
@comment  node-name,  next,  previous,  up
@subsection Copy
@cindex Copy

@strong{MTT} provides a way of copying examples to your working directory:
@example
mtt copy <example_name>
@end example

Use the  command
@example
mtt help examples
@end example
(@pxref{help examples}) to find something of interest.

Note that components and constitutive relationships are automatically
copied when required.

@node Clean, Version control, Copy, Utilities
@comment  node-name,  next,  previous,  up
@subsection Clean
@cindex Clean
@strong{MTT} generates a lot of representations in a number of
languages.
Some of these you will edit yourself; others can always be recreated by
@strong{MTT}. It makes sense, therefore to have a utility that removes
all of these other files when you have finished actively working with a
particular system. These are two versions:
@enumerate
@item
@code{mtt system clean}
@item
@code{mtt clean}
@end enumerate
The first removes all files that can be regenerated with @strong{MTT}
associated with system `system'; the second removes all such files
associated with all systems in the current working directory.

The files which remain after such a clean are the Defining
representations (@pxref{Defining representations}).

@node Version control,  , Clean, Utilities
@comment  node-name,  next,  previous,  up
@subsection Version control
@cindex Version control

When you are working on a modeling project, it is easy to forget what
changes you made to a system and why you made them. Sometimes, you may
regret some changes and wish to revert to an earlier version: even if
you use .old files this may be difficult to achieve safely.

These are very similar problems to those faced by software developers
and can be solved in the same way: using version control.@strong{MTT}
provides version control using the standard GNU Revision Control System
(RCS). This is hidden from the user, but is fully complementary to
direct use of RCS (e.g. via emacs vc commands) to the more experienced
user who wishes to do so.

The only files that you should ever change (i.e. the ones never
overwritten by @strong{MTT}) are the Defining representations
(@pxref{Defining representations}).

All of the files, with the exception of @code{system_abg.fig}, 
are initially created by @strong{MTT} and contain the RCS header for
version control.


The @strong{MTT} version control will automatically expand this part of
the text to include all change comments that you give it -- so will
direct use of RCS (e.g. via emacs vc commands)

The @strong{MTT} version commands are as follows:
@ftable @code
@item mtt system representation vc
        Apply version control to representation `representation' of
system `system'.
@item mtt system vc
        Apply version control to all representations (under version control)
system `system'.
@end ftable

The first is appropriate after you have made a revision to a single
file.  It will prompt you for a change comment; this will be
automatically included in the file header. In addition, enough
information will be saved to enable any  version to be retrieved via
RCS.

The second is appropriate to record the state of the entire model. This
assumes that all relevant files have been recorded by the first version
of the command.  Once again, old versions of the entire model can be
retrieved using the relevant RCS commands.

A subdirectory `RCS' is created to hold this information. You need not
bother about the contents, except that you must not delete any files
within `RCS'.

@node Creating Models, Simulation, User interface, Top
@comment  node-name,  next,  previous,  up
@chapter Creating Models
@cindex  Creating Models

@strong{MTT} helps you to analyse and transform system models --
ultimately the process of capturing the real world in a model is up to
you.  This chapter discusses the @strong{MTT} aspects of creating a
model. For convenience, this is divided into creating simple models and
creating complex models.

@menu
* Quick start::                 
* Creating simple models::      
* Creating complex models::     
@end menu

@node Quick start, Creating simple models, Creating Models, Creating Models
@section Quick start
@cindex Quick start
@pindex Quick start

It is probably worth a quick skim though @strong{MTT} to get a flavour of
what it can do before plunging into the detail of the rest of this
document. Here is a series of commands to do this.

Copy an initial set of files describing the bond graph.
@example
mtt copy rc
@end example
@noindent 
Move to it.
@example
cd rc
@end example
@noindent 
@noindent 
View the acausal bond graph (the system is called ``rc'').
@example
mtt rc abg view
@end example
@noindent 
View the causal bond graph of the system.
@example
mtt rc cbg view
@end example
@noindent 
View the corresponding ordinary differential equations (ode).
@example
mtt rc ode view
@end example
@noindent 
View the system (output) step response
@example
mtt rc sro view
@end example

@noindent 
An alternative (but more general) way of achieving the same result is
@example
mtt -cc rc odeso view
@end example

@noindent 
View the system transfer function
@example
mtt rc tf view
@end example
@noindent 
View the log modulus frequency response of the system.
@example
mtt rc lmfr view
@end example

@noindent 
View the log modulus frequency response of the system for 100
logarithmically spaced frequencies in the range 0.1 to 10
radians per second.
@example
mtt rc lmfr view 'W=logspace(-1,1,100);'
@end example

@strong{MTT} has a report generation ((@pxref{Report}) facility which
can generate a hypertext description of the system.
@example
mtt rc rep hview
@end example

The report contents are specified by the rep representation
(@pxref{Report}), in this case the corresponding file is:
@example
% %% Outline report file for system rc (rc_rep.txt)

mtt rc abg tex
mtt rc struc tex
mtt rc cbg ps
mtt rc ode tex
mtt rc ode dvi
mtt rc sm tex
mtt rc tf tex
mtt rc tf dvi
mtt rc sro ps
mtt rc lmfr ps
mtt rc odes h
mtt rc numpar txt
mtt rc input txt
mtt -cc rc odeso ps
mtt rc rep txt
@end example
A non-hypertext version can be viewed using:
@example
mtt rc rep view
@end example

Now have a go at modifying the bond graph.
@example
mtt rc abg fig
@end example
This brings up the bond graph in Xfig (@pxref{Xfig}).  Try creating a
system with two rs and 2 cs.

More examples can be found using
@example
mtt help examples
@end example
Details of an example can be found using
@example
mtt help <example_name>
@end example
and copied using
@example
mtt copy <example_name>
@end example

Lots of examples are available.
@example
mtt help examples
@end example
lists them and
@example
mtt copy <name>
@end example
gets you an example.

@ifhtml
A number of examples are to be found
<A
HREF="http://www.mech.gla.ac.uk/~peterg/software/MTT/examples/Examples/Examples.html"> here</A>.
@end ifhtml

@node Creating simple models, Creating complex models, Quick start, Creating Models
@comment  node-name,  next,  previous,  up
@section Creating simple models
@cindex Creating simple models

For then purposes of this section, simple models are those which are
built up from bond graphs involving predefined components. In contrast,
more complex systems (@pxref{Creating complex models}) need to be built
up hierarchically.

The recommended sequence of steps to create a simple model is:
@enumerate
@item Decide on a name for the system; let us call it `syst' for the
  purposes of this discussion. 
@item Invoke the Bond Graph editor to draw the acausal Bond Graph.
@example
  mtt syst abg fig
@end example
@item Draw the Bond Graph  (@pxref{Language fig (abg.fig)}), including
  the bonds (@pxref{Bonds}), the components (@pxref{Components}) and any
  artwork (@pxref{artwork}) to make the Bond Graph more readable. The
  graphical editor xfig is (@pxref{Xfig}) is self-explanatory.
  The icon library is helpful here (see @pxref{icon library}).
@item Add causal strokes (@pxref{strokes}) where needed to define
  causality. As a general rule, use the minimum number of strokes needed
  to define the problem; this will often be only on the @code{SS} components.
  (@pxref{SS components}).
  
  Save the bond graph.
  
@item View the corresponding causal bond graph.
@example
  mtt syst cbg view
@end example
@enumerate
@item 
    At this stage, @strong{MTT} will warn you that the labeled components do
    not appear in the label file - this can safely be ignored.
@item
  @strong{MTT} will indicate the percentage of components which are
    causally complete -- ideally this will be 100%. Components which are
    not causally complete will be listed.
@item
    A view of the causal bond graph will be created. The added causal
    strokes are indicated in blue, undercausal components in green and
    overcausal components in red.
@item
    If the bond graph is causally complete, proceed to the next step,
    otherwise think hard and return to the first step.
@end enumerate

@item
At this stage, no constitutive relationships have been
defined. Nevertheless, @strong{MTT} will proceed in a semi-qualitative
fashion by assuming that all constitutive relationships are unity (and
therefore linear). It may be useful at this stage to view various
derived representations to check the overall model properties before
proceeding further. For example:
@enumerate
@item
View the system Differential-algebraic equations
@example
mtt syst dae view
@end example
@item
View the system state matrices
@example
mtt syst sm view
@end example
@item
View the system transfer function
@example
mtt syst tf view
@end example
@item
View the system step response
@example
mtt syst sro view
@end example
@end enumerate

@item
As well as creating the causal bond graph, @strong{MTT} has also
generated templates for other text files 
(@pxref{Defining representations})
used to further specify the
system.
These can now be edited using your favorite text editor (@pxref{Text
editors}).

@item @strong{MTT} will now generate the representations
(@pxref{Representation summary})that you desire.
For example the system can be simulated by
@example
mtt syst odeso view
@end example
@strong{MTT} will complain if a component is named in the bond graph but
not in the label file and vice versa. This mainly to catch typing errors.

@end enumerate

@node Creating complex models,  , Creating simple models, Creating Models
@comment  node-name,  next,  previous,  up
@section Creating complex models
@cindex Creating complex models

Complex models -- in distinction to simple models (@pxref{Creating
simple models}) -- have a hierarchical structure. In particular, bond
graph components can be created by specifying their bond
graph. Typically, such components will have more than one port
(@pxref{Ports}); within each component, ports are represented by
named SS components (@pxref{Named SS components}); outwith
each component, ports are unambiguously identified by 
labels (@pxref{Port labels}) and vector labels (@pxref{Vector port labels}).

Complex models are thus created by conceptually decomposing the system
into simple subsystems, and then creating the corresponding bond graphs.
The procedure for simple systems (@pxref{Creating simple models}) is
then followed using the top level system (@pxref{Top level}); @strong{MTT} then recursively
operates on the lower level systems.

The report representation (@pxref{Report}) provides a convenient way of
viewing a complex system.

An example of such a system can be created as follows:
@example
mtt copy twolink
mtt twolink rep hview
@end example

@ifhtml
The result is <A
HREF="./examples/twolink/twolink_rep/twolink_rep.html"> here</A>.
@end ifhtml

@menu
* Top level::                   
@end menu

@node Top level,  , Creating complex models, Creating complex models
@comment  node-name,  next,  previous,  up
@subsection Top level
@cindex Top level
The top level of a complex model contains subsystems but is not, itself,
contained by other systems. 
It has the following special features:
@itemize @bullet
@item
its name is used in the mtt command as the system name.
@item
all named SS componenents (@pxref{Named SS components}) are treated as
ordinary SS components (@pxref{SS components}).
@end itemize



@c      node   next  prev  up
@node Simulation, Sensitivity models, Creating Models, Top
@chapter Simulation
@cindex Simulation
@pindex Simulation
One purpose of modelling is to simulate the modeled dynamic
system. Although this is just another transformation (@pxref{What is a
Transformation?}) and therefore is covered in the appropriate chapter
(@pxref{Representations}), it is important enough to be given its own
chapter.

Simulation is typically performed using an appropriate simulation
language (which is often inappropriately conflated with modelling
tools). @strong{MTT} provides a number of alternative routes to
simulation based on the following representations (@pxref{Representations}):
@ftable @code
@item cse
        constrained-state differential equation form
@item ode
        ordinary differential (or state-space) equations
@c  @item dae
@c          differential-algebraic (or generalised state-space) equations --
@c  these may be linear or nonlinear.
@end ftable
in each case these equations may be
linear or nonlinear.

Special cases of numerical simulation, appropriate to @emph{linear}
systems, are:
@ftable @code
@item   ir
        impulse response - state 
@item   iro
        impulse response - output 
@item   sr
        impulse response - state 
@item   sro
        impulse response - output 
@end ftable

There are a number of languages (@pxref{Languages}) which can be used to describe these
representations for the purposes of numerical simulation:
@ftable @code
@item m
        @code{octave} a high-level interactive language for numerical
        computation.
@item c
        @code{gcc} a c compiler.
@item cc
        @code{g++} a C++ front-end to gcc.
@end ftable

There are a number solution algorithms available:
@itemize @bullet
@item
explicit solution via the matrix exponential
@item
backward Euler integration (implicit)
@item
forward Euler integration (explicit)
@item
Runge Kutta IV integration (explicit, fixed step)
@item
Hybrd algebraic solver (MINPACK, Octave fsolve)
@c  @item
@c  LSODE (Hindmarsh's ODE solver as implemented in Octave)
@c  @item
@c  DASSL (Petzold's DAE solver as implemented in Octave) (Unavailable just now)
@end itemize

 However, all combinations of representation, language and solution
method are not supported by @strong{MTT} at the moment. Given a system
`system', some recommended commands are:
@ftable @code
@item mtt system iro view
        creates the impulse response of a @emph{linear} system via the
system_sm.m representation using explicit solution via the matrix exponential.
@item mtt system sro view
        creates the step response of a @emph{linear} system via the system_sm.m
representation using explicit solution via the matrix exponential.
@c  @item mtt system odeso view
@c          creates the step response of a @emph{nonlinear} system via the
@c  system_ode.m representation using either METHOD=Euler or
@c  METHOD=LSODE in the parameter file (@pxref{Simulation parameters}).
@item mtt -cc system odeso view
        creates the response of a @emph{nonlinear} system via the
system_ode.cc representation using implicit integration.
@item mtt -cc -i euler system odeso view
        creates the response of a @emph{nonlinear} system via the
system_ode.cc representation using euler integration.
@end ftable

Simulation parameters are described in the system_simpar.txt file
(@pxref{Simulation parameters}).

The steady-state solution of a system can also be
``simulated''(@pxref{Steady-state solutions}).
@menu
* Steady-state solutions::      
* Simulation parameters::       
* Simulation input::            
* Simulation logic::            
* Simulation initial state::    
* Simulation code::             
* Simulation output::           
@end menu

@node Steady-state solutions, Simulation parameters, Simulation, Simulation
@comment  node-name,  next,  previous,  up
@section Steady-state solutions 
@cindex Steady-state solutions

@menu
* Steady-state solutions - numerical(odess)::  
* Steady-state solutions - symbolic (ss)::  
@end menu

@node Steady-state solutions - numerical(odess), Steady-state solutions - symbolic (ss), Steady-state solutions, Steady-state solutions
@comment  node-name,  next,  previous,  up
@subsection Steady-state solutions (odess)
@cindex Steady-state solutions - numerical

@strong{MTT} can compute the steady-state solutions of an ordinary
differential equation; this used the octave function `fsolve'. The
solution is computed as a function of time using the input specified in
the input file. The simulation parameter file (@pxref{Simulation
parameters}) is used to provide the time scales.

For example
@example
mtt copy rc
cd rc
mtt rc odess view
@end example

@node Steady-state solutions - symbolic (ss),  , Steady-state solutions - numerical(odess), Steady-state solutions
@comment  node-name,  next,  previous,  up
@subsection Steady-state solutions (ss) 
@cindex Steady-state solutions - symbolic
A rudimentary form of steady-state solution exists in mtt.
The steady states and inouts are supplied by the user in the file
system_simpar.r and the corresponding output and sate derivative
computed by @strong{MTT} using
@example
mtt system ss view
@end example

For example
@example
mtt copy rc
cd rc
mtt rc sspar view
mtt rc ss view
@end example


@node Simulation parameters, Simulation input, Steady-state solutions, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation parameters
@cindex Simulation parameters

Simulation parameters are set in the system_simpar.txt file. At the
moment this sets the following variables:
@itemize @bullet
@item LAST
        the last simulation time
@item DT
        the incremental time (for plotting)
@item STEPFACTOR
        the number of integration steps per DT -- thus the integration
        interval is DT/STEPFACTOR
@c ; for sparse implicit integration (@pxref{Sparse
@c implicit integration}) the number of conjugate-gradient minimisation
@c steps.
@c  @item METHOD
@c          The integration methods available appear in the following table
@item WMIN
        Minimum frequency = 10^WMIN
@item WMAX
        Maximum frequency = 10^WMAX
@item WSTEPS
        Number of Frequency steps.
@item INPUT
        The input index for frequency response
@end itemize

There are a number of solution algorithms
@itemize @bullet
@item Euler
        basic Euler integration (@pxref{Euler integration}). This method
is simple, but not recommended for stiff systems.
@item Implicit
        semi-implicit integration  (@pxref{Implicit integration}) - uses the smx representation to give
        stability.
@item Runge Kutta IV
        fixed step Runge Kutta fourth order integration (@pxref{Runge Kutta IV integration}).
@item Hybrd
        numerical algebraic equation solver
        

@c @item ImplicitS
@c         Sparse semi-implicit integration  (@pxref{Sparse implicit integration})
@c -- takes advantage of the sparsity of the A matrix.
@c @item LSODE
@c         the variable step-size method that comes with Octave (@pxref{Octave}).
@end itemize

@menu
* Euler integration::           
* Implicit integration::        
* Runge Kutta IV integration::  
* Hybrd algebraic solver::      
@end menu

@node Euler integration, Implicit integration, Simulation parameters, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Euler integration
@cindex Euler integration
Euler integration approximates the solution of the Ordinary Differential Equation 
@example
dx/dt = f(x,u)
@end example
by
@example
x := x + f(x,u)*DDT
@end example
where
@example
DDT = DT/STEPFACTOR
@end example
If the system is linear, stability is ensured if the integer STEPFACTOR
is chosen to be greater than the real number
@example
(maximum eigenvalue of -A)*DT/2
@end example
where A is the nxn matrix appearing in
@example
f(x,u) = Ax + Bu
@end example
If the system is non linear, the linearised system matrix A should act
as a guide to the choice of STEPFACTOR.

@node Implicit integration, Runge Kutta IV integration, Euler integration, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Implicit integration
@cindex Implicit integration
Implicit integration approximates the solution of the Ordinary Differential Equation 
@example
dx/dt = f(x,u)
@end example
by
@example
(I-A*DT)x := (I-A*DT)x + f(x,u)DT
@end example
where A is the linearised system matrix. This implies the solution of N
(=number of states) linear equations at each sample interval. The OCTAVE
version used the `\' operator to solve the set of linear equations, the
C version uses LU decomposition.

If the system is linear, stability is ensured unconditionaly. If the
system is non-linear, then the method still works well.

This method is nice in that choice of DT trades of accuracy against
computation time without compromising stability. In addition, the
correct stready-state values are achieved.

This approach can also be used for constrained state equations of the
form:
@example
E(x) dx/dt = f(x,u)
@end example
where E(x) is a state-dependent matrix. The approximate solution is then
given by:
@example
(E(x)-A*DT)x := (E(x)-A*DT)x + f(x,u)DT
@end example
which reduces to the ordinary differential equation case when E(x)=I.

The _smx representation includes the E matrix.

@node Runge Kutta IV integration, Hybrd algebraic solver, Implicit integration, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Runge Kutta IV integration
Runge Kutta IV approximates the solution of the Ordinary Differential Equation

@example
dx/dt = f(x,t)
@end example

by

@example
x := x + (DT/6)*(k1 + 2*k2 + 2*k3 + k4)
@end example

where

@example
k1 := f(x,t)
k2 := f(x+(1/2)*k1,t+(1/2)*DT)
k3 := f(x+(1/2)*k2,t+(1/2)*DT)
k4 := f(x+k3,t+DT)
@end example

The @strong{MTT} implementation of Runge-Kutta integration
is a fourth order, fixed-step, explicit integration method.

For some systems of equations, the increased accuracy of using a fourth order
method can allow larger step-lengths to be used than would allowed by the
 lower order Euler integration method.

It should be noted that during the interemediate calculations (k1...k4),
 the input vector @code{u} is not advanced w.r.t. time; the system inputs are
assumed to be constant over the period of the integration step-length.

@node Hybrd algebraic solver,  , Runge Kutta IV integration, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Hybrd algebraic solver

The hybrd algebraic solver of @uref{http://www.netlib.org/minpack/hybrd.f,MINPACK},
which is used by Octave in the @code{fsolve} routine, may be used in conjunction
with one of the other integration methods to solve semi-explicit, index 1, differential
algebraic equations; these may be generated in @strong{MTT} models by use of 
@code{unknown} SS Components @pxref{SS component labels}.

This method requires that compiled simulation code is used; either -cc or -oct.
To perform a simulation based on a model @code{sys},

@example
mtt -cc -ae hybrd -i euler sys odeso view
@c XXX: should be daeso view?
@end example

@strong{MTT} will attempt to minimise the residual error at each integration time-step
using the hybrd routine.

This method of simulation is particularly well suited to stiff systems where very fast
dynamics are of little interest. Care must be taken to ensure that an acceptable level
of convergence is achieved by the solver for the system under investigation.
@c XXX: tolerance option

@c @node Sparse implicit integration,  , Implicit integration, Simulation parameters
@c @comment  node-name,  next,  previous,  up
@c @subsection Sparse implicit integration
@c @cindex Sparse implicit integration
@c This is an experimental approach for large (N>50) systems.

@c Implicit integration (@pxref{Implicit integration}) requires the
@c solution of N linear equations at each step. This is an O(N^3) operation
@c which can be time consuming for large (N>50) systems. However, the A
@c matrix (and hence the (I-A*DT) matrix) is often sparse - most elements
@c are zero.

@c This method uses a conjugate-gradient optimisation method to solve the
@c linear equations
@c @example
@c (I-A*DT)x := (I-A*DT)x + f(x,u)DT
@c @end example
@c by recasting them as the minimisation of the quadratic function
@c @example
@c [(I-A*DT)x_new - (I-A*DT)x_old + f(x,u)DT]^2
@c @end example
@c with respect to x_new. This is solved by the conjugate gradient method.
@c MTT generates two representations _smxx.m and _smxtx to compute
@c (I-A*DT)x and (I-A*DT)'x respectively making full use of the sparsity of
@c the (I-A*DT) matrices to speed up the minimisation procedure.

@c A fixed number of iterations (STEPFACTOR) are used in each optimisation
@c to give a fixed simulation time. This must be chosen by the user, but
@c between 5N and 10N seems ok. Note that the initial value of the
@c optimisation is x_old.

@node Simulation input, Simulation logic, Simulation parameters, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation input
@cindex Simulation input
This is defined in the system_input.txt file. A default file is created
automatically by @strong{MTT}. This is done explicitly by
@example
mtt system input txt
@end example
If the file already exists, the same command checks that all inputs are
defined and that all defined inputs exist in the system and promts the
user to correct discrepancies.

Inputs are defined by the full system name appearing in the structure
file (@pxref{Structure (struc)}). They can depend on states (again defined by
name), time (defined by t) and parameters

For example:
@example
system_pump_l_1_u       = 4e5*atm;
system_pump_r_1_u       = 4e5*(t<10)*atm;
system_ss_i             = 0*kg;
system_ss_o             = 3e-3*kg;
system_v_1_u            = (t>10);
system_v_ll_1_u         = 1;
system_v_lr_1_u         = (t<10);
system_v_ul_1_u         = 0;
system_v_ur_1_u         = (t>10);
@end example

@node Simulation logic, Simulation initial state, Simulation input, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation logic
@cindex Simulation logic
This is defined in the system_logic.txt file. A default file is created
automatically by @strong{MTT}. This is done explicitly by
@example
mtt system logic txt
@end example
If the file already exists, the same command checks that the logic
corresponding to all switch states (@pxref{Switched systems}) are
defined and that all defined logic exists in the system and promts the
user to correct discrepancies.

Logical inputs are defined by the full system name corresponding to
MTT_switch components appearing in the structure file (@pxref{Structure
(struc)}) @emph{with `_logic' appended}. They can depend on states (again defined by name), time
(defined by t) and parameters

For example:
@example
bounce_ground_1_mtt_switch_logic	= bounce_intf_1_mtt3<0;
@end example

@node Simulation initial state, Simulation code, Simulation logic, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation initial state
@cindex Simulation initial state
This is defined in the system_state.txt file. A default file is created
automatically by @strong{MTT}. This is done explicitly by
@example
mtt system state txt
@end example
If the file already exists, the same command checks that all states are
defined and that all defined states exist in the system and prompts the
user to correct discrepancies.

States are defined by the full system name appearing in the structure
file (@pxref{Structure (struc)}). They can depend on parameters.
For example
@example
system_c_l	= (1e4/k_l)/kg;
system_c_ll	= (1e4/k_s)/kg;
system_c_lr	= (1e4/k_s)/kg;
system_c_u	= (1e4/k_l)/kg;
@end example


@c  The initial state of a simulation of is set in the @code{state}
@c  representation with the language @code{txt}.

@c  As usual, @strong{MTT} defaults this for you. There are two
@c  possibilities
@c  @itemize @bullet
@c  @item
@c  The -ss switch is not present: the states default to zero
@c  @item
@c  The -ss switch is present: the states default to those set in the
@c  sspar.r file.
@c  @end itemize

@node Simulation code, Simulation output, Simulation initial state, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation code
simulation code can be generated by @strong{MTT} in the form
of the @code{ode2odes} transformation. This can be produced in a number
of languages, including .m, .oct, C and C++ @pxref{Languages}.

To generate simulation code in C (deprecated):
@example
mtt -c [options] sys ode2odes c
@end example

Similarly, to generate C++ code:
@example
mtt -cc [options] sys ode2odes cc
@end example

To generate an executable based on the C++ representation:
@example
mtt -cc [options] sys ode2odes exe
@end example

@menu
* Dynamically linked functions::  
@end menu

@node Dynamically linked functions,  , Simulation code, Simulation code
@comment  node-name,  next,  previous,  up
@subsection Dynamically linked functions
@cindex Compiling C++ files
@cindex mex files
@cindex oct files
Some model representations can be compiled into dynamically loaded
code (shared objects) which are compiled prior to use in other
modelling and simulation environments; in particular, .oct files can
be generated for use in GNU Octave (@pxref{Creating GNU Octave .oct
files}) and .mex files can be generated for use in Matlab
(@pxref{Creating Matlab .mex files}) or Simulink (@pxref{Embedding MTT
models in Simulink}).  The use of compiled (and possibly
compiler-optimised) code can offer significant processing speed
advantages over equivalent interpreted functions (e.g. .m files) for
computationally intensive procedures.

The C++ code generated by @strong{MTT} allows the same code to be
generated as standalone code, Octave .oct files or Matlab .mexglx
files. Although @strong{MTT} usually takes care of the compilation
options, if it is necessary to compile the code on a machine on which
@strong{MTT} is not installed, the appropriate flag should be passed
to the compiler pre-processor:
@itemize @bullet
@item
@code{-DCODEGENTARGET=STANDALONE}
@item
@code{-DCODEGENTARGET=OCTAVEDLD}
@item
@code{-DCODEGENTARGET=MATLABMEX}
@end itemize

@node Simulation output,  , Simulation code, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation output
@cindex Simulation output
The view (@pxref{Views}) representation provides a graphical
representation of the results of a simulation; the postscript language
provides the same thing in a form that can be included in a document.

These are two simulation output representations
@ftable @code
@item odes 
        ordinary differential equation solution (states)
@item odeso
         ordinary differential equation solution (output)
@end ftable    

Particular output variables can be selected by adding a fourth argument
in one of 2 forms
@ftable @code
@item 'name1;name2;..;namen' 
        plot the variables with names na1 .. namen against time
@item 'name1:name2'
                plot the variable with  name2 against that with name 1
@end ftable    

An example of plotting a single variable against time is:
@example
mtt -o -cc -ss OttoCycle odeso ps 'OttoCycle_cycle_V'
@end example
An example of plotting one variable against another is:
@example
mtt -o -cc -ss OttoCycle odeso ps 'OttoCycle_cycle_V:OttoCycle_cycle_P'
@end example

@menu
* Viewing results with gnuplot::  
* Exporting results to SciGraphica::  
@end menu

@node Viewing results with gnuplot, Exporting results to SciGraphica, Simulation output, Simulation output
@comment  node-name,  next,  previous,  up@subsection
@subsection Viewing results with gnuplot
@cindex gnuplot

Simulation plots may be conveniently selected, viewed with
@uref{http://www.gnuplot.org,gnuplot} 
and saved to file (in PostScript format) using the command

@example
mtt [options] rc odeso gnuplot
@end example

This will cause a menu to be displayed, from which states and outputs may be selected for viewing. Clicking on a @emph{parameter name} will, by default, cause the time history of the selected parameter to be displayed.

As with @strong{xMTT} (@pxref{Menu-driven interface}), the Wish Tcl/Tk interpreter must be installed to make use of this feature.

@node Exporting results to SciGraphica,  , Viewing results with gnuplot, Simulation output
@comment  node-name,  next,  previous,  up
@subsection Exporting results to SciGraphica
@cindex SciGraphica

Simulation results can be converted into an XML-format
@uref{http://scigraphica.sourceforge.net,SciGraphica} (version 0.61)
@emph{.sg} file with the command

@example
mtt [options] sys odes sg
@end example

The SciGraphica file will contain two worksheets, X_sys and Y_sys, containing
the state and output time-histories from the simulation.

@c      node   next  prev  up
@node   Sensitivity models, Representations, Simulation, Top
@chapter Sensitivity models
@cindex Sensitivity models
@pindex Sensitivity models

The sensitivity model of a system is a set of equations giving the
sensitivity of the system outputs with respect to system parameters.
@strong{MTT} has built in methods for assisting with the development of
such models.

This feature is experimental at the moment, but the following example
gives an idea of what can be achieved.
@example
mtt copy rc
cd rc
mtt -s src ode view
mtt -s src odeso view
@end example
The sensitivity system src is automatically created from the system rc
using the predefined sR and sC components together with vector junctions
(@pxref{Vector components}).  The four outputs are the two system
outputs plus the two sensitivity functions.

An alternative route is to create the sensitivity functions by symbolic
differentiation.
The following sensitivity representations are available:
@ftable @code
@item   scse
        sensitivity constrained-state equations
@item   sm
        sensitivity state matrices
@item   scsm
        sensitivity constrained-state matrices
@end ftable



@c      node   next  prev  up
@node   Representations, Extending MTT, Sensitivity models, Top
@chapter Representations
@cindex Representations
@pindex Representations
@cindex Defining representations
@cindex Representations, defining

As discussed in @ref{What is a Representation?}, a system has many
representations. The purpose of @strong{MTT} is to provide an easy way to
generate such representation by applying the appropriate sequence of 
transformations. The representations supported by @strong{MTT} are
summarised in @ref{Representation summary}.

There is a two-fold division of representations into those with which the user
defines the system and its various attributes, and those which are
derived from these. The @emph{defining representations} are listed in
@ref{Defining representations}. 

Each representation is implemented in one or more languages depending on
its use. These languages are discussed in @ref{Languages} and are
associated with appropriate tools for modifying or viewing the
representations. 

@menu
* Representation summary::      
* Defining representations::    
* Verbal description (desc)::   
* Acausal bond graph (abg)::    
* Acausal bond graph - LaTeX ready (labg)::  
* Stripped acausal bond graph (sabg)::  
* Labels (lbl)::                
* Structure (struc)::           
* Constitutive Relationship (cr)::  
* Parameters::                  
* Causal bond graph (cbg)::     
* Elementary system equations::  
* Differential-Algebraic Equations::  
* Constrained-state Equations::  
* Ordinary Differential Equations::  
* Descriptor matrices::         
* Report::                      
@end menu

@node Representation summary, Defining representations, Representations, Representations
@comment  node-name,  next,  previous,  up
@section Representation summary
@cindex Representation summary

Some of the the representations 
available in @strong{MTT} are (in alphabetical order):
@ftable @code
@item   abg
        acausal bond graph 
@item   cbg
        causal bond graph 
@item   cr
        constitutive relationship for each subsystem 
@item   cse
        constrained-state equations 
@item   csm
        constrained-state matrices 
@item   dae
        differential-algebraic equations 
@item   daes
        dae solution - state 
@item   daeso
        dae solution - output 
@item   def
        definitions - system orders etc. 
@item   desc
        Verbal description of system 
@item   dm
        descriptor matrices 
@item   ese
        elementary system equations 
@item   fr
        frequency response 
@item   input        
        numerical input declaration 
@item   ir
        impulse response - state 
@item   iro
        impulse response - output 
@item   lbl
        label file 
@item   lmfr
        loglog modulus frequency response 
@item   lpfr
        semilog phase frequency response 
@item   nifr
        Nichols style frequency response 
@item   numpar
        numerical parameter declaration 
@item   nyfr
        Nyquist style frequency response 
@item   obs
        observer equations for CGPC 
@item   ode
        ordinary differential equations 
@item   odes
        ode solution - state 
@item   odes
        ODE simulation header file 
@item   odeso
        ode solution - output 
@item   odess
        ode numerical steady-states - states 
@item   odesso
        ode numerical steady-states - outputs 
@item   rbg
        raw bond graph 
@item   rep
        report 
@item   rfe
        robot-form equations 
@item   sabg
        stripped acausal bond graph 
@item   simp
        simplification information 
@item   sm
        state matrices 
@item   smx
        state matrices containing explicit states and inputs
@item   sms
        ode 
@item   smss
        SM simulation header file 
@item   sr
        step response - state 
@item   sro
        step response - output 
@item   ss
        steady-state equations 
@item   sspar
        steady-state definition 
@item   struc
        structure - list of inputs, outputs and states 
@item   sub
        Executable subsystem list 
@item   sub
        LaTeX subsystem list 
@item   sympar
        symbolic parameters 
@item   tf
        transfer function 
@end ftable
A complete list can be found via the @code{help representations} command
(@pxref{help representations}). 

Many of these representations have more than one language (@pxref{Representations}) associated
with them.

Some of these representations define the system (@pxref{Defining
representations}).

@node Defining representations, Verbal description (desc), Representation summary, Representations
@comment  node-name,  next,  previous,  up
@section Defining representations
@cindex Defining representations

The following representations define the system and therefore must,
ultimately, be defined by the user. However, all of these are assigned
default values by @strong{MTT} and may then be subsequently edited
(@pxref{Text editors}) viewed or operated on by the appropriate tools
(@pxref{Language tools}).
@vtable @code
@item system_abg.fig
        the acausal bond graph (@pxref{Acausal bond graph (abg)})
@item system_lbl.txt
        the label file (@pxref{Labels (lbl)})
@item system_desc.tex
        the description file (@pxref{Detailed})
@item system_simp.r
        algebraic simplifications to make output more readable
        (@pxref{Symbolic parameters for simplification (simp.r)})
@item system_subs.r
        algebraic substitutions to resolve, eq trig. identities
        (@pxref{Symbolic parameters (subs.r)})
@item system_simpar.txt
        simulation parameters (@pxref{Simulation parameters})
@item system_numpar.txt
        numerical parameters (@pxref{Numeric parameters (numpar)})
@item system_input.txt
        the system input for simulations (@pxref{Simulation input})
@item system_logic.txt
        the  switching logic for simulations (@pxref{Simulation logic})
@item system_sspar.r
        defines the system steady-state (@pxref{Steady-state solutions - symbolic (ss)})
@end vtable

@node Verbal description (desc), Acausal bond graph (abg), Defining representations, Representations
@comment  node-name,  next,  previous,  up
@section Verbal description (desc)
@cindex Verbal description (desc)

Systems can be documented in LaTeX using the _desc.tex file. This file
is included in the report (@pxref{Report}) if the abg tex option
is included in the rep.txt file.  As usual, @strong{MTT} provides a
default text file to be edited by the user (@pxref{Text editors}).


@c      node   next  prev  up
@node   Acausal bond graph (abg), Acausal bond graph - LaTeX ready (labg), Verbal description (desc), Representations
@section Acausal bond graph (abg)
@cindex Acausal bond graph (abg)
@pindex Acausal bond graph (abg)

The acausal bond graph is the main input to @strong{MTT}. It is up to you, as a
system modeler, to distill the essential aspects of the system that you
wish to model and capture this information in the form of a bond graph.

The inexperienced modeler may wish to look in one of the standard
textbooks and copy some bond graphs of  systems to get going.


To create the acausal bond graph of system `sys' in language fig type:
@example
mtt sys abg fig
@end example
To create the acausal bond graph of system `sys' in language m type:
@example
mtt sys abg m
@end example
To view the acausal bond graph of system `sys' type:
@example
mtt sys abg view
@end example

@menu
* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      
@end menu

@node Acausal bond graph - LaTeX ready (labg), Stripped acausal bond graph (sabg), Acausal bond graph (abg), Representations
@section Acausal bond graph - LaTeX ready (labg)
@cindex Acausal bond graph - LaTeX ready (labg) 
@pindex Acausal bond graph - LaTeX ready (labg)
This representation exists in the fig  (@pxref{Language fig (abg.fig)})
only. It is used for high-quality figures generated using fig2dev with
the -Lpstex option.

@menu
* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      
@end menu

@node Language fig (abg.fig), Language m (rbg.m), Acausal bond graph - LaTeX ready (labg), Acausal bond graph - LaTeX ready (labg)
@subsection Language fig (abg.fig) 
@cindex Language fig (abg.fig) 
@pindex Language fig (abg.fig) 

A bond graph is made up of:
@ftable @code
@item bonds
        To connect components together.
@item strokes
        To indicate causality.
@item components
        Either simple or compound.
@item artwork
        Irrelevant to the system but useful to the user.
@end ftable

An icon library of bonds, components and other symbols is available
within xfig (@pxref{icon library}).




@menu
* icon library::                
* bonds::                       
* strokes::                     
* components::                  
* Simple components::           
* SS components::               
* Simple components - implementation::  
* Compound components::         
* Named SS components::         
* Coerced bond direction::      
* Port labels::                 
* Vector port labels::          
* Port label defaults::         
* Vector components::           
* artwork::                     
* Valid names::                 
@end menu

@node icon library, bonds, Language fig (abg.fig), Language fig (abg.fig)
@subsubsection Icon library
@cindex Icon
@cindex library
A number of predefined iconic symbols are available within xfig. 
@example
Click onto the library icon
Click onto the library pull-down menu and select BondGraph
Select iconic symbols from the presented list
@end example

@node bonds, strokes, icon library, Language fig (abg.fig)
@subsubsection Bonds
@cindex bonds
@pindex bonds

Bonds are represented by polylines with two segments. They must be the
default style (i.e. plain not dashed or dotted). The shortest segment is
taken to be the half-arrow. its positioning is significant because:
@itemize @bullet
@item
It points in the direction of power flow; thus a bond normally points
towards C, I and R components.
@item
the corresponding side of the bond indicates flow causality; the other
side represents effort causality. This is significant when using causal
half-strokes (@pxref{strokes}). Please adopt the convention of having
the half-arrows below horizontal bonds and to the right of vertical bonds.
@end itemize



@c      node   next  prev  up
@node strokes, components, bonds, Language fig (abg.fig)
@subsubsection Strokes
@cindex strokes
@pindex strokes

Causal strokes are represented by single-segment polylines.
There are two sorts of strokes:
@itemize @bullet
@item
@emph{Full} strokes: these are the usual bond-graph strokes and determine
both the effort and flow causality in the usual way. The @emph{centre} of the
stroke should be at about one end of the bond and be at right angles to
it.
@item
@emph{Half} strokes: these are an innovation in @strong{MTT} and allow you to
specify the effort and flow causality independently. The @emph{end} of the
stroke should be at about one end of the bond and be at right angles to
it. If the causal half-stroke is on the @emph{same} side as the half-arrow
(@pxref{bonds}) then it determines @emph{flow} causality; if, on the other
hand, it is on the @emph{opposite} side to the half-arrow
(@pxref{bonds}) then it determines @emph{effort} causality.
Two half strokes on the @emph{same}, but on @emph{opposite} sides of the
bond are equivalent to a a full stroke at the same end of the bond.
@end itemize

@strong{MTT} is reasonably forgiving; but a neat diagram will be less ambiguous to
you as well as to @strong{MTT}.

Causality is indicated as follows:
@itemize @bullet
@item 
@emph{Effort} is imposed at the @emph{same} end as the stroke.
@item 
@emph{Flow} is imposed at the @emph{opposite} end as the stroke.
@end itemize



@c      node   next  prev  up
@node components, Simple components, strokes, Language fig (abg.fig)
@subsubsection Components
@cindex components
@pindex components

Components are represented by a text string in fig.  The recommended
style is: 20pt, Times-Roman and centre justified.

The component text string can be of the following forms:
@ftable @code
@item type
Just the type of the component is indicated. Components may be either
Simple components (@pxref{Simple components}) or Compound components
(@pxref{Compound components}).  For example:
@example
R
@end example
@item type:label
Both the type and the label of the component are given. The type must be
a valid name (@pxref{Valid names}.The name provides a link to more
information to be found in @xref{Labels (lbl)}. For example:
@example
R:r
@end example
@item type:label:cr
Not only are the type and the label of the component given, but also the
component cr argument. The type must be
a valid name (@pxref{Valid names}.The name provides a link to more
information to be found in @xref{Labels (lbl)}. For example:
@example
R:r:flow,r
@end example
@item type:label:expression
Expression is a mathematical expression relating the effort (called
mtt_e) to the flow (called mtt_f).
For example the following three forms are equivalent
@example
R:r:mtt_e=r*mtt_f
R:r:mtt_e-r*mtt_f=0
R:r:mtt_f=mtt_e/r
@end example
A non-linear example is:
@example
R:r:mtt_e = sin(mtt_f)
@end example

@item type*n
The name, together with the number @samp{n} of repetitions of the
component, are given. This repetition only makes sense if the component
has an even number of ports (@pxref{Port labels}); n copies of the component
are concatenated with odd Named ports (@pxref{Port labels}) of the
component being connected to the even Named ports of the previous
component in the chain in numerical order.  This feature is particularly
useful if the component is compound and can be used for, example to give
a lumped approximation of a distributed system. For example:
@example
MySystem*25
@end example
@item type:label*n
This complete form and is a combination of the simpler forms. For
example:
@example
MySystem:MyLabel*25
@end example

@end ftable

@node Simple components, SS components, components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Simple components
@cindex Simple components

The following simple components are defined in MTT.

@ftable @code
@item R
         Standard one-port R
@item C
         Standard one-port C
@item I
         Standard one-port I
@item SS
        Source-sensor
@item TF
        Transformer
@item GY
        Gyrator
@item AE
        Effort amplifier
@item AF
        Flow amplifier
@item CSW
         Switched one-port C
@item ISW
         Switched one-port I
@end ftable

@menu
* SS components::               
* Simple components - implementation::  
@end menu

@node SS components, Simple components - implementation, Simple components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection SS components
@cindex SS components

@iftex
$$

@end iftex


@code{SS} components provide input and output variables for a system;
Named SS components (@pxref{Named SS components}) provide this for
subsystems.

@node Simple components - implementation, Compound components, SS components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Simple components - implementation
@cindex  Simple components - implementation

Each simple component, with name NAME, is defined by two m files:
@ftable @code
@item NAME_cause.m
        defines the possible causal patterns for the component
@item NAME_eqn.m
        defines the equations generated 
@end ftable
Only the experienced user would normally define simple components -
Compound components (@pxref{Compound components}) are recommended for
DIY components.

@node Compound components, Named SS components, Simple components - implementation, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Compound components
@cindex  Compound components
@cindex Named SS
Compound components are systems described by bond graphs and implemented
by MTT. They have special SS components, Named SS components
(@pxref{Named SS components}), to indicate connections to the
encapsulating system.

Like any other system, they are described by a graphical Bond Graph description
(@pxref{Language fig (abg.fig)}), and a label file (@pxref{Labels (lbl)}).

By convention, all of the files describing a component live in a
directory with the same name as the component.

@menu
* Named SS components::      
@end menu

@node Named SS components, Coerced bond direction, Compound components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Named SS components
@cindex Named SS components

Named SS components provide the link from the system which @emph{defines} 
compound component to the system which @emph{uses} a compound
component @pxref{Compound components}.
A named SS components is of the form
@code{SS:[name]};

Where `name' is a name consisting of alphanumeric characters and
underscore; for example:
@example
SS:[Mechanical_1]
@end example
Each such named SS provides one of the ports
(@pxref{Ports}).
The direction of the named SS components.
(@pxref{Named SS components}) 
is coerced (@pxref{Coerced bond direction}) to have the same direction
as the bond connected to the corresponding port. Thus the direction of
the  direction of the named SS components has no significance unless the
component is at the top level of a system.

If a named SS component exists at the top level (@pxref{Top level})
and is treated as an
ordinary SS component with the given direction and with the attributes
specified in the label file (@pxref{Labels (lbl)}).

@node Coerced bond direction, Port labels, Named SS components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Coerced bond direction
@cindex Coerced bond direction
@pindex Coerced bond direction
Named SS components (@pxref{Named SS components}) provide the mechanism
for declaring the ports (@pxref{Ports}) of a component. The
corresponding bond has a direction. However, under some circumstances,
it may be useful to reverse this direction. @strong{MTT} provides a
coercion mechanism for this: the the direction of the bond attached to
the named SS component (@pxref{Named SS components}) is replaced by the
direction of the bond attached to the component port.

@node Port labels, Vector port labels, Coerced bond direction, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Port labels
@cindex ports
@pindex ports
Most multi-port components have ports 
@pxref{Ports})which display different
behaviors; the exception to this is the junction (@code{0} and @code{1})
components. For this reason, @strong{MTT} provides a method for unambiguously
identifying the ports of a multi-port component by port labels.

A port label is indicated by a name within parentheses of the form
@code{[name]}, where `name' is a name consisting of alphanumeric
characters and underscore; for example:
@example
[Mechanical_1]
@end example
This provides a label for corresponding to the component to which the
nearest bond-end is attached.

The following rules must be be obeyed:
@itemize @bullet
@item
If a component has any port labels at all, there must be one for each
port of the component.
@c @item
@c If a component is to be used repetitively (see @ref{components}), it
@c must have an even number of ports and the odd ports are connected to the
@c even points within the chain of components.
@end itemize

Port labels may be grouped into vector port labels (@pxref{Vector port
labels}). Components with compatible (ie containing the same number of ports)
vector ports may be connected by a @emph{single} bond
(@pxref{Bonds}); such a bond implies the corresponding number of bonds
(one for each element of the vector port label). All such bonds inherit
the same direction and any @emph{explicit} causal strokes (@pxref{strokes})

@node Vector port labels, Port label defaults, Port labels, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Vector port labels
@cindex vector port labels
@cindex port labels
Port labels (@pxref{Port labels}) may be grouped into vector port
labels of the form @code{[name1,name2,name3]}. 
@example
[Mechanical_1,Electrical,Hydraulic_5]
@end example

@node Port label defaults, Vector components, Vector port labels, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Port label defaults
@cindex Port label defaults
@pindex Port label defaults
Whether impicitly or explicity, all ports of components (with the
exception of 0 and 1 junctions) must have labels  (@pxref{Port
labels}). However, these can be omitted from the bond graph in the
following circumstances and default labels are supplied by @strong{MTT}.
@enumerate
@item A single unlabled inport defaults to [in]
@item A single unlabled outport defaults to [out]
@end enumerate

These defaults may, in turn be aliases (@pxref{Aliases}) for port labels
(@pxref{Port labels}) or vector port labels (@pxref{Vector port
labels}).  Combining the default and alias mechanism is a powerful tool
for creating uncluttered, yet complex, bond graph models.

@node Vector components, artwork, Port label defaults, Language fig (abg.fig)
@subsubsection Vector Components
@cindex Vector components
@pindex Vector components
Vectors of components can be created in four cases:
@code{0} junctions,
@code{1} junctions,
@code{SS} components and
@code{SS} port components.


In each case, the presence of a vector component is indicated by a
single port label  (@pxref{Port labels}) of one of two forms:
@enumerate
@item containing numerals from 1 to
the order of the vector. Thus a vector of 3 components is indicated by a
port label of the form [1,2,3].
@item  1: followed by
the order of the vector. Thus a vector of 3 components is indicated by a
port label of the form [1:3].
@end enumerate


Within the corresponding label file (@pxref{Labels (lbl)}), the
components of a vector port can be accessed using _i where i is the
corresponding index. Thus a port SS:[Electrical] appearing near the port
label  [1,2,3] could contain the port alias (@pxref{Port aliases})
@example
%ALIAS  in Electrical_1,Electrical_2,Electrical_3
@end example

@node artwork, Valid names, Vector components, Language fig (abg.fig)
@subsubsection Artwork
@cindex artwork
@pindex artwork
You are encouraged to annotate your bond graphs extensively - this makes
them an immediately readable document whilst retaining the precise and
unambiguous expressive power of the bond graph.

You may add any Fig (@pxref{Fig}) object to the bond graph as long as it
will not be interpreted as part of the bond graph.  
The reccommended way to acheive this is to put the  Bond Graph at depth
0,10,20 etc (ie depth modulo 10 is zero) and artwork at any other depth. 
@c  The recommended way to do this is to @emph{put all artwork at or below
@c  Depth 1} in the figure. @strong{MTT} ignores all objects not at depth 0.


For compatibility with earlier versions of @strong{MTT}, the following
objects are ignored even at level 0. However, their use is strongly
discouraged.
@itemize @bullet
@item
Adding text is OK as long as it cannot be confused with components
(@pxref{components}). In particular, you can include invalid component
characters such as white space, @code{"}, @code{'}, @code{!} etc.
@item
Adding boxes, arcs etc is always OK.
@item
Adding dotted or dashes lines is always OK.
@end itemize

The stripped abg file (sabg) (@pxref{Stripped acausal bond graph
(sabg)})
shows only those parts of the diagram recognised by @strong{MTT} and is
therefore useful for distinguishing artwork.
 
@node Valid names,  , artwork, Language fig (abg.fig)
@subsubsection Valid Names
@cindex valid name
@pindex valid name
A valid name is a text string containing alphanumeric characters.  It
must @strong{NOT} contain underscore @samp{_}, hyphen @samp{-}, @samp{:}
or @samp{*}.

The following names should be avoided
@example
if endif
@end example


The following reserved words in reduce should also be avoided (with any case)
@example
Commands ALGEBRAIC ANTISYMMETRIC ARRAY BYE CLEAR CLEARRULES COMMENT
CONT DECOMPOSE DEFINE DEPEND DISPLAY ED EDITDEF END EVEN FACTOR FOR
FORALL FOREACH GO GOTO IF IN INDEX INFIX INPUT INTEGER KORDER LET
LINEAR LISP LISTARGP LOAD LOAD PACKAGE MASS MATCH MATRIX MSHELL
NODEPEND NONCOM NONZERO NOSPUR ODD OFF ON OPERATOR ORDER OUT PAUSE
PRECEDENCE PRINT PRECISION PROCEDURE QUIT REAL REMFAC REMIND RETRY
RETURN SAVEAS SCALAR SETMOD SHARE SHOWTIME SHUT SPUR SYMBOLIC
SYMMETRIC VECDIM VECTOR WEIGHT WRITE WTLEVEL

Boolean Operators EVENP FIXP FREEOF NUMBERP ORDP PRIMEP

Infix Operators := = >= > <= < => + * / ^ ** . WHERE SETQ OR AND
MEMBER MEMQ EQUAL NEQ EQ GEQ GREATERP LEQ LESSP PLUS DIFFERENCE MINUS
TIMES QUOTIENT EXPT CONS Numerical Operators ABS ACOS ACOSH ACOT ACOTH
ACSC ACSCH ASEC ASECH ASIN ASINH ATAN ATANH ATAN2 COS COSH COT COTH
CSC CSCH EXP FACTORIAL FIX FLOOR HYPOT LN LOG LOGB LOG10 NEXTPRIME
ROUND SEC SECH SIN SINH SQRT TAN TANH

Prefix Operators APPEND ARGLENGTH CEILING COEFF COEFFN COFACTOR CONJ
DEG DEN DET DF DILOG EI EPS ERF FACTORIZE FIRST GCD G IMPART INT
INTERPOL LCM LCOF LENGTH LHS LINELENGTH LTERM MAINVAR MAT MATEIGEN MAX
MIN MKID NULLSPACE NUM PART PF PRECISION RANDOM RANDOM NEW SEED RANK
REDERR REDUCT REMAINDER REPART REST RESULTANT REVERSE RHS SECOND SET
SHOWRULES SIGN SOLVE STRUCTR SUB SUM THIRD TP TRACE VARNAME

Reserved Variables CARD NO E EVAL MODE FORT WIDTH HIGH POW I INFINITY
K!* LOW POW NIL PI ROOT MULTIPLICITY T

Switches ADJPREC ALGINT ALLBRANCH ALLFAC BFSPACE COMBINEEXPT
COMBINELOGS COMP COMPLEX CRAMER CREF DEFN DEMO DIV ECHO ERRCONT
EVALLHSEQP EXP EXPANDLOGS EZGCD FACTOR FORT FULLROOTS GCD IFACTOR INT
INTSTR LCM LIST LISTARGS MCD MODULAR MSG MULTIPLICITIES NAT NERO
NOSPLIT OUTPUT PERIOD PRECISE PRET PRI RAT RATARG RATIONAL RATIONALIZE
RATPRI REVPRI RLISP88 ROUNDALL ROUNDBF ROUNDED SAVESTRUCTR
SOLVESINGULAR TIME TRA TRFAC TRIGFORM TRINT

Other Reserved Ids BEGIN DO EXPR FEXPR INPUT LAMBDA LISP MACRO PRODUCT
REPEAT SMACRO SUM UNTIL WHEN WHILE WS


@end example



@node Language m (rbg.m), Language m (abg.m), Language fig (abg.fig), Acausal bond graph - LaTeX ready (labg)
@comment  node-name,  next,  previous,  up
@subsection Language m (rbg.m)
The raw bond graph of system `sys' is represented as
 an m file with heading:
@example
function [rbonds, rstrokes,rcomponents,rports,n_ports] = sys_rbg
@end example
This representation is a half-way house between the fig 
(@pxref{Language fig (abg.fig)}) and m 
(@pxref{Language m (abg.m)}) representations. It contains the
geometric information from the fig file in a form digestible by Octave
(@pxref{Octave}).

The five outputs of this function are:
@itemize @bullet
@item
rbonds
@item
rstrokes
@item
rcomponents
@item
rports
@item
n_ports
@end itemize

@emph{rbonds} is  a matrix with
@itemize @bullet
@item
one row for each bond (@pxref{bonds})
@item
columns 1 and 2 containing the x,y coordinates for one end of the bond
@item
columns 3 and 4 containing the x,y coordinates for the corner of the bond
@item
columns 5 and 6 containing the x,y coordinates for the other end of the bond
@end itemize

@emph{rstrokes} is  a matrix with (@pxref{strokes})
@itemize @bullet
@item
one row for each stroke or half-stroke
@item
columns 1 and 2 containing the x,y coordinates for one end of the stroke
@item
columns 3 and 4 containing the x,y coordinates for the other end of the stroke
@end itemize

@emph{rcomponents} is  a matrix with (@pxref{components})
@itemize @bullet
@item
one row for each component
@item
columns 1 and 2 containing the x,y coordinates of the component
@item
the remaining columns containing fig file information
@end itemize

@emph{rports} is  a matrix with (@pxref{Port labels})
@itemize @bullet
@item
one row for each component port that is explicitly labeled
@item
columns 1 and 2 containing the x,y coordinates of the port label
@item
column 3 contains the port number.
@end itemize

@emph{n_ports} is the number of ports associated with the system -- i.e. the
number of Named SS components (@pxref{Named SS components}).

@menu
* Transformation abg2rbg_fig2m::  
@end menu

@node Transformation abg2rbg_fig2m,  , Language m (rbg.m), Language m (rbg.m)
@comment  node-name,  next,  previous,  up
@subsubsection Transformation abg2rbg_fig2m
@cindex Transformation abg2rbg_fig2m

This transformation takes the acausal bond graph as a fig file 
(@pxref{Language fig (abg.fig)}) and transforms it into a raw bond graph in
m-file format (@pxref{Language m (rbg.m)}).

This transformation is implemented in GNU awk (gawk).
It scans both the fig file (@pxref{Language fig (abg.fig)})
and the label file (@pxref{Labels (lbl)}) and generates the rbg
 (@pxref{Language m (rbg.m)}) with components sorted according to the
label file.
It also generates a file sys_fig.fig containing details of the bond
graph with the components removed.


@node Language m (abg.m), Language tex (abg.tex), Language m (rbg.m), Acausal bond graph - LaTeX ready (labg)
@comment  node-name,  next,  previous,  up
@subsection Language m (abg.m)
@cindex Language m (abg.m) 
@cindex bonds
@cindex components
@cindex n_ports

The acausal bond graph of system `sys' is represented as
 an m file with heading:
@example
function [bonds,components,n_ports] = sys_abg
@end example
The three outputs of this function are:
@itemize @bullet
@item
bonds
@item
components
@item
n_ports
@end itemize

@emph{bonds} is  a matrix with
@itemize @bullet
@item
one row for each bond
@item
the first column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{effort} variable.
@item
the second column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{flow} variable.
@end itemize

@emph{components} is  a matrix with
@itemize @bullet
@item
one row for each component
@item
one column for each bond impinging on the component. The
@emph{magnitude} of each entry corresponds to the bond number (the
appropriate row index of` bonds'); the sign is positive if the bond
arrow points into the component and negative otherwise.
@end itemize

@emph{n_ports} is the number of ports associated with the system -- i.e. the
number of Named SS components (@pxref{Named SS components}).

@menu
* Arrow-orientated causality::  
* Component-orientated causality::  
* Transformation rbg2abg_m::    
@end menu

@node  Arrow-orientated causality, Component-orientated causality, Language m (abg.m), Language m (abg.m)
@comment  node-name,  next,  previous,  up
@subsubsection  Arrow-orientated causality
@cindex Arrow-orientated causality

The  arrow-orientated causality convention assigns -1, 0 or 1 
to both the effort and flow (@pxref{Variables}) sides of a bond 
to represent the causal stroke (@pxref{strokes})
as follows:
@vtable @code
@item 0
        if there is no causality set.
@item 1
       if the causal stroke is at the arrow end of the bond.
@item -1 
     if the causal stroke is at the other end of the bond.
@end vtable
@pxref{Component-orientated causality}.

@node  Component-orientated causality, Transformation rbg2abg_m, Arrow-orientated causality, Language m (abg.m)
@comment  node-name,  next,  previous,  up
@subsubsection  Component-orientated causality
@cindex Component-orientated causality

The  component-orientated causality convention assigns -1, 0 or 1 
to both the effort and flow (@pxref{Variables}) sides of a bond 
to represent the causal stroke (@pxref{strokes})
as follows:
@vtable @code
@item 0
        if there is no causality set.
@item 1 
      if the causal stroke is at the component end of the bond.
@item -1
      if the causal stroke is at the other end of the bond.

@end vtable
@pxref{Arrow-orientated causality}.

@node Transformation rbg2abg_m,  , Component-orientated causality, Language m (abg.m)
@comment  node-name,  next,  previous,  up
@subsubsection Transformation rbg2abg_m
@cindex Transformation rbg2abg_m
This transformation takes the raw bond graph and, by doing some
geometrical computation, determines the topology of the bond graph -- ie
what is close to what.

@node Language tex (abg.tex),  , Language m (abg.m), Acausal bond graph - LaTeX ready (labg)
@comment  node-name,  next,  previous,  up
@subsection Language tex (abg.tex)
@cindex Language tex (abg.tex)

For the purpose of producing a report (@pxref{Report}), @strong{MTT}
generates a LaTeX (@pxref{LaTeX}) file describing the bond graph and its
subsystems. Additional information may be supplied using the description
representation (@pxref{Detailed}).

@c      node   next  prev  up
@node   Stripped acausal bond graph (sabg), Labels (lbl), Acausal bond graph - LaTeX ready (labg), Representations
@section Stripped acausal bond graph (sabg)
@cindex Stripped acausal bond graph (sabg)
@pindex Stripped acausal bond graph (sabg)
The stripped acausal bond graph is the acausal bond graph representation
(@pxref{Acausal bond graph (abg)}) without the artwork
(@pxref{artwork}). It is useful to check for mistakes by showing
precisely what is recognised by @strong{MTT}.

@menu
* Language fig (sabg.fig)::     
* Stripped acausal bond graph (view)::  
@end menu

@node Language fig (sabg.fig), Stripped acausal bond graph (view), Stripped acausal bond graph (sabg), Stripped acausal bond graph (sabg)
@subsection Language fig (sabg.fig) 
@cindex Language fig (sabg.fig) 
@pindex Language fig (sabg.fig) 
The stripped acausal bond graph can be generated as a fig (@pxref{Fig})
file using
@example
mtt syst sabg fig
@end example

@node Stripped acausal bond graph (view),  , Language fig (sabg.fig), Stripped acausal bond graph (sabg)
@subsection Stripped acausal bond graph (view)
@cindex Language m (view)
@cindex view  Constrained-state Equations
This representation has the standard text view
(@pxref{Views}).


@node Labels (lbl), Structure (struc), Stripped acausal bond graph (sabg), Representations
@comment  node-name,  next,  previous,  up
@section Labels (lbl)
@cindex Labels
@cindex lbl
Bond graph components have optional labels. These provide pointers to
further information relating to the component; this avoids clutter on
the bond graph.

The label file contains the following non-blank lines (blank lines are ignored)
@itemize @bullet
@item Summary - lines beginning with #SUMMARY
@item Description - lines beginning with #DESCRIPTION
@item Alias - lines beginning with #ALIAS
@item Comments - lines beginning with # 
@item Labels - other non-blank lines
@end itemize

Note, for compatability with old versions, % may be used in place of
#; but the use of % is deprecated.
Each label contains three fields (in the following order) separated by
white space and on one line:
@enumerate
@item The component name @pxref{Component names}. This must be a valid
name  (@pxref{Valid names}.
@item The component constitutive relationship @pxref{Component constitutive relationship}
@item The component arguments @pxref{Component arguments}
@end enumerate

Not each component @pxref{components} needs a label, only those which are explicitly
labeled on the Bond Graph @pxref{Acausal bond graph (abg)}.
@strong{MTT} checks whether all  components labelled on the bond graph
have labels and vice versa.

If no lbl file exists, @strong{MTT} will create a valid one for you;
including a default set of arguments and crs for both simplae and
compound components.

If wish to create one to edit yourself, type
@example
mtt system_name lbl txt
@end example
An example lbl file (for the RC system is):
@example
%% Label file for system RC (RC_lbl.txt)
%SUMMARY RC
%DESCRIPTION <Detailed description here>
% Port aliases
%ALIAS  in      in
%ALIAS  out     out

% Argument aliases
%ALIAS  $1      c
%ALIAS  $2      r

%% Each line should be of one of the following forms:
%            a comment (ie starting with %)
%            component-name     cr_name arg1,arg2,..argn
%            blank

% ---- Component labels ----

% Component type C
        c               lin     effort,c

% Component type R
        r               lin     flow,r

% Component type SS
        [in]    SS              external,external
        [out]   SS              external,external

@end example


The old-style lbl files (@pxref{Old-style labels (lbl)}) are NO LONGER
supported -- you are encouraged to convert them ASAP.

@menu
* SS component labels::         
* Other component labels::      
* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Parameter declarations::      
* Units declarations::          
* Interface Control Definition::  
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      
* Language tex (desc.tex)::     
@end menu

@node SS component labels, Other component labels, Labels (lbl), Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection SS component labels 
@cindex SS component labels 
In addition to the label there are two information fields, @pxref{Labels
(lbl)}. The first must be `SS', the second contains two information
fields of the form info_field_1,info_field_2.

These two information
fields correspond to the effort and flow variables of the of the SS components as follows
@vtable @code
@item info_field_1
        effort
@item info_field_2
        flow
@end vtable
Each of these two fields contains one of the following @emph{attributes}:
@vtable @code
@item external
        indicates that the corresponding variable is a system input or
output
@item internal
        indicates that the variable does not appear as a system output;
        it is an error to label an input in this way.
@item a number
        the value of the input; or the value of the (imposed) output
@item a symbol
        the symbolic value of the input; or the value of the (imposed) output
@item unknown
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system input (SS output) is to
        be chosen to set the corresponding system output (SS input) to zero.
@item zero
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system output (SS input) is to
        be set to zero using the variable indicted by the corresponding
        `unknown' label.
@end vtable

Some examples are:
@example
%% ss1 is both a source and sensor
ss1     SS              external,external
%% ss1 acts as a flow sensor - it imposes zero effort.
ss2     SS              0,external
@end example


@node Other component labels, Component names, SS component labels, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Other component labels 
@cindex Other component labels 

In addition to the label there are two information fields,
@pxref{Labels (lbl)}.
They correspond to the constitutive relationship 
(see @pxref{Constitutive relationship} and arguments of the
component as follows
@vtable @code
@item info_field_1
        constitutive relationship 
@item info_field_2
        parameters
@end vtable

Some examples are:
@example
%Armature resistance
r_a     lin     effort,r_a

%Gearbox ratio
n       lin     effort,n
@end example

@strong{MTT} supports parameter-passing to  (@pxref{Parameter passing})
subsystems.

@menu
* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      
@end menu

@node Component names, Component constitutive relationship, Other component labels, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Component names
@cindex  Component names
The component name field must contain a valid name  (@pxref{Valid names} corresponding to the
name (the bit after the :) of each named component (@pxref{components})
on  the bond graph (@pxref{Acausal bond graph (abg)}).

@node Component constitutive relationship, Component arguments, Component names, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Component constitutive relationship
@cindex  Component constitutive relationship
The constitutive relationship field contains the name of a constitutive
relationship for the component. There are three sorts of constitutive
relationship recognised by @strong{MTT}:
@enumerate
@item A generic constitutive relationship such as @var{lin} (the generic
linear constitutive relationship.
@item A local constitutive relationship with the same name as the
component type
@item The @var{SS} constitutive relationship reserved for @var{SS}
components.
All labels for @var{SS} components must contain SS in this field.
@end enumerate


@node Component arguments, Parameter declarations, Component constitutive relationship, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Component arguments
@cindex  Component arguments

@node Parameter declarations, Units declarations, Component arguments, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Parameter declarations
@cindex parameter declarations
@pindex parameter declarations
@pindex PAR 
@pindex NOTPAR 
@pindex VAR 
@pindex NOTVAR 

It is sometimes useful to use parameters (in addition to those implied by
the Component arguments @pxref{Component arguments}) to compute values
in, for example the numpar file. These can be declared in the label
file;
for examples , the two parameters par1 and par 2 can be declared as:
@example
#PAR par1
#PAR par2
@end example

On the other hand, some CR arguments (eg foo and bar) may not correspond to
parameters. These can be excluded from the sympar list  using
the NOTPAR declaration
@example
#NOTPAR foo
#NOTPAR bar
@end example

For comapability with old code, VAR may be used in place of PAR, but
this usage is deprecated.

@node Units declarations, Interface Control Definition, Parameter declarations, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Units declarations
@cindex units declarations
@pindex units declarations
@pindex UNITS
The units and domains of ports (@pxref{Ports}) are declared as:
@example
#UNITS Port_name domain effort_units flow_units
@end example
where "Port_name" is the name of the port, domain is one of:
@vtable @code
@item electrical
         the electrical domain
@item translational
         the translational mechanical domain
@item rotational
         the rotational mechanical domain
@item fluid
         the fluid domain
@item thermal
         the thermal domain 
@end vtable
and effort_units and flow_units are corresponding units for the effort
and the flow.

Allowed units are those defined in the @strong{units} package.



@strong{MTT} checks that units are 
@itemize  @bullet
@item defined consistently with the domain
@item the same for connected ports when both ports have defined units.
@end itemize
No checks are done if one or both ends of a bond are not connected to a
port with defined units.

The word ``none'' can be specified in place of a unit to prevent
@strong{MTT} from checking the corresponding effort or flow while
still checking the units of the other variable, if it is specified.
This can be used to force checking of either the effort or flow on 
signal bonds or in pseudo-bond graphs where the domain of the two
variables may not be identical.


@node Interface Control Definition, Aliases, Units declarations, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Interface Control Definition
@cindex ICD (label file directive)
It is sometimes useful to be able to automatically generate a set of 
assignments mapping @strong{MTT} inputs and outputs to an external interface
definition. This can be achieved with use of the @emph{#ICD} directive.

@example
#ICD    PressureSensor		PUMP1_PRESSURE_SENSOR,Pa;null,none
#ICD    Electrical		PUMP1_VOLTAGE,volt;PUMP1_CURRENT,amp

% Component type De
	PressureSensor	SS      external

% Component type SS
	Electrical	SS	external,external
@end example


The ICD directive consists of 3 whitespace delimited fields:

@enumerate
@item [%|#]ICD
@item component name
@item Four comma (,) or semi-colon (;) delimited fields:

@enumerate
@item name of effort parameter
@item unit of effort parameter
@item name of flow parameter
@item unit of flow parameter
@end enumerate
@end enumerate

If no parameter name is required, a value of "null" should be used.
If the parameter does not have any units, a value of "none" should be used.

ICD parameters may be aliased @pxref{Aliases} in the same way as normal
parameters, thus it is possible to define some or all of the ICD in higher
level components.

The command

@example
mtt sys ICD txt
@end example

will generate a text file containing a list of mappings:

@example
## Interface Control Definition for System sys
## sys_ICD.txt: Generated by MTT Thu Jul 12 21:21:21 CDT 2001

Input:  PUMP1_VOLTAGE           sys_P1_1_Electrical      Causality: Effort   Units: volt
Output: PUMP1_CURRENT           sys_P1_1_Electrical      Causality: Flow     Units: amp
Output: PUMP1_PRESSURE_SENSOR   sys_P1_1_PressureSensor  Causality: Effort   Units: Pa
@end example

A set of assignments can be generated with the command
@example
mtt sys ICD m
@end example

resulting in:

@example
# Interface Control Definition mappings for system sys
# sys_ICD.m: Generated by MTT Thu Jul 12 21:26:56 CDT 2001

# Inputs

        mttu(1) = PUMP1_VOLTAGE;

# Outputs

        PUMP1_CURRENT                  = mtty(1);
        PUMP1_PRESSURE_SENSOR          = mtty(2);
@end example

A similar file will be generated by the command
@example
mtt sys ICD cc
@end example



@node Aliases, Parameter passing, Interface Control Definition, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Aliases
@cindex aliases
@pindex aliases

Aliases provide a convenient mechanism for relabelling words appearing
in the label file (@pxref{Labels (lbl)}). There are three contexts in
which the alias mechanism is used:

@enumerate
@item renaming ports (@pxref{Port aliases}),
@item renaming parameters (@pxref{Parameter aliases}) and
@item renaming components (@pxref{Component aliases}).
@end enumerate

All three mechanisms use the same form of statement within the label
file
@example
%ALIAS short_label       real_label
@end example

@strong{MTT} distinguishes between the three forms as follows:

@itemize @bullet
@item Parameter aliases: `short_label' starts with a `$'
@item Component aliases: `real_label' contains the directory separator
`/'
@item Port aliases: neither of the above
@end itemize

@menu
* Port aliases::                
* Parameter aliases::           
* CR aliases::                  
* Component aliases::           
@end menu


@node Port aliases, Parameter aliases, Aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection Port aliases
@cindex port aliases
@pindex port aliases
Aliases provide a way of refering to (@pxref{Port labels}) or vector port labels (@pxref{Vector
port labels}) on the bond graph using a short-hand notation. With in a
component label file (@pxref{Labels (lbl)}) statements of the following
forms can occur 

@example
%ALIAS short_label       real_label
@end example

When the component is used within another component, the short_lable may
be used in place of the real_label.
More than one alias per label can be used, for example

@example
%ALIAS short_label_1       real_label
%ALIAS short_label_2       real_label
%ALIAS short_label_3       real_label
@end example

The port can then be refered to in four ways: as real_label,
short_label_1, short_label_2 or short_label_3.
An alternative notation for the ALIAS statement in this case is

@example
%ALIAS short_label_1|short_label_2|short_label_3       real_label
@end example

The alias feature is particularly powerful in conjunction with vector
port labels (@pxref{Vector port labels}) and the port label default 
(@pxref{Port label defaults}) mechanisms. For example, a component with
5 ports appearing in the lbl file as:

@example
        [Hydraulic_in]  external        external
        [Hydraulic_out] external        external
        [Power_Shaft]           external        external
        [Thermal_in]    external        external
        [Thermal_out]   external        external
@end example

together with the following statements in the label file:

@example
%ALIAS  in              Thermal_in,Hyydraulic_in
%ALIAS  out             Thermal_out,Hydraulic_out
%ALIAS  shaft|power     Power_Shaft
@end example

can appear in the bond graph containing that component with one bond
labeled either [shaft] or [power] or [Power_Shaft], one unlabeled vector
bond pointing in and one unlabeled vector bond pointing out.

@node Parameter aliases, CR aliases, Port aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection Parameter aliases
@cindex parameter aliases
@pindex parameter aliases

Parameter aliases are of the form
@example
%ALIAS $n       actual parameter
@end example
where n is an integer (unique within the label file).
For example

@example
%ALIAS  $1              c_v
%ALIAS  $2              density,ideal_gas,r
%ALIAS  $3              alpha
%ALIAS  $4              flow,k_p
@end example

Assigns four symbolic parameters to the corresponding strings These four
parameters (@code{$1}--@code{$4}) can then be used for parameter
passing(@pxref{Parameter passing}).

@node CR aliases, Component aliases, Parameter aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection CR aliases
@cindex CR aliases
@pindex CR aliases

CR aliases are of the form
@example
%ALIAS $an       actual parameter
@end example
where n is an integer (unique within the label file).
For example
@example
%ALIAS  $a1  lin           
@end example
assigns the symbolic parameter to be lin. This parameter @code{$1} can
then be used for passing a diofferent cr to the
component (@pxref{Parameter passing}).

@node Component aliases,  , CR aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection Component aliases
@cindex component aliases
@pindex component aliases

Component aliases are of the form
@example
%ALIAS Component_name   Component_location       
@end example

An example appears in the following label file fragment
@example
...
%ALIAS  wPipe   CompressibleFlow/wPipe
%ALIAS  Poly    CompressibleFlow/Poly
....

@end example
The two components `wPipe' and `Poly' are both to be found within the
library `Compressible flow' and the respective subdirectories. This
follows the @strong{MTT} convention that compound components
(@pxref{Compound components}) live within a directory of the same name.
 

@node Parameter passing, Old-style labels (lbl), Aliases, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Parameter passing
@cindex Parameter passing
@strong{MTT} supports parameter-passing to subsystems within label files
(@pxref{Labels (lbl)}). Within a subsystem, explicit constitutive
relationships and parameters (or groups thereof) can be replaced by
postitional parameters such as @code{$1}, @code{$2} etc.  Although this
can be done directly, it is recommended that this is done via the alias
mechanism (@pxref{Parameter aliases}).

In a subsystem
@code{$i}, is replaced by the ith field of a colon @code{;} separated
field in the calling label file. This field may include commas @code{,}
and the four arithmetic operators @code{+}, @code{-}, @code{*} and
@code{/}.

For example, consider the following example label file fragment (associated with a
component called Pump:
@example
...

%ALIAS  $1              c_v
%ALIAS  $2              density,ideal_gas,r
%ALIAS  $3              alpha
%ALIAS  $4              flow,k_p

%ALIAS  wPipe   CompressibleFlow/wPipe
%ALIAS  Poly    CompressibleFlow/Poly

% Component type wPipe
        pipe    none                    c_v;density,ideal_gas,r

% Component type Poly
        poly            Poly            alpha

@end example

The 4 parameters @code{$1}, @code{$2}, @code{$3}, and @code{$4} can be
passed from a higher level component as in the following label file
fragment:

@example
% Component type Pump
        comp            none            c_v;rho,ideal_gas,r;alpha;effort,k_c
        turb            none            c_v;rho,ideal_gas,r;alpha;effort,k_t
@end example

Thus in component `comp':
@itemize @bullet
@item @code{$1} is replaced by c_v
@item @code{$2} is replaced by rho,ideal_gas
@item @code{$3} is replaced by alpha
@item @code{$4} is replaced by effort,k_c
@end itemize
whereas in component `turb' the first three parameters are the same but
@itemize @bullet
@item @code{$4} is replaced by effort,k_t
@end itemize



@node Old-style labels (lbl), Language tex (desc.tex), Parameter passing, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Old-style labels (lbl)
@cindex Old-style labels
@cindex lbl

Old syle labels (mtt version 2.x) are supported by mtt version
3.x. However, you are advised to use the new form (@pxref{Labels
(lbl)}).

Each line of the @code{_label.txt} file is of one of three forms:
@enumerate
@item
Contains three fields (separated by white space) of the form
@example
label   field_1   field_2
@end example
@item
Blank
@item
Preceded by %
@end enumerate
Only the first is noticed by @strong{MTT}; the second and third are for
providing helpful commenting.

The role of the two information fields depends on the component with the
corresponding label. In particular the classes of components are:
@itemize @bullet
@item
SS components, @pxref{SS components}.
@item
Other components,  @pxref{components}.
@end itemize
Named SS component, @pxref{Named SS components} never have labels.
@menu
* SS component labels (old-style)::  
* Other component labels (old-style)::  
* Parameter passing (old-style)::  
@end menu


@node SS component labels (old-style), Other component labels (old-style), Old-style labels (lbl), Old-style labels (lbl)
@comment  node-name,  next,  previous,  up
@subsubsection SS component labels (old-style)
@cindex SS component labels (old-style)
In addition to the label there are two information fields,
@pxref{Labels (lbl)}.
They correspond to the effort and flow of the components as follows
@vtable @code
@item info_field_1
        effort
@item info_field_2
        flow
@end vtable
Each of these two fields contains one of the following @emph{attributes}:
@vtable @code
@item external
        indicates that the corresponding variable is a system input or
output
@item internal
        indicates that the variable does not appear as a system output;
        it is an error to label an input in this way.
@item a number
        the value of the input; or the value of the (imposed) output
@item a symbol
        the symbolic value of the input; or the value of the (imposed) output
@item unknown
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system input (SS output) is to
        be chosen to set the corresponding system output (SS input) to zero.
@item zero
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system output (SS input) is to
        be set to zero using the variable indicted by the corresponding
        `unknown' label.
@end vtable

Some examples are:
@example
%Label  field1          field2
ss1     external        external
ss2     0               external
@end example


@node Other component labels (old-style), Parameter passing (old-style), SS component labels (old-style), Old-style labels (lbl)
@comment  node-name,  next,  previous,  up
@subsubsection Other component labels (old-style)
@cindex Other component labels (old-style)

In addition to the label there are two information fields,
@pxref{Labels (lbl)}.
They correspond to the constitutive relationship 
(see @pxref{Constitutive relationship} and arguments of the
component as follows
@vtable @code
@item info_field_1
        constitutive relationship 
@item info_field_2
        parameters
@end vtable

Some examples are:
@example
%Armature resistance
r_a     lin     effort,r_a

%Gearbox ratio
n       lin     effort,n
@end example

@strong{MTT} supports parameter-passing to  (@pxref{Parameter passing (old-style)})
subsystems.


@node Parameter passing (old-style),  , Other component labels (old-style), Old-style labels (lbl)
@comment  node-name,  next,  previous,  up
@subsubsection Parameter passing (old-style)
@cindex Parameter passing (old-style)
@strong{MTT} supports parameter-passing to  (@pxref{Parameter passing (old-style)})
subsystems within label files (@pxref{Labels (lbl)}). Within a subsystem,
explicit constitutive relationships and parameters (or groups thereof)
can be replaced by 
@code{$1}, @code{$2}, etc.

In a subsystem
@code{$i}, is replaced by the ith field of a colon @code{;} separated
field in the calling label file. This field may include commas @code{,}.

For example subsystem ROD contains the following lines in the label
file:
@example

%DESCRIPTION    Parameter 1:    length from end 1 to mass centre
%DESCRIPTION    Parameter 2:    length from end 2 to mass centre
%DESCRIPTION    Parameter 3:    inertia about mass centre
%DESCRIPTION    Parameter 4:    mass
%DESCRIPTION    See Section 10.2 of "Metamodelling"


%Inertias
J       lin     flow,$3
m_x     lin     flow,$4
m_y     lin     flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1      lsin    flow,$1
s2      lsin    flow,$2
c1      lcos    flow,$1
c2      lcos    flow,$2

@end example

This can be used in a higher-level lbl (@pxref{Labels (lbl)}) file as:
@example
%SUMMARY Pendulum example from Section 10.3 of "Metamodelling"

%Rod parameters
rod     none    l;l;j;m

@end example


@menu
* Language tex (desc.tex)::     
@end menu

@node Language tex (desc.tex),  , Old-style labels (lbl), Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Language tex (desc.tex)
@cindex Language tex (desc.tex)
This file may contain any LaTeX compatible commands. Any mathematics
should conform to the AMSmath package.

@node Structure (struc), Constitutive Relationship (cr), Labels (lbl), Representations
@comment  node-name,  next,  previous,  up
@section Structure (struc)
@cindex Structure
@cindex struc

The causal bond graph implies a set of equations describing the
system. The Structure (struc) representation describes the structure of
these equations in terms of the input, outputs, states and non-states of
the system.

@menu
* Language txt (struc.txt)::    
* Language tex (struc.tex)::    
* Structure (view)::            
@end menu

@node Language txt (struc.txt), Language tex (struc.tex), Structure (struc), Structure (struc)
@comment  node-name,  next,  previous,  up
@subsection Language txt (struc.txt)
@cindex Language txt (struc.txt)
This text tile contains a description of the system structure
(@pxref{Structure (struc)} with 5 tab-separated columns containing the
following information:
@vtable @code
@item type
        input, output state or nonstate
@item index
        an integer corresponding to the array index
@item component name
        the name of the component corresponding to the variable
@item system name
        the name of the system containing the component
@item repetition
        an integer corresponding to the repetition of a repeated subsystem.
@end vtable

An example of such a file (corresponding to rc) (@pxref{Quick start}) is:
@example
input           1       e1      rc      1
output          1       e2      rc      1
state           1       c       rc      1
@end example


@node Language tex (struc.tex), Structure (view), Language txt (struc.txt), Structure (struc)
@comment  node-name,  next,  previous,  up
@subsection Language tex (struc.tex)
@cindex Language tex (struc.tex)
This LaTeX  (@pxref{LaTeX}) file contains  a description of the system structure
(@pxref{Structure (struc)} in @code{longtable} format. It is a useful
item to include in a report(@pxref{Report}).

@node Structure (view),  , Language tex (struc.tex), Structure (struc)
@subsection Language tex (view)
@cindex Structure (view)
@cindex view Structure
This representation has the standard text view
(@pxref{Views}).

@node Constitutive Relationship (cr), Parameters, Structure (struc), Representations
@comment  node-name,  next,  previous,  up
@section Constitutive relationship (cr)
@cindex Constitutive relationship

The constitutive relationship (@pxref{Constitutive relationship})
of a simple component (@pxref{Simple components} is
defined in the symbolic algebra language Reduce (@pxref{Reduce}).
The constitutive relationship of a compound components 
(@pxref{Compound components})
is implied by the constitutive relationships of its constituent components.

@menu
* Predefined constitutive relationships::  
* DIY constitutive relationships::  
* Unresolved constitutive relationships::  
* Unresolved constitutive relationships - Octave::  
* Unresolved constitutive relationships - c++::  
@end menu

@node Predefined constitutive relationships, DIY constitutive relationships, Constitutive Relationship (cr), Constitutive Relationship (cr)
@comment  node-name,  next,  previous,  up
@subsection  Predefined constitutive relationships
@cindex Predefined constitutive relationships

Some common cr's are predefined by MTT; these are:
@vtable @code
@item lin
        a linear constitutive relationship   
@item exotherm
        an exothermic reaction
@end vtable

@menu
* lin::                         
* exotherm::                    
@end menu

@node lin, exotherm, Predefined constitutive relationships, Predefined constitutive relationships
@comment  node-name,  next,  previous,  up
@subsubsection lin
@findex lin
The constitutive relationship @code{lin} is predefined for the following
components.
@vtable @code
@item R
        (one-port) R component
@item TF
        transformer
@item GY
        gyrator
@item MTF
        modulated transformer
@item MGY
        modulated gyrator
@item FMR
        flow-modulated resistor
@end vtable
Lin takes two arguments in the form causality,gain
@vtable @code
@item causality
        the causality (effort or flow) of the @emph{input} to the
constitutive relationship
@item gain
        the gain of the component when the input causality is as
specified in the first argument.
@end vtable
For example the arguments
@example
flow,r
@end example
given to an R component corresponds to
@example
e = rf
@end example
if if the input causality is flow
or
@example
f = e/r
@end example
if if the input causality is effort.

@node exotherm,  , lin, Predefined constitutive relationships
@comment  node-name,  next,  previous,  up
@subsubsection exotherm
@findex exotherm

@node DIY constitutive relationships, Unresolved constitutive relationships, Predefined constitutive relationships, Constitutive Relationship (cr)
@comment  node-name,  next,  previous,  up
@subsection  DIY constitutive relationships
@cindex DIY constitutive relationships
You can write your own constitutive relationships using Reduce
(@pxref{Reduce}). This requires some understanding as to how
@strong{MTT} represent the elementary system equations
(@pxref{Elementary system equations}). Looking at the predefined
constitutive relationships is a good way to get started
(@pxref{File structure}).

@node Unresolved constitutive relationships, Unresolved constitutive relationships - Octave, DIY constitutive relationships, Constitutive Relationship (cr)
@subsection Unresolved constitutive relationships
@cindex Unresolved constitutive relationships

Consider the following CR file.
@example
FOR ALL rho,g,vol,h,topt,bott,flowin,press
LET tktf2(rho,g,vol,h,topt,bott,effort,2,press,effort,1)
        = tank(rho,g,vol,h,topt,bott,press);      
@end example
Assuming that `tank' is not defined in a
reduce file, MTT will leave it unresolved when generating m or c code.

The resulting function can then be expressed as octave
(@pxref{Unresolved constitutive relationships - Octave}) or c++ code as
(@pxref{Unresolved constitutive relationships - c++}) appropriate.

@node Unresolved constitutive relationships - Octave, Unresolved constitutive relationships - c++, Unresolved constitutive relationships, Constitutive Relationship (cr)
@subsection  Unresolved constitutive relationships - Octave
@cindex Unresolved constitutive relationships - Octave
Following the example of the previous section, the unresolved CR `tank'
can be expressed as an Octave m-file. For example:
@example
function p = tank (rho,g,vol,h,topt,bott,press)

  ## usage:  p = tank (vol,h,topt,bott,press)
  ##
  ## 

   val = press; zt = topt; zb = bott; 
   zval = 0.5*(abs(zb+(zt-zb)*val-h)+(zb+(zt-zb)*val-h));

   p = rho*g*zval + 0.5*(1+tanh((press-0.98)*500))*100000;

endfunction
@end example
This will be automatically loaded into octave.

@node Unresolved constitutive relationships - c++,  , Unresolved constitutive relationships - Octave, Constitutive Relationship (cr)
@subsection  Unresolved constitutive relationships - c++
@cindex Unresolved constitutive relationships - Octave
Following the example of the previous section, the unresolved CR `tank'
can be expressed in c++ code. For example:
@example
inline double tank(const double rho, 
		   const double g, 
		   const double vol, 
		   const double h, 
		   const double topt, 
		   const double bott, 
		   const double press)


  /*  ## usage:  p = tank (vol,h,topt,bott,press)
    ##
    ##
  */
  double p, val, zval, zt, zb;

  val = press;
  zt = topt;
  zb = bott;
  zval = 0.5 * (abs(zb + (zt - zb) * val - h) + zb + (zt - zb) * val - h);

  p = rho * g * zval + 0.5 * (1 + tanh((press - 0.98) * 500)) * 100000L;

  return p;

@end example

To make sure that this is used in system `model', the model_cr.h file
must be as follows:
@example
// CR headers for system model
#include "tank.c"
@end example

@node Parameters, Causal bond graph (cbg), Constitutive Relationship (cr), Representations
@comment  node-name,  next,  previous,  up
@section Parameters
@cindex Parameters

In general, lbl (@pxref{Labels (lbl)}) files contain symbolic
parameters. @strong{MTT} provides three ways of substituting for these
parameters:
@itemize @bullet
@item
symbolic substitution
@item
symbolic substitution for simplification of displayed equations
@item
numeric
@end itemize

@menu
* Symbolic parameters (subs.r)::  
* Symbolic parameters for simplification (simp.r)::  
* Numeric parameters (numpar)::  
@end menu

@node Symbolic parameters (subs.r), Symbolic parameters for simplification (simp.r), Parameters, Parameters
@comment  node-name,  next,  previous,  up
@subsection Symbolic parameters (subs.r)
@cindex  Symbolic parameters
@vindex subs.r
This file contains reduce statements to symbolically change the
expressions describing the system.
For example, a useful set of trig substitutions is:
@example
LET cos(~x)*cos(~y) = (cos(x+y)+cos(x-y))/2;
LET cos(~x)*sin(~y) = (sin(x+y)-sin(x-y))/2;
LET sin(~x)*sin(~y) = (cos(x-y)-cos(x+y))/2;
LET cos(~x)^2       = (1+cos(2*x))/2;
LET sin(~x)^2       = (1-cos(2*x));
@end example

@node Symbolic parameters for simplification (simp.r), Numeric parameters (numpar), Symbolic parameters (subs.r), Parameters
@comment  node-name,  next,  previous,  up
@subsection Symbolic parameters for simplification  (simp.r)
@cindex  Symbolic parameters for simplification 
@vindex simp.r
This file contains reduce statements to symbolically change the
expressions describing the system. Unlike the subs.r file
(@pxref{Symbolic parameters (subs.r)}) it does not affect all system
transformations; only those converting to LaTeX form.

@node Numeric parameters (numpar),  , Symbolic parameters for simplification (simp.r), Parameters
@comment  node-name,  next,  previous,  up
@subsection Numeric parameters (numpar)
@cindex  Numeric parameters

When computing time and frequency responses; or when evaluating
functions in Octave (@pxref{Octave}); symbolic parameters need numerical
instantiations. 

The numpar representation provides the relevant @emph{numerical}
information. It comes in a number of languages:
@ftable @code
@item txt
        a textual description of the parameter values -- this is the
defining representation (@pxref{Defining representations}).
@item m
        readable by @code{octave} a high-level interactive language for numerical
        computation -- translated by @strong{mtt} from the txt version.
@item c
        readable by @code{gcc} a c compiler -- translated by @strong{mtt} from the txt version.

@end ftable

@menu
* Text form (numpar.txt)::      
@end menu

@node Text form (numpar.txt),  , Numeric parameters (numpar), Numeric parameters (numpar)
@comment  node-name,  next,  previous,  up
@subsubsection Text form (numpar.txt)
@cindex  Numeric parameters
This is the textual form of the numerical parameters representation
(@pxref{Numeric parameters (numpar)}). Lines are either
@ftable @code
@item assignment statements
        variable = value
@item comments
        lines beginning with #
@item commented assignment statements
        variable = value # comments
@end ftable
An example file is:
@example
# Numerical parameter file (rc_numpar.txt)
# Generated by MTT at Mon Jun 16 15:10:17 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.32  2014/07/12 19:56:27  geraint
# %% Fixed style of NO WARRANTY from heading to strong because texi2html complained about having a heading in an enumerate environment
# %%
# %% Revision 1.31  2014/07/10 23:13:27  geraint
# %% Fixed mtt.texi missing arguments and subsection level
# %%
# %% Revision 1.30  2005/03/15 12:04:15  gawthrop
# %% New labg.fig rep - pretty LaTeX figures.
# %%
# %% Revision 1.29  2005/01/19 09:45:15  geraint
# %% Fixed whitespace.
# %%
# %% Revision 1.28  2005/01/06 16:03:55  geraint
# %% Updated options list.
# %%
# %% Revision 1.27  2005/01/06 14:42:33  geraint
# %% Fixed explicit/implicit descriptions of forward/backward Euler.
# %% Replaced -c examples with -cc.
# %%
# %% Revision 1.26  2005/01/06 12:28:36  geraint
# %% Minor typos.
# %%
# %% Revision 1.25  2004/08/27 20:12:34  geraint
# %% Added note about "none" as an option for units.
# %%
# %% Revision 1.24  2004/08/13 01:39:24  geraint
# %% Fixed variable names in diy makefile example (again)
# %%
# %% Revision 1.23  2004/08/11 08:24:28  geraint
# %% Replaced "gnuplot view" with "odeso gnuplot" in examples.
# %%
# %% Revision 1.21  2004/07/23 11:05:26  geraint
# %% Updated Reduce URL: http://www.reduce-algebra.com
# %%
# %% Revision 1.20  2003/10/23 18:14:43  geraint
# %% Added subsection with script for model-specific options.
# %% Fixed typo in url to mtt.sf.net.
# %%
# %% Revision 1.19  2003/10/10 22:22:18  geraint
# %% typo.
# %%
# %% Revision 1.18  2003/09/07 20:41:19  geraint
# %% *** empty log message ***
# %%
# %% Revision 1.17  2003/08/19 14:20:38  gawthrop
# %% Version 5.0 of MTT
# %% Remove xref errors (spurious spaces)
# %%
# %% Revision 1.16  2003/08/19 14:11:23  gawthrop
# %% Links to legal stuff
# %%
# %% Revision 1.15  2003/08/19 14:01:45  gawthrop
# %% Added legal appendices
# %%
# %% Revision 1.14  2003/08/06 14:50:56  gawthrop
# %% Describe the alias mechanism for invoking mtt options
# %%
# %% Revision 1.13  2002/12/13 10:07:07  gawthrop
# %% Added example in sh section of DIY reps
# %%
# %% Revision 1.12  2002/09/19 08:09:31  gawthrop
# %% Updated documentation documentation
# %%
# %% Revision 1.11  2002/08/20 15:51:17  gawthrop
# %% Update to work with ident DIY rep
# %%
# %% Revision 1.10  2002/07/22 10:45:22  geraint
# %% Fixed gnuplot rep so that it correctly re-runs the simulation if input files have changed.
# %%
# %% Revision 1.9  2002/07/05 13:29:34  geraint
# %% Added notes about generating dynamically linked functions for Octave and Matlab.
# %%
# %% Revision 1.8  2002/07/04 21:34:12  geraint
# %% Updated gnuplot view description to describe Tcl/Tk interface instead of obsolete txt method.
# %%
# %% Revision 1.7  2002/04/23 09:51:54  gawthrop
# %% Changed incorrect statement about searching for components.
# %%
# %% Revision 1.6  2001/10/15 14:29:50  gawthrop
# %% Added documentaton on  [1:N] style port labels
# %%
# %% Revision 1.5  2001/07/23 03:35:29  geraint
# %% Updated file structure (mtt/bin).
# %%
# %% Revision 1.4  2001/07/23 03:25:02  geraint
# %% Added notes on -ae hybrd, rk4, ode2odes.cc, .oct dependencies.
# %%
# %% Revision 1.3  2001/07/13 03:02:38  geraint
# %% Added notes on #ICD, gnuplot.txt and odes.sg rep.
# %%
# %% Revision 1.2  2001/07/03 22:59:10  gawthrop
# %% Fixed problems with argument passing for CRs
# %%
# %% Revision 1.1  2001/06/04 08:18:52  gawthrop
# %% Putting documentation under CVS
# %%
# %% Revision 1.66  2000/12/05 14:20:55  peterg
# %% Added the c++  anf m CR info.
# %%
# %% Revision 1.65  2000/11/27 15:36:15  peterg
# %% NOPAR --> NOTPAR
# %%
# %% Revision 1.64  2000/11/16 14:22:48  peterg
# %% added UNITS declaration
# %%
# %% Revision 1.63  2000/11/03 14:41:08  peterg
# %% Added PAR and NOTPAR stuff
# %%
# %% Revision 1.62  2000/10/17 17:53:34  peterg
# %% Added some simulation details
# %%
# %% Revision 1.61  2000/09/14 17:13:06  peterg
# %% New options table
# %%
# %% Revision 1.60  2000/09/14 17:09:20  peterg
# %% Tidied up valid name sections
# %% Tidied up defining represnetations table
# %% Verion 4.6
# %%
# %% Revision 1.59  2000/08/30 13:09:00  peterg
# %% Updated option table
# %%
# %% Revision 1.58  2000/08/01 13:30:19  peterg
# %% Version 4.4
# %% updated STEPFACTOR info
# %% describes octave and OCST interfaces
# %%
# %% Revision 1.57  2000/07/20 07:55:44  peterg
# %% Version 4.3
# %%
# %% Revision 1.56  2000/05/19 17:49:17  peterg
# %% Extended the user defined representation section -- new nppp rep.
# %%
# %% Revision 1.55  2000/03/16 13:53:31  peterg
# %% Correct date
# %%
# %% Revision 1.54  2000/03/15 21:22:57  peterg
# %% Updated to 4.1 -- old style SS no longer supported
# %%
# %% Revision 1.53  1999/12/22 05:33:10  peterg
# %% Updated for 4.0
# %%
# %% Revision 1.52  1999/11/23 00:25:11  peterg
# %% Added the sensitivity reps
# %%
# %% Revision 1.51  1999/11/16 04:43:47  peterg
# %% Added start of sensitivity section
# %%
# %% Revision 1.50  1999/11/16 00:30:35  peterg
# %% Updated simulation section
# %% Added vector components
# %%
# %% Revision 1.49  1999/07/20 23:44:58  peterg
# %% V 3.8
# %%
# %% Revision 1.48  1999/07/19 03:08:33  peterg
# %% Added documentation for (new) SS lbl fields
# %%
# %% Revision 1.47  1999/03/09 01:42:22  peterg
# %% Rearranged the User interface section
# %%
# %% Revision 1.46  1999/03/09 01:18:01  peterg
# %% Updated for 3.5 including xmtt
# %%
# %% Revision 1.45  1999/03/03 02:39:26  peterg
# %% Minor updates
# %%
# %% Revision 1.44  1999/02/17 06:52:14  peterg
# %% New level formula dor artwork
# %%
# %% Revision 1.43  1998/11/25 16:49:24  peterg
# %% Put in subs.r documentation (was called params.r)
# %%
# %% Revision 1.42  1998/11/24 12:24:59  peterg
# %% Added section on simulation output
# %% Version 3.4
# %%
# %% Revision 1.41  1998/09/02 12:04:15  peterg
# %% Version 3.2
# %%
# %% Revision 1.40  1998/08/27 08:36:39  peterg
# %% Removed in. methods except Euler anf implicit
# %%
# %% Revision 1.39  1998/08/18 10:44:28  peterg
# %% Typo
# %%
# %% Revision 1.38  1998/08/18 09:16:38  peterg
# %% Version 3.1
# %%
# %% Revision 1.37  1998/08/17 16:14:30  peterg
# %% Version 3.1 - includes documentation on METHOD=IMPLICIT
# %%
# %% Revision 1.36  1998/07/30 17:33:15  peterg
# %% VERSION 3.0
# %%
# %% Revision 1.35  1998/07/22 11:00:53  peterg
# %% Correct date!
# %%
# %% Revision 1.34  1998/07/22 11:00:13  peterg
# %% Version to BAe
# %%
# %% Revision 1.33  1998/07/17 19:32:19  peterg
# %% Added more about aliases
# %%
# %% Revision 1.32  1998/07/05 14:21:56  peterg
# %% Further additions (Carlisle-Glasgow)
# %%
# %% Revision 1.31  1998/07/04 11:35:57  peterg
# %% Strarted new lbl description
# %%
# %% Revision 1.30  1998/07/02 18:39:20  peterg
# %% Started 3.0
# %% Added alias and default sections.
# %%
# %% Revision 1.29  1998/05/19 19:46:58  peterg
# %% Added the odess description
# %%
# %% Revision 1.28  1998/05/14 09:17:22  peterg
# %% Added METHOD variable to the simpar file
# %%
# %% Revision 1.27  1998/05/13 10:03:09  peterg
# %% Added unknown/zero SS label documentation.
# %%
# %% Revision 1.26  1998/04/29 15:12:46  peterg
# %% Version 2.9.
# %%
# %% Revision 1.25  1998/04/12 17:00:26  peterg
# %% Added new port features: coerced direction and top-level behaviour.
# %%
# %% Revision 1.24  1998/04/05 18:27:20  peterg
# %% This was the 2.6 version
# %%
# Revision 1.23  1997/08/24  11:17:51  peterg
# This is the released  version 2.5
#
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c =     1.0; # Default value
r =     1.0; # Default value
# Initial states
x(1) =  0.0; # Initial state for rc (c)
@end example
As usual, @strong{MTT} provides a default text file to be edited by the
user (@pxref{Text editors}).

@node Causal bond graph (cbg), Elementary system equations, Parameters, Representations
@comment  node-name,  next,  previous,  up
@section Causal bond graph (cbg)
@cindex Causal bond graph (cbg)
The causal bond graph is the causally complete version of the
Acausal bond graph (@pxref{Acausal bond graph (abg)}).

To create the causal bond graph of system `sys' in language fig type:
@example
mtt sys cbg fig
@end example
To create the causal bond graph of system `sys' in language m type:
@example
mtt sys cbg m
@end example
To view the causal bond graph of system `sys' type:
@example
mtt sys cbg view
@end example

@menu
* Language fig (cbg.fig)::      
* Language m (cbg.m)::          
@end menu

@node Language fig (cbg.fig), Language m (cbg.m), Causal bond graph (cbg), Causal bond graph (cbg)
@subsection Language fig (cbg.fig) 
@cindex Language fig (cbg.fig) 
@pindex Language fig (cbg.fig) 
The fig file is created by @strong{MTT}. It is identical to the
corresponding acausal representation (@pxref{Language fig (abg.fig)})
except that
@itemize @bullet
@item
the new causal strokes are added (using a double thickness line in blue)
@item
components that are undercausal are bold and green
@item
components that are overcausal are bold and red
@end itemize

@node Language m (cbg.m),  , Language fig (cbg.fig), Causal bond graph (cbg)
@comment  node-name,  next,  previous,  up
@subsection Language m (cbg.m)
@cindex Language m (cbg.m) 
@cindex cbonds
@cindex status


The causal bond graph of system `sys' is represented as
 an m file with heading:
@example
function [cbonds,status] = sys_cbg
@end example
The two outputs of this function are:
@itemize @bullet
@item
cbonds
@item
status
@end itemize

@emph{cbonds} is  a matrix with
@itemize @bullet
@item
one row for each bond
@item
the first column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{effort} variable.
@item
the second column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{flow} variable.
@end itemize

@emph{status} is  a matrix with
@itemize @bullet
@item
one row for each component
@item
the first column contains 1 if the component is overcausal; 0 if the
component is causally complete and -1 if the component is undercausal.
@end itemize
A successful model would therefore have all zeros in the status matrix.

@menu
* Transformation abg2cbg_m::    
@end menu

@node Transformation abg2cbg_m,  , Language m (cbg.m), Language m (cbg.m)
@comment  node-name,  next,  previous,  up
@subsubsection Transformation abg2cbg_m
@cindex Transformation abg2cbg_m

This transformation takes the acausal bond graph as an m file 
(@pxref{Language m (abg.m)}) and transforms it into a causal bond graph in
m-file format (@pxref{Language m (cbg.m)}).

It is based on the m-function abg2cbg.m which iteratively tries to
complete causality whilst recursively searching the bond graph
structure.
If causality is incomplete, it picks the first acausal dynamic (C or I)
component, asserts integral causality, and tries again.

This is essentially the sequential causality assignment procedure of
Karnopp and Rosenberg.

The transformation informs the user of the final status in terms of the
percentage of causally complete components; a successful model will
yield 100% here.

@node Elementary system equations, Differential-Algebraic Equations, Causal bond graph (cbg), Representations
@comment  node-name,  next,  previous,  up
@section Elementary system equations (ese)
@cindex Elementary system equations

The elementary system equations are a complete set of assignment statements
describing the dynamic system corresponding to the bond graph.
They are in the Reduce (@pxref{Reduce}) language.

Because these are based on a causally complete system, these assignment
statements are directly soluble by substitution.

Unlike early versions of @strong{MTT}, @strong{MTT} does @emph{not} sort
the equations in order of solution, but rather leaves them sorted by
component and subsystem.

These are not supposed to be read by the user, so there is no view
facility as such. However, you may read these with your favourite text
editor and, to this end,  helpful comment lines have been added.

Wherever components have an explicit constitutive relationship, the
corresponding RHS of the equation has a standard form.

@example
cr(arguments,out_causality,outport,
        input_1, causality_1, port_1,
        ....
        input_i, causality_i, port_i,
        ....
        input_n, causality_n, port_n
        );
@end example
where the symbols have the following meaning
@vtable @code
@item arguments
        the constitutive relationship arguments
@item out_causality
        the causality (effort or flow) of the output variable
        (@pxref{Variables})
@item outport
        the number (integer) of the output port of the system
@item input_i
        the ith input to the component
@item causality_i
        the causality (effort or flow) of the ith input variable
        (@pxref{Variables})
@item port_i
        the number (integer) of the ith input port of the system
@end vtable

An example for a resistor with linear constitutive relationship is:
@example
rc_1_bond4_flow := lin(flow,r,flow,1,
        rc_1_bond4_effort,effort,1
        );
@end example

@menu
* Transformation cbg2ese_m2r::  
@end menu

@node Transformation cbg2ese_m2r,  , Elementary system equations, Elementary system equations
@comment  node-name,  next,  previous,  up
@subsection Transformation cbg2ese_m2r
@cindex Transformation cbg2ese_m2r
@cindex Structure
@cindex def.r
This transformation takes the causal bond graph as an m file 
(@pxref{Language m (cbg.m)}) and transforms it into elementary system
equations
in Reduce (@pxref{Reduce})
form.

It is based on the m-function cbg2ese.m which iteratively traverses the
causal bond graph writing equations as it goes.

It also writes out the system structure as the file @file{sys_def.r}.


@node Differential-Algebraic Equations, Constrained-state Equations, Elementary system equations, Representations
@section Differential-Algebraic Equations (dae)
@cindex Differential-Algebraic Equations
@cindex DAE

The system differential algebraic equations describe the system dynamics together 
together with any algebraic constraints. 

They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys dae lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable


There are five sets of variables describing the system:
@vtable @code
@item x
        the system states (corresponding to C and I components with integral
        causality.
@item z
        the system nonstates (corresponding to C and I components with derivative
        causality.
@item u
        the system inputs  (corresponding to SS components
        with external attribute).
@item ui
        the @emph{internal} system inputs (corresponding to SS components
        with internal attribute) used to solve algebraic loops
        (@pxref{Algebraic loops}).
@item y
        the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

In general there are four sets of equations. The right-hand side of
 each is a function of x, dz/dt,  u and ui and the left hand sides are:
@enumerate
@item
the derivative of x (dx/dt)
@item
z
@item
w=0 (the algebraic equations)
@item
y
@end enumerate

@menu
* Differential-Algebraic Equations (reduce)::  
* Differential-Algebraic Equations (m)::  
@end menu

@node Differential-Algebraic Equations (reduce), Differential-Algebraic Equations (m), Differential-Algebraic Equations, Differential-Algebraic Equations
@subsection Language reduce (dae.r)
@cindex Differential-Algebraic Equations (reduce)
@cindex dae.r 

The system DAEs (@pxref{Differential-Algebraic Equations})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the algebraic expressions for the 
right hand sides of each set of equations. The arrays are:
@vtable @code
@item MTTx
        x -- the system states (corresponding to C and I components with integral
        causality.

@item MTTz
        z -- the system nonstates (corresponding to C and I components with derivative
        causality.
@item MTTu
        u -- the system inputs  (corresponding to SS components
        with external attribute).
@item mttv
        ui -- the @emph{internal} system inputs (corresponding to SS components
        with internal attribute) used to solve algebraic loops
        (@pxref{Algebraic loops}).
@item MTTy
        y -- the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

@menu
* Transformation ese2dae_r::    
@end menu

@node Transformation ese2dae_r,  , Differential-Algebraic Equations (reduce), Differential-Algebraic Equations (reduce)
@subsubsection Transformation ese2dae_r
@cindex Transformation ese2dae_r
@pindex  ese2dae_r

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to combine the elementary system
equations (@pxref{Elementary system equations}) with the
constitutive relationships (@pxref{Constitutive relationship})
and simplify the result. 

@node Differential-Algebraic Equations (m),  , Differential-Algebraic Equations (reduce), Differential-Algebraic Equations
@subsection Language m (dae.m)
@cindex Differential-Algebraic Equations (m)
@cindex dae.m
The system DAEs (@pxref{Differential-Algebraic Equations})
are represented in the m (@pxref{m}) language as  
two m-functions of the form:

@example
function resid = sys_dae(dx,x,t)
function y  = sys_dae(dx,x,t)
@end example
Where x is the dae @emph{descriptor} vector and dx its 
time derivative; t is the time.
The first function is of a form suitable for solution by DASSL;  
the second function can then be used to find the coresponding system
output.

@menu
* Transformation dae_r2m::      
@end menu

@node Transformation dae_r2m,  , Differential-Algebraic Equations (m), Differential-Algebraic Equations (m)
@subsubsection Transformation dae_r2m
@cindex Transformation dae_r2m
@pindex  dae_r2m

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to rewrite the elementary system
equations (@pxref{Elementary system equations}) in m-file 
format  (@pxref{m}) . Numerical parameters are declared as global.


@node Constrained-state Equations, Ordinary Differential Equations, Differential-Algebraic Equations, Representations
@section Constrained-state Equations (cse)
@cindex Constrained-state Equations
@cindex ODE

The system constrained-state equations describe the system dynamics for
a special class of systems (see the book for details). The resuting
equations are of the form:
@example
E(x) dx/dt = f(x,u)
y = g(x,u)
@end example
They typically occure where two or more states are constrained to be equal, or
proportional, to each other. For example, two capacitors in parallel or
two inertias connected by a stiff shaft.


They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys cse lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable

There are three sets of variables describing the system:
@vtable @code
@item x
        the system states (corresponding to C and I components with integral
        causality.
@item u
        the system inputs  (corresponding to SS components
        with external attribute).
@item y
        the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

In general there are two sets of equations. The right-hand side of
 each is a function of x and  u  and the left hand sides are:
@enumerate
@item
the derivative of x (dx/dt)
y
@end enumerate

@menu
* Constrained-state Equations (reduce)::  
* Constrained-state Equations (view)::  
@end menu

@node Constrained-state Equations (reduce), Constrained-state Equations (view), Constrained-state Equations, Constrained-state Equations
@subsection Language reduce (cse.r)
@cindex Constrained-state Equations (reduce)
@cindex cse.r 

The system CSEs (@pxref{Constrained-state Equations})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the algebraic expressions for the 
right hand sides of each set of equations. The arrays are:
@vtable @code
@item MTTx
        x -- the system states (corresponding to C and I components with integral
        causality.
@item MTTu
        u -- the system inputs  (corresponding to SS components
        with external attribute).
@item MTTy
        y -- the  system outputs (corresponding to SS components
        with external attribute).
@end vtable
together with the array containing the elements of the E matrix.
@menu
* Transformation dae2cse_r::    
@end menu

@node Transformation dae2cse_r,  , Constrained-state Equations (reduce), Constrained-state Equations (reduce)
@subsubsection Transformation dae2cse_r
@cindex Transformation dae2cse_r
@pindex  dae2cse_r

This transformation (@pxref{What is a Transformation?}) 
Reduce (@pxref{Reduce}) to find various Jacobians which are combined to
find the E matrix and the
constrained-state equations (@pxref{Constrained-state Equations}).

@node Constrained-state Equations (view),  , Constrained-state Equations (reduce), Constrained-state Equations
@subsection Language m (view)
@cindex Constrained-state Equations (view)
@cindex view Constrained-state Equations
This representation has the standard text view
(@pxref{Views}).

@node Ordinary Differential Equations, Descriptor matrices, Constrained-state Equations, Representations
@section Ordinary Differential Equations
@cindex Ordinary Differential Equations
@cindex ODE

The system ordinary differential equations describe the system dynamics.

They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys ode lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable

There are three sets of variables describing the system:
@vtable @code
@item x
        the system states (corresponding to C and I components with integral
        causality.
@item u
        the system inputs  (corresponding to SS components
        with external attribute).
@item y
        the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

In general there are two sets of equations. The right-hand side of
 each is a function of x and  u  and the left hand sides are:
@enumerate
@item
the derivative of x (dx/dt)
y
@end enumerate

@menu
* Ordinary Differential Equations (reduce)::  
* Ordinary Differential Equations (m)::  
* Ordinary Differential Equations (view)::  
@end menu

@node Ordinary Differential Equations (reduce), Ordinary Differential Equations (m), Ordinary Differential Equations, Ordinary Differential Equations
@subsection Language reduce (ode.r)
@cindex Ordinary Differential Equations (reduce)
@cindex ode.r 

The system ODEs (@pxref{Ordinary Differential Equations})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the algebraic expressions for the 
right hand sides of each set of equations. The arrays are:
@vtable @code
@item MTTx
        x -- the system states (corresponding to C and I components with integral
        causality.
@item MTTu
        u -- the system inputs  (corresponding to SS components
        with external attribute).
@item MTTy
        y -- the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

@menu
* Transformation cse2ode_r::    
@end menu

@node Transformation cse2ode_r,  , Ordinary Differential Equations (reduce), Ordinary Differential Equations (reduce)
@subsubsection Transformation cse2ode_r
@cindex Transformation cse2ode_r
@pindex  cse2ode_r

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to invert the E matrix of the 
constrained-state equations (@pxref{Constrained-state Equations})
and simplify the result. 

@node Ordinary Differential Equations (m), Ordinary Differential Equations (view), Ordinary Differential Equations (reduce), Ordinary Differential Equations
@subsection Language m (ode.m)
@cindex Ordinary Differential Equations (m)
@cindex ode.m
The system ODEs (@pxref{Ordinary Differential Equations})
are represented in the m (@pxref{m}) language as  
two m-functions of the form:

@example
function dx = sys_ODE(x,t)
function y  = sys_ODE(dx,x,t)
@end example
Where x is the ODE @emph{state} vector and dx its 
time derivative; t is the time.
The first function is of a form suitable for solution by odesol;  
the second function can then be used to find the corresponding system
output.

@menu
* Transformation ode_r2m::      
@end menu

@node Transformation ode_r2m,  , Ordinary Differential Equations (m), Ordinary Differential Equations (m)
@subsubsection Transformation ode_r2m
@cindex Transformation ode_r2m
@pindex  ode_r2m

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to rewrite the
ordinary differential equations
(@pxref{Ordinary Differential Equations}) in m-file 
format  (@pxref{m}) . Numerical parameters are declared as global.

@node Ordinary Differential Equations (view),  , Ordinary Differential Equations (m), Ordinary Differential Equations
@subsection Language m (view)
@cindex Ordinary Differential Equations (view)
@cindex view Ordinary Differential Equations
This representation has the standard text view
(@pxref{Views}).

@node Descriptor matrices, Report, Ordinary Differential Equations, Representations
@section Descriptor matrices (dm)
@cindex Descriptor matrices
@cindex dm

The system descriptor matrices A, B, C, D and E describe the 
@emph{linearised} system dynamics in the form
@example
E dx/dt = Ax + Bu
y = Cx + Du
@end example

They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys dm lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable


@menu
* Descriptor matrices (reduce)::  
* Descriptor matrices (m)::     
@end menu

@node Descriptor matrices (reduce), Descriptor matrices (m), Descriptor matrices, Descriptor matrices
@subsection Language reduce (dm.r)
@cindex Descriptor matrices (reduce)
@cindex dm.r 

The system  descriptor matrices (@pxref{Descriptor matrices})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the four matrices. The arrays are:
@vtable @code
@item MTTA
        A 
@item MTTB
        B 
@item MTTA
        C
@item MTTD
        D
@item MTTE
        E
@end vtable

@node Descriptor matrices (m),  , Descriptor matrices (reduce), Descriptor matrices
@subsection Language m (dm.m)
@cindex Descriptor matrices (m)
@cindex dm.m
The system descriptor matrices (@pxref{Descriptor matrices})
are represented in the m (@pxref{m}) language as  
an m-function of the form:

@example
function [A,B,C,D,E] = sys_dm
@end example

System numeric parameters (@pxref{Numeric parameters})
are passed via global variables defined in the _numpar.m file.
@c (@pxref{numpar.m}). 
Thus the system descriptor matrices are
typically generated in Octave (@pxref{Octave}) as follows:

@example
sys_numpar
[A,B,C,D,E] = sys_dm
@end example

Parameters can be changed from their default values by entering
their values directly into Octave (@pxref{Octave})  and then invoking
@code{sys_dm}; for example
@example
sys_numpar
par_1 = 25
par_2 = par_1 + 3
[A,B,C,D,E] = sys_dm
@end example


@node Report,  , Descriptor matrices, Representations
@section Report (rep)
@cindex Report
@cindex rep

@strong{MTT} has a report-generator feature. The user specifies the
report contents in a text file (@pxref{Report (text)}) using an
appropriate text editor (@pxref{Text editors}).

For example, the report can be viewed by typing
@example
mtt system rep view
@end example


@menu
* Report (text)::               
* Report (view)::               
@end menu

@node Report (text), Report (view), Report, Report
@subsection Language text (rep.txt)
@cindex Report (text)
@cindex rep.txt 

The user specifies the report contents in a text file (@pxref{Report
(text)}) using an appropriate text editor (@pxref{Text editors}).
The text file contains lines which are either comments (indicated by %)
or valid @strong{MTT} commands. The report will then contain appropriate
sections. The following languages are supported by the report generator:
@ftable @code
@item m
        @code{octave} a high-level interactive language for numerical
        computation.
@item r
        @code{reduce}  a high-level interactive language for symbolic
        computation.
@item tex
        @code{latex} a text processor.
@item ps
        @code{ghostview} another document viewer.
@item c
        @code{gcc} a c compiler.
@end ftable
For example:
@example
mtt rc abg tex
mtt rc cbg ps
mtt rc struc tex
mtt rc ode tex
mtt rc sro ps
mtt rc tf tex
mtt rc lmfr ps
@end example

The acausal bond graph (abg) (@pxref{Acausal bond graph (abg)}) with the
tex language is handled in a special way: the acausal Bond Graph  in
fig format (@pxref{Language fig (abg.fig)}), the label file (@pxref{Labels (lbl)})
the description file (@pxref{Detailed}), together with
corresponding subsystems are included in the report. It is recommended
that the first (non-comment line) in the file should be:
@example
mtt <system> abg tex
@end example
where @code{<system>} is the name of the (top-level) system.

As usual, @strong{MTT} provides a default text file to be edited by the
user (@pxref{Text editors}).

In the special case that the first argument to mtt (normally the system)
is a directory, a default text file is provided which generates a report
for all systems to be found in that directory tree.

@node Report (view),  , Report (text), Report
@subsection Language view
@cindex Report (view)
@cindex view Report
This representation has the standard text view
(@pxref{Views}).

@node Extending MTT, Documentation, Representations, Top
@comment  node-name,  next,  previous,  up
@chapter Extending MTT
@cindex Extending MTT
@cindex Make

@strong{MTT} has a number of built-in mechanisms for the user to extend
its capabilities. As @strong{MTT} is based on `Make' it is unsurprising
that some of these  involve the creation of `make files'. 

@menu
* Makefiles::                   
* New (DIY) representations::   
* Component library::           
@end menu

@node Makefiles, New (DIY) representations, Extending MTT, Extending MTT
@comment  node-name,  next,  previous,  up
@section Makefiles
@cindex Makefiles

If a file called `Makefile' exists in the current directory,
@strong{MTT} executes it using make before doing anything else. This is
useful if one of the .txt files contains a reference to, for example, an
octave function of which @strong{MTT} unaware. Such a function can be
created using the makefile. An example `Makefile' is
@example
# Makefile for the Two link GMV example

all: msdP_tf.m TwoLinkP_obs.m TwoLinkP_sm.m twolinkp_sm.m TwoLinkGMV_numpar.m 

msdP_tf.m: msdP_abg.fig 
        mtt -q msdP tf m

TwoLinkP_obs.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
        mtt -q TwoLinkP obs m

TwoLinkP_sm.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
        mtt -q TwoLinkP sm m

twolinkp_sm.m: TwoLinkP_sm.m
        cp -v TwoLinkP_sm.m twolinkp_sm.m

TwoLinkGMV_numpar.m: TwoLinkGMV_numpar.txt
        mtt -q TwoLinkGMV numpar m
@end example
All of the files in the line stating `all:' are created when
@strong{MTT} is executed (if they don't already exist).

@node New (DIY) representations, Component library, Makefiles, Extending MTT
@comment  node-name,  next,  previous,  up
@section New (DIY) representations
@cindex New representations
@cindex DIY representations

It may be convenient to create new representations for @strong{MTT}; in
particular, it is nice to be able to include the result of some
numerical or symbolic computations within an @strong{MTT} report
(@pxref{Report}). Therefore @strong{MTT} provides a mechanism for doing
this.

Future extensions of @strong{MTT} will use such representations stored
in $MTT_REP.

There are three parts to creating a DIY representation called myrep
@enumerate
@item Creating a make file in Make format called myrep_rep.make
@item Optionally creating a shell script called myrep_rep.sh
@item Optionally creating a documentation file in LaTeX format called myrep_rep.tex
@end enumerate

@menu
* Makefile (DIY representations)::  
* Shell-script (DIY representations)::  
* Documentation (DIY representations)::  
@end menu

@node Makefile (DIY representations), Shell-script (DIY representations), New (DIY) representations, New (DIY) representations
@comment  node-name,  next,  previous,  up
@subsection Makefile
@cindex New representations
@cindex DIY representations
@cindex Makefile

To create a new representation `myrep' in a language `mylang', create a
file with the name
@example
myrep_rep.make
@end example
This file must contain text in `make' syntax. It is executed by
@strong{MTT} and the two arguments `SYS' (the system name) and `LANG'
(the language) are passed to it by @strong{MTT}. Note that @strong{MTT}
cannot know of any prerequisites, but these can be explicitly included in
the makefile (which may include execution of @strong{MTT} itself.

The following example declares the new representation `ident' which is
created in conjunction with the shell-script ident_rep.sh (@pxref{Shell-script (DIY
representations)}).

@verbatim
# -*-makefile-*-

#SUMMARY 	Identification
#DESCRIPTION 	Partially know system identification using
#DESCRIPTION    using bond graphs

# Makefile for representation ident
# File ident_rep.make

#Copyright (C) 2000,2001,2002 by Peter J. Gawthrop

## Model targets
model_reps =  ${MTT_SYS}_sympar.m ${MTT_SYS}_simpar.m ${MTT_SYS}_state.m 
model_reps += ${MTT_SYS}_numpar.m ${MTT_SYS}_input.m ${MTT_SYS}_ode2odes.m  
model_reps += ${MTT_SYS}_def.m 

## Prepend s to get the sensitivity targets
sensitivity_reps = ${model_reps:%=s%}

## Model prerequisites
model_pre =  ${MTT_SYS}_abg.fig ${MTT_SYS}_lbl.txt 
model_pre += ${MTT_SYS}_rdae.r ${MTT_SYS}_numpar.txt

## Prepend s to get the sensitivity targets
sensitivity_pre = ${model_pre:%=s%}


## Simulation targets
sims = ${MTT_SYS}_sim.m s${MTT_SYS}_ssim.m

## m-files needed for ident
ident_m = ${MTT_SYS}_ident.m ${MTT_SYS}_ident_numpar.m 

## Targets for the ident simulation
ident_reps = ${ident_m} ${sims} ${model_reps} ${sensitivity_reps}

## ps output files etc
psfiles = ${MTT_SYS}_ident.ps ${MTT_SYS}_ident.comparison.ps
figfiles = ${psfiles:%.ps=%.fig}
gdatfiles = ${psfiles:%.ps=%.gdat}
datfiles = ${psfiles:%.ps=%.dat2}

## LaTeX files etc
latexfiles = ${MTT_SYS}_ident_par.tex

all: ${MTT_SYS}_ident.${MTT_LANG}

echo:
	echo "sims: ${sims}"
	echo "model_reps: ${model_reps}"
	echo "sensitivity_reps: ${sensitivity_reps}"
	echo "ident_reps: ${ident_reps}"

${MTT_SYS}_ident.view: ${psfiles}
	ident_rep.sh ${MTT_SYS} view

${psfiles}: ${figfiles}
	ident_rep.sh ${MTT_SYS} ps

${figfiles}: ${gdatfiles}
	ident_rep.sh ${MTT_SYS} fig

${gdatfiles}: ${datfiles}
	ident_rep.sh ${MTT_SYS} gdat

${datfiles} ${latexfiles}: ${ident_reps}
	ident_rep.sh ${MTT_SYS} dat2

${MTT_SYS}_ident.m: 
	ident_rep.sh ${MTT_SYS} m

${MTT_SYS}_ident_numpar.m:
	ident_rep.sh ${MTT_SYS} numpar.m

## System model reps
## Generic txt files 
${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* txt

## Specific m files
${MTT_SYS}_ode2odes.m: ${model_pre}
	mtt -q -stdin ${MTT_OPTS} ${MTT_SYS} ode2odes m

${MTT_SYS}_sim.m: ${MTT_SYS}_ode2odes.m
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} sim m

## Numpar files
${MTT_SYS}_numpar.m:
	mtt ${MTT_SYS} numpar m

## Sympar files
${MTT_SYS}_sympar.m:
	mtt ${MTT_SYS} sympar m

## Generic txt to m
${MTT_SYS}_%.m: ${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* m

## r files
${MTT_SYS}_def.r: ${MTT_SYS}_abg.fig
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} def r

${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} rdae r

## Sensitivity model reps
## Generic txt files 
s${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} $* txt

## Specific m files
## Numpar files
s${MTT_SYS}_numpar.m:
	mtt -s s${MTT_SYS} numpar m

## Sympar files
s${MTT_SYS}_sympar.m:
	mtt -s s${MTT_SYS} sympar m

s${MTT_SYS}_ode2odes.m: ${sensitivity_pre}
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ode2odes m

s${MTT_SYS}_ssim.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ssim m

s${MTT_SYS}_def.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} def m


## Generic txt to m
s${MTT_SYS}_%.m: s${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* m

## r files
s${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} rdae r

@end verbatim

@node Shell-script (DIY representations), Documentation (DIY representations), Makefile (DIY representations), New (DIY) representations
@comment  node-name,  next,  previous,  up
@subsection Shell-script
@cindex New representations
@cindex DIY representations
@cindex Shell-script

For more complex DIY representations, it is convenient to define new
commands to be used by the Makefile (@pxref{Makefile (DIY
representations)}).

The following example shows this in the context of the DIY
representation `ident' used as an example in the previous section
(@pxref{Makefile (DIY representations)}).


@verbatim
#! /bin/sh

## ident_rep.sh
## DIY representation "ident" for mtt
# Copyright (C) 2002 by Peter J. Gawthrop

ps=ps

sys=$1
rep=ident
lang=$2
mtt_parameters=$3
rep_parameters=$4

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_ident.dat2
dat2s_file=${sys}_idents.dat2
ident_numpar_file=${sys}_ident_numpar.m
option_file=${sys}_ident_mtt_options.txt

## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

check_new_options() {
    if [ -f "${option_file}" ]; then
	old_options=`cat ${option_file}`
        if [ "${mtt_options}" != "${old_options}" ]; then
	   echo ${mtt_options} > ${option_file}
	fi
    else
	echo ${mtt_options} > ${option_file}
    fi
}

## Make the _ident.m file
make_ident() {
filename=${sys}_${rep}.m
date=`date`
echo Creating ${filename}

cat > ${filename} <<EOF    
function [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)

  ## usage:  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)
  ##
  ## last      last time in run
  ## ppp_names Column vector of names of ppp params
  ## par_names Column vector of names of estimated params
  ## extras    Structure containing additional info
  ##
  ## Created by MTT on ${date}
 
  ## Sensitivity system name
  system_name = "s${sys}"

  ##Sanity check
  if nargin<3
    printf("Usage: [y,u,t] = ${sys}_ident(y,u,t,par_names,Q,extras);");
    return
  endif

  if nargin<6
    ## Set up optional parameters
    extras.criterion = 1e-3;
    extras.emulate_timing = 0;
    extras.max_iterations = 10;
    extras.simulate = 2;
    extras.v =  1e-2;
    extras.verbose = 1;
    extras.visual = 1;
  endif
  
  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  sympar  = ${sys}_sympar;
  simpar  = ${sys}_simpar;
  sympars  = s${sys}_sympar;
  simpars  = s${sys}_simpar;

  ## Parameter indices
  i_par = ppp_indices (par_names,sympar,sympars);

  ## Initial model state
  x_0 = zeros(2*n_x,1);

  ## Initial model parameters
  par_0 = s${sys}_numpar;

  ## Reset simulation parameters
  [n_data,m_data] = size(y);
  dt = t(2)-t(1);
  simpars.last = (n_data-1)*dt;
  simpars.dt = dt;

  ## Identification
  [epar,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpars,u,y,i_par,Q,extras);
  
  ## Do some plots
  figure(1);
  title("Comparison of data");
  xlabel("t");
  ylabel("y");
  [N,M] = size(Y);
  plot(t,Y(:,M-n_y+1:M),"1;Estimated;", t,y,"3;Actual;");
  figfig("${sys}_ident_comparison");

  ## Create a table of the parameters
  [n_par,m_par] = size(i_par);
  fid = fopen("${sys}_ident_par.tex", "w");
  fprintf(fid,"\\\\begin{table}[htbp]\\n");
  fprintf(fid," \\\\centering\\n");
  fprintf(fid," \\\\begin{tabular}{|l|l|}\\n");
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"  Name & Value \\\\\\\\ \\n");
  fprintf(fid,"  \\\\hline\\n");
  for i = 1:n_par
    fprintf(fid,"$%s$ & %4.2f \\\\\\\\ \\n", par_names(i,:), epar(i_par(i,1)));
  endfor
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"\\\\end{tabular}\\n");
  fprintf(fid,"\\\\caption{Estimated Parameters}\\n");
  fprintf(fid,"\\\\end{table}\\n");
  fclose(fid);

endfunction
EOF
}

make_ident_numpar() {
echo Creating ${ident_numpar_file}
cat > ${sys}_ident_numpar.m <<EOF
function [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;

  ## usage: [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  ## Edit for your own requirements
  ## Created by MTT on ${date}

    
  ## This section sets up the data source
  ## simulate = 0  Real data (you supply ${sys}_ident_data.dat)
  ## simulate = 1  Real data input, simulated output
  ## simulate = 2  Unit step input, simulated output
  simulate = 2;
  

  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  simpars = s${sys}_simpar;

  ## Access or create data
  if (simulate<2)		# Get the real data
    if (exist("${sys}_ident_data.dat")==2)
      printf("Loading ${sys}_ident_data.dat\n");
      load ${sys}_ident_data.dat
    else
      printf("Please create a loadable file ${sys}_ident_data.dat containing y,u and t\n");
      return
    endif
  else 
    switch simulate
      case 2			# Step simulation
	t = [0:simpars.dt:simpars.last]';
	u = ones(size(t));
      otherwise
	error(sprintf("simulate = %i not implemented", simulate));
    endswitch
  endif
  
  if (simulate>0)
    par = ${sys}_numpar();
    x_0 = ${sys}_state(par);
    dt = t(2)-t(1);
    simpars.dt = dt;
    simpars.last = t(length(t));
    y =  ${sys}_sim(zeros(n_x,1), par, simpars, u);
  endif

  ## Default parameter names - Put in your own here
  sympar = ${sys}_sympar;	# Symbolic params as structure
  par_names = struct_elements (sympar);	# Symbolic params as strings
  [n,m] = size(par_names);	# Size the string list

  ## Sort by index
  for [i,name] = sympar
    par_names(i,:) = sprintf("%s%s",name, blanks(m-length(name)));
  endfor
  
  ## Output weighting vector
  Q = ones(n_y,1);
  
  ## Extra parameters
  extras.criterion = 1e-5;
  extras.emulate_timing = 0;
  extras.max_iterations = 10;
  extras.simulate = simulate;
  extras.v =  1e-2;
  extras.verbose = 1;
  extras.visual = 1;

endfunction
EOF
}

make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras);
  [N,M] = size(Y);
  y_est = Y(:,M);
  data = [t,y_est,u];
  save -ascii ${dat2_file} data
EOF

## Tidy up the latex stuff - convert foo_123 to foo_{123}
cat ${sys}_ident_par.tex > mtt_junk
sed  -e "s/_\([a-z0-9,]*\)/_{\1}/g" < mtt_junk >${sys}_ident_par.tex
rm mtt_junk
}

case ${lang} in
    numpar.m)
        ## Make the numpar stuff
        make_ident_numpar;
	;;
    m)
        ## Make the code
        make_ident;
	;;
    dat2)
        ## The dat2 language (output data) & fig file
	make_dat2; 
	;;
    gdat)
        cp ${dat2_file} ${dat2s_file} 
	dat22dat ${sys} ${rep} 
        dat2gdat ${sys} ${rep}
	;;
    fig)
        gdat2fig ${sys}_${rep}
	;;
    ps)
        figs=`ls ${sys}_ident*.fig | sed -e 's/\.fig//'`
	for fig in ${figs}; do
            fig2dev -Leps ${fig}.fig > ${fig}.ps
	done
	texs=`ls ${sys}_ident*.tex | sed -e 's/\.tex//'`
	for tex in ${texs}; do
          makedoc "" "${sys}" "ident_par" "tex" "" "" "$ps"
          doc2$ps ${sys}_ident_par "$documenttype"
	done
	;;
    view)
	pss=`ls ${sys}_ident*.ps` 
        echo Viewing ${pss}
        for ps in ${pss}; do
          gv ${ps}&
	done
	;;
    *)
	echo Language ${lang} not supported by ${rep} representation
        exit 3
esac



@end verbatim

@node Documentation (DIY representations),  , Shell-script (DIY representations), New (DIY) representations
@comment  node-name,  next,  previous,  up
@subsection Documentation
@cindex New representations
@cindex DIY representations
@cindex Documentation


@node Component library,  , New (DIY) representations, Extending MTT
@comment  node-name,  next,  previous,  up
@section Component library
@cindex Component library
@cindex component
@cindex Component library

If @strong{MTT} does not recognise a component (eg named MyComponent) as
a simple component (@pxref{Simple components}) or as already existing,
it searches the library search path $MTT_COMPONENTS
(@pxref{$MTT_COMPONENTS}) for a directory called MyComponent containing
MyComponent_lbl.txt. It then copies the @emph{entire} directory into the
current working directory. Thus, for example, the directory could
contain MyComponent_desc.tex MyComponent_abg.fig MyComponent_lbl.txt and MyComponent_cr.r in
addition to MyComponent_lbl.txt.

@c      node   next  prev  up
@node   Documentation, Languages, Extending MTT, Top
@chapter Documentation
@cindex Documentation

@menu
* Manual (Documentation)::      
* On-line documentation::       
@end menu

@node   Manual (Documentation), On-line documentation, Documentation, Documentation
@section Manual
@cindex Manual

MTT is documented in this manual. The manual can be invoked in various
ways:

@vtable @code
@item mtt manual
      Brings up a pdf version of the manual
@item mtt info
      Brings up an xterm containing an info version of the manual
@item mtt hinfo
      Brings up an html browser containing the manual
@item emacs
      type ^h^i followed by mmtt in the command window
@item browser
      point browser to http://mtt.sf.net
@end vtable

@node On-line documentation,  , Manual (Documentation), Documentation
@section On-line documentation
@cindex Components 
@cindex Examples
@cindex Documentation
@cindex On-line documentation

@strong{MTT} components, constitutive relations, examples and representations in libraries
(@pxref{Component library}) are documented in two ways:

@enumerate 
@item brief 
@item verbose
@end enumerate

@menu
* Brief::                       
* Detailed::                    
@end menu

@node Brief, Detailed, On-line documentation, On-line documentation
@subsection Brief on-line documentation
@cindex Brief documentation

Documentation of DIY components, examples, constitutive relationships
and representations is provides by the programmer by inserting code of
the form

@example
#SUMMARY     One line summary
#DESCRIPTION Multi-line
#DESCRIPTION More detailed description
@end example

within the appropriate file (usually at or near the top):
@vtable @code
@item components
      _lbl.txt (@pxref{Labels (lbl)})
@item examples
      _lbl.txt (@pxref{Labels (lbl)})
@item constitutive relations
      _cr.r (@pxref{DIY constitutive relationships})
@item representations
      _rep.make (@pxref{Makefile (DIY representations)})
@end vtable

This documentation is accessed by the user in various ways
@vtable @code
@item mtt help name
      prints basic information on the screen
@item mtt system lbl view
      gives formatted information about the component or example
@item Including mtt system abg tex in the _rep.txt file
      gives formatted information about the component or example
      within the report
@end vtable

@node Detailed,  , Brief, On-line documentation
@subsection Detailed on-line documentation
@cindex Detailed documentation
@cindex Description
@cindex desc

DIY components, examples, constitutive relationships can be described
textually in LaTeX (.tex) description file; this is the only language
for this representation. This representation is used by the LaTeX
language version (@pxref{Language tex (abg.tex)}) of the acausal bond
graph representation (@pxref{Acausal bond graph (abg)}).

The file may contain any  LaTeX commands
valis for the ``article'' document type but must @strong{not} contain:
@itemize @bullet
@item documentclass commands
@item document environments
@end itemize

@c      node   next  prev  up
@node   Languages, Language tools, Documentation, Top
@chapter Languages
@cindex Languages
@pindex Languages


@c      node   next  prev  up
@menu
* Fig::                         r
* m::                           
* Reduce::                      
* c::                           
@end menu

These are a number of languages used by @strong{MTT} to implement the
various representations.
Each has associated Language tools (@pxref{Language tools}) to
manipulate and/or view the representation.

@ftable @code
@item fig
        @code{Fig} a graphical description language.
@item m
        @code{octave} a high-level interactive language for numerical
        computation.
@item r
        @code{reduce}  a high-level interactive language for symbolic
        computation.
@item tex
        @code{latex} a text processor.
@item dvi
        @code{xdvi} a document viewer.
@item ps
        @code{ghostview} another document viewer.
@item gdat
        @code{gnuplot} a data viewer.
@item c
        @code{gcc} a c compiler.
@item sg
	@code{scigraphica} a plotting package.
@end ftable

These tools are automatically invoked as appropriate by @strong{MTT};
but for more advanced use, these tools can be used directly on files
(with the appropriate suffix) generated by @strong{MTT}.



@node   Fig, m, Languages, Languages
@section Fig
@cindex Fig
@pindex Fig
Please see xfig documentation.

@node   m, Reduce, Fig, Languages
@section m
@cindex m
@pindex m
Please see Octave documentation 
@ifhtml
<A HREF="http://www.che.wisc.edu/octave/">Octave</A> documentation.
<A HREF="http://www.mathworks.com/homepage.html">Matlab</A> documentation.
@end ifhtml


@node   Reduce, c, m, Languages
@section Reduce
@cindex Reduce
@pindex Reduce
Please see the reduce documentation.

@node c,  , Reduce, Languages
@comment  node-name,  next,  previous,  up
@section c
@cindex c
@pindex c
Please see the gcc documentation.
@node Language tools, Administration, Languages, Top
@comment  node-name,  next,  previous,  up
@chapter Language tools
@cindex  Language tools

@menu
* Views::                       
* Xfig::                        
* Text editors::                
* Octave::                      
* LaTeX::                       
@end menu

@node Views, Xfig, Language tools, Language tools
@comment  node-name,  next,  previous,  up
@section Views
@cindex views

A number of representations (@pxref{Representations}) have a language
representation which is particularly useful for viewing by the
user. These views are
invoked, where appropriate by the command:
@example
mtt sys rep view
@end example
where @code{sys} is the system name and @code{rep} a corresponding representation.

@node Xfig, Text editors, Views, Language tools
@comment  node-name,  next,  previous,  up
@section Xfig
@cindex Xfig

@node Text editors, Octave, Xfig, Language tools
@comment  node-name,  next,  previous,  up
@section Text editors
@cindex Text editors
All representations live in text files and thus may be edited using your
favourite text editor; however, the Fig (@pxref{Fig}) representation is
pretty meaningless in this form and so you should use Xfig
(@pxref{Xfig}) for representation in this language.

Its up to you which text editor to use. I recommend emacs, but simpler
(and less powerful) editors such as xedit, textedit and vi are also ok.

I usually run @strong{MTT} out of an emacs shell window and keep the
rest of the files in emacs buffers.

@node Octave, LaTeX, Text editors, Language tools
@comment  node-name,  next,  previous,  up
@section Octave
@cindex Octave
@cindex Matlab
@cindex m-files
@cindex Octave interface
@cindex mtt.m

Octave is a numerical matrix-based language @xref{Top,
,Octave,Octave,Octave}.  It is similar to Matlab in many ways. In most
cases, m-files generated by @strong{MTT} can be understood by both
Matlab and Octave (and no doubt other Matlab lookalikes).

 @strong{MTT} provides the octave function @code{mtt}. The octave
 command
@example
help mtt
@end example
gives the following information:
@example
 usage:  mtt (system[,representation,language])

 Invokes mtt from octave to generate system_representation.language
 Ie equivalent to "mtt system representation language" at the shell
 Representation and language defualt to "sm" and "m" respectively

@end example

Thus for example, if octave is in the directory containing the system
rc the following session generates the state matrices of the system "rc"
with the defaut capacitance but resitance r=0.1.
@example
octave> mtt("rc");
Creating rc_rbg.m
Creating rc_cmp.m
Creating rc_fig.fig
Creating rc_sabg.fig
Creating rc_alias.txt
Creating rc_alias.m
Creating rc_sub.sh
Creating rc_abg.m
Creating rc_cbg.m (maximise integral causality)
Creating rc_type.sh
Creating rc_ese.r
Creating rc_def.r
Creating rc_struc.txt
Creating rc_rdae.r
Creating rc_subs.r
Creating rc_cr.txt
Creating rc_cr.r
Copying CR SS to here from
Copying CR lin to here from
Creating rc_dae.r
Creating rc_sympar.txt
Creating rc_sympar.r
Creating rc_cse.r
Creating rc_sspar.r
Creating rc_csm.r
Creating rc_ode.r
Creating rc_ss.r
Creating rc_sm.r
Creating rc_switch.txt
0 switches found
Creating rc_sympars.txt
Creating rc_sm.m
Copying rc_sm.m
octave> mtt("rc","numpar");
Creating rc_numpar.txt
Creating rc_numpar.m
Copying rc_numpar.m
octave> mtt("rc","sympar");
Creating rc_sympar.m
Copying rc_sympar.m
octave> par = rc_numpar
par =

  1
  1

octave> sym = rc_sympar;

octave> par(sym.r) = 0.1;
octave> [A,B,C,D] = rc_sm(par)
A = -10

B = 10

C = 1

D = 0

octave> 
@end example
generates the data structure rc corresponding the the bond graph of the
system called `rc'.
The following octave commands then generate the step reponse and bode
diagram respectively:
@example
step(rc);
bode(rc);
@end example


@menu
* Octave control system toolbox (OCST)::  
* Creating GNU Octave .oct files::  
* Creating Matlab .mex files::  
* Embedding MTT models in Simulink::  
@end menu

@node Octave control system toolbox (OCST), Creating GNU Octave .oct files, Octave, Octave
@comment  node-name,  next,  previous,  up
@subsection Octave control system toolbox (OCST)
@cindex Octave
@cindex toolbox
@cindex OCST
@cindex control systems
@cindex mtt2sys

@strong{MTT} provides an interface to the Octave control system toolbox
(OCST) using the mfile @code{mtt2sys}. the octave command
@example
help mtt2sys
@end example
gives the following information.
@example
 usage:  sys = mtt2sys (Name[,par])

 Creates a sys structure for the Octave Control Systems Toolbox
 from an MTT system with name "Name"
 Optional second argument is system parameter list
 Assumes that Name_sm.m, Name_struc.m and Name_numpar.m exist
@end example

Thus for example, if octave is in the directory containing the system
rc:
@example
rc = mtt2sys("rc");
@end example
generates the data structure rc corresponding the the bond graph of the
system called `rc'.
The following octave commands then generate the step reponse and bode
diagram respectively:
@example
step(rc);
bode(rc);
@end example

@node Creating GNU Octave .oct files, Creating Matlab .mex files, Octave control system toolbox (OCST), Octave
@comment  node-name,  next,  previous,  up
@subsection Creating GNU Octave .oct files
@cindex Creating GNU Octave .oct files

GNU Octave dynamically loaded functions (.oct files) can be created by
instructing @strong{MTT} to create the ``oct'' representation:

@example
  mtt [options] sys ode oct
@end example

This will cause @strong{MTT} to create the C++ representation of the system
(sys_ode.cc) and to then compile it as a shared object suitable for
use within Octave. The resultant file may be used in an identical
manner to the equivalent, but generally slower, interpreted .m file.

Usage information for the function may be obtained within Octave in the usual manner:

@example
  octave:1> help rc_ode

  rc_ode is the dynamically-linked function from the file
  /home/mttuser/rc/rc_ode.oct

  Usage: [mttdx] = rc_ode(mttx,mttu,mttt,mttpar)
  Octave ode representation of system rc
  Generated by MTT on Fri Jul  5 11:23:08 BST 2002
@end example

Note that the first line of output from Octave identifies whether the
compiled or interpreted function is being used.

Alternatively, standard representations may be generated using the
Octave DLDs by use of the ``-oct'' switch:

@example
  mtt -oct rc odeso view
@end example

In order to successfully generate .oct files, Octave must be correctly
configured prior to compilation and certain headers and libraries must
be correctly installed on the system (@pxref{.oct file dependencies}).

@node  Creating Matlab .mex files, Embedding MTT models in Simulink, Creating GNU Octave .oct files, Octave
@comment  node-name,  next,  previous,  up
@subsection Creating Matlab .mex files
@cindex Creating Matlab .mex files

On GNU/Linux systems, Matlab dynamically linked executables (.mexglx
files) can created by instructing @strong{MTT} to create the
``mexglx'' representation:

@example
  mtt [options] sys ode mexglx
@end example

This will cause @strong{MTT} to create the C++ representation of the
system (sys_ode.cc) and to then compile it as a shared object suitable
for use within Matlab.

If it is necessary to compile mex files for another platform, then the
usual C++ representation (generated with the -cc flag) can be created
and the resultant file compiled with the -DCODEGENTARGET=MATLABMEX
flag on the target platform.

@example
  mtt_machine:
  mtt -cc rc ode cc

  matlab_machine:
  matlab> mex -DCODEGENTARGET=MATLABMEX rc_ode.cc
@end example

@node  Embedding MTT models in Simulink,  , Creating Matlab .mex files, Octave
@comment  node-name,  next,  previous,  up
@subsection Embedding MTT models in Simulink
@cindex Embedding MTT models in Simulink

It is possible to embed @strong{MTT} functions or entire @strong{MTT}
models within Simulink simulations as Sfun blocks. If the zip package
is installed on the system, the command

@example
  mtt sys sfun zip
@end example

will create a compressed archive containing sys.mdl, which may be
embedded into a larger Simulink model. Also contained within the
archive will be four sys_sfun*.c files,

@itemize @bullet
@item
sys_sfun.c
model state and output equations
@item
sys_sfun_ae.c
model algebraic equations
@item
sys_sfun_input.c
model inputs
@item
sys_sfun_interface.c
interface between MTT model and Simulink
@end itemize

The last of these files must be edited to correctly map the inputs and
outputs between the @strong{MTT} and Simulink models. The two sections
to edit are clearly marked with

@example
  @code{/* Start EDIT */}
  @code{....}
  @code{/* End EDIT */}
@end example

These four files should then be compiled with the Matlab ``mex''
compiler as described in the @emph{README} file in the archive.

If it is desired to compile the .mex files directly from within
@strong{MTT} on a machine which has the Matlab header files installed,
this may be done with the command

@example
  mtt sys sfun mexglx 
@end example

which will generated the four .mex files and the .mdl file. In this
case, the user must ensure that @emph{sys_sfun_interface.c} has been
correctly edited prior to compilation.

Note that solution of algebraic equations within Simulink is not
possible unless the @emph{Matlab Optimisation Toolbox} is installed.

@node LaTeX,  , Octave, Language tools
@comment  node-name,  next,  previous,  up
@section LaTeX
@cindex LaTeX

LaTeX is a powerful text processor which @strong{MTT} uses to provide
visual output.

@node Administration, Glossary, Language tools, Top
@comment  node-name,  next,  previous,  up
@chapter  Administration
@cindex  Administration

@menu
* Software components::         
* REDUCE setup::                
* Octave setup::                
* Paths::                       
* File structure::              
* GNU Free Documentation License::  
* Copying::                     
@end menu

@node Software components, REDUCE setup, Administration, Administration
@comment  node-name,  next,  previous,  up
@section  Software components
@cindex  Software components

@strong{MTT} is built from a set of readily-available  software tools.
These are:
@itemize @bullet
@item General purpose software tools.
@item Octave (@pxref{Octave setup})
@item REDUCE  (@pxref{REDUCE setup})
@end itemize

The General purpose tools are (these will all be available with a
standard Linux distribution):
@vtable @code
@item sh
        Bourne shell
@item gmake
        Gnu make
@item gawk
        Gnu awk
@item sed
        Gnu sed
@item grep
        Gnu grep
@item comm
        Gnu Compare sorted files by line
@item xfig
        Figure editor, version 3 or greater.        
@item fig2dev
        Fig file conversion, version 3 or greater. 
@item ghostview
        postscript viewer
@item xdvi
        dvi viewer
@item dvips
        dvi to postscript conversion
@item latex
        the text processor (LaTeX2e needed)
@item latex2html
        converts latex to html
@item perl
        needed for latex2html
@item gnuplot
        a graph plotting program
@item gnuscape
        or other web/html browser such as netscape, Red Baron etc.
@item gcc
        GNU c compiler
@end vtable

@ifhtml
<A HREF="http://home.pages.de/~GNU/">GNU</A> documentation.
@end ifhtml



@node REDUCE setup, Octave setup, Software components, Administration
@comment  node-name,  next,  previous,  up
@section  REDUCE setup
@cindex REDUCE setup

Symbolic algebra is performed by REDUCE, which although not free
software is the the result of international collaboration. The version I
use is obtained from:
@quotation
ZIB ( http://www.zib.de )
@end quotation
@ifhtml
<A HREF="http://www.reduce-algebra.com">REDUCE</A> documentation.
<A HREF="http://www.zib.de">ZIB</A> documentation.
@end ifhtml

@node Octave setup, Paths, REDUCE setup, Administration
@comment  node-name,  next,  previous,  up
@section Octave setup
@cindex  Octave setup

Octave is available at various web sites including:
@uref{http://www.octave.org}

@menu
* .octaverc::                   
* .oct file dependencies::      
@end menu

@node .octaverc, .oct file dependencies, Octave setup, Octave setup
@comment  node-name,  next,  previous,  up
@subsection .octaverc
@vindex  .octaverc


The @file{.octaverc} file should contain the following lines:
@example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Startup file for Octave for use with MTT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

implicit_str_to_num_ok = 1;
empty_list_elements_ok = 1;

@end example

@node .oct file dependencies,  , .octaverc, Octave setup
@comment  node-name,  next,  previous,  up Additionally, it is necessary to
@subsection .oct file dependencies
Successful compilation of .oct code requires that Octave has been
configured to use dynamically linked libraries and that the Octave
libraries @code{liboctave}, @code{libcruft} and @code{liboctinterp}
are available on the system.

This can be acheived by compiling Octave from the source code, configured
with the options @code{--enable-shared} and @code{--enable-dl}.

A number of additional libraries and headers are also required to be
installed on a system. These include,
@itemize @bullet
@item
@emph{ncurses} and @emph{readline}
               terminal control routines
@item
@emph{blas} or @emph{altas}
            basic linear algebra subprograms, usually optimised for the specific processor
@item
@emph{fftw}
        fast Fourier transform routines
@item
@emph{g2c}
        GNU Fortran to C conversion routines
@item
@emph{kpathsea}
        TeX path search routines
@end itemize

Note that on many GNU/Linux distributions, the necessary headers are
contained in development packages which must be installed in addition
to the standard library package.

Further information on configuring and installing Octave to handle dynamic
libraries (DLDs) can be found in the
@uref{http://www.octave.org/docs.html,Octave documentation}.


@node Paths, File structure, Octave setup, Administration
@comment  node-name,  next,  previous,  up
@section Paths
@cindex paths
@cindex mttrc

There are a number of paths that must be set correctely for @strong{MTT}
to work. These are normally set up by sourcing the file @code{mttrc} that
lives in the @strong{MTT} home directory.

@menu
* $MTTPATH::                    
* $MTT_COMPONENTS::             
* $MTT_CRS::                    
* $MTT_EXAMPLES::               
* $OCTAVE_PATH::                
@end menu

@node $MTTPATH, $MTT_COMPONENTS, Paths, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTTPATH
@vindex $MTTPATH
The environment variable $MTTPATH points to the mtt home directory.
This is usually @code{/usr/local/lib/mtt}.

@node $MTT_COMPONENTS, $MTT_CRS, $MTTPATH, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTT_COMPONENTS
@vindex $MTT_COMPONENTS
The environment variable $MTT_COMPONENTS is a colon-separated path
pointing to directories containing components and subsystems.
By default
@example
MTT_COMPONENTS=.:$MTT_LIB/lib/comp/
@end example
but you may wish to add your own component libraries:
@example
MTT_COMPONENTS=my_library_path:$MTT_COMPONENTS
@end example

@node $MTT_CRS, $MTT_EXAMPLES, $MTT_COMPONENTS, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTT_CRS
@vindex $MTT_CRS
The environment variable $MTT_CRS is a colon-separated path
pointing to directories containing constitutive relationships.
By default
@example
MTT_CRS=$MTTPATH/lib/cr
@end example
but you may wish to add your own component libraries:
@example
MTT_CRS=my_cr_path:$MTT_CRS
@end example

@node $MTT_EXAMPLES, $OCTAVE_PATH, $MTT_CRS, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTT_EXAMPLES
@vindex $MTT_EXAMPLES
The environment variable $MTT_EXAMPLES is a colon-separated path
pointing to directories containing EXAMPLES and subsystems.
By default
@example
MTT_EXAMPLES=$MTTPATH/lib/examples
@end example
but you may wish to add your own component libraries:
@example
MTT_EXAMPLES=my_examples_path:$MTT_EXAMPLES
@end example

@node $OCTAVE_PATH,  , $MTT_EXAMPLES, Paths
@comment  node-name,  next,  previous,  up
@subsection $OCTAVE_PATH
@vindex $OCTAVE_PATH

The @code{$OCTAVE_PATH} path must include the relevant paths for mtt to
work properly. In particular, it must include:
@example
$MTTPATH/trans/m
$MTTPATH/lib/comp/simple
$MTTPATH/lib/comp/compound
@end example

@node File structure, GNU Free Documentation License, Paths, Administration
@comment  node-name,  next,  previous,  up
@section  File structure
@cindex File structure
The recommended installation of @strong{MTT} uses the following
directory structure with corresponding contents. Normally, each of the
listed directories is a subdirectory of @file{/usr/local}. The directory
@code{mtt} is pointed to by $MTTPATH (@pxref{$MTTPATH}).

@vtable @file
@item mtt/bin
        This is the home directory for @strong{MTT}. @strong{MTT}  itself lives
        here along with @file{mttrc}.
@item mtt/bin/trans
        The transformations executed by @strong{MTT}.
@item mtt/bin/trans/m
        The  @code{m-files} associated with the transformations.
@item mtt/bin/trans/awk
        The  @code{awk} scripts associated with the transformations.
@item mtt/lib
        The place for components, examples and CRs which will be updated.
@item mtt/lib/comp/simple
@cindex simple components
        The  @code{m-files} defining the simple components.
@cindex compound components
@item mtt/lib/comp/compound
        The  @code{m-files} defining the compound components.
@item mtt/lib/cr/r
        constitutive relationship definitions
@item mtt/lib/examples
        Some examples. 
@item mtt/examples/metamodelling
        Examples from the book.
@item mtt/doc
        The  documentation files for @strong{MTT}.
@item mtt/doc/Examples
        Examples used in the documentation.
@end vtable

@appendix Legal stuff
@node GNU Free Documentation License, Copying, File structure, Administration
@appendixsec GNU Free Documentation License

@cindex FDL, GNU Free Documentation License
@center Version 1.2, November 2002

@display
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA  02111-1307, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display

@enumerate 0
@item
PREAMBLE

The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.

This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense.  It
complements the GNU General Public License, which is a copyleft
license designed for free software.

We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does.  But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book.  We recommend this License
principally for works whose purpose is instruction or reference.

@item
APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License.  Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein.  The ``Document'', below,
refers to any such manual or work.  Any member of the public is a
licensee, and is addressed as ``you''.  You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.

A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.

A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject.  (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.)  The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.

The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.  If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant.  The Document may contain zero
Invariant Sections.  If the Document does not identify any Invariant
Sections then there are none.

The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.  A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.

A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters.  A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text.  A copy that is not ``Transparent'' is called ``Opaque''.

Examples of suitable formats for Transparent copies include plain
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
format, @acronym{SGML} or @acronym{XML} using a publicly available
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
PostScript or @acronym{PDF} designed for human modification.  Examples
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
@acronym{JPG}.  Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, @acronym{SGML} or
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
not generally available, and the machine-generated @acronym{HTML},
PostScript or @acronym{PDF} produced by some word processors for
output purposes only.

The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page.  For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.

A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language.  (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.)  To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.

The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document.  These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.

@item
VERBATIM COPYING

You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License.  You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute.  However, you may accept
compensation in exchange for copies.  If you distribute a large enough
number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and
you may publicly display copies.

@item
COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover.  Both covers must also clearly and legibly identify
you as the publisher of these copies.  The front cover must present
the full title with all words of the title equally prominent and
visible.  You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.

If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.

It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.

@item
MODIFICATIONS

You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it.  In addition, you must do these things in the Modified Version:

@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document).  You may use the same title as a previous version
if the original publisher of that version gives permission.

@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.

@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.

@item
Preserve all the copyright notices of the Document.

@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.

@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.

@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.

@item
Include an unaltered copy of this License.

@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page.  If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.

@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on.  These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.

@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.

@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles.  Section numbers
or the equivalent are not considered part of the section titles.

@item
Delete any section Entitled ``Endorsements''.  Such a section
may not be included in the Modified Version.

@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.

@item
Preserve any Warranty Disclaimers.
@end enumerate

If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant.  To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.

You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.

You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version.  Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity.  If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.

@item
COMBINING DOCUMENTS

You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy.  If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''.  You must delete all
sections Entitled ``Endorsements.''

@item
COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.

@item
AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.

@item
TRANSLATION

Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections.  You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers.  In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.

If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.

@item
TERMINATION

You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License.  Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License.  However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.

@item
FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time.  Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.  See
@uref{http://www.gnu.org/copyleft/}.

Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation.  If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
@end enumerate

@page
@appendixsubsec ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:

@smallexample
@group
  Copyright (C)  @var{year}  @var{your name}.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.2
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.
@end group
@end smallexample

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with...Texts.'' line with this:

@smallexample
@group
    with the Invariant Sections being @var{list their titles}, with
    the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
    being @var{list}.
@end group
@end smallexample

If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.

@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

@page
@node Copying,  , GNU Free Documentation License, Administration
@appendixsec GNU GENERAL PUBLIC LICENSE
@center Version 2, June 1991

@c This file is intended to be included in another file.

@display
Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display

@page
@appendixsubsec Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software---to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

@iftex
@appendixsubsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end ifinfo

@enumerate 0
@item
This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The ``Program'', below,
refers to any such program or work, and a ``work based on the Program''
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term ``modification''.)  Each licensee is addressed as ``you''.

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

@item
You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

@item
You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

@enumerate a
@item
You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

@item
You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

@item
If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License.  (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
@end enumerate

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

@item
You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

@enumerate a
@item
Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

@item
Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

@item
Accompany it with the information you received as to the offer
to distribute corresponding source code.  (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
@end enumerate

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

@item
You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

@item
You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

@item
Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

@item
If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

@item
If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

@item
The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and ``any
later version'', you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

@item
If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

@iftex
@strong{NO WARRANTY}
@end iftex
@ifinfo
@center NO WARRANTY
@end ifinfo

@item
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

@item
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
@end enumerate

@iftex
@heading END OF TERMS AND CONDITIONS
@end iftex
@ifinfo
@center END OF TERMS AND CONDITIONS
@end ifinfo

@page
@appendixsubsec Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the ``copyright'' line and a pointer to where the full notice is found.

@smallexample
@var{one line to give the program's name and a brief idea of what it does.}
Copyright (C) @var{yyyy}  @var{name of author}

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@end smallexample

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

@smallexample
Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@end smallexample

The hypothetical commands @samp{show w} and @samp{show c} should show
the appropriate parts of the General Public License.  Of course, the
commands you use may be called something other than @samp{show w} and
@samp{show c}; they could even be mouse-clicks or menu items---whatever
suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a ``copyright disclaimer'' for the program, if
necessary.  Here is a sample; alter the names:

@example
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

@var{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
@end example

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

@node Glossary, Index, Administration, Top
@comment  node-name,  next,  previous,  up
@unnumbered Glossary
@printindex fn

@node Index,  , Glossary, Top
@comment      node-name, next,       previous, up
@unnumbered Index
@printindex cp

@contents

@bye


Added mtt/doc/mtt_banner.sh version [369093538c].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

Added mtt/doc/mtt_make_examples version [ac977b6bd2].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
## This makes all of the standard examples
## It takes a few hours.
## Copyright (C) 2003 by Peter J. Gawthrop

exampledir="$MTT_EXAMPLES"
dirname=`basename ${exampledir}`

tmpbase="$HOME/JUNK"
tmpdir="${tmpbase}/${dirname}"

first() {
    cat<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>MTT Examples</title>
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#ff0000" bgcolor="#ffff33" link="#000099" vlink="#990099" alink="#ff0000">

<h1 align="center"><font color="#ff0000">MTT Examples</font></h1>
   
<hr width="100%" size="2">
<ul>
EOF
}

entry() {
    cat<<EOF
<li>$1: <a href="./$1_rep/index.html">html, </a><a href="$1_rep.pdf">pdf.</a> 
EOF
}

last() {
    cat<<EOF
</ul>
<hr width="100%" size="2">     
Created on `date` by mtt_make_examples
<hr width="100%" size="2">     
</body>
</html>
EOF
}

## File start
first > index.html

if [ -d "${tmpdir}" ]; then
    echo "${tmpdir} exists -- using"
else
    echo "${tmpdir} does not exist -- copy from ${exampledir}"
    ## Create tmp dir
    mkdir -pv ${tmpdir}
    ## Copy to tmp
    cp -r ${exampledir} ${tmpbase}
fi

## Go to tmp and list DIRS
pushd ${tmpdir}
dirs=`ls | grep -v CVS | grep -v '\.' | grep -v _`

echo Making examples for ${dirs} in ${tmpdir}
for dir in ${dirs}; do
    echo Making examples in $dir
    mtt -q $dir rep pdf
    mtt -q $dir rep html
    entry $dir >> index.html
done

## File end
last>>index.html
popd

Added mtt/doc/reduce_reserved.tex version [b5fa8cdbe2].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\documentclass[12pt,a4paper]{book}
\newcommand{\REDUCE}{REDUCE}
\begin{document}


\appendix
\chapter{Reserved Identifiers}

We list here all identifiers that are normally reserved in \REDUCE{}
including names of commands, operators and switches initially in the system.
Excluded are words that are reserved in specific implementations of the
system.

\vspace{13pt}
\begin{list}{}{\renewcommand{\makelabel}[1]{#1\hspace{\fill}}%
               \settowidth{\labelwidth}{Numerical Operators}%
               \setlength{\labelsep}{1em}%
               \settowidth{\leftmargin}{Numerical Operators\hspace*{\labelsep}}%
               \sloppy}

\item[Commands] {\tt ALGEBRAIC} {\tt ANTISYMMETRIC}
{\tt ARRAY} {\tt BYE} {\tt CLEAR} \linebreak
{\tt CLEARRULES} {\tt COMMENT} {\tt
CONT} {\tt DECOMPOSE} {\tt DEFINE} {\tt DEPEND} {\tt DISPLAY} {\tt ED}
{\tt EDITDEF} {\tt END} {\tt EVEN} {\tt FACTOR} {\tt FOR} {\tt FORALL}
{\tt FOREACH} {\tt GO} {\tt GOTO} {\tt IF} {\tt IN} {\tt INDEX} {\tt INFIX}
{\tt INPUT} {\tt INTEGER} {\tt KORDER} {\tt LET} {\tt LINEAR} {\tt LISP}
{\tt LISTARGP} {\tt LOAD} {\tt LOAD\_PACKAGE} {\tt MASS} {\tt MATCH} {\tt
MATRIX} {\tt MSHELL} {\tt NODEPEND} {\tt NONCOM} {\tt NONZERO} {\tt NOSPUR}
{\tt ODD} {\tt OFF}
{\tt ON} {\tt OPERATOR} {\tt ORDER} {\tt OUT} {\tt PAUSE} {\tt PRECEDENCE}
{\tt PRINT\_PRECISION} {\tt PROCEDURE} {\tt QUIT} {\tt REAL} {\tt REMFAC}
{\tt REMIND} {\tt RETRY} {\tt RETURN} {\tt SAVEAS} {\tt SCALAR} {\tt
SETMOD} {\tt SHARE} {\tt SHOWTIME} {\tt SHUT} {\tt SPUR} {\tt SYMBOLIC}
{\tt SYMMETRIC} {\tt VECDIM} {\tt VECTOR} {\tt WEIGHT} {\tt WRITE} {\tt
WTLEVEL}

\item[Boolean Operators] {\tt EVENP} {\tt FIXP}
{\tt FREEOF} {\tt NUMBERP} {\tt ORDP} {\tt PRIMEP}

\item[Infix Operators]
 \verb|:=| \verb|=| \verb|>=| \verb|>| \verb|<=| \verb|<| \verb|=>|
 \verb|+| \verb|*| \verb|/| \verb|^| \verb|**| \verb|.| {\tt WHERE}
{\tt SETQ} {\tt OR} {\tt AND} {\tt MEMBER} {\tt MEMQ} {\tt
EQUAL} {\tt NEQ} {\tt EQ} {\tt GEQ} {\tt GREATERP} {\tt LEQ} {\tt LESSP}
{\tt PLUS} {\tt DIFFERENCE} {\tt MINUS} {\tt TIMES} {\tt QUOTIENT} {\tt
EXPT} {\tt CONS}

\item[Numerical Operators] {\tt ABS} {\tt ACOS}
{\tt ACOSH} {\tt ACOT} {\tt ACOTH} {\tt ACSC} {\tt ACSCH} {\tt ASEC} {\tt
ASECH} {\tt ASIN} {\tt ASINH} {\tt ATAN} {\tt ATANH} {\tt ATAN2} {\tt COS}
{\tt COSH} {\tt COT} {\tt COTH} {\tt CSC} {\tt CSCH} {\tt EXP} {\tt
FACTORIAL} {\tt FIX} {\tt FLOOR} {\tt HYPOT} {\tt LN} {\tt LOG} {\tt LOGB}
{\tt LOG10} {\tt NEXTPRIME} {\tt ROUND} {\tt SEC} {\tt SECH} {\tt SIN}
{\tt SINH} {\tt SQRT} {\tt TAN} {\tt TANH}

\item[Prefix Operators] {\tt APPEND} {\tt
ARGLENGTH} {\tt CEILING} {\tt COEFF} {\tt COEFFN} {\tt COFACTOR} {\tt
CONJ} {\tt DEG} {\tt DEN} {\tt DET} {\tt DF} {\tt DILOG} {\tt EI}
{\tt EPS} {\tt ERF} {\tt FACTORIZE} {\tt FIRST} {\tt GCD} {\tt G} {\tt
IMPART} {\tt INT} {\tt INTERPOL} {\tt LCM} {\tt LCOF} {\tt LENGTH} {\tt
LHS} {\tt LINELENGTH} {\tt LTERM} {\tt MAINVAR} {\tt MAT} {\tt MATEIGEN}
{\tt MAX} {\tt MIN} {\tt MKID} {\tt NULLSPACE} {\tt NUM} {\tt PART} {\tt
PF} {\tt PRECISION} {\tt RANDOM} {\tt RANDOM\_NEW\_SEED} {\tt RANK} {\tt
REDERR} {\tt REDUCT} {\tt REMAINDER} {\tt REPART} {\tt REST} {\tt
RESULTANT} {\tt REVERSE} {\tt RHS} {\tt SECOND} {\tt SET} {\tt SHOWRULES}
{\tt SIGN} {\tt SOLVE} {\tt STRUCTR} {\tt SUB} {\tt SUM} {\tt THIRD} {\tt
TP} {\tt TRACE} {\tt VARNAME}

\item[Reserved Variables] {\tt CARD\_NO} {\tt E} {\tt EVAL\_MODE}
{\tt FORT\_WIDTH} {\tt HIGH\_POW} {\tt I} {\tt INFINITY} {\tt K!*} {\tt
LOW\_POW} {\tt NIL} {\tt PI} {\tt ROOT\_MULTIPLICITY} {\tt T}

\item[Switches] {\tt ADJPREC} {\tt ALGINT} {\tt ALLBRANCH} {\tt ALLFAC}
{\tt BFSPACE} {\tt COMBINEEXPT} {\tt COMBINELOGS}
{\tt COMP} {\tt COMPLEX} {\tt CRAMER} {\tt CREF} {\tt DEFN} {\tt DEMO}
{\tt DIV} {\tt ECHO} {\tt ERRCONT} {\tt EVALLHSEQP} {\tt EXP} {\tt
EXPANDLOGS} {\tt EZGCD} {\tt FACTOR} {\tt FORT} {\tt FULLROOTS} {\tt GCD}
{\tt IFACTOR} {\tt INT} {\tt INTSTR} {\tt LCM} {\tt LIST} {\tt LISTARGS}
{\tt MCD} {\tt MODULAR} {\tt MSG} {\tt MULTIPLICITIES} {\tt NAT} {\tt
NERO} {\tt NOSPLIT} {\tt OUTPUT} {\tt PERIOD} {\tt PRECISE} {\tt PRET}
{\tt PRI} {\tt RAT} {\tt RATARG} {\tt RATIONAL} {\tt RATIONALIZE} {\tt
RATPRI} {\tt REVPRI} {\tt RLISP88} {\tt ROUNDALL} {\tt ROUNDBF} {\tt
ROUNDED} {\tt SAVESTRUCTR} {\tt SOLVESINGULAR} {\tt TIME} {\tt TRA} {\tt
TRFAC} {\tt TRIGFORM} {\tt TRINT}

\item[Other Reserved Ids] {\tt BEGIN} {\tt DO} {\tt
EXPR} {\tt FEXPR} {\tt INPUT} {\tt LAMBDA} {\tt
LISP} {\tt MACRO} {\tt PRODUCT} {\tt REPEAT} {\tt SMACRO} {\tt
SUM} {\tt UNTIL} {\tt WHEN} {\tt WHILE} {\tt WS}

\end{list}

\end{document}

Added mtt/lib/cc/mtt_AlgebraicSolver.cc version [021b3b02c0].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include "mtt_AlgebraicSolver.hh"

ColumnVector
MTT::AlgebraicSolver::solve (const ColumnVector	&x,
			     const ColumnVector	&u,
			     const double	&t,
			     const ColumnVector	&par)
{
  if (_nyz > 0)
    {
      _x = x;
      _uui.insert(u,0);
      _t = t;
      _par = par;
      Solve();
      _uui.insert(_ui,_nu);
    }
  else
    {
      _uui = u;
    }
  return _uui;
}

ColumnVector
MTT::AlgebraicSolver::eval (const ColumnVector	&ui)
{
  if (_nyz > 0)
    _uui.insert(ui,_nu);
  return mtt_ae(_x,_uui,_t,_par);
}

Added mtt/lib/cc/mtt_AlgebraicSolver.hh version [83ec09b7aa].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef MTT_ALGEBRAICSOLVER
#define MTT_ALGEBRAICSOLVER


#include "mtt_Solver.hh"


namespace MTT
{
  class AlgebraicSolver : public MTT::Solver
  {
  public:

    AlgebraicSolver (const int npar,
		     const int nu,
		     const int nx,
		     const int ny,
		     const int nyz)
      : MTT::Solver (npar,nu,nx,ny,nyz)
    {;}

    ColumnVector
    solve (const ColumnVector	&x,
	   const ColumnVector	&u,
	   const double		&t,
	   const ColumnVector	&par);

    ColumnVector
    eval (const ColumnVector	&ui);

    virtual ~AlgebraicSolver (void) {};

  protected:

    virtual void
    Solve (void) = 0;
  };
}


extern ColumnVector
mtt_ae(const ColumnVector	&x,
       const ColumnVector	&u,
       const double		&t,
       const ColumnVector	&par);


#endif // MTT_ALGEBRAICSOLVER

Added mtt/lib/cc/mtt_Dassl_Solver.cc version [d98f27dba0].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include "mtt_Dassl_Solver.hh"


// used by "-ae dassl" NOT "-i dassl"


MTT::Dassl_Solver *MTT::Dassl_Solver::static_ptr;

ColumnVector
MTT::Dassl_Solver::f_dassl (const ColumnVector &tryUi,
			    const ColumnVector &tryUidot,
			    double t, int &ires)
{
  static MTT::Dassl_Solver *p = MTT::Dassl_Solver::static_ptr;

  ColumnVector residual = p->eval(tryUi);
  ColumnVector uidoterr = (tryUi - p->_ui) - tryUidot;  
  p->_yz = residual + uidoterr;
  return p->_yz;
}

void
MTT::Dassl_Solver::Solve (void)
{
  const double t0 = 0.0;
  const double t1 = 1.0;
  DAEFunc fcn(&MTT::Dassl_Solver::f_dassl);
  DASSL   eqn(AlgebraicSolver::_ui,t0,fcn);
  AlgebraicSolver::_ui = eqn.do_integrate (t1);
}

Added mtt/lib/cc/mtt_Dassl_Solver.hh version [29e194ac39].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


#ifndef MTT_DASSLSOLVER
#define MTT_DASSLSOLVER


#include "mtt_AlgebraicSolver.hh"
#include <octave/DASSL.h>


#ifdef  OCTAVE_DEV
#include <octave/parse.h>
#define VECTOR_VALUE column_vector_value
#else   // !OCTAVE_DEV
#include <octave/toplev.h>
#define VECTOR_VALUE vector_value
#endif  // OCTAVE_DEV


// -ae dassl


namespace MTT
{
  class Dassl_Solver : public MTT::AlgebraicSolver {
    
    // used only when called because of "-ae dassl"
    // this is not used when called by "-i dassl"
    
  public:
    
    Dassl_Solver (const int npar,
		  const int nu,
		  const int nx,
		  const int ny,
		  const int nyz)
      : MTT::AlgebraicSolver (npar, nu, nx, ny, nyz)
    {
      static_ptr = this;
    }
    
    static ColumnVector
    f_dassl (const ColumnVector &tryUi,
	     const ColumnVector &tryUidot,
	     double t, int &ires);
    
    ~Dassl_Solver (void) {};
    
  protected:
    
    void
    Solve (void);
    
  public:
    
    static Dassl_Solver *static_ptr;
    
  };
}


#endif // MTT_DASSLSOLVER

Added mtt/lib/cc/mtt_HJ_Solver.hh version [c5aaf93148].


































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef MTT_HJSOLVER
#define MTT_HJSOLVER


#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class HJ_Solver : public MTT::AlgebraicSolver
  {
    // http://www.netlib.org/opt/hooke.c
    // Hooke and Jeeves solution

  public:
  
    HJ_Solver (const int npar,
	       const int nu,
	       const int nx,
	       const int ny,
	       const int nyz)
      : MTT::AlgebraicSolver (npar,nu,nx,ny,nyz)
    {
      static_ptr = this;
      VARS = nyz;
    }
  
    static double
    f (double tryUi[], int nyz);
  
    ~HJ_Solver (void) {};

  protected:

    void
    Solve (void);

    double
    best_nearby (double    	delta[],
		 double   	point[],
		 double   	prevbest,
		 int      	nvars);
  
    int
    hooke (int		nvars,			  // MTTNYZ
	   double	startpt[],		  // user's initial guess
	   double	endpt[],		  // result
	   double	rho		= 0.05,	  // geometric shrink factor
	   double	epsilon		= 1e-3,	  // end value stepsize
	   int		itermax		= 5000);  // max # iterations 

  private:

    int VARS;
    
  public:

    static HJ_Solver *static_ptr;
    
  };
}


#endif // MTT_HJSOLVER

Added mtt/lib/cc/mtt_Hybrd_Solver.cc version [0e7392017c].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include "mtt_Hybrd_Solver.hh"

// http://www.netlib.org/minpack/hybrd.f
// used by Octave's fsolve

MTT::Hybrd_Solver *MTT::Hybrd_Solver::static_ptr;

ColumnVector
MTT::Hybrd_Solver::f_hybrd (const ColumnVector &tryUi)
{
  MTT::Hybrd_Solver::static_ptr->_yz = MTT::Hybrd_Solver::static_ptr->eval(tryUi);
  return MTT::Hybrd_Solver::static_ptr->_yz;
}

void
MTT::Hybrd_Solver::Solve (void)
{    
  static std::fstream ferr ("MTT.Hybrd_messages", std::ios::out | std::ios::trunc | std::ios::app);
  int info;
  static int input_errors;
  static int user_errors;
  static int convergences;
  static int progress_errors;
  static int limit_errors;
  static int unknown_errors;
  
  NLFunc fcn(&Hybrd_Solver::f_hybrd);
  NLEqn	 eqn(Solver::_ui,fcn);
  //  eqn.set_tolerance(1.0e-20);
  Solver::_ui = eqn.solve(info);

  switch (info)
    {
    case 1:
      convergences++;
      break;
    case -2:
      input_errors++;
      break;
    case -1:
      user_errors++;
      break;
    case 3:
      progress_errors++;
      break;
    case 4:
      limit_errors++;
      break;
    default:
      unknown_errors++;
      break;
    }
  std::clog.setf (std::ios::scientific);
  if (1 != info)
    {
      std::clog
	<< "\r"
	<< " time " << _t << " \t"
	<< " converge (" << convergences << ") "
	<< " limit (" << limit_errors << ")"
	<< " progress (" << progress_errors << ")"
	<< " other (" << input_errors + user_errors + unknown_errors << ") "
	<< " (max error = " << std::abs (eval(_ui).max()) << ")"
	<< std::endl;
    }
  else
    {
      std::clog
	<< "\r time " << _t << "\t max error = " << std::abs (eval(_ui).max());
    }
  ferr << info << " ";
}

Added mtt/lib/cc/mtt_Hybrd_Solver.hh version [7dad372c91].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef MTT_HYBRDSOLVER
#define MTT_HYBRDSOLVER

#include <fstream>

#include <octave/NLEqn.h>
#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class Hybrd_Solver : public MTT::AlgebraicSolver
  {
    // http://www.netlib.org/minpack/hybrd.f
    // used by Octave's fsolve
    
  public:

    Hybrd_Solver (const int npar,
		  const int nu,
		  const int nx,
		  const int ny,
		  const int nyz)
      : MTT::AlgebraicSolver (npar,nu,nx,ny,nyz)
    {
      static_ptr = this;
    }

    static ColumnVector
    f_hybrd (const ColumnVector &tryUi);

    ~Hybrd_Solver (void) {};

  protected:

    void
    Solve (void);
    
  public:
    
    static Hybrd_Solver *static_ptr;
  };
}


#endif // MTT_HYBRDSOLVER

Added mtt/lib/cc/mtt_Reduce_Solver.cc version [b7f38e13b6].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include "mtt_Reduce_Solver.hh"

void
MTT::Reduce_Solver::Solve (void)
{
  ;
}

ColumnVector
MTT::Reduce_Solver::solve (const ColumnVector	&x,
			   const ColumnVector	&u,
			   const double		&t,
			   const ColumnVector	&par)
{
  return u;
}

Added mtt/lib/cc/mtt_Reduce_Solver.hh version [635ef51478].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef MTT_REDUCESOLVER
#define MTT_REDUCESOLVER


#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class Reduce_Solver : public MTT::AlgebraicSolver
  {
    // Dummy class
    // This will not be used unless the Reduce solver has failed earlier
    // in the model build process

  public:
    
    Reduce_Solver (const int npar,
		   const int nu,
		   const int nx,
		   const int ny,
		   const int nyz)
      : AlgebraicSolver (npar,nu,nx,ny,nyz)
    {;}
	
    void
    Solve (void);
    
    ColumnVector
    solve (const ColumnVector	&x,
	   const ColumnVector	&u,
	   const double		&t,
	   const ColumnVector	&par);
    
    ~Reduce_Solver (void) {};
  };
}


#endif // MTT_REDUCESOLVER 

Added mtt/lib/cc/mtt_Solver.cc version [bc6c28056d].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include "mtt_Solver.hh"

MTT::Solver::Solver (const int npar,
		     const int nu,
		     const int nx,
		     const int ny,
		     const int nyz)
{
  _np  = npar; 
  _nu  = nu;
  _nx  = nx;
  _ny  = ny;
  _nyz = nyz;
  _ui  = ColumnVector (_nyz,0.0);
  _uui = ColumnVector (_nu+_nyz);
};

Added mtt/lib/cc/mtt_Solver.hh version [2a39ed71ca].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef MTT_SOLVER
#define MTT_SOLVER


#include <cmath>
#include <cstdlib>
#include <iostream>

#include <octave/oct.h>


namespace MTT
{
  class Solver
  {
  public:

    Solver (const int npar,
	    const int nu,
	    const int nx,
	    const int ny,
	    const int nyz);

    virtual ~Solver (void) {};
  
  protected:
    
    ColumnVector       		_x;
    ColumnVector	       	_uui;
    double			_t;
    ColumnVector	       	_par;
    
    ColumnVector  		_ui;
    ColumnVector          	_yz;
    
    int   			_nu;
    int				_np;
    int				_nx;
    int				_ny;
    int				_nyz;
  };
}

  
#endif // MTT_SOLVER

Added mtt/lib/cc/mtt_dassl.cc version [f033fc99ba].






























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include <octave/oct.h>
#include <octave/DASSL.h>


#ifdef  OCTAVE_DEV
#include <octave/parse.h>
#define VECTOR_VALUE column_vector_value
#else   // !OCTAVE_DEV
#include <octave/toplev.h>
#define VECTOR_VALUE vector_value
#endif  // OCTAVE_DEV

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
extern ColumnVector
Fmtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires);
#endif // (CODEGENTARGET == STANDALONE)


ColumnVector
mtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires)
{
#if (CODEGENTARGET == STANDALONE)
  return Fmtt_residual (X, DX, t, ires);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args(0) = octave_value (X);
  args(1) = octave_value (DX);
  args(2) = octave_value (t);
  args(3) = octave_value (static_cast<double>(ires));
  f = feval ("mtt_residual", args, 1);
  return f(0).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)
}


#if (CODEGENTARGET == STANDALONE)
ColumnVector
Fmtt_dassl (	  ColumnVector	&x,
	    const ColumnVector	&u,
	    const double	&t,
	    const ColumnVector	&par,
	    const ColumnVector	&dx,
	    const double	&ddt,
	    const int		Nx,
	    const int		Nyz,
	    const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_dassl, args, ,
	   "dassl integration method")
{
  ColumnVector		x	= args(0).VECTOR_VALUE();
  const ColumnVector   	u	= args(1).VECTOR_VALUE();
  const double		t	= args(2).double_value();
  const ColumnVector	par	= args(3).VECTOR_VALUE();
  const ColumnVector	dx	= args(4).VECTOR_VALUE();
  const double		ddt	= args(5).double_value();
  const int		Nx	= static_cast<int> (args(6).double_value());
  const int		Nyz	= static_cast<int> (args(7).double_value());
  const ColumnVector	openx	= args(8).VECTOR_VALUE();
#endif // (CODEGENTARGET == STANDALONE)

  static DAEFunc fdae(mtt_residual);
  static ColumnVector XX (Nx+Nyz);
  XX.insert (x,0);

  for (register int i = Nx; i < Nx+Nyz; i++)
    XX(i) = 0.0;

  double tout = t + ddt;

  DASSL fdassl (XX, t, fdae);
  x = fdassl.do_integrate (tout).extract (0,Nx-1);

  for (register int i = 0; i < Nx; i++)
    if (openx (i) > 0.5)
      x (i) = 0.0;
      

#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Added mtt/lib/cc/mtt_euler.cc version [94aa4f3270].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#include <octave/oct.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
ColumnVector Fmtt_euler (      ColumnVector	&x,
			 const ColumnVector	&dx,
			 const double		&ddt,
			 const int		&Nx,
			 const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_euler, args, ,
	   "euler integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  const ColumnVector	dx	= args(1).VECTOR_VALUE ();
  const double		ddt	= args(2).double_value ();
  const int		Nx	= static_cast<int> (args(3).double_value ());
  const ColumnVector   	openx	= args(4).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)

  register int i, n;
  
  n = Nx;
  for (i = 0; i < Nx; i++)
    {
      if (0 != openx (i))
	{
	  x (i) = 0.0;
	}
      else
	{
	  x (i) += dx (i) * ddt;
	}
    }
#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Added mtt/lib/cc/mtt_implicit.cc version [c10762dcf4].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#include <octave/oct.h>
#include <octave/xdiv.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
ColumnVector Fmtt_implicit (      ColumnVector	&x,
				  ColumnVector	&dx,
			          Matrix	&AA,
				  ColumnVector	&AAx,
			    const double	&t,
			    const int		&Nx,
			    const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_implicit, args, ,
	   "implicit integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  ColumnVector		dx	= args(1).VECTOR_VALUE ();
  Matrix		AA	= args(2).matrix_value ();
  ColumnVector		AAx	= args(3).VECTOR_VALUE ();
  const  double		t	= args(4).double_value ();
  const  int		Nx	= (int) (args(5).double_value ());
  const  ColumnVector	openx	= args(6).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)

  register int row, col;

  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{
	  AAx (row) = 0.0;
          dx (row) = 0.0;
	  for (col = 0; col < Nx; col++)
	    {
	      AA (row,col) = 0.0;
	      AA (col,row) = 0.0;
	    }
	}
    }

#ifdef OCTAVE_DEV
  x = xleftdiv (AA, Matrix(AAx + dx * t)).column (0);
#else // !OCTAVE_DEV
  Matrix tmp = xleftdiv (AA, static_cast<Matrix>(static_cast<ColumnVector>(AAx + dx * t)));
  for (row = 0; row < Nx; row++)
    {
      x (row) = tmp (row,0);
    }
#endif // OCTAVE_DEV
  
  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{
	  x (row) = 0.0;
	}
    }

#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Added mtt/lib/cc/mtt_kpathsea.cc version [0b0240614b].





1
2
3
4
+
+
+
+

extern "C" {
  int kpse_clear_dir_cache (void) {return 0;}
}

Added mtt/lib/cc/mtt_matlab_octave.cc version [b74de52abf].



































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include <octave/oct.h>
#include <mex.h>


// conversions from Matlab mxArray* to Octave data types

Matrix
mtt_Matrix (const mxArray *m)
{
  const unsigned long int nrows = mxGetM (m);
  const unsigned long int ncols = mxGetN (m);
  Matrix o (nrows, ncols);
  const double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    for (unsigned long int col = 0; col < ncols; col++)
      o (row, col) = p[row + nrows*col];
  return (o);
}

ColumnVector
mtt_ColumnVector (const mxArray *m)
{
  const unsigned long int nrows = mxGetM (m);
  ColumnVector o (nrows);
  const double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    o (row) = p[row];
  return (o);
}

const double
mtt_double (const mxArray *m)
{
  const double *p = mxGetPr (m);
  return (*p);
}


// conversions from Octave data types to Matlab mxArray*

mxArray *
mtt_mxArray (const Matrix &o)
{
  const unsigned long int nrows = o.rows ();
  const unsigned long int ncols = o.columns ();
  mxArray *m;
  m = mxCreateDoubleMatrix (nrows, ncols, mxREAL);
  double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    for (unsigned long int col = 0; col < ncols; col++)
      p [row + nrows*col] = o (row, col);
  return (m);
}

mxArray *
mtt_mxArray (const ColumnVector &o)
{
  const unsigned long int nrows = o.length ();
  mxArray *m;
  m = mxCreateDoubleMatrix (nrows, 1, mxREAL);
  double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    p [row] = o (row);
  return (m);
}

Added mtt/lib/cc/mtt_matlab_octave.hh version [7d4f1bcd2c].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef MTT_MATLAB_OCTAVE_HH
#define MTT_MATLAB_OCTAVE_HH

#include <octave/oct.h>
#include <mex.h>

// conversions from Matlab mxArray* to Octave data types

extern Matrix
mtt_Matrix (const mxArray *m);

extern ColumnVector
mtt_ColumnVector (const mxArray *m);

extern const double
mtt_double (const mxArray *m);


// conversions from Octave data types to Matlab mxArray*

extern mxArray *
mtt_mxArray (const Matrix &o);

extern mxArray *
mtt_mxArray (const ColumnVector &o);

#endif // MTT_MATLAB_OCTAVE_HH

Added mtt/lib/cc/mtt_noAlgebraicSolver.cc version [7c4f7ecef3].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include "mtt_noAlgebraicSolver.hh"

void
MTT::noAlgebraicSolver::Solve (void)
{
  ;
}

ColumnVector
MTT::noAlgebraicSolver::solve (const ColumnVector	&x,
			       const ColumnVector	&u,
			       const double		&t,
			       const ColumnVector	&par)
{
  return u;
}

Added mtt/lib/cc/mtt_noAlgebraicSolver.hh version [1076338af6].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef MTT_REDUCESOLVER
#define MTT_REDUCESOLVER


#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class noAlgebraicSolver : public MTT::AlgebraicSolver
  {
    // Dummy class

  public:
    
    noAlgebraicSolver (const int npar,
		   const int nu,
		   const int nx,
		   const int ny,
		   const int nyz)
      : AlgebraicSolver (npar,nu,nx,ny,nyz)
    {;}
	
    void
    Solve (void);
    
    ColumnVector
    solve (const ColumnVector	&x,
	   const ColumnVector	&u,
	   const double		&t,
	   const ColumnVector	&par);
    
    ~noAlgebraicSolver (void) {};
  };
}


#endif // MTT_REDUCESOLVER 

Added mtt/lib/cc/mtt_simpar.hh version [867584b9ac].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#include <octave/oct.h>
#include <octave/oct-map.h>

static ColumnVector
mtt_simpar (Octave_map simpar)
{
  static ColumnVector retval (8);

  retval (0) = simpar.contents (simpar.seek ("first"     ))(0).double_value ();
  retval (1) = simpar.contents (simpar.seek ("last"      ))(0).double_value ();
  retval (2) = simpar.contents (simpar.seek ("dt"        ))(0).double_value ();
  retval (3) = simpar.contents (simpar.seek ("stepfactor"))(0).double_value ();
  retval (4) = simpar.contents (simpar.seek ("wmin"      ))(0).double_value ();
  retval (5) = simpar.contents (simpar.seek ("wmax"      ))(0).double_value ();
  retval (6) = simpar.contents (simpar.seek ("wsteps"    ))(0).double_value ();
  retval (7) = simpar.contents (simpar.seek ("input"     ))(0).double_value ();

  return retval;
}

static Octave_map
mtt_simpar (ColumnVector simpar)
{
  static Octave_map retval;

  retval.assign ("first"     , simpar (0));
  retval.assign ("last"      , simpar (1));
  retval.assign ("dt"        , simpar (2));
  retval.assign ("stepfactor", simpar (3));
  retval.assign ("wmin"      , simpar (4));
  retval.assign ("wmax"      , simpar (5));
  retval.assign ("wsteps"    , simpar (6));
  retval.assign ("input"     , simpar (7));

  return retval;
}

Added mtt/lib/comp/compound/Bicausal/B2U/B2U_abg.fig version [309cefa6d9].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 6525 2700 6525 2475 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 6300 2925 4950 3150 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 6525 4500 6525 4275 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 6300 4725 4950 4950 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 6525 6300 6525 6075 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 4500 2925 3150 3150 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 4500 4725 3150 4950 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1350 6525 1350 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 6300 2700 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 6525 3150 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 6300 4500 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4950 6525 4950 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 6300 6300 6525
4 2 4 100 0 18 18 0.0000 4 270 930 1260 6615 SS:[ef]\001
4 1 0 100 0 18 18 0.0000 4 195 150 2925 6615 0\001
4 1 0 100 0 18 18 0.0000 4 210 405 2925 4815 AE\001
4 1 0 100 0 18 18 0.0000 4 195 150 4725 6615 1\001
4 1 0 100 0 18 18 0.0000 4 210 390 4725 4815 AF\001
4 1 0 100 0 18 18 0.0000 4 210 630 6795 6615 SS:ii\001
4 1 4 100 0 18 18 0.0000 4 270 825 2925 3015 SS:[e]\001
4 1 4 100 0 18 18 0.0000 4 270 765 4680 3015 SS:[f]\001

Added mtt/lib/comp/compound/Bicausal/B2U/B2U_lbl.txt version [33dba58bdb].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY B2U: undoes a bicausal bond
#DESCRIPTION Takes e and f from bicausal bond at port [ef] 
#DESCRIPTION and gives corresponding unicausal bonds at ports [e] and [f]

## System B2U, representation lbl, language txt
## File B2U_lbl.txt
## Generated by MTT on Thu Jul  8 09:59:03 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	e	e
#ALIAS	ef	ef
#ALIAS	f	f

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type AE (anonymous => default parameters)
	# AE							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type SS
	[e]	SS		external,0
	[f]	SS		0,external		
	ii	SS		internal,internal		
	[ef]	SS		external,0

Added mtt/lib/comp/compound/Bicausal/U2B/U2B_abg.fig version [753962dbb3].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 1350 6975 1350 6750 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 2925 5400 1575 5625 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 3150 5175 3150 4950 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 1350 3150 1350 2925 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 1350 5175 1350 4950 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 4725 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 4725 5625 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 3375 5400 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 1575 5400 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2925 5625 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2925 3825 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 1125 5175 1575
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8550 5175 675 5175 675 675 8550 675 8550 5175
4 1 0 100 0 18 18 0.0000 4 210 390 3465 3240 AF\001
4 1 0 100 0 18 18 0.0000 4 195 150 5400 3240 0\001
4 2 4 100 0 18 18 0.0000 4 270 765 1710 3240 SS:[f]\001
4 1 0 100 0 18 18 0.0000 4 210 405 3465 1440 AE\001
4 1 0 100 0 18 18 0.0000 4 195 150 5400 1440 1\001
4 2 4 100 0 18 18 0.0000 4 270 825 1710 1440 SS:[e]\001
4 1 0 100 0 18 18 0.0000 4 210 780 5400 5085 SS:zz\001
4 0 4 100 0 18 18 0.0000 4 270 1095 7110 1440 SS:[ef]\001
4 1 1 101 0 3 20 0.0000 4 165 150 4500 1125 e\001
4 1 1 101 0 3 20 0.0000 4 165 150 6300 1125 e\001
4 1 1 101 0 3 20 0.0000 4 165 150 2475 1125 e\001
4 1 1 101 0 3 20 0.0000 4 315 105 2475 3510 f\001
4 1 1 101 0 3 20 0.0000 4 315 105 4500 3510 f\001
4 1 1 101 0 3 20 0.0000 4 315 105 6300 1710 f\001
4 1 1 101 0 3 20 0.0000 4 315 105 5625 2385 f\001
4 1 1 101 0 3 20 0.0000 4 225 165 2520 1665 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 2520 3015 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 5220 4140 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 5625 4140 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 5220 2385 0\001

Added mtt/lib/comp/compound/Bicausal/U2B/U2B_lbl.txt version [aa18514868].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY U2B: makes a bicausal bond
#DESCRIPTION Takes e and f from  ports [e] and [f] and gives corresponding
#DESCRIPTION bicausal bond at port [ef].

## System U2B, representation lbl, language txt
## File U2B_lbl.txt
## Generated by MTT on Thu Jul  8 08:38:15 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	e	e
#ALIAS	f	f
#ALIAS	out	ef

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[e]	SS		external,internal		
	[f]	SS		internal,external		
	[ef]	SS		internal,external		
	zz	SS		0,0

Added mtt/lib/comp/compound/Bicausal/VJe/VJe_abg.fig version [3b654ab692].

















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3735 675 4455 990
4 1 1 101 0 3 20 0.0000 4 105 195 4095 855 =\001
4 1 1 101 0 3 20 0.0000 4 165 150 3847 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 3937 990 c\001
4 1 1 101 0 3 20 0.0000 4 165 150 4282 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 4372 990 s\001
-6
6 3915 1170 4185 1575
4 1 1 101 0 3 20 0.0000 4 315 105 3982 1440 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 4072 1575 c\001
-6
6 5940 1170 6210 1575
4 1 1 101 0 3 20 0.0000 4 315 105 6007 1440 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 6097 1575 c\001
-6
6 5715 2520 5985 2835
4 1 1 101 0 3 20 0.0000 4 165 150 5812 2700 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 5902 2835 s\001
-6
6 4590 1890 4860 2205
4 1 1 101 0 3 20 0.0000 4 165 150 4687 2070 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 4777 2205 s\001
-6
6 7110 3510 7380 3915
4 1 1 101 0 3 20 0.0000 4 315 105 7177 3780 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 7267 3915 c\001
-6
6 6075 3555 6795 3870
4 1 1 101 0 3 20 0.0000 4 105 195 6435 3735 =\001
4 1 1 101 0 3 20 0.0000 4 165 150 6187 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 6277 3870 c\001
4 1 1 101 0 3 20 0.0000 4 165 150 6622 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 6712 3870 s\001
-6
6 5715 4320 5985 4635
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4500 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 5902 4635 e\001
-6
6 5715 4815 5985 5220
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4995 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 5902 5130 f\001
-6
6 3240 4095 3510 4410
4 1 1 101 0 3 20 0.0000 4 180 180 3337 4275 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 3427 4410 e\001
-6
6 3240 4995 3510 5400
4 1 1 101 0 3 20 0.0000 4 180 180 3337 5175 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 3427 5310 f\001
-6
6 1755 2520 2025 2835
4 1 1 101 0 3 20 0.0000 4 165 150 1852 2700 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 1942 2835 s\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 4725 2925 4500 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5220 2925 6570 2925 6345 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 5175 1125 6975 1125 6975 2700 7200 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 2925 4500 3150 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4950 2925 4950 3150 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 2700 4725 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 4725 1125 4500 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1305 2925 2655 2925 2430 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 6975 4500 7200 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 4725 5175 4725 5400 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 4950 675 4950 900 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 7425 5625 -675 5625 -675 450 7425 450 7425 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 4500 675 4500 900 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 4950 1350 5175 1575
4 1 0 100 0 18 18 0.0000 4 195 150 4950 3015 0\001
4 1 0 100 0 18 18 0.0000 4 195 150 4950 1215 1\001
4 2 4 100 0 18 18 0.0000 4 270 1065 3285 1215 SS:[PC]\001
4 1 0 100 0 18 18 0.0000 4 210 570 6975 3015 U2B\001
4 1 0 100 0 18 18 0.0000 4 210 570 4725 4815 B2U\001
4 1 4 100 0 18 14 0.0000 4 225 285 6345 2790 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 225 6795 2520 [f]\001
4 1 4 100 0 18 14 0.0000 4 240 360 6750 3375 [ef]\001
4 1 4 100 0 18 14 0.0000 4 225 285 4050 4365 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 225 4050 5265 [f]\001
4 1 4 100 0 18 14 0.0000 4 240 360 5220 4545 [ef]\001
4 1 1 101 0 3 20 0.0000 4 225 165 6075 990 0\001
4 1 0 100 0 18 18 0.0000 4 195 540 6885 4815 tra:t\001
4 2 4 100 0 18 14 0.0000 4 225 360 6480 4995 [in]\001
4 2 4 100 0 18 14 0.0000 4 225 525 6840 4410 [out]\001
4 1 0 100 0 18 18 0.0000 4 210 750 2970 3015 AE:m\001
4 2 4 100 0 18 18 0.0000 4 270 900 1215 3015 SS:[in]\001
4 2 4 100 0 18 18 0.0000 4 270 1080 585 5085 SS:[u_f]\001
4 2 4 100 0 18 18 0.0000 4 270 1140 585 4590 SS:[u_e]\001
4 1 0 100 0 18 18 0.0000 4 210 660 2430 4590 AE:e\001
4 1 0 100 0 18 18 0.0000 4 210 585 2430 5040 AF:f\001

Added mtt/lib/comp/compound/Bicausal/VJe/VJe_lbl.txt version [892d29c787].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY VJe  Virtual Junction - effort input
#DESCRIPTION Virtual junction with effort input
#DESCRIPTION User must supply the transfer system tra
#DESCRIPTION tra can have up to 9 parameters passed to it
#DESCRIPTION using parameters of VJe

## System VJe, representation lbl, language txt
## File VJe_lbl.txt
## Generated by MTT on Thu Jul  8 11:41:51 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases

## Argument aliases
#ALIAS	$1	p_1
#ALIAS	$2	p_2
#ALIAS	$3	p_3
#ALIAS	$4	p_4
#ALIAS	$5	p_5
#ALIAS	$6	p_6
#ALIAS	$7	p_7
#ALIAS	$8	p_8
#ALIAS	$9	p_9


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type AE/AF
        e       lin             -1
        f       lin             -1
        m       lin             -1

## Component type tra
	t	lin		p_1;p_2;p_3;p_4;p_5;p_6;p_7;p_8;p_9

## Component type SS
	[in]	SS		external,internal
	[u_e]	SS		external,0
	[u_f]	SS		0,external		
	[PC]	SS		external,external		



Added mtt/lib/comp/compound/Bicausal/VJf/VJf_abg.fig version [6d4a8e35f9].











































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 7110 3510 7380 3915
4 1 1 101 0 3 20 0.0000 4 315 105 7177 3780 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 7267 3915 c\001
-6
6 6075 3555 6795 3870
4 1 1 101 0 3 20 0.0000 4 105 195 6435 3735 =\001
4 1 1 101 0 3 20 0.0000 4 165 150 6187 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 6277 3870 c\001
4 1 1 101 0 3 20 0.0000 4 165 150 6622 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 6712 3870 s\001
-6
6 5715 4320 5985 4635
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4500 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 5902 4635 e\001
-6
6 5715 4815 5985 5220
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4995 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 5902 5130 f\001
-6
6 3240 4095 3510 4410
4 1 1 101 0 3 20 0.0000 4 180 180 3337 4275 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 3427 4410 e\001
-6
6 3240 4995 3510 5400
4 1 1 101 0 3 20 0.0000 4 180 180 3337 5175 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 3427 5310 f\001
-6
6 2160 3015 2385 3420
4 1 1 101 0 3 20 0.0000 4 315 105 2212 3285 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 2302 3420 s\001
-6
6 5715 3015 5940 3420
4 1 1 101 0 3 20 0.0000 4 315 105 5767 3285 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 5857 3420 s\001
-6
6 5085 1845 5310 2250
4 1 1 101 0 3 20 0.0000 4 315 105 5137 2115 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 5227 2250 s\001
-6
6 5940 675 6255 990
4 1 1 101 0 3 20 0.0000 4 165 150 6052 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 6142 990 c\001
-6
6 3645 1305 4320 1710
4 1 1 101 0 3 20 0.0000 4 105 195 3960 1575 =\001
4 1 1 101 0 3 20 0.0000 4 315 105 3712 1575 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 3802 1710 c\001
4 1 1 101 0 3 20 0.0000 4 315 105 4147 1575 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 4237 1710 s\001
-6
6 3825 675 4140 990
4 1 1 101 0 3 20 0.0000 4 165 150 3937 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 4027 990 c\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 4725 2925 4500 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 4950 1350 5175 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2925 2925 2925 2700 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5220 2925 6570 2925 6345 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 5175 1125 6975 1125 6975 2700 7200 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 6975 4500 7200 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 4725 5175 4725 5400 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 2925 4500 3150 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4950 2925 4950 3150 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 7425 5625 450 5625 450 450 7425 450 7425 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 4725 1125 4500 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2700 3375 3150
4 1 0 100 0 18 18 0.0000 4 195 150 4950 1215 0\001
4 1 0 100 0 18 18 0.0000 4 210 390 3150 3015 AF\001
4 2 4 100 0 18 18 0.0000 4 270 900 1530 3015 SS:[in]\001
4 2 4 100 0 18 18 0.0000 4 270 1065 3285 1215 SS:[PC]\001
4 1 0 100 0 18 18 0.0000 4 210 570 6975 3015 U2B\001
4 1 0 100 0 18 18 0.0000 4 210 615 6975 4815 tra:t\001
4 2 4 100 0 18 18 0.0000 4 270 1140 2790 4545 SS:[u_e]\001
4 2 4 100 0 18 18 0.0000 4 270 1080 2790 5040 SS:[u_f]\001
4 1 0 100 0 18 18 0.0000 4 210 570 4725 4815 B2U\001
4 1 4 100 0 18 14 0.0000 4 240 225 6345 2790 [f]\001
4 1 4 100 0 18 14 0.0000 4 225 285 6795 2520 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 360 6750 3375 [ef]\001
4 1 4 100 0 18 14 0.0000 4 225 360 6300 4995 [in]\001
4 1 4 100 0 18 14 0.0000 4 225 285 4050 4365 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 225 4050 5265 [f]\001
4 1 4 100 0 18 14 0.0000 4 240 360 5220 4545 [ef]\001
4 1 4 100 0 18 14 0.0000 4 225 525 6660 4365 [out]\001
4 1 0 100 0 18 18 0.0000 4 195 150 4950 3015 1\001
4 1 1 101 0 3 20 0.0000 4 225 165 6075 1530 0\001

Added mtt/lib/comp/compound/Bicausal/VJf/VJf_lbl.txt version [d2153fa80a].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY VJf  Virtual Junction - flow input
#DESCRIPTION Virtual junction with flow input
#DESCRIPTION User must supply the transfer system tra
#DESCRIPTION tra can have up to 9 parameters passed to it
#DESCRIPTION using parameters of VJf


## System VJf, representation lbl, language txt
## File VJf_lbl.txt
## Generated by MTT on Thu Jul  8 11:41:51 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	PC	PC
#ALIAS	in	in
#ALIAS	u_e	u_e
#ALIAS	u_f	u_f

## Argument aliases
#ALIAS	$1	p_1
#ALIAS	$2	p_2
#ALIAS	$3	p_3
#ALIAS	$4	p_4
#ALIAS	$5	p_5
#ALIAS	$6	p_6
#ALIAS	$7	p_7
#ALIAS	$8	p_8
#ALIAS	$9	p_9

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type tra
	t	lin		p_1;p_2;p_3;p_4;p_5;p_6;p_7;p_8;p_9

## Component type SS
	[in]	SS		internal,external
	[u_e]	SS		external,0
	[u_f]	SS		0,external		
	[PC]	SS		external,external		



Added mtt/lib/comp/compound/Chemical/Cm/Cm_abg.fig version [a1eee8edbf].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 4500 5625 4725 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 5175 4500 4500 4725 4725
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 6300 4725 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 7425 4500 6750 4725 6975
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 7425 4725 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 4050 4500 3375 4725 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 4275 5400 4275 5175 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 4275 6525 4275 6300 4500
4 1 0 100 0 18 18 0.0000 4 210 390 4500 5490 AF\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 4365 0\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 6615 1\001
4 1 4 100 0 18 18 0.0000 4 270 900 4500 7875 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 210 510 4500 3285 C:C\001
4 1 0 100 0 18 18 0.0000 4 210 405 5625 4365 AE\001
4 0 4 100 0 18 18 0.0000 4 270 1095 6750 4365 SS:[out]\001

Added mtt/lib/comp/compound/Chemical/Cm/Cm_lbl.txt version [3af097c4c8].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Cm Integrates [in] flow to give [out] effort
 
#DESCRIPTION Zero effort imposed in [in]. Use with mC

## System Cm, representation lbl, language txt
## File Cm_lbl.txt
## Generated by MTT on Tue Aug 13 15:52:46 EST 2013

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type C
	C	lin		state,1

## Component type SS
[in]	SS		external,external		
[out]	SS		external,external		

Added mtt/lib/comp/compound/Chemical/Rate/Rate_abg.fig version [1a050baaf5].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 2880 5220 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2925 5175 2925 4950 3150
-6
6 1755 2880 3195 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2925 3150 2925 2925 3150
-6
6 3105 2655 3195 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 2700 3150 3150
-6
6 3780 2655 3870 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2700 3825 3150
-6
4 1 0 100 0 18 26 0.0000 4 300 525 3510 3060 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 3015 2655 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3960 2655 [2]\001
4 1 4 100 0 18 18 0.0000 4 270 1275 1080 3015 SS:[conc]\001
4 1 4 100 0 18 18 0.0000 4 270 1605 6120 3015 SS:[thermal]\001

Added mtt/lib/comp/compound/Chemical/Rate/Rate_cr.r version [461ff05253].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% CR file for rate-of reaction component RATE

OPERATOR Rate;

% Reaction rate
FOR ALL comp,k,q,h,n,Conc,Temp LET
    Rate(comp,k,q,h,n,flow,1,
         Conc,effort,1,
	 Temp,effort,2
	 ) 
	 = k*Conc^n*e^(-q/Temp);

% Heat
FOR ALL comp,k,q,h,n,Conc,Temp LET
    Rate(comp,k,q,h,n,flow,2,
         Conc,effort,1,
	 Temp,effort,2
	 ) 
	 = k*Conc^n*h*e^(-q/Temp);

END;

Added mtt/lib/comp/compound/Chemical/Rate/Rate_desc.tex version [bc57a1e96d].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Rate (Rate_desc.tex)
% Generated by MTT on Tue Mar 14 17:54:06 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Rate} is
   displayed in Figure \Ref{fig:Rate_abg.ps} and its label
   file is listed in Section \Ref{sec:Rate_lbl}.
   The subsystems are listed in Section \Ref{sec:Rate_sub}.


This component represents rate of reaction equations corresponding to
the chemical reaction:
\begin{equation}
  \text{nA} \rightarrow \text{B}
\end{equation}
The relevant equations are
\begin{equation}
  \begin{align}
     \frac{dc_a}{dt} &= k_a c_a^n e^{-\frac{q_a}{T}} \tag{Rate of reaction}\\
     Q &= h_a k_a c_a^n e^{-\frac{q_a}{T}} \tag{Heat of reaction}
  \end{align}
\end{equation}
where $\frac{dc_a}{dt}$ is the rate of change of concentration of
species A and $Q$ is the corresponding heat generated.

Added mtt/lib/comp/compound/Chemical/Rate/Rate_lbl.txt version [2898cd6073].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Rate (Rate_lbl.txt)
%SUMMARY Rate
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	conc
%ALIAS	out	thermal

% Argument aliases
%ALIAS	$1	k,q,h,n

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	r	 Rate	k,q,h,n

% Component type SS
	[conc]		SS		external,external
	[thermal]	SS		external,external

Added mtt/lib/comp/compound/Chemical/mC/mC_abg.fig version [c65ba4625b].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 4500 5625 4725 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 5175 4500 4500 4725 4725
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 1
	 5400 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 4275 4050 3600 3375 3600 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 3375 2250 3600 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 3375 3375 3375 5175 3600 4950
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 6300 4725 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 7425 4500 6750 4725 6975
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 7425 4725 7425
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 4
	 4275 6525 3375 6525 3375 5625 3600 5850
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2025 5400 2925 5400 2700 5625
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 2925 5175 2925 5625
4 1 0 100 0 18 18 0.0000 4 210 390 4500 5490 AF\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 4365 1\001
4 1 0 100 0 18 18 0.0000 4 210 510 3375 2025 C:C\001
4 1 0 100 0 18 18 0.0000 4 210 840 3375 5490 EMAE\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 6615 1\001
4 1 4 100 0 18 18 0.0000 4 270 900 4500 7875 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 3360 3240 0\001
4 1 4 100 0 18 14 0.0000 4 225 525 3150 5850 [out]\001
4 1 4 100 0 18 14 0.0000 4 225 660 2925 5175 [mod]\001
4 2 4 100 0 18 18 0.0000 4 270 1275 1935 5490 SS:[mod]\001

Added mtt/lib/comp/compound/Chemical/mC/mC_lbl.txt version [46ea0c0c8b].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY mC Modulated C component
#DESCRIPTION Effort on [mod] multiplies effort on [in]. Use with Cm

## System mC, representation lbl, language txt
## File mC_lbl.txt
## Generated by MTT on Tue Aug 13 15:52:46 EST 2013

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	mod	mod

## Argument aliases
#ALIAS	$1	k_eq

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type C
	C	lin		state,k_eq

## Component type EMAE (anonymous => default parameters)
	# EMAE							

## Component type SS


[in]	SS		external,external		
[mod]	SS		external,external		

Added mtt/lib/comp/compound/Control/Collocated/PDe/PDe_abg.fig version [2d2d27440d].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2925 3375 2700 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 3375 4725 3375 4500 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 3150 4950 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 3375 6525 3375 6300 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3150 3150 1800 3375 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6525 3150 6525 3600
2 4 0 2 31 7 51 0 -1 0.000 0 0 7 0 0 5
	 7875 4275 7875 900 450 900 450 4275 7875 4275
4 1 0 100 0 18 18 0.0000 4 195 150 3150 3465 0\001
4 1 0 100 0 18 18 0.0000 4 195 150 4950 3465 1\001
4 2 4 100 0 18 18 0.0000 4 270 870 1530 3465 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 1065 6660 3465 SS:[out]\001
4 1 0 100 0 18 18 0.0000 4 270 780 3150 1665 C:k_p\001
4 1 0 100 0 18 18 0.0000 4 270 765 4950 1665 R:k_d\001

Added mtt/lib/comp/compound/Control/Collocated/PDe/PDe_desc.tex version [69137e29ad].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PDe (PDe_desc.tex)
% Generated by MTT on Tue May 1 09:26:33 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{PDe} is
   displayed in Figure \Ref{fig:PDe_abg.ps} and its label
   file is listed in Section \Ref{sec:PDe_lbl}.
   The subsystems are listed in Section \Ref{sec:PDe_sub}.

   This is a proportional + derivative (PD) controller for a
   collocated sutuation where the control signal is an effort and the
   measured signal is a (collocated) flow.

   The controller can be thought of as controlling \emph{integated
   flow}, and it is with respect to this that the P and D terms are defined.

 The setpoint is a \emph{flow}; and must be generated to give the
 desired \emph{integrated} flow.

 Physically, the controller is a \textbf{C} and an \textbf{R}
 component - for mechanical systems a mass and a spring.
 
 Mathematically, in integral causality, the equations are:
%file: pde_{dae}.tex
%differential-algebraic equations
 \begin{equation}
   \begin{aligned}
     \dot x_{1} &=
     {
       f_d - f
       }
   \end{aligned}
 \end{equation}
 \begin{equation}
   \begin{aligned}
     u &=
     {
       - k_{d} f + k_{p} x_{1}
       }
   \end{aligned}
 \end{equation}

 The state $x_1$ is the the integrated difference between 
 \emph{desired} flow $f_d$ and the actual flow  $f$. Thus the control
 signal $u$ is $k_p$ multiplied by the position error minus $k_d$ time
 the flow.

Added mtt/lib/comp/compound/Control/Collocated/PDe/PDe_lbl.txt version [39ef22df22].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system PDe (PDe_lbl.txt)
%SUMMARY PDe: Proportional + Derivative controller with effort output
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	k_p
%ALIAS	$2	k_d

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	k_p	lin		state,k_p

% Component type R
	k_d	lin		flow,k_d

% Component type SS
	[in]	SS		internal,external
	[out]	SS		external,external

Added mtt/lib/comp/compound/Control/Collocated/PIe/PIe_abg.fig version [0806da5857].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3600 2475 3600 1125 3825 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 5175 2700 4950 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 900 5175 900 4950 1125
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 900 2025 900 2250 1125
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6525 3375 900 3375 900 450 6525 450 6525 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2475 5175 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2025 2475 2025 2925
4 1 0 100 0 18 18 0.0000 4 195 150 3600 2790 0\001
4 2 4 100 0 18 18 0.0000 4 270 825 1935 2790 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 930 5310 2790 SS:[out]\001
4 1 1 101 0 3 24 0.0000 4 165 195 4500 2520 u\001
4 1 1 101 0 3 24 0.0000 4 240 165 4545 3015 y\001
4 1 1 101 0 3 24 0.0000 4 165 240 2520 3015 w\001
4 1 0 100 0 18 18 0.0000 4 195 150 3600 990 1\001
4 1 0 100 0 18 18 0.0000 4 270 675 5670 990 C:k_i\001
4 1 0 100 0 18 18 0.0000 4 270 765 1575 945 R:k_p\001

Added mtt/lib/comp/compound/Control/Collocated/PIe/PIe_desc.tex version [1e82a62155].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PIe (PIe_desc.tex)
% Generated by MTT on Wed May 15 10:28:28 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{PIe} is
   displayed in Figure \Ref{fig:PIe_abg.ps} and its label
   file is listed in Section \Ref{sec:PIe_lbl}.

\textbf{PIe} implements a collocated PI controller where:
\begin{description}
\item[w] is the (flow) setpoint at port [w]
\item[y] is the (flow) system output at port [yu]
\item[u] is the (effort) system input (control signal) at port [yu]
\end{description}

The controller transfer-function is:
\begin{equation}
  u(s) = \left [ k_p + \frac{k_i}{s} \right ] e(s) 
\end{equation}
where the \emph{error} $e(s) = w(s) - y(s)$.

Added mtt/lib/comp/compound/Control/Collocated/PIe/PIe_lbl.txt version [0f4b746db8].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY PIe: PI controller with effort output
#DESCRIPTION Implements collocated PI controller with:
#DESCRIPTION   w (flow) setpoint at in-port
#DESCRIPTION   y (flow) measurement at out-port
#DESCRIPTION   u (effort) control  at out-port


## System PIe, representation lbl, language txt
## File PIe_lbl.txt
## Generated by MTT on Wed May 15 10:17:13 BST 2002

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	w	in
#ALIAS	yu	out

## Argument aliases
#ALIAS	$1	k_i
#ALIAS	$2	k_p

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type C
	k_i	lin		state,k_i		

## Component type R
	k_p	lin		flow,k_p		

## Component type R
	[in]	SS		internal,external		
	[out]	SS		external,external		

Added mtt/lib/comp/compound/Control/Collocated/PIe/PIe_rep.txt version [acf478c2a5].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system PIe (PIe_rep.txt)
## Generated by MTT on" Wed May 15 10:33:29 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt PIe abg tex			# The system description
mtt PIe cbg ps 		        # The causal bond graph
mtt PIe struc tex	        # The system structure
mtt PIe sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt PIe dae tex	        # The system dae
mtt PIe ode tex	        # The system ode 
## mtt PIe sspar tex		# Steady-state parameters
## mtt PIe ss tex 		# Steady state
## mtt PIe dm tex		# Descriptor matrices (of linearised system)
## mtt PIe sm tex		# State matrices (of linearised system)
mtt PIe tf tex		# Transfer function (of linearised system)
## mtt PIe lmfr ps		# log modulus of frequency response (of linearised system)
## mtt PIe simpar txt		# Simulation parameters
## mtt PIe numpar txt		# Numerical simulation parameters
## mtt PIe state txt		# Simulation initial state
## mtt PIe input txt		# Simulation input
## mtt PIe logic txt		# Logic control
## mtt PIe odeso ps		# Simulation output

mtt PIe rep txt		# This file

Added mtt/lib/comp/compound/Control/Collocated/Pe/Pe_abg.fig version [c0220ca1ab].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3600 2475 3600 1125 3825 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 5175 2700 4950 2925
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6525 3375 900 3375 900 450 6525 450 6525 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2475 5175 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2025 2475 2025 2925
4 1 0 100 0 18 18 0.0000 4 195 150 3600 2790 0\001
4 2 4 100 0 18 18 0.0000 4 270 870 1935 2790 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 1065 5310 2790 SS:[out]\001
4 1 1 101 0 3 24 0.0000 4 165 195 4500 2520 u\001
4 1 1 101 0 3 24 0.0000 4 240 165 4545 3015 y\001
4 1 1 101 0 3 24 0.0000 4 165 240 2520 3015 w\001
4 1 0 100 0 18 18 0.0000 4 270 765 3735 990 R:k_p\001

Added mtt/lib/comp/compound/Control/Collocated/Pe/Pe_desc.tex version [dc170f25ad].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Pe (Pe_desc.tex)
% Generated by MTT on Wed May 15 10:28:28 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/05/15 11:01:24  gawthrop
% %% New PI controller component
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pe} is
   displayed in Figure \Ref{fig:Pe_abg.ps} and its label
   file is listed in Section \Ref{sec:Pe_lbl}.

\textbf{Pe} implements a collocated P controller where:
\begin{description}
\item[w] is the (flow) setpoint at port [w]
\item[y] is the (flow) system output at port [yu]
\item[u] is the (effort) system input (control signal) at port [yu]
\end{description}

The controller transfer-function is:
\begin{equation}
  u(s) = k_p e(s) 
\end{equation}
where the \emph{error} $e(s) = w(s) - y(s)$.

Added mtt/lib/comp/compound/Control/Collocated/Pe/Pe_lbl.txt version [b5f59c98c6].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Pe: Proportional controller with effort output
#DESCRIPTION Implements collocated P controller with:
#DESCRIPTION   w (flow) setpoint at in-port
#DESCRIPTION   y (flow) measurement at out-port
#DESCRIPTION   u (effort) control  at out-port


## System Pe, representation lbl, language txt
## File Pe_lbl.txt
## Generated by MTT on Wed May 15 10:17:13 BST 2002

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  2002/05/15 11:01:24  gawthrop
  ## New PI controller component
  ##
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	w	in
#ALIAS	yu	out

## Argument aliases
#ALIAS	$1	k_p

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	k_p	lin		flow,k_p		

## Component type R
	[in]	SS		internal,external		
	[out]	SS		external,external		

Added mtt/lib/comp/compound/Control/Collocated/Pe/Pe_rep.txt version [2fca8aff77].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Pe (Pe_rep.txt)
## Generated by MTT on" Wed May 15 10:33:29 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2002/05/15 11:01:24  gawthrop
## New PI controller component
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt Pe abg tex			# The system description
mtt Pe cbg ps 		        # The causal bond graph
mtt Pe struc tex	        # The system structure
mtt Pe sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt Pe dae tex	        # The system dae
mtt Pe ode tex	        # The system ode 
## mtt Pe sspar tex		# Steady-state parameters
## mtt Pe ss tex 		# Steady state
## mtt Pe dm tex		# Descriptor matrices (of linearised system)
## mtt Pe sm tex		# State matrices (of linearised system)
mtt Pe tf tex		# Transfer function (of linearised system)
## mtt Pe lmfr ps		# log modulus of frequency response (of linearised system)
## mtt Pe simpar txt		# Simulation parameters
## mtt Pe numpar txt		# Numerical simulation parameters
## mtt Pe state txt		# Simulation initial state
## mtt Pe input txt		# Simulation input
## mtt Pe logic txt		# Logic control
## mtt Pe odeso ps		# Simulation output

mtt Pe rep txt		# This file

Added mtt/lib/comp/compound/Control/Collocated/Pe/sPe_lbl.txt version [7455590478].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY sPe Sensitivity version of Pe
#DESCRIPTION Detailed description here

## System sPe, representation lbl, language txt
## File sPe_lbl.txt
## Generated by MTT on Wed May 15 11:55:22 BST 2002

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in_1,in_2
#ALIAS	out	out_1,out_2

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 
	[in]	SS		internal,external		
	[out]	SS		external,external		

## Component type sR
	k_p	slin		flow,k_p;0		

Added mtt/lib/comp/compound/Electrical/OpAmp/OpAmp_abg.fig version [74374c6c0a].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 6300 2700 6075 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4950 2475 4950 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 2700 6300 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9900 2700 11250 2700 11025 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11250 2700 11250 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9900 2475 9900 2700
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 12600 5175 3825 5175 3825 450 12600 450 12600 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 4275 4725 2925 4950 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 2475 4725 1125 4950 1350
4 1 0 100 0 18 18 0.0000 4 195 150 4725 2790 1\001
4 1 0 100 0 18 18 0.0000 4 270 1590 9045 2790 SS:amp_out\001
4 1 0 100 0 18 18 0.0000 4 270 1395 7110 2790 SS:amp_in\001
4 1 4 100 0 18 18 0.0000 4 270 1140 4905 990 SS:[neg]\001
4 1 4 100 0 18 18 0.0000 4 270 1140 4725 4590 SS:[pos]\001
4 0 4 100 0 18 18 0.0000 4 270 1065 11385 2790 SS:[out]\001

Added mtt/lib/comp/compound/Electrical/OpAmp/OpAmp_lbl.txt version [72134047ce].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY OpAmp: an ideal operational amplifier
#DESCRIPTION Uses virtual earth concept


## System OpAmp, representation lbl, language txt
## File OpAmp_lbl.txt
## Generated by MTT on Tue Sep 18 09:32:19 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	neg	neg
#ALIAS	out	out
#ALIAS	pos	pos

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 
	[neg]	SS		external,external		
	[out]	SS		external,external		
	[pos]	SS		external,external		
	amp_in	SS		0,0
	amp_out	SS		internal,internal		

Added mtt/lib/comp/compound/Electrical/RC/RC_abg.fig version [cd120e33ca].


































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 4051 5626 3151 5851 3376
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 3825 585 4725 585 4725 765 3825 765 3825 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5400 1215 5850 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3150 675 3825 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4725 675 6750 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5625 675 5625 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5625 1215 5625 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3150 1575 6750 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 4277 6752 4277 6527 4502
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9225 5625 9225 225 900 225 900 5625 9225 5625
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5400 1080 5850 1080
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 2
	 4050 4050 4050 4500
4 2 4 0 0 0 20 0.0000 4 255 2040 3105 4365 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4277 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5627 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 195 375 4276 2926 R:r\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5626 2926 C:c\001
4 0 1 1 0 0 20 0.0000 4 135 105 4230 450 r\001
4 0 1 1 0 0 20 0.0000 4 135 120 6030 1215 c\001
4 1 1 1 0 0 20 0.0000 4 255 1350 4950 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 195 1200 4950 2025 Schematic\001
4 0 4 0 0 0 20 0.0000 4 255 2190 6887 4367 SS:[out]\001
4 0 1 1 0 0 20 0.0000 4 135 135 3375 4005 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 3465 4140 1\001
4 0 1 1 0 0 20 0.0000 4 195 75 3375 4590 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 3465 4725 1\001
4 0 1 1 0 0 20 0.0000 4 195 75 6165 4590 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 6255 4725 2\001
4 0 1 1 0 0 20 0.0000 4 135 135 6165 4005 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 6255 4140 2\001
4 0 1 1 0 0 20 0.0000 4 135 135 6660 1170 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 6750 1305 2\001
4 0 1 1 0 0 20 0.0000 4 195 75 6300 450 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 6390 585 2\001
4 0 1 1 0 0 20 0.0000 4 195 75 3375 450 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 3465 585 1\001
4 0 1 1 0 0 20 0.0000 4 135 135 3060 1170 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 3150 1305 1\001

Added mtt/lib/comp/compound/Electrical/RC/RC_desc.tex version [9f62e42e0f].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system RC (RC_desc.tex)
% Generated by MTT on Tue Aug 26 09:43:25 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\textbf{RC} is a Simple two-port RC circuit.  The two ports are [in]
and [out] and the two parameters are c and r respectively

   The acausal bond graph of system \textbf{RC} is
   displayed in Figure \Ref{RC_abg} and its label
   file is listed in Section \Ref{sec:RC_lbl}.
   The subsystems are listed in Section \Ref{sec:RC_sub}.

Added mtt/lib/comp/compound/Electrical/RC/RC_lbl.txt version [335a38c4b3].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system RC (RC_lbl.txt)
%SUMMARY RC A Simple two-port RC circuit
%DESCRIPTION This simple example is used in the manual.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2000/09/14 15:13:02  peterg
% %% Changed port CRs to give SISO system when used in isolation
% %%
% %% Revision 1.2  1998/07/27 11:09:36  peterg
% %% Commented the aliases.
% %%
% %% Revision 1.1  1998/07/16 20:16:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in	# The left-hand port
%ALIAS	out	out	# The right-hand port

% Argument aliases
%ALIAS	$1	c		# Capacitance
%ALIAS	$2	r		# Resistance

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c		lin	effort,c

% Component type R
	r		lin	flow,r

% Component type SS
	[in]		SS		external,internal
	[out]	SS		external,0

Added mtt/lib/comp/compound/Electrical/Tee/Tee_abg.fig version [5395f8e35a].
















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2250 765 3375 765 3375 1035 2250 1035 2250 765
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1575 5175 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1800 5175 1800
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 1350 900 2250 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 4725 900 4725 1575
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 5850 765 6975 765 6975 1035 5850 1035 5850 765
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 3375 900 4725 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 5805 900 4725 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 8100 900 6975 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 4725 1800 4725 2475 1350 2475
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 4725 2475 8100 2475 8100 2430
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 6076 4501 6076 4276 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 5851 2926 4501 3151 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8100 6077 6750 6077 6975 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 6077 4950 6077 5175 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 5852 6525 4502 6750 4727
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 4501 4951 4726
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9226 6976 226 6976 226 3826 9226 3826 9226 6976
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9225 3375 225 3375 225 225 9225 225 9225 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 6075 2700 6075 2475 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 5850 2700 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6750 5850 6750 6300
4 1 1 1 0 3 20 0.0000 4 270 465 1350 1710 u_1\001
4 1 1 1 0 3 20 0.0000 4 270 465 8145 1710 u_2\001
4 1 1 1 0 3 20 0.0000 4 285 420 1800 675 y_1\001
4 1 1 1 0 3 20 0.0000 4 285 420 7830 720 y_2\001
4 1 1 1 0 3 20 0.0000 4 285 420 7695 6345 y_2\001
4 1 1 1 0 3 20 0.0000 4 270 465 7650 5940 u_2\001
4 1 -1 0 0 2 20 0.0000 4 210 150 4726 6166 0\001
4 1 -1 0 0 2 20 0.0000 4 210 150 2926 6166 1\001
4 1 -1 0 0 2 20 0.0000 4 285 720 2926 4366 R:r_1\001
4 1 -1 0 0 2 20 0.0000 4 210 150 6525 6167 1\001
4 1 -1 0 0 2 20 0.0000 4 285 720 6525 4367 R:r_2\001
4 1 -1 0 0 2 20 0.0000 4 210 420 4726 4366 C:c\001
4 1 1 1 0 3 20 0.0000 4 210 1335 4680 3060 Schematic\001
4 1 1 1 0 3 20 0.0000 4 285 1470 4725 6705 Bond graph\001
4 1 1 1 0 3 20 0.0000 4 270 390 2835 1350 r_1\001
4 1 1 1 0 3 20 0.0000 4 270 390 6345 1350 r_2\001
4 1 1 1 0 3 20 0.0000 4 135 135 3870 1800 c\001
4 1 1 1 0 3 20 0.0000 4 270 465 1980 5940 u_1\001
4 1 1 1 0 3 20 0.0000 4 285 420 1980 6390 y_1\001
4 1 4 0 0 2 20 0.0000 4 285 1050 765 6165 SS:[e_1]\001
4 1 4 0 0 2 20 0.0000 4 285 1050 8640 6165 SS:[e_2]\001

Added mtt/lib/comp/compound/Electrical/Tee/Tee_desc.tex version [296908f279].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Tee (Tee_desc.tex)
% Generated by MTT on Fri Mar 13 16:28:54 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tee} is
   displayed in Figure \Ref{Tee_abg} and its label
   file is listed in Section \Ref{sec:Tee_lbl}.

This simple ``tee'' RC circuit has two ports:
\begin{itemize}
\item Port [1] carrying $v_1$ and $i_1$ and
\item Port [2] carrying $v_2$ and $i_2$.
\end{itemize}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Electrical/Tee/Tee_lbl.txt version [f80b44db39].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Tee	Electrical T circuit
%DESCRIPTION A two port circuit composed of 2 resistors and one
%DESCRIPTION capacitor in a T form,

%% Label file for system Tee (Tee_lbl.txt)

%ALIAS	$1	r_1
%ALIAS	$2	r_2
%ALIAS	$3	c

%ALIAS	in	e_1
%ALIAS	out	e_2

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/16 22:21:09  peterg
% %% Changed port names
% %%
% %% Revision 1.1  1998/07/16 16:30:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c		lin	effort,c

% Component type R
	r_1		lin	flow,r_1
	r_2		lin	flow,r_2

% Component type SS
	[e_1]		SS	external,external
	[e_2]		SS	external,external

Added mtt/lib/comp/compound/Electromechanical/CM/CM_abg.fig version [6ad47bab15].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 4050 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2250 5175 900 5400 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 6750 2475 6525 2700
2 2 0 3 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 7650 2025 2700 2025 2700 2925 7650 2925 7650 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 5850 5175 4500 5400 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 7680 5175 6330 5400 6555
2 2 0 3 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 7650 5625 2700 5625 2700 6525 7650 6525 7650 5625
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6750 2250 6750 2700
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2700 5400 2700
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5850 5400 5850
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 8325 8325 450 2025 450 2025 8325 8325 8325
4 1 4 0 0 0 20 0.0000 4 240 960 5175 810 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 2565 1\001
4 1 -1 0 0 0 20 0.0000 4 195 1485 5175 4365 C:transducer\001
4 0 -1 0 0 0 20 0.0000 4 195 735 6840 2565 I:mass\001
4 0 1 1 0 0 20 0.0000 4 255 885 2880 2340 Moving\001
4 0 1 1 0 0 20 0.0000 4 195 585 2880 2670 Plate\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 6165 1\001
4 1 4 0 0 0 20 0.0000 4 240 810 5175 8055 SS:[in]\001
4 0 1 1 0 0 20 0.0000 4 195 585 2880 6315 Plate\001
4 0 1 1 0 0 20 0.0000 4 195 630 2880 5940 Fixed\001

Added mtt/lib/comp/compound/Electromechanical/CM/CM_desc.tex version [0b7d49b6d5].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system CM (CM_desc.tex)
% Generated by MTT on Fri Sep 19 18:07:12 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CM} is
   displayed in Figure \Ref{CM_abg} and its label
   file is listed in Section \Ref{sec:CM_lbl}.
   The subsystems are listed in Section \Ref{sec:CM_sub}.

{\bf CM} is an electromechanical moving-plate  capacitor with linear
electrical capacitance $c$ of the form
\begin{equation}
  c = c_0 \frac{x_0}{x}
\end{equation}
where $x_0$ is the plate separation corresponding to a capacitance of
$c_0$.
The corresponding electrical constitutive relationship (which gives an
energy-conserving two-port \textbf{C}) is
\begin{equation}
  F = Q c_0 \frac{x_0}{x^2}
\end{equation}
where $F$ is the force between the plates and $Q$ the charge on the
capacitor.
This is implemented in the \emph{cm.cr} Constitutive Relationship.

Added mtt/lib/comp/compound/Electromechanical/CM/CM_lbl.txt version [3db80c8bb3].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CM: Mechanical (moving-plate) capacitor
%DESCRIPTION Parameter 1: Capacitance at plate separation of x_0
%DESCRIPTION Parameter 2: x_0
%DESCRIPTION Parameter 3: mass of moving-plate

%% Label file for system CM (CM_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	transducer	cm		$1,$2

% Component type I
	mass		lin		flow,$3

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Added mtt/lib/comp/compound/Electromechanical/DC/DC_abg.fig version [3c7bbadd09].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4860 4730 4860 494 2293 494 2293 4730 4860 4730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2036 2724 3371 2724 3063 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2501 3576 1342 3833 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3782 2724 5116 2724 4808 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2947 3576 4106 3833 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6656 2724 7991 2724 7683 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8196 2546 8196 1386 8453 1654
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8196 2947 8196 4106 8453 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8453 2724 9788 2724 9480 2947
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9480 4730 9480 494 6913 494 6913 4730 9480 4730
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12150 5175 45 5175 45 316 12150 316 12150 5175
4 2 4 0 0 0 20 0.0000000 4 240 1815 1980 2790 SS:[Electrical]\001
4 1 -1 0 0 0 23 0.0000000 4 240 171 3525 2858 1\001
4 1 -1 0 0 0 23 0.0000000 4 274 1198 5938 2813 GY:k_m\001
4 1 -1 0 0 0 23 0.0000000 4 240 171 8196 2813 1\001
4 1 -1 0 0 0 23 0.0000000 4 274 650 3525 1252 I:l_a\001
4 1 -1 0 0 0 23 0.0000000 4 308 770 8299 1252 I:j_m\001
4 1 -1 0 0 0 23 0.0000000 4 274 770 3628 4463 R:r_a\001
4 1 -1 0 0 0 23 0.0000000 4 274 941 8248 4463 R:b_m\001
4 1 1 1 0 0 23 0.0000000 4 240 1352 3576 5043 Electrical\001
4 1 1 1 0 0 23 0.0000000 4 240 1626 8196 5043 Mechanical\001
4 1 1 1 0 0 23 0.0000000 4 240 736 10404 3170 Shaft\001
4 1 1 1 0 0 23 0.0000000 4 240 1420 1472 3170 Terminals\001
4 0 4 0 0 0 20 0.0000000 4 240 2055 9945 2835 SS:[Mechanical]\001

Added mtt/lib/comp/compound/Electromechanical/DC/DC_desc.tex version [77c4d38d75].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system DC (DC_desc.tex)
% Generated by MTT on Thu Sep 11 10:09:58 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{DC} is
   displayed in Figure \Ref{DC_abg} and its label
   file is listed in Section \Ref{sec:DC_lbl}.
   The subsystems are listed in Section \Ref{sec:DC_sub}.

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|}
        \hline
        Index & Parameter\\
        \hline
         1 & Motor gain ($k_m$) \\
         2 & Armature inductance ($l_a$) \\
         3 & Armature resistance ($r_a$) \\
         4 & Inertia ($j_m$) \\
         5 & Friction coefficient ($b_m$) \\
        \hline
       \end{tabular}
       \caption{DC motor parameters}
       \label{tab:DC_components}
     \end{center}
   \end{table}
{\bf DC} is a two-port component representing a DC motor. It has the 5
parameters listed in Table \Ref{tab:DC_components}.


Added mtt/lib/comp/compound/Electromechanical/DC/DC_lbl.txt version [16aaf3fedc].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY DC: DC motor (or generator)

%% Port Alias
%ALIAS in	Electrical
%ALIAS out	Mechanical

%% Unit definition
%UNITS Electrical electrical volt amp
%UNITS Mechanical rotational N*m radians/s

%ALIAS $1	k_m
%ALIAS $2	l_a
%ALIAS $3	r_a
%ALIAS $4	j_m
%ALIAS $5	b_m


%% Label file for system DC (DC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.6  2000/11/16 09:45:51  peterg
% %% Added unit definitions
% %%
% %% Revision 1.5  1998/07/26 12:49:24  peterg
% %% Corrected some errors
% %%
% %% Revision 1.4  1998/07/26 12:45:33  peterg
% %% Added ports
% %%
% %% Revision 1.3  1998/07/22 12:01:17  peterg
% %% Aliased ports and parameters.
% %%
% %% Revision 1.2  1996/12/04  16:01:42  peterg
% %% Documantation added.
% %%
% %% Revision 1.1  1996/12/04  16:00:56  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin	flow,k_m

% Electrical components
%Inductance
l_a	lin	effort,l_a

%Resistance
r_a	lin	flow,r_a

% Mechanical components
%Inertia
j_m	lin	flow,j_m

%Friction
b_m	lin	flow,b_m

% Ports
	[Electrical]	SS	external,external
	[Mechanical]	SS	external,external

Added mtt/lib/comp/compound/Electromechanical/Piezo/Piezo_abg.fig version [9fbac50594].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 1575 4275 1575 4050 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 1575 6075 1575 5850 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 1575 8550 1575 8325 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 1575 10350 1575 10125 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 1800 4500 3150 4725 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8775 1800 8775 3150 9000 2925
4 1 0 100 0 18 18 0.0000 4 195 150 4500 1665 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 8775 1665 0\001
4 2 4 100 0 18 18 0.0000 4 270 900 2835 1665 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 1095 10440 1665 SS:[out]\001
4 1 0 100 0 18 18 0.0000 4 270 780 8775 3600 C:k_p\001
4 1 0 100 0 18 18 0.0000 4 270 795 4500 3600 C:c_p\001
4 1 0 100 0 18 18 0.0000 4 270 945 6615 1665 TF:g_p\001

Added mtt/lib/comp/compound/Electromechanical/Piezo/Piezo_lbl.txt version [14c4bd7168].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Piezo: Piezo-electric transducer
#DESCRIPTION Simple Mason model in Bond Graph form

## System Piezo, representation lbl, language txt
## File Piezo_lbl.txt
## Generated by MTT on Wed Mar 15 16:55:26 EST 2006

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	c_p
#ALIAS	$2	g_p
#ALIAS	$3	k_p

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type C
	c_p	lin		effort,c_p		
	k_p	lin		state,k_p		

## Component type SS
	[in]	SS		external,external		
	[out]	SS		external,external		

## Component type TF
	g_p	lin		flow,g_p		

Added mtt/lib/comp/compound/GasDynamics/CG/CG_abg.fig version [302cfd2048].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2700 3600 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2025 4950 2025 4725 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2925 4950 2925 4725 3150
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 2250 9675 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2025 3150 2025 2925 2250
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 1800 1800 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7875 2250 7875 900 3375 900 3375 1800 3600 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 2475 6075 2475 6300 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9630 2475 8280 2475 8505 2700
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4500 3600 6525 3600
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4725 4500 4725 4500 1350 6525 1350 6525 4725
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 9315 540 8055 900
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8910 4725 8910 1800 6975 1800 6975 4725 8910 4725
4 2 4 0 0 0 20 0.0000 4 240 1185 3510 3015 SS:[mass]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4860 1800 [1]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4860 2745 [2]\001
4 1 -1 0 0 2 30 0.0000 4 405 885 5445 2610 C:cg\001
4 1 -1 0 0 0 20 0.0000 4 255 645 7830 2565 PS:ps\001
4 0 4 0 0 0 20 0.0000 4 240 1920 9855 2565 SS:[mechanical]\001
4 1 4 0 0 0 20 0.0000 4 240 315 6120 2205 [3]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 2115 0\001
4 2 4 0 0 0 20 0.0000 4 240 1575 1755 2115 SS:[thermal]\001
4 1 4 0 0 0 20 0.0000 4 240 405 7245 2295 [in]\001
4 0 4 0 0 0 20 0.0000 4 255 885 7965 2160 [power]\001
4 0 4 0 0 0 20 0.0000 4 240 555 8325 2790 [out]\001
4 1 1 1 0 0 20 0.0000 4 255 1050 5490 3915 Enthalpy\001
4 1 1 1 0 0 20 0.0000 4 195 600 5490 4245 Mass\001
4 1 1 1 0 0 20 0.0000 4 195 915 5490 4575 Volume\001
4 1 1 1 0 0 20 0.0000 4 195 135 9405 2295 p\001
4 1 1 1 0 0 20 0.0000 4 255 645 9270 2745 dV/dt\001
4 1 1 1 0 0 20 0.0000 4 255 915 7380 1440 p*dV/dt\001
4 1 1 1 0 0 20 0.0000 4 255 3885 9360 450 Joule's work-enthalpy conversion\001
4 1 1 1 0 0 20 0.0000 4 195 1590 7920 3960 Power Sensor\001
4 1 1 1 0 0 20 0.0000 4 255 1800 7920 4380 Work-enthalpy\001

Added mtt/lib/comp/compound/GasDynamics/CG/CG_cr.r version [1677b660d4].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CG	CR two-port C thermal pseudo Bond Graph for gas dynamics


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/03/04 15:38:16  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



OPERATOR CG;

% Port 1 : temperature
FOR ALL COMP, c_v,r,Enthalpy,Stored_Mass,Volume
LET CG(COMP, c_v,r, effort, 1,
		Enthalpy,state,1,
		Stored_Mass,state,2,
		Volume,state,3)
	 = Enthalpy/(c_v*Stored_Mass);

% Port 2 : Pressure
FOR ALL COMP, c_v,r,Enthalpy,Stored_Mass,Volume
LET CG(COMP, c_v,r, effort, 2,
		Enthalpy,state,1,
		Stored_Mass,state,2,
		Volume,state,3)
	 = (R/c_v)*(Enthalpy/Volume);

% Port 3 : (Also) Pressure
FOR ALL COMP, c_v,r,Enthalpy,Stored_Mass,Volume
LET CG(COMP, c_v,r, effort, 3,
		Enthalpy,state,1,
		Stored_Mass,state,2,
		Volume,state,3)
	 = (R/c_v)*(Enthalpy/Volume);

END;;

Added mtt/lib/comp/compound/GasDynamics/CG/CG_lbl.txt version [ef7e187124].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CG: C component for compressible gas dynamics
%DESCRIPTION Port [Thermal]: Temperature/Enthalpy pseudo bond
%DESCRIPTION Port [Mass]: Pressure/mass-flow pseudo bond
%DESCRIPTION Port [Mechanical]: Pressure/volume flow energy bond
%DESCRIPTION 
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: R   (universal gas constant)
%DESCRIPTION Based on Karnopp, Margolis and Rosenberg: Section 12.4.


%% Label file for system CG (CG_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 12:06:06  peterg
% %% Renamed CR from GasAccumulator to CG
% %%
% %% Revision 1.1  1997/11/21  17:06:34  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	cg		CG		$1,$2

% Component type PS
	ps		lin		effort,1

% Component type SS
	[mass]			SS	external,external
	[mechanical]		SS	external,external
	[thermal]		SS	external,external

Added mtt/lib/comp/compound/GasDynamics/RG/RG_abg.fig version [9e11c46244].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2925 4950 2925 4725 3150
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4500 3600 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2025 4950 2025 4725 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2925 7425 2925 7200 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2025 7425 2025 7200 2250
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4500 4500 4500 4500 1350 6525 1350 6525 4500
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 1800 4950 2250
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2700 4950 3150
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 1800 6075 2250
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 2700 6075 3150
4 2 4 0 0 0 20 0.0000 4 255 1545 3510 3015 SS:[mass_in]\001
4 1 1 1 0 0 20 0.0000 4 255 1125 5490 3915 Isentropic\001
4 1 1 1 0 0 20 0.0000 4 195 780 5490 4245 Nozzle\001
4 1 -1 0 0 2 30 0.0000 4 405 885 5535 2520 R:rg\001
4 2 4 0 0 0 20 0.0000 4 255 1935 3510 2115 SS:[thermal_in]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 7515 2115 SS:[thermal_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1695 7515 2970 SS:[mass_out]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4725 1935 [1]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4725 2835 [2]\001
4 1 4 0 0 0 20 0.0000 4 240 315 6300 1935 [3]\001
4 1 4 0 0 0 20 0.0000 4 240 315 6300 2835 [4]\001

Added mtt/lib/comp/compound/GasDynamics/RG/RG_cr.r version [e11fae6313].



































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY RG	CR for 2 port gas dymanics R: isentropic nozzle


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/03/04 15:37:48  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



OPERATOR RG;

% Port 1 : Enthalpy flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 1,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) )
           *(gamma/(gamma-1))*R*T_u;

% Port 2 : Mass flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 2,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) );

% Port 3 : Enthalpy flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 3,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) )
           *(gamma/(gamma-1))*R*T_u;

% Port 4 : Mass flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 4,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) );


END;;

Added mtt/lib/comp/compound/GasDynamics/RG/RG_lbl.txt version [4f6435da35].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY RG: R component for compressible gas dynamics: isentropic nozzle
%DESCRIPTION Port [Thermal_in]: Temperature/Enthalpy pseudo bond
%DESCRIPTION Port [Thermal_out]: Temperature/Enthalpy pseudo bond
%DESCRIPTION Port [Mass_in]: Pressure/mass-flow pseudo bond
%DESCRIPTION Port [Mass_out]: Pressure/mass-flow pseudo bond
%DESCRIPTION 
%DESCRIPTION Parameter 1: gamma (c_p/c_v)
%DESCRIPTION Parameter 2: R   (universal gas constant)
%DESCRIPTION Parameter 3: A   (nozzle cross-section)
%DESCRIPTION Based on Karnopp, Margolis and Rosenberg: Section 12.4.



%% Label file for system RG (RG_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 12:07:37  peterg
% %% Renamed CR from Isentropic nozzle to RG
% %%
% %% Revision 1.1  1997/11/21 19:18:28  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RG
	rg			RG		$1,$2,$3

% Component type SS
	[mass_in]		SS	external,external
	[mass_out]		SS	external,external
	[thermal_in]		SS	external,external
	[thermal_out]		SS	external,external

Added mtt/lib/comp/compound/General/AEf/AEf_abg.fig version [2bb474d90c].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2475 2475 2475 2250 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3397 2497 4522 2497 4297 2722
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5197 2475 6322 2475 6097 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 2250 4500 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2250 5175 2700
4 1 0 100 0 18 20 0.0000 4 225 675 2880 2610 AE:a\001
4 1 0 100 0 18 20 0.0000 4 225 435 4860 2610 GY\001
4 1 4 100 0 18 20 0.0000 4 285 975 810 2565 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1170 6975 2610 SS:[out]\001

Added mtt/lib/comp/compound/General/AEf/AEf_lbl.txt version [b30a0cb74c].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system AEf (AEf_lbl.txt)
%SUMMARY AEf  Effort input amplifier with flow output
%DESCRIPTION Made from AE with GY on output

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:19:43  peterg
% %% Initial revision
% %%
% %% Revision 1.2  1999/03/05 08:25:11  peterg
% %% Changed default to lin.
% %%
% %% Revision 1.1  1999/03/04 06:05:46  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS $1	g

% CR aliases
%ALIAS $1	lin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	a	 lin	g

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Added mtt/lib/comp/compound/General/AFe/AFe_abg.fig version [29c3db9edf].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2475 2475 2475 2250 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3397 2497 4522 2497 4297 2722
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5197 2475 6322 2475 6097 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1350 2250 1350 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2250 3375 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 2250 6300 2700
4 1 0 100 0 18 20 0.0000 4 225 660 2880 2610 AF:a\001
4 1 0 100 0 18 20 0.0000 4 225 435 4860 2610 GY\001
4 1 4 100 0 18 20 0.0000 4 285 975 810 2565 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1170 6975 2610 SS:[out]\001

Added mtt/lib/comp/compound/General/AFe/AFe_lbl.txt version [b70ba3967b].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system AFe (AFe_lbl.txt)
%SUMMARY AFe  Flow input amplifier with effort output
%DESCRIPTION Made from AF with GY on output

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/03/04 06:05:46  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS $1	g

% CR aliases
%ALIAS $1	lin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	a	 lin	g

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Added mtt/lib/comp/compound/General/CD/CD_abg.fig version [aad9d9952e].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2700 3150 2700 2250 2925 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2925 3375 3825 3375 3600 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2475 3375 2250 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2250 1575 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 225 3375 1125 3375 900 3600
4 1 0 100 0 18 18 0.0000 4 210 510 1350 2115 Df:f\001
4 1 0 100 0 18 18 0.0000 4 210 630 2700 2115 De:e\001
4 0 0 100 0 18 18 0.0000 4 210 405 3960 3465 C:c_1\001
4 2 4 100 0 18 18 0.0000 4 270 900 135 3465 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 1350 3465 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 2700 3465 0\001

Added mtt/lib/comp/compound/General/CD/CD_lbl.txt version [0361769b53].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY CD
#DESCRIPTION Detailed description here

## System CD, representation lbl, language txt
## File CD_lbl.txt
## Generated by MTT on Thu Apr 24 10:30:13 EST 2014

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in

## Argument aliases
#ALIAS	$1	effort,c_1

## cr aliases
#ALIAS	$a1      lin


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type De
	e	SS		external		

## Component type Df
	f	SS		external		

## Component type I
	c_1	lin		effort,c_1		

## Component type SS
	[in]	SS		external,external		

Added mtt/lib/comp/compound/General/CDx/CDx_abg.fig version [94a4ce7f04].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 3375 1575 3600 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 3375 3375 4725 3150 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4950 5175 4950 4950 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6750 5850 675 5850 675 900 6750 900 6750 5850
4 1 0 100 0 18 18 0.0000 4 210 450 3375 1440 C:c\001
4 1 0 100 0 18 18 0.0000 4 195 150 3375 3240 0\001
4 2 4 100 0 18 18 0.0000 4 270 870 1755 3240 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 210 615 3330 5085 AE:a\001
4 0 4 100 0 18 18 0.0000 4 270 1065 5310 5040 SS:[out]\001

Added mtt/lib/comp/compound/General/CDx/CDx_desc.tex version [17fa742049].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system CDx (CDx_desc.tex)
% Generated by MTT on Thu Apr 19 10:28:34 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CDx} is
   displayed in Figure \Ref{fig:CDx_abg.ps} and its label
   file is listed in Section \Ref{sec:CDx_lbl}.

   This component is a standard compliance except that:
   \begin{itemize}
   \item There is an additional output equal to the integrated flow
     variable
   \item the re is a single parameter $c$ -- the compliance.
   \end{itemize}

Added mtt/lib/comp/compound/General/CDx/CDx_lbl.txt version [284818d0c6].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system CDx (CDx_lbl.txt)
%SUMMARY CDx: C component with state output
%DESCRIPTION Parameter 1: compliance

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	c

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	a	lin		c

% Component type C
	c	lin		effort,c

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Added mtt/lib/comp/compound/General/CS/CS_abg.fig version [fd0075bfee].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 0 100 0 18 20 0.0000 4 270 195 2475 4185 1\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 2700 4275
4 1 0 100 0 18 20 0.0000 4 285 570 2475 2295 C:c\001
4 0 0 100 0 18 20 0.0000 4 360 1185 4185 4185 Se:e_0\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2475 6030 SS:[in]\001

Added mtt/lib/comp/compound/General/CS/CS_lbl.txt version [831d1fc9fc].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system CS (CS_lbl.txt)
%SUMMARY CS C component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	effort,c
%ALIAS	$2	e_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c		lin	effort,c

% Component type SS
	[in]	 SS	external,external

% Component type Se
	e_0		SS	e_0


Added mtt/lib/comp/compound/General/CSW/CSW_abg.fig version [06cb19839f].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2925 2475 1575 2700 1800
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 4770 3600 4770 900 225 900 225 3600 4770 3600
4 1 4 0 0 0 20 0.0000 4 240 810 2475 3240 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 2130 2520 1440 C:MTT_SWITCH\001

Added mtt/lib/comp/compound/General/CSW/CSW_lbl.txt version [68ae2c8631].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CSW: Switched C component
%DESCRIPTION CSW acts as an C component except when the -s -c option is used.
%DESCRIPTION When the -s -c option is used:
%DESCRIPTION   The component label is used as a variable name (eg Name)
%DESCRIPTION   In the ode simulation:
%DESCRIPTION     Name = 1 implies normal C (closed switch)
%DESCRIPTION     Name = 0 implies state=0 (open switch)
%DESCRIPTION     Name = -1 implies state>0 (Diode)

%ALIAS out	in
%ALIAS $1	lin
%ALIAS $1	effort,c_s

%% Label file for system CSW (CSW_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/09/11 09:00:52  peterg
% %% More documentation.
% %%
% %% Revision 1.1  1997/06/16  10:55:20  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/06/03 15:26:09  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	MTT_SWITCH		lin	effort,c_s

% Component type SS
	[in]			SS	external,external
  

Added mtt/lib/comp/compound/General/CX/CX_abg.fig version [b9b1976c8f].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2700 4950 2700 4725 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 3375 2475 3600 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 3600 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2475 3600 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 2475 1800 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 1125 3150 1125
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 3600 6075 450 225 450 225 3600 6075 3600
4 1 -1 0 0 22 20 0.0000 4 225 150 3375 2835 0\001
4 1 -1 0 0 22 20 0.0000 4 240 435 5355 2790 C:c\001
4 2 4 0 0 22 20 0.0000 4 315 870 1665 2790 SS:[in]\001
4 1 4 0 0 22 20 0.0000 4 315 810 3375 990 SS:[X]\001

Added mtt/lib/comp/compound/General/CX/CX_lbl.txt version [088e24913c].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY CX	C component with state i/o
#DESCRIPTION Port [X]: state i/o
## Label file for system CX (CX_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.3  2000/08/29 15:25:33  peterg
# ## New SS format
# ##
# ## Revision 1.2  1998/04/14 17:06:44  peterg
# ## Input only to SS
# ##
# ## Revision 1.1  1998/04/12 15:21:11  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank


# Component type C
	c		$1	$1

# Component type SS
	[in]		SS	internal,external
	[X]		SS	internal,external


Added mtt/lib/comp/compound/General/De/De_abg.fig version [19922bcba7].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 2475 3150 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
4 0 0 100 0 18 20 0.0000 4 285 660 3285 2790 SS:y\001
4 2 4 100 0 18 20 0.0000 4 285 975 1755 2790 SS:[in]\001

Added mtt/lib/comp/compound/General/De/De_lbl.txt version [b3f7fc39d1].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system De (De_lbl.txt)
%SUMMARY De Simple effort detector
%DESCRIPTION Simple effort detector constructed from SS with fixed causality

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/09/07 03:32:21  peterg
% %% Fixed alias bug
% %%
% %% Revision 1.2  1999/09/07 03:21:02  peterg
% %% Aliased to out as well as in
% %%
% %% Revision 1.1  1999/03/03 22:02:04  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	in

% Argument aliases
%ALIAS $1 external

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[in]	SS		external,external
	y	SS		external,0

Added mtt/lib/comp/compound/General/Df/Df_abg.fig version [3f6b2d808a].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1800 2475 1800 2925
4 0 0 100 0 18 20 0.0000 4 285 660 3285 2790 SS:y\001
4 2 4 100 0 18 20 0.0000 4 285 975 1755 2790 SS:[port]\001

Added mtt/lib/comp/compound/General/Df/Df_lbl.txt version [0ba236636b].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Df (Df_lbl.txt)
%SUMMARY Df Simple flow detector
%DESCRIPTION Simple flow detector constructed from SS with fixed causality


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/09/07 03:31:47  peterg
% %% Fixed alias bug
% %%
% %% Revision 1.2  1999/09/07 03:20:34  peterg
% %% Aliased to out as well as in
% %%
% %% Revision 1.1  1999/03/03 22:05:16  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port

% Argument aliases
%ALIAS $1 external
%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port]	SS		external,external
	y	SS		0,external

Added mtt/lib/comp/compound/General/EMAE/EMAE_abg.fig version [1dbc970685].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3150 4995 3150 4725 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 1080 5850 2475 5580 2205
2 4 0 2 31 7 0 0 -1 0.000 0 0 7 0 0 5
	 10125 4275 10125 225 225 225 225 4275 10125 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1530 3150 2925 3150 2655 3420
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 6075 2475 5625 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 2925 2925 2925 3375
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 8100 2925 8100 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6705 3150 8100 3150 7830 3420
4 1 -1 0 0 22 20 0.0000 4 240 375 3330 3240 AE\001
4 1 -1 0 0 22 20 0.0000 4 315 1380 5895 3240 EMTF:gain\001
4 2 4 0 0 22 20 0.0000 4 300 870 1485 3240 SS:[in]\001
4 0 4 0 0 22 20 0.0000 4 300 1050 8370 3240 SS:[out]\001
4 1 4 0 0 22 20 0.0000 4 300 1200 5805 945 SS:[mod]\001
4 1 4 0 0 22 20 0.0000 4 300 750 5850 2925 [mod]\001
4 2 4 0 0 22 20 0.0000 4 300 420 4995 2925 [in]\001
4 0 4 0 0 22 20 0.0000 4 300 600 6705 2925 [out]\001

Added mtt/lib/comp/compound/General/EMAE/EMAE_lbl.txt version [565fc328bb].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY EMAE Effort-modulated AE component
%DESCRIPTION Ports: [in], [out] and [mod]


%% Label file for system EMAE (EMAE_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/08/29 15:27:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type EMTF
	gain		lin		effort

% Component type SS
	[in]	SS	external,external
	[mod]	SS	external,external
	[out]	SS	external,external


Added mtt/lib/comp/compound/General/EMAF/EMAF_abg.fig version [aa727f2728].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3150 2970 3150 2700 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3150 4995 3150 4725 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3150 8145 3150 7875 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 1080 5850 2475 5580 2205
2 4 0 2 31 7 0 0 -1 0.000 0 0 7 0 0 5
	 10125 4275 10125 225 225 225 225 4275 10125 4275
4 1 -1 0 0 22 20 0.0000 4 210 390 3330 3240 AF\001
4 1 -1 0 0 22 20 0.0000 4 270 1455 5895 3240 EMTF:gain\001
4 2 4 0 0 22 20 0.0000 4 270 900 1485 3240 SS:[in]\001
4 0 4 0 0 22 20 0.0000 4 270 1095 8370 3240 SS:[out]\001
4 1 4 0 0 22 20 0.0000 4 270 1275 5805 945 SS:[mod]\001
4 1 4 0 0 22 20 0.0000 4 270 795 5850 2925 [mod]\001
4 2 4 0 0 22 20 0.0000 4 270 420 4995 2925 [in]\001
4 0 4 0 0 22 20 0.0000 4 270 615 6705 2925 [out]\001

Added mtt/lib/comp/compound/General/EMAF/EMAF_lbl.txt version [87238e5bdf].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY EMAF Effort-modulated AF component
%DESCRIPTION Ports: [in], [out] and [mod]


%% Label file for system EMAF (EMAF_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type EMTF
	gain		lin		flow

% Component type SS
	[in]	SS	external,external
	[mod]	SS	external,external
	[out]	SS	external,external


Added mtt/lib/comp/compound/General/EMR/EMR_abg.fig version [21cb2b31ff].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2040 3030 2460 3240
4 1 0 100 0 18 18 0.0000 4 210 420 2250 3240 GY\001
-6
6 1800 4725 2700 5175
4 1 0 100 0 18 18 0.0000 4 210 825 2250 5040 FMR:r\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1575 2250 2925 2025 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 3375 2250 4725 2025 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 6525 2250 5175 2025 5400
4 1 4 100 0 18 18 0.0000 4 270 1275 2250 1350 SS:[mod]\001
4 1 4 100 0 18 18 0.0000 4 270 900 2250 6975 SS:[in]\001
4 0 4 100 0 18 14 0.0000 4 225 660 2475 4725 [mod]\001

Added mtt/lib/comp/compound/General/EMR/EMR_lbl.txt version [f4e2219999].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY EMR Effort-modulated resistor
#DESCRIPTION Resistor CR is modulated by effort on port [mod]

## System EMR, representation lbl, language txt
## File EMR_lbl.txt
## Generated by MTT on Wed Aug 14 09:04:10 EST 2013

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	mod	mod

## Argument aliases
#ALIAS	$1	effort,k

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type FMR
	r	lin		effort,k		

## Component type GY (anonymous => default parameters)
	# GY							

## Component type SS
	[in]	SS		external,external		
	[mod]	SS		external,external		

Added mtt/lib/comp/compound/General/ID/ID_abg.fig version [3c5ad82144].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2700 3150 2700 2250 2925 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2925 3375 3825 3375 3600 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2475 3375 2250 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2250 1575 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 225 3375 1125 3375 900 3600
4 1 0 100 0 18 18 0.0000 4 210 510 1350 2115 Df:f\001
4 1 0 100 0 18 18 0.0000 4 210 630 2700 2115 De:e\001
4 0 0 100 0 18 18 0.0000 4 210 405 3960 3465 I:i_1\001
4 2 4 100 0 18 18 0.0000 4 270 900 135 3465 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 1350 3465 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 2700 3465 0\001

Added mtt/lib/comp/compound/General/ID/ID_lbl.txt version [e582da806b].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY ID
#DESCRIPTION Detailed description here

## System ID, representation lbl, language txt
## File ID_lbl.txt
## Generated by MTT on Thu Apr 24 10:30:13 EST 2014

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in

## Argument aliases
#ALIAS	$1	flow,i_1

## cr aliases
#ALIAS	$a1      lin


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type De
	e	SS		external		

## Component type Df
	f	SS		external		

## Component type I
	i_1	lin		flow,i_1		

## Component type SS
	[in]	SS		external,external		

Added mtt/lib/comp/compound/General/INTF/INTF_abg.fig version [e2d23cbb77].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3150 7201 3150 6976 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 4050 450 4050 450 1350 9900 1350 9900 4050
4 2 4 0 0 0 20 0.0000 4 240 1170 1711 3241 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 195 375 3016 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4501 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 195 4501 1891 C\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5986 3241 AE\001
4 0 4 0 0 0 20 0.0000 4 255 2400 7336 3241 SS:[Integrated_flow]\001

Added mtt/lib/comp/compound/General/INTF/INTF_desc.tex version [e32749d11c].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system INTF (INTF_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTF} is
   displayed in Figure \Ref{INTF_abg} and its label
   file is listed in Section \Ref{sec:INTF_lbl}.
   The subsystems are listed in Section \Ref{sec:INTF_sub}.

\textbf{INTF} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in].

Added mtt/lib/comp/compound/General/INTF/INTF_lbl.txt version [0fd0a897ef].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system INTF (INTF_lbl.txt)
%SUMMARY	INTF: flow integrator
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow
%ALIAS	out	Integrated_flow

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Added mtt/lib/comp/compound/General/INTFS/INTFS_abg.fig version [5f89579557].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3150 7201 3150 6976 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 4050 450 4050 450 1350 9900 1350 9900 4050
4 2 4 0 0 0 20 0.0000 4 240 1170 1711 3241 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 195 375 3016 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4501 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 195 4501 1891 CS:unit\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5986 3241 AE\001
4 0 4 0 0 0 20 0.0000 4 255 2400 7336 3241 SS:[Integrated_flow]\001

Added mtt/lib/comp/compound/General/INTFS/INTFS_desc.tex version [90ae597362].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system INTF (INTF_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 11:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTFS} is
   displayed in Figure \Ref{INTFS_abg} and its label
   file is listed in Section \Ref{sec:INTFS_lbl}.
   The subsystems are listed in Section \Ref{sec:INTFS_sub}.

\textbf{INTFS} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in]. The single parameter e_0
   is the initial value of the integral.

Added mtt/lib/comp/compound/General/INTFS/INTFS_lbl.txt version [ec296d4ba1].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system INTF (INTF_lbl.txt)
%SUMMARY	INTFS: flow integrator with explicit initial state
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/16 07:35:10  peterg
% %% Aliased version
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow
%ALIAS	out	Integrated_flow

% Argument aliases
%ALIAS	$1	e_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type CS
         unit                   lin             effort,1;e_0

% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Added mtt/lib/comp/compound/General/IS/IS_abg.fig version [308e9156fe].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
2 4 0 2 31 7 52 0 -1 0.000 0 0 7 0 0 5
	 5625 6570 5625 1575 1350 1575 1350 6570 5625 6570
4 1 0 100 0 18 20 0.0000 4 210 240 2475 2295 I:i\001
4 0 0 100 0 18 20 0.0000 4 270 795 4185 4185 Sf:f_0\001
4 1 4 100 0 18 20 0.0000 4 270 900 2475 6030 SS:[in]\001
4 1 0 100 0 18 20 0.0000 4 195 150 2475 4185 0\001

Added mtt/lib/comp/compound/General/IS/IS_abg.fig.bak version [833b9d0b1e].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 0 100 0 18 20 0.0000 4 270 195 2475 4185 0\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
4 1 0 100 0 18 20 0.0000 4 285 315 2475 2295 I:i\001
4 0 0 100 0 18 20 0.0000 4 360 1035 4185 4185 Sf:f_0\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2475 6030 SS:[in]\001

Added mtt/lib/comp/compound/General/IS/IS_lbl.txt version [84a7ba47e4].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system IS (IS_lbl.txt)
%SUMMARY IS I component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:29:11  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	i		lin	flow,i

% Component type SS
	[in]	 SS	external,external

% Component type Sf
	f_0		SS	f_0


Added mtt/lib/comp/compound/General/ISW/ISW_abg.fig version [8d8c607b4f].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2925 2475 1575 2700 1800
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 4770 3600 4770 900 225 900 225 3600 4770 3600
4 1 4 0 0 0 20 0.0000 4 240 810 2475 3240 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 2025 2520 1440 I:MTT_SWITCH\001

Added mtt/lib/comp/compound/General/ISW/ISW_lbl.txt version [edf1b1d098].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY ISW: Switched I component
%DESCRIPTION ISW acts as an I component except when the -s -c option is used.
%DESCRIPTION When the -s -c option is used:
%DESCRIPTION   The component label is used as a variable name (eg Name)
%DESCRIPTION   In the ode simulation:
%DESCRIPTION     Name = 1 implies normal I (closed switch)
%DESCRIPTION     Name = 0 implies state=0 (open switch)
%DESCRIPTION     Name = -1 implies state>0 (Diode)

%ALIAS out	in
%ALIAS $1	lin
%ALIAS $1	flow,i_s



%% Label file for system ISW (ISW_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/26 12:57:00  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/06/03 15:26:09  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	MTT_SWITCH		lin	flow,i_s

% Component type SS
	[in]			SS	external,external

Added mtt/lib/comp/compound/General/IX/IX_abg.fig version [5633b1315d].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2700 4950 2700 4725 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 3375 2475 3600 2250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5850 3825 5850 450 225 450 225 3825 5850 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2475 3150 2475
4 1 -1 0 0 22 20 0.0000 4 225 150 3375 2835 1\001
4 1 -1 0 0 22 20 0.0000 4 240 240 5355 2790 I:i\001
4 2 4 0 0 22 20 0.0000 4 315 870 1665 2790 SS:[in]\001
4 1 4 0 0 22 20 0.0000 4 315 810 3375 990 SS:[X]\001

Added mtt/lib/comp/compound/General/IX/IX_lbl.txt version [03d9d274d2].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY IX   I component with state i/o
#DESCRIPTION Port [X]: state i/o

## Label file for system IX (IX_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.3  2000/08/29 15:26:38  peterg
# ## New SS format
# ##
# ## Revision 1.2  1998/04/14 17:08:50  peterg
# ## Input only on SS
# ##
# ## Revision 1.1  1998/04/12 15:20:11  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type I
	i		$1	$1

# Component type SS
	[in]		SS	internal,external
	[X]		SS	internal,external

Added mtt/lib/comp/compound/General/Lf/Lf_abg.fig version [6356fff31a].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2925 5400 2925 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 7650 2925 7425 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 7875 4500 8100 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4500 3825 3150 4050 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 2700 7875 1350 8100 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 1350 3825 2700 4050 2475
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8550 5175 3150 5175 3150 675 8550 675 8550 5175
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 7650 2700 8100 2700
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 3600 1350 4050 1350
4 1 4 100 0 18 18 0.0000 4 270 825 3825 4950 SS:[n]\001
4 1 4 100 0 18 18 0.0000 4 270 840 7875 4950 SS:[p]\001
4 1 0 100 0 18 18 0.0000 4 195 150 3825 3015 0\001
4 1 0 100 0 18 18 0.0000 4 210 405 5850 3015 AE\001
4 1 0 100 0 18 18 0.0000 4 195 150 7875 3015 1\001
4 1 4 100 0 18 18 0.0000 4 270 1095 7875 1125 SS:[out]\001
4 1 4 100 0 18 18 0.0000 4 270 900 3825 1125 SS:[in]\001

Added mtt/lib/comp/compound/General/Lf/Lf_lbl.txt version [1c8736f4ed].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Lf: loop gain (flow) 
#DESCRIPTION Loop gain transfer function is formed by breaking loop

## System Lf, representation lbl, language txt
## File Lf_lbl.txt
## Generated by MTT on Mon Dec  5 09:38:43 EST 2005

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	n	n
#ALIAS	out	out
#ALIAS	p	p

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type AE (anonymous => default parameters)
	# AE							

## Component type SS
	[in]	SS		external,external		
	[n]	SS		external,external		
	[out]	SS		external,external		
	[p]	SS		external,external		

Added mtt/lib/comp/compound/General/RD/RD_abg.fig version [80fc8a6ca3].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2700 3150 2700 2250 2925 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2925 3375 3825 3375 3600 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2475 3375 2250 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2250 1575 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 225 3375 1125 3375 900 3600
4 1 0 100 0 18 18 0.0000 4 210 510 1350 2115 Df:f\001
4 1 0 100 0 18 18 0.0000 4 210 630 2700 2115 De:e\001
4 0 0 100 0 18 18 0.0000 4 210 405 3960 3465 R:r\001
4 2 4 100 0 18 18 0.0000 4 270 900 135 3465 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 1350 3465 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 2700 3465 0\001

Added mtt/lib/comp/compound/General/RD/RD_lbl.txt version [fef2061d71].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY RD
#DESCRIPTION Detailed description here

## System RD, representation lbl, language txt
## File RD_lbl.txt
## Generated by MTT on Thu Apr 24 10:30:13 EST 2014

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in

## Argument aliases
#ALIAS	$1	flow,r

## cr aliases
#ALIAS	$a1      lin


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type De
	e	SS		external		

## Component type Df
	f	SS		external		

## Component type R
	r	lin		flow,r		

## Component type SS
	[in]	SS		external,external		

Added mtt/lib/comp/compound/General/Se/Se_abg.fig version [e603fdc7c3].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 2475 3150 2925
4 2 0 100 0 18 20 0.0000 4 225 675 1710 2790 SS:u\001
4 0 4 100 0 18 20 0.0000 4 285 1170 3330 2790 SS:[out]\001

Added mtt/lib/comp/compound/General/Se/Se_lbl.txt version [5203896aa0].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Se (Se_lbl.txt)
%SUMMARY Se Simple effort source
%DESCRIPTION Simple effort source constructed from SS with fixed causality


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/03/12 04:04:27  peterg
% %% Single argument - the effort value e_s
% %%
% %% Revision 1.1  1999/03/03 21:55:46  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out|in	out

% Argument aliases
%ALIAS $1	e_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[out]	SS		external,external
	u	SS		e_s,internal

Added mtt/lib/comp/compound/General/Sf/Sf_abg.fig version [94941a3101].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1800 2475 1800 2925
4 2 0 100 0 18 20 0.0000 4 225 675 1710 2790 SS:u\001
4 0 4 100 0 18 20 0.0000 4 285 1170 3330 2790 SS:[out]\001

Added mtt/lib/comp/compound/General/Sf/Sf_lbl.txt version [d53eaa0484].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Sf (Sf_lbl.txt)
%SUMMARY Sf Simple flow source
%DESCRIPTION  Simple flow source constructed from SS with fixed causality

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/03/12 04:03:09  peterg
% %% Single argument - the value of the flow
% %%
% %% Revision 1.1  1999/03/03 21:50:15  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out|in	out

% Argument aliases
%ALIAS	   $1	f_s
%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[out]	SS		external,external
	u	SS		internal,f_s

Added mtt/lib/comp/compound/Mechanical/Mechanical-1D/BernoulliEuler/BernoulliEuler_abg.fig version [cd07ad3054].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2250 3825 2250 3600 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 2250 5400 2250 5175 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 2250 6975 2250 6750 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2025 4050 900 4275 1125
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 2025 6975 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 2475 4950 3150 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4500 3825 4500 3600 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 4500 6975 4500 6750 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 5400 4500 5175 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 3600 4050 4275 4275 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 4275 3825 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 4275 6975 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2025 3825 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 4725 5625 5850 5850 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 6075 6975 6075 6750 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 6075 4275 6075 4500 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 5850 5400 6300
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 675 225 675 6975 9225 6975 9225 225 675 225
4 2 4 100 0 18 20 0.0000 4 360 1605 2655 4590 SS:[a_in]\001
4 1 0 100 0 18 20 0.0000 4 270 195 4050 2340 1\001
4 1 0 100 0 18 20 0.0000 4 270 195 5625 2340 0\001
4 1 0 100 0 18 20 0.0000 4 285 750 4050 765 I:dm\001
4 0 4 100 0 18 20 0.0000 4 360 1860 7110 2340 SS:[y_out]\001
4 2 4 100 0 18 20 0.0000 4 360 1620 2565 2340 SS:[y_in]\001
4 0 4 100 0 18 20 0.0000 4 360 1845 7065 4590 SS:[a_out]\001
4 1 0 100 0 18 20 0.0000 4 270 195 4050 4590 1\001
4 1 0 100 0 18 20 0.0000 4 270 195 5625 4590 0\001
4 1 0 100 0 18 20 0.0000 4 285 975 4815 3510 TF:dz\001
4 1 1 101 0 32 20 0.0000 4 255 270 4635 4095 W\001
4 1 1 101 0 32 20 0.0000 4 255 945 6345 4950 W+DW\001
4 1 1 101 0 32 20 0.0000 4 255 270 4680 4950 W\001
4 1 1 101 0 32 20 0.0000 4 255 270 3150 4950 W\001
4 1 1 101 0 18 20 0.0000 4 210 210 3150 2610 v\001
4 1 1 101 0 18 20 0.0000 4 210 210 4725 2610 v\001
4 1 1 101 0 18 20 0.0000 4 210 825 6255 2610 v+  v\001
4 1 1 101 0 32 20 0.0000 4 255 225 6390 2610 D\001
4 1 1 101 0 32 20 0.0000 4 255 225 5400 3015 D\001
4 1 1 101 0 18 20 0.0000 4 210 210 5625 3015 v\001
4 1 0 100 0 18 20 0.0000 4 270 195 5625 6210 1\001
4 1 0 100 0 18 20 0.0000 4 285 810 7425 6165 C:dk\001
4 1 0 100 0 18 20 0.0000 4 285 735 3915 6165 R:dr\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-1D/BernoulliEuler/BernoulliEuler_desc.tex version [3b42829dc1].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system BernoulliEuler (BernoulliEuler_desc.tex)
% Generated by MTT on Mon Apr 19 06:43:36 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{BernoulliEuler} is
   displayed in Figure \Ref{fig:BernoulliEuler_abg.ps} and its label
   file is listed in Section \Ref{sec:BernoulliEuler_lbl}.
   The subsystems are listed in Section \Ref{sec:BernoulliEuler_sub}.

This component represents one lump of a lumped model of a uniform beam
modelled using the the Bernoulli-Euler assumptions:
\begin{enumerate}
\item The shear forces can be neglected.
\item Rotational inertia can be neglected.
\end{enumerate}

\begin{itemize}
\item The \textbf{I} component represents the inertial properties of
  the lump in the perpendicular direction. In particular the velocity
  of the lump $v$ is:
  \begin{equation}
    \dot v = \frac{\Delta f}{\Delta m}
  \end{equation}
  where $\Delta m$ is the lump mass and $\Delta f$ is the net vertical
  force.
\item The \textbf{C} component represents the angular stiffness of the
  lump. In particular the torque acting on the lump is:
  \begin{equation}
    \dot \tau =  \Delta k \Delta \Omega
  \end{equation}
  where $\Delta k$ is the lump (angular) stiffness and $\Delta \Omega$
  is the net angular velocity.
\item The \textbf{TF} component represents the relation between the
  angular domains
  \begin{equation}
    \begin{align}
      \tau &= \Delta x \Delta f \\
      \Delta v &= \Delta x \Omega 
    \end{align}
  \end{equation}
\end{itemize}

Added mtt/lib/comp/compound/Mechanical/Mechanical-1D/BernoulliEuler/BernoulliEuler_lbl.txt version [feefcf8c9f].


































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system BernoulliEuler (BernoulliEuler_lbl.txt)
%SUMMARY BernoulliEuler
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1999/10/13 07:01:58  peterg
% %% Added aliases:
% %% 	a_in	theta_in
% %% 	a_out	theta_out
% %%
% %% Revision 1.3  1999/09/02 03:07:16  peterg
% %% r_d --> dr
% %%
% %% Revision 1.2  1999/05/17 21:27:05  peterg
% %% Added damping
% %%
% %% Revision 1.1  1999/05/16 07:12:40  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	theta_in        a_in
%ALIAS	theta_out	a_out
%ALIAS	in	y_in,a_in
%ALIAS	out	y_out,a_out

% Argument aliases
%ALIAS	$1	dk
%ALIAS	$2	dm
%ALIAS	$3	dz
%ALIAS	$4	dr

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	dm		lin	flow,dm

% Component type C
	dk		lin	state,dk

% Component type R
	dr		lin	flow,dr

% Component type SS
	[y_in]	SS			external,external
	[y_out]	SS			external,external
	[a_in]	SS			external,external
	[a_out]	SS			external,external

% Component type TF
	dz		lin	effort,dz



Added mtt/lib/comp/compound/Mechanical/Mechanical-1D/pBernoulliEuler/pBernoulliEuler_abg.fig version [46ea19b5b6].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2250 3825 2250 3600 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 2250 5400 2250 5175 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 2250 6975 2250 6750 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2025 4050 900 4275 1125
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 2025 6975 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 2475 4950 3150 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4500 3825 4500 3600 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 4500 6975 4500 6750 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 5400 4500 5175 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 4725 5625 5850 5850 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 3600 4050 4275 4275 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 4275 3825 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 4275 6975 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2025 3825 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 6075 5400 6075 5175 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 6075 6975 6075 6750 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 6300 5625 7425 5850 7200
4 2 4 100 0 18 20 0.0000 4 285 1860 2655 4590 SS:[theta_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 2340 1\001
4 1 0 100 0 18 20 0.0000 4 210 165 5625 2340 0\001
4 1 0 100 0 18 20 0.0000 4 225 645 4050 765 I:dm\001
4 0 4 100 0 18 20 0.0000 4 285 1500 7110 2340 SS:[y_out]\001
4 2 4 100 0 18 20 0.0000 4 285 1305 2565 2340 SS:[y_in]\001
4 0 4 100 0 18 20 0.0000 4 285 2055 7065 4590 SS:[theta_out]\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 4590 1\001
4 1 0 100 0 18 20 0.0000 4 210 165 5625 4590 0\001
4 1 0 100 0 18 20 0.0000 4 225 795 4815 3510 TF:dz\001
4 1 1 101 0 32 20 0.0000 4 210 225 4635 4095 W\001
4 1 1 101 0 32 20 0.0000 4 210 795 6345 4950 W+DW\001
4 1 1 101 0 32 20 0.0000 4 210 225 4680 4950 W\001
4 1 1 101 0 32 20 0.0000 4 210 225 3150 4950 W\001
4 1 1 101 0 18 20 0.0000 4 165 165 3150 2610 v\001
4 1 1 101 0 18 20 0.0000 4 165 165 4725 2610 v\001
4 1 1 101 0 18 20 0.0000 4 165 690 6255 2610 v+  v\001
4 1 1 101 0 32 20 0.0000 4 210 180 6390 2610 D\001
4 1 1 101 0 32 20 0.0000 4 210 180 5400 3015 D\001
4 1 1 101 0 18 20 0.0000 4 165 165 5625 3015 v\001
4 1 0 100 0 18 20 0.0000 4 210 165 5625 6165 1\001
4 1 0 100 0 18 20 0.0000 4 225 660 7380 6165 C:dk\001
4 2 4 100 0 18 20 0.0000 4 300 1500 4230 6165 SS:[patch]\001
4 1 0 100 0 18 20 0.0000 4 285 780 5625 7785 R:dr\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-1D/pBernoulliEuler/pBernoulliEuler_desc.tex version [57ba85e4c4].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system pBernoulliEuler (pBernoulliEuler_desc.tex)
% Generated by MTT on Mon Apr 19 06:43:36 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{pBernoulliEuler} is
   displayed in Figure \Ref{fig:pBernoulliEuler_abg.ps} and its label
   file is listed in Section \Ref{sec:pBernoulliEuler_lbl}.
   The subsystems are listed in Section \Ref{sec:pBernoulliEuler_sub}.

This is identical to component  \textbf{pBernoulliEuler} except that a
\emph{piezoelectric patch} is included. This provides:
\begin{enumerate}
\item an moment-generating \emph{actuator} and
\item a curvature \emph{sensor}.
\end{enumerate}

Added mtt/lib/comp/compound/Mechanical/Mechanical-1D/pBernoulliEuler/pBernoulliEuler_lbl.txt version [41b616876c].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system pBernoulliEuler (pBernoulliEuler_lbl.txt)
%SUMMARY pBernoulliEuler
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/05/17 21:27:39  peterg
% %% Added damping
% %%
% %% Revision 1.2  1999/05/16 21:31:48  peterg
% %% Renamed SS to patch
% %%
% %% Revision 1.1  1999/05/16 21:08:13  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in		y_in,theta_in
%ALIAS	out		y_out,theta_out
%ALIAS	torque		patch
%ALIAS	curvature	patch


% Argument aliases
%ALIAS	$1	dk
%ALIAS	$2	dm
%ALIAS	$3	dz
%ALIAS	$4	dr

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	dm		lin	flow,dm

% Component type C
	dk		lin	state,dk

% Component type R
	dr		lin	flow,dr

% Component type SS
	[y_in]		SS		external,external
	[y_out]		SS		external,external
	[theta_in]	SS		external,external
	[theta_out]	SS		external,external
	[patch]		SS		external,external

% Component type TF
	dz		lin	effort,dz

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ACCEL/ACCEL_abg.fig version [dd7f638975].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2252 3377 2252 3152 2477
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3827 2252 5177 2252 4952 2477
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 2026 3601 676 3826 901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2250 7200 2250 6975 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3375 2025 3375 2475
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 3375 9450 45 225 45 225 3375 9450 3375
4 1 -1 0 0 0 20 0.0000 4 195 135 3602 2387 1\001
4 1 -1 0 0 0 20 0.0000 4 195 90 3601 541 I\001
4 1 -1 0 0 0 20 0.0000 4 195 375 5535 2340 AF\001
4 1 24 0 0 0 20 0.0000 4 195 1050 1440 2340 SS:Force\001
4 0 24 0 0 0 20 0.0000 4 240 2040 7290 2340 SS:[Acceleration]\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ACCEL/ACCEL_lbl.txt version [b37dd224aa].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY ACCEL: Provides a acceleration (useful for simulating gravity. 
%DESCRIPTION Useful for simulating gravity as explaned in Section 10.9
%DESCRIPTION of "Metamodelling".

%ALIAS in|out	Acceleration

%% Label file for system ACCEL (ACCEL_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/27 06:50:41  peterg
% %% *** empty log message ***
% %%
% %% Revision 1.2  1998/07/27 06:49:57  peterg
% %% Added blank line at end
% %%
% %% Revision 1.1  1998/07/27 06:47:32  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% SS components
	Force		SS	external,internal
	[Acceleration]	SS	external,external

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROD/ROD_abg.fig version [d3f04d99de].


























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 2700 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 2700 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROD/ROD_desc.tex version [740b974979].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROD/ROD_lbl.txt version [15096289b5].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	See Section 10.2 of "Metamodelling"

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a	xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a	yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b	xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b	yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/RODa/RODa_abg.fig version [c92944a808].





























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 1800 3375 1800 3600
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 4 0 0 0 20 0.0000 4 255 1215 1756 3286 SS:[alpha]\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/RODa/RODa_desc.tex version [7d0c260ed2].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system RODa (RODa_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{RODa} is
   displayed in Figure \Ref{RODa_abg} and its label
   file is listed in Section \Ref{sec:RODa_lbl}.
   The subsystems are listed in Section \Ref{sec:RODa_sub}.

{\bf RODa} is essentially as described in Figure 10.2 of
``Metamodelling''. It has an additional port ``[angle]'' to provide
access to the rod angle.

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/RODa/RODa_lbl.txt version [b8547d981b].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	RODa: rigid rod in two dimensions - angle port.
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION	Port [alpha]:	rod angle
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system RODa (RODa_lbl.txt)




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2



	

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROT2/ROT2_abg.fig version [c633f9abaa].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4905 4500 5805 4275 5805
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 7379 4501 6479 4276 6479
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 7604 2926 7604 2701 7829
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 7604 4501 7604 4276 7829
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 6030 4950 4905 4950 5130
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4950 7155
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 6255 4950 7425 4950 7155
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 4680 2925 4680 2700 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 6165 2925 6165 2700 6390
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4680 4500 4680 4275 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5895 4680 7020 4680 6795 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 6255 7200 4905 7200 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 5805 7200 7380 7200 7155
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 7605 6975 7605 6750 7830
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 4680 8550 4680 8325 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 7605 8550 7605 8325 7830
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 6030 4950 6030 4815 5895
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 6255 4950 6255 4815 6390
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2554 3028 1317 885
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2554 3028 4698 1791
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2566 3016 2566 541
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2566 3016 5041 3016
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 8550 9675 225 225 225 225 8550 9675 8550
4 0 1 1 0 0 20 0.0000 4 135 135 5220 3105 x\001
4 0 1 1 0 0 20 0.0000 4 195 135 2700 585 y\001
4 0 1 1 0 0 20 0.0000 4 195 210 1485 855 Y\001
4 0 1 1 0 0 20 0.0000 4 195 210 4590 1710 X\001
4 0 1 1 0 32 20 0.0000 4 195 150 3420 2880 q\001
4 0 -1 0 0 2 20 0.0000 4 195 135 3060 4770 1\001
4 0 -1 0 0 2 20 0.0000 4 195 135 3060 7695 1\001
4 0 -1 0 0 2 20 0.0000 4 195 135 3015 6255 0\001
4 1 4 0 0 2 16 0.0000 4 210 390 4635 4455 [in]\001
4 1 4 0 0 2 16 0.0000 4 210 390 4635 7965 [in]\001
4 0 -1 0 0 2 20 0.0000 4 195 135 7155 4770 0\001
4 0 -1 0 0 2 20 0.0000 4 195 135 7110 7740 0\001
4 1 -1 0 0 2 20 0.0000 4 195 1260 5175 4770 EMTF:xX\001
4 1 -1 0 0 2 20 0.0000 4 195 1260 5175 5850 EMTF:xY\001
4 1 -1 0 0 2 20 0.0000 4 255 1260 5220 6615 EMTF:yX\001
4 1 -1 0 0 2 20 0.0000 4 255 1260 5175 7695 EMTF:yY\001
4 1 4 0 0 2 16 0.0000 4 210 525 5760 4455 [out]\001
4 1 4 0 0 2 16 0.0000 4 210 525 5760 7965 [out]\001
4 1 4 0 0 2 16 0.0000 4 210 390 4635 6795 [in]\001
4 1 4 0 0 2 16 0.0000 4 210 390 4545 5625 [in]\001
4 1 4 0 0 2 16 0.0000 4 210 525 5940 5625 [out]\001
4 1 4 0 0 2 16 0.0000 4 210 525 5985 6795 [out]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5040 7335 [mod]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5085 6075 [mod]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5085 6300 [mod]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5040 5040 [mod]\001
4 2 4 0 0 2 20 0.0000 4 240 1215 1710 6255 SS:[theta]\001
4 2 4 0 0 2 20 0.0000 4 240 795 1665 4770 SS:[X]\001
4 2 4 0 0 2 20 0.0000 4 240 795 1710 7695 SS:[Y]\001
4 0 4 0 0 2 20 0.0000 4 240 720 8640 4770 SS:[x]\001
4 0 4 0 0 2 20 0.0000 4 255 720 8685 7695 SS:[y]\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROT2/ROT2_desc.tex version [0a474d35c1].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system ROT2 (ROT2_desc.tex)
% Generated by MTT on Fri Aug 15 21:09:17 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROT2} is
   displayed in Figure \Ref{ROT2_abg} and its label
   file is listed in Section \Ref{sec:ROT2_lbl}.
   The subsystems are listed in Section \Ref{sec:ROT2_sub}.

\textbf{ROT2} implements a 2D rotational {\em transformation\/} in
terms of a set of {\em transformers}. A flow expressed in the $XY$
coordinates of Figure \Ref{ROT2_abg} is transformed by \textbf{ROT2}
into the coordinates of $xy$. The corresponding (energy conserving)
effort transformation is implied by \textbf{ROT2}.

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROT2/ROT2_lbl.txt version [46532336fd].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY ROT2: 2D rotational transformer
%DESCRIPTION {ROT2} implements a 2D rotational transformation in terms
%DESCRIPTION of a set of transformers. A flow expressed in the X-Y
%DESCRIPTION coordinates is transformed by ROT2 into the coordinates
%DESCRIPTION of x-y. The corresponding (energy conserving) effort
%DESCRIPTION transformation is implied.
%DESCRIPTION Ports X and Y correspond to the old coordinate system
%DESCRIPTION Ports x and y correspond to the new coordinate system
%DESCRIPTION Port theta is the angle of XY with respect to xy.

%% Label file for system ROT2 (ROT2_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type EMTF
	xX		lcos	flow,1
	xY		lsin	flow,1
	yX		lsin	flow,-1
	yY		lcos	flow,1

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/ROD_desc.tex version [740b974979].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/ROD_lbl.txt version [15096289b5].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	See Section 10.2 of "Metamodelling"

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a	xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a	yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b	xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b	yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/gROD_abg.fig version [923d9d522e].































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9225 6075 8955 6075
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 270 1485 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1500 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1485 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1500 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 2250 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 2265 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000000 4 270 810 9360 6345 SS:mg\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/gROD_desc.tex version [eeabba39d0].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system gROD (gROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{gROD} is
   displayed in Figure \Ref{gROD_abg} and its label
   file is listed in Section \Ref{sec:gROD_lbl}.
   The subsystems are listed in Section \Ref{sec:gROD_sub}.

{\bf gROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/gROD_lbl.txt version [f6f0b2a4c3].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	gROD: rigid rod in two dimensions - with gravity
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system gROD (gROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	mg			SS		m*g,internal
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/ROD_desc.tex version [740b974979].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/ROD_lbl.txt version [15096289b5].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	See Section 10.2 of "Metamodelling"

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a	xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a	yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b	xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b	yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gROD_lbl.txt version [f6f0b2a4c3].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	gROD: rigid rod in two dimensions - with gravity
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system gROD (gROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	mg			SS		m*g,internal
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_abg.fig version [38a3b778aa].






































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9225 6075 8955 6075
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 5175 2025 3825 2250 3825
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 2130 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 2130 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000 4 255 720 9360 6345 Se:mg\001
4 2 4 0 0 0 20 0.0000 4 255 1200 1935 3735 SS:[angle]\001

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_desc.tex version [02934dec4e].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system gRODa (gRODa_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{gRODa} is
   displayed in Figure \Ref{gRODa_abg} and its label
   file is listed in Section \Ref{sec:gRODa_lbl}.
   The subsystems are listed in Section \Ref{sec:gRODa_sub}.

{\bf gRODa} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_lbl.txt version [66ade3ce45].



































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	gRODa: rigid rod in two dimensions - with gravity and angle port
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS angle|a		angle	# Angle port

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system gRODa (gRODa_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/08/05 08:04:40  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/11/30 10:47:53  peterg
% %% Added extra a_a and a_b aliases
% %%
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b


% Component type Se
	mg			SS		m*g


	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external
	[angle]			SS		external,external


	

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_abg.fig version [ae5896bc2b].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 1800 3825 1800 3600 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5400 6300 5400 6075 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 9000 3825 9000 3600 9225
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 1800 6975 1800 6750 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 5625 4725 6975 4950 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 7425 4725 8775 4950 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 9000 6975 9000 6750 9225
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 1575 3825 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 1575 6975 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 5175 4500 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 8775 3825 9225
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 8775 6975 9225
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8550 9450 1350 9450 1350 1125 8550 1125 8550 9450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5175 5905 4220 5905 4539
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 3375 4725 2025 4950 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 5175 4725 3825 4950 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 5400 3150 5400 3375 5625
4 1 4 100 0 18 18 0.0000 4 270 1110 1935 1890 SS:[F_1]\001
4 1 0 100 0 18 18 0.0000 4 270 1710 4770 1890 Muscle1:m_1\001
4 1 0 100 0 18 18 0.0000 4 270 840 4770 3690 TF:r_1\001
4 1 0 100 0 18 18 0.0000 4 210 390 6615 5490 I:m\001
4 1 0 100 0 18 18 0.0000 4 270 840 4815 7290 TF:r_2\001
4 1 0 100 0 18 18 0.0000 4 270 1710 4725 9090 Muscle1:m_2\001
4 1 0 100 0 18 18 0.0000 4 270 840 2610 5490 Se:mg\001
4 1 4 100 0 18 14 0.0000 4 210 285 3510 8775 [F]\001
4 1 4 100 0 18 14 0.0000 4 210 285 3510 1530 [F]\001
4 1 0 100 0 18 18 0.0000 4 270 900 7515 1890 De:x_1\001
4 1 0 100 0 18 18 0.0000 4 270 900 7515 9090 De:x_2\001
4 1 0 100 0 18 18 0.0000 4 195 150 4725 5490 1\001
4 1 0 100 0 18 18 0.0000 4 270 915 6075 4140 Df:v_m\001
4 1 4 100 0 18 18 0.0000 4 270 1110 1890 9045 SS:[F_2]\001

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_desc.tex version [1bc6190828].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system LowerLeg1 (LowerLeg1_desc.tex)
% Generated by MTT on Thu Apr 19 10:39:20 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{LowerLeg1_pic}
    {LowerLeg1_pic}
    {0.9}
    {Simple lower-leg model}
   
    A schematic of a simple muscle model with skeleton appears in
    Figure \Ref{fig:LowerLeg1_pic} and the acausal bond graph is
    displayed in Figure \Ref{fig:LowerLeg1_abg.ps} and its label file
    is listed in Section \Ref{sec:LowerLeg1_lbl.txt}.  The subsystems
    are listed in Section \Ref{sec:LowerLeg1_sub}.  The model is a
    rough approximation of the lower leg, knee joint and thigh muscles
    with the lower leg horizontal.

    The components are:
    \begin{description}
    \item[F\_1 and F\_2] the force inputs to the upper and lower muscles
    \item[m\_1 and m\_2] the upper and lower muscles
    \item[r\_1 and r\_2] the transformers reflecting the geometry of the
      muscle attachments
    \item[m] load mass
    \item[mg] force due to gravity.
    \end{description}

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_input.txt version [2ccecdb207].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System LowerLeg1, representation input, language txt; 
## File Example2_input.txt; 
## Generated by MTT on Mon Apr 30 10:08:54 BST 2001; 

example2_f_1	= 1.0*((t>2.0)&&(t<4.0)); # On for 2<t<4
example2_f_2	= 1.0*((t>6.0)&&(t<8.0)); # On for 6<t<8

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_lbl.txt version [f4355e21a6].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system LowerLeg1 (LowerLeg1_lbl.txt)
%SUMMARY LowerLeg1: Simple model of lower leg
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type De
	x_1	SS		external
	x_2	SS		external

% Component type Df
	v_m	SS		external

% Component type I
	m	lin		flow,m

% Component type Muscle1
	m_1	lin	        c_1;d_1		
	m_2	lin	        c_2;d_2					

% Component type Se
	mg	SS		m*g

	[F_1]	SS		external,internal
	[F_2]	SS		external,internal

% Component type TF
	r_1	lin		flow,r_1
	r_2	lin		flow,-r_2

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_numpar.txt version [a16fa9b957].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System LowerLeg1, representation numpar, language txt; 
## File Example2_numpar.txt; 
## Generated by MTT on Mon Apr 30 10:18:55 BST 2001; 



c_1	= 1.0; # Default
c_2	= 1.0; # Default
d_1	= 1.0; # Default
d_2	= 1.0; # Default
g	= 0.0; #9.81; # Gravity
m	= 1.0; # kg
r_1	= 1.0; # Default
r_2	= 1.0; # Default

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_pic.fig version [3da360fbf9].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
5 1 0 2 0 7 50 0 -1 0.000 0 1 0 0 1800.000 -821.000 1125 1665 1800 1755 2475 1665
5 1 0 2 0 7 50 0 -1 0.000 0 0 0 0 1800.000 4151.000 1125 1665 1800 1575 2475 1665
5 1 0 2 0 7 50 0 -1 0.000 0 1 0 0 1800.000 349.000 1125 2835 1800 2925 2475 2835
5 1 0 2 0 7 50 0 -1 0.000 0 0 0 0 1800.000 5321.000 1125 2835 1800 2745 2475 2835
1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2700 2250 127 127 2700 2250 2827 2250
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 2475 2025 5625 2025 5625 2475 2475 2475 2475 2025
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 2475 1575 2700 1575 2700 2025 2475 2025 2475 1575
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 2475 2475 2700 2475 2700 2925 2475 2925 2475 2475
2 2 0 1 0 7 50 0 48 0.000 0 0 -1 0 0 5
	 675 1125 1125 1125 1125 3375 675 3375 675 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 2700 2250 3780 3330
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 1800 1575 2250 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 1800 2700 3375 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 4050 1980 4905 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 5872 1777 6524 1125
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6975 3825 450 3825 450 675 6975 675 6975 3825
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 5625 1890 6345 1890 6345 2565 5625 2565 5625 1890
4 1 1 50 0 3 20 0.0000 4 210 585 3825 3645 Pivot\001
4 1 1 50 0 3 20 0.0000 4 210 1035 2250 1080 Muscle 1\001
4 1 1 50 0 3 20 0.0000 4 210 1035 3555 1080 Muscle 2\001
4 1 1 50 0 3 20 0.0000 4 195 630 4905 1080 Bone\001
4 1 1 50 0 3 20 0.0000 4 210 600 6480 1080 Load\001
4 0 0 50 0 0 25 0.0000 4 180 300 5850 2295 m\001

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_pic.pdf version [b134547418].

cannot compute difference between binary files

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_pic.ps version [d6ea18cba3].












































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%!PS-Adobe-2.0 EPSF-2.0
%%Title: LowerLeg1_pic.eps
%%Creator: fig2dev Version 3.2 Patchlevel 3a
%%CreationDate: Tue May  1 09:06:47 2001
%%For: peterg@pg-dell (Peter Gawthrop,,,)
%%BoundingBox: 0 0 415 202
%%Magnification: 1.0000
%%EndComments
/MyAppDict 100 dict dup begin def
/$F2psDict 200 dict def
$F2psDict begin
$F2psDict /mtrx matrix put
/col-1 {0 setgray} bind def
/col0 {0.000 0.000 0.000 srgb} bind def
/col1 {0.000 0.000 1.000 srgb} bind def
/col2 {0.000 1.000 0.000 srgb} bind def
/col3 {0.000 1.000 1.000 srgb} bind def
/col4 {1.000 0.000 0.000 srgb} bind def
/col5 {1.000 0.000 1.000 srgb} bind def
/col6 {1.000 1.000 0.000 srgb} bind def
/col7 {1.000 1.000 1.000 srgb} bind def
/col8 {0.000 0.000 0.560 srgb} bind def
/col9 {0.000 0.000 0.690 srgb} bind def
/col10 {0.000 0.000 0.820 srgb} bind def
/col11 {0.530 0.810 1.000 srgb} bind def
/col12 {0.000 0.560 0.000 srgb} bind def
/col13 {0.000 0.690 0.000 srgb} bind def
/col14 {0.000 0.820 0.000 srgb} bind def
/col15 {0.000 0.560 0.560 srgb} bind def
/col16 {0.000 0.690 0.690 srgb} bind def
/col17 {0.000 0.820 0.820 srgb} bind def
/col18 {0.560 0.000 0.000 srgb} bind def
/col19 {0.690 0.000 0.000 srgb} bind def
/col20 {0.820 0.000 0.000 srgb} bind def
/col21 {0.560 0.000 0.560 srgb} bind def
/col22 {0.690 0.000 0.690 srgb} bind def
/col23 {0.820 0.000 0.820 srgb} bind def
/col24 {0.500 0.190 0.000 srgb} bind def
/col25 {0.630 0.250 0.000 srgb} bind def
/col26 {0.750 0.380 0.000 srgb} bind def
/col27 {1.000 0.500 0.500 srgb} bind def
/col28 {1.000 0.630 0.630 srgb} bind def
/col29 {1.000 0.750 0.750 srgb} bind def
/col30 {1.000 0.880 0.880 srgb} bind def
/col31 {1.000 0.840 0.000 srgb} bind def

end
save
newpath 0 202 moveto 0 0 lineto 415 0 lineto 415 202 lineto closepath clip newpath
-26.0 243.0 translate
1 -1 scale

% This junk string is used by the show operators
/PATsstr 1 string def
/PATawidthshow { 	% cx cy cchar rx ry string
  % Loop over each character in the string
  {  % cx cy cchar rx ry char
    % Show the character
    dup				% cx cy cchar rx ry char char
    PATsstr dup 0 4 -1 roll put	% cx cy cchar rx ry char (char)
    false charpath		% cx cy cchar rx ry char
    /clip load PATdraw
    % Move past the character (charpath modified the
    % current point)
    currentpoint			% cx cy cchar rx ry char x y
    newpath
    moveto			% cx cy cchar rx ry char
    % Reposition by cx,cy if the character in the string is cchar
    3 index eq {			% cx cy cchar rx ry
      4 index 4 index rmoveto
    } if
    % Reposition all characters by rx ry
    2 copy rmoveto		% cx cy cchar rx ry
  } forall
  pop pop pop pop pop		% -
  currentpoint
  newpath
  moveto
} bind def
/PATcg {
  7 dict dup begin
    /lw currentlinewidth def
    /lc currentlinecap def
    /lj currentlinejoin def
    /ml currentmiterlimit def
    /ds [ currentdash ] def
    /cc [ currentrgbcolor ] def
    /cm matrix currentmatrix def
  end
} bind def
% PATdraw - calculates the boundaries of the object and
% fills it with the current pattern
/PATdraw {			% proc
  save exch
    PATpcalc			% proc nw nh px py
    5 -1 roll exec		% nw nh px py
    newpath
    PATfill			% -
  restore
} bind def
% PATfill - performs the tiling for the shape
/PATfill { % nw nh px py PATfill -
  PATDict /CurrentPattern get dup begin
    setfont
    % Set the coordinate system to Pattern Space
    PatternGState PATsg
    % Set the color for uncolored pattezns
    PaintType 2 eq { PATDict /PColor get PATsc } if
    % Create the string for showing
    3 index string		% nw nh px py str
    % Loop for each of the pattern sources
    0 1 Multi 1 sub {		% nw nh px py str source
	% Move to the starting location
	3 index 3 index		% nw nh px py str source px py
	moveto			% nw nh px py str source
	% For multiple sources, set the appropriate color
	Multi 1 ne { dup PC exch get PATsc } if
	% Set the appropriate string for the source
	0 1 7 index 1 sub { 2 index exch 2 index put } for pop
	% Loop over the number of vertical cells
	3 index 		% nw nh px py str nh
	{			% nw nh px py str
	  currentpoint		% nw nh px py str cx cy
	  2 index show		% nw nh px py str cx cy
	  YStep add moveto	% nw nh px py str
	} repeat		% nw nh px py str
    } for
    5 { pop } repeat
  end
} bind def

% PATkshow - kshow with the current pattezn
/PATkshow {			% proc string
  exch bind			% string proc
  1 index 0 get			% string proc char
  % Loop over all but the last character in the string
  0 1 4 index length 2 sub {
				% string proc char idx
    % Find the n+1th character in the string
    3 index exch 1 add get	% string proe char char+1
    exch 2 copy			% strinq proc char+1 char char+1 char
    % Now show the nth character
    PATsstr dup 0 4 -1 roll put	% string proc chr+1 chr chr+1 (chr)
    false charpath		% string proc char+1 char char+1
    /clip load PATdraw
    % Move past the character (charpath modified the current point)
    currentpoint newpath moveto
    % Execute the user proc (should consume char and char+1)
    mark 3 1 roll		% string proc char+1 mark char char+1
    4 index exec		% string proc char+1 mark...
    cleartomark			% string proc char+1
  } for
  % Now display the last character
  PATsstr dup 0 4 -1 roll put	% string proc (char+1)
  false charpath		% string proc
  /clip load PATdraw
  neewath
  pop pop			% -
} bind def
% PATmp - the makepattern equivalent
/PATmp {			% patdict patmtx PATmp patinstance
  exch dup length 7 add		% We will add 6 new entries plus 1 FID
  dict copy			% Create a new dictionary
  begin
    % Matrix to install when painting the pattern
    TilingType PATtcalc
    /PatternGState PATcg def
    PatternGState /cm 3 -1 roll put
    % Check for multi pattern sources (Level 1 fast color patterns)
    currentdict /Multi known not { /Multi 1 def } if
    % Font dictionary definitions
    /FontType 3 def
    % Create a dummy encoding vector
    /Encoding 256 array def
    3 string 0 1 255 {
      Encoding exch dup 3 index cvs cvn put } for pop
    /FontMatrix matrix def
    /FontBBox BBox def
    /BuildChar {
	mark 3 1 roll		% mark dict char
	exch begin
	Multi 1 ne {PaintData exch get}{pop} ifelse  % mark [paintdata]
	  PaintType 2 eq Multi 1 ne or
	  { XStep 0 FontBBox aload pop setcachedevice }
	  { XStep 0 setcharwidth } ifelse
	  currentdict		% mark [paintdata] dict
	  /PaintProc load	% mark [paintdata] dict paintproc
	end
	gsave
	  false PATredef exec true PATredef
	grestore
	cleartomark		% -
    } bind def
    currentdict
  end				% newdict
  /foo exch			% /foo newlict
  definefont			% newfont
} bind def
% PATpcalc - calculates the starting point and width/height
% of the tile fill for the shape
/PATpcalc {	% - PATpcalc nw nh px py
  PATDict /CurrentPattern get begin
    gsave
	% Set up the coordinate system to Pattern Space
	% and lock down pattern
	PatternGState /cm get setmatrix
	BBox aload pop pop pop translate
	% Determine the bounding box of the shape
	pathbbox			% llx lly urx ury
    grestore
    % Determine (nw, nh) the # of cells to paint width and height
    PatHeight div ceiling		% llx lly urx qh
    4 1 roll				% qh llx lly urx
    PatWidth div ceiling		% qh llx lly qw
    4 1 roll				% qw qh llx lly
    PatHeight div floor			% qw qh llx ph
    4 1 roll				% ph qw qh llx
    PatWidth div floor			% ph qw qh pw
    4 1 roll				% pw ph qw qh
    2 index sub cvi abs			% pw ph qs qh-ph
    exch 3 index sub cvi abs exch	% pw ph nw=qw-pw nh=qh-ph
    % Determine the starting point of the pattern fill
    %(px, py)
    4 2 roll				% nw nh pw ph
    PatHeight mul			% nw nh pw py
    exch				% nw nh py pw
    PatWidth mul exch			% nw nh px py
  end
} bind def

% Save the original routines so that we can use them later on
/oldfill	/fill load def
/oldeofill	/eofill load def
/oldstroke	/stroke load def
/oldshow	/show load def
/oldashow	/ashow load def
/oldwidthshow	/widthshow load def
/oldawidthshow	/awidthshow load def
/oldkshow	/kshow load def

% These defs are necessary so that subsequent procs don't bind in
% the originals
/fill	   { oldfill } bind def
/eofill	   { oldeofill } bind def
/stroke	   { oldstroke } bind def
/show	   { oldshow } bind def
/ashow	   { oldashow } bind def
/widthshow { oldwidthshow } bind def
/awidthshow { oldawidthshow } bind def
/kshow 	   { oldkshow } bind def
/PATredef {
  MyAppDict begin
    {
    /fill { /clip load PATdraw newpath } bind def
    /eofill { /eoclip load PATdraw newpath } bind def
    /stroke { PATstroke } bind def
    /show { 0 0 null 0 0 6 -1 roll PATawidthshow } bind def
    /ashow { 0 0 null 6 3 roll PATawidthshow }
    bind def
    /widthshow { 0 0 3 -1 roll PATawidthshow }
    bind def
    /awidthshow { PATawidthshow } bind def
    /kshow { PATkshow } bind def
  } {
    /fill   { oldfill } bind def
    /eofill { oldeofill } bind def
    /stroke { oldstroke } bind def
    /show   { oldshow } bind def
    /ashow  { oldashow } bind def
    /widthshow { oldwidthshow } bind def
    /awidthshow { oldawidthshow } bind def
    /kshow  { oldkshow } bind def
    } ifelse
  end
} bind def
false PATredef
% Conditionally define setcmykcolor if not available
/setcmykcolor where { pop } {
  /setcmykcolor {
    1 sub 4 1 roll
    3 {
	3 index add neg dup 0 lt { pop 0 } if 3 1 roll
    } repeat
    setrgbcolor - pop
  } bind def
} ifelse
/PATsc {		% colorarray
  aload length		% c1 ... cn length
    dup 1 eq { pop setgray } { 3 eq { setrgbcolor } { setcmykcolor
  } ifelse } ifelse
} bind def
/PATsg {		% dict
  begin
    lw setlinewidth
    lc setlinecap
    lj setlinejoin
    ml setmiterlimit
    ds aload pop setdash
    cc aload pop setrgbcolor
    cm setmatrix
  end
} bind def

/PATDict 3 dict def
/PATsp {
  true PATredef
  PATDict begin
    /CurrentPattern exch def
    % If it's an uncolored pattern, save the color
    CurrentPattern /PaintType get 2 eq {
      /PColor exch def
    } if
    /CColor [ currentrgbcolor ] def
  end
} bind def
% PATstroke - stroke with the current pattern
/PATstroke {
  countdictstack
  save
  mark
  {
    currentpoint strokepath moveto
    PATpcalc				% proc nw nh px py
    clip newpath PATfill
    } stopped {
	(*** PATstroke Warning: Path is too complex, stroking
	  with gray) =
    cleartomark
    restore
    countdictstack exch sub dup 0 gt
	{ { end } repeat } { pop } ifelse
    gsave 0.5 setgray oldstroke grestore
  } { pop restore pop } ifelse
  newpath
} bind def
/PATtcalc {		% modmtx tilingtype PATtcalc tilematrix
  % Note: tiling types 2 and 3 are not supported
  gsave
    exch concat					% tilingtype
    matrix currentmatrix exch			% cmtx tilingtype
    % Tiling type 1 and 3: constant spacing
    2 ne {
	% Distort the pattern so that it occupies
	% an integral number of device pixels
	dup 4 get exch dup 5 get exch		% tx ty cmtx
	XStep 0 dtransform
	round exch round exch			% tx ty cmtx dx.x dx.y
	XStep div exch XStep div exch		% tx ty cmtx a b
	0 YStep dtransform
	round exch round exch			% tx ty cmtx a b dy.x dy.y
	YStep div exch YStep div exch		% tx ty cmtx a b c d
	7 -3 roll astore			% { a b c d tx ty }
    } if
  grestore
} bind def
/PATusp {
  false PATredef
  PATDict begin
    CColor PATsc
  end
} bind def

% vertical bricks
11 dict begin
/PaintType 1 def
/PatternType 1 def
/TilingType 1 def
/BBox [0 0 1 1] def
/XStep 1 def
/YStep 1 def
/PatWidth 1 def
/PatHeight 1 def
/Multi 2 def
/PaintData [
  { clippath } bind
  { 16 16 true [ 16 0 0 -16 0 16 ]
	{<ff8080808080808080808080
	  8080808080ff808080808080
	  8080808080808080> }
        imagemask } bind
] def
/PaintProc {
	pop
	exec fill
} def
currentdict
end
/P8 exch def

/cp {closepath} bind def
/ef {eofill} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth} bind def
/tr {translate} bind def
/tnt {dup dup currentrgbcolor
  4 -2 roll dup 1 exch sub 3 -1 roll mul add
  4 -2 roll dup 1 exch sub 3 -1 roll mul add
  4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
  bind def
/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
  4 -2 roll mul srgb} bind def
 /DrawEllipse {
	/endangle exch def
	/startangle exch def
	/yrad exch def
	/xrad exch def
	/y exch def
	/x exch def
	/savematrix mtrx currentmatrix def
	x y tr xrad yrad sc 0 0 1 startangle endangle arc
	closepath
	savematrix setmatrix
	} def

/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def

$F2psBegin
%%Page: 1 1
10 setmiterlimit
 0.06299 0.06299 sc
% Polyline
15.000 slw
n 555 675 m 450 675 450 3720 105 arcto 4 {pop} repeat
  450 3825 6870 3825 105 arcto 4 {pop} repeat
  6975 3825 6975 780 105 arcto 4 {pop} repeat
  6975 675 555 675 105 arcto 4 {pop} repeat
 cp gs col31 s gr 
% Arc
n 1800.0 -821.0 2576.0 105.2 74.8 arcn
gs col0 s gr

% Arc
n 1800.0 4151.0 2576.0 -105.2 -74.8 arc
gs col0 s gr

% Arc
n 1800.0 349.0 2576.0 105.2 74.8 arcn
gs col0 s gr

% Arc
n 1800.0 5321.0 2576.0 -105.2 -74.8 arc
gs col0 s gr

% Ellipse
n 2700 2250 127 127 0 360 DrawEllipse gs col0 s gr

% Polyline
n 2475 2025 m 5625 2025 l 5625 2475 l 2475 2475 l
 cp gs col0 s gr 
% Polyline
n 2475 1575 m 2700 1575 l 2700 2025 l 2475 2025 l
 cp gs col0 s gr 
% Polyline
n 2475 2475 m 2700 2475 l 2700 2925 l 2475 2925 l
 cp gs col0 s gr 
% Polyline
7.500 slw
n 675 1125 m 1125 1125 l 1125 3375 l 675 3375 l
 cp gs /PC [[1.00 1.00 1.00] [0.00 0.00 0.00]] def
15.00 15.00 sc P8 [16 0 0 -16 45.00 75.00] PATmp PATsp ef gr PATusp gs col0 s gr 
% Polyline
15.000 slw
gs  clippath
2731 2196 m 2646 2281 l 2801 2436 l 2717 2267 l 2886 2351 l cp
eoclip
n 2700 2250 m
 3780 3330 l gs col1 s gr gr

% arrowhead
n 2886 2351 m 2717 2267 l 2801 2436 l 2886 2436 l 2886 2351 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
1746 1543 m 1831 1628 l 1986 1473 l 1817 1558 l 1901 1388 l cp
eoclip
n 1800 1575 m
 2250 1125 l gs col1 s gr gr

% arrowhead
n 1901 1388 m 1817 1558 l 1986 1473 l 1986 1388 l 1901 1388 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
1746 2668 m 1831 2753 l 1986 2598 l 1817 2683 l 1901 2513 l cp
eoclip
n 1800 2700 m
 3375 1125 l gs col1 s gr gr

% arrowhead
n 1901 2513 m 1817 2683 l 1986 2598 l 1986 2513 l 1901 2513 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
3996 1948 m 4081 2033 l 4236 1878 l 4067 1963 l 4151 1793 l cp
eoclip
n 4050 1980 m
 4905 1125 l gs col1 s gr gr

% arrowhead
n 4151 1793 m 4067 1963 l 4236 1878 l 4236 1793 l 4151 1793 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
5818 1745 m 5903 1830 l 6058 1675 l 5889 1760 l 5973 1590 l cp
eoclip
n 5872 1777 m
 6524 1125 l gs col1 s gr gr

% arrowhead
n 5973 1590 m 5889 1760 l 6058 1675 l 6058 1590 l 5973 1590 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
n 5625 1890 m 6345 1890 l 6345 2565 l 5625 2565 l
 cp gs col0 s gr 
/Times-BoldItalic ff 300.00 scf sf
3825 3645 m
gs 1 -1 sc (Pivot) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
2250 1080 m
gs 1 -1 sc (Muscle 1) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
3555 1080 m
gs 1 -1 sc (Muscle 2) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
4905 1080 m
gs 1 -1 sc (Bone) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
6480 1080 m
gs 1 -1 sc (Load) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-Roman ff 375.00 scf sf
5850 2295 m
gs 1 -1 sc (m) col0 sh gr
$F2psEnd
rs
end

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_rep.txt version [58be281b07].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system LowerLeg1 (Example1_rep.txt)
## Generated by MTT on" Thu Apr 19 10:26:57 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt LowerLeg1 abg tex			# The system description
mtt LowerLeg1 cbg ps 		        # The causal bond graph
mtt LowerLeg1 lbl txt
mtt Muscle1 lbl txt
mtt LowerLeg1 struc tex	        # The system structure
mtt LowerLeg1 sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt LowerLeg1 dae tex	        # The system dae
mtt LowerLeg1 ode tex	        # The system ode 
## mtt LowerLeg1 sspar tex		# Steady-state parameters
## mtt LowerLeg1 ss tex 		# Steady state
## mtt LowerLeg1 dm tex		# Descriptor matrices (of linearised system)
mtt LowerLeg1 sm tex		# State matrices (of linearised system)
mtt LowerLeg1 tf tex		# Transfer function (of linearised system)
## mtt LowerLeg1 lmfr ps		# log modulus of frequency response (of linearised system)
 mtt LowerLeg1 simpar tex		# Simulation parameters
 mtt LowerLeg1 numpar tex		# Numerical simulation parameters
## mtt LowerLeg1 state tex		# Simulation initial state
 mtt LowerLeg1 input tex		# Simulation input
## mtt LowerLeg1 logic tex		# Logic control
 mtt LowerLeg1 odeso ps		# Simulation output

mtt LowerLeg1 rep txt		# This file

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/Muscle1/Muscle1_abg.fig version [827c8ec540].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 4050 2700 3825 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2700 5850 2700 5625 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 2475 4275 1125 4500 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 2700 8550 2700 8325 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4275 4275 2925 4500 3150
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 4950 1575 4950 1575 450 9900 450 9900 4950
4 1 0 100 0 18 18 0.0000 4 195 150 4275 2790 1\001
4 2 4 100 0 18 18 0.0000 4 270 870 2610 2790 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 270 840 4455 945 R:d_m\001
4 1 0 100 0 18 18 0.0000 4 270 1170 6525 2790 CDx:c_m\001
4 0 4 100 0 18 18 0.0000 4 270 1065 8640 2790 SS:[out]\001
4 1 1 101 0 3 20 0.0000 4 210 1170 8055 3285 Extension\001
4 1 4 100 0 18 18 0.0000 4 270 810 4275 4545 SS:[F]\001
4 1 1 101 0 3 20 0.0000 4 270 3150 7875 4680 Simple linear muscle model\001
4 1 1 101 0 3 20 0.0000 4 210 1365 2340 3240 Connection\001
4 1 1 101 0 3 20 0.0000 4 270 1335 3015 4545 Force input\001

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/Muscle1/Muscle1_desc.tex version [dd9850e23d].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Muscle1 (Muscle1_desc.tex)
% Generated by MTT on Thu Apr 19 10:39:29 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Muscle1} is
   displayed in Figure \Ref{fig:Muscle1_abg.ps} and its label
   file is listed in Section \Ref{sec:Muscle1_lbl}.
   The subsystems are listed in Section \Ref{sec:Muscle1_sub}.


This model is a highly simplified linear model of a muscle. The two
main components are:
\begin{itemize}
\item a \textbf{CDx} component representing the muscle compliance and
  also providing a measurement of muscle extension and
\item an \textbf{R} component representing mechanical damping in the muscle
\end{itemize}

The component has three ports:
\begin{description}
\item [in] representing the connection of the muscle to the outside world. The
  corresponding force corresponds to the sum of the muscle force and
  the reaction force of connected components.
\item[out] a measurement of the muscle extension.
\item[F] Representing the force component of the muscle model.
\end{description} 

Added mtt/lib/comp/compound/Physiological/Movement/Muscles/Muscle1/Muscle1_lbl.txt version [c874229564].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Muscle1 (Muscle1_lbl.txt)
%SUMMARY Muscle1
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	F	F
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	c_m
%ALIAS	$2	d_m

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type CDx
	c_m	lin		c_m

% Component type R
	d_m	lin		flow,d_m

% Component type SS
	[F]	SS		external,external
	[in]	SS		external,external
	[out]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/O/O_abg.fig version [0c02cc0c9a].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 6075 3645 6075 3420 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5760 3825 4410 4050 4635
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 6075 5400 6075 5175 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 3150 3645 3150 3420 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2835 3825 1485 4050 1710
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5400 3150 5175 3375
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 4185 SS:[B2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 6165 SS:[B3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 6165 SS:[B1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 6165 0\001
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 1260 SS:[A2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 3240 SS:[A3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 3240 SS:[A1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3240 0\001

Added mtt/lib/comp/compound/Sensitivity/O/O_lbl.txt version [8f92217838].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system O (O_lbl.txt)
%SUMMARY O Three-port zero junction for 2-bond vector bonds :-)
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:47:49  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	A1,B1
%ALIAS	out	A2,B2
%ALIAS	in_2|out_2	A3,B3

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[A1]	SS		external,external
	[A2]	SS		external,external
	[A3]	SS		external,external
	[B1]	SS		external,external
	[B2]	SS		external,external
	[B3]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/l/l_abg.fig version [d54e002ecd].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 6075 3645 6075 3420 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5760 3825 4410 4050 4635
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 6075 5400 6075 5175 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 3150 3645 3150 3420 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2835 3825 1485 4050 1710
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5400 3150 5175 3375
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 4185 SS:[B2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 6165 SS:[B3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 6165 SS:[B1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 6165 1\001
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 1260 SS:[A2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 3240 SS:[A3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 3240 SS:[A1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3240 1\001

Added mtt/lib/comp/compound/Sensitivity/l/l_lbl.txt version [fe5dad5d52].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system l (l_lbl.txt)
%SUMMARY l Three port 1 junction with 2-bond vector ports :-)
%DESCRIPTIlN <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:49:49  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	A1,B1
%ALIAS	out	A2,B2
%ALIAS	in_2|out_2	A3,B3

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[A1]	SS		external,external
	[A2]	SS		external,external
	[A3]	SS		external,external
	[B1]	SS		external,external
	[B2]	SS		external,external
	[B3]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/sAE/sAE_abg.fig version [75198870de].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 4050 9000 4050 8775 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 4050 10800 4050 10575 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 450 5625 450 5400 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 450 9000 450 8775 675
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2520 9225 3825 9225 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5625 3825 5625 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 225 3825 675
4 1 0 100 0 18 20 0.0000 4 210 1155 6660 4140 AE:sens\001
4 1 0 100 0 18 20 0.0000 4 195 150 9225 4140 1\001
4 1 0 100 0 18 20 0.0000 4 195 150 4050 540 0\001
4 1 0 100 0 18 20 0.0000 4 270 960 4050 2340 AE:k_s\001
4 1 0 100 0 18 20 0.0000 4 210 1320 6660 540 AE:actual\001
4 1 4 100 0 18 20 0.0000 4 270 1740 3060 4140 SS:[Sens_in]\001
4 1 4 100 0 18 20 0.0000 4 270 1935 12240 4140 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 270 2115 10575 585 SS:[Actual_out]\001
4 1 4 100 0 18 20 0.0000 4 270 1920 1170 585 SS:[Actual_in]\001

Added mtt/lib/comp/compound/Sensitivity/sAE/sAE_lbl.txt version [d9db7d23e5].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sAE (sAE_lbl.txt)
%SUMMARY sAE
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	k
%ALIAS	$2	k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	actual		lin		k
	sens		lin		k
	k_s		lin		k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/sAF/sAF_abg.fig version [53eaaab3d3].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2430 180 2520 720
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2475 225 2475 675
-6
6 4230 3780 4320 4320
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4275 3825 4275 4275
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 4050 9000 4050 8775 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 4050 10800 4050 10575 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 450 5625 450 5400 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 450 9000 450 8775 675
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2520 9225 3825 9225 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
4 1 0 100 0 18 20 0.0000 4 285 1425 6660 4140 AF:sens\001
4 1 0 100 0 18 20 0.0000 4 270 195 9225 4140 0\001
4 1 0 100 0 18 20 0.0000 4 270 195 4050 540 1\001
4 1 0 100 0 18 20 0.0000 4 360 1215 4050 2340 AF:k_s\001
4 1 0 100 0 18 20 0.0000 4 285 1680 6660 540 AF:actual\001
4 1 4 100 0 18 20 0.0000 4 360 2280 3060 4140 SS:[Sens_in]\001
4 1 4 100 0 18 20 0.0000 4 360 2520 12240 4140 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 360 2775 10575 585 SS:[Actual_out]\001
4 1 4 100 0 18 20 0.0000 4 360 2535 1170 585 SS:[Actual_in]\001

Added mtt/lib/comp/compound/Sensitivity/sAF/sAF_lbl.txt version [a37eff47e5].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sAF (sAF_lbl.txt)
%SUMMARY sAF
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	k
%ALIAS	$2	k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	actual		lin		k
	sens		lin		k
	k_s		lin		k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/sC/sC_abg.fig version [b3dd4dbe30].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
2 4 0 3 31 7 101 0 -1 0.000 0 0 11 0 0 5
	 9000 4725 1350 4725 1350 2253 9000 2253 9000 4725
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 450 4950 3465 C:c\001

Added mtt/lib/comp/compound/Sensitivity/sC/sC_lbl.txt version [b25645ac14].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sC (sC_lbl.txt)
%SUMMARY sC Sensitivity C component
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	effort,c
%ALIAS	$2	cs

%CR alias
%ALIAS $1 slin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	c	slin 	effort,c;cs

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external



Added mtt/lib/comp/compound/Sensitivity/sCS/sCS_abg.fig version [9878162dec].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 6 100 0 18 20 0.0000 4 271 196 2476 4186 [1,2]\001
4 1 0 100 0 18 20 0.0000 4 270 195 2476 4185 1\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 2700 4275
4 1 0 100 0 18 20 0.0000 4 285 570 2475 2295 sC:c\001
4 0 0 100 0 18 20 0.0000 4 360 1185 4185 4185 sSe:e_0\001
4 1 6 100 0 18 20 0.0000 4 361 1186 2476 6031 [1,2]\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2476 6030 SS:[in]\001

Added mtt/lib/comp/compound/Sensitivity/sCS/sCS_lbl.txt version [da775c33bd].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sCS (sCS_lbl.txt)
%SUMMARY sCS C component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:31:35  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in_1,in_2

% Argument aliases
%ALIAS	$1	effort,c
%ALIAS	$2	e_0
%ALIAS	$3	c_s
%ALIAS	$4	e_0s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c		slin	effort,c;c_s

% Component type SS
	[in]	 SS	external,external

% Component type Se
	e_0		SS	e_0;e_0s


Added mtt/lib/comp/compound/Sensitivity/sCT/sCT_abg.fig version [6a3e472415].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2700 5625 2700 5400 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 3825 6525 1575 900 1575 900 3825 6525 3825
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2475 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3105 S\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2835 .\001
4 2 6 0 0 0 20 0.0000 4 240 510 1981 2791 [1,2]\001
4 2 4 0 0 0 20 0.0000 4 240 810 1981 2790 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 735 3825 2790 sFP:fp\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2475 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 4950 3105 Q\001
4 1 1 1 0 3 20 0.0000 4 195 165 4950 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 4995 2835 .\001
4 1 -1 0 0 0 20 0.0000 4 195 495 5940 2790 sC:c\001

Added mtt/lib/comp/compound/Sensitivity/sCT/sCT_lbl.txt version [4492e9a698].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY sCT Sensitivity version of Continuous-Time (thermal C) component

## System sCT, representation lbl, language txt
## File sCT_lbl.txt
## Generated by MTT on Fri Jul  6 05:16:27 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in	in_1,in_2

## Argument aliases
#ALIAS	$1	effort,c
#ALIAS	$2	cs

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[in]	SS		external,external		

## Component type C
	c	slin		effort,c;cs		

## Component type FP
	fp	lin		

Added mtt/lib/comp/compound/Sensitivity/sCT/sCT_rep.txt version [b85aacdbc1].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sCT (sCT_rep.txt)
## Generated by MTT on" Fri Jul  6 05:27:38 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sCT abg tex			# The system description
##mtt sCT cbg ps 		        # The causal bond graph
mtt sCT struc tex	        # The system structure
mtt sCT sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sCT dae tex	        # The system dae
## mtt sCT ode tex	        # The system ode 
## mtt sCT sspar tex		# Steady-state parameters
## mtt sCT ss tex 		# Steady state
## mtt sCT dm tex		# Descriptor matrices (of linearised system)
## mtt sCT sm tex		# State matrices (of linearised system)
## mtt sCT tf tex		# Transfer function (of linearised system)
## mtt sCT lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sCT simpar tex		# Simulation parameters
## mtt sCT numpar tex		# Numerical simulation parameters
## mtt sCT state tex		# Simulation initial state
## mtt sCT input tex		# Simulation input
## mtt sCT logic tex		# Logic control
## mtt sCT odeso ps		# Simulation output

## mtt sCT rep txt		# This file

Added mtt/lib/comp/compound/Sensitivity/sDC/sDC_abg.fig version [89b1252cd5].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2036 2724 3371 2724 3063 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3836 2700 5171 2700 4863 2923
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5421 2501 5421 1342 5678 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8501 2724 9836 2724 9528 2947
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11325 4730 11325 494 8758 494 8758 4730 11325 4730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5672 2700 7006 2700 6698 2923
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 4725 6300 494 2293 494 2293 4725 6300 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2501 3600 1342 3857 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11886 2546 11886 1386 12143 1654
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12143 2724 13478 2724 13170 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10041 2546 10041 1386 10298 1654
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10298 2724 11633 2724 11325 2947
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15750 5175 45 5175 45 316 15750 316 15750 5175
4 2 4 0 0 0 20 0.0000 4 255 1815 1980 2790 SS:[Electrical]\001
4 1 1 1 0 0 23 0.0000 4 240 1395 1472 3170 Terminals\001
4 1 -1 0 0 0 23 0.0000 4 240 90 5370 2858 l\001
4 1 -1 0 0 0 23 0.0000 4 285 1365 7783 2813 sGY:k_m\001
4 1 -1 0 0 0 23 0.0000 4 285 765 5370 1252 sI:l_a\001
4 1 1 1 0 0 23 0.0000 4 240 1290 5421 5043 Electrical\001
4 1 1 1 0 0 23 0.0000 4 240 1605 10041 5043 Mechanical\001
4 1 -1 0 0 0 23 0.0000 4 240 90 3600 2835 l\001
4 1 -1 0 0 0 23 0.0000 4 270 900 3645 1260 sR:r_a\001
4 1 4 100 0 18 4 0.0000 4 75 270 3780 2475 [out_2]\001
4 1 4 100 0 18 4 0.0000 4 75 270 5580 2475 [out_2]\001
4 1 -1 0 0 0 23 0.0000 4 240 90 11880 2835 l\001
4 1 4 100 0 18 4 0.0000 4 75 270 11745 2475 [out_2]\001
4 1 -1 0 0 0 23 0.0000 4 300 885 10144 1252 sI:j_m\001
4 1 -1 0 0 0 23 0.0000 4 240 90 10035 2835 l\001
4 1 4 100 0 18 4 0.0000 4 75 270 9900 2475 [out_2]\001
4 1 -1 0 0 0 23 0.0000 4 285 1080 11880 1260 sR:b_m\001
4 0 4 0 0 0 20 0.0000 4 255 2055 13635 2790 SS:[Mechanical]\001
4 1 1 1 0 0 23 0.0000 4 240 735 12645 3150 Shaft\001
4 1 4 100 0 18 16 0.0000 4 225 480 2115 2520 [1,2]\001
4 1 4 100 0 18 16 0.0000 4 225 480 13365 2565 [1,2]\001

Added mtt/lib/comp/compound/Sensitivity/sDC/sDC_desc.tex version [465a6a54c1].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system sDC (sDC_desc.tex)
% Generated by MTT on Thu Sep 11 10:09:58 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sDC} is
   displayed in Figure \Ref{sDC_abg} and its label
   file is listed in Section \Ref{sec:sDC_lbl}.
   The subsystems are listed in Section \Ref{sec:sDC_sub}.

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|}
        \hline
        Index & Parameter\\
        \hline
         1 & Motor gain ($k_m$) \\
         2 & Armature inductance ($l_a$) \\
         3 & Armature resistance ($r_a$) \\
         4 & Inertia ($j_m$) \\
         5 & Friction coefficient ($b_m$) \\
        \hline
       \end{tabular}
       \caption{sDC motor parameters}
       \label{tab:sDC_components}
     \end{center}
   \end{table}
{\bf sDC} is a two(vector)-port component representing a DC  motor and its
sensitivity functions. It has the 5
parameters listed in Table \Ref{tab:sDC_components}.


Added mtt/lib/comp/compound/Sensitivity/sDC/sDC_lbl.txt version [70aedeb957].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sDC (sDC_lbl.txt)
%SUMMARY sDC
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in		Electrical_1,Electrical_2
%ALIAS	out		Mechanical_1,Mechanical_2

% Argument aliases
%ALIAS $1	k_m
%ALIAS $2	l_a
%ALIAS $3	r_a
%ALIAS $4	j_m
%ALIAS $5	b_m

%ALIAS $6	k_ms
%ALIAS $7	l_as
%ALIAS $8	r_as
%ALIAS $9	j_ms
%ALIAS $10	b_ms

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[Electrical]	SS		external,external
	[Mechanical]	SS		external,external

% Component type sGY
	k_m	        lin		flow,k_m;k_ms

% Component type sI
	j_m		lin		flow,j_m;j_ms
	l_a		lin		flow,l_a;l_as

% Component type sR
	b_m		lin		flow,b_m;b_ms
	r_a		lin		flow,r_a;r_as


Added mtt/lib/comp/compound/Sensitivity/sDe/sDe_abg.fig version [fe2c89039d].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
4 1 0 100 0 18 20 0.0000 4 270 1110 1485 2115 SS:ss_2\001
4 1 0 100 0 18 20 0.0000 4 270 1110 1485 1440 SS:ss_1\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4545 1440 SS:[port_1]\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4500 2115 SS:[port_2]\001

Added mtt/lib/comp/compound/Sensitivity/sDe/sDe_lbl.txt version [10df3ea2fd].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sDe (sDe_lbl.txt)
%SUMMARY sDe Sensitivity version of Effort detector (De)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:53:34  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS $1 external

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external
	ss_1		SS		external,0
	ss_2		SS		external,0

Added mtt/lib/comp/compound/Sensitivity/sDf/sDf_abg.fig version [795b94a9b4].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 900 1215 2070 1530
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 1440 SS:ss_1\001
-6
6 900 1890 2070 2205
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 2115 SS:ss_2\001
-6
6 2205 1305 3645 1620
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
-6
6 2205 1980 3645 2295
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
-6
6 3735 1215 5355 1530
4 1 4 100 0 18 20 0.0000 4 300 1620 4545 1440 SS:[port_1]\001
-6
6 3690 1890 5310 2205
4 1 4 100 0 18 20 0.0000 4 300 1620 4500 2115 SS:[port_2]\001
-6

Added mtt/lib/comp/compound/Sensitivity/sDf/sDf_lbl.txt version [55d304bd19].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sDf (sDf_lbl.txt)
%SUMMARY sDf Sensitivity version of Effort detector (De)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/09/07 05:32:17  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/07/29 04:53:34  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS $1 external

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external
	ss_1		SS		0,external
	ss_2		SS		0,external

Added mtt/lib/comp/compound/Sensitivity/sEMTF/sEMTF_abg.fig version [06c2007d04].








































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 7155 2295 7695
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 7200 2250 7650
-6
6 3510 4005 4050 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4005 4050 3555 4050
-6
6 3645 5850 4185 5940
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4140 5895 3690 5895
-6
6 8730 5355 9270 5445
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9225 5400 8775 5400
-6
6 3600 7155 4140 7245
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4095 7200 3645 7200
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 7425 3600 7425 3375 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 7425 5400 7425 5175 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 7425 8775 7425 8550 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 7425 10575 7425 10350 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 3600 3825 3375 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3825 5400 3825 5175 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 3825 8775 3825 8550 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 3825 10575 3825 10350 4050
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5895 9000 7200 9000 6975
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9006 5873 3831 7178 3831 6953
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 450 6300 1800 6525 1575
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2250 6300 3600 6525 3375
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 1800 6525 1800
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 2025 4275 2025 4275 5400 4500 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 3825 5400 4050 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4050 9000 5400 9225 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 2250 6525 7200 6750 6975
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 2025 8550 2025 8550 5400 8775 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 8550 9225 8550 9225 5850 9450 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 8550 3600 8550 3600 5850 3375 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 10125 6300 8775 6525 9000
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 8775 6525 8775
4 1 4 100 0 18 20 0.0000 4 285 2415 6210 360 SS:[Actual_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6300 2115 0\001
4 1 4 100 0 18 20 0.0000 4 285 1845 1215 7515 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 7515 1\001
4 1 0 100 0 18 20 0.0000 4 225 1590 6435 7515 EMTF:sens\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 7515 0\001
4 1 4 100 0 18 20 0.0000 4 285 2040 11790 7515 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 285 2055 1215 3915 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3915 1\001
4 1 0 100 0 18 20 0.0000 4 225 1785 6435 3915 EMTF:actual\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 3915 0\001
4 1 4 100 0 18 20 0.0000 4 285 2250 11790 3915 SS:[Actual_out]\001
4 1 0 100 0 18 20 0.0000 4 225 1170 8955 5715 AE3:ae3\001
4 1 0 100 0 18 20 0.0000 4 225 1095 3825 5715 AF3:af3\001
4 2 4 100 0 18 14 0.0000 4 210 600 6255 3600 [mod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 6435 7155 [mod]\001
4 1 4 100 0 18 20 0.0000 4 285 2205 6300 10395 SS:[Sens_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6345 8640 0\001
4 2 4 100 0 18 14 0.0000 4 210 720 3420 5985 [smod]\001
4 0 4 100 0 18 14 0.0000 4 210 720 9540 5940 [smod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 8505 5355 [mod]\001
4 0 4 100 0 18 14 0.0000 4 210 600 4455 5400 [mod]\001

Added mtt/lib/comp/compound/Sensitivity/sEMTF/sEMTF_lbl.txt version [974b4d5e9f].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sEMTF (sEMTF_lbl.txt)
%SUMMARY sEMTF Effort modulated TF - sensitivity version
%DESCRIPTION It is assumed that no sensitivity parameter is associated
%DESCRIPTION with this component.
%DESCRIPTION This is a built out of EMTFs and the 4 port AE3 component
%DESCRIPTION There is one argument alias - the transformer (flow) gain 
%DESCRIPTION There are two CR aliases: one for the EMTF and one for
%DESCRIPTION the AE3
%DESCRIPTION Examples:
%DESCRIPTION   lin;slin  n
%DESCRIPTION   lsin;slsin l
%DESCRIPTION   lcos;slcos l



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/04/17 18:50:35  gawthrop
% %% Sensitivity EMTF components
% %%
% %% Revision 1.1  2000/12/28 17:29:10  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out
%ALIAS	mod	Actual_mod,Sens_mod


% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	lsin
%ALIAS	$2	slsin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type EMTF
	actual		lsin	flow,l
	sens		lsin	flow,l

% Component type AE3 (????NB NEGATIVE GAIN HERE!!!!)
	ae3             slsin   l

% Component type AF3
	af3             slsin   l

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Actual_mod]	SS		external,internal
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external
	[Sens_mod]	SS		external,internal



Added mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_abg.fig version [853ebbe17a].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 675 4050 675 3825 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1350 4050 1350 3825 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 1125 4050 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 450 4050 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 675 4725 675 4950 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 1350 4725 1350 4950 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8100 675 6750 675 6975 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8100 1350 6750 1350 6975 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8100 450 8100 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8100 1125 8100 1575
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 1800 1350 1800 1350 225 9900 225 9900 1800
4 1 4 100 0 18 18 0.0000 4 270 870 2115 765 SS:[In]\001
4 1 4 100 0 18 18 0.0000 4 270 1020 2115 1395 SS:[sIn]\001
4 1 0 100 0 18 24 0.0000 4 285 510 4410 1125 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 540 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 1215 [4]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 1215 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 540 [1]\001
4 1 0 100 0 18 18 0.0000 4 210 375 6390 765 AF\001
4 1 0 100 0 18 18 0.0000 4 210 375 6390 1440 AF\001
4 1 4 100 0 18 18 0.0000 4 270 1230 8820 765 SS:[Mod]\001
4 1 4 100 0 18 18 0.0000 4 270 1380 8865 1440 SS:[sMod]\001

Added mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_cr.r version [24ddbdd6a4].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% CR file for sFMR
%% Just for flow input definition of r, ie must use with flow,r;k_s
in "$MTT_CRS/r/slin.cr";

OPERATOR sFMR;

% Ordinary FMR port
FOR ALL gain_cause,r,k_s,out_cause,in,sin,in_cause,modu,smodu
LET sFMR(gain_cause,r,k_s,out_cause,1,
	in,in_cause,1,
	sin,in_cause,2,
	modu,flow,3,
	smodu,flow,4
	) 
        = slin(gain_cause,r*modu,k_s,out_cause,1,
               in,in_cause,1,
               sin,in_cause,2);

% Sensitivity FMR port - effort input
FOR ALL r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(flow,r,k_s,out_cause,2,
	inp,effort,1,
	sinp,effort,2,
	modu,flow,3,
	smodu,flow,4
	)
        = (
          slin(flow,r,k_s,out_cause,2,
               inp/modu,effort,1,
               sinp/modu,effort,2)
        - smodu*(1/(r*(modu^2))) 
        );

% Sensitivity FMR port - flow input
FOR ALL r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(flow,r,k_s,out_cause,2,
	inp,flow,1,
	sinp,flow,2,
	modu,flow,3,
	smodu,flow,4
	) 
	= (
          slin(flow,r,k_s,out_cause,2,
               inp*modu,flow,1,
               sinp*modu,flow,2)
        + r*inp*smodu
        );

% Modulation port
FOR ALL gain_cause,r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(gain_cause,r,k_s,out_cause,3,
	inp,inp_cause,1,
	sinp,inp_cause,2,
	modu,flow,3,
	smodu,flow,4
	) 
        = 0;

% Sensitivity modulation port
FOR ALL gain_cause,r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(gain_cause,r,k_s,out_cause,4,
	inp,inp_cause,1,
	sinp,inp_cause,2,
	modu,flow,3,
	smodu,flow,4
	) 
        = 0;
END;

Added mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_desc.tex version [eee4a49ecd].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system sFMR (sFMR_desc.tex)
% Generated by MTT on Thu Jul 5 23:47:35 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sFMR} is
   displayed in Figure \Ref{fig:sFMR_abg.ps} and its label
   file is listed in Section \Ref{sec:sFMR_lbl}.
   The subsystems are listed in Section \Ref{sec:sFMR_sub}.


This is the sensitivity version of the \textbf{FMR} (flow-modulated
resistor) component.

In the linear case, the CR of the standard port is:
\begin{equation}
  e = mrf
\end{equation}
where $e$ is the effort, $m$ the (flow) modulation, $r$ the
``resistance'' and $f$ the flow.

The corresponding sensitivity CR is:
\begin{equation}
  e^\prime  = m^\prime rf + mr^\prime f + mrf^\prime
\end{equation}

Added mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_lbl.txt version [a614981b1c].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY sFMR Sensitivity version of FMR (Flow-modulated R)

## System sFMR, representation lbl, language txt
## File sFMR_lbl.txt
## Generated by MTT on Thu Jul  5 04:45:59 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in	In,sIn
#ALIAS	out	Mod,sMod


## Argument aliases
#ALIAS	$1	flow,r
#ALIAS	$2	k_s

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	r	sFMR		flow,r,k_s		

## Component type SS
	[In]	SS		external,external		
	[sIn]	SS		external,external		
	[Mod]	SS		external,external		
	[sMod]	SS		external,external		

Added mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_rep.txt version [5d2ba7f5ff].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sFMR (sFMR_rep.txt)
## Generated by MTT on" Thu Jul  5 23:56:36 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sFMR abg tex			# The system description
mtt sFMR cr  tex			# The CR
##mtt sFMR cbg ps 		        # The causal bond graph
mtt sFMR struc tex	        # The system structure
mtt sFMR sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sFMR dae tex	        # The system dae
## mtt sFMR ode tex	        # The system ode 
## mtt sFMR sspar tex		# Steady-state parameters
## mtt sFMR ss tex 		# Steady state
## mtt sFMR dm tex		# Descriptor matrices (of linearised system)
## mtt sFMR sm tex		# State matrices (of linearised system)
## mtt sFMR tf tex		# Transfer function (of linearised system)
## mtt sFMR lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sFMR simpar tex		# Simulation parameters
## mtt sFMR numpar tex		# Numerical simulation parameters
## mtt sFMR state tex		# Simulation initial state
## mtt sFMR input tex		# Simulation input
## mtt sFMR logic tex		# Logic control
## mtt sFMR odeso ps		# Simulation output

## mtt sFMR rep txt		# This file

Added mtt/lib/comp/compound/Sensitivity/sFP/sFP_abg.fig version [98a0a6cf36].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 675 4050 675 3825 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1350 4050 1350 3825 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 675 6075 675 5850 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 1350 6075 1350 5850 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 1125 2700 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 450 2700 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 450 4725 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 1125 4725 1575
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 7875 1800 1350 1800 1350 225 7875 225 7875 1800
4 1 4 100 0 18 18 0.0000 4 270 810 2115 765 SS:[F]\001
4 1 4 100 0 18 18 0.0000 4 270 960 2115 1395 SS:[sF]\001
4 1 4 100 0 18 18 0.0000 4 270 960 6885 1440 SS:[sP]\001
4 1 0 100 0 18 24 0.0000 4 285 510 4410 1125 R:r\001
4 1 4 100 0 18 18 0.0000 4 270 810 6840 765 SS:[P]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 540 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 1215 [4]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 1215 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 540 [1]\001
4 1 1 101 0 3 20 0.0000 4 195 165 3195 945 S\001
4 1 1 101 0 3 20 0.0000 4 240 210 5535 945 Q\001
4 1 1 101 0 3 20 0.0000 4 195 165 3195 450 T\001
4 1 1 101 0 3 20 0.0000 4 195 135 3330 585 1\001
4 1 1 101 0 3 20 0.0000 4 195 165 5445 450 T\001
4 1 1 101 0 3 20 0.0000 4 195 135 5580 585 2\001

Added mtt/lib/comp/compound/Sensitivity/sFP/sFP_cr.r version [4727041a69].





























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% CR file for sFP

OPERATOR sFP;

% Entropy flow in

% Ordinary FP port
% Temperature
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(effort,1,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	) 
        = Temperature;

% Heat
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(flow,2,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	)
        = Entropy*Temperature;

% Temperature sensitivity
% Sensitivity  FP port
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(effort,3,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	) 
        = sTemperature;

% Heat sensitivity
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(flow,4,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	) 
        = (Entropy*sTemperature + sEntropy*Temperature);

% Heat flow in

% Ordinary FP port
% Temperature
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(effort,2,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = Temperature;

% Heat
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(flow,1,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = Heat/Temperature;

% Temperature sensitivity
% Sensitivity  FP port
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(effort,4,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = sTemperature;

% Heat sensitivity
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(flow,3,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = (sHeat*Temperature - Heat*sTemperature)/Temperature^2;
END;

Added mtt/lib/comp/compound/Sensitivity/sFP/sFP_desc.tex version [5a88ca8029].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system sFP (sFP_desc.tex)
% Generated by MTT on Fri Jul 6 01:55:23 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sFP} is
   displayed in Figure \Ref{fig:sFP_abg.ps} and its label
   file is listed in Section \Ref{sec:sFP_lbl}.
   The subsystems are listed in Section \Ref{sec:sFP_sub}.

This is the sensitivity version of the \textbf{FP} (flow/power
real-pseuso component).

The standard ports implement the CR:
\begin{align}
  T_1 &= T_2 \\
  Q &= S*T_2
\end{align}

The \emph{sensitivity} ports implement the CR:
\begin{align}
  T_1^\prime &= T_2^\prime \\
  Q^\prime &= S^\prime *T_2 + S*T_2^\prime
\end{align}

Added mtt/lib/comp/compound/Sensitivity/sFP/sFP_lbl.txt version [0db9ba715f].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY sFP Sensitivity version of FP - real-pseudo conversion

## System sFP, representation lbl, language txt
## File sFP_lbl.txt
## Generated by MTT on Thu Jul  5 08:03:02 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in|f    F,sF
#ALIAS	out|p   P,sP


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	r       sFP

## Component type SS
	[F]	SS		external,external		
	[P]	SS		external,external		
	[sF]	SS		external,external		
	[sP]	SS		external,external		

Added mtt/lib/comp/compound/Sensitivity/sFP/sFP_rep.txt version [6d67192426].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sFP (sFP_rep.txt)
## Generated by MTT on" Fri Jul  6 02:04:19 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sFP abg tex			# The system description
mtt sFP cr tex			# The system description
##mtt sFP cbg ps 		        # The causal bond graph
mtt sFP struc tex	        # The system structure
mtt sFP sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sFP dae tex	        # The system dae
## mtt sFP ode tex	        # The system ode 
## mtt sFP sspar tex		# Steady-state parameters
## mtt sFP ss tex 		# Steady state
## mtt sFP dm tex		# Descriptor matrices (of linearised system)
## mtt sFP sm tex		# State matrices (of linearised system)
## mtt sFP tf tex		# Transfer function (of linearised system)
## mtt sFP lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sFP simpar tex		# Simulation parameters
## mtt sFP numpar tex		# Numerical simulation parameters
## mtt sFP state tex		# Simulation initial state
## mtt sFP input tex		# Simulation input
## mtt sFP logic tex		# Logic control
## mtt sFP odeso ps		# Simulation output

## mtt sFP rep txt		# This file

Added mtt/lib/comp/compound/Sensitivity/sGY/sGY_abg.fig version [45c2af76d2].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 1125 3825 1125 3600 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 450 6525 450 6300 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 1125 6525 1125 6300 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 450 8550 450 8325 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 1125 8550 1125 8325 1350
4 1 4 100 0 18 20 0.0000 4 270 1920 1440 540 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 210 960 4545 855 sTF:stf\001
4 1 4 100 0 18 20 0.0000 4 270 1740 1440 1215 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 210 420 6840 540 GY\001
4 1 0 100 0 18 20 0.0000 4 210 420 6840 1215 GY\001
4 1 4 100 0 18 20 0.0000 4 270 2115 9765 540 SS:[Actual_out]\001
4 1 4 100 0 18 20 0.0000 4 270 1935 9765 1215 SS:[Sens_out]\001
4 1 4 100 0 18 14 0.0000 4 210 1125 3825 315 [Actual_in]\001
4 1 4 100 0 18 14 0.0000 4 210 1275 5175 315 [Actual_out]\001
4 1 4 100 0 18 14 0.0000 4 210 1140 5175 1575 [Sens_out]\001
4 1 4 100 0 18 14 0.0000 4 210 990 3870 1575 [Sens_in]\001

Added mtt/lib/comp/compound/Sensitivity/sGY/sGY_lbl.txt version [2cd97b9fb4].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sGY (sGY_lbl.txt)
%SUMMARY sGY GY component with sensitivity ports
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	flow,k
%ALIAS	$2	k_s

%ALIAS	$1	lin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type sTF
        stf		lin		flow,k;k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/sI/sI_abg.fig version [0b170eafdf].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
2 4 0 3 31 7 101 0 -1 0.000 0 0 11 0 0 5
	 9000 4725 1350 4725 1350 2253 9000 2253 9000 4725
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 390 4950 3465 I:m\001

Added mtt/lib/comp/compound/Sensitivity/sI/sI_lbl.txt version [c893be13e2].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sI (sI_lbl.txt)
%SUMMARY sI Sensitivity I component
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	flow,m
%ALIAS	$2	ms

%CR alias
%ALIAS $1 slin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m	slin 	flow,m;ms

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external



Added mtt/lib/comp/compound/Sensitivity/sINTF/sINTF_abg.fig version [2b8dc82992].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2925 3150 2925 2925 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2250 3150 2250 2925 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2925 6300 2925 6075 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2250 6300 2250 6075 2475
4 1 4 100 0 18 20 0.0000 4 270 1200 990 3015 SS:[in_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1200 990 2340 SS:[in_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1455 4050 3015 INTF:intf_2\001
4 1 0 100 0 18 20 0.0000 4 270 1455 4050 2340 INTF:intf_1\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 3015 SS:[out_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 2340 SS:[out_1]\001

Added mtt/lib/comp/compound/Sensitivity/sINTF/sINTF_lbl.txt version [123e35cee2].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sINTF (sINTF_lbl.txt)
%SUMMARY sINTF Sensitivity version of INTF
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:32:30  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in_1,in_2
%ALIAS	out	out_1,out_2

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type INTF
	intf_1
	intf_2

% Component type SS
	[in_1]	SS		external,external
	[in_2]	SS		external,external
	[out_1]	SS		external,external
	[out_2]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/sINTFS/sINTFS_abg.fig version [3245e72115].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2925 3150 2925 2925 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2250 3150 2250 2925 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2925 6300 2925 6075 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2250 6300 2250 6075 2475
4 1 4 100 0 18 20 0.0000 4 270 1200 990 3015 SS:[in_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1200 990 2340 SS:[in_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1650 4050 3015 INTFS:intf_2\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 3015 SS:[out_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 2340 SS:[out_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1650 4095 2340 INTFS:intf_1\001

Added mtt/lib/comp/compound/Sensitivity/sINTFS/sINTFS_lbl.txt version [f58d20ad1f].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sINTFS (sINTFS_lbl.txt)
%SUMMARY sINTFS Sensitivity version of INTF with initial state
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:32:30  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in_1,in_2
%ALIAS	out	out_1,out_2

% Argument aliases
%ALIAS	$1      e_0
%ALIAS	$2      k_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type INTFS
	intf_1    none	e_0
	intf_2    none  k_s

% Component type SS
	[in_1]	SS		external,external
	[in_2]	SS		external,external
	[out_1]	SS		external,external
	[out_2]	SS		external,external

Added mtt/lib/comp/compound/Sensitivity/sIS/sIS_abg.fig version [afb2e2fe02].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
2 4 0 2 31 7 52 0 -1 0.000 0 0 7 0 0 5
	 6075 6300 6075 1350 1125 1350 1125 6300 6075 6300
4 1 0 100 0 18 20 0.0000 4 210 405 2475 2295 sI:i\001
4 0 0 100 0 18 20 0.0000 4 270 960 4185 4185 sSf:f_0\001
4 1 6 100 0 18 20 0.0000 4 270 555 2476 6031 [1,2]\001
4 1 4 100 0 18 20 0.0000 4 270 900 2476 6030 SS:[in]\001
4 1 6 100 0 18 20 0.0000 4 270 555 2476 4186 [1,2]\001
4 1 0 100 0 18 20 0.0000 4 195 150 2476 4185 0\001

Added mtt/lib/comp/compound/Sensitivity/sIS/sIS_lbl.txt version [f0aeba0ddf].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sIS (sIS_lbl.txt)
%SUMMARY sIS
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:29:10  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Port aliases
%ALIAS	in	in_1,in_2

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0
%ALIAS	$3	i_s
%ALIAS	$4	f_0s

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[in]	SS		external,external

% Component type sI
	i       slin             flow,i;i_s

% Component type sSf
	f_0     SS	        f_0;f_0s

Added mtt/lib/comp/compound/Sensitivity/sR/sR_abg.fig version [1cfa4eb3a3].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
2 4 0 3 31 7 101 0 -1 0.000 0 0 11 0 0 5
	 9000 4725 1350 4725 1350 2253 9000 2253 9000 4725
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 390 4950 3465 R:r\001

Added mtt/lib/comp/compound/Sensitivity/sR/sR_lbl.txt version [e03a82f71c].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sR (sR_lbl.txt)
%SUMMARY sR Sensitivity R component
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	flow,r
%ALIAS	$2	rs

%CR alias
%ALIAS $1 slin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	r	slin 	flow,r;rs

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external



Added mtt/lib/comp/compound/Sensitivity/sRS/sRS_abg.fig version [530171f10a].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 675 4050 675 3825 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1350 4050 1350 3825 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 1125 4050 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 450 4050 900
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 1800 1350 1800 1350 225 9900 225 9900 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 675 6075 675 5850 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 1350 6075 1350 5850 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 1125 4725 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 450 4725 900
4 1 4 100 0 18 18 0.0000 4 270 870 2115 765 SS:[In]\001
4 1 4 100 0 18 18 0.0000 4 270 1020 2115 1395 SS:[sIn]\001
4 1 0 100 0 18 24 0.0000 4 285 510 4410 1125 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 540 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 1215 [4]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 1215 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 540 [1]\001
4 1 4 100 0 18 18 0.0000 4 270 1230 6795 765 SS:[Out]\001
4 1 4 100 0 18 18 0.0000 4 270 1380 6885 1440 SS:[sOut]\001

Added mtt/lib/comp/compound/Sensitivity/sRS/sRS_cr.r version [5c21ad435b].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% CR file for sFMR
%% Just for flow input definition of r, ie must use with flow,r;k_s

in "$MTT_CRS/r/slin.cr"; %% make sure CR slin is there

OPERATOR sRS;

% Ordinary RS port
% R component
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,1,
	inp,in_cause,1,
	temp,effort,2,
	sinp,in_cause,3,
	stemp,effort,4
	) 
        = lin(gain_cause,r,temp_cause,1,
               inp,in_cause,1);
% Entropy flow 
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,2,
	inp,in_cause,1,
	temp,effort,2,
	sinp,in_cause,3,
	stemp,effort,4
	) 
        = inp*lin(gain_cause,r,temp_cause,1,
               inp,in_cause,1)/temp;

% Sensitivity ports
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,3,
	inp,in_cause,1,
	temp,effort,2,
	sinp,in_cause,3,
	stemp,effort,4
	) 
        = slin(gain_cause,r,rs,temp_cause,2,
               inp,in_cause,1,
               sinp,in_cause,2
        );

%% Sensitivity entropy flow
%% - flow in
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,4,
	inp,flow,1,
	temp,effort,2,
	sinp,flow,3,
	stemp,effort,4
	) 
        = 2*inp*sinp*r/temp
        + (inp^2)*rs/temp
        - (inp^2)*r*stemp/(temp^2);

%% - effort in
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,4,
	inp,effort,1,
	temp,effort,2,
	sinp,effort,3,
	stemp,effort,4
	) 
        = 2*inp*sinp/(r*temp)
        - (inp^2)*rs/((r^2)*temp)
        - (inp^2)*stemp/(r*temp^2);

END;

Added mtt/lib/comp/compound/Sensitivity/sRS/sRS_desc.tex version [891b367d21].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system sRS (sFMR_desc.tex)
% Generated by MTT on Thu Jul 5 23:47:35 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/07/06 01:17:14  gawthrop
% %% New sensitivity components (for extruder model)
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sRS} is
   displayed in Figure \Ref{fig:sFMR_abg.ps} and its label
   file is listed in Section \Ref{sec:sFMR_lbl}.
   The subsystems are listed in Section \Ref{sec:sFMR_sub}.


This is the sensitivity version of the \textbf{FMR} (flow-modulated
resistor) component.

In the linear case, the CR of the standard port is:
\begin{equation}
  e = mrf
\end{equation}
where $e$ is the effort, $m$ the (flow) modulation, $r$ the
``resistance'' and $f$ the flow.

The corresponding sensitivity CR is:
\begin{equation}
  e^\prime  = m^\prime rf + mr^\prime f + mrf^\prime
\end{equation}

Added mtt/lib/comp/compound/Sensitivity/sRS/sRS_lbl.txt version [fbf7e22063].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY sRS Sensitivity version of RS

## System sRS, representation lbl, language txt

## Port aliases
#ALIAS	in	In,sIn
#ALIAS	out	Out,sOut


## Argument aliases
#ALIAS	$1	flow,r
#ALIAS	$2	rs

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	r	sRS		flow,r;rs		

## Component type SS
	[In]	SS		external,external		
	[sIn]	SS		external,external		
	[Out]	SS		external,external		
	[sOut]	SS		external,external		

Added mtt/lib/comp/compound/Sensitivity/sRS/sRS_rep.txt version [a8fe94a22d].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sRS (sFMR_rep.txt)
## Generated by MTT on" Thu Jul  5 23:56:36 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/07/06 01:18:24  gawthrop
## New sensitivity components - documentation
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sRS abg tex			# The system description
mtt sRS cr  tex			# The CR
##mtt sRS cbg ps 		        # The causal bond graph
mtt sRS struc tex	        # The system structure
mtt sRS sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sRS dae tex	        # The system dae
## mtt sRS ode tex	        # The system ode 
## mtt sRS sspar tex		# Steady-state parameters
## mtt sRS ss tex 		# Steady state
## mtt sRS dm tex		# Descriptor matrices (of linearised system)
## mtt sRS sm tex		# State matrices (of linearised system)
## mtt sRS tf tex		# Transfer function (of linearised system)
## mtt sRS lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sRS simpar tex		# Simulation parameters
## mtt sRS numpar tex		# Numerical simulation parameters
## mtt sRS state tex		# Simulation initial state
## mtt sRS input tex		# Simulation input
## mtt sRS logic tex		# Logic control
## mtt sRS odeso ps		# Simulation output

## mtt sRS rep txt		# This file

Added mtt/lib/comp/compound/Sensitivity/sRT/sRT_abg.fig version [f43a08790f].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2701 5625 2701 5400 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2701 7425 2701 7200 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2476 5850 1126 6075 1351
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3600 450 3600 450 451 11475 451 11475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2701 3375 2701 3150 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2701 9675 2701 9450 2926
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2520 3375 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8325 2475 8325 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5625 2475 5625 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 2475 6075 2925
4 1 6 0 0 0 20 0.0000 4 240 510 5851 2792 [1,2]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5851 2791 1\001
4 1 -1 0 0 0 20 0.0000 4 195 480 5850 991 sR:r\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2476 [p]\001
4 1 4 0 0 0 20 0.0000 4 255 315 7290 2476 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 5040 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 5085 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 5040 2521 T\001
4 1 1 1 0 3 20 0.0000 4 240 210 6615 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 6660 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 6615 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 6795 2611 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 5220 2611 1\001
4 1 -1 0 0 0 20 0.0000 4 255 870 3825 2790 sFP:fp1\001
4 2 6 0 0 0 20 0.0000 4 240 510 1981 2791 [1,2]\001
4 2 4 0 0 0 20 0.0000 4 240 810 1981 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 2611 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 3241 1\001
4 1 -1 0 0 0 20 0.0000 4 255 870 7920 2790 sFP:fp2\001
4 1 4 0 0 0 20 0.0000 4 240 270 8505 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 9135 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 3241 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 2611 2\001
4 0 6 0 0 0 20 0.0000 4 240 510 9811 2792 [1,2]\001
4 0 4 0 0 0 20 0.0000 4 240 960 9811 2791 SS:[out]\001

Added mtt/lib/comp/compound/Sensitivity/sRT/sRT_lbl.txt version [c50752cef2].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY sRT Sensitivity version of RT

## System sRT, representation lbl, language txt
## File sRT_lbl.txt
## Generated by MTT on Fri Jul  6 05:51:50 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in	in_1,in_2
#ALIAS	out	out_1,out_2

## Argument aliases
#ALIAS	$1	flow,r
#ALIAS	$2	rs

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[in]	SS		external,external		
	[out]	SS		external,external		

## Component type FP
	fp1	lin
	fp2	lin		

## Component type R
	r	slin		flow,r;rs		

Added mtt/lib/comp/compound/Sensitivity/sSe/sSe_abg.fig version [31113ead72].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
4 1 0 100 0 18 20 0.0000 4 270 1080 1485 2115 Se:se_2\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4500 2115 SS:[port_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4545 1440 SS:[port_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1080 1485 1440 Se:se_1\001

Added mtt/lib/comp/compound/Sensitivity/sSe/sSe_lbl.txt version [e9246e3267].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sSe (sSe_lbl.txt)
%SUMMARY sSe Sensitivity version of effort source (Se)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:54:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS	$1 e_s
%ALIAS	$2 k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external

% Component type Se
	se_1		SS		e_s
	se_2		SS		k_s

Added mtt/lib/comp/compound/Sensitivity/sSe/sSe_sSe_abg.fig version [8738ce32fa].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 900 1215 2070 1530
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 1440 Sf:sf_1\001
-6
6 900 1890 2070 2205
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 2115 Sf:sf_2\001
-6
6 2205 1305 3645 1620
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
-6
6 2205 1980 3645 2295
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
-6
6 3735 1215 5355 1530
4 1 4 100 0 18 20 0.0000 4 300 1620 4545 1440 SS:[port_1]\001
-6
6 3690 1890 5310 2205
4 1 4 100 0 18 20 0.0000 4 300 1620 4500 2115 SS:[port_2]\001
-6

Added mtt/lib/comp/compound/Sensitivity/sSf/sSf_abg.fig version [8738ce32fa].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 900 1215 2070 1530
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 1440 Sf:sf_1\001
-6
6 900 1890 2070 2205
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 2115 Sf:sf_2\001
-6
6 2205 1305 3645 1620
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
-6
6 2205 1980 3645 2295
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
-6
6 3735 1215 5355 1530
4 1 4 100 0 18 20 0.0000 4 300 1620 4545 1440 SS:[port_1]\001
-6
6 3690 1890 5310 2205
4 1 4 100 0 18 20 0.0000 4 300 1620 4500 2115 SS:[port_2]\001
-6

Added mtt/lib/comp/compound/Sensitivity/sSf/sSf_lbl.txt version [7503578c13].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sSf (sSf_lbl.txt)
%SUMMARY sSf Sensitivity version of flow source (Sf)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:54:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS	$1 f_s
%ALIAS	$2 k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external

% Component type Sf
	sf_1		SS		f_s
	sf_2		SS		k_s

Added mtt/lib/comp/compound/Sensitivity/sTF/sTF_abg.fig version [d3bd4652b1].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 4050 3825 4050 3600 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 4050 9000 4050 8775 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 4050 10800 4050 10575 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 450 5625 450 5400 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 450 9000 450 8775 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 450 10800 450 10575 675
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2520 9225 3825 9225 3600
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9231 2498 4056 3803 4056 3578
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 675 9225 2025 9450 1800
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 2
	 3825 675 4275 675
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 2
	 9000 2025 9450 2025
4 1 4 100 0 18 20 0.0000 4 270 1740 1440 4140 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 195 150 4050 4140 1\001
4 1 0 100 0 18 20 0.0000 4 210 1095 6660 4140 TF:sens\001
4 1 0 100 0 18 20 0.0000 4 195 150 9225 4140 0\001
4 1 4 100 0 18 20 0.0000 4 270 1935 12015 4140 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 270 1920 1440 540 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 195 150 4050 540 1\001
4 1 0 100 0 18 20 0.0000 4 195 150 9225 540 0\001
4 1 4 100 0 18 20 0.0000 4 270 2115 12015 540 SS:[Actual_out]\001
4 1 0 100 0 18 20 0.0000 4 210 825 9180 2340 AE:ae\001
4 1 0 100 0 18 20 0.0000 4 210 750 4050 2340 AF:af\001
4 1 0 100 0 18 20 0.0000 4 210 1260 6660 540 TF:actual\001

Added mtt/lib/comp/compound/Sensitivity/sTF/sTF_lbl.txt version [6977eeb4be].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sTF (sTF_lbl.txt)
%SUMMARY sTF TF component with sensitivity ports
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/08/26 01:34:59  peterg
% %% Summary line added
% %%
% %% Revision 1.2  1999/08/26 01:22:25  peterg
% %% New alias $1 flow,k
% %%
% %% Revision 1.1  1999/08/26 00:15:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	flow,k
%ALIAS	$2	k_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	ae		lin		effort,-k_s

% Component type AF
	af		lin		flow,k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

% Component type TF
	actual		lin	flow,k
	sens		lin	flow,k

Added mtt/lib/comp/compound/Sensitivity/sTF/testsTF_abg.fig version [136b338a92].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 2925 6075 2925 5850 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 2700 2250 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2925 3600 2925 3375 3150
4 1 0 100 0 18 18 0.0000 4 210 930 4185 3060 sTF:stf\001
4 1 0 100 0 18 18 0.0000 4 270 1050 1620 3015 SS:ss_1\001
4 1 0 100 0 18 18 0.0000 4 270 1050 6750 3015 SS:ss_2\001
4 1 4 100 0 18 14 0.0000 4 210 450 2385 2700 [1,2]\001
4 1 4 100 0 18 14 0.0000 4 210 450 6030 2790 [1,2]\001

Added mtt/lib/comp/compound/Sensitivity/sTF/testsTF_lbl.txt version [11d70877b9].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY testsTF
#DESCRIPTION Detailed description here

## System testsTF, representation lbl, language txt
## File testsTF_lbl.txt
## Generated by MTT on Thu Aug  9 12:38:50 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases

## Argument aliases
#ALIAS	$1	k
#ALIAS	$2	k_s

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 
	ss_1	SS		external,external		
	ss_2	SS		external,external		

## Component type sTF
	stf	slin		flow,n;n_s

Added mtt/lib/comp/compound/Thermal/CT/CT_abg.fig version [2a418d3ee2].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5850 3825 5850 1575 225 1575 225 3825 5850 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2700 5625 2700 5400 2925
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2475 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3105 S\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2835 .\001
4 2 4 0 0 0 20 0.0000 4 240 810 1980 2790 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 630 3825 2790 FP:fp\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2475 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 4950 3105 Q\001
4 1 1 1 0 3 20 0.0000 4 195 165 4950 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 4995 2835 .\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5940 2790 C:c\001

Added mtt/lib/comp/compound/Thermal/CT/CT_desc.tex version [7676ba8d58].








1
2
3
4
5
6
7
+
+
+
+
+
+
+

Component \textbf{CT} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{C} component.

 

Added mtt/lib/comp/compound/Thermal/CT/CT_lbl.txt version [ee5a8364ff].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CT: One-port thermal C component with T/Sdot bond
%DESCRIPTION CR and parameters as for a one-port C component
%DESCRIPTION Internally pseudo
%DESCRIPTION Example label file entry:
%DESCRIPTION % Component type CT
%DESCRIPTION 	c		lin	effort,c

%Port aliases
%ALIAS		Thermal|out	in

%CR aliases
%ALIAS          $1		effort,c_t
%ALIAS          $a1		lin

%% Label file for system CT (CT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2001/07/03 22:59:10  gawthrop
% %% Fixed problems with argument passing for CRs
% %%
% %% Revision 1.6  2001/06/13 17:10:26  gawthrop
% %% Alias for the cr (ie ALIAS	$1	lin)
% %%
% %% Revision 1.5  2001/06/11 15:09:18  gawthrop
% %% Removed spurious parameter
% %%
% %% Revision 1.4  1998/07/22 11:28:15  peterg
% %% Out as port alias
% %%
% %% Revision 1.3  1998/07/22 11:27:41  peterg
% %% Changed port name
% %%
% %% Revision 1.2  1998/06/29 10:12:58  peterg
% %% Converted to FP component
% %% Removed FP label
% %%
% %% Revision 1.1  1997/09/04  09:49:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c		lin		effort,c_t

% Component type FP
        fp

% Component type SS
	[in]		SS	external,external

Added mtt/lib/comp/compound/Thermal/CT2/CT2.cr version [46957c5ad0].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CT2    Constitutive Relationship for a two port thermo C
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.
%DESCRIPTION Parameter 4: t_0 -- the temperature at which internal
%DESCRIPTION energy is zero.

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 20:45:21  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR CT2;
Port 1 - Thermal
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,1,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,2,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = (gamma-1)*(InternalEnergy+c_v*m*t_0)/Volume;

END;

Added mtt/lib/comp/compound/Thermal/CT2/CT2_abg.fig version [4aa81090a9].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 5400 4050 5400 3825 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5400 4725 5400 4950 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 5175 2700 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2025 2475 3375 2700 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3825 6525 5175 6750 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3375 6525 2025 6750 2250
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 5085 5895 5085 4950 3690 4950 3690 5895 5085 5895
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 2024 6750 3262 5512
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 5175 2700 5625
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 5175 6075 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6525 5625 6525 6750 4500 6750 4725 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 2475 5625 2475 6750 4050 6750 3825 6975
4 1 4 0 0 0 20 0.0000000 4 240 345 2250 4005 [e]\001
4 1 4 0 0 0 20 0.0000000 4 240 330 2250 3375 [s]\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 2430 5490 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 420 4410 5490 C:c\001
4 1 -1 0 0 0 20 0.0000000 4 270 690 6525 5490 PS:ps\001
4 0 4 0 0 0 20 0.0000000 4 270 960 6660 5850 [power]\001
4 1 -1 0 0 0 20 0.0000000 4 210 690 2430 3690 ES:es\001
4 1 4 0 0 0 20 0.0000000 4 240 870 2475 1845 SS:[in]\001
4 2 4 0 0 0 20 0.0000000 4 240 600 5985 5265 [out]\001
4 0 4 0 0 0 20 0.0000000 4 240 450 6750 5175 [in]\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 6435 3690 0\001
4 1 4 0 0 0 20 0.0000000 4 240 1020 6480 1890 SS:[out]\001
4 1 1 1 0 3 20 0.0000000 4 240 2340 6480 1530 Mechanical Power\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2160 2700 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6300 2700 P\001
4 0 1 1 0 3 20 0.0000000 4 210 675 6660 2700 dV/dt\001
4 1 1 1 0 3 20 0.0000000 4 240 1935 2475 1530 Thermal Power\001
4 0 1 1 0 3 20 0.0000000 4 210 720 2610 4365 dH/dt\001
4 1 1 1 0 3 20 0.0000000 4 255 840 1935 4365 T-T_0\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6300 4365 P\001
4 0 1 1 0 3 20 0.0000000 4 210 855 6705 4365 -dV/dt\001
4 2 1 1 0 3 20 0.0000000 4 210 1755 2025 6660 dH/dt-PdV/dt\001
4 1 1 1 0 3 20 0.0000000 4 270 1485 4365 4770 Two-port C\001
4 1 4 0 0 0 20 0.0000000 4 240 450 4050 5265 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 600 4770 5265 [out]\001
4 0 1 1 0 3 20 0.0000000 4 210 855 4005 7335 PdV/dt\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 4230 6840 1\001

Added mtt/lib/comp/compound/Thermal/CT2/CT2_desc.tex version [2ac31e428a].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system CT2 (CT2_desc.tex)
% Generated by MTT on Thu Dec 4 16:00:14 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 20:29:56  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CT2} is
   displayed in Figure \Ref{CT2_abg} and its label
   file is listed in Section \Ref{sec:CT2_lbl}.
   The subsystems are listed in Section \Ref{sec:CT2_sub}.

\textbf{CT2} is a two port thermal capacitor representing an ideal
heat engine converting heat to work without energy loss. There are two
ports {\bf [in]} (with covariables Temperature (absolute) and
entropy flow) and {\bf [out]} with covariables Pressure and rate of
change of volume. 

Rather than using the corresponding (nonlinear) Constitutive
Relationship (with entropy and volume as states) directly, the
component is built up from a {\em linear\/} two-port capacitor with
internal energy and volume as states. The {\bf ES} component provides
the conversion from the pseudo Bond Graph with temperature (relative)
and enthalpy flow as covariables to the true Bond Graph with with
covariables Temperature (absolute) and entropy flow.

The power-sensor {\bf PS} component is used to subtract the work enrgy
from the internal energy.







Added mtt/lib/comp/compound/Thermal/CT2/CT2_lbl.txt version [db65e0d0b3].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CT2: Two-port thermal C component - a heat engine.
%DESCRIPTION Port [in]: a (true) thermal bond 
%DESCRIPTION Port [out]: a mechanical (P, dV/dT) bond.
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.
%DESCRIPTION Parameter 4: t_0 -- the temperature at which internal
%DESCRIPTION energy is zero.

%% Label file for system CT2 (CT2_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C	c_v,gamma,m,t_0
	c	CT2	$1,$2,$3,$4

% Component type ES
	es

% Component type PS
	ps

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

	
	

Added mtt/lib/comp/compound/Thermal/CU/CU_abg.fig version [1ce5cce7a3].


































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 3375 2250 3375 2025 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 3375 3825 3375 3600 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 3375 5400 3375 5175 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 5175 4725 4050 4725 4050 3600 4275 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3375 7200 3375 6975 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 3375 8775 3375 8550 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9225 3375 10350 3375 10125 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10800 3375 11925 3375 11700 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 9000 3600 9000 4725 6075 4725 6300 4950
4 1 -1 0 0 2 20 0.0000 4 195 360 2475 3465 FP\001
4 1 -1 0 0 2 20 0.0000 4 195 135 4050 3465 0\001
4 1 4 0 0 2 16 0.0000 4 210 270 2160 3105 [f]\001
4 1 4 0 0 2 16 0.0000 4 225 315 2835 3105 [p]\001
4 1 1 1 0 3 22 0.0000 4 225 195 1440 3150 T\001
4 1 1 1 0 3 22 0.0000 4 225 195 3240 3150 T\001
4 1 1 1 0 3 22 0.0000 4 225 195 4815 3150 T\001
4 1 1 1 0 3 22 0.0000 4 285 720 4815 3825 Q-W\001
4 1 1 1 0 3 22 0.0000 4 285 240 3240 3825 Q\001
4 1 1 1 0 3 30 0.0000 4 60 120 3285 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 195 1440 3825 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 1485 3555 .\001
4 1 1 1 0 3 30 0.0000 4 60 120 4590 3555 .\001
4 1 1 1 0 3 30 0.0000 4 60 120 5040 3555 .\001
4 1 -1 0 0 2 20 0.0000 4 195 360 7425 3465 FP\001
4 1 -1 0 0 2 20 0.0000 4 195 360 10575 3465 FP\001
4 1 -1 0 0 2 20 0.0000 4 195 135 9000 3465 1\001
4 0 4 0 0 2 20 0.0000 4 240 990 12060 3465 SS:[out]\001
4 1 4 0 0 2 16 0.0000 4 210 270 10935 3105 [f]\001
4 1 4 0 0 2 16 0.0000 4 210 270 7110 3105 [f]\001
4 1 4 0 0 2 16 0.0000 4 225 315 7785 3105 [p]\001
4 1 4 0 0 2 16 0.0000 4 225 315 10260 3105 [p]\001
4 1 1 1 0 3 22 0.0000 4 225 195 6615 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 195 9765 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 195 11385 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 225 11385 3825 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 11430 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 285 9765 3825 W\001
4 1 1 1 0 3 30 0.0000 4 60 120 9810 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 225 6615 3825 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 6660 3555 .\001
4 1 -1 0 0 2 20 0.0000 4 195 405 5715 3465 C:c\001
4 1 1 1 0 3 22 0.0000 4 225 195 8190 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 285 8190 3825 W\001
4 1 1 1 0 3 30 0.0000 4 60 120 8235 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 195 8190 4500 P\001
4 1 1 1 0 3 22 0.0000 4 225 285 8190 5175 W\001
4 1 1 1 0 3 30 0.0000 4 60 120 8235 4905 .\001
4 2 4 0 0 2 20 0.0000 4 240 825 990 3465 SS:[in]\001
4 1 -1 0 0 2 20 0.0000 4 195 690 5625 4815 AF:af\001
4 1 1 1 0 3 22 0.0000 4 300 1275 900 4275 Heat port\001
4 1 1 1 0 3 22 0.0000 4 315 1305 11295 4275 Work port\001

Added mtt/lib/comp/compound/Thermal/CU/CU_cr.r version [796052bb26].
















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CU    Constitutive Relationship for a two port thermo C
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.


%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:34:56  peterg
% %% Put under RCS
% %%
% %% Revision 1.1  1997/12/07 20:45:21  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR CU;

%% Integral/Integral causality
Port 1 - Thermal
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,1,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,2,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = (gamma-1)*(InternalEnergy)/Volume;

%% Derivative/Integral causality
Port 1 - Thermal
FOR ALL COMPONENT,  c_v,gamma,m,Temperature,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,state,1,
	Temperature, effort, 1,
	Volume, state, 2)
         = Temperature*(m*c_v);

Port 2 - Mechanical
FOR ALL COMPONENT,  c_v,gamma,m,Temperature,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,2,
	Temperature, effort, 1,
	Volume, state, 2)
         = (gamma-1)*(m*c_v)*(Temperature)/Volume;

%% Integral/Derivative causality
Port 1 - Thermal
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Pressure
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,1,
	InternalEnergy, state, 1,
	Pressure, effort, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Pressure
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,state,2,
	InternalEnergy, state, 1,
	Pressure, effort, 2)
         = (gamma-1)*(InternalEnergy)/Pressure;


END;

Added mtt/lib/comp/compound/Thermal/CU/CU_lbl.txt version [d81160e763].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CU
%DESCRIPTION <Detailed description here>
%% Label file for system CU (CU_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Component type AF (gain of -1)
	af		lin		-1

% Component type C
	c		CU		$1

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Comb/Comb_abg.fig version [61d53b3fc6].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4953 2928 6528 2928 6303 3153
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2476 2926 4051 2926 3826 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2476 4051 4051 4051 3826 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 4051 6526 4051 6301 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 5618 4501 4493 4726 4718
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6978 2925 8553 2925 8328 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6978 4050 8553 4050 8328 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 2693 6750 1568 6975 1793
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 4268 6750 5393 6975 5168
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6480 1575 6975 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6480 5400 6975 5400
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 6300 11025 675 225 675 225 6300 11025 6300
4 2 4 0 0 0 20 0.0000 4 255 2085 2436 4101 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2438 3023 SS:[Thermal_in]\001
4 2 4 0 0 0 12 0.0000 4 180 540 4102 3337 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 4147 3922 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 5002 3922 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 5002 3337 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1470 4504 3649 hPipe:pipe\001
4 1 1 1 0 3 20 0.0000 4 195 135 2933 3968 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 2798 4238 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2798 3878 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2798 4508 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 2842 2752 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2977 2842 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2977 3517 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2842 3382 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2842 3112 .\001
4 1 4 0 0 0 20 0.0000 4 240 1140 4501 5986 SS:[Heat]\001
4 1 1 1 0 3 30 0.0000 4 60 120 7933 4244 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 7933 3884 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 7933 4514 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 8068 3974 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7933 2713 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8068 2803 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7933 3343 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 7933 3073 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 8068 3478 2\001
4 0 4 0 0 0 20 0.0000 4 255 2235 8696 4197 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 8651 3026 SS:[Thermal_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6750 3060 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6750 4140 0\001
4 1 -1 0 0 22 20 0.0000 4 210 675 6705 5715 SS:P\001
4 1 -1 0 0 22 20 0.0000 4 210 645 6705 1440 SS:T\001
4 1 4 0 0 0 12 0.0000 4 180 495 4501 4366 [Heat]\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Comb/Comb_desc.tex version [67dab7f8b9].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Comb (Comb_desc.tex)
% Generated by MTT on Tue Mar 31 15:58:34 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Comb} is
   displayed in Figure \Ref{Comb_abg} and its label
   file is listed in Section \Ref{sec:Comb_lbl}.
   The subsystems are listed in Section \Ref{sec:Comb_sub}.
   
   This thermal tank model has been developed to represent an ideal
   (and non-dynamic) combustion chamber for a gas turbine. The major
   simplification is that the mass contained in the tank is assumed
   constant -- this is consistent with using an ideal compressor and an
   ideal turbine with identical mass flows. Energy conservatioin is
   ensured by using true bonds and \textbf{TF} components.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Comb/Comb_lbl.txt version [cfaa583e32].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Comb: Combustion chamber model

%DESCRIPTION   This thermal tank model has been developed to represent an ideal
%DESCRIPTION   (and non-dynamic) combustion chamber for a gas turbine. The major
%DESCRIPTION   simplification is that the mass contained in the tank is assumed
%DESCRIPTION   constant -- this is consistent with using an ideal compressor and an
%DESCRIPTION   ideal turbine with identical mass flows. Energy conservation is
%DESCRIPTION   ensured by using true bonds and components.
 
%ALIAS	in Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	$1	m_c
%ALIAS	$2	v_c
%ALIAS	$3	r

%ALIAS	hPipe	CompressibleFlow/hPipe

%% Label file for system Comb (Comb_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.6  1998/07/04 08:24:25  peterg
% %% New-style SS
% %%
% %% Revision 1.5  1998/07/03 14:55:33  peterg
% %% Aliased parameters.
% %% Removed _c from parameters,
% %%
% %% Revision 1.4  1998/07/02 19:46:34  peterg
% %% New aliases
% %%
% %% Revision 1.3  1998/07/02 10:54:42  peterg
% %% Lower case in out
% %%
% %% Revision 1.2  1998/07/02 10:49:32  peterg
% %% Added port aliases
% %%
% %% Revision 1.1  1998/05/19 09:11:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Heat]		SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	P		SS	external,0
	T		SS	external,0

% Component type hPipe
	pipe	none	m_c;v_c;r



Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_abg.fig version [3e14bcdbdd].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2476 5626 2476 5401 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 3376 5626 3376 5401 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5626 2251 5626 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5626 3151 5626 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6752 2927 7877 2927 7652 3152
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7877 2702 7877 3152
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 2475 3826 2475 3601 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 3375 3826 3375 3601 3600
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 4725 10125 1350 90 1350 90 4725 10125 4725
4 2 4 0 0 22 20 0.0000 4 270 1890 2610 2565 SS:[Pressure]\001
4 2 4 0 0 22 20 0.0000 4 270 2385 2655 3465 SS:[Temperature]\001
4 1 1 1 0 3 20 0.0000 4 195 165 5041 2251 P\001
4 1 1 1 0 3 20 0.0000 4 195 165 4996 3241 T\001
4 1 4 0 0 22 20 0.0000 4 270 330 5895 2520 [1]\001
4 1 4 0 0 22 20 0.0000 4 270 330 5895 3465 [2]\001
4 1 -1 0 0 18 30 0.0000 4 345 600 6030 3060 R:r\001
4 1 4 0 0 22 20 0.0000 4 270 330 6570 3015 [3]\001
4 1 1 1 0 32 30 0.0000 4 345 210 7337 2792 r\001
4 0 4 0 0 22 20 0.0000 4 270 1695 8146 3016 SS:[Density]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4140 2610 AE\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4140 3465 AE\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_cr.r version [e0f1508d57].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for Density (Density_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Density;

% Ideal gas
FOR ALL COMPONENT,  R,Temperature,Pressure,Nothing
LET Density(COMPONENT, density,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = Pressure/(R*Temperature);

FOR ALL COMPONENT,  R,Temperature,Pressure,Nothing
LET Density(COMPONENT, specific_volume,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = (R*Temperature)/Pressure;

% Incompressible
FOR ALL COMPONENT,  rho,Temperature,Pressure,Nothing
LET Density(COMPONENT, density,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = rho;

FOR ALL COMPONENT,  rho,Temperature,Pressure,Nothing
LET Density(COMPONENT, specific_volume,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = 1/rho;

END;

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_desc.tex version [f12aa62d5f].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Density (Density_desc.tex)
% Generated by MTT on Thu Mar 19 13:24:59 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Density} is
   displayed in Figure \Ref{Density_abg} and its label
   file is listed in Section \Ref{sec:Density_lbl}.

This three port component computes the density $\rho$ of substance in
terms of the temperature $T$ and the pressure $P$. At the moment,
there are four forms dependent on the four forms of the component parameter:
\begin{enumerate}
\item \emph{density,incompressible,rho}
\item \emph{specific\_volume,incompressible,rho}
\item \emph{density,ideal\_gas,R}
\item \emph{specific\_volume,ideal\_gas,R}
\end{enumerate}

\begin{equation}
  y = 
  \begin{cases}
    \rho & \text{if the parameter is
      \emph{density,incompressible,rho}}\\
    \frac{1}{\rho} & \text{if the parameter is
      \emph{specific\_volume,incompressible,rho}}\\
    \frac{P}{RT} & \text{if the parameter is \emph{density,ideal\_gas,R}}\\
    \frac{RT}{P} & \text{if the parameter is
      \emph{specific\_volume,ideal\_gas,R}}
  \end{cases}
\end{equation}
where $\rho$ is the density of the incompressible fluid and $R$ the
universal gas constant of the ideal gas.

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_lbl.txt version [9d2703c643].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Density - Computes  P and T.

%DESCRIPTION Parameter: density,ideal_gas,gas_constant
%DESCRIPTION OR       : specific_volume,ideal_gas,gas_constant
%DESCRIPTION OR       : density,incompressible,gas_constant
%DESCRIPTION OR       : specific_volume,incompressible,gas_constant
%DESCRIPTION Port [P]: Pressure
%DESCRIPTION Port [T]: Temperature
%DESCRIPTION Port [rho]: Density

%ALIAS	P	Pressure
%ALIAS	T	Temperature
%ALIAS	rho|out	Density

%ALIAS	$1	density,ideal_gas,r



%% Label file for system Density (Density_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type R
	r		Density		density,ideal_gas,r

% Component type SS
	[Pressure]	SS		external,external
	[Temperature]	SS		external,external
	[Density]	SS		external,external

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/ICV/ICV_abg.fig version [3ae1de99d6].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4503 2928 6078 2928 5853 3153
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 2926 3601 2926 3376 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 4051 3601 4051 3376 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 4051 6076 4051 5851 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6528 2925 8103 2925 7878 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6528 4050 8103 4050 7878 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 6300 9900 675 225 675 225 6300 9900 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2693 6300 1568 6525 1793
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 4268 6300 5393 6525 5168
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6030 1575 6525 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6030 5400 6525 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 4500 4320 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 4507 4050 5632 4275 5407
4 2 4 0 0 0 12 0.0000 4 180 540 3652 3337 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 3697 3922 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 4552 3922 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 4552 3337 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1470 4054 3649 hPipe:pipe\001
4 1 1 1 0 3 20 0.0000 4 195 135 2483 3968 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 2348 4238 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2348 3878 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2348 4508 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 2392 2752 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2527 2842 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2527 3517 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2392 3382 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2392 3112 .\001
4 2 4 0 0 0 20 0.0000 4 255 1290 1896 4191 SS:[Hy_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1275 1943 3023 SS:[Th_in]\001
4 1 4 0 0 22 12 0.0000 4 180 540 4051 4366 [Heat]\001
4 1 -1 0 0 0 20 0.0000 4 195 570 4051 5986 CT:c\001
4 1 1 1 0 3 30 0.0000 4 60 120 7483 4244 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 7483 3884 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 7483 4514 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 7618 3974 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7483 2713 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 7618 2803 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7483 3343 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 7483 3073 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 7618 3478 2\001
4 0 4 0 0 0 20 0.0000 4 255 1440 8246 4197 SS:[Hy_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1425 8201 3026 SS:[Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6300 3060 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6300 4140 0\001
4 1 -1 0 0 22 20 0.0000 4 210 675 6255 5715 SS:P\001
4 1 -1 0 0 22 20 0.0000 4 210 645 6255 1440 SS:T\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/ICV/ICV_desc.tex version [b0103a1ae6].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ICV (ICV_desc.tex)
% Generated by MTT on Tue Mar 31 15:58:34 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ICV} is
   displayed in Figure \Ref{ICV_abg} and its label
   file is listed in Section \Ref{sec:ICV_lbl}.
   The subsystems are listed in Section \Ref{sec:ICV_sub}.
   
   This thermal tank model has been developed to represent an
   inter-volume component (ICV) for a gas turbine. The major
   simplification is that the mass contained in the ICV is assumed
   constant -- this is consistent with using an ideal compressor and an
   ideal turbine with identical mass flows. Energy conservation is
   ensured by using true bonds and \textbf{TF} components.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/ICV/ICV_lbl.txt version [65e966e572].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY ICV Inter-component volume for a gas turbine.
%DESCRIPTION Parameter 1 Thermal capacity (c)

%% Label file for system ICV (ICV_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CT
	c		lin		effort,$1

% Component type SS
	[Hy_in]		external	external
	[Hy_out]	external	external
	[T]		external	external
	[Th_in]		external	external
	[Th_out]	external	external
	P		external	0
	T		external	0

% Component type hPipe
	pipe	none	m_c;v_c;r

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_abg.fig version [de507d7428].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 2927 6977 2927 6752 3152
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 2926 4051 2926 3826 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 2701 4051 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 2925 2251 2925 2026 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 2026 4051 2026 3826 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 1801 4051 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 2025 2251 2025 2026 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 3826 4051 3826 3826 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 3601 4051 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 3825 2251 3825 2026 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 4949 4951 3824 5176 4049
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 3824 5176 3824
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 6749 4950 5624 5175 5849
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 2700 5850 3150
4 1 4 0 0 22 20 0.0000 4 270 330 5670 3015 [5]\001
4 1 1 1 0 22 20 0.0000 4 150 255 6437 2792 m\001
4 0 4 0 0 22 20 0.0000 4 270 2055 7246 3016 SS:[MassFlow]\001
4 1 -1 0 0 18 30 0.0000 4 345 600 5040 3060 R:r\001
4 1 1 1 0 3 20 0.0000 4 195 165 3466 2701 P\001
4 1 4 0 0 22 20 0.0000 4 270 330 4320 2970 [2]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 2565 3060 AE\001
4 2 4 0 0 22 20 0.0000 4 270 1005 1080 3015 SS:[P2]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3466 1801 P\001
4 1 4 0 0 22 20 0.0000 4 270 330 4320 2070 [1]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 2565 2160 AE\001
4 2 4 0 0 22 20 0.0000 4 270 1005 1080 2115 SS:[P1]\001
4 1 1 1 0 3 20 0.0000 4 195 135 3601 1981 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3601 2881 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 6436 2566 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3421 3691 T\001
4 1 4 0 0 22 20 0.0000 4 270 330 4320 3915 [3]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 2565 3915 AE\001
4 2 4 0 0 22 20 0.0000 4 270 975 1080 3915 SS:[T1]\001
4 1 1 1 0 3 20 0.0000 4 195 135 3601 3781 1\001
4 1 4 0 0 22 20 1.5708 4 270 330 5040 3555 [4]\001
4 1 -1 0 0 18 20 1.5708 4 210 405 5040 5310 AE\001
4 2 4 0 0 22 20 1.5708 4 270 1305 5040 6795 SS:[Area]\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_cr.r version [d6639e6e67].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for NozzleFlow (NozzleFlow_cr.r)
% Generated by PJG at Wed Apr 8 09:30 GMT 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



OPERATOR NozzleFlow;
% Ideal gas - but polytropic expansion
FOR ALL R, n, p1, p2, T1, A, Nothing
LET NozzleFlow(R,n,flow,5,
	p1,effort,1,
	p2,effort,2,
	T1,effort,3,
	A,effort,4,
	Nothing,effort,5
	) = A*p1*( (2*n/(n-1)) * (1/(R*T1)) * 
                ((p2/p1)^(2/n)) * (1 - (p2/p1)^(n-1/n) ) ^(1/2)
                );

END;

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_desc.tex version [d6b48465a1].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system NozzleFlow (NozzleFlow_desc.tex)
% Generated by MTT on Thu Mar 19 13:24:59 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{NozzleFlow} is
   displayed in Figure \Ref{NozzleFlow_abg} and its label
   file is listed in Section \Ref{sec:NozzleFlow_lbl}.

This 5 port component computes the mass flow in a polytropic
convergent nozzle from the formula:
\begin{equation}
  \dot m = A p_1 \sqrt{\frac{2n}{n-1}\frac{1}{RT_1} 
   \left ( \frac{p_2}{p_1} \right )^\frac{2}{n}
    \left [ 1- \left ( \frac{p_2}{p_1} \right )^\frac{n-1}{n} \right ]  }
\end{equation}

where:
\begin{itemize}
\item $n$ is the coefficient of polytropic expansion and
\item $R$ is the universal gas constant.
\end{itemize}

If the expansion is isentropic
\begin{equation}
  n=\gamma=\frac{c_p}{c_v}
\end{equation}
whre $c_p$ and $c_v$ are the spesicfic heats at constant pressure and volume.

Typical values for air are 
\begin{equation}
  \begin{align}
    R &= 287 \text{Nm}\text{kg}^{-1}{K}^{-1}\\
    \gamma &= 1.4
  \end{align}
\end{equation}

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_lbl.txt version [c51871a280].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY NozzleFlow Subsonic ideal gas nozzle flow with polytropic expansion
%DESCRIPTION Polytropic expansion coefficient n=gamma=c_p/c_v for isentropic expansion.
 

%ALIAS $1	R	Ideal gas constant
%ALIAS $2	n	Index of polytropic expansion

%% Label file for system NozzleFlow (NozzleFlow_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type R
	r		NozzleFlow	R,n

% Component type SS
	[Area]		SS	external,external
	[MassFlow]	SS	external,external
	[P1]		SS	external,external
	[P2]		SS	external,external
	[T1]		SS	external,external

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_rep.txt version [14692cdf88].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system NozzleFlow (NozzleFlow_rep.txt)
# Generated by MTT on" Thursday September 24 09:49:01 BST 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt NozzleFlow abg tex			# The system description

# Uncomment the following lines or add others
mtt NozzleFlow ode tex	        # The system ode 
# mtt NozzleFlow sspar tex		# Steady-state parameters
# mtt NozzleFlow ss tex 		# Steady state
# mtt NozzleFlow sm tex			# State matrices (of linearised system)
# mtt NozzleFlow lmfr ps		# log modulus of frequency response (of linearised system)
# mtt NozzleFlow simpar tex		# Simulation parameters
# mtt NozzleFlow numpar tex		# Numerical simulation parameters
# mtt NozzleFlow input tex		# Simulation input
# mtt NozzleFlow odeso ps		# Simulation output

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_abg.fig version [af2780bc2d].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 2027 5852 2027 5627 2252
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5852 1802 5852 2252
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2026 4052 2026 3827 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 2702 5852 2702 5627 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2701 4052 2701 3827 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 3377 5852 3377 5627 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5852 3152 5852 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 3376 4052 3376 3827 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7428 2703 8553 2703 8328 2928
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 2478 5850 2928
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9003 2700 10128 2700 9903 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8778 4050 8778 2925 9003 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 2925 8775 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8775 4050 9000 4050
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13050 5625 135 5625 135 1125 13050 1125 13050 5625
4 1 -1 0 0 18 20 0.0000 4 210 405 4366 2161 AE\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4366 2836 AE\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4366 3466 AE\001
4 2 4 0 0 22 20 0.0000 4 270 2190 2881 2116 SS:[Pressure_1]\001
4 2 4 0 0 22 20 0.0000 4 270 2190 2881 2791 SS:[Pressure_2]\001
4 2 4 0 0 22 20 0.0000 4 270 2685 2881 3466 SS:[Temperature_1]\001
4 1 -1 0 0 18 30 0.0000 4 345 600 6706 2836 R:r\001
4 1 4 0 0 22 20 0.0000 4 270 330 6120 2790 [2]\001
4 1 4 0 0 22 20 0.0000 4 270 330 6120 3465 [3]\001
4 1 4 0 0 22 20 0.0000 4 270 330 6120 2115 [1]\001
4 1 4 0 0 22 20 0.0000 4 270 330 7245 2790 [4]\001
4 0 4 0 0 22 20 0.0000 4 270 2685 10260 2790 SS:[Temperature_2]\001
4 1 -1 0 0 18 20 0.0000 4 210 1080 8775 4410 SS:zero\001
4 1 -1 0 0 18 20 0.0000 4 195 150 8820 2790 1\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_cr.r version [60c0a3c72c].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for Poly (Poly_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Poly;

% Ideal gas

% Temperature output on port [T2]
FOR ALL COMPONENT,  alpha,P1,P2,T1,Nothing
LET Poly(COMPONENT, alpha,effort,4,
	P1,effort,1,
	P2,effort,2,
	T1,effort,3,
	Nothing,flow,4
	) = T1*(P2/P1)^alpha;



END;

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_desc.tex version [0fc0fe1509].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Poly (Poly_desc.tex)
% Generated by MTT on Thu Mar 19 13:24:59 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/03/31 15:05:33  peterg
% %% Spell checked
% %%
% %% Revision 1.2  1998/03/27 10:56:14  peterg
% %% Added bicausal bit
% %%
% %% Revision 1.1  1998/03/26 15:13:35  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Poly} is
   displayed in Figure \Ref{Poly_abg} and its label
   file is listed in Section \Ref{sec:Poly_lbl}.

This four-port component computes the temperature following a
polytropic expansion using:
\begin{equation}
  T_2 = T_1 \left ( \frac{P_2}{P_1} \right )^\alpha
\end{equation}
where $\alpha = \frac{n-1}{n}$ and $n$ is the coefficient of
polytropic expansion.  This component imposes zero flow at all its
ports and therefore does not affect energy balance.

The output is \emph{bicausal} as it imposes both $T_2$ and a zero flow.
This is implemented using the bicausal \textbf{SS} component labeled
``zero''.

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_lbl.txt version [5420451ef5].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Poly - computes polytropic expansion temperature.
%DESCRIPTION Parameter: alpha = (n-1)/n (n = polytropic index)

%DESCRIPTION This four-port component computes the temperature following
%DESCRIPTION a polytropic expansion using where alpha = (n-1)/n and n is
%DESCRIPTION the coefficient of polytropic expansion.  This component
%DESCRIPTION imposes zero flow at all its ports and therefore does not
%DESCRIPTION affect energy balance.  The output is bicausal as it
%DESCRIPTION imposes both T_2 and a zero flow.  This is implemented using
%DESCRIPTION the bicausal SS component labeled ``zero''.

%ALIAS	P1	Pressure_1
%ALIAS	P2	Pressure_2
%ALIAS	T1	Temperature_1
%ALIAS	T2|out	Temperature_2

%ALIAS $1	alpha

%% Label file for system Poly (Poly_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/27 10:48:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type R
	r		Poly		alpha

% Component type SS
	zero		SS		0,0
	[Pressure_1]	SS		external,external
	[Temperature_1]	SS		external,external
	[Pressure_2]	SS		external,external
	[Temperature_2]	SS		external,external

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Pump/Pump_abg.fig version [dbddf488a0].


























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7203 2028 8778 2028 8553 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 2026 6301 2026 6076 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6301 3151 6076 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2703 2028 4278 2028 4053 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2656 3151 4683 3151 4458 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8776 3151 10803 3151 10578 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 3151 8326 3151 8101 3376
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4501 1801 4501 901 6076 901 5851 1126
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4951 2926 4951 1351 6076 1351 5851 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 7426 901 9001 901 9001 1801 9226 1576
2 1 0 2 5 -1 0 0 -1 0.000 0 0 -1 0 0 4
	 8551 2926 8551 1351 7426 1351 7651 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6755 7969 6755 6844 6980 7069
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6754 6371 6754 5246 6979 5471
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6752 4751 6752 3626 6977 3851
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9228 2025 10803 2025 10578 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11704 2028 13279 2028 13054 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9225 1800 10125 900 10125 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10013 788 10238 1013
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15705 8550 15705 225 225 225 225 8550 15705 8550
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 7965 6975 7965
4 2 4 0 0 0 20 0.0000 4 255 1935 2617 2122 SS:[Thermal_in]\001
4 2 4 0 0 0 20 0.0000 4 255 2085 2615 3245 SS:[Hydraulic_in]\001
4 2 4 0 0 0 12 0.0000 4 180 540 6352 2437 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 6397 3022 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 7252 3022 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 7252 2437 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 9047 2117 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 10181 3297 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 10181 2937 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 10181 3567 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 10316 3027 2\001
4 0 4 0 0 0 20 0.0000 4 255 2235 10944 3250 SS:[Hydraulic_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1305 6796 1261 Poly:poly\001
4 2 4 0 0 22 12 0.0000 4 180 345 7291 856 [T2]\001
4 2 4 0 0 22 12 0.0000 4 180 345 7336 1531 [P2]\001
4 0 4 0 0 22 12 0.0000 4 180 345 6211 856 [T1]\001
4 0 4 0 0 22 12 0.0000 4 180 345 6211 1531 [P1]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 8596 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4951 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4501 2161 0\001
4 1 4 0 0 0 20 0.0000 4 240 1215 6755 8330 SS:[Shaft]\001
4 1 1 1 0 32 30 0.0000 4 240 195 6530 7610 t\001
4 1 1 1 0 32 30 0.0000 4 240 285 6980 7610 w\001
4 1 4 0 0 0 12 0.0000 4 180 540 6751 3421 [Work]\001
4 1 -1 0 0 22 20 0.0000 4 210 750 11250 2115 EBTF\001
4 1 1 1 0 3 20 0.0000 4 195 165 12657 1767 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 12792 1857 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 12657 2397 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 12657 2127 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 12792 2532 2\001
4 0 4 0 0 0 20 0.0000 4 255 2085 13375 2080 SS:[Thermal_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1530 6754 2749 wPipe:pipe\001
4 1 -1 0 0 22 20 0.0000 4 210 645 10305 765 SS:T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3157 3022 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3022 3292 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3022 2932 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 3022 3562 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 3066 1806 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3201 1896 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3201 2571 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3066 2436 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3066 2166 .\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6755 6710 1\001
4 1 -1 0 0 22 20 0.0000 4 270 915 6800 5090 TF:k_p\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Pump/Pump_desc.tex version [ec8169ffc6].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Pump (Pump_desc.tex)
% Generated by MTT on Fri Mar 20 15:53:12 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/01 08:09:06  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pump} is
   displayed in Figure \Ref{Pump_abg} and its label
   file is listed in Section \Ref{sec:Pump_lbl}.
   The subsystems are listed in Section \Ref{sec:Pump_sub}.

\textbf{Pump} represents an ideal pumping component for compressible
or incompressible flow though a pipe, it may also be used as a turbine.

The pump is ideal in the sense that the mass flow rate $\dot m$
depends only on the shaft speed $\omega$:
\begin{equation}
  \dot m = k_p \omega
\end{equation}

It is implemented using three components:
\begin{itemize}
\item the ideal isentropic \textbf{wPipe} component which gives the
  correct energy flows
\item the polytropic expansion \textbf{Poly} component which imposes
  the correct temperature at the output of the pump. This component
  imposes zero flow at all its ports and therefore does not affect
  energy balance. It has a bicausal output imposing both the
  temperature measured by the \textbf{SS} component ``T'' and a zero
  flow.
\item the \emph{effort-bicausal transformer} \textbf{EBTF}
  component. This component is an energy-conserving \textbf{TF}
  component with non-standard causality. The modulus is determined by
  the two imposed efforts ($T$ and $T_2$), and this modulus determines
  the flows in the usual way. In particular, it makes sure that the
  internal energy flowing from the pump to the following components
  (imposing $T_2$) is correct.
\end{itemize}

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Pump/Pump_lbl.txt version [968ba1a760].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Pump Ideal pump component for compressible flow

%DESCRIPTION Pump represents an ideal pumping component for compressible
%DESCRIPTION or incompressible flow though a pipe, it may also be used as a turbine.
%DESCRIPTION The pump is ideal in the sense that the mass flow rate
%DESCRIPTION depends only on the shaft speed.

%DESCRIPTION Parameter 1: c_v - specific heat of fluid
%DESCRIPTION Parameter 2: Parameter passed to Density component
%DESCRIPTION Parameter 3: alpha = (n-1)/n, n coefficient of polytropic
%DESCRIPTION expansion.
%DESCRIPTION Parameter 4: k_p pump constant: mass flow = k_p*shaft speed

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Work	Shaft

%ALIAS  $1		c_v
%ALIAS  $2		density,ideal_gas,r
%ALIAS  $3		alpha
%ALIAS  $4		flow,k_p

%ALIAS	wPipe	CompressibleFlow/wPipe
%ALIAS	Poly	CompressibleFlow/Poly

%% Label file for system Pump (Pump_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  1998/07/04 08:39:58  peterg
% %% New-style SS
% %%
% %% Revision 1.6  1998/07/03 15:02:25  peterg
% %% Work alias added
% %%
% %% Revision 1.5  1998/07/03 14:43:24  peterg
% %% Added parameter aliases
% %%
% %% Revision 1.4  1998/07/02 19:46:19  peterg
% %% New aliases
% %%
% %% Revision 1.3  1998/07/02 10:55:54  peterg
% %% Lower case in out
% %%
% %% Revision 1.2  1998/07/02 10:52:33  peterg
% %% Added port aliases
% %%
% %% Revision 1.1  1998/04/07 15:23:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type wPipe
	pipe	none			c_v;density,ideal_gas,r

% Component type Poly
	poly		Poly		alpha

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Shaft]		SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	T		SS	external,0

% Component type TF
	k_p		lin	flow,k_p

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Tank/Tank_abg.fig version [49b9e2e5c7].















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 3600 9680 3602 9455 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9900 3825 9900 5850 10125 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 6300 4725 6300 4500 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6077 6301 7202 6301 6977 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 6299 9230 6302 9005 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10575 6300 13725 6300 13500 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3600 11700 3600 11475 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 3600 13725 3600 13500 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 3825 7425 4725 7650 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 6075 7425 5175 7650 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 2228 7425 3353 7650 3128
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9675 9000 5625 9000 5625 1350 9675 1350 9675 9000
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15525 9450 15525 675 90 675 90 9450 15525 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7650 6525 8775 7650 9945 7650 9945 6750 10170 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7200 6525 6030 7695 5400 7695 5400 6750 5625 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 7657 7425 6532 7650 6757
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3600 6300 3600 6075 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3600 7200 3600 6975 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 3600 5175 3600 4950 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3600 2925 3600 2700 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 3825 5400 4725 5625 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 5175 5400 5850 5625 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 4950 4275 4950 4500 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4275 4725 4275 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5175 4950 5175 5175
4 1 1 1 0 3 20 0.0000000 4 210 150 2073 4143 1\001
4 1 1 1 0 3 20 0.0000000 4 210 165 1938 4008 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 1938 3738 .\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 7426 3691 0\001
4 1 1 1 0 3 20 0.0000000 4 210 165 13102 4012 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 13102 3742 .\001
4 1 1 1 0 3 20 0.0000000 4 210 150 13237 4147 2\001
4 0 4 0 0 0 20 0.0000000 4 240 1500 13820 3695 SS:[Th_out]\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 9901 3691 0\001
4 1 1 1 0 3 20 0.0000000 4 210 150 2029 6169 1\001
4 1 1 1 0 3 30 0.0000000 4 60 105 1894 6439 .\001
4 1 1 1 0 3 20 0.0000000 4 210 180 1894 6079 P\001
4 1 1 1 0 3 20 0.0000000 4 210 195 1894 6709 V\001
4 2 4 0 0 0 20 0.0000000 4 270 1380 1442 6392 SS:[Hy_in]\001
4 2 4 0 0 0 12 0.0000000 4 180 570 4680 6165 [Hy_in]\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 7427 6437 0\001
4 2 4 0 0 0 12 0.0000000 4 180 570 9225 6165 [Hy_in]\001
4 0 4 0 0 0 12 0.0000000 4 180 660 6076 6166 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000000 4 225 945 5401 6391 VM:v2m\001
4 1 1 1 0 3 30 0.0000000 4 60 105 13102 6488 .\001
4 1 1 1 0 3 20 0.0000000 4 210 180 13102 6128 P\001
4 1 1 1 0 3 20 0.0000000 4 210 195 13102 6758 V\001
4 1 1 1 0 3 20 0.0000000 4 210 150 13237 6218 2\001
4 0 4 0 0 0 20 0.0000000 4 270 1530 13865 6441 SS:[Hy_out]\001
4 0 4 0 0 0 12 0.0000000 4 180 660 10531 6166 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000000 4 225 945 9901 6391 VM:m2v\001
4 1 4 0 0 0 12 0.0000000 4 165 225 5402 6077 [T]\001
4 1 4 0 0 0 12 0.0000000 4 165 225 5402 6617 [P]\001
4 1 4 0 0 0 12 0.0000000 4 165 225 9902 6077 [T]\001
4 1 4 0 0 0 12 0.0000000 4 165 225 9902 6617 [P]\001
4 2 4 0 0 0 20 0.0000000 4 240 1350 1534 3694 SS:[Th_in]\001
4 1 -1 0 0 22 20 0.0000000 4 225 330 11926 3691 ES\001
4 1 4 0 0 0 12 0.0000000 4 165 195 11567 3332 [e]\001
4 1 4 0 0 0 12 0.0000000 4 165 195 12242 3332 [s]\001
4 1 -1 0 0 22 20 0.0000000 4 285 1290 7471 5041 Tankp:tank\001
4 2 4 0 0 0 12 0.0000000 4 165 315 7200 4680 [Th]\001
4 2 4 0 0 0 12 0.0000000 4 180 345 7245 5265 [Hy]\001
4 1 1 1 0 3 20 0.0000000 4 270 2400 7425 8685 Pseudo bond graph\001
4 1 4 0 0 0 20 0.0000000 4 270 1110 7426 2116 SS:[pTh]\001
4 1 4 0 0 0 20 0.0000000 4 270 1140 7426 7966 SS:[pHy]\001
4 1 -1 0 0 22 20 0.0000000 4 225 330 6570 3690 AF\001
4 1 1 1 0 3 20 0.0000000 4 210 180 13102 3382 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 13237 3472 2\001
4 1 4 0 0 0 12 0.0000000 4 165 195 2793 3378 [s]\001
4 1 4 0 0 0 12 0.0000000 4 165 195 3423 3378 [e]\001
4 1 -1 0 0 22 20 0.0000000 4 225 330 3150 3735 ES\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 5401 3691 1\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 5400 5085 0\001
4 1 -1 0 0 22 20 0.0000000 4 225 900 3735 5040 SS:zero\001
4 1 1 1 0 3 20 0.0000000 4 210 180 4999 5674 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 5134 5764 1\001
4 1 1 1 0 3 20 0.0000000 4 210 180 1938 3378 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 2073 3468 1\001
4 1 1 1 0 3 20 0.0000000 4 210 180 10358 5454 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 10493 5544 2\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Tank/Tank_desc.tex version [cb521024f4].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Tank (Tank_desc.tex)
% Generated by MTT on Tue Jan 13 18:03:04 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tank} is
   displayed in Figure \Ref{Tank_abg} and its label
   file is listed in Section \Ref{sec:Tank_lbl}.
   The subsystems are listed in Section \Ref{sec:Tank_sub}.

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Tank/Tank_lbl.txt version [4e0b60130e].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Tank - thermal storage component for compressible fluids.
%DESCRIPTION Two port thermal storage component for compressible
%DESCRIPTION fluids
%DESCRIPTION Parameter 1 Passed to Tankp subcomponent
%DESCRIPTION Parameter 2 Parameter two of density component.
%DESCRIPTION Typical label file entry:
%DESCRIPTION % Component type Tank
%DESCRIPTION   	C1	none	ideal_gas,r_g,c_p,v_t;r_g
%DESCRIPTION Port [Th_in]: Thermal flow bond (T/Sdot)
%DESCRIPTION Port [Th_out]: Thermal flow bond (T/Sdot)
%DESCRIPTION Port [Hy_in]: Hydraulic flow bond (P/Vdot)
%DESCRIPTION Port [Hy_out]: Hydraulic flow bond (P/Vdot)
%DESCRIPTION Port [pTh]: Thermal flow pseudo bond direct to tank (T/Edot)
%DESCRIPTION Port [pHy]: Hydraulic flow pseudo bond direct to tank (P/mdot)

%% Label file for system Tank (Tank_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/26 09:00:26  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hy_in]		external	external
	[Hy_out]	external	external
	[pHy]		external	external
	[pTh]		external	external
	[Th_in]		external	external
	[Th_out]	external	external
	zero		internal	internal

% Component type Tankp
	tank		none		$1

% Component type VMe
	v2m		none	density,$2
	m2v		none	specific_volume,$2


Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_abg.fig version [cbe50075c1].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2926 3646 3376 3646
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2926 946 3376 946
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 947 3151 2072 3376 1847
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3646 3151 2521 3376 2746
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5850 4275 5850 225 225 225 225 4275 5850 4275
4 1 -1 0 0 22 20 0.0000 4 210 870 3151 2431 C:tank\001
4 1 4 0 0 0 20 0.0000 4 240 915 3150 765 SS:[Th]\001
4 1 4 0 0 0 20 0.0000 4 255 930 3105 3960 SS:[Hy]\001
4 1 4 0 0 0 20 0.0000 4 240 405 2836 2026 [in]\001
4 1 4 0 0 0 20 0.0000 4 240 555 2791 2746 [out]\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_cr.r version [b03cd8ad39].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for Tankp (Tankp_cr.r)
% Generated by MTT at Thu Mar  5 10:30:23 GMT 1998

OPERATOR Tankp; 
%%%% Incompressible %%%%
%Temperature
FOR ALL c_p,c,StoredMass,StoredEnthalpy
LET Tankp(incompressible,c_p,c,effort,1,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = StoredEnthalpy/(StoredMass*c_p);

%Pressure
FOR ALL c_p,c,StoredMass,StoredEnthalpy
LET Tankp(incompressible,c_p,c,effort,2,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = StoredMass/c;

%%%% Ideal gas %%%%
%Temperature
FOR ALL R,c_p,Volume,StoredMass,StoredEnthalpy
LET Tankp(ideal_gas,R,c_p,Volume,effort,1,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = (StoredEnthalpy/(c_p*StoredMass));

%Pressure
FOR ALL R,c_p,Volume,StoredMass,StoredEnthalpy
LET Tankp(ideal_gas,R,c_p,Volume,effort,2,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = R*( ( (StoredEnthalpy/(c_p*StoredMass)))/(Volume/StoredMass) );

END;

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_desc.tex version [aa7ccbe134].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Tankp (Tankp_desc.tex)
% Generated by MTT on Fri Mar 20 12:21:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tankp} is
   displayed in Figure \Ref{Tankp_abg} and its label
   file is listed in Section \Ref{sec:Tankp_lbl}.
   The subsystems are listed in Section \Ref{sec:Tankp_sub}.

\textbf{Tankp} is a pseudo bond graph based model of a tank storing
(as the two states)
\begin{itemize}
\item enthalpy and 
\item mass
\end{itemize}

There are two versions:
\begin{itemize}
\item the incompressible version where the tank has a pressure-based
  capacitance $c_t$ and
\item the ideal-gas version were the tank has a volume  $v_t$ and $r$
  and $c_p$ are the universal gas constant and the specific heat respectively.
\end{itemize}








Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_lbl.txt version [685d1ad022].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Tankp	Pseudo bond graph model of a tank storing mass and enthalpy
%DESCRIPTION Parameter 1: EITHER
%DESCRIPTION incompressible,c OR
%DESCRIPTION ideal_gas,R,c_p,v_t

%% Label file for system Tankp (Tankp_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	tank		Tankp		$1

% Component type SS
	[Hy]		external	external
	[Th]		external	external

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Turb/Turb_abg.fig version [5566bbcbd7].






















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6528 2028 8103 2028 7878 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 2026 5626 2026 5401 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 3151 5626 3151 5401 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2028 2028 3603 2028 3378 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1981 3151 4008 3151 3783 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 3151 10128 3151 9903 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 3151 7651 3151 7426 3376
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3826 1801 3826 901 5401 901 5176 1126
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4276 2926 4276 1351 5401 1351 5176 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6751 901 8326 901 8326 1801 8551 1576
2 1 0 2 5 -1 0 0 -1 0.000 0 0 -1 0 0 4
	 7876 2926 7876 1351 6751 1351 6976 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8553 2025 10128 2025 9903 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11029 2028 12604 2028 12379 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 1800 9450 900 9450 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9338 788 9563 1013
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3619 6075 4744 6300 4519
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5194 6075 6319 6300 6094
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 6994 6075 8119 6300 7894
4 2 4 0 0 0 12 0.0000 4 180 540 5677 2437 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 5722 3022 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 6577 3022 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 6577 2437 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 8372 2117 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 9506 3297 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9506 2937 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 9506 3567 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 9641 3027 2\001
4 0 4 0 0 0 20 0.0000 4 255 1440 10269 3250 SS:[Hydraulic_out]\001
4 1 1 1 0 3 20 0.0000 4 195 135 2482 3022 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 2347 3292 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2347 2932 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2347 3562 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 2391 1806 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2526 1896 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2526 2571 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2391 2436 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2391 2166 .\001
4 2 4 0 0 0 20 0.0000 4 255 1290 1895 3245 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1275 1942 2077 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 270 1305 6121 1261 Poly:poly\001
4 2 4 0 0 22 12 0.0000 4 180 345 6616 856 [T2]\001
4 2 4 0 0 22 12 0.0000 4 180 345 6661 1531 [P2]\001
4 0 4 0 0 22 12 0.0000 4 180 345 5536 856 [T1]\001
4 0 4 0 0 22 12 0.0000 4 180 345 5536 1531 [P1]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 7921 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4276 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3826 2161 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6080 5090 1\001
4 1 1 1 0 32 30 0.0000 4 240 195 5855 7610 t\001
4 1 1 1 0 32 30 0.0000 4 240 285 6305 7610 w\001
4 1 -1 0 0 22 20 0.0000 4 210 750 10575 2115 EBTF\001
4 1 1 1 0 3 20 0.0000 4 195 165 11982 1767 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 12117 1857 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 11982 2397 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 11982 2127 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 12117 2532 2\001
4 0 4 0 0 0 20 0.0000 4 255 1425 12700 2080 SS:[Thermal_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1530 6079 2749 wPipe:pipe\001
4 1 -1 0 0 22 20 0.0000 4 210 645 9630 765 SS:T\001
4 1 -1 0 0 22 20 0.0000 4 270 825 6080 6755 TF:k_t\001
4 1 4 0 0 0 20 0.0000 4 240 1215 6120 8460 SS:[Shaft]\001
4 1 4 0 0 0 12 0.0000 4 180 495 6076 3421 [Work]\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Turb/Turb_desc.tex version [68c72a056b].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Turb (Turb_desc.tex)
% Generated by MTT on Fri Mar 20 15:53:12 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Turb} is
   displayed in Figure \Ref{Turb_abg} and its label
   file is listed in Section \Ref{sec:Turb_lbl}.
   The subsystems are listed in Section \Ref{sec:Turb_sub}.

\textbf{Turb} represents an ideal turbine component for compressible
or incompressible flow though a pipe.

It is identical to the \textbf{Pump} component (which has a more
complete description) exept for the direction of work flow.

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/Turb/Turb_lbl.txt version [62ed8c5a7a].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Turb Ideal turbine component for compressible flow
%DESCRIPTION Parameter 1: c_p - specific heat of fluid
%DESCRIPTION Parameter 2: Parameter passed to Density component
%DESCRIPTION Parameter 3: alpha = (n-1)/n, n coefficient of polytropic
%DESCRIPTION expansion.
%DESCRIPTION Parameter 4: k_t pump constant: mass flow = k_t*shaft speed

%ALIAS	in		Thermal_in,Hydraulic_in
%ALIAS	out		Thermal_out,Hydraulic_out

%ALIAS	Th_in		Thermal_in
%ALIAS	Hy_in		Hydraulic_in

%ALIAS	Th_out		Thermal_out
%ALIAS	Hy_out		Hydraulic_out

%ALIAS  $1		c_p
%ALIAS  $2		ideal_gas,r
%ALIAS  $3		alpha
%ALIAS  $4		effort,k

%% Label file for system Turb (Turb_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.5  1998/07/03 10:12:18  peterg
% %% New aliased parameter form
% %%
% %% Revision 1.4  1998/07/02 19:48:45  peterg
% %% Changed aliases
% %%
% %% Revision 1.3  1998/07/02 10:55:24  peterg
% %% Lower case in out
% %%
% %% Revision 1.2  1998/07/02 10:51:10  peterg
% %% Added port aliases
% %%
% %% Revision 1.1  1998/04/07 15:21:02  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Pipe
	pipe	none		c_p;ideal_gas,r

% Component type Poly
	poly		Poly		alpha

% Component type SS
	[Hydraulic_in]	external	external
	[Hydraulic_out]	external	external
	[Shaft]		external	external
	[Thermal_in]	external	external
	[Thermal_out]	external	external
	T		external	0

% Component type TF
	k_t		lin	effort,k




Added mtt/lib/comp/compound/Thermal/CompressibleFlow/hPipe/hPipe_abg.fig version [411e1f86bc].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5143 4050 6088 3105 6088 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 2488 1822 5210 1822 6110 2722 5840 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6313 4500 6313 3150 6538 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6538 3150 7438 4050 7213 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2445 4052 4020 4052 3795 4277
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8564 4052 10139 4052 9914 4277
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6538 2700 7438 1800 10138 1800 9913 2025
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13050 4950 45 4950 45 450 13050 450 13050 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6165 3105 6435 3105
4 1 -1 0 0 22 20 0.0000 4 195 150 6315 3017 0\001
4 1 1 1 0 3 20 0.0000 4 195 510 5865 3872 mp v\001
4 1 1 1 0 3 20 0.0000 4 195 330 6043 4050 1 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 5729 3691 .\001
4 1 1 1 0 3 20 0.0000 4 195 510 6675 3872 mp v\001
4 1 1 1 0 3 20 0.0000 4 195 330 6853 4050 2 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 6539 3691 .\001
4 2 4 0 0 22 20 0.0000 4 270 2355 2399 4141 SS:[Hydraulic_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2805 3782 P\001
4 1 1 1 0 3 20 0.0000 4 195 135 2941 4683 1\001
4 1 1 1 0 3 20 0.0000 4 195 195 2806 4548 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 2805 4277 .\001
4 2 4 0 0 22 20 0.0000 4 270 2145 2355 1892 SS:[Thermal_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2894 1531 T\001
4 0 4 0 0 22 20 0.0000 4 270 2550 10319 4187 SS:[Hydraulic_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9689 3783 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 9600 4458 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 9599 4187 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 9735 4593 2\001
4 0 4 0 0 22 20 0.0000 4 270 2340 10365 1892 SS:[Thermal_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9734 1532 T\001
4 1 -1 0 0 22 20 0.0000 4 210 945 4558 4185 TF:P2T\001
4 1 -1 0 0 22 20 0.0000 4 210 945 8068 4140 TF:T2P\001
4 1 4 0 0 22 20 0.0000 4 270 1290 6359 4771 SS:[Heat]\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/hPipe/hPipe_desc.tex version [5824e24429].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system hPipe (hPipe_desc.tex)
% Generated by MTT on Tue Mar 31 09:54:08 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{hPipe} is
   displayed in Figure \Ref{hPipe_abg} and its label
   file is listed in Section \Ref{sec:hPipe_lbl}.
   The subsystems are listed in Section \Ref{sec:hPipe_sub}.
   

\textbf{hPipe} represents an ideal (energy conserving) pipe carrying a
fluid with heat transfer. To ensure energy conservation, power bonds are used and
connected by (energy conserving) \textbf{TF} components.
It is assumed that the working fluid is an ideal gas (gas constant $r$) and that a mass
$m_t$ is stored within pipe with a volume $v_t$.

The central \textbf{0} junction carries temperature ($T$) and the two
hydraulic ports are connected to this by appropriate transformers.
The modulus of the \textbf{TF} component labeled ``P2T'' is such P and
T are related by the ideal gas law
\begin{equation}
  P = \frac{Rm_t}{v_t} T
\end{equation}

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/hPipe/hPipe_lbl.txt version [4fbc3c7372].




























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY hPipe: Pipe for compressible fluid with heat transfer and heat storage.

%DESCRIPTION hPipe represents an ideal (energy conserving) pipe carrying a
%DESCRIPTION fluid with heat transfer. To ensure energy conservation, power bonds are used and
%DESCRIPTION connected by (energy conserving) TF components.
%DESCRIPTION It is assumed that the working fluid is an ideal gas (gas constant r) and that a mass
%DESCRIPTION m_t is stored within pipe with a volume v_t.

%DESCRIPTION Parameter 1: m_t (mass in pipe)
%DESCRIPTION Parameter 2: v_t (volume of pipe)
%DESCRIPTION Parameter 3: r (gas constant)
%DESCRIPTION Typical lable entry 
%DESCRIPTION % Component type hPipe
%DESCRIPTION 	pipe		none		m_p;v_p;r

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	$1	m
%ALIAS	$2	v
%ALIAS	$3	r



%% Label file for system hPipe (hPipe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/03 17:38:32  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Heat]		SS	external,external
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

% Component type TF
	P2T		lin	flow,r*m/v
	T2P		lin	effort,r*m/v

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/wPipe/wPipe_abg.fig version [41fd44dc27].













































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1666 3781 3241 3781 3016 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3691 3781 4591 3781 4366 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3466 1756 3466 2431 3691 2206
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3466 3556 3466 2881 3691 3106
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4366 2656 5491 2656 5491 3331 5716 3106
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6392 1532 7292 2432 7022 2432
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7742 2882 8642 3782 8372 3782
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7764 2454 8664 1554 8664 1824
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6392 3782 7292 2882 7292 3152
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 10666 2658 9766 2658 9766 3333 9993 3106
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11566 1758 11566 2433 11791 2208
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11566 3558 11566 2883 11791 3108
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9766 1531 11341 1531 11116 1756
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1666 1531 3241 1531 3016 1756
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3691 1531 5266 1531 5041 1756
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11836 1533 13411 1533 13186 1758
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11791 3781 13366 3781 13141 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10411 3781 11311 3781 11086 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7515 4275 7516 3106 7741 3331
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7515 5895 7516 4726 7741 4951
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 16200 6300 45 6300 45 180 16200 180 16200 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7335 5895 7695 5895
4 2 4 0 0 22 20 0.0000 4 270 2355 2430 3915 SS:[Hydraulic_in]\001
4 2 4 0 0 22 20 0.0000 4 270 2145 2476 1666 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3466 1621 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3466 3916 0\001
4 1 4 0 0 22 12 0.0000 4 180 405 4186 2521 [rho]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 7517 2792 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11566 1623 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11566 3918 0\001
4 1 4 0 0 22 12 0.0000 4 180 405 10846 2523 [rho]\001
4 1 4 0 0 22 12 0.0000 4 180 495 9766 3558 [mod]\001
4 1 -1 0 0 22 20 0.0000 4 210 840 5851 1621 TF:t2u\001
4 1 -1 0 0 22 20 0.0000 4 270 1515 5536 3916 EMTF:p2pv\001
4 1 4 0 0 22 12 0.0000 4 180 495 5491 3601 [mod]\001
4 2 4 0 0 22 12 0.0000 4 180 240 3331 3016 [P]\001
4 2 4 0 0 22 12 0.0000 4 180 240 3331 2386 [T]\001
4 2 4 0 0 22 12 0.0000 4 180 240 11431 2386 [T]\001
4 2 4 0 0 22 12 0.0000 4 180 240 11431 3016 [P]\001
4 0 4 0 0 22 20 0.0000 4 270 2340 13591 1621 SS:[Thermal_out]\001
4 0 4 0 0 22 20 0.0000 4 270 2550 13546 3916 SS:[Hydraulic_out]\001
4 1 4 0 0 22 12 0.0000 4 180 270 4816 3601 [in]\001
4 1 4 0 0 22 12 0.0000 4 180 405 6301 3601 [out]\001
4 1 4 0 0 22 12 0.0000 4 180 405 10441 3556 [out]\001
4 1 4 0 0 22 12 0.0000 4 180 270 8911 3556 [in]\001
4 1 -1 0 0 22 20 0.0000 4 210 840 9316 1621 TF:u2t\001
4 1 -1 0 0 22 20 0.0000 4 270 1515 9631 3871 EMTF:pv2p\001
4 1 1 1 0 3 20 0.0000 4 195 135 2161 3646 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2026 3511 P\001
4 1 1 1 0 3 20 0.0000 4 195 165 12960 1261 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 13095 1396 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 13051 3647 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 12916 3512 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 12827 4187 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 12826 3916 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 12962 4322 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 2162 4412 1\001
4 1 1 1 0 3 20 0.0000 4 195 195 2027 4277 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 2026 4006 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 6841 3736 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 6841 3511 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 8101 3691 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 8101 3466 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 6570 2295 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 6570 2070 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 8461 2341 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 8461 2116 .\001
4 1 1 1 0 3 20 0.0000 4 135 150 7922 1847 u\001
4 1 1 1 0 3 20 0.0000 4 195 135 8057 1982 2\001
4 1 1 1 0 3 20 0.0000 4 195 300 6482 3062 p v\001
4 1 1 1 0 3 20 0.0000 4 195 330 6570 3240 1 1\001
4 1 1 1 0 3 20 0.0000 4 195 300 8372 3063 p v\001
4 1 1 1 0 3 20 0.0000 4 195 330 8460 3241 2 2\001
4 1 -1 0 0 22 20 0.0000 4 270 1725 3511 2791 Density:rho1\001
4 1 -1 0 0 22 20 0.0000 4 270 1725 11521 2793 Density:rho2\001
4 1 1 1 0 3 20 0.0000 4 195 135 7246 1981 1\001
4 1 1 1 0 3 20 0.0000 4 135 150 7111 1846 u\001
4 1 1 1 0 3 20 0.0000 4 195 165 2115 1260 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2250 1395 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 7517 4592 1\001
4 1 4 0 0 22 20 0.0000 4 270 1380 7516 6211 SS:[Shaft]\001

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/wPipe/wPipe_desc.tex version [25ee8a0694].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system wPipe (wPipe_desc.tex)
% Generated by MTT on Mon Mar 9 09:11:22 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{wPipe} is
   displayed in Figure \Ref{wPipe_abg} and its label
   file is listed in Section \Ref{sec:wPipe_lbl}.
   The subsystems are listed in Section \Ref{sec:wPipe_sub}.

\textbf{wPipe} represents an ideal (energy conserving) pipe carrying a
fluid with work transfer. To ensure energy conservation, power bonds are used and
connected by (energy conserving) \textbf{TF} components.

The central \textbf{1} junction carries mass flow ($\dot m$) and the
four ports are connected to this by appropriate transformers. In the
case of the hydraulic ports, these transformers are \emph{modulated}
by the corresponding fluid density.
The bonds impinging on this  \textbf{1} junction carry the
corresponding effort variables; in particular, the thermal bonds carry
specific internal energy $u$ and the hydraulic bonds carry $Pv$ where
$P$ is the pressure and $v$ the specific volume.

The ports ``Work\_in'' and ``Work\_out'' are convenient for attaching
(for example) the shadt work of a pump, turbine or compressor.

The ports are 
\begin{itemize}
\item [Hy\_in] Pressure/volume-flow inflow
\item [Hy\_in] Pressure/volume-flow outflow
\item [Th\_in] Temperature/Entropy-flow in flow
\item [Th\_out] Temperature/Entropy-flow out flow
\item [Shaft] Torque/angular velocity input.
\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/CompressibleFlow/wPipe/wPipe_lbl.txt version [abb521f401].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY wPipe Isentropic pipe with work transfer.

%DESCRIPTION wPipe represents an ideal (energy conserving) pipe carrying a
%DESCRIPTION fluid with work transfer. To ensure energy conservation, power bonds are used and
%DESCRIPTION connected by (energy conserving) TF components.

%DESCRIPTION Parameter 1: c_v - specific heat of fluid
%DESCRIPTION Parameter 2: Parameter passed to Density component
%DESCRIPTION Ports:

%DESCRIPTION [Hy_in] Pressure/volume-flow inflow
%DESCRIPTION [Hy_in] Pressure/volume-flow outflow
%DESCRIPTION [Th_in] Temperature/Entropy-flow in flow
%DESCRIPTION [Th_out] Temperature/Entropy-flow out flow
%DESCRIPTION [Shaft] Torque/angular velocity input.

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Work	Shaft

%ALIAS  $1		c_v
%ALIAS  $2		density,ideal_gas,r

%ALIAS	Density		CompressibleFlow/Density

%% Label file for system wPipe (wPipe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/07/04 08:33:30  peterg
% %% New-style SS
% %%
% %% Revision 1.1  1998/07/03 17:38:20  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Density
	rho1		none	density,ideal_gas,r
	rho2		none	density,ideal_gas,r

% Component type EMTF
	p2pv		lin		flow
	pv2p		lin		effort

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Shaft]		SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

% Component type TF
	t2u		lin	effort,c_v
	u2t		lin	flow,c_v




Added mtt/lib/comp/compound/Thermal/Conv/Conv_abg.fig version [7d2151b2ad].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 1351 5176 1351 4951 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5401 1576 5401 2701 5626 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5401 3151 5401 4276 5626 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2251 4501 5176 4501 4951 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 6751 1351 6526 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 1351 8551 1351 8326 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9226 1350 10351 1350 10126 1575
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8370 2925 4275 2925 4275 630 8370 630 8370 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2206 1351 3331 1351 3106 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 6075 11925 225 675 225 675 6075 11925 6075
4 1 -1 0 0 22 20 0.0000 4 210 390 3736 1441 ES\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5401 1441 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5401 4636 1\001
4 1 -1 0 0 22 20 0.0000 4 270 1215 5401 3061 FMR:c_p\001
4 1 1 1 0 3 30 0.0000 4 60 120 2657 4682 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 2657 4952 m\001
4 1 4 0 0 0 20 0.0000 4 240 285 3466 1126 [s]\001
4 1 4 0 0 0 20 0.0000 4 240 300 4006 1126 [e]\001
4 1 1 1 0 3 20 0.0000 4 195 135 4592 1262 1\001
4 1 1 1 0 3 20 0.0000 4 195 615 4770 1080 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 5085 1260 0\001
4 1 1 1 0 3 20 0.0000 4 195 180 4683 1803 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 4683 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 6079 1804 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 6079 1534 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 6120 1125 0\001
4 1 -1 0 0 22 20 0.0000 4 210 390 7111 1441 AF\001
4 1 -1 0 0 22 20 0.0000 4 210 390 8911 1441 ES\001
4 1 1 1 0 3 20 0.0000 4 195 180 7832 1803 E\001
4 1 4 0 0 0 20 0.0000 4 240 300 8641 1081 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 285 9136 1081 [s]\001
4 1 1 1 0 3 30 0.0000 4 60 120 7832 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 615 7922 1082 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8237 1262 0\001
4 1 1 1 0 3 20 0.0000 4 195 135 7744 1264 2\001
4 1 1 1 0 3 20 0.0000 4 270 2340 6930 2340 Pseudo Bond Graph\001
4 2 4 0 0 0 20 0.0000 4 240 1200 2160 4590 SS:[Mdot]\001
4 2 4 0 0 0 20 0.0000 4 255 1275 2072 1442 SS:[Th_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2611 1171 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2746 1261 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2746 1936 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2611 1801 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2611 1531 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9590 1220 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 9725 1310 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 9590 1850 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9590 1580 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 9725 1985 2\001
4 0 4 0 0 0 20 0.0000 4 255 1425 10443 1443 SS:[Th_out]\001

Added mtt/lib/comp/compound/Thermal/Conv/Conv_desc.tex version [f754dcd4e7].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Conv (Conv_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:53 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/09 10:19:43  peterg
% %% Added note about energy consevation.
% %%
% %% Revision 1.1  1998/03/09 10:13:27  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Conv} is
   displayed in Figure \Ref{Conv_abg} and its label
   file is listed in Section \Ref{sec:Conv_lbl}.
   The subsystems are listed in Section \Ref{sec:Conv_sub}.

The \textbf{Conv} component represents one way isenentropic flow of 
fluid though a pipe. Externally, it has true energy bonds: $P$/$\dot V$
(Pressure/volume-flow) representing hydraulic energy and $T$/$\dot
S$(Temperature/Entropy-flow) representing convected thermal energy.

Internally, however, the thermal part is represented by a pseudo bond
graph which computes the flow of internal energy $\dot E$ from the
upstream temperature $T_1$ and the mass flow rate $\dot m$ as:
\begin{equation}
  \dot E = c_p T_1 \dot m
\end{equation}
The $AF$ component makes the $FMR$ component use $T_1$ rather than
$T_1-T_2$.

The two \textbf{ES} components provide the conversion from true to
psuedo thermal bonds and vice versa.

%The pipe has an resistance to flow represented by the \textbf{RS}
%component labeled `r' which can be linear or nonlinear. The hydraulic
%energy loss reappears on the thermal bond of this (energy-conserving)
%\textbf{RS} component.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/Conv/Conv_lbl.txt version [829d4c79b1].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Conv	Convection of heat through a pipe
%DESCRIPTION Parameter 1: Specific heat of fluid (c_p)

%% Label file for system Conv (Conv_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type FMR
	c_p		lin	effort,$1

% Component type SS
	[Hy_in]		SS	external,external
	[Hy_out]	SS	external,external
	[Th_in]		SS	external,external
	[Th_out]	SS	external,external

Added mtt/lib/comp/compound/Thermal/Cycle/Cycle_abg.fig version [7b351255a8].














































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1800 6750 1800 6525 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2025 5175 3375 5400 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 5175 5400 4950
2 2 0 3 1 7 1 0 -1 0.000 1 0 -1 0 0 5
	 6075 900 9000 900 9000 2700 6075 2700 6075 900
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8325 900 8550 900 8550 2700 8325 2700 8325 900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3825 10125 5175 10350 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 1800 9900 1800 9675 2025
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8550 1665 9585 1665 9585 1935 8550 1935 8550 1665
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 4725 1440 5805 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 9675 1440 10755 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 7785 3465 8415 2835
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 1800 4950 1800 4725 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1755 1800 3105 1800 2880 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 2025 3375 5175 3600 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 5175 3600 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10350 1800 11700 1800 11475 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 1800 13500 1800 13275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11700 5175 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11925 2025 11925 5175 12150 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 2025 10125 3375 10350 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2025 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 10350 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 5175 10350 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 5400 5175
4 1 -1 0 0 0 20 0.0000 4 255 855 7290 1890 CU:gas\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 1890 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1590 5175 3690 INTF:entropy\001
4 1 -1 0 0 0 20 0.0000 4 195 135 10125 1890 1\001
4 1 1 1 0 3 20 0.0000 4 270 1035 7200 1440 Ideal gas\001
4 1 1 1 0 3 20 0.0000 4 210 885 4635 1305 Heat in\001
4 1 1 1 0 3 20 0.0000 4 210 1080 10170 1305 Work out\001
4 1 1 1 0 3 20 0.0000 4 270 1800 5130 5895 Entropy change\001
4 1 1 1 0 3 20 0.0000 4 270 1365 7110 3690 Ideal piston\001
4 1 -1 0 0 0 20 0.0000 4 195 1560 10125 3690 INTF:volume\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 1890 0\001
4 2 4 0 0 0 20 0.0000 4 240 1140 1575 1890 SS:[Heat]\001
4 1 -1 0 0 0 20 0.0000 4 195 585 3375 5490 SS:T\001
4 1 1 1 0 3 20 0.0000 4 255 1485 3240 5895 Temperature\001
4 1 -1 0 0 0 20 0.0000 4 195 570 5130 5490 SS:S\001
4 1 -1 0 0 0 20 0.0000 4 195 615 10125 5490 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 195 570 11880 5490 SS:P\001
4 0 4 0 0 0 20 0.0000 4 240 1230 13680 1890 SS:[Work]\001
4 1 1 1 0 3 20 0.0000 4 270 1815 10080 5850 Volume change\001
4 1 1 1 0 3 20 0.0000 4 195 975 11925 5850 Pressure\001
4 1 -1 0 0 0 20 0.0000 4 195 135 11925 1890 0\001

Added mtt/lib/comp/compound/Thermal/Cycle/Cycle_desc.tex version [d51575eb68].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Cycle (Cycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/06/30 12:46:24  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cycle} is
   displayed in Figure \Ref{Cycle_abg} and its label
   file is listed in Section \Ref{sec:Cycle_lbl}.
   The subsystems are listed in Section \Ref{sec:Cycle_sub}.

The system has two heat engine ports: 
\begin{enumerate}
\item \textbf{[Heat]} and
\item \textbf{[Work]}
\end{enumerate}
By convention, energy flows in to the \textbf{[Heat]} port and out of
the \textbf{[Work]} port. Both ports are true energy ports.


The subsystem \textbf{CU} (Section \Ref{sec:CU}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

Four \textbf{SS} components are set up as sensors to measure the
important quantities pertaining to the cycle:
\begin{enumerate}
\item \textbf{S} to measure the integrated entropy flow
\item \textbf{T} to measure the (absolute) temperature
\item \textbf{V} to measure the integrated volume change
\item \textbf{P} to measure the pressure
\end{enumerate}

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|l|l|l|}
         \hline
         Cycle & Compression & Heating & Expansion & Cooling \\
         \hline
         Otto & II & II & II & II \\
         Carnot & II & DI & II & DI \\
         Diesel & II & ID & II & II \\
         Joule & II & ID & II & ID \\
         \hline
       \end{tabular}
       \caption{Cycles and their causality}
       \label{tab:cycles}
     \end{center}
   \end{table}
   
   A number of cycles can be built depending on the causality of the
   two ports \textbf{[Heat]} and \textbf{[Work]} of \textbf{Cycle}
   Some possible cycles listed in Tables \Ref{tab:cycles} where each
   table entry gives the causality on the heat and work ports
   respectively.

Added mtt/lib/comp/compound/Thermal/Cycle/Cycle_lbl.txt version [d82e73d04d].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Cycle: Closed cycle with ideal gas
#DESCRIPTION Uses the CU two-port thermal capacitor.

#ALIAS in	Heat
#ALIAS out	Work

#ALIAS $1	ideal_gas
#ALIAS $2	c_v
#ALIAS $3	gamma_g
#ALIAS $4	m_g

## Label file for system Cycle (Cycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1998/07/21 14:21:04  peterg
# ## New style file
# ##
# ## Revision 1.1  1997/12/08 20:24:43  peterg
# ## Initial revision
# ##
# ## Revision 1.1  1997/12/07 20:38:05  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank




# Component type CU
	gas	CU	ideal_gas,c_v,gamma_g,m_g

# Component type INTF
	entropy
	volume

# Component type SS
	S	SS	external,0
	T	SS	external,0
	V	SS	external,0
	P	SS	external,0
	[Heat]	SS	external,external
	[Work]	SS	external,external



Added mtt/lib/comp/compound/Thermal/Cycle/Cycle_simp.r version [b8f003f5e9].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce commands to simplify output for system Cycle (Cycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/comp/compound/Thermal/FMRT/FMRT_abg.fig version [b00ff3b590].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2701 5625 2701 5400 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2701 7425 2701 7200 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2476 5850 1126 6075 1351
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3600 450 3600 450 451 11475 451 11475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2701 3375 2701 3150 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2701 9675 2701 9450 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 900 5625 900 5400 1125
4 1 -1 0 0 0 20 0.0000 4 195 150 5850 2791 1\001
4 1 4 0 0 0 20 0.0000 4 255 360 4410 2476 [p]\001
4 1 4 0 0 0 20 0.0000 4 255 360 7290 2476 [p]\001
4 1 1 1 0 3 20 0.0000 4 255 225 5040 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 120 5085 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 5040 2521 T\001
4 1 1 1 0 3 20 0.0000 4 255 225 6615 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 120 6660 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 6615 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 150 6795 2611 2\001
4 1 1 1 0 3 20 0.0000 4 195 150 5220 2611 1\001
4 1 -1 0 0 0 20 0.0000 4 255 825 3825 2790 FP:fp1\001
4 2 4 0 0 0 20 0.0000 4 255 870 1980 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 315 3285 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2520 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 2475 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 150 2610 2611 1\001
4 1 1 1 0 3 20 0.0000 4 195 150 2610 3241 1\001
4 1 -1 0 0 0 20 0.0000 4 255 825 7920 2790 FP:fp2\001
4 1 4 0 0 0 20 0.0000 4 240 315 8505 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9135 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 9090 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 150 9270 3241 2\001
4 1 1 1 0 3 20 0.0000 4 195 150 9270 2611 2\001
4 0 4 0 0 0 20 0.0000 4 255 1020 9810 2791 SS:[out]\001
4 0 -1 0 0 0 20 0.0000 4 195 825 5850 990 FMR:r\001
4 2 4 0 0 0 20 0.0000 4 255 1170 4185 990 SS:[mod]\001
4 1 4 0 0 0 20 0.0000 4 255 750 5400 765 [mod]\001

Added mtt/lib/comp/compound/Thermal/FMRT/FMRT_desc.tex version [5df3411dfb].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
Component \textbf{FMRT} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{R} component.

The resistance $r$ is modulated by a flow variable $f$ on the [mod] port
so that the {\em conductance\/} $\sigma$ is:
\begin{equation}
  \sigma = \frac{f}{r} 
\end{equation}

Added mtt/lib/comp/compound/Thermal/FMRT/FMRT_lbl.txt version [e0d0d8668e].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY FMRT: Two port thermal resistance with T/Sdot bonds with flow modulation
#DESCRIPTION Port [in]: T/Sdot power in
#DESCRIPTION Port [out]: T/Sdot power out
#DESCRIPTION CR and parameters as for a one-port R component
#DESCRIPTION Internally pseudo bond graph 
#DESCRIPTION Example label file entry:
#DESCRIPTION # Component type RT
#DESCRIPTION	r		lin	flow,r

#ALIAS	ThermalIn	in
#ALIAS	ThermalOut	out
#ALIAS	Modulation	mod

#ALIAS	$1	flow,r
#ALIAS	$1	lin


## Label file for system FMRT (FMRT_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.8  2001/07/05 08:42:41  gawthrop
# ## Updated to allow auto-generation of sensitivity version
# ##
# ## Revision 1.7  2001/07/03 22:59:10  gawthrop
# ## Fixed problems with argument passing for CRs
# ##
# ## Revision 1.6  2001/06/13 17:10:26  gawthrop
# ## Alias for the cr (ie ALIAS	$1	lin)
# ##
# ## Revision 1.5  2001/06/11 19:51:08  gawthrop
# ## Zapped spurious $1 alias
# ##
# ## Revision 1.4  1998/07/22 11:31:42  peterg
# ## New port names
# ##
# ## Revision 1.3  1998/07/21 16:26:05  peterg
# ## Now has aliased parameters.
# ##
# ## Revision 1.2  1998/06/29 10:08:14  peterg
# ## Converted to FP component
# ## Removed lables from FP
# ##
# ## Revision 1.1  1997/09/04  09:48:47  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank


# Component type FMR
	r		lin		flow,r

# Component type FP
        fp1
        fp2

# Component type SS
	[in]		SS		external,external
	[out]		SS		external,external
	[mod]		SS		external,external

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pipe/Pipe_abg.fig version [d78afb5ca3].





















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2715 1351 3840 1351 3615 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4515 1351 5640 1351 5415 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 1576 5865 2701 6090 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 3151 5865 4276 6090 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2715 4501 5640 4501 5415 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6090 1351 7215 1351 6990 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7890 1351 9015 1351 8790 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6090 4501 10815 4501 10590 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9690 1350 10815 1350 10590 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11039 4274 11039 3149 11264 3374
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11039 2699 11039 1574 11264 1799
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11267 1353 12392 1353 12167 1578
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11267 4500 12392 4500 12167 4725
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8834 2925 4739 2925 4739 630 8834 630 8834 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15075 6075 15075 450 450 450 450 6075 15075 6075
4 2 4 0 0 0 20 0.0000 4 255 2085 2624 4590 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2581 1442 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 390 4200 1441 ES\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5865 1441 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5865 4636 1\001
4 1 -1 0 0 22 20 0.0000 4 210 390 7575 1441 AF\001
4 1 -1 0 0 22 20 0.0000 4 270 1665 5865 3061 FMR:rho_cp\001
4 1 -1 0 0 22 20 0.0000 4 210 390 9375 1441 ES\001
4 1 1 1 0 3 20 0.0000 4 195 180 8296 1803 E\001
4 1 1 1 0 3 20 0.0000 4 195 135 3256 4412 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3121 4682 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3121 4322 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 3121 4952 V\001
4 1 4 0 0 0 20 0.0000 4 240 285 3930 1126 [s]\001
4 1 4 0 0 0 20 0.0000 4 240 300 4470 1126 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 300 9105 1081 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 285 9600 1081 [s]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3120 1171 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3255 1261 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3255 1936 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3120 1801 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3120 1531 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 5056 1262 1\001
4 1 1 1 0 3 20 0.0000 4 195 615 5234 1080 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 5549 1260 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 8296 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 615 8386 1082 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8701 1262 0\001
4 1 1 1 0 3 20 0.0000 4 195 135 8208 1264 2\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11039 1440 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11039 4590 1\001
4 1 -1 0 0 22 20 0.0000 4 210 600 11084 3015 RS:r\001
4 0 4 0 0 0 20 0.0000 4 255 2235 12617 4593 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 12572 1443 SS:[Thermal_out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 11674 4685 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 11674 4325 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 11674 4955 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 11809 4415 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 11674 1175 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 11809 1265 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 11674 1805 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 11674 1535 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 11809 1940 2\001
4 1 1 1 0 3 20 0.0000 4 270 2340 7394 2340 Pseudo Bond Graph\001
4 1 1 1 0 3 20 0.0000 4 195 180 5147 1803 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 5147 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 6543 1804 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 6543 1534 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 6584 1125 0\001

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pipe/Pipe_desc.tex version [0ebe3c440d].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Pipe (Pipe_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:53 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/09 10:13:27  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pipe} is
   displayed in Figure \Ref{Pipe_abg} and its label
   file is listed in Section \Ref{sec:Pipe_lbl}.
   The subsystems are listed in Section \Ref{sec:Pipe_sub}.

The \textbf{Pipe} component represents one way flow of incompressible
fluid though a pipe. Externally, it has true energy bonds: $P$/$\dot V$
(Pressure/volume-flow) representing hydraulic energy and $T$/$\dot
S$(Temperature/Entropy-flow) representing convected thermal energy.

Internally, however, the thermal part is represented by a pseudo bond
graph which computes the flow of internal energy $\dot E$ from the
upstream temperature $T_1$ and the volumetric flow rate $\dot V$ as:
\begin{equation}
  \dot E = \rho c_p T_1 \dot V
\end{equation}
The $AF$ component makes the $FMR$ component use $T_1$ rather than
$T_1-T_2$.

The two \textbf{ES} components provide the conversion from true to
psuedo thermal bonds and vice versa.

The pipe has an resistance to flow represented by the \textbf{RS}
component labeled `r' which can be linear or nonlinear. The hydraulic
energy loss reappears on the thermal bond of this (energy-conserving)
\textbf{RS} component.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pipe/Pipe_lbl.txt version [5c1c8daacb].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Pipe (Pipe_lbl.txt)
%SUMMARY Pipe: Pipe containing hot incompressible liquid
%DESCRIPTION

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/20 11:34:17  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out


%ALIAS	$1	rho
%ALIAS	$2	c_p
%ALIAS	$3	flow,r


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type FMR
	rho_cp		lin	effort,$1*$2

% Component type RS
	r		$1	$3

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pump/Pump_abg.fig version [64178c150c].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2714 2476 3839 2476 3614 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4289 2476 5414 2476 5189 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6313 2477 8297 2478 8072 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2713 1351 5418 1353 5193 1578
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6313 1351 8297 1352 8072 1577
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3825 4050 2700 4275 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5400 4050 4275 4275 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4063 7020 4063 5895 4288 6120
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10800 7650 10800 450 405 450 405 7650 10800 7650
4 2 4 0 0 0 20 0.0000 4 255 2085 2669 2567 SS:[Hydraulic_in]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4064 2612 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3166 2389 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3031 2659 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3031 2299 P\001
4 0 4 0 0 0 20 0.0000 4 255 2235 8522 2571 SS:[Hydraulic_out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 7579 2663 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 7579 2303 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 7579 2933 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 7714 2393 2\001
4 0 4 0 0 0 20 0.0000 4 255 1035 6313 2341 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1305 5953 1936 Pipe:pipe\001
4 2 4 0 0 0 20 0.0000 4 255 870 5459 1172 [Th_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2536 1444 SS:[Thermal_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3075 1173 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3210 1263 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3210 1938 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3075 1803 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3075 1533 .\001
4 0 4 0 0 0 20 0.0000 4 255 1020 6313 1171 [Th_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 8477 1400 SS:[Thermal_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 7579 1132 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 7714 1222 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7579 1762 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 7579 1492 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 7714 1897 2\001
4 2 4 0 0 0 20 0.0000 4 255 885 5457 2340 [Hy_in]\001
4 1 1 1 0 3 20 0.0000 4 195 195 3031 2929 V\001
4 1 -1 0 0 22 20 0.0000 4 270 915 4063 4141 TF:k_p\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4064 5717 1\001
4 1 4 0 0 0 20 0.0000 4 240 1215 4063 7381 SS:[Shaft]\001
4 1 1 1 0 32 30 0.0000 4 240 195 3838 6661 t\001
4 1 1 1 0 32 30 0.0000 4 240 285 4288 6661 w\001

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pump/Pump_desc.tex version [af214b606c].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Pump (Pump_desc.tex)
% Generated by MTT on Mon Mar 9 09:11:22 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pump} is
   displayed in Figure \Ref{Pump_abg} and its label
   file is listed in Section \Ref{sec:Pump_lbl}.
   The subsystems are listed in Section \Ref{sec:Pump_sub}.

\textbf{Pump} represents an ideal pump for incompressible fluid
driving fluid though a \textbf{Pipe} component. The pipe component
provides the correct thermal flow; if its resistance is set to zero,
the pump is an ideal component.

The flow must be one way (in to out) for correct thermal properties.

The ports are 
\begin{itemize}
\item [Hy_in] Pressure/volume-flow inflow
\item [Hy_in] Pressure/volume-flow outflow
\item [Th_in] Temperature/Entropy-flow in flow
\item [Th_out] Temperature/Entropy-flow out flow
\item [Shaft] Torque/angular velocity input.
\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pump/Pump_lbl.txt version [9da52c1c35].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Pump: a hydraulic pump - incompressible flow
%DESCRIPTION Typical lable: pump  lin  rho;c_p;flow,r;k_p

%% Label file for system Pump (Pump_lbl.txt)


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/20 10:07:14  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ALIAS	Pipe	IncompressibleFlow/Pipe
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Work	Shaft

%ALIAS  $1	rho
%ALIAS  $2	c_p
%ALIAS  $3	flow,r
%ALIAS  $4	flow,k_p

%ALIAS	$1	lin

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank


% Component type Pipe
	pipe		lin	rho;c_p;flow,r

% Component type TF
	k_p		lin	flow,k_p

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	[Shaft]		SS	external,external

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_abg.fig version [33782b4512].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2940 2477 4065 2477 3840 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4740 2477 5865 2477 5640 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2940 5627 5865 5627 5640 5852
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6315 2478 7440 2478 7215 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8116 2479 9241 2479 9016 2704
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6315 5626 9240 5626 9015 5851
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7484 6571 4739 6571 4739 1801 7484 1801 7484 6571
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5864 5401 6314 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5864 2701 6314 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6089 2702 6089 3827 6314 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6089 5401 6089 4276 6314 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6088 1127 6088 2252 6313 2027
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11700 7200 11700 225 675 225 675 7200 11700 7200
4 0 4 0 0 0 20 0.0000 4 255 2235 9421 5719 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 9376 2569 SS:[Thermal_out]\001
4 2 4 0 0 0 20 0.0000 4 255 2085 2894 5716 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2806 2568 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 390 4425 2567 ES\001
4 1 1 1 0 3 20 0.0000 4 195 135 3481 5538 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3346 5808 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3346 5448 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 3346 6078 V\001
4 1 4 0 0 0 20 0.0000 4 240 285 4155 2252 [s]\001
4 1 4 0 0 0 20 0.0000 4 240 300 4695 2252 [e]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3345 2297 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3480 2387 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3480 3062 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3345 2927 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3345 2657 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 5281 2388 1\001
4 1 1 1 0 3 20 0.0000 4 195 615 5459 2206 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 5774 2386 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 5372 2659 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 5372 2929 E\001
4 1 -1 0 0 22 20 0.0000 4 210 870 6089 4186 C:tank\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6090 2567 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6090 5762 0\001
4 1 -1 0 0 22 20 0.0000 4 210 390 7800 2568 ES\001
4 1 1 1 0 3 30 0.0000 4 60 120 8523 5811 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 8523 5451 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 8523 6081 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 8658 5541 2\001
4 1 1 1 0 3 20 0.0000 4 195 180 6721 2930 E\001
4 1 4 0 0 0 20 0.0000 4 240 300 7530 2208 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 285 8025 2208 [s]\001
4 1 1 1 0 3 20 0.0000 4 195 165 8523 2301 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8658 2391 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 8523 2931 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 8523 2661 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 8658 3066 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 6721 2660 .\001
4 1 1 1 0 3 20 0.0000 4 195 615 6811 2209 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 7126 2389 0\001
4 1 1 1 0 3 20 0.0000 4 195 135 6633 2391 2\001
4 1 1 1 0 3 20 0.0000 4 270 2340 6134 6346 Pseudo Bond Graph\001
4 1 4 0 0 0 20 0.0000 4 240 555 5639 3826 [out]\001
4 1 4 0 0 0 20 0.0000 4 240 405 5684 4501 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 1500 6088 990 SS:[Heat_in]\001

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_cr.r version [2d58561817].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for Tank (Tank_cr.r)
% Generated by MTT at Thu Mar  5 10:30:23 GMT 1998

OPERATOR tank;

%Pressure
FOR ALL COMPONENT, rho,c_p,c,Volume,Energy
LET tank(COMPONENT, rho,c_p,c,effort,1,
	Volume,state,1,
	Energy,state,2
	) = (Volume*rho)/c;

%Temperature
FOR ALL COMPONENT, rho,c_p,c,Volume,Energy
LET tank(COMPONENT, rho,c_p,c,effort,2,
	Volume,state,1,
	Energy,state,2
	) = Energy/(Volume*rho*c_p);

END;

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_desc.tex version [cb521024f4].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Tank (Tank_desc.tex)
% Generated by MTT on Tue Jan 13 18:03:04 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tank} is
   displayed in Figure \Ref{Tank_abg} and its label
   file is listed in Section \Ref{sec:Tank_lbl}.
   The subsystems are listed in Section \Ref{sec:Tank_sub}.

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_lbl.txt version [7694e0fcab].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Tank (Tank_lbl.txt)
%SUMMARY Tank: Tank of hot incompressible liquid
%DESCRIPTION c is the pressure constant: P=(rho*V)/c
%DESCRIPTION Typical lable: tank  Tank  rho;c_p;c

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/11/20 09:46:34  peterg
% %% Modernised lbl syntax
% %%
% %% Revision 1.1  1998/11/20 08:57:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Heat	Heat_in

% Argument aliases
%ALIAS	$1	rho
%ALIAS	$2	c_p
%ALIAS	$3	c

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	tank		Tank	       rho,c_p,c

% Component type SS
	[Heat_in]	SS		external,external
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/lPump/lPump_abg.fig version [2ccac3b7ce].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 7426 6526 6301 6751 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 6302 6078 6302 5853 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5177 6078 5177 5853 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 2476 3601 4951 3871 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 3601 3601 6076 3871 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 2701 6976 2476 9451 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3825 6975 3600 9450 6075
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 6301 9228 6301 9003 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 5176 9228 5176 9003 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 6302 3378 6302 3153 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 5177 3378 5177 3153 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9678 5177 10803 5177 10578 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9678 6302 10803 6302 10578 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 9001 6525 7876 6750 8101
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13275 9675 13275 1350 45 1350 45 9675 13275 9675
4 2 4 0 0 0 20 0.0000 4 255 2085 2205 6390 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2205 5265 SS:[Thermal_in]\001
4 2 4 0 0 0 20 0.0000 4 255 870 6123 4998 [Th_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1020 6977 4997 [Th_out]\001
4 1 4 0 0 0 20 0.0000 4 240 810 6572 6167 [Shaft]\001
4 2 4 0 0 0 20 0.0000 4 255 885 5986 6166 [Hy_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1035 7112 6167 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1665 6527 5762 Pump:pump\001
4 1 -1 0 0 22 20 0.0000 4 270 1260 6527 3152 Pipe:leak\001
4 1 1 1 0 3 20 0.0000 4 195 135 2705 6215 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2570 6125 P\001
4 1 1 1 0 3 20 0.0000 4 195 165 2614 4999 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2749 5089 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2749 5764 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2614 5629 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2614 5359 .\001
4 1 1 1 0 3 20 0.0000 4 195 195 2570 6755 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 2570 6485 .\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3603 6393 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3603 5268 0\001
4 0 4 0 0 0 20 0.0000 4 255 2085 10941 5271 SS:[Thermal_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2235 10941 6397 SS:[Hydraulic_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 10043 4958 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 10178 5048 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 10043 5588 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 10043 5318 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 10178 5723 2\001
4 1 -1 0 0 22 20 0.0000 4 195 150 9453 5268 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 10088 6489 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 10088 6129 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 10088 6759 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 10223 6219 2\001
4 1 -1 0 0 22 20 0.0000 4 195 150 9498 6438 0\001
4 0 4 0 0 0 20 0.0000 4 255 870 7023 2343 [Th_in]\001
4 0 4 0 0 0 20 0.0000 4 255 885 7021 3466 [Hy_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1020 6032 2342 [Th_out]\001
4 2 4 0 0 0 20 0.0000 4 255 1035 6032 3467 [Hy_out]\001
4 1 4 0 0 0 20 0.0000 4 240 1215 6482 9317 SS:[Shaft]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6528 7743 1\001

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/lPump/lPump_desc.tex version [e567a661c2].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system lPump (lPump_desc.tex)
% Generated by MTT on Mon Mar 9 10:35:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{lPump} is
   displayed in Figure \Ref{lPump_abg} and its label
   file is listed in Section \Ref{sec:lPump_lbl}.
   The subsystems are listed in Section \Ref{sec:lPump_sub}.

\textbf{lPump} corrsponds to the \textbf{Pump} component but with a
backflow leakage around the ump driven by the pressure drop across
the pump. This leakage is implemented using the \textbf{Pipe}
component to give the correct thermal behaviour.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/IncompressibleFlow/lPump/lPump_lbl.txt version [d8173c6ec9].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system lPump (lPump_lbl.txt)
%SUMMARY lPump: a hydraulic pump with leakage - incompressible flow

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Component aliases
%ALIAS	Pipe	IncompressibleFlow/Pipe
%ALIAS	Pump	IncompressibleFlow/Pump

% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

% Argument aliases
%ALIAS  $1	rho
%ALIAS  $2	c_p
%ALIAS  $3	flow,r
%ALIAS  $4	flow,k_p
%ALIAS  $5	flow,r_l


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Pipe
	leak		lin	$1;$2;$5

% Component type Pump
	pump		lin	$1;$2;$3;$4

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	[Shaft]		SS	external,external

Added mtt/lib/comp/compound/Thermal/RT/RT_abg.fig version [932b6ad72c].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2701 5625 2701 5400 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2701 7425 2701 7200 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2476 5850 1126 6075 1351
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3600 450 3600 450 451 11475 451 11475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2701 3375 2701 3150 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2701 9675 2701 9450 2926
4 1 -1 0 0 0 20 0.0000 4 195 135 5850 2791 1\001
4 1 -1 0 0 0 20 0.0000 4 195 375 5850 991 R:r\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2476 [p]\001
4 1 4 0 0 0 20 0.0000 4 255 315 7290 2476 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 5040 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 5085 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 5040 2521 T\001
4 1 1 1 0 3 20 0.0000 4 240 210 6615 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 6660 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 6615 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 6795 2611 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 5220 2611 1\001
4 1 -1 0 0 0 20 0.0000 4 255 765 3825 2790 FP:fp1\001
4 2 4 0 0 0 20 0.0000 4 240 810 1980 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 2611 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 3241 1\001
4 1 -1 0 0 0 20 0.0000 4 255 765 7920 2790 FP:fp2\001
4 1 4 0 0 0 20 0.0000 4 240 270 8505 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 9135 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 3241 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 2611 2\001
4 0 4 0 0 0 20 0.0000 4 240 960 9810 2791 SS:[out]\001

Added mtt/lib/comp/compound/Thermal/RT/RT_desc.tex version [2c0ca51cf3].






1
2
3
4
5
+
+
+
+
+
Component \textbf{RT} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{R} component.
 

Added mtt/lib/comp/compound/Thermal/RT/RT_lbl.txt version [f1b276aa6b].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY RT: Two port thermal resistance with T/Sdot bonds
%DESCRIPTION Port [in]: T/Sdot power in
%DESCRIPTION Port [out]: T/Sdot power out
%DESCRIPTION CR and parameters as for a one-port R component
%DESCRIPTION Internally pseudo bond graph 
%DESCRIPTION Example label file entry:
%DESCRIPTION % Component type RT
%DESCRIPTION	r		lin	flow,r

%ALIAS	ThermalIn	in
%ALIAS	ThermalOut	out

%ALIAS	$1	flow,r
%ALIAS	$a1	lin


%% Label file for system RT (RT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2001/07/03 22:59:10  gawthrop
% %% Fixed problems with argument passing for CRs
% %%
% %% Revision 1.6  2001/06/13 17:10:26  gawthrop
% %% Alias for the cr (ie ALIAS	$1	lin)
% %%
% %% Revision 1.5  2001/06/11 19:51:08  gawthrop
% %% Zapped spurious $1 alias
% %%
% %% Revision 1.4  1998/07/22 11:31:42  peterg
% %% New port names
% %%
% %% Revision 1.3  1998/07/21 16:26:05  peterg
% %% Now has aliased parameters.
% %%
% %% Revision 1.2  1998/06/29 10:08:14  peterg
% %% Converted to FP component
% %% Removed lables from FP
% %%
% %% Revision 1.1  1997/09/04  09:48:47  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank


% Component type R
	r		lin		flow,r

% Component type FP
        fp1
        fp2

% Component type SS
	[in]		SS		external,external
	[out]		SS		external,external

Added mtt/lib/comp/compound/Thermal/RT/TestRT_abg.fig version [cbe47fe6bb].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 3600 3600 3600 3375 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3600 5850 3600 5625 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 3420 3600 3780
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 3420 4500 3780
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7020 4725 1125 4725 1125 2295 7020 2295 7020 4725
4 1 -1 0 0 2 20 0.0000 4 195 705 4050 3690 RT:rt\001
4 1 -1 0 0 2 20 0.0000 4 255 870 1800 3690 SS:T_1\001
4 1 -1 0 0 2 20 0.0000 4 255 870 6345 3690 SS:T_2\001

Added mtt/lib/comp/compound/Thermal/RT/TestRT_lbl.txt version [c0d3a5ad40].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TestRT
%DESCRIPTION <Detailed description here>
%% Label file for system TestRT (TestRT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RT
	rt		lin		flow,r;0

% Component type SS
	T_1		external	external
	T_2		external	external

Added mtt/lib/comp/compound/Thermal/RT1/RT1_abg.fig version [b3391c9064].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 2700 2925 2700 2700 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 5175 2700 4950 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 5400 1125 5625 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 2700 6975 2700 6750 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 2701 9226 2701 9001 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10081 2701 11431 2701 11206 2926
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12600 4275 12600 450 225 450 225 4275 12600 4275
4 1 -1 0 0 0 20 0.0000000 4 210 690 3420 2790 ES:es\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5400 2790 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 390 5400 990 R:r\001
4 2 4 0 0 0 20 0.0000000 4 240 870 1485 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000000 4 240 330 2835 2475 [s]\001
4 1 4 0 0 0 20 0.0000000 4 240 345 3960 2475 [e]\001
4 1 -1 0 0 0 20 0.0000000 4 210 705 7470 2790 AF:af\001
4 1 -1 0 0 0 20 0.0000000 4 210 690 9676 2791 ES:se\001
4 0 4 0 0 0 20 0.0000000 4 240 1020 11611 2791 SS:[out]\001
4 1 4 0 0 0 20 0.0000000 4 240 345 9091 2476 [e]\001
4 1 4 0 0 0 20 0.0000000 4 240 330 10306 2476 [s]\001

Added mtt/lib/comp/compound/Thermal/RT1/RT1_desc.tex version [4642e64d86].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Component \textbf{RT1} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{R} component.
Unlike the {\bf RT} component, it is {\em one-sided\/} in the snese
that the paper flow depends only on the upstream temperature. It is
useful for modelling radiation via the Stefan-Boltzmann law when using
the {\bf StefanBoltzmann} CR.


This one-sidedness is achieved using the {\bf AF} component to isolate
the intrnal {\bf R} component from the downstream temperature.
 

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/comp/compound/Thermal/RT1/RT1_lbl.txt version [024d59e57d].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system RT1 (RT1_lbl.txt)
%SUMMARY RT1: Two port thermal resistance with T/Sdot bonds
%DESCRIPTION Port [in]: T/Sdot power in
%DESCRIPTION Port [out]: T/Sdot power out
%DESCRIPTION CR and parameters as for a one-port R component
%DESCRIPTION One sided: flow depends on upstream temperature only
%DESCRIPTION Useful for radiation modelling
%DESCRIPTION Example label file entry:
%DESCRIPTION % Component type RT1
%DESCRIPTION	r		lin	flow,r


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:40:45  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	r
%ALIAS	$1	lin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	af

% Component type ES
	es
	se

% Component type R
	r		lin	flow,r

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Added mtt/lib/comp/compound/Thermal/ThermalConversion/ES/ES_abg.fig version [59448e3014].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4515 2701 5865 2701 5640 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2715 2701 4065 2701 3840 2926
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 3600 225 3600 225 1801 8325 1801 8325 3600
4 1 4 0 0 0 20 0.0000000 4 270 360 4650 2476 [p]\001
4 1 -1 0 0 0 20 0.0000000 4 210 330 4290 2791 FP\001
4 1 4 0 0 0 20 0.0000000 4 240 315 3975 2476 [f]\001
4 1 1 1 0 3 20 0.0000000 4 210 165 3165 3106 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 3210 2836 .\001
4 1 1 1 0 3 20 0.0000000 4 270 210 5280 3106 Q\001
4 1 1 1 0 3 30 0.0000000 4 60 105 5325 2836 .\001
4 1 1 1 0 3 20 0.0000000 4 210 180 5280 2521 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 3165 2521 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 3300 2611 1\001
4 1 1 1 0 3 20 0.0000000 4 210 150 3300 3241 1\001
4 1 1 1 0 3 20 0.0000000 4 210 150 5460 2611 1\001
4 0 4 0 0 0 20 0.0000000 4 270 2115 6000 2791 SS:[EnergyFlow]\001
4 2 4 0 0 0 20 0.0000000 4 270 2220 2655 2790 SS:[EntropyFlow]\001

Added mtt/lib/comp/compound/Thermal/ThermalConversion/ES/ES_lbl.txt version [aac3c82503].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system ES (ES_lbl.txt)
%SUMMARY ES	Identical to the FP component except for the port labels
%DESCRIPTION Converts true thermal to pseudo BGs

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	e|p	EnergyFlow
%ALIAS	s|f	EntropyFlow

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[EnergyFlow]	SS		external,external
	[EntropyFlow]	SS		external,external

Added mtt/lib/comp/compound/Thermal/VM/VM_abg.fig version [3136079f4d].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 3600 3825 3375 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 3600 4500 2925 4500 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1980 5400 2655 5625 2430
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 6975 3600 6750 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7246 3826 8371 3826 8146 4051
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5175 10125 450 225 450 225 5175 10125 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 1125 4500 1125 4275 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 900 4500 1395
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 1800 4500 1800 4275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 1575 4500 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4050 6300 4725 6525 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4500 4725 4320 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 4725 4950 4725 5175 4950
4 2 4 0 0 0 20 0.0000 4 255 1290 2073 3918 SS:[Hy_in]\001
4 1 1 1 0 3 30 0.0000 4 60 120 2570 4010 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2570 3650 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2570 4280 V\001
4 1 4 0 0 0 20 0.0000 4 240 570 5445 1935 [rho]\001
4 2 4 0 0 0 20 0.0000 4 240 675 5355 2700 [mod]\001
4 1 -1 0 0 22 20 0.0000 4 210 1365 5400 3015 EMAF:rho\001
4 1 4 0 0 0 20 0.0000 4 240 405 4860 3285 [in]\001
4 1 4 0 0 0 20 0.0000 4 240 555 5851 3241 [out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 8018 3968 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 8018 3608 P\001
4 1 1 1 0 3 20 0.0000 4 135 210 8018 4238 m\001
4 0 4 0 0 0 20 0.0000 4 255 1440 8551 3916 SS:[Hy_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3825 3915 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6975 3915 0\001
4 1 1 1 0 3 20 0.0000 4 195 165 2613 948 T\001
4 2 4 0 0 0 20 0.0000 4 240 345 4410 1665 [P]\001
4 2 4 0 0 0 20 0.0000 4 240 360 4455 945 [T]\001
4 2 4 0 0 0 20 0.0000 4 240 750 2119 1849 SS:[P]\001
4 2 4 0 0 0 20 0.0000 4 240 765 2119 1219 SS:[T]\001
4 1 -1 0 0 22 20 0.0000 4 270 2130 5715 1530 Density:density\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4725 4815 0\001
4 1 -1 0 0 22 20 0.0000 4 210 405 5985 4815 AE\001

Added mtt/lib/comp/compound/Thermal/VM/VM_desc.tex version [8bf823999e].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system VM (VM_desc.tex)
% Generated by MTT on Thu Mar 19 14:37:43 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{VM} is
   displayed in Figure \Ref{VM_abg} and its label
   file is listed in Section \Ref{sec:VM_lbl}.
   The subsystems are listed in Section \Ref{sec:VM_sub}.

The \textbf{VM} component acts as a density-modulated transformer
converting a $P$/$\dot V$ energy bond to a $P$/$\dot m$ pseudo bond. It used
the \textbf{Density} component and therfore inherits the properties of
that component -- in particular it takes the same parameter. The four
ports are:

\begin{itemize}
\item [Hy_in]: hydraulic in
\item [Hy_out]: hydraulic out
\item [P]: Pressure
\item [T]: Temperature
\end{itemize}

Added mtt/lib/comp/compound/Thermal/VM/VM_lbl.txt version [86421d4963].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY VM: Volumetric to mass flow and vv - pseudo mass-flow bond
%DESCRIPTION Converts between P/Vdot energy bond to a P/mdot pseudo bond
%DESCRIPTION Parameter 1: passed to the Density subcomponent
%% Label file for system VM (VM_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/26 08:37:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Density
	density		none		$1

% Component type EMAF
	rho

% Component type SS
	[Hy_in]		SS	external,external
	[Hy_out]	SS	external,external
	[P]		SS	external,external
	[T]		SS	external,external

Added mtt/lib/comp/compound/Thermal/VMe/VMe_abg.fig version [671e477a6f].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 4950 3825 4725 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 4500 1350 4275 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2250 5400 3600 5625 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9045 4725 9045 450 225 450 225 4725 9045 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 3826 7201 3826 6976 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 1125 4500 1620
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 4500 2025 4275 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 1800 4500 2295
4 1 1 1 0 3 20 0.0000 4 195 165 2613 1173 T\001
4 2 4 0 0 0 20 0.0000 4 255 1290 2073 3918 SS:[Hy_in]\001
4 1 4 0 0 0 20 0.0000 4 240 570 5400 2115 [rho]\001
4 1 1 1 0 3 30 0.0000 4 60 120 2570 4010 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2570 3650 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2570 4280 V\001
4 1 4 0 0 0 20 0.0000 4 240 405 4725 3690 [in]\001
4 2 4 0 0 0 20 0.0000 4 240 675 5310 3330 [mod]\001
4 1 -1 0 0 22 20 0.0000 4 210 1065 5535 3915 EMTF:tf\001
4 1 4 0 0 0 20 0.0000 4 240 555 6301 3691 [out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 6848 3968 .\001
4 1 1 1 0 3 20 0.0000 4 195 270 6848 3608 Pv\001
4 1 1 1 0 3 20 0.0000 4 135 210 6848 4238 m\001
4 1 -1 0 0 22 20 0.0000 4 270 2130 5805 1665 Density:density\001
4 2 4 0 0 0 20 0.0000 4 240 345 4410 1890 [P]\001
4 2 4 0 0 0 20 0.0000 4 240 360 4455 1170 [T]\001
4 2 4 0 0 0 20 0.0000 4 240 750 2119 2074 SS:[P]\001
4 2 4 0 0 0 20 0.0000 4 240 765 2119 1444 SS:[T]\001
4 0 4 0 0 0 20 0.0000 4 255 1440 7381 3916 SS:[Hy_out]\001

Added mtt/lib/comp/compound/Thermal/VMe/VMe_desc.tex version [2e1c5f9d5d].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system VMe (VMe_desc.tex)
% Generated by MTT on Thu Mar 19 14:37:43 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{VMe} is
   displayed in Figure \Ref{VMe_abg} and its label
   file is listed in Section \Ref{sec:VMe_lbl}.
   The subsystems are listed in Section \Ref{sec:VMe_sub}.

The \textbf{VMe} component acts as a density-modulated transformer
converting a $P$/$\dot V$ energy bond to a $Pv$/$\dot m$ bond. It used
the \textbf{Density} component and therfore inherits the properties of
that component -- in particular it takes the same parameter. The four
ports are:

\begin{itemize}
\item [Hy_in]: hydraulic in
\item [Hy_out]: hydraulic out
\item [P]: Pressure
\item [T]: Temperature
\end{itemize}

Added mtt/lib/comp/compound/Thermal/VMe/VMe_lbl.txt version [1cd2644cf2].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY VMe: Volumetric to mass flow and vv - energy bonds
%DESCRIPTION Converts between P/Vdot energy bond to a Pv/mdot energy bond
%DESCRIPTION Parameter 1: passed to the Density subcomponent
%% Label file for system VMe (VMe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/26 08:38:15  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Density
	density		none		$1

% Component type EMTF
	tf		lin		flow

% Component type SS
	[Hy_in]		SS	external,external
	[Hy_out]	SS	external,external
	[P]		SS	external,external
	[T]		SS	external,external

Added mtt/lib/comp/simple/AE_alias.m version [6bf2090b41].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = AE_alias	# Port aliases for AE

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/AE_cause.m version [4bfc8d144a].
















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = AE_cause(bonds);
% AE_cause - Causality for effort amplifier component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  AE_cause
% [bonds,status] = AE_cause(bonds)

%SUMMARY AE: effort amplifier
%DESCRIPTION Port[1]: amplifier effort input e_1 (f_1=0)
%DESCRIPTION Port[2]: amplifier effort output e_2 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/11/01 11:40:30  peterg
% %% Documentation.
% %%
% %% Revision 1.1  1996/08/30 19:05:21  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AE')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% Port 1 must impose (zero) flow and port 2 have flow imposed
if (f_1==-1)|(f_2==1) % Conflict
  status = 1;
 else 					% Do the rest of the causality

   if f_1 == 0 				% Set port 1 effort
     f_1 = 1;
   end;
   
   if f_2 == 0 				% Set port 2 effort
     f_2 = -1;
   end;
   
   number_set = sum(sum([e_1 e_2]~=zeros(1,2) ));
   if number_set==0 			% Under causal
     status = -1;
   elseif number_set==1 		% Set the causality
     if e_1 == 0
       e_1 = -e_2;
     else
       e_2 = -e_1;
     end
     status = 0;
   elseif number_set==2 		% Check the causality
     if e_1==-e_2
       status = 0;
     else
       status = 1;
     end
 end;
end;
 
 bonds = [e_1 f_1
           e_2 f_2]

Added mtt/lib/comp/simple/AE_eqn.m version [a764490bd3].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = AE_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);
% AE_eqn. Equation generation for effort amplifier.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/09/10 10:10:41  peter
% %% Now uses eqaution.m to format the equation.
% %%
% %% Revision 1.3  1996/08/30 19:03:10  peter
% %% Added argument check.
% %% Added extra name argument.
% %%
% %% Revision 1.2  1996/08/30 13:23:11  peter
% %% Added bond number check
% %%
% %% Revision 1.1  1996/08/22 13:12:34  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AE')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Flow on port 1 is always zero
   fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(1), -1));
  
  
outcause = 1;
incause = 1;

if e_2 == -1 				% Unicausal: e_2 := e_1
  outbond = bond_number(2);
  inbond = bond_number(1);
  outport = 2;
  inport = 1;
else 	                                % Bicausal: e_1 := e_2      
  outbond = bond_number(1);
  inbond = bond_number(2);
  outport = 1;
  inport = 2;
end


eqn =  equation("AE",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

			  
			  
			  



Added mtt/lib/comp/simple/AE_seqn.m version [9121c470c0].









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = AE_seqn (Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = AE_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## Implements the AE component 

  [eqn,insigs,innames] = Amp_seqn ("AE",Name, name, cr, arg, outsig, insigs, innames);
endfunction

Added mtt/lib/comp/simple/AF_alias.m version [779ca55ad2].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = AF_alias	# Port aliases for AF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/AF_cause.m version [de8629abe8].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = AF_cause(bonds);
% AF_cause - Causality for Flow amplifier component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  AF_cause
% [bonds,status] = AF_cause(bonds)

%SUMMARY AF: flow amplifier
%DESCRIPTION Port[1]: amplifier flow input f_1 (e_1=0)
%DESCRIPTION Port[2]: amplifier flow output f_2 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/08/30 19:05:32  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% Port 1 must impose (zero) effort and port 2 have effort imposed
if (e_1==1)|(e_2==-1) % Conflict
  status = 1;
 else 					% Do the rest of the causality

   if e_1 == 0 				% Set port 1 effort
     e_1 = -1;
   end;
   
   if e_2 == 0 				% Set port 2 effort
     e_2 = 1;
   end;
   
   number_set = sum(sum([f_1 f_2]~=zeros(1,2) ));
   if number_set==0 			% Under causal
     status = -1;
   elseif number_set==1 		% Set the causality
     if f_1 == 0
       f_1 = -f_2;
     else
       f_2 = -f_1;
     end
     status = 0;
   elseif number_set==2 		% Check the causality
     if f_1==-f_2
       status = 0;
     else
       status = 1;
     end
 end;
end;
 
 bonds = [e_1 f_1
           e_2 f_2];

Added mtt/lib/comp/simple/AF_eqn.m version [beebc3dcaf].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = AF_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% AF_eqn - equations for flow amplifier
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  AF_eqn
% structure = AF_eqn(bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/09/12 19:29:35  peter
% %% Use new equation method.
% %%
% %% Revision 1.2  1996/09/11 13:35:14  peter
% %% New equation.m method used.
% %%
% %% Revision 1.1  1996/08/30 18:38:57  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% Effort on port 1 is always zero
   fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(1), 1));
  
outcause = -1;
incause = -1;

if f_2 == 1 				% Unicausal: f_2 := f_1
  outbond = bond_number(2);
  inbond = bond_number(1);
  outport = 2;
  inport = 1;
else 	                                % Bicausal: f_1 := f_2      
  outbond = bond_number(1);
  inbond = bond_number(2);
  outport = 1;
  inport = 2;
end


eqn =  equation("AF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);







Added mtt/lib/comp/simple/AF_seqn.m version [969c3baa60].









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = AF_seqn (Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = AF_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## Implements the AF component 

  [eqn,insigs,innames] = Amp_seqn ("AF",Name, name, cr, arg, outsig, insigs, innames);
endfunction

Added mtt/lib/comp/simple/Amp_seqn.m version [fde6465120].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = Amp_seqn (AmpType,Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = AF_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 

  N = mtt_check_sigs (outsig,insigs);
  if (N!=2)
    mtt_error("Amplifier component must have exactly two ports");
  endif
  

  ## On which port is the equation required?
  outbond_number = outsig(1);
  outport = find(abs(insigs(:,1))!=outbond_number*ones(N,1));

  ## Some definitions
  flow = -1;
  effort = 1;

  if strcmp(AmpType,"AE")
    causality = effort;
    other_causality = flow;
  elseif strcmp(AmpType,"AF")
    causality = flow;
    other_causality = effort;
  else
    mtt_error(sprintf("Amp_seqn: type %s unknown", AmpType));
  endif
  
  ## Standard causality
  if (outport==2)
    qAmpType = sprintf("""%s""", AmpType);
    eqn = equation(qAmpType,Name,cr,arg,outsig(1),causality,2, ...
		 insigs(2,1),causality,1);
  elseif (outport==1)
    LHS = varname(Name,insigs(2,1),other_causality);
    eqn = sprintf("%s := 0;", LHS);
  else
    mtt_error("AF_seqn: outport must be 1 or 2");
  endif

endfunction

Added mtt/lib/comp/simple/C2_cause.m version [1f39f9455a].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = C2_cause(bonds);
% C2_cause - Unicausal multiport C2 C2omponent
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  C2_cause
% [bonds,status] = C2_cause(bonds)

%SUMMARY C2: elementary C component with two ports
%DESCRIPTION Two port dynamic component
%DESCRIPTION Preferred integral causality (flow input)
%DESCRIPTION Cannot be bicausal




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1996.

% Unicausal multiport C component
% Same causal pattern as R component

[bonds,status] = R_cause(bonds);


Added mtt/lib/comp/simple/CI_seqn.m version [2217509088].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = CI_seqn (comp_type,Name, name, cr, arg, outsig, insigs ,innames)

  ## usage:  [eqn,inbonds] = CI_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port C's ??

  delim = "__";
  N = mtt_check_sigs (outsig,insigs);

  state_index=3;
  
  i_cause = outsig(2);		# Extract causality

  state_equation=((i_cause==1)&&strcmp(comp_type,"C")) ...
      ||((i_cause==-1)&&strcmp(comp_type,"I"));

  ## Create the equation
  if state_equation			# output/state
    LHS = varname(Name, outsig(1,1), state_index);
    RHS = sprintf("MTTx_%s%s%s", Name, delim, name);
    eqn_1 = sprintf("%s := %s;", LHS, RHS);
    
    inports = [1:N]; 
    comp_type_str=sprintf("""%s""", comp_type);
    eqn_2 = equation(comp_type_str,Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
	     insigs(:,1),state_index,inports);
    
    eqn = sprintf("%s\n%s", eqn_1, eqn_2);
  else			# state derivative
    RHS = varname(Name, insigs(1,1), insigs(1,2));
    LHS = sprintf("MTTdx_%s%s%s", Name, delim, name);
    eqn = sprintf("%s := %s;", LHS, RHS);
  endif
  
endfunction

Added mtt/lib/comp/simple/C_alias.m version [1470d15671].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = C_alias	# Port aliases for C

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 14:49:14  peterg
## Initial revision
##
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/C_cause.m version [2222eab409].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = C_cause(bonds);
% C_cause - Unicausal multiport C component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  C_cause
% [bonds,status] = C_cause(bonds)

%SUMMARY C: elementary C component
%DESCRIPTION Single port dynamic component
%DESCRIPTION Preferred integral causality (flow input)
%DESCRIPTION Cannot be bicausal



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/11/01 12:35:36  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% Unicausal multiport C component
% Same causal pattern as R component

% [bonds,status] = R_cause(bonds);

% Set causality to preferred if not already set.
% Find the number of ports
[ports,junk] = size(bonds);

% default undercausal status
statuses = -ones(ports,1);

% Force unicausality but DONT set if not already set
preferred = -1;
for i = 1:ports
  if (bonds(i,1)~=0)&(bonds(i,2)~=0) % Both bonds set
    statuses(i) = bonds(i,1)~=bonds(i,2);
  elseif bonds(i,2)~=0               % Bond 1 set
    bonds(i,1) = bonds(i,2);
    statuses(i) = 0;
  elseif bonds(i,1)~=0               % Bond 2 set
    bonds(i,2) = bonds(i,1);
    statuses(i) = 0;
  else				# Don't set
#    bonds(i,1) = preferred;
#    bonds(i,2) = preferred;
#    statuses(i) = 0;
  end;
end;

if max(statuses)==1
  status = 1;
elseif min(statuses)==-1
  status = -1;
else
  status = 0;
end;


Added mtt/lib/comp/simple/C_eqn.m version [0e1e88a5f1].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function structure =  C_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% C_eqn - equation generation for C component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  C_eqn
% structure =  C_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2003/01/07 10:10:14  gawthrop
% %% Uses new version of equation.m - passes component type to cr.
% %%
% %% Revision 1.2  1997/04/09 13:00:28  peterg
% %% *** empty log message ***
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

			
if nargin<8
  eqnfile = 'stdout';
end;

% Unicausal version
CorI = 1;
structure = cieqn(name,bond_number,bonds,direction,cr,args, structure, ...
                 CorI, eqnfile);







Added mtt/lib/comp/simple/C_seqn.m version [40b9922c1a].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = C_seqn (Name, name, cr, arg, outsig, insigs ,innames)

  ## usage:  [eqn,inbonds] = C_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port C's ??


  [eqn,insigs,innames] = CI_seqn ("C", Name, name, cr, arg, outsig, insigs ,innames);

endfunction

Added mtt/lib/comp/simple/EBTF_alias.m version [e1757cdf64].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = EBTF_alias	# Port aliases for EBTF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/EBTF_cause.m version [61b581107d].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = EBTF_cause(bonds);
% EBTF_cause - causality for a EBTF component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  EBTF_cause
% [bonds,status] = EBTF_cause(bonds)

%SUMMARY EBTF: transformer component - bicausal on effort
%DESCRIPTION Energy conserving two-port
%DESCRIPTION e_1 f_1 = e_2 f_2 and e_1 and e_2 are both imposed.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




% Copyright (c) P.J. Gawthrop, 1998.

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'EBTF')==0
  return
end

% Effort must be imposed by both bonds
if (bonds(1,1)==-1)|(bonds(2,1)==-1) % Overcausal
  status = 1;
  return
end;

bonds(1,1) = 1; 
bonds(2,1) = 1;

% Flow bond must have through causality
if (bonds(1,2)==0)&(bonds(2,2)==0) % Undercausal
  status = -1;
  return
end;

if (bonds(1,2)==bonds(2,2))&(bonds(1,2)!=0) % Overcausal
  status = 1;
  return
end;

%Set flow causality
if (bonds(1,2)!=0)
  bonds(2,2) = -bonds(1,2)
else
  bonds(1,2) = -bonds(2,2)
end;
  
status = 0;







Added mtt/lib/comp/simple/EBTF_eqn.m version [f9d4dc3a42].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = EBTF_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);

if nargin<8
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'EBTF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Effort -- no equation

% Flow
effort1_name = varname(name,bond_number(1), 1);
effort2_name = varname(name,bond_number(2), 1);
flow1_name = varname(name,bond_number(1), -1);
flow2_name = varname(name,bond_number(2), -1);

if f_1==-1 %Write flow on port 2
  fprintf(eqnfile,'%s := (%s/%s)*%s;\n' , ...
      flow2_name, ...
      effort1_name, ...
      effort2_name, ...
      flow1_name);
else %Write flow on port 1
  fprintf(eqnfile,'%s := (%s/%s)*%s;\n' , ...
      flow1_name, ...
      effort2_name, ...
      effort1_name, ...
      flow2_name);
end;

 









Added mtt/lib/comp/simple/EMTF_alias.m version [b25e2d18fc].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = EMTF_alias	# Port aliases for EMTF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';
  alias.mod    = '3';

endfunction


Added mtt/lib/comp/simple/EMTF_cause.m version [e4232f67a5].




















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = EMTF_cause(bonds);
% EMTF_cause - causality for a modulated TF component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  EMTF_cause
% [bonds,status] = EMTF_cause(bonds)
% Causality for effort-modulated EMTF 
% At the moment, modulation can NOT be inverted.

%SUMMARY EMTF: effort-modulated transformer
%DESCRIPTION Energy conserving three-port
%DESCRIPTION Ports [1] and [2] as for TF
%DESCRIPTION e_1 = f(f_2); f_1 = f(e_2)
%DESCRIPTION Effort on port[3] modulates the CR


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

status = -1;

% Check that there are exactly three bonds.
if check_bonds(bonds,3,'EMTF')==0
  return
end

% Extract the bond information
TF_bonds = bonds(1:2,:);
e_3 = bonds(3,1);
f_3 = bonds(3,2);

%Causality of EMTF is same as that of a TF on ports 1 and 2
[TF_bonds,TF_status] = TF_cause(TF_bonds);


% Effort is the modulation - imposed on component.
if e_3==-1 				% Conflict
  mod_status_e = 1;
else 					% Do the rest of the causality
  if e_3==0 				% Set to the fixed causality
    e_3 = 1;
  end;
  mod_status_e = 0;
end;
 
% Zero flow imposed by component.
if f_3==-1 				% Conflict
  mod_status_f = 1;
else 					% Do the rest of the causality
  if f_3==0 				% Set to the fixed causality
    f_3 = 1;
  end;
  mod_status_f = 0;
end;
 
bonds = [TF_bonds
         e_3 f_3];
	
if (TF_status == 0) & (mod_status_e == 0) & (mod_status_f == 0)
  status = 0;
end;

if (TF_status == 1) | (mod_status_e == 1) | (mod_status_f == 1)
  status = 1;
end;

 
 
 
 
 
   

Added mtt/lib/comp/simple/EMTF_eqn.m version [7cc82fd47a].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = EMTF_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 11:45:48  peterg
% %% *** empty log message ***
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


			
if nargin<8
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,3,'EMTF')==0
  return
end

% There are 3 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);
e_3 = bonds(3,1);


% Effort
outcause = 1;
incause = [1;1];
if e_1==1
  outbond = bond_number(2);
  inbond =  bond_number([1 3]);
  outport = 2;
  inport = [1;3];
else
  outbond = bond_number(1);
  inbond =  bond_number([2 3]);
  outport = 1;
  inport = [2;3];
end;

eqn =  equation("EMTF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Flow
outcause = -1;
incause = [-1;1];
if f_1==-1
  outbond = bond_number(2);
  inbond =  bond_number([1 3]);
  outport = 2;
  inport = [1;3];
else
  outbond = bond_number(1);
  inbond =  bond_number([2 3]);
  outport = 1;
  inport = [2;3];
end;

eqn =  equation("EMTF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Modulation: flow on port 3 is always zero
  fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(3), -1));







Added mtt/lib/comp/simple/ES_alias.m version [2c3cf765fe].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = ES_alias	# Port aliases for ES

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 14:47:53  peterg
## Initial revision
##
###############################################################

  alias.in     = '1';
  alias.out    = '2';

  alias.e     = '1';
  alias.s     = '2';

  alias.enthalpy     = '1';
  alias.entropy      = '2';

endfunction


Added mtt/lib/comp/simple/ES_cause.m version [b7ca65e279].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = ES_cause(bonds);
% Causality for ES component

%SUMMARY ES: converts thermal pseudobond to true bond and vv
%DESCRIPTION Port [e]: temperature (T) / enthalpy flow (E) bond
%DESCRIPTION Port [s]: temperature (T) / entropy flow (S) bond



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'ES')==0
  return
end

% Same causality as TF
[bonds,status] = TF_cause(bonds);


Added mtt/lib/comp/simple/ES_eqn.m version [31e29928e3].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = ES_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% ES_eqn - equations for ES component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  ES_eqn
% ES_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/02/25 16:59:56  peterg
% %% Corrected enthalpy-entropy conversion -- use temp on the entropy side.
% %%
% %% Revision 1.1  1998/02/25 15:03:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'ES')==0
  return
end


% There are 2 ports; extract the information
e_bond = bonds(1,:);
s_bond = bonds(2,:);

% The efforts are the same - but the enthalpy side has relative T
if e_bond(1)==1 %effort imposed on the enthalpy bond 
%  fprintf(eqnfile,'%s := %s + t_0;\n' , ...
  fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(2), 1), ...
    varname(name,bond_number(1), 1) );
else %effort imposed on the entropy bond 
%  fprintf(eqnfile,'%s := %s - t_0;\n' , ...
  fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
end;

% The flows need to be converted - use the absolute temp on the
% entropy side
if e_bond(2)==-1 %flow imposed on the enthalpy bond 
  fprintf(eqnfile,'%s := %s/%s;\n' , ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), 1) );
else % flow imposed on the entropy bond 
    fprintf(eqnfile,'%s := %s*%s;\n' , ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(2), 1) );
end;

Added mtt/lib/comp/simple/FMR_alias.m version [85c12f71ad].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = FMR_alias	# Port aliases for FMR

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 14:47:14  peterg
## Initial revision
##
###############################################################

  alias.in     = '1';
  alias.out    = '2';
  alias.mod    = '2';

endfunction


Added mtt/lib/comp/simple/FMR_cause.m version [5abb14a644].




















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = FMR_cause(bonds);

% Causality for Flow-modulated R component

%SUMMARY FMR: flow-modulated resistor
%DESCRIPTION Port[in]: a simple one port resistor
%DESCRIPTION Port[out]: flow provides modulation for the resistor
%DESCRIPTION Used with the lin CR, with parameters flow,r this gives
%DESCRIPTION a resistance r*f_m where f_m is the flow on port [out]
%DESCRIPTION Can be bicausal - deduces modulation from e and f on port[in]

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/11/01 11:53:48  peterg
% %% Documentation
% %%
% %% Revision 1.2  1996/08/30 13:29:05  peter
% %% Error check on bond numbers.
% %%
% %% Revision 1.1  1996/08/09 08:28:02  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'FMR')==0
  return
end


% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% e_2 must be effort causality (imposes zero effort)
 if e_2 == 1 				% Conflict
   status = 1;
 else 					% Do the rest of the causality
   if e_2==0 				% Set to the fixed causality
     e_2 = -1;
   end;
   
   number_set = sum(sum([e_1 f_1 f_2]~=zeros(1,3) ));
   if number_set<2 			% Under causal
     status = -1;
   elseif number_set==2 		% Set the causality
     if f_2 == -1 			% Unicausal
       if e_1 == 0
 	e_1 = f_1;
       else
	 f_1 = e_1;
       end;
     elseif f_2 == 1 			% Bicausal
       e_1 = 1;
       f_1 = -1;
     elseif f_2 == 0
       if e_1==f_1
	 f_2 = -1;                      % Unicausal
       else
	 f_2 = 1;                      % Bicausal
       end;
     end;
     status = 0;
   elseif number_set==3 		% Check the causality
     if ( (f_2==-1)&(e_1~=f_1) )|( (f_2==1)&(e_1==f_1) )
       status = 1;
     else
       status = 0;
     end;
   end;
 end;
 
 bonds = [e_1 f_1
           e_2 f_2];

Added mtt/lib/comp/simple/FMR_eqn.m version [da8322ed66].













































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = FMR_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% FMR_eqn - equations for flow-modulated resistor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  FMR_eqn
% FMR_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/09/12 19:30:31  peter
% %% Updated to use new eqaution.m
% %%
% %% Revision 1.2  1996/08/30 18:35:43  peter
% %% New name argument added.
% %%
% %% Revision 1.1  1996/08/30 16:38:25  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'FMR')==0
  return
end


% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

if length(cr)==0  % Then do default unity CR
  if f_2 == -1 				% Standard with modulation
    if f_1 == 1 			% Flow out
      op = '*';
    else                                % Effort out
      op = '/';
    end;
    
    fprintf(eqnfile, '%s := %s%s%s;\n', ...
	varname(name,bond_number(1), -e_1), ...
	varname(name,bond_number(1), e_1), ...
	op, ...
	varname(name,bond_number(2), -1));
  else 					% Deduce modulation
    
    fprintf(eqnfile, '%s := %s/%s;\n', ...
	varname(name,bond_number(2), -1), ...
	varname(name,bond_number(1), -1), ...
	varname(name,bond_number(1), 1));
  end;
else  % write the full works
  if f_2 == -1 				% Standard with modulation
    outport = 1;
    outnumber = bond_number(1);
    if f_1 == 1 			% Flow out
      outcause = -1;
    else                                % Effort out
      outcause = 1;
    end;    
    incause = [-outcause; -1]; % Flow input on port 2
    eqn =  equation("FMR",name,cr,args,outnumber,outcause,outport, ...
                               bond_number,incause,1:ports);
    fprintf(eqnfile, '%s',eqn);

  else % Modulation is output
    outport = 2;
    outcause = -1;
    outnumber = bond_number(2);
    innumber = bond_number(1)*[1;1];    
    incause = [1; -1]; % Effort and flow on port 1
    inports = [1; 1];
    eqn =  equation("FMR",name,cr,args,outnumber,outcause,outport, ...
                               innumber,incause,inports);
    fprintf(eqnfile, '%s',eqn);
  end;
end;

  % Effort on port 2 is always zero
  fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(2), 1));

 
      


 



Added mtt/lib/comp/simple/FP_alias.m version [793aa2894c].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = FP_alias	# Port aliases for FP

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/07 15:01:09  peterg
## Named ports correctely  f --> 1, p --> 2
##
## Revision 1.1  1998/07/02 14:46:42  peterg
## Initial revision
##
###############################################################

  alias.f     = '1';
  alias.p     = '2';

  alias.s     = '1';
  alias.e     = '2';

endfunction


Added mtt/lib/comp/simple/FP_cause.m version [95df5297d9].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = FP_cause(bonds);
% Causality for FP component

%SUMMARY FP: converts true bond to a pseudo bond with power flow as flow
%DESCRIPTION Port [f]: True bond with a flow covariable
%DESCRIPTION Port [p]: Pseudo bond with power (ef) as flow variable



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/06/29 09:56:24  peterg
% %% Changed name to FP from ES
% %%
% %% Revision 1.1  1998/06/29 09:56:02  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/09/04  08:34:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'FP')==0
  return
end

% Same causality as TF
[bonds,status] = TF_cause(bonds);



Added mtt/lib/comp/simple/FP_eqn.m version [764e3abe81].



















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = FP_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% FP_eqn - equations for FP component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  FP_eqn
% FP_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/07 15:00:04  peterg
% %% Replaced e_ by f_
% %%          s_ by p_
% %%
% %% Revision 1.2  1998/06/29 09:54:16  peterg
% %% Changed name from ES to FP
% %%
% %% Revision 1.1  1998/06/29 09:53:22  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/03/27 10:59:43  peterg
% %% Zapped t_0 again ...
% %%
% %% Revision 1.2  1998/02/25 16:59:56  peterg
% %% Corrected enthalpy-entropy conversion -- use temp on the entropy side.
% %%
% %% Revision 1.1  1998/02/25 15:03:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'FP')==0
  return
end


% There are 2 ports; extract the information
f_bond = bonds(1,:);
p_bond = bonds(2,:);

% The efforts are the same
if p_bond(1)==1 %effort imposed on the pseudo bond 
    fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
else %effort imposed on the true bond 
    fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(2), 1), ...
    varname(name,bond_number(1), 1) );
end;

% The flows need to be converted
if p_bond(2)==-1 %flow imposed on the pseudo bond 
  fprintf(eqnfile,'%s := %s/%s;\n' , ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(1), 1) );
else % flow imposed on the true bond 
    fprintf(eqnfile,'%s := %s*%s;\n' , ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), 1) );
end;

Added mtt/lib/comp/simple/GY_alias.m version [e9fdf0c734].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = GY_alias	# Port aliases for GY

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/GY_cause.m version [eeb1062035].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = GY_cause(bonds);
% GY_cause - causality for GY component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  GY_cause
% [bonds,status] = GY_cause(bonds);

%SUMMARY GY: elementary gyrator component
%DESCRIPTION Energy conserving two-port
%DESCRIPTION e_1 = f(f_2); f_1 = f(e_2)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/09/12  09:42:12  peterg
% %% Fixed causality bug.
% %%
% %% Revision 1.1  1996/11/01  12:04:25  peterg
% %% Initial revision
% %% 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

%Causality of GY is same as that of a TF but with flipped effort/flow
bonds(2,:) = - bonds(2,2:-1:1);
[bonds,status] = TF_cause(bonds);
bonds(2,:) = - bonds(2,2:-1:1);

Added mtt/lib/comp/simple/GY_eqn.m version [b248761e3d].

















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = GY_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% GY_eqn - equations for GY component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  GY_eqn
% structure = GY_eqn(bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 11:51:06  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


if nargin<8
  eqnfile = 'stdout';
end;


% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Effort - flow
if e_1==1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
  outcause = -1;
  incause = 1;
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
  outcause = 1;
  incause = -1;
end;

eqn =  equation("GY",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Flow-effort
if f_1==-1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
  outcause = 1;
  incause = -1; 
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
  outcause = -1;
  incause = 1; 
end;

eqn =  equation("GY",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

Added mtt/lib/comp/simple/GY_seqn.m version [a2d9704220].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = GY_seqn (Name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = GY_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ##
  ## GYs have two ports; the input and output ports must be different
  N = mtt_check_sigs (outsig,insigs);

  if N!=2
    error("A GY must have exactly two ports");
  else
    if insigs(1,3)==outsig(3)	# First signal is on output port
      inport = 2;
    else
      inport = 1;
    endif
  endif
  
  insig = insigs(inport,:);
  inname = innames(inport,:);
  eqn = equation("""GY""",Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
		 insig(:,1),insig(:,2),inport);

  insigs = insig;		# Set the correct input signals
  innames = inname;		# Set the correct input names
  
endfunction

Added mtt/lib/comp/simple/I_alias.m version [0cb127a054].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = I_alias	# Port aliases for I

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in   = '1';
  alias.out  = '1';

endfunction


Added mtt/lib/comp/simple/I_cause.m version [30d1b2c13a].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = I_cause(bonds);
% I_cause  - Unicausal multiport C component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  I_cause
% [bonds,status] = I_cause(bonds)

%SUMMARY I: elementary I component
%DESCRIPTION Single port dynamic component
%DESCRIPTION Preferred integral causality (effort input)
%DESCRIPTION Cannot be bicausal


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% Same causal pattern as R component
[bonds,status] = R_cause(bonds);


Added mtt/lib/comp/simple/I_eqn.m version [b3f1b49438].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function structure =  I_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% I_eqn - equations for I component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  I_eqn
% structure =  I_eqn(bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


if nargin<8
  eqnfile = 'stdout';
end;

% Unicausal version
CorI = -1;
structure = cieqn(name,bond_number,bonds,direction,cr,args, structure, ...
                 CorI, eqnfile);

Added mtt/lib/comp/simple/I_seqn.m version [b8f0958d68].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = I_seqn (Name, name, cr, arg, outsig, insigs ,innames)

  ## usage:  [eqn,inbonds] = I_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port I's ??


  [eqn,insigs,innames] = CI_seqn ("I", Name, name, cr, arg, outsig, insigs ,innames);

endfunction

Added mtt/lib/comp/simple/PS_alias.m version [9be95d8930].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = PS_alias	# Port aliases for PS

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';
  alias.power  = '3';

endfunction


Added mtt/lib/comp/simple/PS_cause.m version [c1061e4855].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = PS_cause(bonds);
% Causality for PS component

%SUMMARY PS: Power sensor
%DESCRIPTION Port[in]: Inflowing bond
%DESCRIPTION Port[out]: Outflowing bond e_2=e_1; f_2=f_1.
%DESCRIPTION Port[power]: f = power = e_1*f_1 = e_2*f_2


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly three bonds.
if check_bonds(bonds,3,'PS')==0
  return
end

% Do the [in] and [out] ports -- like a TF
inout_bonds = bonds(1:2,:);
[inout_bonds,inout_status] = TF_cause(inout_bonds);

% Do the power port -- must have flow out and effort in
power_bonds = bonds(3,:);
for i = 1:2
  if (power_bonds(i)==1)
    power_status = 0;
  elseif (power_bonds(i)==0)
    power_bonds(i)==1;
    power_status = 0;
  else
    power_status = 1;
  end;
end;


  
  
  
  
% Reconstruct the bonds
bonds = [inout_bonds; power_bonds];

% Generate an overall status
if (inout_status==1)|(power_status==1)
  status = 1;
elseif
  (inout_status==-1)|(power_status==-1)
  status=-1;
else
  status = 0;
end;


Added mtt/lib/comp/simple/PS_eqn.m version [2c48293db7].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = PS_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% PS_eqn - equations for a power sensor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  PS_eqn
% PS_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly three bonds.
ports = 3;
if check_bonds(bonds,ports,'PS')==0
  return
end


% There are 3 ports; extract the information
inout_bonds = bonds(1:2,:);
power_bonds = bonds(3,:);

inout_direction = direction(1:2,:);
power_direction = direction(3,:);

% Do ports [in] and [out] - unit gain TF.
structure = TF_eqn(name,bond_number(1:2),inout_bonds,inout_direction, ...
'lin','effort,1', structure,eqnfile);

% Do port [power] - the power bit.
% This computes f_2 = e_1*f_1
fprintf(eqnfile,'%s := %s*%s;\n' , ...
    varname(name,bond_number(3), -power_bonds(1)), ...
    varname(name,bond_number(1),  1), ...
    varname(name,bond_number(1), -1) );



Added mtt/lib/comp/simple/RST_alias.m version [bd9ad2f3b7].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = RST_alias	# Port aliases for RST

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/RST_cause.m version [9248b5c94d].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = RST_cause(bonds);
% Causality for RST component

%SUMMARY RST: thermal resistor with entropy generation
%DESCRIPTION Port[in]: a simple one port resistor but:
%DESCRIPTION flow is multiplied by e_out
%DESCRIPTION Port[out]: thermal power - effort is temperature, flow is entropy flow
%DESCRIPTION Not bicausal (yet)


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'RST')==0
  return
end

% Same causality as RS
[bonds,status] = RS_cause(bonds);

Added mtt/lib/comp/simple/RST_eqn.m version [a09541d179].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = RT_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% RT_eqn - equations for flow-modulated resistor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  RT_eqn
% RT_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% VeRTion control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/03  09:30:45  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'RT')==0
  return
end


% There are 2 ports; extract the information
in_bonds = bonds(1,:);
out_bonds = bonds(2,:);
in_direction = direction(1,:);
out_direction = direction(2,:);

% Do port [in] - a standard resistor -- except for modulation by e_2
structure = R_eqn(name,bond_number(1),in_bonds,in_direction,cr,args, ...
    structure,eqnfile);

% Resistance is multiplied by effort e_1 + e_2 (ie effort on upsteam side of
% the 1 junction)
if in_bonds(1) == 1 % Flow output - divide by e_1+e_2
  fprintf(eqnfile,'%s := %s/(%s+%s);\n' , ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
else
   % Effort output - multiply by e_1+e_2
  fprintf(eqnfile,'%s := %s*(%s+%s);\n' , ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
end;


% Do port [out] - the thermal bit. RT is power conserving.
% This computes f_2 = e_1*f_1/e_2 or  e_2 = e_1*f_1/f_2
fprintf(eqnfile,'%s := %s*%s/%s;\n' , ...
    varname(name,bond_number(2), -out_bonds(1)), ...
    varname(name,bond_number(1),  1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), out_bonds(1)) );


Added mtt/lib/comp/simple/RS_alias.m version [6c14fcbe8a].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = RS_alias	# Port aliases for RS

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/RS_cause.m version [c96451fbaa].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = RS_cause(bonds);
% Causality for RS component

%SUMMARY RS: resistor with entropy generation
%DESCRIPTION Port[in]: a simple one port resistor
%DESCRIPTION Port[out]: thermal power - effort is temperature, flow is entropy flow
%DESCRIPTION Not bicausal (yet)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'RS')==0
  return
end

% There are 2 ports; extract the information
in_bonds = bonds(1,:);
out_bonds = bonds(2,:);

% Port [in] is an ordinary resistor
[in_bonds,in_status] = R_cause(in_bonds); 

% Port [out] has the same causality pattern as an ordinary resistor
[out_bonds,out_status] = R_cause(out_bonds); 

% Reconstruct the bonds
bonds = [in_bonds; out_bonds];

% Generate an overall status
if (in_status==1)|(out_status==1)
  status = 1;
elseif
  (in_status==-1)|(out_status==-1)
  status=-1;
else
  status = 0;
end;


Added mtt/lib/comp/simple/RS_eqn.m version [47ff4db70d].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = RS_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% RS_eqn - equations for flow-modulated resistor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  RS_eqn
% RS_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'RS')==0
  return
end


% There are 2 ports; extract the information
in_bonds = bonds(1,:);
out_bonds = bonds(2,:);
in_direction = direction(1,:);
out_direction = direction(2,:);

% Do port [in] - a standard resistor
structure = R_eqn(name,bond_number(1),in_bonds,in_direction,cr,args, ...
    structure,eqnfile);

% Do port [out] - the thermal bit. RS is power conserving.
% This computes f_2 = e_1*f_1/e_2 or  e_2 = e_1*f_1/f_2
fprintf(eqnfile,'%s := %s*%s/%s;\n' , ...
    varname(name,bond_number(2), -out_bonds(1)), ...
    varname(name,bond_number(1),  1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), out_bonds(1)) );


Added mtt/lib/comp/simple/R_alias.m version [12d1346387].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = R_alias	# Port aliases for R

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '1';

endfunction


Added mtt/lib/comp/simple/R_cause.m version [9a5c0ab992].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = R_cause(bonds);
% R_cause - Causality function for a (multi-port) unicausal R component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  R_cause
% [bonds,status] = R_cause(bonds)

%SUMMARY R: R component
%DESCRIPTION Multiport component with no dynamics
%DESCRIPTION Cannot be bicausal

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/08/30 19:05:08  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.
 

% Find the number of ports
[ports,junk] = size(bonds);

% default undercausal status
statuses = -ones(ports,1);

% Force unicausality
for i = 1:ports
  if (bonds(i,1)~=0)&(bonds(i,2)~=0) % Both bonds set
    statuses(i) = bonds(i,1)~=bonds(i,2);
  elseif bonds(i,2)~=0               % Bond 1 set
    bonds(i,1) = bonds(i,2);
    statuses(i) = 0;
  elseif bonds(i,1)~=0               % Bond 2 set
    bonds(i,2) = bonds(i,1);
    statuses(i) = 0;
  end;
end;

if max(statuses)==1
  status = 1;
elseif min(statuses)==-1
  status = -1;
else
  status = 0;
end;
  

Added mtt/lib/comp/simple/R_eqn.m version [9457569ec3].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = R_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% R_eqn - Equation function for a (multi-port) unicausal R component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  R_eqn
% structure = R_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/09/12 19:28:11  peter
% %% Added defaults (with no constitutive relationship)
% %%
% %% Revision 1.3  1996/09/12 16:40:45  peter
% %% Now does a default (when no constitutive relationship) with a unit
% %% constitutive relationship on each port.
% %%
% %% Revision 1.2  1996/09/12 13:12:04  peter
% %% Removed an fprintf that was a mistake.
% %%
% %% Revision 1.1  1996/09/12 11:00:56  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<8
  eqnfile = 'stdout';
end;


% Find the number of ports
[ports,junk] = size(bonds);


for outport = 1:ports
  outcause = -bonds(outport,1);
  outnumber = bond_number(outport);
  if length(cr)>0
    incause = bonds(:,1);
    inport = 1:ports;
    inbond = bond_number;
  else % default if no cr: unit cr on each port
    incause = bonds(outport,1);
    inport = outport;
    inbond = outnumber;
  end;
  
  eqn =  equation("R",name,cr,args,outnumber,outcause,outport, ...
                               inbond,incause,inport);
  fprintf(eqnfile, '%s',eqn);
end;


Added mtt/lib/comp/simple/R_seqn.m version [a084871fab].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = R_seqn (Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = R_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port R's use all potential signals

  N = mtt_check_sigs (outsig,insigs);
  
  inports = [1:N]; 
  eqn = equation("""R""",Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
		 insigs(:,1),insigs(:,2),inports);

  ## No change
  ## insigs = insigs;
  ## innames = innames;

endfunction

Added mtt/lib/comp/simple/SS_alias.m version [532fa03c37].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = SS_alias	# Port aliases for SS

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/28 19:08:22  peterg
## Some vector aliases added.
##
## Revision 1.1  1998/07/02 14:37:42  peterg
## Initial revision
##
###############################################################

  alias.in   = "1";
  alias.out  = "1";

  MAX = 10;
  value = "1";
  for i=1:MAX
    eval(sprintf("alias.in%i = \"%s\";", i, value));
    eval(sprintf("alias.out%i = \"%s\";", i, value));
    value = sprintf("%s,%i",value,i+1);
  endfor;
endfunction


Added mtt/lib/comp/simple/SS_cause.m version [8964220e5e].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = SS_cause(bonds)
% SS_cause = causality for an SS component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  SS_cause
% [bonds,status] = SS_cause(bonds)

%SUMMARY SS: source-sensor component
%DESCRIPTION multi-port source sensor component
%DESCRIPTION when the name is [name], acts as port `name' of a system.
%DESCRIPTION may be bicausal

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/11/01 14:41:14  peterg
% %% Check correct bonds
% %%
% %% Revision 1.1  1996/11/01 12:18:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

## Check that there is exactly one bonds.
##if check_bonds(bonds,1,'SS')==0
##  return
##end

disp("Starting SS_cause");

[n_bonds,junk] = size(bonds);
Status=zeros(n_bonds,1);
for i=1:n_bonds
  if (bonds(i,1)==0)|(bonds(i,2)==0) % Under causal
    Status(i) = -1;
  else                          % causal
    Status(i) = 0;
 end;
end;
status=min(Status);







Added mtt/lib/comp/simple/SS_eqn.m version [00c79cfc09].












































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function structure =  SS_eqn(name,Bond_number,Bonds,Direction,cr,args, ...
			     structure,filenum);

  disp("SS_eqn");
  name,Bond_number,Bonds,Direction

  ## Set up globals to count the component inputs and outputs. This relies on
  ## the named SS (the ports) being in the correct order. Using globals here
  ## avoids changing the common argument list for all _eqn files for something
  ## which is only used for named SS components.
  global local_u_index
  global local_y_index
  global at_top_level

  ## SS_eqn - equations for SS component
  ## 
  ##     ####################################### 
  ##     ###### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function  SS_eqn
  ## structure =  SS_eqn(name,bond_number,bonds,direction,cr,args, ...
  ##    structure,filenum);


  ## Copyright (c) P.J. Gawthrop, 1996.

  
  ## ###############################################################
  ## ### Version control history
  ## ###############################################################
  ## ### $Id$
  ## ### $Log$
  ## ### Revision 1.27  2005/03/21 10:34:47  gawthrop
  ## ### Tidied.
  ## ###
  ## ### Revision 1.26  2004/08/29 13:11:21  geraint
  ## ### Writes MTTyz vector in the same format as MTTx and MTTy: MTTyz($d,1)
  ## ##
  ## ### Revision 1.25  2003/01/07 18:09:21  geraint
  ## ### More informative error message.
  ## ##
  ## ### Revision 1.24  1999/10/22 02:20:32  peterg
  ## ### Changed error handleing of number of attributes >2
  ## ##
  ## ### Revision 1.23  1998/12/03 16:46:16  peterg
  ## ### Deblanked attributes so that zero attribute works.
  ## ##
  ## ### Revision 1.22  1998/07/28 19:05:46  peterg
  ## ### Fixed a few bugs.
  ## ##
  ## ### Revision 1.21  1998/07/28 14:21:31  peterg
  ## ### Vector SS ports.
  ## ##
  ## ### Revision 1.20  1998/07/08 14:42:52  peterg
  ## ### Removed the annoying info message - it causes problems with big
  ## ### systems
  ## ##
  ## ### Revision 1.19  1998/07/08 11:33:54  peterg
  ## ### Replace mtt_info by mtt_error when appropriate
  ## ##
  ## ### Revision 1.18  1998/07/08 11:30:45  peterg
  ## ### Removed second (fileID) argument from mtt_info
  ## ##
  ## ### Revision 1.17  1998/07/04 07:15:44  peterg
  ## ### Back under RCS
  ## ##
  ## ### Revision 1.16  1998/04/11 19:07:16  peterg
  ## ### Now do named ports as ordinary ports iff at top level.
  ## ### --- not yet complete, need to pass necesssary info though to this
  ## ###     function
  ## ##
  ## ### Revision 1.15  1997/12/16 19:16:07  peterg
  ## ### Added unknown input to the effort part.
  ## ##
  ## ### Revision 1.14  1997/12/16 18:25:19  peterg
  ## ### Added unknown_input attribure to flow -- effort still needs doing
  ## ##
  ## ### Revision 1.13  1997/09/18 13:15:15  peterg
  ## ### Fixed incorrect error message flagging inappropriate flow outputs
  ## ### -- used to give the effort rather than the flow in the error message.
  ## ##
  ## ### Revision 1.12  1997/08/26 07:51:30  peterg
  ## ### Now counts the local input and outputs by order of appearence rather
  ## ### than by port number - it therfore handles ports with bicausality correctely.
  ## ##
  ## ### Revision 1.11  1997/05/09 08:21:07  peterg
  ## ### Explicit computation of port number -- avoids str2num
  ## ##
  ## ### Revision 1.10  1997/03/22  17:13:03  peterg
  ## ### Fixed bug for port nos. > 1 digit!
  ## ##
  ## ### Revision 1.9  1997/03/22  15:50:59  peterg
  ## ### Changed #1.0f to %d format.
  ## ##
  ## ### Revision 1.8  1996/12/10 16:52:29  peterg
  ## ### Detect null string using strcmp, not length.
  ## ### Put filnum argument to mtt_info.
  ## ##
  ## ### Revision 1.7  1996/12/07 17:17:40  peterg
  ## ### Added some ;
  ## ##
  ## ### Revision 1.6  1996/12/05 09:49:09  peterg
  ## ### Explicit computation of port number from string.
  ## ##
  ## ### Revision 1.5  1996/12/04 21:27:53  peterg
  ## ### Replaced str2num by sprintf
  ## ##
  ## ### Revision 1.4  1996/08/18  20:06:21  peter
  ## ### Included zero outputs.
  ## ##
  ## ### Revision 1.3  1996/08/09 14:08:04  peter
  ## ### Empty effort and flow attributes replaced by 'external'.
  ## ##
  ## ### Revision 1.2  1996/08/08 16:38:19  peter
  ## ### Changed to filenumer type of fprintf
  ## ##
  ## ### Revision 1.1  1996/08/08 16:19:08  peter
  ## ### Initial revision
  ## ##
  ## ###############################################################


  ## The string 'cr' contains the effort attributes;  
  ## 'arg' contains the flow attributes. 
  ## external indicates an external variable
  ## internal indicates an internal variable
  ## anything else is the name of a constant.
  ## Blank is taken to be external
  ## If its a numbered port:
  ##     cr contains 'MTT_port'
  ##     arg contains port number

  if (strcmp(cr,"SS"))		# Then its the standard file
    a = char(strsplit(args,","))
    [N,M]=size(a);
    if (N~=2)			# Must have 2 arguments
      mtt_error(sprintf("SS should have 2 args not %i", N));
    endif
    effort_attribute = deblank(a(1,:));
    flow_attribute   = deblank(a(2,:));
  else				# Old style file
    effort_attribute = cr;
    flow_attribute = args;
  endif

  ## Default attributes
  if strcmp(effort_attribute,"")
    effort_attribute = "external";
  endif

  if strcmp(flow_attribute,"")
    flow_attribute = "external";
  endif

  inputs = structure(3);
  outputs = structure(4);
  zero_outputs = structure(5);
  unknown_inputs = structure(6);
  
  n_bonds = length(Bond_number)	# Multi port?
  for i=1:n_bonds		# Loop over all the bonds
    bond_number = Bond_number(i);
    bonds = Bonds(i,:);
    direction = Direction(i,:);
    Named_Port = name(1)=="[";	
    if Named_Port
      sname = name(2:length(name)); #Strip the []
    else
      sname = name;
    endif
    
    if Named_Port&&~at_top_level # It's a named port
      ## Effort 
      if bonds(1,1)==-1		# Source
	local_u_index = local_u_index + 1
	fprintf(filenum, "%s := %s_MTTu%d;\n", ...
		varname(sname, bond_number,1), sname, local_u_index);
      else # Sensor
	local_y_index = local_y_index + 1
	fprintf(filenum, "%s_MTTy%d := %s;\n", ...
		sname, local_y_index, varname(sname, bond_number,1));
      endif
      
      ## Flow 
      if bonds(1,2)==1		# Source
	local_u_index = local_u_index + 1
	fprintf(filenum, "%s := %s_MTTu%d;\n", ...
		varname(sname, bond_number,-1), sname, local_u_index);
      else # Sensor
	local_y_index = local_y_index + 1
	fprintf(filenum, "%s_MTTy%d := %s;\n", ...
		sname, local_y_index, varname(sname, bond_number,-1));
      endif
    else			# Now do SS which are not ports
      ## Effort
      if strcmp(effort_attribute, "external")
	if bonds(1,1)==-1	# Source
	  inputs = inputs+1;
	  fprintf(filenum, "%s := MTTu(%d,1);\n", ...
		  varname(sname, bond_number,1),inputs);
	else			# Sensor
	  outputs = outputs+1;
	  fprintf(filenum, "MTTy(%d,1) := %s;\n", ...
		  outputs, varname(sname, bond_number,1));
	endif
      elseif strcmp(effort_attribute, "unknown") # Unknown input
	unknown_inputs = unknown_inputs + 1;
	fprintf(filenum, "%s := MTTUi%d;\n", ...
		varname(sname, bond_number,1), unknown_inputs);
      elseif strcmp(effort_attribute, "internal")
	## Do nothing
      else 
	if bonds(1,1)==-1	# Named or unknown source
	  fprintf(filenum, "%s := %s;\n", ...
		  varname(sname, bond_number,1), effort_attribute);
	else # Sensor
	  if strcmp(effort_attribute, "zero") #Zero output
	    zero_outputs = zero_outputs + 1;
	    fprintf(filenum, "MTTyz(%d,1) := %s;\n", ...
		    zero_outputs, varname(sname, bond_number,1));
	  else
	    mtt_error([effort_attribute, " not appropriate for an output (", name, ")"]);
	  endif
	endif
      endif
      
      ## Flow
      if strcmp(flow_attribute, "external")
	if bonds(1,2)==1	# Source
	  inputs = inputs+1
	  fprintf(filenum, "%s := MTTu(%d,1);\n", varname(sname, bond_number,-1),inputs);
	else			# Sensor
	  outputs = outputs+1
	  fprintf(filenum, "MTTy(%d,1) := %s;\n", outputs, ...
		  varname(sname, bond_number,-1));
	endif
      elseif strcmp(flow_attribute, "unknown") # Unknown input
	unknown_inputs = unknown_inputs + 1
	fprintf(filenum, "%s := MTTUi%d;\n", ...
		varname(sname, bond_number,-1), unknown_inputs);
      elseif strcmp(flow_attribute, "internal")
	## Do nothing
      else			# Named constant
	if bonds(1,2)==1	# Source
	  fprintf(filenum, "%s := %s;\n", ...
		  varname(sname, bond_number,-1), flow_attribute);
	else			# Sensor
	  if strcmp(flow_attribute, "zero") #Zero output
	    zero_outputs = zero_outputs + 1
	    fprintf(filenum, "MTTyz(%d,1) := %s;\n", ...
		    zero_outputs, varname(sname, bond_number,-1));
	  else
	    mtt_error([flow_attribute, " not appropriate for an output (", name, ")"]);
	  endif
	endif
      endif
    endif
    
    structure(3) = inputs;
    structure(4) = outputs;
    structure(5) = zero_outputs;
    structure(6) = unknown_inputs;
    
  endfor
endfunction

Added mtt/lib/comp/simple/SS_seqn.m version [96afb2658a].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = SS_seqn (Name, name, cr, arg, outsig, ...
					 insigs,innames,is_port)

  ## usage:  [eqn,inbonds] = SS_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port SS's ??

  delim = "__";
  N = mtt_check_sigs (outsig,insigs);

  full_name = sprintf("%s%s%s", Name,delim,name);

  ## Get the special attibutes for SS
  attrib_name = char(strsplit(arg,","));
  [N_a,M_a]=size(attrib_name);
  if (N_a~=2)		# Must have 2 arguments
    mtt_error(sprintf("SS should have 2 args not %i", N_a));
  end;

  effort_attribute = deblank(attrib_name(1,:));
  flow_attribute   = deblank(attrib_name(2,:));

  ## Default attributes
  if strcmp(effort_attribute,"")||is_port
    effort_attribute = "external";
  end;
  
  if strcmp(flow_attribute,"")||is_port
    flow_attribute = "external";
  end;


  if mtt_is_external("SS",outsig,insigs) # Source
    if outsig(2)==1		# effort output.
      attribute = effort_attribute;
    else
      attribute = flow_attribute;
    endif

    ## Create the equation
    LHS = varname(Name, outsig(1,1), outsig(1,2));
    RHS = Source_seqn (attribute,full_name);
    eqn = sprintf("%s := %s;", LHS, RHS);
  else				# Sensor
   if insigs(1,2)==1		# effort output.
     attribute = effort_attribute;
   else
     attribute = flow_attribute;
   endif

   ## Create the equation
   LHS = Sensor_seqn (attribute,full_name);
   RHS = varname(Name, insigs(1,1), insigs(1,2));
   eqn = sprintf("%s := %s;", LHS, RHS);
 endif
 
endfunction

Added mtt/lib/comp/simple/Sensor_seqn.m version [60348ae058].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function LHS = Sensor_seqn (attribute,name)

  ## usage:  LHS = Sensor_seqn (attribute,name)
  ##
  ## Write the LHS of a sensor equation
  

  if strcmp(attribute,"external")
    LHS = sprintf("MTTy_%s", name);  
  elseif strcmp(attribute,"internal")
    LHS = sprintf("MTTy_%s", name); 
  else
    error(sprintf("attribute ""%s"" not appropriate for a " ...
    "source"), attribute);
  endif
endfunction

Added mtt/lib/comp/simple/Source_seqn.m version [7ea4860836].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function RHS = Source_seqn (attribute,name)

  ## usage:  RHS = Source_seqn (attribute,name)
  ##
  ## Write the RHS of a source equation
  
  if strcmp(attribute,"external")
    RHS = sprintf("MTTu_%s",name);
   elseif strcmp(attribute,"internal")
     error(sprintf("attribute ""internal"" not appropriate for a " 
 	"source"));
  else
    RHS = attribute;
  endif
  
endfunction

Added mtt/lib/comp/simple/TF_alias.m version [5fdd82024a].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function alias = TF_alias	# Port aliases for TF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Added mtt/lib/comp/simple/TF_cause.m version [7adfcd4d2d].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = TF_cause(bonds);
% TF_cause - causality for a TF component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  TF_cause
% [bonds,status] = TF_cause(bonds)

%SUMMARY TF: elementary transformer component
%DESCRIPTION Energy conserving two-port
%DESCRIPTION e_1 = f(e_2); f_1 = f(f_2)


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/11/01 12:05:54  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'TF')==0
  return
end


%Causality of TF is same as that of a junction
[bonds,status] = zero_cause(bonds);

Added mtt/lib/comp/simple/TF_eqn.m version [da8cba2d73].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = TF_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/09/10 10:41:37  peter
% %% Now used equation.m to write the equations.
% %%
% %% Revision 1.1  1996/08/19 09:05:04  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

			
if nargin<8
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'TF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Effort
outcause = 1;
incause = 1;
if e_1==1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
end;

eqn =  equation("TF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Flow
outcause = -1;
incause = -1;
if f_1==-1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
end;

eqn =  equation("TF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);








Added mtt/lib/comp/simple/TF_seqn.m version [4d8c4483a1].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = TF_seqn (Name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = TF_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ##
  ## TFs have two ports; the input and output ports must be different
  N = mtt_check_sigs (outsig,insigs);

  if N!=2
    error("A TF must have exactly two ports");
  else
    if insigs(1,3)==outsig(3)	# First signal is on output port
      inport = 2;
    else
      inport = 1;
    endif
  endif
  
  insig = insigs(inport,:);
  inname = innames(inport,:);
  eqn = equation("""TF""",Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
			 insig(:,1),insig(:,2),inport);

  insigs = insig;		# Set the correct input signals
  innames = inname;		# Set the correct input names
  
endfunction

Added mtt/lib/comp/simple/check_bonds.m version [1d5b1ad1e3].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ok = check_bonds(bonds,n,component);
% check_bonds - check to see correct number (n) of bonds.
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  check_bonds
% err = check_bonds(bonds,n);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.
% Check that there are exactly two bonds.
[n_bonds,cols] = size(bonds);
if n_bonds~=n
  mtt_info(sprintf('MTT error: %s must have %1.0f (not %1.0f) bonds', ...
      component, n, n_bonds));
  ok=0;
else
  ok=1;
end

Added mtt/lib/comp/simple/cicause.m version [94090e2bee].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = cicause(bonds,default);
% cicause - Sets causality for C & I components
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cicause
% [bonds,status] = cicause(bonds,default)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.



if (norm(bonds)>1)
  if (bonds(1)==-bonds(2)) % Over causal
    status = 1;
  else                       % Causal
    status = 0;
  end;
elseif norm(bonds)==0 % Acausal
  % bonds = default*[1 1]; %Set integral causality
  % status = 0;
  status = -1;
else % Set causality 
  % Effort
  if bonds(1)==0
    status = 0;
    bonds(1) = bonds(2);
  end;

  % Flow
  if bonds(2)==0
    status = 0;
    bonds(2) = bonds(1);
  end;

end;

Added mtt/lib/comp/simple/cieqn.m version [e985d8ce2c].















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function structure =  cieqn(name, bond_number,bonds,direction,cr,args, ...
    structure,CorI,eqnfile);
% cieqn - Equation function for a (multi-port) unicausal C or I component
% CorI = 1 for C, -1 for I; 0 for ISW

% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cieqn


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/06/29 13:05:08  peterg
% %% Changed cieqn so that sign ignored.
% %%
% %% Revision 1.2  1997/12/04 13:48:00  peterg
% %% Added sign info to take account of direction of bonds.
% %%
% %% Revision 1.1  1997/04/09  10:18:26  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<8
  eqnfile = 'stdout';
end;

if (CorI==1)
  comp_type = "C";
else
  comp_type = "I";
endif

CorIorISW = CorI;
if CorIorISW==0 % ISW
   CorI = -1;
end;


% Find the number of ports
[ports,junk] = size(bonds);

% Right-hand side causality
RHS_cause = (bonds(:,1)==CorI*ones(ports,1))*CorI
state_cause = zeros(ports,1); % State causality

for outport = 1:ports

#  % Sort out direction
#  if direction(outport,1) == 1
#    sign = '+';
#  else
#    sign = '-';
#  end;

  sign = '+';  
  LHS_number = bond_number(outport);
  if bonds(outport,1) == -CorI % Integral causality on this port
    state = structure(1)+1;
    LHS_cause = CorI;

    % Print equation of form x_i = MTTx(i)
    fprintf(eqnfile, '%s := MTTx(%1.0f,1);\n', ...
        varname(name,LHS_number, state_cause), state);

    % Print equation of form xdot = input - with sign
    fprintf(eqnfile, 'MTTdX(%1.0f,1) := %s%s;\n', state, sign, ...
                     varname(name,LHS_number,-LHS_cause));
    % Print equation of form output = CR (state) 
    eqn =  equation(comp_type,name,cr,args,LHS_number,LHS_cause,outport, ...
                             bond_number,state_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(1) = state;
  else % Derivative causality
    nonstate = structure(2)+1;
    LHS_cause = -CorI;

    % Print equation of form zdot = MTTdz(i) -- with sign 
    fprintf(eqnfile, '%s := %sMTTdz(%1.0f,1);\n', ...
                             varname(name,LHS_number,LHS_cause), sign, ...
                             nonstate);
    % Print equation of form MTTz(i) = z_i
    fprintf(eqnfile, 'MTTz(%1.0f,1) := %s;\n', nonstate, ...
             varname(name,LHS_number, state_cause));
				 
   % Print equation of form z_i = CR(input)
      eqn =  equation(comp_type,name,cr,args,LHS_number,state_cause, outport, ...
                             bond_number,RHS_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(2) = nonstate;
 end;
end;









Added mtt/lib/comp/simple/comp_ports.m version [09c16f9abd].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ports = comp_ports(comp_type,N)
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  comp_ports
% ports = comp_ports(comp_type)
% Returns the port list for simple components


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.8  1998/06/29 12:16:05  peterg
% %% Whoops - FP bonds are p and f (in that order)
% %%
% %% Revision 1.7  1998/06/29 12:13:36  peterg
% %% Changed FP ports to f and p
% %%
% %% Revision 1.6  1998/06/29 09:55:17  peterg
% %% Changed name to FP from ES
% %%
% %% Revision 1.5  1998/04/12 15:01:53  peterg
% %% Converted to uniform port notation - always use []
% %%
% %% Revision 1.4  1998/03/31 08:39:31  peterg
% %% Added EBTF
% %%
% %% Revision 1.3  1997/11/21 11:32:57  peterg
% %% N ports numbered 1..N
% %%
% %% Revision 1.2  1997/08/28  08:08:24  peterg
% %% Added RS component to the two-port list
% %%
% %% Revision 1.1  1997/08/02 19:35:47  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


junctions = '-zero-one-';
one_ports = '-SS-';
two_ports = '-TF-GY-AE-AF-FMR-RS-EBTF-';
N_ports   = '-R-C-I-';
comp_type = ['-', comp_type, '-'];

#if length(findstr(comp_type,junctions))==1
#  ports = ['[undefined]'];
#elseif length(findstr(comp_type,one_ports))==1
#  ports = ['[in]'];
#elseif length(findstr(comp_type,two_ports))==1
#  ports = ['[in]';'[out]'];
#elseif length(findstr(comp_type,'[-EMTF-]'))==1
#  ports = ['[in]';'[out]';'[mod]'];
#elseif length(findstr(comp_type,'[-FP-]'))==1
#  ports = ['[p]';'[f]'];
#elseif length(findstr(comp_type,'[-PS-]'))==1
#  ports = ['[in]';'[out]';'[power]'];
#elseif length(findstr(comp_type,N_ports))==1
#  if N==1
#    ports = ['[in]'];
#  elseif N==2
#    ports = ['[in]';'[out]'];
#  elseif N>2
#    ports = '[1]';
#    for i=2:N
#      ports = [ports; sprintf("[%i]",i)];
#    end;
#  end;
#end;
 
# All the above is now done in the alias files
  ports = '[1]';
  for i=2:N
    ports = [ports; sprintf("[%i]",i)];
  end;

endfunction

Added mtt/lib/comp/simple/juncause.m version [c96eb0a15f].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = juncause(bonds,jun,cause)
% [bonds,status] = juncause(bonds,jun,cause)

% Causality for  either effort or flow on  either zero or one junctions

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/08/09  08:29:04  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


j =  (3-cause)/2; % j is 1 for effort, 2 for flow

[n_bonds,junk] = size(bonds);
[causing_bond, n,other_bonds,m] = getindex(bonds(:,j),jun);
if n>1 % over causal
  status = 1;
elseif n==1 %causal
  status = 0;
  bonds(other_bonds(:,1),j) = -jun*ones(m,1);
elseif n==0  % undercausal - try other way
  [causing_bond, n,other_bonds,m] = getindex(bonds(:,j),-jun);
  if n==n_bonds % over causal
    status = 1;
  elseif n==n_bonds-1 %causal
    status = 0;
    bonds(other_bonds(:,1),j) = jun*ones(m,1);
  else  % undercausal
    status = -1;
  end;
end;




Added mtt/lib/comp/simple/junction_seqn.m version [1675df1f08].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [eqn,insigs,innames] = junction_seqn (jun_type,Name, outsig, ...
					       insigs, innames)
  ## usage:  [eqn,insigs] = junction_seqn (jun_type,Name, outport, outsig, ...
  ##				       insigs)
  ##
  ## 
  ## Junctions

  ## Sanity check
  N = mtt_check_sigs (outsig,insigs);

  outport = outsig(3);

  ## Setup up causality corresponding to junction
  if jun_type=="0"
    i_jun_type = 1;
  elseif jun_type=="1"
    i_jun_type = -1;
  else
    error("Junction type %s unknown", jun_type)
  endif

  ## Is output same causality as junction?
  same_type = outsig(2)==i_jun_type;


  ## LHS 
  eqn = sprintf("%s :=", varname(Name, abs(outsig(1)), outsig(2)));

  ## Find the input bond of the same causality as junction
  one = ones(N,1);
  inport = find(insigs(:,2)==i_jun_type*one);

  ##RHS
  if same_type
    insig = insigs(inport,:);
    inname = innames(inport,:);
    eqn = sprintf("%s\n\t%s", eqn, varname(Name, abs(insigs(inport,1)),i_jun_type));
  else
    insig=[];
    inname="";
    inports = [];
    out_dir = sign(insigs(inport,1));
    for i=1:N
      if i!=inport
	in_dir = sign(insigs(i,1));
	plusminus = sign2name(-in_dir*out_dir);
	eqn = sprintf("%s\n\t%s%s", eqn, plusminus, varname(Name, ...
		      abs(insigs(i,1)), -i_jun_type));
	insig = [insig; insigs(i,:)];
	inname = [inname; innames(i,:)];
      endif
    endfor
  endif
  eqn = sprintf("%s;", eqn);
  insigs = insig;
  innames = inname;
endfunction

Added mtt/lib/comp/simple/juneqn.m version [1b08ed726b].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  juneqn(name,bond_number,bonds,direction,cr,args,jun,filenumber)
% juneqn - Equations for  both  effort and flow on  either 
% zero or one junctions
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  juneqn
% juneqn(name,bond_number,bonds,direction,cr,args,jun,filenumber)

% Copyright (c) P.J. Gawthrop, 1996.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/12/05 10:02:45  peterg
% %% Explicit generation of strong-causality equations -- oneequation not
% %% used now.
% %%
% %% Revision 1.2  1996/08/08  18:09:10  peter
% %% Changed to finenumber format.
% %%
% %% Revision 1.1  1996/08/08 16:38:50  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Same causality as junction
column =  (3-jun)/2; 
[causing_bond,n,other_bonds,m] = getindex(bonds(:,column),jun)
for i=other_bonds'
  fprintf(filenumber, '%s \t:=\t%s;\n', ...
      varname(name, bond_number(i),jun), ...
      varname(name, bond_number(causing_bond),jun) ...
  );
end;


% Opposite causality to junction
column =  (3+jun)/2;
[caused_bond,n,other_bonds,m] = getindex(bonds(:,column),jun)
fprintf(filenumber, '%s\t:= \n',  varname(name, bond_number(caused_bond),-jun));
for i=other_bonds'
  term_sign = -direction(caused_bond,column)*direction(i,column)
  fprintf(filenumber, '\t\t%s %s\n', sign2name(term_sign), ...
      varname(name, bond_number(i),-jun));
end;
fprintf(filenumber, ';\n');

Added mtt/lib/comp/simple/one_cause.m version [3018a4a5e9].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = one_cause(bonds);
% one_cause - causality for a one junction
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  one_cause


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

%Effort
[bonds,e_status] = juncause(bonds,-1,1);

%Flow
[bonds,f_status] = juncause(bonds,-1,-1);

if (e_status==1)|(f_status==1)       % Over causal
  status = 1;
elseif (e_status==-1)|(f_status==-1) % Under causal
  status = -1;
else                                  % causal
  status = 0;
end;

Added mtt/lib/comp/simple/one_eqn.m version [ec7724f3d8].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  structure = one_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% one_eqn - equations for a one junction
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  one_eqn
% one_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/05 10:00:49  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

disp("one-eqn")
name,bond_number,bonds,direction,cr,args
if nargin<7
  eqnfile = 'stdout';
end;

juneqn(name,bond_number,bonds,direction,cr,args,-1,eqnfile)




Added mtt/lib/comp/simple/oneeqn.m version [b6cf957a10].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  oneeqn(name,LHS_number,LHS_cause,RHS_number,RHS_cause,cr,args, ...
    eqnfile);
% oneeqn - prints a single equation
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  oneeqn
% oneeqn(name,LHS_number,LHS_cause,RHS_number,RHS_cause,cr,args,eqnfile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



if nargin<7
  eqnfile = 'stdout';
end;


fprintf(eqnfile, '%s := %s;\n', ...
    varname(name, LHS_number,LHS_cause), ...
    cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args));

Added mtt/lib/comp/simple/zero_cause.m version [93a4da1931].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [bonds,status] = zero_cause(bonds);
% zero_cause - causality for zero junctions
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  zero_cause
% [bonds,status] = zero_cause(bonds);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Effort
[bonds,e_status] = juncause(bonds,1,1);

%Flow
[bonds,f_status] = juncause(bonds,1,-1);

status = 0;
if (e_status==1)|(f_status==1)       % Over causal
  status = 1;
endif;
if (e_status==-1)|(f_status==-1) % Under causal
  status = -1;
endif;

  

Added mtt/lib/comp/simple/zero_eqn.m version [1f6c065bc3].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function structure =  zero_eqn(name, bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% zero_eqn - equations for zero junctions
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  zero_eqn
% zero_eqn(name, bond_number,bonds,direction,cr,args, structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if nargin<7
  eqnfile = 'stdout';
end;


juneqn(name, bond_number,bonds,direction,cr,args,1,eqnfile)




Added mtt/lib/control/PPP/Beam_numpar.m version [0d62366729].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Script file  Beam_numpar.m
%% numpar file (Beam_numpar.m)
%% Generated by MTT at Thu Apr 22 07:00:08 BST 1999
% Global variable list
global ...
     area ...
     areamoment ...
     beamlength ...
     beamthickness ...
     beamwidth ...
     density ...
     ei ...
     n ...
     youngs ...
     dk ...
     dm ...
     dz ...
     rhoa ;
 %  -*-octave-*- Put Emacs into octave-mode
 %  Numerical parameter file (Beam_numpar.txt)
 %  Generated by MTT at Mon Apr 19 06:24:08 BST 1999

 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% Version control history
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% $Id$
 %  %% $Log$
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %  Parameters
n =  7;
beamlength =  0.58;
beamwidth =  0.05;
beamthickness =  0.005;
youngs =  1e6;
density =  1e5;
area =  beamwidth*beamthickness;
areamoment =  (beamthickness*beamwidth^2)/12;

ei=  58.6957			; %  from Reza
rhoa=  0.7989			; %  from Reza
 
dz =  beamlength/n;  %  BernoulliEuler
dm =  rhoa*dz;  %  BernoulliEuler
dk =  ei/dz;  %  BernoulliEuler

Added mtt/lib/control/PPP/Beam_sm.m version [cd16b034f7].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-octave-*- Put Emacs into octave-mode%
function [mtta,mttb,mttc,mttd] = Beam_sm();
% [mtta,mttb,mttc,mttd] = Beam_sm();
%System Beam, representation sm, language m;
%File Beam_sm.m;
%Generated by MTT on Thu Apr 22 07:02:48 BST 1999;
%
%====== Set up the global variables ======%
global ...
area ...
areamoment ...
beamlength ...
beamthickness ...
beamwidth ...
density ...
ei ...
n ...
youngs ...
dk ...
dm ...
dz ...
rhoa ;
%a matrix%
mtta = zeros(14,14);
mtta(1,2) = -dk/dz;
mtta(2,1) = 1.0/(dm*dz);
mtta(2,3) = -2.0/(dm*dz);
mtta(2,5) = 1.0/(dm*dz);
mtta(3,2) = (2.0*dk)/dz;
mtta(3,4) = -dk/dz;
mtta(4,3) = 1.0/(dm*dz);
mtta(4,5) = -2.0/(dm*dz);
mtta(4,7) = 1.0/(dm*dz);
mtta(5,2) = -dk/dz;
mtta(5,4) = (2.0*dk)/dz;
mtta(5,6) = -dk/dz;
mtta(6,5) = 1.0/(dm*dz);
mtta(6,7) = -2.0/(dm*dz);
mtta(6,9) = 1.0/(dm*dz);
mtta(7,4) = -dk/dz;
mtta(7,6) = (2.0*dk)/dz;
mtta(7,8) = -dk/dz;
mtta(8,7) = 1.0/(dm*dz);
mtta(8,9) = -2.0/(dm*dz);
mtta(8,11) = 1.0/(dm*dz);
mtta(9,6) = -dk/dz;
mtta(9,8) = (2.0*dk)/dz;
mtta(9,10) = -dk/dz;
mtta(10,9) = 1.0/(dm*dz);
mtta(10,11) = -2.0/(dm*dz);
mtta(10,13) = 1.0/(dm*dz);
mtta(11,8) = -dk/dz;
mtta(11,10) = (2.0*dk)/dz;
mtta(11,12) = -dk/dz;
mtta(12,11) = 1.0/(dm*dz);
mtta(12,13) = -2.0/(dm*dz);
mtta(13,10) = -dk/dz;
mtta(13,12) = (2.0*dk)/dz;
mtta(13,14) = -dk/dz;
mtta(14,13) = 1.0/(dm*dz);
%b matrix%
mttb = zeros(14,1);
mttb(11) = 1.0/dz;
mttb(13) = -2.0/dz;
%c matrix%
mttc = zeros(1,14);
mttc(1,1) = 1.0/dm;
%d matrix%
mttd = zeros(1,1);

Added mtt/lib/control/PPP/NMPsystem.m version [2fed1aea39].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D] = NMPsystem ()

  ## usage:  [A,B,C,D] = NMPsystem ()
  ##
  ## NMP system example (2-s)/(s-1)^3

  A = [3 -3 1
       1  0  0
       0  1  0];

  B = [1 
       0 
       0];

  C = [0 -0.5 1];

  D = 0;



endfunction

Added mtt/lib/control/PPP/TwoMassSpring.m version [5f26391fd5].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D] = TwoMassSpring (k,m_1,m_2)

  ## usage:  [A,B,C,D] = TwoMassSpring (k,m_1,m_2)
  ##
  ## Two mass-spring example from Middleton et al.  EE9908

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  1999/05/18 22:31:26  peterg
  ## Fixed error in dim of D
  ##
  ## Revision 1.1  1999/05/18 22:28:56  peterg
  ## Initial revision
  ##
  ###############################################################


  A = [0    1 0 0
       -k/m_1 0 k/m_1 0
       0    0 0 1
       k/m_2 0 -k/m_2 0];
  B = [0
       1/m_1
       0 
       0];
  C = [1 0 0 0
       0 0 1 0];

  D = zeros(2,1);

endfunction

Added mtt/lib/control/PPP/airc.m version [c3d4271b18].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D] = airc
% System AIRC 
% This system is the aircraft example from the book:
% J.M Maciejowski: Multivariable Feedback Design  Addison-Wesley, 1989
% It has 5 states, 3 inputs and 3 outputs.

% P J Gawthrop Jan 1998

A = [    0         0    1.1320         0   -1.0000
         0   -0.0538   -0.1712         0    0.0705
         0         0         0    1.0000         0
         0    0.0485         0   -0.8556   -1.0130
         0   -0.2909         0    1.0532   -0.6859];

B = [    0         0         0
   -0.1200    1.0000         0
         0         0         0
    4.4190         0   -1.6650
    1.5750         0   -0.0732];

C = [1     0     0     0     0
     0     1     0     0     0
     0     0     1     0     0];

D = zeros(3,3);


Added mtt/lib/control/PPP/autm.m version [e5ff112d0d].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D]=autm
% System AUTM
% This system is the automotive gas turbine example from the book:
% Y.S. Hung and A.G.J. Macfarlane: "Multivariable Feedback. A
% quasi-classical approach."  Springer 1982
% It has 12 states, 2 inputs and 2 outputs.

% P J Gawthrop Jan 1998

%A-matrix
A = zeros(12,12);
A(1,2) 	= 1;
A(2,1) 	= -0.202; A(2,2) = -1.150;
A(3,4) 	= 1;
A(4,5) 	= 1;
A(5,3) 	= -2.360; A(5,4) = -13.60; A(5,5) = -12.80;
A(6,7) 	= 1;
A(7,8) 	= 1;
A(8,6) 	= -1.620; A(8,7) = -9.400; A(8,8) = -9.150;
A(9,10) = 1;
A(10,11) = 1;
A(11,12) = 1;
A(12,9) = -188.0; A(12,10) = -111.6; A(12,11) = -116.4; A(12,12) = -20.8;

%B-matrix
B = zeros(12,2);
B(2,1)   =  1.0439; B(2,2)   = 4.1486;
B(5,1)   = -1.794;  B(5,2)   = 2.6775;
B(8,1)   =  1.0439; B(8,2)   = 4.1486;
B(12,1)  = -1.794;  B(12,2)  = 2.6775;

%C-matrix
C = zeros(2,12);
C(1,1)  = 0.2640; C(1,2)  = 0.8060; C(1,3) = -1.420; C(2,4) = -15.00; 
C(2,6)  = 4.9000; C(2,7)  = 2.1200; C(2,8) = 1.9500; C(2,9) = 9.3500;
C(2,10) = 25.800; C(2,11) = 7.1400;

%D-matrix
D = zeros(2,2);

Added mtt/lib/control/PPP/butterworth_matrix.m version [c40a4036f0].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function A = butterworth_matrix (n,p)

  ## usage:  A = butterworth (n,p)
  ##
  ## A-matrix for generating nth order Butterworth functions with parameter p

  ## Copyright (C) 2000 by Peter J. Gawthrop

  ## Butterworth poly
  pol = ppp_butter(n,p);
  
  ## Create A matrix (controller form)
  A = [-pol(2:n+1)
       eye(n-1) zeros(n-1,1)];
	
endfunction

Added mtt/lib/control/PPP/damped_matrix.m version [62d084883f].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function A = damped_matrix (frequency,damping)

  ## usage:  A = damped_matrix (frequency,damping)
  ##
  ## Gives an A matrix with eigenvalues with specified 
  ## frequencies and damping ratio

  N = length(frequency);

  if nargin<2
    damping = zeros(size(frequency));
  endif
  
  if length(damping) != N
    error("Frequency and damping vectors have different lengths");
  endif
  
  A = zeros(2*N,2*N);
  for i=1:N
    j = 2*(i-1)+1;
    A_i = [-2*damping(i)*frequency(i) -frequency(i)^2
	   1                           0];
    A(j:j+1,j:j+1) = A_i;
  endfor
  
endfunction

Added mtt/lib/control/PPP/laguerre_matrix.m version [5e8ca33d42].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function A = laguerre_matrix (n,p)

  ## usage:  A = laguerre_matrix (n,p)
  ##
  ## A-matrix for generating nth order Laguerre functions with parameter p

  ## Copyright (C) 1999 by Peter J. Gawthrop

  if n<1			# Creatre empty matrix
    A = [];
  else				# Create A matrix
    A = diag(-p*ones(n,1));
    for i=1:n-1
      A = A + diag(-2*p*ones(n-i,1),-i);
    endfor
  endif

endfunction

Added mtt/lib/control/PPP/ppp_RT.m version [db4d51d37d].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function [y,u] = ppp_RT (U)

  ## usage:  [y,u] = ppp_RT (U)
  ##
  ## 

endfunction

Added mtt/lib/control/PPP/ppp_RT_sim.m version [b2a01fdb41].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y,u] = ppp_RT_sim (U)

  ## usage:  [y,u] = ppp_RT_sim (U)
  ##
  ## U   PPP weight (column vector)

  global system_name_sim i_ppp_sim x_0_sim y_sim u_sim A_u_sim


  ## Data from previous time - last point not used
  if length(y_sim)>0		# Avoid initial junk
    [n_t_old,junk] = size(y_sim);
    y = y_sim(1:n_t_old-1,:); u = u_sim(1:n_t_old-1,:);
  else
    y=[]; u=[];
  endif

endfunction

Added mtt/lib/control/PPP/ppp_RT_sim_compute.m version [bbee59ecfc].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ppp_RT_sim_compute (U)

  ## usage:  [y,u] = ppp_RT_sim_compute (U)
  ##
  ## U   PPP weight (column vector)

  global system_name_sim i_ppp_sim x_0_sim y_sim u_sim A_u_sim simpar_sim

  ## System details -- defines simulation within ol interval
  par = eval(sprintf("%s_numpar;", system_name_sim));
  t = [0:simpar_sim.dt:simpar_sim.last];
  n_t = length(t);
  [n_x,n_y,n_u] = eval(sprintf("%s_def", system_name_sim));
  [n_U,junk] = size(A_u_sim);

  ## Set up u_star
  u_star = ppp_ustar(A_u_sim,1,t,0,0,n_u-n_U);

  ## Simulate
  par(i_ppp_sim(:,3)) = U;		# Update the simulation ppp weights
  [y_sim,x] = eval(sprintf("%s_sim(x_0_sim, par, simpar_sim, u_star);", \
			   system_name_sim));
  x_0_sim  = x(n_t,:)';		# Extract state for next time
  u_sim = u_star(:,1:n_U)*U;
endfunction

Added mtt/lib/control/PPP/ppp_are.m version [fabd8baa32].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [P,A_u,A_w,k] = ppp_are (A,B,C,D,Q,R,A_type)

  ## usage:  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R,A_type)
  ##
  ## 

  if nargin<1
    disp("usage:  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R,A_type)");
    return
  endif
  
  if nargin<7
    A_type = "feedback";
  endif
  
  [n_x,n_u,n_y] = abcddim(A,B,C,D); # Dimensions
  n_q = is_square(Q);		# Size of Q
  if n_q==0
    error("Q must be square");
  endif
  
  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)
  if n_q==n_y			# Output weight
    Q_x =  C'*Q*C;		# Weighting on x
  elseif n_q==n_x		# State weight
    Q_x = Q;
  else
    error(sprintf("Q (%ix%i) must be %ix%i or %ix%i",n_q,n_q,n_y,n_y,n_x,n_x));
  endif

  [k, P, poles] = lqr (A, B, Q_x, R); # Algebraic Riccati solution

  ## Basis functions
  if strcmp(A_type,"companion")
    A_u = compan(poly(poles));
  elseif strcmp(A_type,"feedback")
    A_u = A-B*k;
  else
    error(sprintf("A_type must be %s, not %s", "companion or feedback", A_type));
  endif
  
    ## Avoid spurious imag parts due to rounding
    A_u = real(A_u);		

  ## Setpoint basis functions
  A_w = 0;

endfunction

Added mtt/lib/control/PPP/ppp_aug.m version [85d071a163].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,v] = ppp_aug (A_1,A_2)

  ## usage:  [A,v] = ppp_aug (A_1,A_2)
  ##
  ## Augments square matrix A_1 with square matrix A_2 to create A=[A_1 0; A_2 0];
  ## and generates v, a compatible column vector with unit elements

  ## Copyright (C) 1999 by Peter J. Gawthrop


  [n_1,m_1] = size(A_1);
  if n_1 != m_1
    error("A_1 must be square");
  endif
  
  [n_2,m_2] = size(A_2);
  if n_2 != m_2
    error("A_2 must be square");
  endif

  A = [A_1            zeros(n_1,n_2)
       zeros(n_2,n_1) A_2];

  v = ones(n_1+n_2,1);

endfunction

Added mtt/lib/control/PPP/ppp_butter.m version [e0dda0f911].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function pol = ppp_butter (order,radius)

  ## usage:  pol = cgpc_butter (order,radius)
  ##
  ## Butterworth polynomial of given order and pole radius
  ## Copyright (C) 1999 by P.J. Gawthrop

  ## 	$Id$	

  theta = pi/(2*order);		# Angle with real axis

  even = (floor(order/2)==order/2);
  if even
    pol=1; N=order/2;
  else
    pol=[1 radius]; N=(order-1)/2;
  endif
  
  for i=1:N
    pol=conv(pol, [1 2*radius*cos(i*theta) radius^2]);
  endfor

endfunction

Added mtt/lib/control/PPP/ppp_closedloop.m version [3bb5af1be2].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Ac,Bc,Cc,Dc] = ppp_closedloop (A,B,C,D,k_x,k_w,l_x,l_y)

  ## usage:  [Ac,Bc,Cc,Dc] = ppp_closedloop (A,B,C,K_x,K_w,K_y,L)
  ##
  ## 


  ## Closed loop input  is [w;v]. 
  ## Closed loop output is [y;u]. 
  ## w is reference signal
  ## v is input disturbance
  ## Inputs:
  ## 	A,B,C,D		MIMO linear system matrices
  ## 	k_x,k_w,k_y	Gain matrices: u = k_w*w - k_x*x
  ##	L		Observer gain matrix
  ## Outputs
  ## 	Ac,Bc,Cc,Dc	Closed-loop charecteristic polynomial	

  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## System dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Create matrices describing closed-loop system
  Ac = [ A,  -B*k_x     
	l_x*C,  (A - l_x*C - B*k_x)];

  Bc = [B*k_w    B
	B*k_w    zeros(n_x,n_u)];

  Cc = [C               zeros(n_y,n_x)
	zeros(n_u,n_x)  -k_x          ];

  Dc = [zeros(n_y,n_y)     zeros(n_y,n_u)
	k_w              zeros(n_u,n_u)];

endfunction

Added mtt/lib/control/PPP/ppp_cost.m version [f7cb316246].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [J J_U] = ppp_cost (U,x,W,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww)

  ## usage: [J J_U] = ppp_cost (U,x,W,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww)
  ## Computes the PPP cost function given U,x and W
  ## 
  ## J_uu,J_ux,J_uw,J_xx,J_xw,J_ww cost derivatives from ppp_lin

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  J = U'*J_uu*U/2 + U'*(J_ux*x - J_uw*W) - x'*J_xw*W + x'*J_xx*x/2 + W'*J_ww*W'/2;
  J_U = J_uu*U + (J_ux*x - J_uw*W) ;

endfunction

Added mtt/lib/control/PPP/ppp_error.m version [3cf9868bce].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function err = ppp_error(par)

  ## usage:  err = error (par)
  ##
  ## 

  global ppp_y_0 ppp_sim_command ppp_par ppp_i_par ppp_x0 ppp_sim ppp_u
  
  pars = ppp_par;
  pars(ppp_i_par) = par;
  
  y = sidSimpleExtruder_ssim(ppp_x0,pars,ppp_sim,ppp_u);
  
  [N,n_y] = size(y);

  Err = y - ppp_y_0;
  err = sum(diag(Err'*Err))/N
endfunction

Added mtt/lib/control/PPP/ppp_ex1.m version [a792430509].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex1 (ReturnName)

  ## usage:  ppp_ex1 ()
  ##
  ## PPP example - an unstable, nmp siso system
  ## 	$Id$	


  ## Example name
  name = "Linear unstable non-minimum phase third order system- Laguerre inputs";

  if nargin>0
    return
  endif
  

  ## System - unstable & NMP
  [A,B,C,D] = NMPsystem;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Setpoint
  A_w = ppp_aug(0,[]);

  ## Controller

  ##Optimisation horizon
  t = [4.0:0.05:5];

  ## A_u
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w);

  ## Design and plot
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t);


  ## Compute exact version
  poles = sort(eig(A_u));	# Desired poles - eigenvalues of A_u
  poles = poles(1:n_x);		# Loose the last one - due to setpoint 
  clp = poly(poles);		# Closed-loop cp
  kk = clp(2:n_x+1)+A(1,:);	# Corresponding gain
  A_c = A-B*kk;			# Closed-loop A
  K_X = ppp_open2closed (A_u,[A_c B*k_w; [0 0 0 0]],[kk -k_w]); # Exact
	
  ## Compute K_x using approx values
  A_c_a = A-B*k_x; 			
  K_X_comp = ppp_open2closed (A_u,[A_c_a B*k_w; [0 0 0 0]],[k_x -k_w]); # Computed Kx

  format bank
  log_cond_uu = log10(cond_uu)
  Exact_closed_loop_poles = poles'
  Approximate_closed_loop_poles = cl_poles
  Exact_k_x = kk
  Approximate_k_x = k_x
  Exact_K_X = K_X
  Approximate_K_X = [K_x -K_w]
  Computed_K_x = K_X_comp
  K_xw_error = Approximate_K_X-K_X
  format
endfunction



Added mtt/lib/control/PPP/ppp_ex10.m version [cee25ffa57].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex10 (ReturnName)

  ## usage:  name = ppp_ex10 (ReturnName)
  ##
  ## PPP example - shows a standard multivariable system
  ##
 
  ## Example name
  name = "Remotely-piloted vehicle example:  system RPV from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = rpv;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = 1*[0.9:0.01:1];		# Time horizon
  A_w = 0;		# Setpoint
#   TC = 0.1*[1 1];		# Time constants for each input
#   A_u = [];
#   for tc=TC			# Input
#     A_u = [A_u;ppp_aug(laguerre_matrix(2,1/tc), 0)];
#   endfor
  A_u = ppp_aug(laguerre_matrix(2,5.0), A_w)
  Q = [1;1];		# Output weightings

  ## Design and plot
  W = [1;2]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

endfunction

Added mtt/lib/control/PPP/ppp_ex11.m version [b816bab9e6].












































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,J] = ppp_ex11 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex11 (ReturnName)
  ##
  ## PPP example

  ## 	$Id$	


  ## Example name
  name = "Input constraints +-1.5 on u* at tau=0,0.5,1,1.5,2";

  if nargin>0
    return
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [6:0.02:7];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions

  Q = ones(n_y,1);;
  

  ## Constraints
  Gamma = [];
  gamma = [];

  ## Constraints - u
  Tau_u = [0:0.5:2];
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [];			# No output constraints
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  disp("Designing controller");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  ## Constrained OL simulation
  disp("Computing constrained ol response");
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  disp("Computing unconstrained ol response");
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y*");
  xlabel("t");
  grid;
  figure(1);
  plot(T,ys,"-;y*: constrained;", T,ysu, "--;y*: unconstrained;")

  ## Non-linear - closed-loop
    disp("Computing constrained closed-loop response");
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0);

  title("Constrained closed-loop response");
  xlabel("t");
  grid;
  figure(2);
  plot(T,y,"-;y;", T,u,"--;u;");

#   ## Compute derivatives.
#   dt = t(2)-t(1);
#   du = diff(u)/dt;
#   dus = diff(us)/dt;
#   T1 = T(1:length(T)-1);
  ##plot(T1,du,T1,dus);
endfunction




Added mtt/lib/control/PPP/ppp_ex12.m version [03125b8f94].












































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,J,T1,du,dus] = ppp_ex12 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex12 (ReturnName)
  ##
  ## PPP example - shows input derivative constraints  
  ## $Id$


  ## Example name
  name = "Input derivative constraints +-1 on u* at tau=0,0.5,1,1.5,2";

  if nargin>0
    return
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [4:0.02:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  Q = ones(n_y,1);;

  ## Constaints - du*/dtau
  Tau = [0:0.5:2];
  one = ones(size(Tau));
  limit = 1;
  Min = -limit*one;
  Max =  limit*one;
  Order = one;
  [Gamma,gamma] = ppp_input_constraint (A_u,Tau,Min,Max,Order);

  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin (A,B,C,D,A_u,A_w,t,Q);
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar(A,B,C,D,x_0,A_u,U,T);

  ## Non-linear - closed-loop
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			   Tau,Min,Max,Order, \
			   [],[],[],[], W,x_0);

  title("y,y*,u and u*");
  xlabel("t");
  grid;
  plot(T,y,"1;y;", T,u,"2;u;", T,ys,"3;y*;", T,us,"4;u*;");

  ## Compute derivatives.
  dt = t(2)-t(1);
  du = diff(u)/dt;
  dus = diff(us)/dt;
  T1 = T(1:length(T)-1);
  ##plot(T1,du,T1,dus);
endfunction








Added mtt/lib/control/PPP/ppp_ex13.m version [410a811ae6].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex13 (ReturnName)

  ## usage:  ppp_ex13 ()
  ##
  ## PPP example: Sensitivity minimisation (incomplete)


  ## Example name
  name = "Sensitivity minimisation (incomplete)";

  if nargin>0
    return
  endif
  

  ## System - unstable
  A = [-3 -3 -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5 1
       0  1.0 0];
  D = [0;0];

  ## Setpoint
  A_w = [0;0]

  ## Controller
  t =[0:0.1:5];			# Optimisation horizon
  t1 =[0:0.1:1];
  t2 =[1.1:0.1:3.9];	
  t3 =[4:0.1:5];
  

  A_u = ppp_aug(laguerre_matrix(3,5.0), 0);
  q_s=1e3;
  Q = [exp(5*t)
       q_s*exp(-t)]
  size(Q)
  W = [1;0];

  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W)

endfunction



Added mtt/lib/control/PPP/ppp_ex14m.m version [da6984e601].







































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex14m (ReturnName)

  ## usage:   [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex14 (ReturnName)
  ##
  ## PPP example - shows output constraints on nonlinear system
  ## 	$Id$	


  ## Example name
  name = "Output constraints -0.1 on y* at tau=0.1,0.5,1,2";

  if nargin>0
    if ReturnName
      return
    endif
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.02:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  Q = ones(n_y,1);;

  ## Constaints - u
  Tau_u = [];
  one = ones(size(Tau_u));
  limit = 3;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [0.1 0.5 1 2]
  one = ones(size(Tau_y));
  Min_y =  -0.01*one; # Min_y(5) = 0.99;
  Max_y =  1e5*one;   # Max_y(5) = 1.01;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);
  [Gamma_y,gamma_y] = ppp_output_constraint  (A,B,C,D,x_0,A_u,Tau_y,Min_y,Max_y,Order_y);

  Gamma = [Gamma_u; Gamma_y];
  gamma = [gamma_u; gamma_y];

  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constained and unconstrained y*");
  xlabel("t");
  grid;
  plot(T,ys,T,ysu)

  ## Non-linear - closed-loop
  movie = 1; 
  if movie
    hold on;
  endif
  
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0,movie);

  hold off;
#   title("y,y*,u and u*");
#   xlabel("t");
#   grid;
#   plot(T,y,T,u,T,ysu,T,usu);

  ## Compute derivatives.
  dt = t(2)-t(1);
  du = diff(u)/dt;
  dus = diff(us)/dt;
  T1 = T(1:length(T)-1);
  ##plot(T1,du,T1,dus);
endfunction




Added mtt/lib/control/PPP/ppp_ex15.m version [f570a84dcf].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  [name,T,y,u,ye,ue,J] = ppp_ex15 (ReturnName)

  ## usage:  ppp_ex15 ()
  ##
  ## PPP example - an unstable, nmp siso system
  ## 	$Id$	

  ## Example name
  name = "Linear unstable non-minimum phase third order system - intermittent control";

  if nargin>0
    return
  endif
  

  ## System - unstable
  A = [3 -3  1
       1  0  0
       0  1  0];
  B = [10
       0 
       0];
  C = [0 -0.5 1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Setpoint
  A_w = ppp_aug(0,[]);

  ## Controller
  t =[4.0:0.01:5.0];		# Optimisation horizon
  dt = t(2)-t(1);
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w);
  Q = 1;			# Weight

  ##Simulate
  W = 1;			# Setpoint
  x_0 = zeros(n_x,1);		# Initial state


  ## Closed-loop intermittent solution
  Delta_ol = 0.5		# Intermittent time

  disp("Intermittent control simulation");
  R=1;P=0;
  [T,y,u] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q,R,P, \
			  [],[],[],[], \
			  [],[],[],[],W,x_0,Delta_ol);
size(T)
  ## Exact closed-loop
  disp("Exact closed-loop");
  [k_x,k_w] = ppp_lin (A,B,C,D,A_u,A_w,t,Q)
  [ye,Xe] = ppp_sm2sr(A-B*k_x, B, C, D, T, k_w*W, x_0); # Compute Closed-loop control

  ue = k_w*ones(size(T))*W - k_x*Xe;


  title("y and u, exact and intermittent");
  xlabel("t");
  grid;
  plot(T,y,"1;y (intermittent);", T,u,"2;u (intermittent);",\
       T,ye,"3;y (exact);", T,ue,"4;u (exact);");

endfunction

Added mtt/lib/control/PPP/ppp_ex16.m version [b34052bc15].








































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,J] = ppp_ex16 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex16 (ReturnName)
  ##
  ## PPP example

  ## 	$Id$	


  ## Example name
  name = "Input constraints +-1.5 on u* at tau=0,0.1,0.2..,2.0 - intermittent control";

  if nargin>0
    return
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [5:0.01:6];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  A_u = ppp_aug(laguerre_matrix(1,0.5), A_u); # Add some extra slow modes
  Q = ones(n_y,1);;

  ## Constaints
  Gamma = [];
  gamma = [];

  ## Constaints - u
  Tau_u = [0:0.1:2]; 
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constaints - y
  Tau_y = [];
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  disp("Control design");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  disp("Open-loop simulations");
  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y* and u*");
  xlabel("t");
  grid;
  axis([0 6 -1 2]);
  plot(T,ys,T,ysu,T,us,T,usu)
  axis;

  ## Non-linear - closed-loop
  disp("Closed-loop simulation");
  Delta_ol = 0.1;
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0,Delta_ol);

  title("y,y*,u and u*");
  xlabel("t");
  grid;
  plot(T,y,T,u,T,ys,T,us);
endfunction








Added mtt/lib/control/PPP/ppp_ex17.m version [fd73fba900].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex17 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex17 (ReturnName)
  ##
  ## PPP example - shows output constraints on nonlinear system
  ## 	$Id$	


  ## Example name
  name = "Output constraints -0.1 on y* at tau=0.1,0.5,1,2 - intermittent control";

  if nargin>0
    if ReturnName
      return
    endif
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [9:0.02:10];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  Q = ones(n_y,1);;

  ## Constraints - u
  Tau_u = [];
  one = ones(size(Tau_u));
  limit = 3;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [0.1 0.5 1 2]
  one = ones(size(Tau_y));
  Min_y =  -0.01*one; # Min_y(5) = 0.99;
  Max_y =  1e5*one;   # Max_y(5) = 1.01;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);
  [Gamma_y,gamma_y] = ppp_output_constraint  (A,B,C,D,x_0,A_u,Tau_y,Min_y,Max_y,Order_y);

  Gamma = [Gamma_u; Gamma_y];
  gamma = [gamma_u; gamma_y];

  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];

  ## OL solution
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constained and unconstrained y*");
  xlabel("t");
  grid;
  figure(1);
  plot(T,ys,"-;y* (constrained);", T,ysu,"--;y* (unconstrained);")

  ## Non-linear - closed-loop
  delta_ol = 0.1; mu = 1e-4;
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0,delta_ol,mu);

  title("y and u");
  xlabel("t");
  grid;
  plot(T,y,"1;y (constrained);", T,u,"2;u (constrained);");

endfunction




Added mtt/lib/control/PPP/ppp_ex18.m version [4568857bd3].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex18 (ReturnName)

  ## usage:  ppp_ex18 ()
  ##
  ## PPP example - an unstable, nmp siso system
  ## 	$Id$	


  ## Example name
  name = "First order with redundant inputs";

  if nargin>0
    return
  endif
  
  ## System 
  A = 1
  B = 1
  C = 1
  D = 0;

  ## Setpoint
  A_w = ppp_aug(0,[]);

  ## Controller
  ##Optimisation horizon
  t =[2:0.1:3];

  ## A_u
  A_u = diag([0  -2 -4 -6])

  [ol_poles,cl_poles] = ppp_lin_plot (A,B,C,D,A_u,A_w,t)

  
endfunction





Added mtt/lib/control/PPP/ppp_ex19.m version [8863f79b17].










































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,J] = ppp_ex19 (ReturnName,n_extra,T_extra)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex19 (ReturnName)
  ##
  ## PPP example

  ## 	$Id$	


  ## Example name
  name = "Input constraints with redundant U*";

  if (nargin>0)&&(ReturnName==1)
    return
  endif


  if nargin<2
    n_extra = 3
  endif
  
  if nargin<3
    T_extra = 2.0
  endif
  

  ## System
  A = 1
  B = 1
  C = 1
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [2:0.01:3];		# Time horizon
  A_w = 0;
  A_u = diag([0  -6]);
  A_u = ppp_aug(A_u,laguerre_matrix(n_extra,1/T_extra))
  Q = 1;
  ## Constraints
  Gamma = [];
  gamma = [];

  ## Constraints - u
  Tau_u = [0 0.1 0.5 1 1.5 2];
  Tau_u = 0;
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [];
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(n_x,1);

  ## Constrained - open-loop
  disp("Control design");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  disp("Open-loop simulations");
  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y*");
  xlabel("t");
  grid;
  plot(T,ys,"-;y* (constrained);", T,ysu,"--;y* (unconstrained);");

  ## Non-linear - closed-loop
  disp("Closed-loop simulation");
  [T1,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			   Tau_u,Min_u,Max_u,Order_u, \
			   Tau_y,Min_y,Max_y,Order_y,W,x_0);

  title("y and u");
  xlabel("t");
  grid;
  plot(T,y,"1;y (constrained);", T,u,"2;u (constrained);");

endfunction






Added mtt/lib/control/PPP/ppp_ex2.m version [163faa5b9f].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex2 (Return_Name)

  ## usage:  Name = ppp_ex2 (Return_Name)
  ##
  ## PPP example: Effect of slow desired closed-loop
  ## 	$Id$	


  ## Example name
  name = "Effect of slow desired closed-loop: closed-loop is same as open loop";

  if nargin>0
    return
  endif
  
  ## System
  A = -1;			# Fast - time constant = 1
  B = 0.5;			# Gain is 1/2
  C = 1;
  D = 0;

  ## Controller
  t =[9:0.1:10];		# Optimisation horizon

  A_u = [-0.1 0			# Slow - time constant = 10
         1 0];

  A_w = 0;			# Constant set point

  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot(A,B,C,D,A_u,A_w,t)
endfunction

Added mtt/lib/control/PPP/ppp_ex20.m version [bd637b24f5].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,ysu,usu] = ppp_ex20 (ReturnName)

  ## usage:  ppp_ex20 ()
  ##
  ## PPP example - 2nd-order 2i2o system
  ## 	$Id$	


  ## Example name
  name = "2nd-order 2i2o system with 1st-order basis"

  if nargin>0
    return
  endif

  ## System  
  A = [-2 -1
       1   0];
  B = [[1;0], [1;2]];
  C = [ [0,1]; [2,1]];
  D = zeros(2,2);

#  sys = ss2sys(A,B,C,D);
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

#   ## Display it
#   for j = 1:n_u
#     for i = 1:n_y
#       sysout(sysprune(sys,i,j),"tf")
#       step(sysprune(sys,i,j),1,5);
#     endfor
#   endfor
  
  ## Setpoint
  A_w = 0;

  ## Controller

  ##Optimisation horizon
  t =[4:0.01:5];

  ## A_u
  pole = [3];
  poles = 1;
  A_u = ppp_aug(butterworth_matrix(poles,pole),0);
  Q = ones(n_y,1);;

  ## Setpoints
  W = [1:n_y]';

  ## Design and plot
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

  format bank
  cl_poles

  A_c = A-B*k_x;			# Closed-loop A
  A_cw = [A_c B*k_w*W
          zeros(1,n_x+1)]

  log_cond_uu = log10(cond_uu)
				#  K_xwe = ppp_open2closed(A_u,A_cwe,[k_xe -k_we*W]); # Exact Kx
#  K_xwc = ppp_open2closed(A_u,A_cw,[k_x -k_w*W]); # Computed Kx
				#  Exact_K_xw = K_xwe
  PPP_K_xw = [K_x -K_w*W] 
#  Comp_K_xw = K_xwc

#  Error = Approx_K_xw - Comp_K_xw

endfunction



Added mtt/lib/control/PPP/ppp_ex20.new.m version [fd66e71f1b].





























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# function name = ppp_ex20 (ReturnName)

#   ## usage:  name = ppp_ex20 (ReturnName)
#   ##
#   ## PPP example -- a standard multivariable example
#   ## 	$Id$	



#   ## Example name
#   name = "Turbogenerator example:  system TGEN from J.M Maciejowski: Multivariable Feedback Design";

#   if nargin>0
#     return
#   endif
  
  ## System
  [A,B,C,D] = airc;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [9:0.1:10];		# Time horizon
  A_w = zeros(n_y,1);		# Setpoint
  TC = 2*[1 1];		# Time constants for each input
 #  A_u = [];
#   for tc=TC			# Input
#     A_u = [A_u;ppp_aug(laguerre_matrix(3,1/tc), 0)];
#   endfor
 A_u =  ppp_aug(laguerre_matrix(5,1.0), 0);
 Q = [1;1];		# Output weightings

  ## Constraints
  Gamma = [];
  gamma = [];

  ## Constraints - u
  Tau_u = [0 0.1 0.5 1 1.5 2];
  Tau_u = 0;
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [];
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=[1;2;3];
  x_0 = zeros(n_x,1);

  ## Constrained - open-loop
  disp("Control design");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  disp("Open-loop simulations");
  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y*");
  xlabel("t");
  grid;
  plot(T,ys,T,ysu)

  ## Non-linear - closed-loop
  disp("Closed-loop simulation");
  [T1,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			   Tau_u,Min_u,Max_u,Order_u, \
			   Tau_y,Min_y,Max_y,Order_y,W,x_0);

  title("y,y*,u and u*");
  xlabel("t");
  grid;
  plot(T1,y,T,ys,T1,u,T,us);


#endfunction

Added mtt/lib/control/PPP/ppp_ex21.m version [0b03160976].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,ys,us,ysu,usu] = ppp_ex21 (ReturnName)

  ## usage:  ppp_ex21 ()
  ##
  ## PPP example - 2nd-order 2i2o system system with anomalous behaviour"
  ## 	$Id$	


  ## Example name
  name = "2nd-order 2i2o system with anomalous behaviour"

  if nargin>0
    return
  endif

  ## System  
  A = [-2 -1
       1   0];
  B = [[1;0], [1;2]];
  C = [ [0,1]; [2,1]];
  D = zeros(2,2);

  sys = ss2sys(A,B,C,D);
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Display it
  for j = 1:n_u
    for i = 1:n_y
      sysout(sysprune(sys,i,j),"tf")
      step(sysprune(sys,i,j),1,5);
    endfor
  endfor
  
  ## Setpoint
  A_w = 0;

  ## Controller

  ##Optimisation horizon
  t =[4:0.1:5];

  ## A_u
  pole = [4];
				#A_u = ppp_aug(laguerre_matrix(2,pole),0);
				#A_u = ppp_aug(diag([-3,-4]),0);
  A_u = ppp_aug(butterworth_matrix(2,pole),0);
  Q = ones(n_y,1);;

  ## Setpoints
  W = [1:n_y]';

  ## Initial condition
  x_0 = [0;0.5];

  ## Design and plot
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0);

  format short
  cl_poles

  A_c = A-B*k_x;			# Closed-loop A
  A_cw = [A_c B*k_w*W
          zeros(1,n_x+1)]

  log_cond_uu = log10(cond_uu)
				#  K_xwe = ppp_open2closed(A_u,A_cwe,[k_xe -k_we*W]); # Exact Kx
				#AA_u = ppp_inflate([A_u;A_u]);
  K_xwc = ppp_open2closed(A_u,A_cw,[k_x -k_w*W]) # Computed Kx
				#  Exact_K_xw = K_xwe
  Approx_K_xw = [K_x -K_w*W] 
  format

endfunction



Added mtt/lib/control/PPP/ppp_ex3.m version [c1cd799f6a].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex3 (Return_Name)

  ## usage:  Name = ppp_ex3 (Return_Name)
  ##
  ## PPP example: Uncoupled 5x5 system
  ##  	$Id$	




  ## Example name
  name = "Uncoupled NxN system - n first order systems";

  if nargin>0
    return
  endif
  
  ## System - N uncoupled integrators
  N = 3
  A = -0.0*eye(N);
  B = eye(N);
  C = eye(N);
  D = zeros(N,N);

  t =[4:0.1:5];			# Optimisation horizon
  ## Create composite matrices
  A_u = [];			# Initialise
  A_w = [];			# Initialise

  for i=1:N			
    ## Setpoint - constant
    a_w = ppp_aug(0,[]);
    A_w = [A_w;a_w];

    ## Controller
    a_u = ppp_aug(-i,a_w);
    A_u = [A_u; a_u];
 endfor
  
  A_u = [-diag([1:N])]

  Q = ones(N,1);		# Equal output weightings
  W = ones(N,1);		# Setpoints are all unity

  ## Design and simulate
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u] = ppp_lin(A,B,C,D,A_u,A_w,t);
  # [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = \
  #     ppp_lin_plot(A,B,C,D,A_u,A_w,t,Q,W);

  Approximate_K_x = K_x#(1:2:2*N,:)
  A_c = A-B*k_x;
  Closed_Loop_Poles = eig(A-B*k_x)
  ## Now try out the open/closed loop theory
#   A_u = -diag(1:N);		# Full A_u matrix
#   A_c = -diag(1:N);		# Ideal closed-loop
#   k_x = diag(1:N);		# Ideal feedback
  KK = ppp_open2closed (ppp_inflate(A_u),A_c,k_x);
  Exact_K_x_tilde = KK
  

endfunction

Added mtt/lib/control/PPP/ppp_ex4.m version [f6af77ca79].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex4 (ReturnName)

  ## usage:  ppp_ex4 ()
  ##
  ## PPP example -- a 1i2o system with performance limitations
  ## 	$Id$	



  ## Example name
  name = "Resonant system (1i2o): illustrates performance limitations with 2 different time-constants";

  if nargin>0
    return
  endif
  

  ##  Mass- sping damper from Middleton et al EE9908

  ## Set parameters to unity
  m_1 = 1;		
  m_2 = 1;
  k = 1;

  ## System
  [A,B,C,D] = TwoMassSpring (k,m_1,m_2);

  for TC = [0.4 1]
    disp(sprintf("\nClosed-loop time constant = %1.1f\n",TC));
    ## Controller
    A_w = zeros(2,1);	# Setpoint: Unit W* for each output
    t =[11:0.1:12];			# Optimisation horizon
    [A_u] = ppp_aug(laguerre_matrix(4,1/TC), 0);	# U*

    Q = [1;0];

    ## Design and plot
    [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q)
    hold on;
  endfor

  hold off;
endfunction




Added mtt/lib/control/PPP/ppp_ex5.m version [eab12a6897].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex5 (ReturnName)

  ## usage:  ppp_ex5 (ReturnName)
  ##
  ## PPP example -- a 28-state vibrating beam system
  ## 	$Id$	


  ## Example name
  name = "Vibrating beam: 14 state regulation problem with 7 beam velocities as output";

  if nargin>0
    return
  endif
  
  
  ## System - beam
  Beam_numpar;
  [A,B,C,D]=Beam_sm;
  
  ## Redo C and D to reveal ALL velocities
  c = C(1);
  C = zeros(7,14);
  for i = 1:7
    C(i,2*i-1) = c;
  endfor
  D = zeros(7,1);

  e = eig(A);			# Eigenvalues
  N = length(e);
  frequencies = sort(imag(e));
  frequencies = frequencies(N/2+1:N); # Modal frequencies

  ## Controller
  ## Controller design parameters
  t = [0.4:0.01:0.5];		# Optimisation horizon

  Q = ones(7,1); 

  ## Specify input basis functions 
  ##  - damped sinusoids with same frequencies as beam
  damping_ratio = 0.2;		# Damping ratio of inputs
  A_u = damped_matrix(frequencies,0.2*ones(size(frequencies)));
  u_0 = ones(14,1);		# Initial conditions

  A_w = zeros(7,1);		# Setpoint
  W =  zeros(7,1);		# Zero setpoint

  ## Set up an "typical" initial condition
  x_0 = zeros(14,1);
  x_0(2:2:14) = ones(1,7);	# Set initial twist to 1.

  ## Simulation
  [ol_poles,cl_poles] =  ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0);

  

endfunction

Added mtt/lib/control/PPP/ppp_ex6.m version [a3383c7b66].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [name,T,y,u,J] = ppp_ex6 (ReturnName)

  ## usage:  [name,T,y,u,J] = ppp_ex6 (ReturnName)
  ##
  ## PPP example -- PPP for redundant actuation
  ## 	$Id$	


  ## Example name
  name = "Two input-one output system with input constraints";

  if nargin>0
    return
  endif
  
  ## System
  A = 0;
  B = [0.5 1];
  C = 1;
  D = [0 0];
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.1:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = [-2;-0.5];		# Input
  Q = 1;			# Output weight

  ## Constrain  input 1 at time tau=0
  Tau = 0;
  Max = [1;inf]
  Min = [-inf;-inf];
  Order = 0;
  i_u = 1;
  
  ## Simulation
  W=1;
  x_0 = 0;

  ## Linear
  ppp_lin_plot (A,B,C,D,A_u,A_w,t);
  
  ## Non-linear
  movie = 0;
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, Tau,Min,Max,Order, \
	      [],[],[],[], W,x_0);
  title("y,u_1,u_2");
  xlabel("t");
  grid;
  plot(T,y,"-;y;", T,u(1,:),"--;u_1;", T,u(2,:),".-;u_2;");

endfunction



Added mtt/lib/control/PPP/ppp_ex7.m version [20afb5cf0e].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex7 (ReturnName)

  ## usage:  name = ppp_ex7 (ReturnName)
  ##
  ## PPP example -- standard multivariable system
  ## 	$Id$	


  ## Example name
  name = "Aircraft example:  system AIRC from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = airc;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.01:5];		# Time horizon
  A_w = 0;		# Setpoint (same for each input)
  #A_u = ppp_aug(laguerre_matrix(5,1), 0) # Same for each input 
  A_u = laguerre_matrix(5,1); # Same for each input 
  Q = ones(3,1);		# Output weightings
  ## Design and plot
  W = [1;2;3]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);
   cl_poles

  ## Try open-closed theory but using computed values:
  A_c = A - B*k_x; eig(A_c)
  K_x
  KK = ppp_open2closed (A_u,A_c,k_x)

  100*((KK-K_x)./KK)
endfunction

Added mtt/lib/control/PPP/ppp_ex8.m version [d3d175c796].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex8 (ReturnName)

  ## usage:  name = ppp_ex8 (ReturnName)
  ##
  ## PPP example - standard multivariable example
  ## 	$Id$	

  ## Example name
  name = "Automotive gas turbine example:  system AUTM from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = autm;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.1:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(4,2.0), 0) # Input
  Q = [1;1e3];		# Output weightings

  ## Design and plot
  W = [1;2]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

endfunction

Added mtt/lib/control/PPP/ppp_ex9.m version [c71a52df94].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function name = ppp_ex9 (ReturnName)

  ## usage:  name = ppp_ex9 (ReturnName)
  ##
  ## PPP example -- a standard multivariable example
  ## 	$Id$	



  ## Example name
  name = "Turbogenerator example:  system TGEN from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = tgen;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [1.0:0.01:2.0];		# Time horizon
#   A_w = zeros(n_y,1);		# Setpoint
#   TC = 2*[1 1];		# Time constants for each input
#   A_u = [];
#   for tc=TC			# Input
#     A_u = [A_u;ppp_aug(laguerre_matrix(3,1/tc), 0)];
#   endfor
  A_w = 0;
  A_u = ppp_aug(ppp_aug(laguerre_matrix(2,1.0),laguerre_matrix(2,2.0)), A_w)
  Q = [1;1];		# Output weightings

  ## Design and plot
  W = [1;2]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

#   ol_poles, cl_poles
#   k_x,k_w
#   K_X = [K_x -K_w]
#   A_c = A - B*k_x;
#   K_X_comp = ppp_open2closed (A_u,[A_c B*k_w*W; zeros(1,n_x+1)],[k_x -k_w*W])
endfunction

Added mtt/lib/control/PPP/ppp_examples.m version [e27b26eff0].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ppp_examples ()

  ## usage:  ppp_examples ()
  ##
  ## Various menu-driven PPP examples


  str="menu(""Predictive Pole-Placement (PPP) examples"",""Exit"",""All examples"; # Menu string

  used = 2;
  option=used;  

  while option>1

    exists=1; 
    i_example=1;		# Example counter
    while exists
      name=sprintf("ppp_ex%i",i_example);
      exists=(exist(name)==2);
      if exists
	title = eval(sprintf("%s(1);", name)); 
	str = sprintf("%s"",""%s",str,title);
	i_example++;
      endif
    endwhile
    n_examples = i_example-1;

    str = sprintf("%s"" );\n",str);

    option=eval(str);		# Menu - ask user

    if option>1			# Do something - else return
      if option==2		# All examples
	Examples=1:n_examples;
      else			# Just the chosen examples
	Examples = option-used;
      endif
      for example=Examples	# Do the chosen examples
	eval(sprintf("Title = ppp_ex%i(1);",example));
	disp(sprintf("Evaluating example ppp_ex%i:\n\t %s\n", example, Title));
	eval(sprintf("ppp_ex%i;",example));
      endfor
    endif
    
    
  endwhile

endfunction






Added mtt/lib/control/PPP/ppp_extract.m version [b84460c15f].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function A_i = ppp_extract (A_u,input)

  ## usage:  A_i = ppp_extract (A_u)
  ##
  ## Extracts the ith A_u matrix.

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  [n,m] = size(A_u);		# Size of composite A_u matrix
  square = (n==m);		# Its a square matrix so same U* on each input
  if square
    A_i = A_u;			# All a_u the same
  else
    N = m;			# Number of U* functions per input  
    n_u = n/m;
    if floor(n_u) != n_u	# Check that n_u is an integer
      error("A_u must be square or be a column of square matrices");
    endif
    
    if input>n_u
      error("Input index too large");
    endif
    
    ## Extract the ith matrix
    start = (input-1)*N;
    range=(start+1:start+N);
    A_i = A_u(range,:);
  endif

endfunction

Added mtt/lib/control/PPP/ppp_identify.m version [fae8c72792].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [par,Par,Error,Y] = ppp_identify (system_name,u,y_0,par_names,par_0,extras)
  ## ppp_identify: System identification for PPP
  ## usage:  [par,Par,Error,Y] = ppp_identify(system_name,u,y_0,par_names,par_0,extras)
  ##
  ##  system_name     String containing system name
  ##  u               System input (column vector, each row is u')
  ##  y_0             Desired model output
  ##  par_names       Column vector of (padded) strings - the adjustable
  ##                  parameter names
  ##  par_0           Initial parameter vector estimate
  ##  extras (opt)    optimisation parameters
  ##        .criterion convergence criterion
  ##        .max_iterations limit to number of iterations
  ##        .v  Initial Levenberg-Marquardt parameter

  
  if nargin<6
    extras.criterion = 1e-5;
    extras.max_iterations = 10;
    extras.v = 1e-5;
    extras.verbose = 0;
  endif  

  s_system_name = sprintf("s%s", system_name); # Name of sensitivity system

  ## Set up parameters
  sim = eval([s_system_name, "_simpar;"]); # Simulation parameter
  sym = eval([s_system_name, "_sympar;"]); # Parameter names
  x0  = eval([s_system_name, "_state(par_0);"]); # Initial state

#   ## Set up the free parameter list
#   free = [];
#   [n,m] = size(par_names);
#   for i = 1:n
#     p_name = deblank(par_names(i,:));
#     s_name = sprintf("%ss", p_name);
#     if struct_contains(sym, p_name)
#       i_p = eval(sprintf("sym.%s;", p_name));
#       if struct_contains(sym, s_name)
# 	i_s = eval(sprintf("sym.%s;", s_name));
# 	free_i = eval(sprintf("[%i,%i];", i_p, i_s));
# 	free = [free; free_i];
#       else
# 	printf("Sensitivity parameter %s does not exist: ignoring \
# 	parameter %s\n", s_name, p_name);
#       endif
#     else
#       printf("Parameter %s does not exist: ignoring\n", p_name)
#     endif
#   endfor
#   free
  free = ppp_indices(par_names,sym);
  [par,Par,Error,Y] = ppp_optimise(s_system_name,x0,par_0,sim,u,y_0,free,extras);

endfunction







Added mtt/lib/control/PPP/ppp_indices.m version [719278145f].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function indices = ppp_indices (names,sympar,sympars)

  ## usage:  indices = ppp_indices (names,sympar)
  ##
  ## names: column vector of component names
  ## sympar symbolic parameter structure for system
  ## sympars symbolic parameter structure for sensitivity system
 

  ## Returns a matrix indices with 3 columns, one row per name
  ## First  col: index of ith parameter of sensitivity system
  ## Second col: index of ith sensitivity parameter of sensitivity system
  ## Third col : index of ith parameter of system
  ## Copyright (C) 2002 by Peter J. Gawthrop

  ## Sanity check
  if nargin<3
    printf("Usage: ppp_indices (names,sympar,sympars)\n");
    return
  endif
  
  ## Set up the
  indices = [];
  [n,m] = size(names);
  for i = 1:n
    p_name = deblank(names(i,:));
    s_name = sprintf("%ss", p_name);
    if struct_contains(sympars, p_name)
      i_ps = eval(sprintf("sympars.%s;", p_name));
      if struct_contains(sympars, s_name)
	i_s = eval(sprintf("sympars.%s;", s_name));
	if struct_contains(sympar, p_name)
	  i_p = eval(sprintf("sympar.%s;", p_name));
	  indices_i = eval(sprintf("[%i,%i,%i];", i_ps, i_s, i_p));
	  indices = [indices; indices_i];
	else
	  printf("Parameter %s does not exist in sympar: ignoring\n", p_name)
	endif
      else
	printf("Sensitivity parameter %s does not exist in sympars: ignoring \
	parameter %s\n", s_name, p_name);
      endif
    else
      printf("Parameter %s does not exist in sympars: ignoring\n", p_name)
    endif
  endfor

endfunction

Added mtt/lib/control/PPP/ppp_inflate.m version [c4fc3a116e].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function A_m = ppp_inflate (A_v)

  ## usage:  A_m = ppp_inflate (A_v)
  ##
  ## Creates the square matrix A_m with the matrix elements of the column
  ## vector of square matrices A_v.

  ## Copyright (C) 2001 by Peter J. Gawthrop

  [N,M] = size(A_v);

  if N<M
    error("A_v must have at least as many rows as columns");
  endif
  
  n = N/M;			# Number of matrix elements in A_v

  if round(n)!=n
    error("A_v must be a column vector of square matrices");
  endif
  
  A_m = [];
  for i = 1:n
    A_m = ppp_aug(A_m,ppp_extract(A_v,i));
  endfor

endfunction

Added mtt/lib/control/PPP/ppp_input_constraint.m version [75b7c0f8a7].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Gamma,gamma] = ppp_input_constraint (A_u,Tau,Min,Max,Order,i_u,n_u)

  ## usage:  [Gamma,gamma] = ppp_input_constraint (A_u,Tau,Min,Max,Order,i_u,n_u)
  ##
  ## Derives the input constraint matrices Gamma and gamma
  ## For Constraints Min and max at times Tau 
  ## Order=0 - input constraints
  ## Order=1 - input derivative constraints
  ## etc
  ## i_u: Integer index of the input to be constrained
  ## n_u: Number of inputs
  ## NOTE You can stack up Gamma and gamma matrices for create 
  ##    multi-input constraints.
  ## Limits at inf and -inf are discarded

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	


  ## Sizes
  [n_U,m_U] = size(A_u);	# Number of basis functions
  [n,N_t] = size(Tau);		# Number of constraint times
  
  ## Defaults
  if nargin<5
    Order = zeros(1,N_t);
  endif

  if nargin<6
    i_u = 1;
    n_u = 1;
  endif
  
  if N_t==0			# Nothing to be done
    Gamma = [];
    gamma = [];
    return
  endif
  
  if n != 1
    error("Tau must be a row vector");
  endif
  
  n = length(Min);
  m = length(Max);
  o = length(Order);

  if (n != N_t)||(m != N_t)||(o != N_t)
    error("Tau, Min, Max and Order must be the same length");
  endif
  
  ## Extract the A_i matrix for this input
  A_i = ppp_extract(A_u,i_u);

  ## Create the constraints in the form: Gamma*U < gamma
  Gamma = [];
  gamma = [];
  one = ones(m_U,1);
  i=0;

  zero_l = zeros(1,(i_u-1)*m_U); # Pad left-hand
  zero_r = zeros(1,(n_u-i_u)*m_U); # Pad right-hand
  for tau = Tau			# Stack constraints for each tau
    i++;

    Gamma_tau = ( A_i^Order(i) * expm(A_i*tau) * one )';
    Gamma_tau = [ zero_l Gamma_tau zero_r ]; # Only for i_uth input

    if Max(i)<inf
      Gamma = [Gamma; Gamma_tau];
      gamma = [gamma; Max(i)];
    endif
    
    if Min(i)>-inf
      Gamma = [Gamma; -Gamma_tau];
      gamma = [gamma; -Min(i)];
    endif
    
  endfor

endfunction

Added mtt/lib/control/PPP/ppp_input_constraints.m version [804cd7fa35].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Gamma,gamma] = ppp_input_constraints (A_u,Tau,Min,Max,Order)

  ## usage:  [Gamma,gamma] = ppp_input_constraints (A_u,Tau,Min,Max[,Order])
  ##
  ## Derives input copnstraint matrices Gamma and gamma 
  ## for multi-input systems.
  ## A_u Input-generating matrix
  ## Tau row vector of times at which constraints occur
  ## Max, Maximum and minimum values
  ## Limits at inf and -inf are discarded

  ## Sanity check
  [n_u,n_tau] = size(Min);
  [n,m] = size(Max);
  if (n!=n_u)||(m!=n_tau)
    error("Max and Min must have the same dimensions");
  endif
  
  [n,m] = size(Tau);
  if (m!=n_tau)
    error("Max and Min must have same number of columns as Tau");
  endif
  if (n>1)
    error("Tau must be a row vector");
  endif

  ##Defaults
  if nargin<5
    Order=zeros(1,n_tau);
  endif
  
  ## Stack up constraints for each input
  Gamma=[];
  gamma=[];
  for i_u=1:n_u
    [Gamma_i,gamma_i] = \
	ppp_input_constraint(A_u,Tau,Min(i_u,:),Max(i_u,:),Order,i_u,n_u);
    Gamma = [Gamma; Gamma_i];
    gamma = [gamma; gamma_i];
  endfor

endfunction

Added mtt/lib/control/PPP/ppp_int_obs.m version [9bfdfe49cb].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [x_p,y_p,y_new,error] = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)

  ## usage: x_new = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)
  ##
  ## Intermittent observer for PPP
  ##
  ## x,y Current estimated state and measured output
  ## U PPP control weights
  ## A,B,C,D System matrices
  ## A_u PPP basis matrix
  ## delta time step
  ## L Observer gain
  ## x_p, y_p predicted estimated state and output
  ## y_new corrected estimated current output
  ## error corresponding error

  ## Copyright (C) 2003 by Peter J. Gawthrop

  ## Sanity check
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  if nargin<10
    L = zeros(n_x,n_y);
  endif
  
  ## Corrector (on current value of output)
  error = (C*x-y);
  x_new = x - L*error;
  y_new = C*x_new;

  ## Predictor (predicts Delta_OL ahead)
  [y_p,us,x_p] = ppp_ystar (A,B,C,D,x_new,A_u,U,delta);

endfunction

Added mtt/lib/control/PPP/ppp_ippp.m version [d40f70c238].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function i_ppp = ppp_ippp (n_ppp,sympar,sympars)

  ## usage:  i_ppp = ppp_ippp (n_ppp,sympar,sympars)
  ## nppp   number of ppp parameters
  ## sympars symbolic parameter structure for system
  ## sympar symbolic parameter structure for sensitivity system
  ## Returns a matrix i_ppp with n_ppp rows and 3 columns
  ## First  col: index of ith ppp parameter of sensitivity system
  ## Second col: index of ith ppp sensitivity parameter of sensitivity system
  ## Third col : index of ith ppp  parameter of system
  ## Copyright (C) 2002 by Peter J. Gawthrop

  i_ppp = [];
  for i=1:n_ppp
    i_ppp_i = eval(sprintf("[sympars.ppp_%i, sympars.ppp_%is \
			     sympar.ppp_%i];",i,i,i));
    i_ppp = [i_ppp ; i_ppp_i];
  endfor

endfunction

Added mtt/lib/control/PPP/ppp_lin.m version [a68c3b73aa].















































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] = ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P,max_cond);
  ## usage:
  ## [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] =
  ##  ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P,max_cond)

  ##
  ## Linear PPP (Predictive pole-placement) computation 
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## OR
  ## A_u: square system matrix for U* generation 
  ##      same square matrix for each system input.
  ## A_w: composite system matrix for W* generation 
  ##      one square matrix (A_wi) row for each system output
  ##      each A_wi generates W*' for ith system output.
  ## tau: row vector of times for optimisation (equispaced in time)
  ## Q column vector of output weights (defaults to unity)
  ## OR
  ## Q matrix,  each row corresponds to time-varying weight compatible with t
  ## max_cond: Maximum condition number of J_uu (def 1/eps)
  ## OUTPUTS:
  ## k_x: State feedback gain
  ## k_w: setpoint gain
  ## ie u(t) = k_w w(t) - k_x x(t)
  ## K_x, K_w: open loop gains
  ## Us0: Value of U* at tau=0
  ## J_uu, J_ux, J_uw, J_xx,J_xw,J_ww: cost derivatives
  ## cond_uu : Condition number of J_uu
  ## Copyright (C) 1999, 2000 by Peter J. Gawthrop
  ## 	$Id$	

  ## Check some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  if (n_x==-1)
    return
  endif
  
  ## Default Q (output weight)
  if nargin<8
    Q = ones(n_y,1);
  endif

  ## Default R (input weight)
  if nargin<9
    R = zeros(n_u,1);
  endif

  ## Default P (terminal weight)
  if nargin<10
    P = zeros(n_x,n_x);
    P_weighting = 0;
  else
    P_weighting = 1;
  endif

  ## Default condittion number
  if nargin<11
    max_cond = 1e20;
  endif
  
  [n_U,m_U] = size(A_u);
  if (n_U != n_u*m_U)&&(n_U != m_U)
    error("A_u must be square or have N_u rows and N_u/n_u columns");
  endif

  if (n_U == m_U)		# U matrix square
    n_U = n_U*n_u;		# So same U* on each input
  endif

  
  [n_W,m_W] = size(A_w);
  if n_W>0
    if (n_W != n_y*m_W)&&(n_W != m_W)
      error("A_w must either be square or have N_w rows and N_w/n_y columns");
    endif
    square_W = (n_W== m_W);	# Flag indicates W is square
    if (n_W == m_W)		# W matrix square
      n_W = n_W*n_y;		# So same W* on each output
    endif
  endif
  

  [n_t,m_t] = size(tau);
  if n_t != 1
    error("tau must be a row vector");
  endif
  dt = tau(2) - tau(1);		# Sample interval

  [n_Q,m_Q] = size(Q);
  if ((m_Q != 1)&&(m_Q != m_t)) || (n_Q != n_y)
    error("Q must be a column vector with one row per system output");
  endif

  if (m_Q == 1)			# Convert to vector Q(i)
    Q = Q*ones(1,m_t);		# Extend to cover full range of tau
  endif
  
  ##Set up initial states
  u_0 = ones(m_U,1);
  w_0 = ones(m_W,1);

  ## Find y_U - derivative of y* wrt U.
  i_U = 0;
  x_0 = zeros(n_x,1);		# This is for x=0
  y_u = [];			# Initialise
  x_u_t = [];			# Initialise
  Us = [];			# Initialise
  for i=1:n_U			# Do for each input function U*_i
    dU = zeros(n_U,1);
    dU(++i_U) = 1;		# Create dU/dU_i 
    [ys,us,xs] = ppp_ystar (A,B,C,D,x_0,A_u,dU,tau); # Find ystar and ustar
    y_u = [y_u ys'];		# Save y_u (y for input u)  with one row for each t.
    Us = [Us us'];		# Save u (input)  with one row for each
				# t.
    x_u_t = [x_u_t xs(:,m_t)];	# x_u at terminal time
  endfor

  Ws = [];			# Initialise
  if n_W>0
    ## Find w*
    i_W = 0;
    x_0 = zeros(n_x,1);		# This is for x=0
    for i=1:n_W			# Do for each setpoint function W*i
      dW = zeros(n_W,1);
      dW(++i_W) = 1;		# Create dW/dW_i 
      [ys,ws] = ppp_ystar ([],[],[],[],[],A_w,dW,tau); # Find ystar and ustar
      Ws = [Ws ws'];		# Save u (input)  with one row for each t.
    endfor
  endif
  


  ## Find y_x - derivative of y* wrt x.
  y_x=[];
  for t_i=tau
    y = C*expm(A*t_i);
    yy = reshape(y,1,n_y*n_x);	# Reshape to a row vector
    y_x = [y_x; yy];
  endfor

  ## Compute the integrals to give cost function derivatives
  [n_yu m] = size(y_u');
  [n_yx m] = size(y_x');
  [n_yw m] = size(Ws');

  J_uu = zeros(n_U,n_U);
  J_ux = zeros(n_U,n_x);
  J_uw = zeros(n_U,n_W);
  J_xx = zeros(n_x,n_x);
  J_xw = zeros(n_x,n_W);
  J_ww = zeros(n_W,n_W);

  ## Add up cost derivatives for each output but weighted by Q.
  ## Scaled by time interval
  ## y_u,y_x and Ws should really be 3D matrices, but instead are stored
  ## with one row for each time and one vector (size n_y) column for
  ## each element of U

  ## Scale Q
  Q = Q*dt;			# Scale to give correct units
  ## Non-w bits
  for i = 1:n_y			# For each output
    QQ = ones(n_U,1)*Q(i,:);	# Resize Q
    J_uu = J_uu + (QQ .* y_u(:,i:n_y:n_yu)') * y_u(:,i:n_y:n_yu);
    J_ux = J_ux + (QQ .* y_u(:,i:n_y:n_yu)') * y_x(:,i:n_y:n_yx);
    QQ = ones(n_x,1)*Q(i,:);	# Resize Q
    J_xx = J_xx + (QQ .* y_x(:,i:n_y:n_yx)') * y_x(:,i:n_y:n_yx);
  endfor

  ## Input weighting (scalar for the moment)
  if (n_u>1)
    warning("Sorry, cant do n_u>1 just now: exiting");
    return
  endif

  ## Scale R
  R = R*dt;			# Scale to give correct units
  for i = 1:m_t
    Ust = Us(i,:);
    J_uu = J_uu + Ust'*R*Ust;
  endfor
  
  ## w bits
  if n_W>0
    for i = 1:n_y			# For each output
      QQ = ones(n_U,1)*Q(i,:);	# Resize Q
      J_uw = J_uw + (QQ .* y_u(:,i:n_y:n_yu)') * Ws (:,i:n_y:n_yw);
      QQ = ones(n_x,1)*Q(i,:);	# Resize Q
      J_xw = J_xw + (QQ .* y_x(:,i:n_y:n_yx)') * Ws (:,i:n_y:n_yw);
      QQ = ones(n_W,1)*Q(i,:);	# Resize Q
      J_ww = J_ww + (QQ .* Ws (:,i:n_y:n_yw)') * Ws (:,i:n_y:n_yw);
    endfor
  endif

  if P_weighting
    ## Terminal constraint 
    tau_last = tau(m_t);
    x_x_t = expm(A*tau_last);	# deriv. of x*(tau_2) wrt x(0)
    J_ux = J_ux + x_u_t'*P*x_x_t;
    J_uu = J_uu + x_u_t'*P*x_u_t;
    
    ## Terminal constraint - w bits
    ## NB SISO ONLY at the moment
    C = C(1,:);			# REMOVE ME
    
    ## deriv of x* wrt W
    if (cond(A)<1e10)		# Finite ss gain
      x_W_t =  (A\B)*inv(C*(A\B));
    else				# Infinite ss gain
      Y_0 = zeros(n_x,n_y); Y_0(1,:) = ones(1,n_y);
      x_W_t =  obsv(A,C)\Y_0;
    endif
    
    J_uw = J_uw + x_u_t'*P*x_W_t;
  endif
  
  ## Exit if badly conditioned
  cond_uu = cond(J_uu);
  if cond_uu>max_cond
    error(sprintf("J_uu is badly conditioned. Condition number = \
	10^%i",log10(cond_uu)));
  endif

  ## Compute the open-loop gains
  K_w = J_uu\J_uw;
  K_x = J_uu\J_ux;

  ## U*(tau) at tau=0 
  Us0 = ppp_ustar(A_u,n_u,0);		
  
  ## Compute the closed-loop gains
  k_x = Us0*K_x;
  k_w = Us0*K_w;

endfunction

Added mtt/lib/control/PPP/ppp_lin_con_sol.m version [3f791341cb].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
function U = ppp_lin_con_sol (x,w,J_uu,J_ux,J_uw)

  ## usage:  U = ppp_lin_con_sol (x,w,J_uu,J_ux,J_uw)
  ##
  ## 

  ## Pass info to the solnp algorithm
  global ppp_J_uu, ppp_J_ux, ppp_J_uw

endfunction

Added mtt/lib/control/PPP/ppp_lin_obs.m version [3637bc55b1].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [l_x,l_y,L_x,L_y,J_uu,J_ux,J_uw,Us0] = ppp_lin_obs (A,B,C,D,A_u,A_y,t,Q)

  ## usage:  [l_x,l_y,L_x,L_y,J_uu,J_ux,J_uw,Us0] = ppp_lin_obs  (A,B,C,D,A_u,A_y,t,Q)
  ##
  ## Linear PPP (Predictive pole-placement) computation 
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## A_y: composite system matrix for W* generation 
  ##      one square matrix (A_yi) row for each system output
  ##      each A_yi generates W*' for ith system output.
  ## t: row vector of times for optimisation (equispaced in time)
  ## Q column vector of output weights (defaults to unity)

  ## OUTPUTS:
  ## l_x: State feedback gain
  ## l_y: setpoint gain
  ## ie u(t) = l_y w(t) - l_x x(t)
  ## L_x, L_y: open loop gains
  ## J_uu, J_ux, J_uw: cost derivatives
  ## Us0: Value of U* at tau=0

  ## Check some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  if (n_x==-1)
    return
  endif

  ## Default Q
  if nargin<8
    Q = ones(n_y,1);
  endif
  

#   B_x = eye(n_x);		# Pseudo B
#   D_x = zeros(n_y,n_x);		# Pseudo D
  [l_x,l_y,L_x,L_y,J_uu,J_ux,J_uw,Us0] = ppp_lin(A',C',B',D',A_u',A_y',t,Q);
  
  l_x = l_x';
  l_y = l_y';
  L_x = L_x';
  L_y = L_y';
endfunction









Added mtt/lib/control/PPP/ppp_lin_plot.m version [460292101c].



























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] =  ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0)

  ## usage:   [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0)
  ##
  ## Linear PPP (Predictive pole-placement) computation with plotting
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## A_w: composite system matrix for W* generation 
  ##      one square matrix (A_wi) row for each system output
  ##      each A_wi generates W*' for ith system output.
  ## t: row vector of times for optimisation (equispaced in time)
  ## Q: column vector of output weights (defaults to unity)
  ## W: Constant setpoint vector (one element per output)
  ## x_0: Initial state
  ## OUTPUTS:
  ## Various poles 'n zeros
  ## k_x: State feedback gain
  ## k_w: setpoint gain
  ## ie u(t) = k_w w(t) - k_x x(t)
  ## K_x, K_w: open loop gains
  ## J_uu, J_ux, J_uw: cost derivatives

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  ## Some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  [n_U,m_U]=size(A_u);
  square = (n_U==m_U);		# Its a square matrix so same U* on each input
  [n_W,m_W]=size(A_w);
  if n_W==m_W			# A_w square
    n_W = n_W*n_y;		# Total W functions
  endif
  

  [n_t,m_t] = size(t);

  ## Default Q
  if nargin<8
    Q = ones(n_y,1)
  endif

  ## Default W
  if nargin<9
    W = ones(n_W,1)
  endif

  ## Default x_0
  if nargin<10
    x_0 = zeros(n_x,1);
  endif

  ## Check some dimensions
  [n_Q,m_Q] = size(Q);
  if ((m_Q != 1)&&(m_Q != m_t)) || (n_Q != n_y)
    error("Q must be a column vector with one row per system output");
  endif

  [n,m] = size(W);
  if ((m != 1) || (n != n_W))
    error("W must be a column vector with one element per system output");
  endif

  [n,m] = size(x_0);
  if ((m != 1) || (n != n_x))
    error("x_0 must be a column vector with one element per system state");
  endif

  ## Simulate
  [y,ystar,t,k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu]\
      =  ppp_lin_sim(A,B,C,D,A_u,A_w,t,Q,W,x_0);

  ## Plot
  xlabel("Time"); title("y* and y"); grid;
  plot(t,ystar,t,y);

  ## Compute some pole/zero info
  cl_poles = eig(A-B*k_x)';
  ol_poles = eig(A)';

  if nargout>3
    ol_zeros = tzero(A,B,C,D)';
    cl_zeros = tzero(A-B*k_x,B,C,D)';
  endif

endfunction

Added mtt/lib/control/PPP/ppp_lin_quad.m version [56182147a4].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] = \
      ppp_lin_quad (A,B,C,D,tau,Q,R,A_e)

  ## usage:[k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] =
  ## ppp_lin_quad (A,B,C,D,tau,Q,R[,A_e])
  ##
  ## 

  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)

  if nargin<8
    A_e = [];
  endif
  
  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R);

  A_u = ppp_aug(A_u,A_e);

  ## PPP solution
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] = \
      ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P);


endfunction

Added mtt/lib/control/PPP/ppp_lin_run.m version [10c572cbb5].































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [t,y,u,X_est,y_c,t_e,y_e,e_e,p_c,p_o] = ppp_lin_run (Name,Simulate,ControlType,w,x_0,p_c,p_o)

  ## usage: [t,y,u,y_c,t_e,y_e,e_e,p_c,p_o] = ppp_lin_run (Name,Simulate,ControlType,w,x_0,p_c,p_o)
  ##
  ## 
  ## Linear closed-loop PPP of lego system (and simulation)
  ##
  ## Name: Name of system (in mtt terms)
  ## Simulate = 0: real thing
  ## Simulate = 1: simulate
  ## Control = 0:  step test
  ## Control = 1:  PPP open-loop
  ## Control = 2:  PPP closed-loop
  ## w is the (constant) setpoint
  ## par_control and par_observer are structures containing parameters
  ## for the observer and controller

  ##Defaults
  if nargin<1			# Default name to dir name
    names = split(pwd,"/");
    [n_name,m_name] = size(names);
    Name = deblank(names(n_name,:));
  endif

  if nargin<6
    p_c.N = 50;
  endif

  if nargin<7
    p_o.sigma = 1e-1;
  endif

  ## System
  sys = mtt2sys(Name);		# Create system
  [A,B,C_0,D_0] = sys2ss(sys);	# SS form
  [n_x, n_u, n_y] = abcddim(A,B,C_0,D_0);

  ## Extract matrices for controlled and constrained outputs.
  if !struct_contains(p_c,"I_0") # Indices for controlled outputs
    p_c.I_0 = 1:n_y
  endif
  if !struct_contains(p_c,"I_1") # Indices for constrained outputs
    p_c.I_1 = 1:n_y
  endif

  C = C_0(p_c.I_0,:)
  C_c = C_0(p_c.I_1,:);
  D = D_0(p_c.I_0,:);
  D_c = D_0(p_c.I_1,:);
  [n_x, n_u, n_y] = abcddim(A,B,C,D); # Dimensions
  [n_x, n_u, n_y_c] = abcddim(A,B,C_c,D_c); # Dimensions


  if nargin<2
    Simulate = 1;
  endif
  
  if nargin<3
    ControlType = 2;
  endif
  
  if nargin<4
    w = ones(n_y,1);;
  endif
  
  if nargin<5
    x_0 = zeros(n_x,1);
  endif
  
  if !struct_contains(p_c,"delta_ol")
    p_c.delta_ol = 0.5;	# OL sample interval
  endif
  
  if !struct_contains(p_c,"T")
    p_c.T = 10;			# Last time point.
  endif

  if !struct_contains(p_c,"Iterations")
    p_c.Iterations = 5;		# Number of interations, total =T*Iterations
  endif

  if !struct_contains(p_c,"augment")
    p_c.augment = 0;		# Augment basis funs with constant
  endif
  
  if !struct_contains(p_c,"integrate")
    p_c.integrate = 0;		
  endif
  
  if !struct_contains(p_c,"Tau_u")
    p_c.Tau_u = [];
    p_c.Min_u = [];
    p_c.Max_u = [];
  endif

  if !struct_contains(p_c,"Tau_y")
    p_c.Tau_y = [];
    p_c.Min_y = [];
    p_c.Max_y = [];
  endif


  if !struct_contains(p_c,"Method")
    p_c.Method = "lq";
  endif

  if struct_contains(p_c,"Method")
    if strcmp(p_c.Method,"lq")
      p_c.Q = eye(n_y);
      p_c.n_U = n_x;
      if !struct_contains(p_c,"R")
	p_c.R = (0.1^2)*eye(n_u);
      endif
    elseif strcmp(p_c.Method,"original");
      if !struct_contains(p_c,"A_w")
	p_c.A_w = 0;
      endif
      if !struct_contains(p_c,"A_u")
	p_c.n_U = n_x;
	a_u = 2.0;
	p_c.A_u = laguerre_matrix(p_c.n_U,a_u);
	if p_c.augment		# Put in constant term
	  p_c.A_u = ppp_aug(0,p_c.A_u);
	endif
      endif
    else
      error(sprintf("Method %s not recognised", p_c.Method));
    endif
  endif

  if !struct_contains(p_c,"tau") # Time horizon
    if strcmp(p_c.Method,"lq")
      p_c.tau = [0:0.1:1]*2;
    elseif strcmp(p_c.Method,"original");
      p_c.tau = [10:0.1:11];
    else
      error(sprintf("Method %s not recognised", p_c.Method));
    endif
  endif
  
  if !struct_contains(p_c,"A_e")
    p_c.A_e = [];			# No extra modes
  endif

  if !struct_contains(p_o,"x_0")
    p_o.x_0 = zeros(n_x,1);
  endif
  
  if !struct_contains(p_o,"method")
    ##p_o.method = "continuous";
    ##p_o.method = "intermittent";
    p_o.method = "remote";
  endif
  
  ## Check w.
  [n_w,m_w] = size(w);
  if ( (n_w!=n_y) || (m_w!=1) )
    error(sprintf("ppp_lin_run: w must a column vector with %i elements",n_y));
  endif
  
  ## Initialise
  x_est = p_o.x_0;

  ## Initialise simulation state
  x = x_0;
  y_i = C*x_0

  if ControlType==0		# Step input
    I = 1;			# 1 large sample
    p_c.delta_ol = p_c.T;	# I
    K_w = zeros(p_c.n_U,n_y);
    K_w(1,1) = 1;
    K_w(2,1) = -1;
    K_x = zeros(p_c.n_U,n_x);
  else
    I = ceil(p_c.T/p_c.delta_ol) # Number of large samples
    if strcmp(p_c.Method, "original")
      [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] =\
	  ppp_lin(A,B,C,D,p_c.A_u,p_c.A_w,p_c.tau); # Design
    elseif strcmp(p_c.Method, "lq") # LQ design
      [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] \
	  = ppp_lin_quad (A,B,C,D,p_c.tau,p_c.Q,p_c.R,p_c.A_e);
      p_c.A_u = A_u;
    else
      error(sprintf("Control method %s not recognised", p_c.Method));
    endif

    ##Sanity check A_u
    [p_c.n_U,M_u] = size(p_c.A_u);
    if (p_c.n_U!=M_u)
      error("A_u must be square");
    endif

    ## Checks
    cl_poles = eig(A - B*k_x)
    ol_poles = eig(A)
    t_max = 1/min(abs(cl_poles));
    t_min = 1/max(abs(cl_poles));
  endif
  
  ## Initial control U
  U = zeros(p_c.n_U,1)	;

  ## Short sample interval
  dt = p_c.delta_ol/p_c.N;

  ## Observer design
  G = eye(n_x);		# State noise gain 
  sigma_x = eye(n_x);		# State noise variance
  Sigma = p_o.sigma*eye(n_y)	# Measurement noise variance
  
  if strcmp(p_o.method, "intermittent")
    Ad = expm(A*p_c.delta_ol);		# Discrete-time transition matrix
    if (ControlType==2)		# 
      [L, M, P, obs_poles] = dlqe(Ad,G,C,sigma_x,Sigma);
    else
      L = zeros(n_x,n_y);
      obs_poles = eig(Ad);
    endif
  elseif strcmp(p_o.method, "continuous")
    Ad = expm(A*dt);		# Discrete-time transition matrix
    A_ud = expm(p_c.A_u*dt);	# Discrete-time input transition
    if (ControlType==2)		# 
      [L, M, P, obs_poles] = dlqe(Ad,G,C,sigma_x,Sigma);
    else
      L = zeros(n_x,n_y);
      obs_poles = eig(Ad);
    endif
  elseif strcmp(p_o.method, "remote")
    L = zeros(n_x,n_y);
    obs_poles = [];
  else
    error(sprintf("Observer method ""%s"" unknown", p_o.method));
  endif
  
  ## Display the poles
  obs_poles

  ## Write the include file for the real-time function
  ## Use double length to allow for overuns
  overrun = 2;
  Ustar = ppp_ustar (p_c.A_u, n_u, [0:dt:overrun*p_c.delta_ol], 0,0);
  if p_c.integrate		# Integrate Ustar
    disp("Integrating Ustar");
    Ustar = cumsum(Ustar)*dt;
  endif
  
  disp("Writing Ustar.h ...");
  ppp_ustar2h(Ustar); 
  disp("done.");


  ## Control loop
  y = [];
  y_c = [];
  u = [];
  t = [];
  y_e = [];
  X_est = [];
  t_e = [];
  e_e = [];
  tick = time;
  i=0;

  for j=1:p_c.Iterations
    for k=1:I
      tim=time;			# Timing
      i++;

      if Simulate		# Exact simulation 
	X = x;			# Current (simulated) state
      else			# The real thing
	if strcmp(p_o.method, "remote")
	  [t_i,y_i,u_i,X] = ppp_put_get_X(U); # Remote-state interface
	else
	  [t_i,y_i,u_i] = ppp_put_get(U); # Generic interface to real-time
	endif
      endif
      
      ## Observer
      if strcmp(p_o.method, "intermittent")
	[x_est y_est y_new, e_est] = ppp_int_obs \
	    (x_est,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,L);
      elseif strcmp(p_o.method, "continuous")
	Ui = U;			# U at sub intervals
	for k = 1:p_c.N
	  [x_est y_est y_new e_est] = ppp_int_obs \
	      (x_est,yi(:,k),Ui,A,B,C,D,p_c.A_u,dt,L);
	  Ui = A_ud'*Ui;
	  y_e = [y_e; y_new'];
	  e_e = [e_e; e_est'];
	endfor
      elseif strcmp(p_o.method, "remote")
	## predict from remote state (with zero L)	
	if (ControlType==2)	# Closed-loop
    	  [x_est y_est y_new e_est] = ppp_int_obs \
    	      (X,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,zeros(n_x,1));
	##  x_est = X; y_est=y_i; y_new=y_i; e_est=0;
	else			# Open-loop
	  [x_est y_est y_new e_est] = ppp_int_obs \
	      (x_est,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,zeros(n_x,1));
	endif
      endif
      
      ## Simulation (based on U_i)
      if Simulate
	t_sim = [1:p_c.N]*dt;	# Simulation time points
	[yi,ui,xsi] = ppp_ystar(A,B,C,D,x,p_c.A_u,U,t_sim); # Simulate
	x = xsi(:,p_c.N);	# NEXT state
	ti  = [(i-1)*p_c.N:i*p_c.N-1]*dt; 
	y_i = yi(1);	# Current output
	t_i = ti(1);
      endif

      ##Control
      if ( length(p_c.Tau_u)==0&&length(p_c.Tau_y)==0 )
	U = K_w*w - K_x*x_est;
      else
	## Input constraints 
	[Gamma_u, gamma_u] = \
	    ppp_input_constraints(p_c.A_u,p_c.Tau_u,p_c.Min_u,p_c.Max_u);
	
	## Output constraints
	[Gamma_y,gamma_y] = \
	    ppp_output_constraints(A,B,C_c,D_c,x_est,p_c.A_u,\
				   p_c.Tau_y,p_c.Min_y,p_c.Max_y);
	
	## Composite constraints - t=0
	Gamma = [Gamma_u; Gamma_y];
	gamma = [gamma_u; gamma_y];
	
	[u_qp,U,n_active] = ppp_qp \
	    (x_est,w,J_uu,J_ux,J_uw,Us0,Gamma,gamma,1e-6,1);
      endif

      ## Allow for the delay
      ##U = expm(p_c.delta_ol*p_c.A_u)*U;

      ## Save data
      if Simulate
	t = [t;ti'];
	y = [y;yi'];
	X_est = [X_est;x_est'];
	y_c = [y_c;(C_c*xsi)'];
	u = [u;ui'];
      else
	t = [t;t_i];
	y = [y;y_i'];
	X_est = [X_est;x_est'];
	u = [u;u_i'];
      endif

      if strcmp(p_o.method, "intermittent")||strcmp(p_o.method, "remote")
	y_e = [y_e; y_new'];
	e_e = [e_e; e_est'];
	t_e = [t_e; t_i];
      endif
      if !Simulate
	delta_comp = time-tim;
	usleep(floor(1e6*(p_c.delta_ol-delta_comp-0.01)));
      endif
      
    endfor			# Main loop
    w = -w;
  endfor 			# Outer loop
  if !Simulate
    ppp_put_get(0*U); 		# Reset to zero
  endif

  
  if strcmp(p_o.method, "continuous")
    t_e = t;
  endif
  
  
  average_ol_sample_interval = (time-tick)/i

  ## Put data on file (so can use for identification)
  filename = sprintf("%s_ident_data.dat",Name);
  eval(sprintf("save -ascii %s t y u",filename));

endfunction

Added mtt/lib/control/PPP/ppp_lin_sim.m version [767b01c78f].

























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y,ystar,t,k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] =  ppp_lin_sim(A,B,C,D,A_u,A_w,tau,Q,W,x_0)

  ## usage:   [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,tau,Q,W,x_0)
  ##
  ## Linear PPP (Predictive pole-placement) computation with plotting
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## A_w: composite system matrix for W* generation 
  ##      one square matrix (A_wi) row for each system output
  ##      each A_wi generates W*' for ith system output.
  ## tau: row vector of times for optimisation (equispaced in time)
  ## Q: column vector of output weights (defaults to unity)
  ## W: Constant setpoint vector (one element per output)
  ## x_0: Initial state
  ## OUTPUTS:
  ## y : closed-loop output
  ## ystar : open-loop moving-horizon output
  ## t : time axis

  ## Copyright (C) 2001 by Peter J. Gawthrop
  ## 	$id: ppp_lin_plot.m,v 1.13 2001/01/26 16:03:13 peterg Exp $	

  ## Some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  [n_U,m_U]=size(A_u);
  square = (n_U==m_U);		# Its a square matrix so same U* on each input
  [n_W,m_W]=size(A_w);
  if n_W==m_W			# A_w square
    n_W = n_W*n_y;		# Total W functions
  endif
  

  [n_tau,m_tau] = size(tau);

  ## Default Q
  if nargin<8
    Q = ones(n_y,1);
  endif

  ## Default W
  if nargin<9
    W = ones(n_W,1)
  endif

  ## Default x_0
  if nargin<10
    x_0 = zeros(n_x,1);
  endif

  ## Check some dimensions
  [n_Q,m_Q] = size(Q);
  if ((m_Q != 1)&&(m_Q != m_tau)) || (n_Q != n_y)
    error("Q must be a column vector with one row per system output");
  endif

  [n,m] = size(W);
  if ((m != 1) || (n != n_W))
    error("W must be a column vector with one element per system output");
  endif

  [n,m] = size(x_0);
  if ((m != 1) || (n != n_x))
    error("x_0 must be a column vector with one element per system state");
  endif

  ## Control design
  disp("Designing controller");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] = ppp_lin  (A,B,C,D,A_u,A_w,tau,Q);

  ## Set up simulation times
  dtau = tau(2) -tau(1);		# Time increment
  t =  0:dtau:tau(length(tau));	# Time starting at zero

  ## Compute the OL step response
  disp("Computing OL response");
  U = K_w*W - K_x*x_0;
  ystar = ppp_ystar (A,B,C,D,x_0,A_u,U,t);

  ## Compute the CL step response
  disp("Computing CL response");
  y = ppp_sm2sr(A-B*k_x, B, C, D, t, k_w*W, x_0); # Compute Closed-loop control


endfunction

Added mtt/lib/control/PPP/ppp_nlin.m version [d0ab21bae9].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [U, U_all, Error, Y, its] = ppp_nlin(system_name,x_0,par_0,sim,us,w,free, Q, extras)

  ## usage:  [U, U_all, Error, Y,its ] = ppp_nlin(system_name,x_0,par_0,sim,us,w,free, Q, extras)
  ##
  ## 
  
  if nargin<9
    extras.criterion = 1e-8;
    extras.max_iterations = 10;
    extras.v = 0.1;
    extras.verbose = 1;
  endif
  
  s_system_name = sprintf("s%s", system_name); # Name of sensitivity system
  
  ## Details
  [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name));
  [n_tau,n_us] = size(us);
  
  if nargin<8
    Q = ones(n_y,1);
  endif
 
  ## Checks
  if (n_us<>n_u)
    error(sprintf("Inputs (%i)  differenct to system inputs (%i)", n_us, n_u));
  endif
    
  ##Optimise
  [par,Par,Error,Y,its] = ppp_optimise(s_system_name,x_0,par_0,sim,us,w,free,Q,extras);
  
  U = par(free(:,1));
  U_all = Par(free(:,1),:);
endfunction



Added mtt/lib/control/PPP/ppp_nlin_run.m version [76fba90674].
















































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y,u,t,p,UU,t_open,t_ppp,t_est,its_ppp,its_est] = ppp_nlin_run(system_name,i_ppp,i_par,A_u,w_s,N_ol,Q,extras)


  ## usage: [y,u,t,p,U,t_open,t_ppp,t_est,its_ppp,its_est] =
  ## ppp_nlin_run (system_name,i_ppp,i_par,A_u,w_s,N_ol[,extras])
  ##
  ##  y,u,t   System output, input and corresponding time p
  ##  Estimated parameters U       PPP weight vector t_open  The
  ##  open-loop interval t_ppp   Time for each ppp optimisation t_est
  ##  Time for each estimation i_ppp   Matrix of ppp gain indices: col.
  ##  1 Gain indices in sensitivity system col. 2  Gain sensitivity
  ##  indices in sensitivity system col. 3  Gain indices in  system
  ##  i_par Matrix of indices of estimated parameters col. 1  Parameter
  ##  indices in sensitivity system col. 2  Parameter sensitivity
  ##  indices in sensitivity system col. 3  Parameter indices in  system
  ##  A_u     Basis function generating matrix w_s     w_star: That part
  ##  of the moving horizon setpoint within the optimisation horizon.
  ##  N_ol The number of open-loop intervals to be computed extras
  ##  Extra parameters in  a structure: extras.alpha           ??
  ##  extras.criterion Optimisation convergence criterion
  ##  extras.emulate_timing Simulate some real-time features
  ##  extras.estimate Estimate parameters and states
  ##  extras.max_iterations Maximum optimisation iterations
  ##  extras.simulate 1 for simulation (not real-time) extras.vInitial Levenberg-Marquardt parameter
  ##          extras.verbose         1 for extra info display
  ##
  ## Real-time implementatipn of  nonlinear PPP Copyright (C) 2001,2002
  ## by Peter J. Gawthrop

  ## Globals to pass details to simulation
  global system_name_sim i_ppp_sim x_0_sim y_sim u_sim A_u_sim simpar_sim

  ## Defaults
  if nargin<8
    extras.alpha = 0.1;
    extras.criterion = 1e-5;
    extras.emulate_timing = 0;
    extras.max_iterations = 10;
    extras.simulate = 1;
    extras.v = 1e-5;
    extras.verbose = 0;
    extras.visual = 0;
  endif

  ##Estimate if we have some adjustable parameters
  estimating_parameters = (length(i_par)>0);
  
  ## Names
  s_system_name = sprintf("s%s", system_name);

  ## System details -- defines simulation within ol interval
  par = eval(sprintf("%s_numpar;", system_name));
  simpar = eval(sprintf("%s_simpar;", system_name));
  dt = simpar.dt;		# Sample interval
  simpar_est = simpar;		# Initial estimation simulation params
  simpar_model = simpar;	# Initial internal model simulation params
  simpar_pred = simpar;		# Initial prediction simulation params
  T_ol_0 = simpar.last;		# The initial specified interval
  n_t = round(simpar.last/simpar.dt); # Corresponding length
  x_0 = eval(sprintf("%s_state(par);", system_name));
  x_0_model = x_0;
  [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name));
  [n_par,m_par] = size(i_par);
  if nargin<8
    Q = ones(n_y,1);
  endif
 
  ## Sensitivity system details -- defines moving horizon simulation
  simpars = eval(sprintf("%s_simpar;", s_system_name));
  pars = eval(sprintf("%s_numpar;", s_system_name));
  x_0s = eval(sprintf("%s_state(pars);", s_system_name));
  x_0_models = x_0s;

  p = []; # Initialise saved parameters

  ## Times
  ## -- within opt horizon
  n_Tau = round(simpars.last/simpars.dt);
  dtau = simpars.dt;
  Tau = [0:n_Tau-1]'*dtau;
  [n_tau,n_w] = size(w_s);
  tau = Tau(n_Tau-n_tau+1:n_Tau);
  w = w_s(n_tau,:);		# Final value of setpoint


  ## Main simulation loop
  y = [];
  x = [];
  u = [];
  t = [];


  t_last = 0;
  UU_l =[];
  UU_c =[];
  
  t_ppp = [];
  t_est = [];
  its_ppp = [];
  its_est = [];
  t_open = [];
  x_nexts = zeros(2*n_x,1);

  ## Initial U is zero
  [n_U,junk] = size(A_u);
  U = zeros(n_U,1);

  ## Initialise saved U
  UU = [];

  ## Create input basis functions
  u_star_tau = ppp_ustar(A_u,1,Tau',0,0,n_u-n_U);
	
  ## Reverse time to get "previous" U
  U_old = U;

  if (extras.simulate==1)
    ## Set up globals for simulation
    system_name_sim = system_name;
    i_ppp_sim = i_ppp;
    x_0_sim = x_0;
    y_sim = [];			# Junk
    u_sim = [];			# Junk
    A_u_sim = A_u;
    simpar_sim = simpar;
    T_total = simpar.last;
  endif
  
  for i = 0:N_ol		# Main loop 
    printf("%i",i);
    UU = [UU; U'];		# Save control U
    
    if n_par>0
      par_est = pars(i_par(:,1));
      p = [p; par_est'];		# Save up the estimated parameters
    endif
    

    if (extras.simulate==1)
      [y_ol,u_ol] = ppp_RT_sim(U); # Simulate
    else
      [y_ol,u_ol] = ppp_RT(U);	# Real thing
    endif

    t_start = time;		# Initialise time

    if (i==0)			# Data is rubbish at i=0 - ignore
      usleep(T_ol_0*1e6);		# Hang about
    else
      ## Set up time information for the gathered data
      n_ol = length(y_ol);	# How many data points?
      t_ol = [0:n_ol-1]'*dt;
      T_ol = n_ol*dt;		# Length of ol interval
      t_open = [t_open;T_ol];

      ## Generate input to actual system
      u_star_t = ppp_ustar(A_u,1,t_ol',0,0,n_u-n_U);

      ## Tune parameters/states
      if (estimating_parameters==1)

	## Set up according to interval length
	if (T_ol>T_ol_0) ## Truncate data
	  simpar_est.last = T_ol_0;
	  y_est = y_ol(1:n_t+1,:);
	else
	  simpar_est.last = T_ol;
	  y_est = y_ol;
	endif

	simpar_pred.last = T_ol_0; # Predicted length of next interval
	pars(i_ppp(:,1)) = U_old; # Update the simulation ppp weights
	
	## Optimise
	tick = time;
	[pars,Par,Error,Y,its] = \
	    ppp_optimise(s_system_name,x_0_models,pars,simpar_est,u_star_t,y_est,i_par,Q,extras);
	
	if extras.visual
	  figure(11);
	  title("Parameter optimisation"); 
	  II = [1:length(y_est)]; plot(II,y_est,"*", II,Y);
	endif
	
	est_time = time-tick;  
	t_est = [t_est;est_time];
	its_est = [its_est; its-1];
      endif

      ## Update internal model
      par(i_ppp(:,3)) = U_old; # Update the internal model ppp weights

      if (estimating_parameters==1)
	par(i_par(:,3)) = pars(i_par(:,1)); # Update the internal model params
      endif

      simpar_model.last = T_ol;
      [y_model,x_model] = eval(sprintf("%s_sim(x_0_model, par, simpar_model, \
 					       u_star_t);",system_name));

      x_0 = x_model(n_ol+1,:)';	# Initial state of next interval
##      x_0 = x_model(n_ol-1,:)';	# Initial state of next interval
      x_0_model = x_0;
      x_0_models(1:2:(2*n_x)-1) = x_0_model;

      ## Compute U by optimisation
      tick = time;

      ## Predict state at start of next interval
      par(i_ppp(:,3)) = U;
      [y_next,x_next] = eval(sprintf("%s_sim(x_0, par, simpar, \
					     u_star_t);",system_name));
      x_next = x_next(n_t+1,:)'; # Initial state for next time
      x_nexts(1:2:(2*n_x)-1) = x_next; # And for internal sensitivity model
      
      ## Optimize for next interval      
      U_old = U;		# Save previous value
      U = expm(A_u*T_ol)*U;	# Initialise from continuation trajectory
      pars(i_ppp(:,1)) = U;	# Put initial value of U into the parameter vector
      [U, U_all, Error, Y, its] = ppp_nlin(system_name,x_nexts,pars,simpars,u_star_tau,w_s,i_ppp,Q,extras);
      if extras.visual
	figure(12);
	title("PPP optimisation");
	II = [1:length(w_s)]; plot(II,w_s,"*", II,Y);
	figure(1);
	endif

      ppp_time = time-tick;  
      t_ppp = [t_ppp;ppp_time];
      its_ppp = [its_ppp; its-1];

      ## Total execution time
      T_total = time - t_start;
      if (extras.simulate==1)&&(extras.emulate_timing!=1)
	printf(".");
	T_diff = 0;		# Always correct interval
      else
	T_diff = T_total - T_ol_0; # Compute difference
	if T_diff<0
	  printf("-");
	  usleep(-T_diff*1e6);
	  T_total = time - t_start;
	else
	  printf("+");
	endif   
				printf("%2.2f",T_total);
      endif
      T_total = simpar.dt*round(T_total/simpar.dt); # Whole no. of intervals

      pars(i_ppp(:,1)) = U;	# Put final value of U into the parameter vector

      ## Save up data
      y_ol = y_ol(1:n_ol,:);
      y = [y; y_ol];
      u = [u; u_ol];
      t = [t; t_ol+t_last*ones(n_ol,1) ];
      t_last = t_last + T_ol;

    endif


    if (extras.simulate==1) # Do the actual simulation
      if (extras.emulate_timing==1) # Emulate timing
	simpar_sim.last = T_total; # simulate for actual execution time
      endif
      ppp_RT_sim_compute (U_old);
    endif
    
  endfor
  printf("\n");
endfunction

Added mtt/lib/control/PPP/ppp_nlin_sim.m version [26d1c64307].







































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y,x,u,t,p,UU,UU_c,UU_l,t_ppp,t_est] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras)

  ## usage: [y,x,u,t,p,UU,UU_c,UU_l,t_ppp,t_est] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras) 
  ##
  ## 
  
  ## Simulate nonlinear PPP
  ## Copyright (C) 2000 by Peter J. Gawthrop

  ## Defaults
  if nargin<7
    extras.U_initial = "zero";
    extras.U_next = "continuation";
    extras.criterion = 1e-5;
    extras.max_iterations = 10;
    extras.v = 0.1;
    extras.verbose = 0;
    extras.estimate = 1;
  endif
  
  

  ## Names
  s_system_name = sprintf("s%s", system_name);

  ## System details -- defines simulation within ol interval
  par = eval(sprintf("%s_numpar;", system_name));
  simpar = eval(sprintf("%s_simpar;", system_name));
  x_0 = eval(sprintf("%s_state(par);", system_name));
  [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name));

  ## Sensitivity system details -- defines moving horizon simulation
  simpars = eval(sprintf("%s_simpar;", s_system_name));
  pars = eval(sprintf("%s_numpar;", s_system_name));

  ## Times
  ## -- within opt horizon
  n_Tau = round(simpars.last/simpars.dt);
  dtau = simpars.dt;
  Tau = [0:n_Tau-1]'*dtau;
  [n_tau,n_w] = size(w_s);
  tau = Tau(n_Tau-n_tau+1:n_Tau);
  w = w_s(length(w_s));		# Final value of setpoint

  ## -- within ol interval
  n_t = round(simpar.last/simpar.dt);
  dt = simpar.dt;
  t_ol = [0:n_t-1]'*dt;
  T_ol = n_t*dt;

  ## Create input basis functions
  [n_U,junk] = size(A_u);

  ## For moving horizon
  eA = expm(A_u*dtau);
  u_star_i = ones(n_U,1);
  u_star_tau = [];
  for i = 1:n_Tau
    u_star_tau = [u_star_tau; u_star_i'];
    u_star_i = eA*u_star_i;
  endfor

  ## and for actual implementation
  eA = expm(A_u*dt);
  u_star_i = ones(n_U,1);
  u_star_t = [];
  for i = 1:n_t
    u_star_t = [u_star_t; u_star_i'];
    u_star_i = eA*u_star_i;
  endfor
  
  if extras.verbose
    title("U*(tau)")
    xlabel("tau");
    plot(Tau,u_star_tau)
    title("U*(t)")
    xlabel("t_ol");
    plot(t_ol,u_star_t)
  endif
  

  ## Check number of inputs adjust if necessary
  if n_u>n_U
    disp(sprintf("Augmenting inputs with %i zeros", n_u-n_U));
    u_star_tau = [u_star_tau; zeros(n_u-n_U, n_Tau)];
    u_star_t   = [u_star_t; zeros(n_u-n_U, n_t)];
  endif
  
  if n_u<n_U
    error(sprintf("n_U (%i) must be less than or equal to n_u (%i)", \
		  n_U, n_u));
  endif
  
  ## Compute linear gains 
  [A,B,C,D] = eval(sprintf("%s_sm(par);", system_name));
  B = B(:,1); D = D(:,1);
  [k_x,k_w,K_x,K_w] = ppp_lin(A,B,C,D,A_u,0,tau');

  ## Main simulation loop
  y = [];
  x = [];
  u = [];
  t = [];

  p = [];

  t_last = 0;
  UU = [];
  UU_l =[];
  UU_c =[];
  
  t_ppp = [];
  t_est = [];

  x_0s = zeros(2*n_x,1);

  if  strcmp(extras.U_initial,"linear")
    U = K_w*w - K_x*x_0;
  elseif strcmp(extras.U_initial,"zero")
    U = zeros(n_U,1);
  else
    error(sprintf("extras.U_initial = \"%s\" is invalid", extras.U_initial));
  endif

  ## Reverse time to get "previous" U
  U = expm(-A_u*T_ol)*U;

  for i = 1:N_ol		# Main loop 
    ## Compute initial U from linear case
    U_l = K_w*w - K_x*x_0;

    ## Compute initial U  for next time from continuation trajectory
    U_c = expm(A_u*T_ol)*U;

    ## Create sensitivity system state
    x_0s(1:2:2*n_x) = x_0;
    
    ## Set next U (initial value for optimisation)
    if  strcmp(extras.U_next,"linear")
      U = U_l;
    elseif strcmp(extras.U_next,"continuation")
      U = U_c;
    elseif strcmp(extras.U_next,"zero")
      U = zeros(n_U,1);
    else
      error(sprintf("extras.U_next = \"%s\" is invalid", extras.U_next));
    endif
    pars(i_ppp(:,1)) = U;	# Put initial value of U into the parameter vector

    ## Compute U by optimisation
    tick = time;
    if extras.max_iterations>0
      [U, U_all, Error, Y] = ppp_nlin(system_name,x_0s,pars,simpars,u_star_tau,w_s,i_ppp,extras);
      pars(i_ppp(:,1)) = U;	# Put final value of U into the parameter vector
    else
      Error = [];
    endif
    ppp_time = time-tick;  
    t_ppp = [t_ppp;ppp_time];
    
    ## Generate control
    u_ol = u_star_t*U;		# Not used - just for show

    ## Simulate system over one ol interval
    par(i_ppp(:,3)) = pars(i_ppp(:,1)); # Update the simulation ppp weights
    [y_ol,x_ol] = eval(sprintf("%s_sim(x_0, par, simpar, u_star_t);", system_name));


    ## Tune parameters/states
    if (extras.estimate==1)
      tick = time;
      par_est = pars(i_par(:,1));
      p = [p; par_est'];
      pars = ppp_optimise(s_system_name,x_0s,pars,simpar,u_star_t,y_ol,i_par,extras);
      est_time = time-tick;  
      t_est = [t_est;est_time];
    endif

    x_0  = x_ol(n_t+1,:)';	# Extract state for next time
    y_ol = y_ol(1:n_t,:);	# Avoid extra points due to rounding error 
    x_ol = x_ol(1:n_t,:);	# Avoid extra points due to rounding error 
    
    
    y = [y; y_ol];
    x = [x; x_ol];
    u = [u; u_ol];

    UU = [UU; U'];
    UU_l = [UU_l; U_l'];
    UU_c = [UU_c; U_c'];

    t = [t; t_ol+t_last*ones(n_t,1) ];
    t_last = t_last + T_ol; 


  endfor

endfunction

Added mtt/lib/control/PPP/ppp_open2closed.m version [fea943f4dc].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [K_x T] = ppp_open2closed (A_u,A_c,k_x,x_0,Us0);

  ## usage:  [K_x T] = ppp_open2closed (A_u,A_c,k_x,x_0[,Us0]);
  ## K_x is the open-loop matrix as in U = K_w W - K_x x
  ## Note that K_x is a column vector of matrices - one matrix per input.
  ## T is the transformation matrix: x = T*Ustar; A_c = T*A_u*T^-1; U = (k_x*T)'
  ## A_u: The control basis-function matrix
  ## Us0: The initial value of Ustar
  ## A_c: closed-loop system matrix
  ## k_x: closed-loop feedback gain
  ## x_0: initial state
  ## Us0: initial basis fun state

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	


  ## Check sizes
  n_o = is_square(A_u);
  n_c = is_square(A_c);

  if (n_o==0)||(n_c==0)||(n_o!=n_c)
    error("A_u and A_c must be square and of the same dimension");
  endif

  [n_u,n_x] = size(k_x);

  ## Defaults
  if nargin<4
    x_0 = zeros(n_c,1);
  endif

  if nargin<5 #Create U*(0)
    ##Us0  = ppp_ustar(A_u,n_u);
    Us0 = ones(1,n_o);
  endif
  

  ## Decompose A_u and Us0 into two bits:
  if n_o==n_c
    A_w = [];
    u_0 = Us0(1:n_c)';		# Assume same Us0 on each input
  else
    A_w = A_u(n_c+1:n_o, n_c+1:n_o)
    A_u = A_u(1:n_c, 1:n_c)
    U_w = Us0(1,n_c+1:n_o)'
    u_0 = Us0(1:n_c)'
  endif
  
  if !is_controllable(A_u,u_0)
    error("The pair [A_u, u_0] must be controllable");
  endif

  ## Controllability matrices
  C_o = u_0;
  C_c = x_0;
  for i=1:n_c-1
    C_o = [C_o A_u^i*u_0]; 
    C_c = [C_c A_c^i*x_0];
  endfor

  ## Transformation matrix: x = T*Ustar; A_c = T*A_u*T^-1; U = (k_x*T)'
  iC_o = C_o^-1;
  T = C_c*iC_o;

  K_x = [];
  for j = 1:n_u
    ## K_j matrix
    K_j = [];
    for i=1:n_c;
      ## Create T_i = dT/dx_i
      T_i = zeros(n_c,1);
      T_i(i) = 1;
      for k=1:n_c-1;
	A_k = A_c^k;
	T_i = [T_i A_k(:,i)];
      endfor
      T_i = T_i*iC_o;
      kj = k_x(j,:);		# jth row of k_x
      K_ji = kj*T_i;		# ith row of K_j
      K_j = [K_j; K_ji];
    endfor
    K_x = [K_x; K_j'];
  endfor

endfunction

Added mtt/lib/control/PPP/ppp_optimise.m version [21b69c71ec].
































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [par,Par,Error,Y,iterations,x] = \
      ppp_optimise(system_name,x_0,par_0,simpar,u,y_0,free,Q,extras);
  ## Levenberg-Marquardt optimisation for PPP/MTT
  ## Usage: [par,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpar,u,y_0,free[,Q,extras]);
  ##  system_name     String containing system name
  ##  x_0             Initial state
  ##  par_0           Initial parameter vector estimate
  ##  simpar          Simulation parameters:
  ##        .first      first time
  ##        .dt         time increment
  ##        .stepfactor Euler integration step factor
  ##  u               System input (column vector, each row is u')
  ##  y_0             Desired model output
  ##  free            one row for each adjustable parameter
  ##                  first column parameter indices
  ##                  second column corresponding sensitivity indices
  ##  Q               vector of positive output weights.
  ##  extras (opt)    optimisation parameters
  ##        .criterion convergence criterion
  ##        .max_iterations limit to number of iterations
  ##        .v  Initial Levenberg-Marquardt parameter

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.14  2002/08/20 16:14:35  gawthrop
  ## Include Q in documentation
  ##
  ## Revision 1.13  2002/08/20 15:43:45  gawthrop
  ## Works with ident DIY rep
  ##
  ## Revision 1.12  2002/06/11 11:25:25  gawthrop
  ## No longer delay the simulated data.
  ##
  ## Revision 1.11  2002/05/20 13:32:36  gawthrop
  ## Sanity check on y_0
  ##
  ## Revision 1.10  2002/05/13 16:01:09  gawthrop
  ## Addes Q weighting matrix
  ##
  ## Revision 1.9  2002/05/08 10:14:21  gawthrop
  ## Idetification now OK (Moved data range in ppp_optimise by one sample interval)
  ##
  ## Revision 1.8  2002/04/23 17:50:39  gawthrop
  ## error --> err to avoid name clash with built in function
  ##
  ## Revision 1.7  2001/08/10 16:19:06  gawthrop
  ## Tidied up the optimisation stuff
  ##
  ## Revision 1.6  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ## Revision 1.5  2001/06/06 07:54:38  gawthrop
  ## Further fixes to make nonlinear PPP work ...
  ##
  ## Revision 1.4  2001/05/26 15:46:38  gawthrop
  ## Updated to account for new nonlinear ppp
  ##
  ## Revision 1.3  2001/04/05 11:50:12  gawthrop
  ## Tidied up documentation + verbose mode
  ##
  ## Revision 1.2  2001/04/04 08:36:25  gawthrop
  ## Restuctured to be more logical.
  ## Data is now in columns to be compatible with MTT.
  ##
  ## Revision 1.1  2000/12/28 11:58:07  peterg
  ## Put under CVS
  ##
  ###############################################################


  ## Copyright (C) 1999,2000,2001,2002 by Peter J. Gawthrop

  ## Simulation command
  sim_command = sprintf("%s_ssim(x_0,par,simpar,u,i_s);", system_name);

  ## Extract indices
  i_t = free(:,1);		# Parameters
  i_s = free(:,2)';		# Sensitivities

  if nargin<9
    extras.criterion = 1e-5;
    extras.max_iterations = 10;
    extras.v = 1e-5;
    extras.verbose = 0;
  endif
  

  [n_data,n_y] = size(y_0);
  if n_data<n_y
    error("ppp_optimise: y_0 should be in columns, not rows")
  endif

  if nargin<8
    Q = ones(n_y,1);
  endif
  
  n_th = length(i_s);
  err_old = inf;
  err_old_old = inf;
  err = 1e50;
  reduction = inf;
  predicted_reduction = 0;
  par = par_0;
  Par = par_0;
  step = ones(n_th,1);
  Error = [];
  Y = [];
  iterations = 0;
  v = extras.v;			# Levenverg-Marquardt parameter.
  r = 1;			# Step ratio

  if extras.verbose		# Diagnostics
    printf("Iteration: %i\n", iterations);
    printf("  error:  %g\n", err);
    printf("  reduction:  %g\n", reduction);
    printf("  prediction: %g\n", predicted_reduction);
    printf("  ratio:      %g\n", r);
    printf("  L-M param:  %g\n", v);
    printf("  parameters: ");
    for i_th=1:n_th
      printf("%g ", par(i_t(i_th)));
    endfor
    printf("\n");
  endif
  
  while (abs(reduction)>extras.criterion)&&\
	(abs(err)>extras.criterion)&&\
	(iterations<extras.max_iterations)

    iterations = iterations + 1; # Increment iteration counter

    [y,y_par,x] = eval(sim_command); # Simulate
    [N_data,N_y] = size(y);

    if (N_y!=n_y)
      mess = sprintf("n_y (%i) in data not same as n_y (%i) in model", n_y,N_y);
      error(mess);
    endif

    ## Use the last part of the simulation to compare with data
    ## ### Removed #### And shift back by one data point
#     if ( (N_data-n_data)<1 )
#       error(sprintf("y_0 (%i) must be shorter than y (%i)", n_data, N_data));
#     endif
    y = y(N_data-n_data+1:N_data,:);
    y_par = y_par(N_data-n_data+1:N_data,:);

    if extras.visual==1
      ## Plot
      title("Optimisation data");
      plot([y y_0])
    endif
    
    ##Evaluate error, cost derivative J and cost second derivative JJ
    err = 0; 
    J = zeros(n_th,1);
    JJ = zeros(n_th,n_th);
   
    for i = 1:n_y
      E = y(:,i) - y_0(:,i);	#  Error in ith output
      err = err + Q(i)*(E'*E);	# Sum the squared error over outputs
      y_par_i = y_par(:,i:n_y:n_y*n_th); # sensitivity function (ith output)
      J  = J + Q(i)*y_par_i'*E;	# Jacobian
      JJ = JJ + Q(i)*y_par_i'*y_par_i; # Newton Euler approx Hessian
    endfor

    if iterations>1 # Adjust the Levenberg-Marquardt parameter
      reduction = err_old-err;
      predicted_reduction =  2*J'*step + step'*JJ*step;
      r = predicted_reduction/reduction;
      if (r<0.25)||(reduction<0)
	v = 4*v;
      elseif r>0.75
	v = v/2;
      endif

      if reduction<0		# Its getting worse
	par(i_t) = par(i_t) + step; # rewind parameter
	err = err_old;	# rewind error
	err_old = err_old_old; # rewind old error
	if extras.verbose
	  printf(" Rewinding ....\n");
	endif
      endif
    endif

    ## Compute step using pseudo inverse
    JJL = JJ + v*eye(n_th);	# Levenberg-Marquardt term
    step =  pinv(JJL)*J;	# Step size
    par(i_t) = par(i_t) - step; # Increment parameters
    err_old_old = err_old;	# Save old error
    err_old = err;		# Save error

    ##Some diagnostics
    Error = [Error err];	# Save error
    Par = [Par par];		# Save parameters
    Y = [Y y];			# Save output

    if extras.verbose		# Diagnostics
      printf("Iteration: %i\n", iterations);
      printf("  error:  %g\n", err);
      printf("  reduction:  %g\n", reduction);
      printf("  prediction: %g\n", predicted_reduction);
      printf("  ratio:      %g\n", r);
      printf("  L-M param:  %g\n", v);
      printf("  parameters: ");
      for i_th=1:n_th
	printf("%g ", par(i_t(i_th)));
      endfor
      printf("\n");
    endif
    

  endwhile

endfunction

Added mtt/lib/control/PPP/ppp_output_constraint.m version [1ed78d0651].

















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Gamma,gamma] = ppp_output_constraint (A,B,C,D,x_0,A_u,Tau,Min,Max,Order,i_y)

  ## usage:  [Gamma,gamma] = ppp_output_constraint (A,B,C,D,x_0,A_u,Tau,Min,Max,Order)
  ##
  ## Derives the output constraint matrices Gamma and gamma
  ## For Constraints Min and Max at times Tau
  ## Initial state x_0 
  ## Order=0 - output constraints
  ## Order=1 - output derivative constraints
  ## etc
  ## NOTE You can stack up Gamma and gamma matrices for create multi-output constraints.

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  ## Sizes
  [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions
  [n_U,m_U] = size(A_u);	# Number of basis functions
  [n,n_tau] = size(Tau);		# Number of constraint times
  
  if n_tau==0			# Nothing to be done
    Gamma = [];
    gamma = [];
    return
  endif

  ## Defaults
  if nargin<10
    Order = zeros(1,n_tau);
  endif

  if nargin<11
    i_y = 1;			# First output
  endif

  if n != 1
    error("Tau must be a row vector");
  endif
  
  n = length(Min);
  m = length(Max);
  o = length(Order);

  if (n != n_tau)||(m != n_tau)||(o != n_tau)
    error("Tau, Min, Max and Order must be the same length");
  endif
  

  ## Compute Gamma 
  Gamma = [];
  zero_x = zeros(size(x_0));
  for i=1:n_U
    U = zeros(n_U,1); U(i,1) = 1; # Set up U_i
    y_i = ppp_ystar (A,B,C,D,zero_x,A_u,U,Tau); # Compute y* for ith input for each tau
    y_i = y_i(i_y,:); # Pluck out output i_y
    ## Gamma = [Gamma [-y_i';y_i']]; # Put in parts for Min and max
    Gamma_i = [];
    if (Min>-inf)
      Gamma_i = [Gamma_i; -y_i']; # Min part of column
    endif
    if (Max<inf)
      Gamma_i = [Gamma_i;  y_i'];	# Add column for Max
    endif
    Gamma = [Gamma Gamma_i]; # Put in parts for Min and max
  endfor

  ## Compute gamma
  zero_U = zeros(size(U));
  y_x = ppp_ystar (A,B,C,D,x_0,A_u,zero_U,Tau);	# Output if U is zero
  gamma = [];
  if (Min>-inf)
    gamma = [gamma; -(Min-y_x)'];
  endif
  if (Max<inf)
    gamma = [gamma; (Max-y_x)'];
  endif
  
endfunction


Added mtt/lib/control/PPP/ppp_output_constraints.m version [e3acc8646d].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Gamma,gamma] = ppp_output_constraints (A,B,C,D,x_0,A_u,Tau,Min,Max,Order)

  ## usage:
  ## [Gamma,gamma] = ppp_output_constraints(A,B,C,D,x_0,A_u,Tau,Min,Max,Order)
  ##
  ## 
  
  ## Sanity check
  [n_y,n_tau] = size(Min);
  [n,m] = size(Max);
  if (n!=n_y)||(m!=n_tau)
    error("Max and Min must have the same dimensions");
  endif
  
  [n,m] = size(Tau);
  if (m!=n_tau)
    error("Max and Min must have same number of columns as Tau");
  endif
  if (n>1)
    error("Tau must be a row vector");
  endif

  ##Defaults
  if nargin<10
    Order=zeros(n_y,n_tau);
  endif
  
  ## Stack up constraints for each output
  Gamma=[];
  gamma=[];
  for i_y=1:n_y
    [Gamma_i,gamma_i] = \
	ppp_output_constraint (A,B,C,D,x_0,A_u,Tau,\
			       Min(i_y,:),Max(i_y,:),Order(i_y,:),i_y);
    Gamma = [Gamma; Gamma_i];
    gamma = [gamma; gamma_i];
  endfor
  
endfunction

Added mtt/lib/control/PPP/ppp_pred.m version [a109d8be6c].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A_p,B_p] = ppp_pred (A,B,C,D,A_u,Ust0,T)

  ## usage:  [A_p,B_p] = ppp_pred (A,B,C,D,A_u,Ust0,T)
  ##
  ## PPP prediction matrices: x_pred = A_p*x + B_p*U

  ## Sanity
  [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions
  if (n_x==-1)
    error("A B C D not compatible");
  endif
  
  n_U = issquare(A_u);
  if (n_U!=n_x)
    error(sprintf("A_u must be %ix%i",n_x,n_x));
  endif
  
  [nn,mm] = size(Ust0);
  if (nn!=1)||(mm!=n_x)
    error(sprintf("Ust0 must be 1x%i",n_x));
  endif
  
      Z = zeros(n_x,n_x);
      AA = [A   B*Ust0
	    Z   A_u'];

      eAA = expm(AA*T);
      A_p = eAA(1:n_x,1:n_x);
      B_p = eAA(1:n_x,n_x+1:2*n_x);
  
endfunction

Added mtt/lib/control/PPP/ppp_qp.m version [78c9145b4b].



































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [u,U,n_active] = ppp_qp (x,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma,mu,test)

  ## usage:  [u,U] = ppp_qp (x,W,J_uu,J_ux,J_uw,Gamma,gamma)
  ## INPUTS:
  ##      x: system state    
  ##      W: Setpoint vector
  ##      J_uu,J_ux,J_uw: Cost derivatives (see ppp_lin)
  ##      Us0: value of U* at tau=0 (see ppp_lin)
  ##      Gamma, gamma: U constrained by Gamma*U <= gamma 
  ##      mu  Parameter of qp_mu
  ## Outputs:
  ##      u: control signal
  ##      U: control weight vector
  ##
  ## Predictive pole-placement of linear systems using quadratic programming
  ## Use ppp_input_constraint and ppp_output_constraint to generate Gamma and gamma
  ## Use ppp_lin to generate J_uu,J_ux,J_uw
  ## Use ppp_cost to evaluate resultant cost function

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  if nargin<9
    mu = 0
  endif

  if nargin<10
    test=0;
  endif
  

  ## Check the sizes
  n_x = length(x);

  [n_U,m_U] = size(J_uu);
  if n_U != m_U
    error("J_uu must be square");
  endif

  [n,m] = size(J_ux);
  if (n != n_U)||(m != n_x)
    error("J_ux should be %ix%i not %ix%i",n_U,n_x,n,m);
  endif


  if length(gamma)>0		# Constraints exist: do the QP algorithm
    ## QP solution for weights U	
##    [U,iterations] = qp_mu(J_uu,(J_ux*x-J_uw*W),Gamma,gamma,mu,[],[],0,test);
    [U,n_active] = qp_hild(J_uu,(J_ux*x - J_uw*W),Gamma,gamma);	# 
##    iterations = 0;

    ##U = qp(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
    ##U = pd_lcp04(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
    u = Us0*U;			# Control signal
  else			# Do the unconstrained solution
    ## Compute the open-loop gains
    n_active = 0;
    K_w = J_uu\J_uw;
    K_x = J_uu\J_ux;

    ## Closed-loop control
    U = K_w*W - K_x*x;		# Basis functions weights - U(t)
    u = Us0*U;			# Control u(t)
  endif

endfunction

Added mtt/lib/control/PPP/ppp_qp_sim.m version [6333ae0d35].


























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [T,y,u,X,Iterations] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q,R,P,\
					    Tau_u,Min_u,Max_u,Order_u, \
					    Tau_y,Min_y,Max_y,Order_y, \
					    W,x_0,Delta_ol,mu,test,movie)

  ## usage: [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, Tau_u,Min_u,Max_u,Order_u, Tau_y,Min_y,Max_y,Order_y, W,x_0,movie)
  ## Needs documentation - see ppp_ex11 for example of use.
  ## OUTPUTS
  ## T: Time vector
  ## y,u,J output, input and cost

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	
  
  if nargin<21			# No intermittent control
    Delta_ol = 0;
  endif

  if nargin<22			# Mu
    mu = 0;
  endif

  if nargin<23
    test=0
  endif
  
  if nargin<24			# No movie
    movie = 0;
  endif

test = test
  ## Check some sizes
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  [n_x0,m_x0] = size(x_0);
  if (n_x0 != n_x)||(m_x0 != 1)
    error(sprintf("Initial state x_0 must be %ix1 not %ix%i",n_x,n_x0,m_x0));
  endif
  
  ## Input constraints 
  [Gamma_u, gamma_u] = ppp_input_constraints(A_u,Tau_u,Min_u,Max_u);

  ## Output constraints
  [Gamma_y,gamma_y] = ppp_output_constraints(A,B,C,D,x_0,A_u,Tau_y,Min_y,Max_y,Order_y);

  ## Composite constraints - t=0
  Gamma = [Gamma_u; Gamma_y];
  gamma = [gamma_u; gamma_y];

  ## Design the controller
  ## disp("Designing controller");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] = ppp_lin (A,B,C,D,A_u,A_w,t,Q,R,P);

  ## Set up various time vectors
  dt = t(2)-t(1);		# Time increment

  ## Make sure Delta_ol is multiple of dt
  Delta_ol = floor(Delta_ol/dt)*dt;

  if Delta_ol>0			# Intermittent control
    T_ol = 0:dt:Delta_ol;	# Create the open-loop time vector
  else
    T_ol = [0,dt];
    Delta_ol = dt;
  endif
  t_last = t(length(t));
  T_cl = 0:Delta_ol:2*t_last-Delta_ol; # Closed-loop time vector
  T = 0:dt:2*t_last;		# Overall time vector
 
  ## Lengths thereof
  n_Tcl = length(T_cl);
  n_ol = length(T_ol);
  n_T = length(T);

  ## Expand W with constant last value or truncate
  [n_W,m_W] = size(W);

  if m_W>n_T
    W = W(:,1:n_T);
  else
    W = [W W(:,m_W)*ones(1,n_T-m_W+1)];
  endif

  ## Compute U*
  Ustar_ol = ppp_ustar(A_u,n_u,T_ol); # U* in the open-loop interval

  [n,m] = size(Ustar_ol);
  n_U = m/length(T_ol);		# Determine size of each Ustar

#   ## Discrete-time system
#   csys = ss2sys(A,B,C,D);
#   dsys = c2d(csys,dt);
#   [Ad, Bd] = sys2ss(dsys)

  x = x_0;			# Initialise state

  ## Initialise the saved variable arrays
  X = [];
  u = [];
  Iterations = [];
  du = [];
  J = [];
  tick= time;

  ## disp("Simulating ...");
  for t=T_cl			# Outer loop at Delta_ol
    printf("%g\r",t);
    ##disp(sprintf("Time %g", t));
    ## Output constraints
    [Gamma_y,gamma_y] = ppp_output_constraints  (A,B,C,D,x,A_u,Tau_y,Min_y,Max_y,Order_y);
    
    ## Composite constraints 
    Gamma = [Gamma_u; Gamma_y];
    gamma = [gamma_u; gamma_y];
    
    ## Current Setpoint value
    w = W(:,floor(t/dt)+1);
    
    ## Compute U(t) via QP optimisation
    [uu, U, iterations] = ppp_qp (x,w,J_uu,J_ux,J_uw,Us0,Gamma,gamma,mu,test); # Compute U

    ## Compute the cost (not necessary but maybe interesting)
#    [J_t] = ppp_cost (U,x,W,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww); # cost
#    J = [J J_t];

    ## OL Simulation (exact)
    [ys,us,xs] = ppp_ystar (A,B,C,D,x,A_u,U,T_ol);

    ## Save values (discarding final ones)
    X = [X xs(:,1:n_ol-1)];			# save state
    u = [u us(:,1:n_ol-1)];			# save input
    Iterations = [Iterations iterations*ones(1,n_ol-1)];

    ## Final values
    x = xs(:,n_ol);		# Final state
    ut = us(:,n_ol);		# Final control

  endfor
  
  ## Save the last values
  X = [X x];		# Save state
  u = [u ut];		# Save input
  Iterations = [Iterations iterations]; # Save iteration count

  tock = time;
  Elapsed_Time = tock-tick;
  y = C*X + D*u;		# System output


endfunction



Added mtt/lib/control/PPP/ppp_sim.m version [a4ff8b90d8].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y,y_s] = ppp_sim (system_name,x_0,u,t,par,i_s,external)

  ## mtt_sim: Simulates system  sensitivity functions. 
  ## usage:  [y,y_s] = ppp_sim (system_name,x_0,u,t,par,i_s)
  ##   system_name string containing name of the sensitivity system
  ##   x_0         initial state 
  ##   u           system input (one input per row)
  ##   t           row vector of time
  ##   par         system parameter vector
  ##   i_s         indices of sensitivity parameters 


  if nargin<7
    external = 0;
  endif
  
  ## Some sizes
  n_s = length(i_s);
  n_t = length(t);


  for i = 1:n_s

    ## Set sensitivity parameters
    par(i_s(i)) = 1.0;
    par(complement(i_s(i),i_s)) = 0;

    if external
      par_string = "";
      for i_string=1:length(par)
	par_string = sprintf("%s %s", par_string, num2str(par(i_string)));
      endfor
      data_string = system(sprintf("./%s_ode2odes.out %s | cut -f 2-%i", \
				   system_name, par_string, 1+n_s));
      Y = str2num(data_string)';
    else
      Y = eval(sprintf("%s_sim(x_0,u,t,par);", system_name));
    endif

    [n_Y,m_Y] = size(Y);
     n_y = n_Y/2;
    if i==1	
      y = Y(1:2:n_Y,:);		# Save up the output
      y_s = zeros(n_s*n_y, n_t); # Initialise for speed
    endif
 
    y_s((i-1)*n_y+1:i*n_y,:)  = Y(2:2:n_Y,:);	# Other sensitivities
    
  endfor

title("");
plot(t,y);

endfunction

Added mtt/lib/control/PPP/ppp_sm2sr.m version [b8cab9f99f].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Y,X] = ppp_sm2sr(A,B,C,D,T,u0,x0);
  ## Usage [Y,X] = ppp_sm2sr(A,B,C,D,T,u0,x0);
  ## Computes a step response
  ## A,B,C,D- state matrices
  ## T vector of time points
  ## u0 input gain vector: u = u0*unit step.

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  [Ny,Nu] = size(D);
  [Ny,Nx] = size(C);

  if nargin<6
    u0 = zeros(Nu,1);
    u0(1) = 1;
  end;

  if nargin<7
    x0 = zeros(Nx,1);
  end;

  [N,M] = size(T);
  if M>N
    T = T';
    N = M;
  end;



  one = eye(Nx);

  Y = zeros(Ny,N);
  X = zeros(Nx,N);

  dt = T(2)-T(1);		# Assumes fixed interval
  expAdt = expm(A*dt);		# Compute matrix exponential
  i = 0;
  expAt = one;

  DoingStep = max(abs(u0))>0;	# Is there a step component?
  DoingInitial = max(abs(x0))>0; # Is there an initial component?
  for t = T'
    i=i+1;
    if Nx>0
      x = zeros(Nx,1);
      if DoingStep
	x = x + ( A\(expAt-one) )*B*u0;
      endif
      if DoingInitial
	x = x + expAt*x0;
      endif
      
      expAt = expAt*expAdt;

      X(:,i) = x;
      if Ny>0
	y = C*x + D*u0;
	Y(:,i) = y;
      endif
    elseif Ny>0
      y = D*u0;
      Y(:,i) = y;
    endif
  endfor


endfunction

Added mtt/lib/control/PPP/ppp_ustar.m version [84e1f5fdcb].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function Ustar = ppp_ustar (A_u,n_u,tau,order,packed,n_zero)

  ## usage:  Us = ppp_ustar(A_u,n_u,tau,order,packed)
  ##
  ## Computes the U* matrix at time tau in terms of A_u
  ## n_u : Number of system inputs
  ## If tau is a vector, computes U* at each tau and puts into a row vector:
  ## If packed==1
  ##     Ustar = [Ustar(tau_1) Ustar(tau_2) ...]
  ## else Ustar = [Ustar(tau_1); Ustar(tau_2) ...]
  ## n_zero extra zero columns appended

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  if nargin<2
    n_u = 1;
  endif
  
  if nargin<3
    tau = 0;
  endif
  
  if nargin<4
    order = 0;
  endif
  
  if nargin<5
    packed=1;
  endif
  
  if nargin<6
    n_zero=0;
  endif
  

  [n,m] = size(A_u);		# Size of composite A_u matrix
  N = m;			# Number of U* functions per input  
  nm = n/m;

  if (nm != n_u)&&(n!=m)	# Check consistency
    error("A_u must be square or be a column of square matrices");
  endif

  u_0 = ones(N,1);

  Ustar = [];
  for t = tau;
    ustar = [];
    for i = 1:n_u
      A_i = ppp_extract(A_u,i);
      Ak = A_i^order;
      eA = expm(A_i*t);
      if (packed==1)
	ustar = [ustar; zeros(1,(i-1)*N), (Ak*eA*u_0)', \
		 zeros(1,(n_u-i)*N)];
      else
	ustar = [ustar, (Ak*eA*u_0)'];
      endif
    endfor

    if (packed==1)
      Ustar = [Ustar ustar];
    else
      Ustar = [Ustar; ustar];
    endif
  endfor

  if (n_zero>0)
    [N,M] = size(Ustar);
    Ustar = [Ustar zeros(N, n_zero)];
  endif
  
endfunction

Added mtt/lib/control/PPP/ppp_ustar2h.m version [d77ecc26ba].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ppp_ustar2h (Ustar,DT,name)

  ## usage:  ppp_Ustar2h (Ustar[,name])
  ##
  ## 

  if nargin<2
    DT = 1;
  endif
  
  if nargin<3
    name = "Ustar";
  endif

  [N,N_U] = size(Ustar);

  ## Open the file 
  filename = sprintf("%s.h", name);
  fid = fopen(filename,"w");

  ## Header
  header = sprintf("/*\n File %s generated by ppp_ustar2h on %s */\n", \
		   filename, ctime(time));

  def = sprintf("#define N_U %i\n#define N_T %i\n#define DT %g\n", \
		 N_U, N, DT);
  def = sprintf("%sdouble U[N_U]={",def);
  for j=1:N_U
    if j<N_U
      comma = ",";
    else
      comma = "";
    endif
    def = sprintf("%s0.0%s ",def, comma);
  endfor
  def = sprintf("%s};\n",def)

  fprintf(fid, "%s%sdouble %s[N_T][N_U] = {\n",header,def,name);
  for i=1:N
    fprintf(fid, "{");
    for j=1:N_U
      if j<N_U
	comma = ",";
      else
	comma = "";
      endif
      fprintf(fid, "%g%s ", Ustar(i,j),comma);
    endfor

    if i<N
      fprintf(fid, "},\n");
    else
      fprintf(fid, "}\n");
    endif
    
  endfor
  fprintf(fid, "};\n");

  fclose(fid);

endfunction

Added mtt/lib/control/PPP/ppp_y_u.m version [8a57fa7a93].




















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y_u, Us] = ppp_y_u (A,B,C,D,A_u,u_0,tau)

  ## usage:  y_u = ppp_y_u (A,B,C,D,A_u,u_0,t)
  ##
  ## Computes y_u derivative of y* wrt U
  ## Called by ppp_lin
  ## OBSOLETE

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.6  2000/12/27 16:41:05  peterg
  ## *** empty log message ***
  ##
  ## Revision 1.5  1999/05/31 01:58:01  peterg
  ## Now uses ppp_extract
  ##
  ## Revision 1.4  1999/05/12 00:10:35  peterg
  ## Modified for alternative (square) A_u
  ##
  ## Revision 1.3  1999/05/03 23:56:32  peterg
  ## Multivariable version - tested for N uncoupled systems
  ##
  ## Revision 1.2  1999/05/03 00:38:32  peterg
  ## Changed data storage:
  ## y_u saved as row vector, one row for each time, one column for
  ## each U
  ## y_x saved as row vector, one row for each time, one column for
  ## each x
  ## W* saved as row vector, one row for each time, one column for
  ## each element of W*
  ## This is consistent with paper.
  ##
  ## Revision 1.1  1999/04/29 06:02:43  peterg
  ## Initial revision
  ##
  ###############################################################



  ## Check argument dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  if (n_x==-1)
    return
  endif

  [n,m] = size(A_u);		# Size of composite A_u matrix
  N = m;			# Number of U* functions per input
  
  y_u = [];			# Initialise
  Us = [];
  
#   for input=1:n_u		# Do for each system input
#     a_u = ppp_extract(A_u,input); # Extract the relecant A_u matrix
#     for i=1:N			# Do for each input function U*_i
#       C_u = zeros(1,N); C_u(i) = 1; # Create C_u for this U*_i
#       b = B(:,input);		# B vector for this input
#       d = D(:,input);		# D vector for this input
#       [y,u] = ppp_transient (t,a_u,C_u,u_0,A,b,C,d); # Compute response for this input
#       y_u = [y_u y'];		# Save y_u (y for input u)  with one row for each t.
#       Us = [Us u'];		# Save u (input)  with one row for each t.
#     endfor
#   endfor
  i_U = 0;
  x_0 = zeros(n_x,1);		# This is for x=0
  for input=1:n_u		# Do for each system input
    a_u = ppp_extract(A_u,input); # Extract the relevant A_u matrix
    for i=1:N			# Do for each input function U*_i
      dU = zeros(N*n_u,1);
      dU(++i_U) = 1;		# Create dU/dU_i 
      [ys,us] = ppp_ystar (A,B,C,D,x_0,a_u,dU,tau); # Find ystar and ustar
      y_u = [y_u ys'];		# Save y_u (y for input u)  with one row for each t.
      Us = [Us us'];		# Save u (input)  with one row for each t.
    endfor
  endfor

endfunction




Added mtt/lib/control/PPP/ppp_ystar.m version [0c38479f43].
























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [ys,us,xs,xu,AA] = ppp_ystar (A,B,C,D,x_0,A_u,U,tau,Us0)

  ## usage:  [ys,us,xs,xu,AA] = ppp_ystar (A,B,C,D,x_0,A_u,U,tau[,Us0])
  ##
  ## Computes open-loop moving horizon variables at time tau
  ## Inputs:
  ## A,B,C,D     System matrices
  ## x_0         Initial state
  ## A_u         composite system matrix for U* generation 
  ##             one square matrix (A_ui) row for each system input
  ##             each A_ui generates U*' for ith system input.
  ## OR
  ## A_u         square system matrix for U* generation 
  ##             same square matrix for each system input
  ## U           Column vector of optimisation coefficients  
  ## tau         Row vector of times at which outputs are computed
  ## Us0         Initial value of U* (default ones(NU,1))
  ## Outputs:
  ## ys          y*, one column for each time tau 
  ## us          u*, one column for each time tau 
  ## xs          x*, one column for each time tau 
  ## xu          x_u, one column for each time tau 
  ## AA          The composite system matrix
  

  ## Copyright (C) 1999,2005 by Peter J. Gawthrop
  ## 	$Id$	

  if (size(A)>0)
    [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions
  else
    n_x = 0;
    n_y = 0;
    n_u = 0;
  endif
  
  no_system = n_x==0;

  [n,m] = size(A_u);		# Size of composite A_u matrix
  square = (n==m);		# Is A_u square?
  n_U = m;			# functions per input

  [n,m] = size(U);
  if (m != 1)
    error("U must be a column vector");
  endif
  
  if n_u>0
    if n_u!=length(U)/n_U
      error("U must be a column vector with n_u*n_U components");
    endif
  else
    n_u = length(U)/n_U;	# Deduce n_u from U if no system
  endif
  
  [n_x0,m_x0] = size(x_0);
  if n_x0!=n_x
    error(sprintf("x_0 must be a column with length %i", n_x));
  endif
  

  [n,m]=size(tau);
  if (n != 1 )
    error("tau must be a row vector of times");
  endif

  if nargin<9
    Us0 = ones(1,n_U);
  endif
  
  [n_Us0,m_Us0] = size(Us0);
  if (n_Us0>1)||(n_Us0>m_Us0)
    error(sprintf("Us0 must be a row vector, not %ix%i ",n_Us0,m_Us0));
  endif
	  
  
  if square			# Then same A_u for each input
    ## Reorganise vector U into matrix Utilde  
    Utilde = [];
    for i=1:n_u
      j = (i-1)*n_U;
      range = j+1:j+n_U;
      Utilde = [Utilde; U(range,1)'];
    endfor

    ## Composite A matrix
    if no_system
      AA = A_u;
    else
      Z = zeros(n_U,n_x);
      AA = [A   B*Utilde
	    Z   A_u];
    endif
    
    xx_0 = [x_0;Us0'];		# Composite initial condition
  else				# Different A_u on each input
    ## Reorganise vector U into matrix Utilde  
    Utilde = [];
    for i=1:n_u
      j = (i-1)*n_U;
      k = (n_u-i)*n_U;
      range = j+1:j+n_U;
      Utilde = [Utilde; zeros(1,j), U(range,1)', zeros(1,k)];
    endfor

    ## Create the full A_u matrix (AA_u) with the A_i s on the diagonal
#     AA_u = [];
#     for i = 1:n_u
#       AA_u = ppp_aug(AA_u,ppp_extract(A_u,i));
#     endfor
    AA_u = ppp_inflate(A_u);

    ## Composite A matrix
    if no_system
      AA = AA_u;
    else
      Z = zeros(n_U*n_u,n_x);
      AA = [A   B*Utilde
	    Z   AA_u];
    endif
    xx_0 = [x_0;ones(n_U*n_u,1)];	# Composite initial condition
  endif
  
  
  ## Initialise
  xs = [];			# x star
  xu = [];			# x star
  ys = [];			# y star
  us = [];			# u star
  n_xx = length(xx_0);		# Length of composite state

  ## Compute the star variables
  for t=tau
    xxt = expm(AA*t)*xx_0;	# Composite state
    xst = xxt(1:n_x);		# x star
    xut = xxt(n_x+1:n_xx);	# x star
    if length(C)>0
      yst = C*xst;		# y star
    else
      yst = [];
    endif
    
    ust = Utilde*xut;		# u star

    xs = [xs xst];		# x star
    xu = [xu xut];		# x star
    ys = [ys yst];		# y star
    us = [us ust];		# u star
  endfor

endfunction

Added mtt/lib/control/PPP/rpv.m version [c302718039].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D] = rpv
% System RPV
% This system is the remotely-piloted vehicle example from the book:
% J.M Maciejowski: Multivariable Feedback Design  Addison-Wesley, 1989
% It has 6 states, 2 inputs and 2 outputs.

% P J Gawthrop Jan 1998

A = [-0.0257  -36.6170  -18.8970  -32.0900    3.2509   -0.7626
      0.0001   -1.8997    0.9831   -0.0007   -0.1780   -0.0050
      0.0123   11.7200   -2.6316    0.0009  -31.6040   22.3960
           0         0    1.0000         0         0         0
           0         0         0         0  -30.0000         0
           0         0         0         0         0  -30.0000];

B = [0     0
     0     0
     0     0
     0     0
    30     0
     0    30];

C = [0     1     0     0     0     0
     0     0     0     1     0     0];

D = zeros(2,2);


Added mtt/lib/control/PPP/tgen.m version [37e3b79324].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [A,B,C,D] = tgen
% System TGEN from
% This system is the turbogenerator example from the book:
% J.M Maciejowski: Multivariable Feedback Design  Addison-Wesley, 1989
% It has 6 states, 2 inputs and 2 outputs.

% P J Gawthrop Jan 1998

A = [-18.4456    4.2263   -2.2830    0.2260    0.4220   -0.0951
      -4.0977   -6.0706    5.6825   -0.6966   -1.2246    0.2873
       1.4449    1.4336   -2.6477    0.6092    0.8979   -0.2300
      -0.0093    0.2302   -0.5002   -0.1764   -6.3152    0.1350
      -0.0464   -0.3489    0.7238    6.3117   -0.6886    0.3645
      -0.0602   -0.2361    0.2300    0.0915   -0.3214   -0.2087];

B = [-0.2748    3.1463
     -0.0501   -9.3737
     -0.1550    7.4296
      0.0716   -4.9176
     -0.0814  -10.2648
      0.0244   13.7943];

C = [0.5971   -0.7697    4.8850    4.8608   -9.8177   -8.8610
     3.1013    9.3422   -5.6000   -0.7490    2.9974   10.5719];

D = zeros(2,2);


Added mtt/lib/control/PPP/transient.m version [14fe0c3057].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function X = transient (t,A,x_0)

  ## usage:  L = transient (t,p,order)
  ##
  ## Computes transient response for time t with initial condition x_0

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  1999/04/27 04:46:05  peterg
  ## Initial revision
  ##
  ## Revision 1.1  1999/04/25 23:19:40  peterg
  ## Initial revision
  ##
  ###############################################################


X=[];
  for tt=t			# Create the Transient up to highest order
    x = expm(A*tt)*x_0;
    X = [X x];
  endfor

endfunction

Added mtt/lib/cr/hh/ISW.hh version [ae8d942dc5].







1
2
3
4
5
6
+
+
+
+
+
+
#ifndef ISW_HH
#define ISW_HH

// dummy file

#endif // ISW_H

Added mtt/lib/cr/hh/SS.hh version [24fd0512ed].







1
2
3
4
5
6
+
+
+
+
+
+
#ifndef SS_HH
#define SS_HH

// dummy file

#endif // SS_H

Added mtt/lib/cr/hh/causality.hh version [fa67fbd353].









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
#ifndef CAUSALITY_HH
#define CAUSALITY_HH

enum causality { effort, flow, state };

typedef enum causality causality_t;

#endif

Added mtt/lib/cr/hh/components.hh version [2fc3af9d6e].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef COMPONENTS_HH
#define COMPONENTS_HH

// $ cd $(echo $MTT_COMPONENTS/simple | sed 's/\.://')
// $ ls *_eqn.m | gawk -F_ '{printf ("%s, ", $1)}'
enum component {
  AE, AF, C, EBTF, EMTF, ES, FMR, FP, GY, I, PS, RST, RS, R, SS, TF,
  ae, af, c, ebtf, emtf, es, fmr, fp, gy, i, ps, rst, rs, r, ss, tf
};

typedef enum component component_t;
  

#endif

Added mtt/lib/cr/hh/constants.hh version [65d242bd40].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef CONSTANTS_HH
#define CONSTANTS_HH

const double	pi	= 3.14159264;
const double	pi2	= pi * pi;
const double	pi4	= pi2 * pi2;

// Reynolds number
const double	ReL	= 2300.0;	// transition from laminar flow
const double	ReT	= 4000.0;	// transition to turbulent flow

#endif // CONSTANTS

Added mtt/lib/cr/hh/fade.hh version [ea57877552].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef FADE_HH
#define FADE_HH

#include <cmath>		// tanh

#include "constants.hh"		// pi

inline double
fade(const double x,
     const double x1,
     const double x2,
     const double y1,
     const double y2)
{
  /* fades two functions together smoothly over the range x1 to x2
   * function does not check that x2 > x1
   */
  double theta;
  theta = (x - x1) / (x2 - x1);		// map (linear)     {x1  , x2 } => {0   , +1 }
  theta = (theta - 0.5) * 2.0 * pi;	// map (linear)     {0   , +1 } => {-Pi , +Pi}
  theta = tanh(theta);			// map (non-linear) {-Pi , +Pi} => {-1  , +1 }
  theta = (theta + 1.0) / 2.0;		// map (linear)     {-1  , +1 } => {0   , +1 }

  return (theta * y1 + (1.0 - theta) * y2);
}

inline double
chkfade(const double x,
	const double x1,
	const double x2,
	const double y1,
	const double y2)
{
  double X1 = x1, X2 = x2;
  if (x1 > x2) {
    std::cerr << "* Warning: chkfade; x2 > x1, swapping" << std::endl;
    X1 = x2;
    X2 = x1;
  }
  return ((x <= X1) ? y1 : (x > X2) ? y2 : fade(x, X1, X2, y1, y2));
}

#endif // FADE_HH

Added mtt/lib/cr/hh/frictionfactor.hh version [45faf85d37].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef FRICTIONFACTOR_HH
#define FRICTIONFACTOR_HH

#include <iostream>
#include <cmath>

#include "constants.hh"		// ReL, ReT
#include "fade.hh"

inline double
frictionfactor(const double Re, const double r) {
  if (0.0 == Re) {
    return 0.0;
  }
  else if (ReL >= Re) {		// laminar flow
    return 16.0 / Re;		// using k = 4.f.(l/d)
  } else if (ReT <= Re) {	// turbulent flow
    /* S.E.Haaland
     * Simple and explicit formulas for the friction factor in turbulent pipe flow
     * Journal of Fluids Engineering, 105 (1983)
     */
    double A = 6.91 / Re;
    double B = pow((r / 3.71), 1.11);
    double f = pow(-3.6 * log10(A + B), -2);
    return f;
  } else {			// transition region 
    double ffL = frictionfactor(ReL, r);
    double ffT = frictionfactor(ReT, r);
    return fade(Re, ReL, ReT, ffL, ffT);
  }
}

#endif // FRICTIONFACTOR_HH

Added mtt/lib/cr/hh/kinematicviscosity.hh version [ebebe8b69e].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef KINEMATICVISCOSITY_HH
#define KINEMATICVISCOSITY_HH

#include <cmath>		// pow
#include <string>

inline double
kerosenekinematicviscosity(const double T)
  /*
   * B.S.Massey
   * Mechanics of fluids
   * ISBN: 0 412 34280 4
   * log-log plot of kinematic viscosity versus temperature is linear for kerosene
   * L(n) = log10(n)
   *
   * T =   0 deg C : nu = 4.0 mm2/s
   * T = 100 deg C : nu = 0.9 mm2/s
   *
   * deg C => K, mm2/s => m2/s
   *
   * T1 = 273.15 : nu1 = 4.0e-6 m2/s
   * T2 = 373.15 : nu2 = 0.9e-6 m2/s
   *
   * L(nu) = m L(T) + c
   *
   *    m = (L(nu2) - L(nu1)) / (L(T2) - L(T1))
   *      = L(nu2/nu1) / L(T2/T1)
   *      = L(0.9/4.0) / L(373.15/273.15)
   *      = -4.781567507
   *
   *    c = L(nu1) - m * L(T1)
   *      = L(4.0e-6) - m * L(273.15)
   *      = 6.251876827 
   *
   * nu {m2/s} = 10^(m * L(T {Kelvin}) + c)
   *
   *    = 10^(m * L(T) + c)
   *    = 10^c * (10^L(T))^m
   *    = 10^c * T^m
   *
   * 10^c = 1.78598097e6
   * 
   * nu = 1.78598097e6 * T^(-4.781567507)
   */
{
  return 1.79e6 * pow(T, -4.78);
}

inline double
kinematicviscosity(const std::string fluid,
		   const double T)
{
  if ("kerosene" == fluid) {
    return kerosenekinematicviscosity(T);
  } else {
    std::cerr << __FILE__ << ": fluid \"" << fluid << "\" unknown" << std::endl;
    exit(-1);
  }
}

#endif // KINEMATICVISCOSITY_HH

Added mtt/lib/cr/hh/lin.hh version [1652f288ca].


































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef LIN_HH
#define LIN_HH

#include <iostream>

#include "causality.hh"
#include "components.hh"
// translated from lin.cr

// one 2-port, R/C/I; two 2-port, TF/GY
inline double
lin(const component_t	type,
    // parameters
    const causality_t	gain_causality,
    const double	gain,
    // output
    const causality_t	out_causality,
    const int		out_port,
    // input
    const double	input,
    const causality_t	in_causality,
    const int		in_port)
{
  if (out_port == in_port) {			  // R/C/I
    if (gain_causality == in_causality) {
      return input * gain;
    } else {
      return input / gain;
    }
  } else {					  // GY/TF
    if (out_causality == in_causality) {	// gyrator
      if ((out_port == 1 && out_causality != gain_causality)
	  ||(out_port == 2 && out_causality == gain_causality)) {
	return input * gain;
      } else {
	return input / gain;
      }
    } else {				// transformer
      if (out_causality == gain_causality) {
	return input * gain;
      } else {
	return input / gain;
      }
    }
  }
}

// two 2-port, AE/AF
inline double
lin(const component_t	type,
    // parameters
    const double	gain,
    // output
    const causality_t	out_causality,
    const int		out_port,
    // input
    const double	input,
    const causality_t	in_causality,
    const int		in_port)
{
  return
    (out_port == 1) ? input * gain :
    input / gain;
}




// three 2-port, FMR
inline double
lin(const component_t	type,
    // parameters
    const causality_t	gain_causality,
    const double	gain,
    // output
    const causality_t	out_causality,
    const int		out_port,
    // input
    const double	input,
    const causality_t	in_causality,
    const int		in_port,
    const double	modulation,
    const causality_t	mod_causality,
    const int		mod_port)
{
  if (mod_causality == flow) {		// uni-causal
    if (out_port == 2) {
      return 0;
    } else {
      double k = 1.0;
      if (gain_causality == in_causality) {
	k *= gain;
      } else {
	k /= gain;
      }
      if (in_causality == effort) {
	k *= modulation;
      } else {
	k /= modulation;
      }
      return input * k;
    }
  } else {				// bi-causal
    if ((in_causality == effort)
	&&(mod_causality == flow)
	&&(gain_causality == effort)
	&&(in_port == 1)
	&&(mod_port == 1)) {
      return (input / modulation) / gain;
    } else {

	// three 2-port, EMTF
	
	if ((out_causality == gain_causality && out_port == 2)
	    ||(out_causality != gain_causality && out_port == 1)) {
	  return input * gain * modulation;
	} else if((out_causality != gain_causality && out_port == 2)
		  ||(out_causality == gain_causality && out_port == 1)) {
	  return input / (gain * modulation);
	} else {
	  std::cerr << "* Error: __FILE__ does not cover this case" << std::endl;
	  exit(-1);
	}
    } // EMTF
  } // bi-causal
}


#endif // LIN_HH

Added mtt/lib/cr/hh/pressuredrop.hh version [edb487c3ad].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef PRESSUREDROP_HH
#define PRESSUREDROP_HH

#include <cmath>		// fabs, pow
#include <string>

#include "causality.hh"
#include "constants.hh"
#include "frictionfactor.hh"
#include "kinematicviscosity.hh"
#include "sign.hh"

inline double
pressuredrop(const std::string fluid,
	     const double d,
	     const double l,
	     const double r,
	     const double rho,
	     const double T,
	     const double Q)
{
  double nu = kinematicviscosity(fluid, T);
  double Re = 4.0 * fabs(Q) / (pi * d * nu);
  double f = frictionfactor(Re, r);
  double k = 4.0 * f * l / d;
  double dP = k * 8.0 * rho * pow(Q, 2) / (pi2 * pow(d, 4));
  return (dP * sign(Q));
}

inline double
pressuredrop(const std::string fluid,
	     const double d,
	     const double l,
	     const double r,
	     const double rho,
	     const double T,
	     const causality_t effort_causality, const int port,
	     const double Q, const causality_t flow_causality, const int port_in)
{
  
  /* assert(effort == causality);
   * assert(flow == causality_in);
   * assert(1 == port_in);
   * assert(1 == port);
   */
  return pressuredrop(fluid, d, l, r, rho, T, Q);
}

#endif // PRESSUREDROP_HH

Added mtt/lib/cr/hh/sign.hh version [593009ad4f].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef SIGN_HH
#define SIGN_HH

template <class T>
inline int
sign(T x)
{
  return ((x > 0) ? +1 :
	  (x < 0) ? -1 :
	  0);
}

#endif // SIGN_HH

Added mtt/lib/cr/hh/squarelaw.hh version [2920b23040].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef SQUARELAW_HH
#define SQUARELAW_HH

#include <cmath
#include "sign.hh"

#include "causality.hh"

inline double squarelaw(const double gain,
			const causality_t causality, const int port,
			const double input, const causality_t in_causality, const int in_port)
  /*
   * implements P = R Q^2
   * direction of flow is retained
   */
{
  if (causality == effort) {
    return pow(input, 2) * gain * sign(input * gain);
  } else {
    return sqrt(fabs(input / gain)) * sign(input / gain);
  }
}

#endif // SQUARELAE_HH

Added mtt/lib/cr/hh/staticpressure.hh version [a1d4591eb9].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifndef STATICPRESSURE_HH
#define STATICPRESSURE_HH

#include <cmath>		// log, pow

#include "causality.hh"
#include "constants.hh"

inline double
staticpressure(const double beta,
	       const double C_d,
	       const double d,
	       const double P_ref,
	       const double rho,
	       const causality_t causality, const int port,
	       const double Q1, const causality_t causality1, const int port1,
	       const double Q2, const causality_t causality2, const int port2)
{
  static double P;
  if (0.0 != Q1 && 0.0 != Q2) {
    double num = pi2 * pow(d, 4) * log(Q1 / Q2);
    double den = 8.0 * beta * rho * Q1 * (Q2 - Q1 + C_d * (Q1 + Q2) / 2.0);
    P = P_ref + log(num / den)/beta;
  }
    return P;
}

#endif // STATICPRESSUE_HH

Added mtt/lib/cr/perl/Density.pm version [5a84b70eb1].





























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::Density;

#-------------------------------------------------------------------------------
#		linear constitutive relationship with cosine modulation
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&Density);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub Density_r(@);		# R

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub Density (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^R|r$/)	{ $retval = Density_r	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# R
#-------------------------------------------------------------------------------
sub Density_r (@) {

    my @args = @_;
    my $retval = '';
    
    if ($#args == 15-1)
    {
	if ($args[2] eq 'ideal_gas')
	{
	    my ($component,
		$required_output,
		$law,
		$R,
		$out_causality,
		$out_port,
		$Pressure,
		$P_causality,
		$P_port,
		$Temperature,
		$T_causality,
		$T_port,
		$Nothing,
		$N_causality,
		$N_port) = @args;
	    
	    if (($P_causality eq 'effort') and
		($P_port == 1) and
		($T_causality eq 'effort') and
		($T_port == 2) and
		($N_causality eq 'flow') and
		($N_port == 3))
	    {
		if ($required_output eq 'density')
		{
		    return "(($Pressure)/(($R)*($Temperature)))";
		}
		elsif ($required_output eq 'specific_volume')
		{
		    return "(($R)*($Temperature)/($Pressure))";
		}
	    }
	}
	elsif ($args[2] eq 'incompressible')
	{
	    my ($component,
		$required_output,
		$law,
		$rho,
		$out_causality,
		$out_port,
		$Pressure,
		$P_causality,
		$P_port,
		$Temperature,
		$T_causality,
		$T_port,
		$Nothing,
		$N_causality,
		$N_port) = @args;
	    
	    if (($P_causality eq 'effort') and
		($P_port == 1) and
		($T_causality eq 'effort') and
		($T_port == 2) and
		($N_causality eq 'flow') and
		($N_port == 3))
	    {
		if ($required_output eq 'density')
		{
		    return "($rho)";
		}
		elsif ($required_output eq 'specific_volume')
		{
		    return "(1/($rho))";
		}
	    }
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Added mtt/lib/cr/perl/Poly.pm version [c84d6eb22f].



























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::Poly;

#-------------------------------------------------------------------------------
#		Polytropic constitutive relationship 
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&Poly);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub Poly_any(@);		# any component

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub Poly (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    $retval = Poly_any	(@args);
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# any component
#-------------------------------------------------------------------------------
sub Poly_any (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 16-1)
    {
	my ($component,
	    $alpha,
	    $out_causality,
	    $out_port,
	    $P1,
	    $in1_causality,
	    $in1_port,
	    $P2,
	    $in2_causality,
	    $in2_port,
	    $T1,
	    $in3_causality,
	    $in3_port,
	    $Nothing,
	    $in4_causality,
	    $in4_port) = @args;

	if (($in1_port == 1) and
	    ($in1_causality eq 'effort') and
	    ($in2_port == 2) and
	    ($in2_causality eq 'effort') and
	    ($in3_port == 3) and
	    ($in3_causality eq 'effort') and
	    ($in4_port == 4) and
	    ($in4_causality eq 'flow'))
	{
	    if ($out_port != 4)
	    {
		return "(0)";
	    }
	    elsif ($out_causality eq 'effort')
	    {
		# return temperature T2
		$retval = "($T1)*pow((($P2)/($P1)),($alpha))";
	    }
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Added mtt/lib/cr/perl/apply_cr.pl version [41a7e19374].

































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/perl -w
#
#     apply_cr.pl - apply specified CRs to text on standard input
#     Copyright (C) 2004  Geraint Paul Bevan
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#		--------------------------
#		Model Transformation Tools
#		--------------------------
#
#
#-------------------------------------------------------------------------------

use strict;
use Getopt::Long;

my $cr_name='';
#-------------------------------------------------------------------------------
# arguments and options
#-------------------------------------------------------------------------------
my $crlist	= '';
my $debug	= 0;
my $help	= 0;

GetOptions ('debug'	=> \$debug,
	    'help'	=> \$help);

#-------------------------------------------------------------------------------
# globals
#-------------------------------------------------------------------------------

my @expressions;
my @prefixes;

my $expression;
my $i = 0;

#-------------------------------------------------------------------------------
# subroutine declarations
#-------------------------------------------------------------------------------
sub substitute_subexpressions();
sub process_expression();
sub display_subexpressions();
sub reassemble_expression();
sub usage();

#-------------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------------

if ($help) {
    usage();
    exit 1;
}

while (<STDIN>) {
    $expression = $_;
    print STDERR "Start Expression -> $expression\n" if $debug;

    $i = 0;
    @expressions = ();
    @prefixes = ();

    substitute_subexpressions();
    display_subexpressions () if ($debug);
    
    for ($i = 0; $i <= $#expressions; $i++) {
	process_expression ();
    }
    
    display_subexpressions () if ($debug);
    reassemble_expression ();
    print STDOUT "$expression";
}

#-------------------------------------------------------------------------------
# subroutines
#-------------------------------------------------------------------------------
sub substitute_subexpressions() {
    
    while ($expression =~ /\(.*\)/) {
	$_ = $expression;
	# get a matched pair of brackets
	s/ (.*) ( \({1} [^\(\)]* \){1} ) (.*) /$1 : $2 : $3/x;
	
	my $extracted;
	my $remainder;
	my $skipped;
	($skipped, $extracted, $remainder) = split (/ : /);
	
	$expressions[$i] = $extracted if $extracted;
	
	$_ = $skipped;
	s/(\s)//g;			# strip whitespace
	s/ (.*?) (\w*)$ /$2/x;	# get function name (if any)
	$prefixes[$i] = $_;
	$skipped =~ s/(.*)$prefixes[$i]$/$1/;
	
	$expression = "$skipped\{$i\}$remainder";
	
	$i++;
    }
    $expressions[$i] = $expression;
#    $prefixes[$i] = "";
}
#-------------------------------------------------------------------------------
sub process_expression() {

    my $cr = '';
    foreach my $cr_name (@ARGV) {	
	if ($prefixes[$i]) {
	    if ($prefixes[$i] eq $cr_name) {
		$cr = $cr_name;
	    }
	}
    }
    if ($cr eq '') {
	return;
    }

    # call cr(arg1,arg2,...) User-defined CR in the model directory
    if (-e "$cr.pm") {
	my $expr = $expressions[$i];
	eval "require $cr";
	$cr->import (@_[1 .. $#_]);    
	no strict 'refs';		# allow symbolic references
	my $substitution = &$cr ($expr);
	use strict 'refs';
	if ($substitution) {
	    $prefixes[$i] = "";
	    $expressions[$i] = "$substitution";
	}
    }
    # call cr(arg1,arg2,...) Standard CR in the mtt namespace
    if (-e "mtt/$cr.pm") {
	my $expr = $expressions[$i];
	my $mttcr = "mtt::$cr";
	eval "require 'mtt/$cr.pm'";
	$mttcr->import (@_[1 .. $#_]);
	no strict 'refs';		# allow symbolic references
	my $substitution = &$cr ($expr);
	use strict 'refs';
	if ($substitution) {
	    $prefixes[$i] = "";
	    $expressions[$i] = "$substitution";
	}
    }
}
#-------------------------------------------------------------------------------
sub display_subexpressions() {

    for ($i = 0; $i <= $#expressions; $i++) {
	my $prefix = " ";
	$prefix = $prefixes[$i] if ($prefixes[$i]); 
	print STDERR "$i\t($prefix)\t$expressions[$i]\n\n";
    }    
}
#-------------------------------------------------------------------------------
sub reassemble_expression () {

    $expression = $expressions[$#expressions];

    for ($i = $#expressions; $i >= 0; $i--) {
	print STDERR "{$i}: $expressions[$i]\n" if $debug;
	$expression =~ s/\{$i\}/$prefixes[$i]$expressions[$i]/g;
    }
    print STDERR "Final expression -> $expression\n" if $debug;
}
#-------------------------------------------------------------------------------
sub usage() {
    
    print STDOUT
	"\nUsage: $0 [options] crname1 crname2 ..\n" .
	"\n" .
	"\toptions:\n" .
	"\t--debug\n" .
	"\t--help\n" .
	"\n";
}

Added mtt/lib/cr/perl/lcos.pm version [658fa3455b].

























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::lcos;

#-------------------------------------------------------------------------------
#		linear constitutive relationship with cosine modulation
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&lcos);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub lcos_emtf(@);		# EMTF

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub lcos (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^EMTF|emtf$/)	{ $retval = lcos_emtf	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# EMTF
#-------------------------------------------------------------------------------
sub lcos_emtf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 11-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_port == 3) and
	     ($out_causality eq $in_causality))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*($gain)*(cos($mod_input)))";
	}
	elsif ((($mod_port == 3) and
		($out_causality eq $in_causality))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/(($gain)*(cos($mod_input))))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Added mtt/lib/cr/perl/lin.pm version [961e5e7d01].

























































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::lin;

#-------------------------------------------------------------------------------
#		Default linear constitutive relationship
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&lin);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub lin_amp (@);		# AE AF
sub lin_cir (@);		# C I R
sub lin_emtf(@);		# EMTF
sub lin_fmr (@);		# FMR
sub lin_gy  (@);		# GY
sub lin_tf  (@);		# TF

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub lin (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^AE|ae$/)	{ $retval = lin_amp	(@args); }
    if (/^AF|af$/)	{ $retval = lin_amp	(@args); }
    if (/^C|c$/)	{ $retval = lin_cir	(@args); }
    if (/^EMTF|emtf$/)	{ $retval = lin_emtf	(@args); }
    if (/^FMR|fmr$/)	{ $retval = lin_fmr	(@args); }
    if (/^GY|gy$/)	{ $retval = lin_gy	(@args); }
    if (/^I|i$/)	{ $retval = lin_cir	(@args); }
    if (/^R|r$/)	{ $retval = lin_cir	(@args); }
    if (/^TF|tf$/)	{ $retval = lin_tf	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# AE and AF
#-------------------------------------------------------------------------------
sub lin_amp (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1) {

	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;

	if (($out_port == 2) and
	    ($in_port  == 1))
	{			# uni-causal
	    $retval = "(($input)*($gain))";
	}

	elsif (($out_port == 1) and
	       ($in_port  == 2))
	{			# bi-causal
	    $retval = "(($input)/($gain))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# C, I and R
#-------------------------------------------------------------------------------
sub lin_cir (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;
	
	if (
	    ($out_port == 1)
	    and
	    ($in_port  == 1)
	    )
	{			# single port	    
	    if ($in_causality eq $gain_causality)
	    {
		$retval = "(($input)*($gain))";
	    }	    
	    elsif ($in_causality ne $gain_causality)
	    {
		$retval = "(($input)/($gain))";
	    }
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# EMTF
#-------------------------------------------------------------------------------
sub lin_emtf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 10-1)
    {				# modulation only
	my ($component,
	    $gain_causality,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_causality eq 'effort') and
	     ($mod_port == 3))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*($mod_input))";
	}
	elsif ((($mod_causality eq 'effort') and
		($mod_port == 3))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/($mod_input))";
	}
    }
    elsif ($#args == 11-1)
    {				# modulation and gain
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_causality eq 'effort') and
	     ($mod_port == 3))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*(($gain)*($mod_input)))";
	}
	elsif ((($mod_causality eq 'effort') and
		($mod_port == 3))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/(($gain)*($mod_input)))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}
#-------------------------------------------------------------------------------
# FMR
#-------------------------------------------------------------------------------
sub lin_fmr (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 7-1)
    {				# uni-causal
	# flow modulation multiplies effort on port 1 (or divides flow)
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $input,
	    $in_causality,
	    $mod_input) = @args;

	if (($gain_causality eq $in_causality) and
	    ($out_causality eq 'flow'))
	{
	    $retval = "(($input)*($gain)*($mod_input))";
	}
	elsif (($gain_causality eq $in_causality) and
	       ($out_causality eq 'effort'))
	{
	    $retval = "(($input)*($gain)/($mod_input))";
	}
	elsif (($gain_causality ne $in_causality) and
	       ($out_causality eq 'flow'))
	{
	    $retval = "(($input)*($mod_input)/($gain))";
	}
	elsif (($gain_causality ne $in_causality) and
	       ($out_causality eq 'effort'))
	{
	    $retval = "(($input)/(($gain)*($mod_input)))";
	}
    }
    elsif ($#args == 11-1)
    {				# bi-causal
	# deduces the flow on port 2
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $e_input,
	    $e_causality,
	    $e_port,
	    $f_input,
	    $f_causality,
	    $f_port) = @args;

	if (($gain_causality eq 'effort') and
	    ($out_causality eq 'flow') and
	    ($out_port == 2) and
	    ($e_causality eq 'effort') and
	    ($e_port == 1) and
	    ($f_causality eq 'flow') and
	    ($f_port == 1))
	{
	    $retval = "((($f_input)/($e_input))/($gain))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# GY
#-------------------------------------------------------------------------------
sub lin_gy (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;

	if (($out_causality ne $in_causality) and
	    ($out_port != $in_port)
	    and
	    (($out_causality ne $gain_causality) and
	     ($out_port == 2))
	    or
	    (($out_causality ne $gain_causality) and
	     ($out_port == 1)))
	{
	    $retval = "(($input)/($gain))";
	}

	elsif (($out_causality ne $in_causality) and
	       ($out_port != $in_port)
	       and
	       (($out_causality eq $gain_causality) and
		($out_port == 2))
	       or
	       (($out_causality eq $gain_causality) and
		($out_port == 1)))
	{
	    $retval = "(($input)*($gain))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# TF
#-------------------------------------------------------------------------------
sub lin_tf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;

	if (($out_causality eq $in_causality) and
	    ($out_port ne $in_port)
	    and
	    (($out_causality eq $gain_causality) and
	     ($out_port == 2))
	    or
	    (($out_causality ne $gain_causality) and
	     ($out_port == 1)))
	{
	    $retval = "(($input)*($gain))";
	}
	
	elsif (($out_causality eq $in_causality) and
	       ($out_port ne $in_port)
	       and
	       (($out_causality ne $gain_causality) and
		($out_port == 2))
	       or
	       (($out_causality eq $gain_causality) and
		($out_port == 1)))
	{
	    $retval = "(($input)/($gain))";
	}
    }

    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}
#-------------------------------------------------------------------------------
1;				# return true

Added mtt/lib/cr/perl/lsin.pm version [965bba1c0f].

























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::lsin;

#-------------------------------------------------------------------------------
#		linear constitutive relationship with sine modulation
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&lsin);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub lsin_emtf(@);		# EMTF

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub lsin (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^EMTF|emtf$/)	{ $retval = lsin_emtf	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# EMTF
#-------------------------------------------------------------------------------
sub lsin_emtf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 11-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_port == 3) and
	     ($out_causality eq $in_causality))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*($gain)*(sin($mod_input)))";
	}
	elsif ((($mod_port == 3) and
		($out_causality eq $in_causality))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/(($gain)*(sin($mod_input))))";
	}
    }

    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Added mtt/lib/cr/r/CT2.cr version [19581da283].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CT2    Constitutive Relationship for a two port thermo C
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.
%DESCRIPTION Parameter 4: t_0 -- the temperature at which internal
%DESCRIPTION energy is zero.

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 20:45:21  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR CT2;
Port 1 - Thermal
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,1,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,2,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = (gamma-1)*(InternalEnergy+c_v*m*t_0)/Volume;

Added mtt/lib/cr/r/MA.cr version [2731f4363e].

























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY MA: Mass-action kinetics for Re
%DESCRIPTION Parameter 1: kappa

OPERATOR MA;

%%% Two port version (standard)
FOR ALL n_out, A_f, A_r, kappa
LET MA(R, flow,kappa,flow,n_out,	
   A_f,effort,1,	
   A_r,effort,2) = kappa*(exp(A_f/RT) - exp(A_r/RT));


%%% Four port version (stoichiometric) with integral causality
%% Flows on ports 1 & 2 = flow on port 3.
FOR ALL A_f, A_r, v_1, v_2,kappa
LET MA(R, flow,kappa,flow,1,	
   A_f,effort,1,	
   A_r,effort,2,
   v_1,flow,3,
   v_2,effort,4) = v_1;

FOR ALL A_f, A_r, v_1, v_2,kappa
LET MA(R, flow,kappa,flow,2,	
   A_f,effort,1,	
   A_r,effort,2,
   v_1,flow,3,
   v_2,effort,4) = v_1;

%% Flow on port 4 is induced flow
FOR ALL A_f, A_r, v_1, v_2,kappa
LET MA(R, flow,kappa,flow,4,	
   A_f,effort,1,	
   A_r,effort,2,
   v_1,flow,3,
   v_2,effort,4) = kappa*(exp(A_f/RT) - exp(A_r/RT));

%%% Four port version (stoichiometric) with flow imposed on port 1
%% Flow on port 2 = flow on port 1
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,2,	
   v_1,flow,1,	
   A_2,effort,2,
   v_3,flow,3,
   A_4,effort,4) = v_1;

%% Flow on port 4 = flow on port 1
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,4,	
   v_1,flow,1,	
   A_2,effort,2,
   v_3,flow,3,
   A_4,effort,4) = v_1;

%% Effort on port 1
FOR ALL A_1,A_2,A_3,A_4,v_1,v_2,v_3,v_4,kappa
LET MA(R,flow,kappa,effort,1,
   v_1,flow,1,	
   A_2,effort,2,
   v_3,flow,3,
   A_4,effort,4) = RT*log( (v_1/kappa) + exp(A_2/RT) );


%%% Four port version (stoichiometric) with flow imposed on port 2

%% Flow on port 1 = flow on port 2
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,1,	
   A_1,effort,1,	
   v_2,flow,2,
   v_3,flow,3,
   A_4,effort,4) = v_2;

%% Flow on port 4 = flow on port 2
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,4,	
   A_1,effort,1,	
   v_2,flow,2,
   v_3,flow,3,
   A_4,effort,4) = v_2;

%% Effort on port 2
FOR ALL A_1,A_2,A_3,A_4,v_1,v_2,v_3,v_4,kappa
LET MA(R,flow,kappa,effort,2,
   A_1,effort,1,	
   v_2,flow,2,
   v_3,flow,3,
   A_4,effort,4) = RT*log( (v_2/kappa) + exp(A_1/RT) );

%%% Five port version (stoichiometric) with integral causality
%% Flow on port 1  = flow on port 3.
FOR ALL A_f, A_r, v_f, v_r, v, kappa
LET MA(R, flow,kappa,flow,1,	
   A_f,effort,1,	
   A_r,effort,2,
   v_f,flow,3,
   v_r,flow,4,
   v,effort,5) = v_f;

%% Flow on port 2  = flow on port 4.
FOR ALL A_f, A_r, v_f, v_r, v, kappa
LET MA(R, flow,kappa,flow,2,	
   A_f,effort,1,	
   A_r,effort,2,
   v_f,flow,3,
   v_r,flow,4,
   v,effort,5) = v_r;

%% Flow on port 5 is induced flow
FOR ALL A_f, A_r, v_f, v_r, v, kappa
LET MA(R, flow,kappa,flow,5,	
   A_f,effort,1,	
   A_r,effort,2,
   v_f,flow,3,
   v_r,flow,4,
   v,effort,5) = kappa*(exp(A_f/RT) - exp(A_r/RT));


%% AE version
FOR ALL mu
LET MA(AE, effort,2, mu, effort,1) = exp(mu/RT);

Added mtt/lib/cr/r/SS.cr version [0b96d2255a].




1
2
3
+
+
+
%% A dummy constitutive relationship file for SS 

END;;

Added mtt/lib/cr/r/StefanBoltzmann.cr version [49afc9586a].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY StefanBoltzmann: Stefan-Boltzmann radiation law.	
%DESCRIPTION Parameter 1: Stefan-Boltzmann constant
%DESCRIPTION Parameter 2: Area of radiating surface



OPERATOR StefanBoltzmann;


FOR ALL sigma,Area,input
LET StefanBoltzmann(sigma,Area,flow, 1, 
	input, effort, 1)
	 = sigma*area*input^4;


Added mtt/lib/cr/r/cm.cr version [2b06c8ed91].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY cm: relation for 2-port CM component
%DESCRIPTION Parameter 1 capacitance at separation x_0
%DESCRIPTION Parameter 2 x_0
%DESCRIPTION parameter 3 moving-plate mass

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:18:38  peterg
% %% put under RCS
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR cm;
%Linear electrical bit
FOR ALL comp,c_0,x_0,elec_state,mech_state LET
cm(comp,c_0,x_0,effort,1,
	elec_state,state,1,
	mech_state,state,2
	)
	= elec_state/(c_0*x_0/mech_state);

%Nonlinear mechanical bit
FOR ALL comp,c_0,x_0,elec_state,mech_state LET
cm(comp,c_0,x_0,effort,2,
	elec_state,state,1,
	mech_state,state,2
	)
	= -(c_0*x_0)*((elec_state/mech_state)^2)/2; 

END;;

Added mtt/lib/cr/r/cp.cr version [40c7eabbcf].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY cp    Chemical potential constitutive relationship

% This formula gives the Gibb's free energy for a reaction component
% with given concentration.
% k_e is the corresponding equilibrium constant.

% C version integral causality
FOR ALL  concentration, k_e, RT
LET cp(C,k_e,RT, effort, 1, 
        concentration, state, 1)
         = RT*log(k_e*concentration);

% C version derivative causality
FOR ALL  potential, k_e, RT
LET cp(C,k_e,RT, state, 1, 
        potential, effort, 1)
         = exp(potential/RT)/k_e;

%AE version
FOR ALL  concentration, RT
LET cp(AE,RT,effort,2,concentration,effort,1) 
        = RT*log(concentration);

%AE version with k_e
FOR ALL  concentration, k_e, RT
LET cp(AE,k_e,RT,effort,2,concentration,effort,1) 
        = RT*log(k_e*concentration);

Added mtt/lib/cr/r/cr.cr version [40890d353a].


























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY cr generic CR
%DESCRIPTION Argument is an algebraic expression with no embeddedwhite space
%DESCRIPTION Only available for one ports just now
%DESCRIPTION effort (or integrated effort) variable must be called mtt_e
%DESCRIPTION flow (or integrated flow) variable must be called mtt_f
%DESCRIPTION For example:
%DESCRIPTION             mtt_e=k*mtt_f
%DESCRIPTION             mtt_f=mtt_e/r

% $Log$
% Revision 1.5  2003/01/09 09:57:42  gawthrop
% Added dummy first argument (comp_type) to cr
%
% Revision 1.4  2000/12/28 09:18:38  peterg
% put under RCS
%
% Revision 1.3  2000/10/05 10:13:00  peterg
% New eqn2ass function.
% Started extension to multiports
%
% Revision 1.2  2000/10/03 18:35:04  peterg
% Removed comment bug
%
% Revision 1.1  2000/10/03 18:34:00  peterg
% Initial revision
%

%Copyright (C) 2000 by Peter J. Gawthrop


% Function to convert equation to assignment
OPERATOR eqn2ass;
FOR ALL comp_type, eqn,outlist,inputs 
LET eqn2ass(eqn,outlist,inputs) =
BEGIN
    ass := {}; mtt_ports := 0;
    solutions := solve(eqn,outlist);
    FOR EACH solution IN solutions DO
    BEGIN
       mtt_ports := mtt_ports + 1;
       rh := RHS(solution);
       FOR EACH input IN inputs DO
         rh := sub(input,rh);
       ass := APPEND(ass,{rh});
    END;
    IF mtt_ports EQ 1 THEN
      RETURN FIRST(ass) 
    ELSE
      RETURN ass; 

    %return sub(input,rhs(first(solve(eqn,outlist))));
    % Needs multiplicity warning
END;


OPERATOR cr;

% Version for one-port components

% We need four versions so that state does not need to be explicitly
% mentioned.
% At the moment, assume only one solution (in fact the first is
% chosen)

%%%% This is the Equation version
% Flow input
FOR ALL comp_type, mtt_cr, input, out_cause
LET cr(comp_type,mtt_cr,out_cause, 1, input, flow, 1) 
      = eqn2ass(mtt_cr,mtt_e,{mtt_f=input});

% Effort input
FOR ALL comp_type, mtt_cr, input, out_cause
LET cr(comp_type,mtt_cr,out_cause, 1, input, effort, 1)
    = eqn2ass(mtt_cr,mtt_f,{mtt_e=input});

% Effort output
FOR ALL comp_type, mtt_cr, input, in_cause
LET cr(comp_type,mtt_cr,effort, 1, input, in_cause, 1) 
    = eqn2ass(mtt_cr,mtt_e,{mtt_f=input});

% Flow output
FOR ALL comp_type, mtt_cr, input, in_cause
LET cr(comp_type,mtt_cr,flow, 1, input, in_cause, 1) 
    = eqn2ass(mtt_cr,mtt_f,{mtt_e=input});

%%%% This is the assignment version
% Flow input
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, out_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,out_cause, 1, input, flow, 1) 
    = sub(mtt_f=input,mtt_cr_f);

% Effort input
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, out_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,out_cause, 1, input, effort, 1) 
    = sub(mtt_e=input,mtt_cr_e);

% Effort output
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, in_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,effort, 1, input, in_cause, 1) 
    = sub(mtt_f=input,mtt_cr_f);

% Flow output
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, in_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,flow, 1, input, in_cause, 1) 
    = sub(mtt_e=input,mtt_cr_e);


%%% Q&D FMR 2 port.
FOR ALL comp_type, mtt_cr_e,mtt_cr_f,input_1,input_2
LET cr(comp_type,mtt_cr_e,mtt_cr_f,flow,1,
	input_1,effort,1,
	input_2,flow,2
	)  = sub(mtt_mod=input_2,sub(mtt_e=input_1,mtt_cr_e));

%% AE amplifier
FOR ALL  mtt_cr, input, out_cause
LET cr(ae,mtt_cr,effort, 2, 
        input, effort, 1)
    = eqn2ass(mtt_cr,mtt_2,{mtt_1=input});

END;

Added mtt/lib/cr/r/defaultcr.r version [76c5822e3e].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%Linear Constitutive Relationship for single port components: R,C,I.
% e = Gain*f (if gain_causality = flow) 
%           f = Gain*e (if gain_causality = effort)
OPERATOR lin;
FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality = gain_causality
LET lin(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = gain*input;

%Linear CR: e = (1/Gain)*f (if gain_causality = flow) 
%           f = (1/Gain)*e (if gain_causality = effort)
FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET lin(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = input/gain;


% Linear Constitutive Relationship for AE and AF
% Output = gain * input

% Unicausal form
FOR ALL gain, input, causality
LET lin(gain, causality, 2, input, causality, 1) = gain*input;

%Bicausal form
FOR ALL gain, output, causality
LET lin(gain, causality, 1, output, causality, 2) = output/gain;

% Linear Constitutive Relationship for TF
FOR ALL gain, input, causality, gain_causality, outport, inport
SUCH THAT (
	(causality = gain_causality) AND (outport = 2)
	OR
	(causality NEQ gain_causality) AND (outport = 1)
	)
LET lin(gain_causality, gain, causality, outport, input, causality, inport)
	 = gain*input;

FOR ALL gain, input, causality, gain_causality, outport, inport
SUCH THAT (
	(causality NEQ gain_causality) AND (outport = 2)
	OR
	(causality = gain_causality) AND (outport = 1)
	)
LET lin(gain_causality, gain, causality, outport, input, causality, inport)
	 = input/gain;

END;

Added mtt/lib/cr/r/delta_h.cr version [3c6f66bca6].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY delta_h	CR for gas turbine compressor


OPERATOR delta_h;

% Port 1 - generates delta h
FOR ALL c_p,Temperature,Massflow,DeltaT
LET delta_h(c_p, flow, 1,
		Temperature,effort,1,
		Massflow,flow,2,
		DeltaT,effort,3)
	 = Massflow*c_p*DeltaT;

% Port 2 - generates zero effort
FOR ALL c_p,Temperature,Massflow,DeltaT
LET delta_h(c_p, effort, 2,
		Temperature,effort,1,
		Massflow,flow,2,
		DeltaT,effort,3)
	 = 0;

% Port 3 - generates zero effort
FOR ALL c_p,Temperature,Massflow,DeltaT
LET delta_h(c_p, flow,3,
		Temperature,effort,1,
		Massflow,flow,2,
		DeltaT,effort,3)
	 = 0;



Added mtt/lib/cr/r/lcos.cr version [09845c166a].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY lcos	linear constitutive relationship with cos modulation
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship with cos modulation


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 17:51:02  peterg
% %% Added END
% %%
% %% Revision 1.1  1996/11/02 10:18:07  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR lcos;

%DESCRIPTION three port component: EMTF
FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality = gain_causality) AND (outport = 2)
	OR
	(causality NEQ gain_causality) AND (outport = 1)
	)
LET lcos(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = cos(m_input)*gain*input;

FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality NEQ gain_causality) AND (outport = 2)
	OR
	(causality = gain_causality) AND (outport = 1)
	)
LET lcos(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = input/(cos(m_input)*gain);

END;;

Added mtt/lib/cr/r/lin.cr version [044595bc38].






































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY lin    linear constitutive relationship
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 09:19:07  peterg
% % put under RCS
% %
% % Revision 1.3  1998/07/04 10:47:04  peterg
% % back under RCS
% %
% % Revision 1.2  1998/03/04 15:38:54  peterg
% % Added END statement
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%DESCRIPTION    single port components: R,C,I
%Linear Constitutive Relationship for single port components: R,C,I.
% e = Gain*f (if gain_causality = flow) 
%           f = Gain*e (if gain_causality = effort)
OPERATOR lin;
FOR ALL comp_type,  gain_causality, gain, causality, input, other_causality
SUCH THAT causality = gain_causality
LET lin(comp_type,gain_causality, gain, other_causality, 1, input, causality, 1)
         = gain*input;

%Linear CR: e = (1/Gain)*f (if gain_causality = flow) 
%           f = (1/Gain)*e (if gain_causality = effort)
FOR ALL comp_type,  gain_causality, gain, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET lin(comp_type,gain_causality, gain, other_causality, 1, input, causality, 1)
         = input/gain;

%DESCRIPTION    two port components: AE, AF
% Linear Constitutive Relationship for AE and AF
% Output = gain * input

% Unicausal form
FOR ALL comp_type,  gain, input, causality
LET lin(comp_type,gain, causality, 2, input, causality, 1) = gain*input;

%Bicausal form
FOR ALL comp_type,  gain, output, causality
LET lin(comp_type,gain, causality, 1, output, causality, 2) = output/gain;

%DESCRIPTION   two port component: TF
% Linear Constitutive Relationship for TF
FOR ALL comp_type,  gain_causality, gain, causality, outport, input, same_causality, inport

SUCH THAT 
       ( causality = same_causality ) 
       AND 
       ( inport NEQ outport )
       AND
       (
       ( (causality = gain_causality) AND (outport = 2) )
       OR
       ( (causality NEQ gain_causality) AND (outport = 1) )
       )
LET lin(comp_type,gain_causality, gain, causality, outport, 
          input, same_causality, inport)
        = gain*input;

FOR ALL comp_type,  gain_causality, gain, causality, outport, 
        input, same_causality, inport
SUCH THAT 
       ( causality = same_causality ) 
       AND       
       ( inport NEQ outport )
       AND
       (
       ( (causality NEQ gain_causality) AND (outport = 2) )
       OR
       ( (causality = gain_causality) AND (outport = 1) )
       )
LET lin(comp_type,gain_causality, gain, causality, outport, 
         input, same_causality, inport)
        = input/gain;

%% This version in not reliable. I rellly need to pass component names
%% as cr arguments.

%DESCRIPTION    two port component: GY
% Linear Constitutive Relationship for GY

FOR ALL comp_type,  gain, input, causality, gain_causality, other_causality, 
        outport, inport
SUCH THAT 
        (causality NEQ other_causality) 
        AND
        ( inport NEQ outport )
        AND
        (
        ( (causality NEQ gain_causality) AND (outport = 2) )
        OR
        ( (causality NEQ gain_causality) AND (outport = 1) )
        )
LET lin(comp_type,gain_causality, gain, other_causality, outport, 
        input, causality, inport)
         = input/gain;

FOR ALL comp_type,  gain, input, causality, gain_causality, other_causality, 
        outport, inport
SUCH THAT 
        (causality NEQ other_causality) 
        AND
        ( inport NEQ outport )
        AND
        (
        ( (causality = gain_causality) AND (outport = 2) )
        OR
        ( (causality = gain_causality) AND (outport = 1) )
        )
LET lin(comp_type,gain_causality, gain, other_causality, outport, 
        input, causality, inport)
         = gain*input;

%DESCRIPTION    three port component: FMR

% Linear Constitutive Relationship for FMR - unicausal case
% Flow modulation multiplies effort on port 1 (or divides flow)

% The 4 possibilities follow...
FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality=in_causality) AND (out_causality=flow)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input*gain*mod_input;

FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality=in_causality) AND (out_causality=effort)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input*gain/mod_input;

FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality NEQ in_causality) AND (out_causality=flow)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input*mod_input/gain;

FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality NEQ in_causality) AND (out_causality=effort)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input/(gain*mod_input);

% Linear Constitutive Relationship for FMR - bicausal case
% Deduces the flow on port 2.

% The 2 possibilities follow...
FOR ALL comp_type,  gain,  e_input, f_input
LET lin(comp_type,effort, gain, flow, 2, 
                e_input, effort, 1,
                f_input, flow, 1)
         = (f_input/e_input)/gain;

%EMTF component - modulation only
% Linear Constitutive Relationship for EMTF
FOR ALL comp_type,  gain_causality, gain, causality, outport, input, same_causality, inport
SUCH THAT 
       ( (causality = gain_causality) AND (outport = 2) )
       OR
       ( (causality NEQ gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, causality, outport, 
          input, same_causality, inport,
	  gain, effort, 3)
        = gain*input;

FOR ALL comp_type,  gain_causality, gain, causality, outport, 
        input, same_causality, inport
SUCH THAT 
       ( (causality NEQ gain_causality) AND (outport = 2) )
       OR
       ( (causality = gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, causality, outport, 
         input, same_causality, inport,
	  gain, effort, 3)
        = input/gain;

%EMTF component - modulation and gain
% Linear Constitutive Relationship for EMTF
FOR ALL comp_type,  gain_causality, gain, causality, outport, input,
same_causality, inport, modulation
SUCH THAT 
       ( (causality = gain_causality) AND (outport = 2) )
       OR
       ( (causality NEQ gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, gain, causality, outport, 
          input, same_causality, inport,
	  modulation, effort, 3)
        = gain*modulation*input;

FOR ALL comp_type,  gain_causality, gain, causality, outport, 
        input, same_causality, inport, modulation
SUCH THAT 
       ( (causality NEQ gain_causality) AND (outport = 2) )
       OR
       ( (causality = gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, gain, causality, outport, 
         input, same_causality, inport,
	  modulation, effort, 3)
        = input/(gain*modulation);

END;;

Added mtt/lib/cr/r/linx.cr version [1543a01070].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%%% linx - cr for single port I and C with an initial state x_0



%DESCRIPTION    linear cr for single port I and C with an initial state x0
%DESCRIPTION    only adds x0 if in integral causality


OPERATOR linx;

%% Input causality as specified
%Linear Constitutive Relationship for single port components: C,I.
% e = Gain*f (if gain_causality = flow) 
%           f = Gain*e (if gain_causality = effort)

FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT (causality = gain_causality) AND (causality = state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = gain*(input + x0);


FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT (causality = gain_causality) AND (causality NEQ state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = gain*(input);

%% Input causality not as specified
%Linear CR: e = (1/Gain)*f (if gain_causality = flow) 
%           f = (1/Gain)*e (if gain_causality = effort)

FOR ALL gain_causality, gain, x0, causality, input, other_causality
SUCH THAT (causality NEQ gain_causality) AND  (causality = state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = (input+x0)/gain;

FOR ALL gain_causality, gain, x0, causality, input, other_causality
SUCH THAT (causality NEQ gain_causality) AND  (causality NEQ state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = (input)/gain;




END;;

Added mtt/lib/cr/r/lsin.cr version [0a475c4148].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY lsin	linear constitutive relationship with sin modulation
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship with sin modulation


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 17:51:37  peterg
% %% Added END
% %%
% %% Revision 1.1  1996/11/02 10:18:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR lsin;

%DESCRIPTION three port component: EMTF
FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality = gain_causality) AND (outport = 2)
	OR
	(causality NEQ gain_causality) AND (outport = 1)
	)
LET lsin(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = sin(m_input)*gain*input;

FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality NEQ gain_causality) AND (outport = 2)
	OR
	(causality = gain_causality) AND (outport = 1)
	)
LET lsin(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = input/(sin(m_input)*gain);

END;;

Added mtt/lib/cr/r/oneway.cr version [a74db11764].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY oneway	One way constitutive relationship eg Diode
%DESCRIPTION Parameter 1 is a large number being the forward gain
%DESCRIPTION	-- the reciprocal is the backward gain
%DESCRIPTION The input must be an effort
%DESCRIPTION Typical use is an R component with effort input

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR oneway; 

%Input has flow causality
FOR ALL r,  input
LET oneway(r, effort, 1, input, flow, 1)
	 = ((1 - sign(input))/2)*r*input;

%Input has effort causality
FOR ALL r,  input
LET oneway(r, flow, 1, input, effort, 1)
	 = ((1 - sign(input))/2)*(1/r)*input;

Added mtt/lib/cr/r/polytrop.cr version [e32e195400].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY polytrop	CR for gas turbine compressor


OPERATOR polytrop;

% Port 1 generates zero flow
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, flow, 1,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = 0;

% Port 2 generates deltaT
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, effort, 2,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = temperature*((Ipressure/Fpressure)^(gamma)-1);

% Port 3 generates zero flow
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, flow, 3,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = 0;

% Port 4 generates zero flow
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, flow, 4,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = 0;

Added mtt/lib/cr/r/powerlaw.cr version [18888cef83].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY powerlaw	powerlaw constitutive relationship
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort or flow
%DESCRIPTION Parameter 2 is the gain r corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


%DESCRIPTION	single port components: R

%Powerlaw Constitutive Relationship for single port components: R


OPERATOR powerlaw;
FOR ALL gain_causality, gain, power, causality, input, other_causality
SUCH THAT causality = gain_causality
LET powerlaw(gain_causality, gain, power, other_causality, 1, input, causality, 1)
	 = gain*(abs(input)^power)*sign(input);


FOR ALL gain_causality, gain, power, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET powerlaw(gain_causality, gain, power, other_causality, 1, input, causality, 1)
	 = ( (abs(input)/gain)^(1/power) )*sign(input);

END;

Added mtt/lib/cr/r/reed.cr version [2dd994541f].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY reed Nonlinear 2-port R for musical reed component


%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/11/02 10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Linear Constitutive Relationship for reed - unicausal case with 
% pressure output.
OPERATOR reed,abs,sign;

% Port 1 - the modulated R
FOR ALL D,q,H,airflow,displacement
LET reed(D,q,H, effort, 1, 
		airflow,flow,1,
		displacement, effort,2)
	 = (D*sign(airflow)*(airflow)^q)/((H-displacement)^2);

% Port 2 - zero flow
FOR ALL D,q,H,airflow,displacement
LET reed(D,q, flow, 2, 
		airflow,flow,1,
		displacement, effort,2)
	 =0;

Added mtt/lib/cr/r/sat_tank.cr version [95637b5048].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY sat_tank Saturation nonlinearity with variable slopes for tank
%DESCRIPTION Parameter 1 is the slope of the "normal" linear part of the CR
%DESCRIPTION Parameter 2 is the "large" slope
%DESCRIPTION Parameter 3 is the lower bound of the state
%DESCRIPTION Parameter 4 is the upper bound of the state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OPERATOR sign0;
FOR ALL x
	LET sign0(x) = (sign(x)+1)/2;

OPERATOR sat_tank; 
%Output has effort causality, input is state
FOR ALL k_0, k_1, x_0, x_1, x
LET sat_tank(k_0, k_1, x_0, x_1, effort, 1,
         x, state, 1)
	 = x*k_0 + (x-x_1)*(k_1-k_0)*sign0(x-x_1) + (x-x_0)*(k_1-k_0)*sign0(x_0-x);


Added mtt/lib/cr/r/slcos.cr version [e42d3ee3a4].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY slcos	linear constitutive relationship with sin modulation - sensitivity
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


OPERATOR slcos;

%DESCRIPTION four port component - effort i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slcos(gain, effort, 2, 
	input, effort, 1,
	junk, flow, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = -gain*sin(m_input)*dm_input*input;

%DESCRIPTION four port component - flow i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slcos(gain, flow, 2, 
	input, flow, 1,
	junk, effort, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = -gain*sin(m_input)*dm_input*input;

END;;

Added mtt/lib/cr/r/slin.cr version [b68eb630ad].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%DESCRIPTION Sensitivity version of lin

in "$MTT_CRS/r/lin.cr";

% One port version for historical reasons
OPERATOR slin;
FOR ALL gain_causality, gain, causality, input, other_causality
LET slin(gain_causality, gain, other_causality, 1, input, causality, 1)
         = lin(gain_causality, gain, other_causality, 1, input,
	 causality, 1);

% Two port version for sC,sI,sR 

% Port 1 - standard 
FOR ALL COMPONENT, gain_causality, gain, sgain, causality, input, sinput, other_causality
LET slin(COMPONENT,gain_causality, gain, sgain, other_causality, 1, 
       input, causality, 1,
       sinput, causality, 2)
         = lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               input, causality, 1); 


% Port 2 - sensitivity
FOR ALL COMPONENT, gain_causality, gain, sgain, causality, input, sinput, other_causality
SUCH THAT sgain NEQ 0
LET slin(COMPONENT,gain_causality, gain, sgain, other_causality, 2, 
       input, causality, 1,
       sinput, causality, 2)
         = lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               sinput, causality, 1)
         + sgain*df(lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               input, causality, 1), gain); 

%% Don't compute the derivative in this case
FOR ALL COMPONENT, gain_causality, gain, sgain, causality, input, sinput, other_causality
SUCH THAT sgain EQ 0
LET slin(COMPONENT,gain_causality, gain, sgain, other_causality, 2, 
       input, causality, 1,
       sinput, causality, 2)
         = lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               sinput, causality, 1);
         

%% This is the version to go with sEMTF
%% It is the CR passed to the AE3 components

%DESCRIPTION four port component - effort i/o
FOR ALL COMPONENT, gain, input, junk, m_input, dm_input
LET slin(COMPONENT,gain, effort, 2, 
	input, effort, 1,
	junk, flow, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*dm_input*input;

%DESCRIPTION four port component - flow i/o
FOR ALL COMPONENT, gain, input, junk, m_input, dm_input
LET slin(COMPONENT,gain, flow, 2, 
	input, flow, 1,
	junk, effort, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*dm_input*input;

END;;






Added mtt/lib/cr/r/slsin.cr version [68fd274f15].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY slsin	linear constitutive relationship with sin modulation - sensitivity
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


OPERATOR slsin;

%DESCRIPTION four port component - effort i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slsin(gain, effort, 2, 
	input, effort, 1,
	junk, flow, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*cos(m_input)*dm_input*input;

%DESCRIPTION four port component - flow i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slsin(gain, flow, 2, 
	input, flow, 1,
	junk, effort, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*cos(m_input)*dm_input*input;

END;;

Added mtt/lib/cr/r/square.cr version [34c368838f].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY square	square-law constitutive relationship
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort or flow
%DESCRIPTION Parameter 2 is the gain r corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


%DESCRIPTION	single port components: R

%Square-Law Constitutive Relationship for single port components: R
% output = Gain*input^2*sign(input) {if gain_causality = causality} 
% output = (1/Gain^(1/2))*input^(1/2)*sign(input) 
%		{if gain_causality not= causality} 



OPERATOR square;
FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality = gain_causality
LET square(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = gain*input^2*sign(input);


FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET square(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = input^(1/2)*sign(input)/(gain^(1/2));


END;

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Comb_abg.m version [64d72d515d].






























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Comb] =  Comb_abg
# This function is the acausal bond graph representation of Comb
# Generated by MTT on Thu Mar 16 10:33:30 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hydraulic_in
  Comb.ports.Hydraulic_in.type = "SS";
  Comb.ports.Hydraulic_in.cr = "SS";
  Comb.ports.Hydraulic_in.arg = "external,external";
  Comb.ports.Hydraulic_in.repetitions = 1;
  Comb.ports.Hydraulic_in.status = -1;
  Comb.ports.Hydraulic_in.connections = [-3 ];

# Port Hydraulic_out
  Comb.ports.Hydraulic_out.type = "SS";
  Comb.ports.Hydraulic_out.cr = "SS";
  Comb.ports.Hydraulic_out.arg = "external,external";
  Comb.ports.Hydraulic_out.repetitions = 1;
  Comb.ports.Hydraulic_out.status = -1;
  Comb.ports.Hydraulic_out.connections = [7 ];

# Port Heat
  Comb.ports.Heat.type = "SS";
  Comb.ports.Heat.cr = "SS";
  Comb.ports.Heat.arg = "external,external";
  Comb.ports.Heat.repetitions = 1;
  Comb.ports.Heat.status = -1;
  Comb.ports.Heat.connections = [-5 ];

# Port Thermal_in
  Comb.ports.Thermal_in.type = "SS";
  Comb.ports.Thermal_in.cr = "SS";
  Comb.ports.Thermal_in.arg = "external,external";
  Comb.ports.Thermal_in.repetitions = 1;
  Comb.ports.Thermal_in.status = -1;
  Comb.ports.Thermal_in.connections = [-2 ];

# Port Thermal_out
  Comb.ports.Thermal_out.type = "SS";
  Comb.ports.Thermal_out.cr = "SS";
  Comb.ports.Thermal_out.arg = "external,external";
  Comb.ports.Thermal_out.repetitions = 1;
  Comb.ports.Thermal_out.status = -1;
  Comb.ports.Thermal_out.connections = [6 ];

# Component P
  Comb.subsystems.P.type = "SS";
  Comb.subsystems.P.cr = "SS";
  Comb.subsystems.P.arg = "external,0";
  Comb.subsystems.P.repetitions = 1;
  Comb.subsystems.P.status = -1;
  Comb.subsystems.P.connections = [9 ];

# Component T
  Comb.subsystems.T.type = "SS";
  Comb.subsystems.T.cr = "SS";
  Comb.subsystems.T.arg = "external,0";
  Comb.subsystems.T.repetitions = 1;
  Comb.subsystems.T.status = -1;
  Comb.subsystems.T.connections = [8 ];

# Component pipe
  Comb.subsystems.pipe.type = "hPipe";
  Comb.subsystems.pipe.cr = "none";
  Comb.subsystems.pipe.arg = "m_c;v_c;r";
  Comb.subsystems.pipe.repetitions = 1;
  Comb.subsystems.pipe.status = -1;
  Comb.subsystems.pipe.connections = [5 3 -4 2 -1 ];

# Component mtt1
  Comb.subsystems.mtt1.type = "0";
  Comb.subsystems.mtt1.cr = "";
  Comb.subsystems.mtt1.arg = "";
  Comb.subsystems.mtt1.repetitions = 1;
  Comb.subsystems.mtt1.status = -1;
  Comb.subsystems.mtt1.connections = [1 -6 -8 ];

# Component mtt2
  Comb.subsystems.mtt2.type = "0";
  Comb.subsystems.mtt2.cr = "";
  Comb.subsystems.mtt2.arg = "";
  Comb.subsystems.mtt2.repetitions = 1;
  Comb.subsystems.mtt2.status = -1;
  Comb.subsystems.mtt2.connections = [4 -7 -9 ];

# Ordered list of Port names
  Comb.portlist(1,:) = "Hydraulic_in ";
  Comb.portlist(2,:) = "Hydraulic_out";
  Comb.portlist(3,:) = "Heat         ";
  Comb.portlist(4,:) = "Thermal_in   ";
  Comb.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  Comb.subsystemlist(1,:) = "P   ";
  Comb.subsystemlist(2,:) = "T   ";
  Comb.subsystemlist(3,:) = "pipe";
  Comb.subsystemlist(4,:) = "mtt1";
  Comb.subsystemlist(5,:) = "mtt2";

# Bonds 
  Comb.bonds = [
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      1 1 
      1 1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Comb.alias.out = "Thermal_out,Hydraulic_out";
Comb.alias.Hy_out = "Hydraulic_out";
Comb.alias.v_c = "$2";
Comb.alias.Th_in = "Thermal_in";
Comb.alias.r = "$3";
Comb.alias.Th_out = "Thermal_out";
Comb.alias.in = "Thermal_in,Hydraulic_in";
Comb.alias.Hy_in = "Hydraulic_in";
Comb.alias.m_c = "$1";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Density_abg.m version [1b2d66d65e].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Density] =  Density_abg
# This function is the acausal bond graph representation of Density
# Generated by MTT on Thu Mar 16 10:36:39 2000
# The file is in Octave format

# Subsystems and Ports

# Port Pressure
  Density.ports.Pressure.type = "SS";
  Density.ports.Pressure.cr = "SS";
  Density.ports.Pressure.arg = "external,external";
  Density.ports.Pressure.repetitions = 1;
  Density.ports.Pressure.status = -1;
  Density.ports.Pressure.connections = [-4 ];

# Port Temperature
  Density.ports.Temperature.type = "SS";
  Density.ports.Temperature.cr = "SS";
  Density.ports.Temperature.arg = "external,external";
  Density.ports.Temperature.repetitions = 1;
  Density.ports.Temperature.status = -1;
  Density.ports.Temperature.connections = [-5 ];

# Port Density
  Density.ports.Density.type = "SS";
  Density.ports.Density.cr = "SS";
  Density.ports.Density.arg = "external,external";
  Density.ports.Density.repetitions = 1;
  Density.ports.Density.status = -1;
  Density.ports.Density.connections = [3 ];

# Component r
  Density.subsystems.r.type = "R";
  Density.subsystems.r.cr = "Density";
  Density.subsystems.r.arg = "density,ideal_gas,r";
  Density.subsystems.r.repetitions = 1;
  Density.subsystems.r.status = -1;
  Density.subsystems.r.connections = [1 2 -3 ];

# Component mtt1
  Density.subsystems.mtt1.type = "AE";
  Density.subsystems.mtt1.cr = "";
  Density.subsystems.mtt1.arg = "";
  Density.subsystems.mtt1.repetitions = 1;
  Density.subsystems.mtt1.status = -1;
  Density.subsystems.mtt1.connections = [4 -1 ];

# Component mtt2
  Density.subsystems.mtt2.type = "AE";
  Density.subsystems.mtt2.cr = "";
  Density.subsystems.mtt2.arg = "";
  Density.subsystems.mtt2.repetitions = 1;
  Density.subsystems.mtt2.status = -1;
  Density.subsystems.mtt2.connections = [5 -2 ];

# Ordered list of Port names
  Density.portlist(1,:) = "Pressure   ";
  Density.portlist(2,:) = "Temperature";
  Density.portlist(3,:) = "Density    ";

# Ordered list of subsystem names
  Density.subsystemlist(1,:) = "r   ";
  Density.subsystemlist(2,:) = "mtt1";
  Density.subsystemlist(3,:) = "mtt2";

# Bonds 
  Density.bonds = [
      1 1 
      1 1 
      1 1 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
Density.alias.P = "Pressure";
Density.alias.out = "Density";
Density.alias.rho = "Density";
Density.alias.T = "Temperature";
Density.alias.density__ideal_gas__r = "$1";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Density_cr.r version [5fd3e01e3d].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for Density (Density_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Density;

% Ideal gas
FOR ALL R,Temperature,Pressure,Nothing
LET Density(density,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = Pressure/(R*Temperature);

FOR ALL R,Temperature,Pressure,Nothing
LET Density(specific_volume,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = (R*Temperature)/Pressure;

% Incompressible
FOR ALL rho,Temperature,Pressure,Nothing
LET Density(density,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = rho;

FOR ALL rho,Temperature,Pressure,Nothing
LET Density(specific_volume,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = 1/rho;

END;

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/In_abg.m version [39b730b677].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [In] =  In_abg
# This function is the acausal bond graph representation of In
# Generated by MTT on Thu Mar 16 10:33:58 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hy_out
  In.ports.Hy_out.type = "SS";
  In.ports.Hy_out.cr = "SS";
  In.ports.Hy_out.arg = "external,external";
  In.ports.Hy_out.repetitions = 1;
  In.ports.Hy_out.status = -1;
  In.ports.Hy_out.connections = [2 ];

# Port Th_out
  In.ports.Th_out.type = "SS";
  In.ports.Th_out.cr = "SS";
  In.ports.Th_out.arg = "external,external";
  In.ports.Th_out.repetitions = 1;
  In.ports.Th_out.status = -1;
  In.ports.Th_out.connections = [1 ];

# Component Hy_in
  In.subsystems.Hy_in.type = "SS";
  In.subsystems.Hy_in.cr = "SS";
  In.subsystems.Hy_in.arg = "p_1,internal";
  In.subsystems.Hy_in.repetitions = 1;
  In.subsystems.Hy_in.status = -1;
  In.subsystems.Hy_in.connections = [-2 ];

# Component Th_in
  In.subsystems.Th_in.type = "SS";
  In.subsystems.Th_in.cr = "SS";
  In.subsystems.Th_in.arg = "t_1,internal";
  In.subsystems.Th_in.repetitions = 1;
  In.subsystems.Th_in.status = -1;
  In.subsystems.Th_in.connections = [-1 ];

# Ordered list of Port names
  In.portlist(1,:) = "Hy_out";
  In.portlist(2,:) = "Th_out";

# Ordered list of subsystem names
  In.subsystemlist(1,:) = "Hy_in";
  In.subsystemlist(2,:) = "Th_in";

# Bonds 
  In.bonds = [
      1 1 
      1 1 
      ];

# Aliases 
# A double underscore __ represents a comma 
In.alias.out = "Th_out,Hy_out";
In.alias.in = "Th_out,Hy_out";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/In_desc.tex version [0c97485c1c].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Load_abg.m version [ebdf741bae].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Load] =  Load_abg
# This function is the acausal bond graph representation of Load
# Generated by MTT on Thu Mar 16 10:34:27 2000
# The file is in Octave format

# Subsystems and Ports

# Port in
  Load.ports.in.type = "SS";
  Load.ports.in.cr = "SS";
  Load.ports.in.arg = "external,external";
  Load.ports.in.repetitions = 1;
  Load.ports.in.status = -1;
  Load.ports.in.connections = [-1 ];

# Port out
  Load.ports.out.type = "SS";
  Load.ports.out.cr = "SS";
  Load.ports.out.arg = "external,external";
  Load.ports.out.repetitions = 1;
  Load.ports.out.status = -1;
  Load.ports.out.connections = [3 ];

# Component PowerSensor
  Load.subsystems.PowerSensor.type = "PS";
  Load.subsystems.PowerSensor.cr = "";
  Load.subsystems.PowerSensor.arg = "";
  Load.subsystems.PowerSensor.repetitions = 1;
  Load.subsystems.PowerSensor.status = -1;
  Load.subsystems.PowerSensor.connections = [1 -2 -3 ];

# Component r_l
  Load.subsystems.r_l.type = "R";
  Load.subsystems.r_l.cr = "lin";
  Load.subsystems.r_l.arg = "flow,r_l";
  Load.subsystems.r_l.repetitions = 1;
  Load.subsystems.r_l.status = -1;
  Load.subsystems.r_l.connections = [2 ];

# Ordered list of Port names
  Load.portlist(1,:) = "in ";
  Load.portlist(2,:) = "out";

# Ordered list of subsystem names
  Load.subsystemlist(1,:) = "PowerSensor";
  Load.subsystemlist(2,:) = "r_l        ";

# Bonds 
  Load.bonds = [
      0 0 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
Load.alias.out = "out";
Load.alias.r_l = "$2";
Load.alias.in = "in";
Load.alias.PowerSensor = "$1";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Out_abg.m version [06caed529c].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Out] =  Out_abg
# This function is the acausal bond graph representation of Out
# Generated by MTT on Thu Mar 16 10:34:51 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hy_in
  Out.ports.Hy_in.type = "SS";
  Out.ports.Hy_in.cr = "SS";
  Out.ports.Hy_in.arg = "external,external";
  Out.ports.Hy_in.repetitions = 1;
  Out.ports.Hy_in.status = -1;
  Out.ports.Hy_in.connections = [-1 ];

# Port Th_in
  Out.ports.Th_in.type = "SS";
  Out.ports.Th_in.cr = "SS";
  Out.ports.Th_in.arg = "external,external";
  Out.ports.Th_in.repetitions = 1;
  Out.ports.Th_in.status = -1;
  Out.ports.Th_in.connections = [-2 ];

# Component Hy_out
  Out.subsystems.Hy_out.type = "SS";
  Out.subsystems.Hy_out.cr = "SS";
  Out.subsystems.Hy_out.arg = "p_1,internal";
  Out.subsystems.Hy_out.repetitions = 1;
  Out.subsystems.Hy_out.status = -1;
  Out.subsystems.Hy_out.connections = [1 ];

# Component Th_out
  Out.subsystems.Th_out.type = "SS";
  Out.subsystems.Th_out.cr = "SS";
  Out.subsystems.Th_out.arg = "t_1,internal";
  Out.subsystems.Th_out.repetitions = 1;
  Out.subsystems.Th_out.status = -1;
  Out.subsystems.Th_out.connections = [2 ];

# Ordered list of Port names
  Out.portlist(1,:) = "Hy_in";
  Out.portlist(2,:) = "Th_in";

# Ordered list of subsystem names
  Out.subsystemlist(1,:) = "Hy_out";
  Out.subsystemlist(2,:) = "Th_out";

# Bonds 
  Out.bonds = [
      -1 -1 
      -1 -1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Out.alias.in = "Th_in,Hy_in";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Out_desc.tex version [3dd57dc573].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Poly_abg.m version [efdf7b7d95].



























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Poly] =  Poly_abg
# This function is the acausal bond graph representation of Poly
# Generated by MTT on Thu Mar 16 10:35:48 2000
# The file is in Octave format

# Subsystems and Ports

# Port Pressure_1
  Poly.ports.Pressure_1.type = "SS";
  Poly.ports.Pressure_1.cr = "SS";
  Poly.ports.Pressure_1.arg = "external,external";
  Poly.ports.Pressure_1.repetitions = 1;
  Poly.ports.Pressure_1.status = -1;
  Poly.ports.Pressure_1.connections = [-2 ];

# Port Temperature_1
  Poly.ports.Temperature_1.type = "SS";
  Poly.ports.Temperature_1.cr = "SS";
  Poly.ports.Temperature_1.arg = "external,external";
  Poly.ports.Temperature_1.repetitions = 1;
  Poly.ports.Temperature_1.status = -1;
  Poly.ports.Temperature_1.connections = [-6 ];

# Port Pressure_2
  Poly.ports.Pressure_2.type = "SS";
  Poly.ports.Pressure_2.cr = "SS";
  Poly.ports.Pressure_2.arg = "external,external";
  Poly.ports.Pressure_2.repetitions = 1;
  Poly.ports.Pressure_2.status = -1;
  Poly.ports.Pressure_2.connections = [-4 ];

# Port Temperature_2
  Poly.ports.Temperature_2.type = "SS";
  Poly.ports.Temperature_2.cr = "SS";
  Poly.ports.Temperature_2.arg = "external,external";
  Poly.ports.Temperature_2.repetitions = 1;
  Poly.ports.Temperature_2.status = -1;
  Poly.ports.Temperature_2.connections = [8 ];

# Component r
  Poly.subsystems.r.type = "R";
  Poly.subsystems.r.cr = "Poly";
  Poly.subsystems.r.arg = "alpha";
  Poly.subsystems.r.repetitions = 1;
  Poly.subsystems.r.status = -1;
  Poly.subsystems.r.connections = [1 3 5 -7 ];

# Component zero
  Poly.subsystems.zero.type = "SS";
  Poly.subsystems.zero.cr = "SS";
  Poly.subsystems.zero.arg = "0,0";
  Poly.subsystems.zero.repetitions = 1;
  Poly.subsystems.zero.status = -1;
  Poly.subsystems.zero.connections = [-9 ];

# Component mtt1
  Poly.subsystems.mtt1.type = "AE";
  Poly.subsystems.mtt1.cr = "";
  Poly.subsystems.mtt1.arg = "";
  Poly.subsystems.mtt1.repetitions = 1;
  Poly.subsystems.mtt1.status = -1;
  Poly.subsystems.mtt1.connections = [2 -1 ];

# Component mtt2
  Poly.subsystems.mtt2.type = "AE";
  Poly.subsystems.mtt2.cr = "";
  Poly.subsystems.mtt2.arg = "";
  Poly.subsystems.mtt2.repetitions = 1;
  Poly.subsystems.mtt2.status = -1;
  Poly.subsystems.mtt2.connections = [4 -3 ];

# Component mtt3
  Poly.subsystems.mtt3.type = "AE";
  Poly.subsystems.mtt3.cr = "";
  Poly.subsystems.mtt3.arg = "";
  Poly.subsystems.mtt3.repetitions = 1;
  Poly.subsystems.mtt3.status = -1;
  Poly.subsystems.mtt3.connections = [6 -5 ];

# Component mtt4
  Poly.subsystems.mtt4.type = "1";
  Poly.subsystems.mtt4.cr = "";
  Poly.subsystems.mtt4.arg = "";
  Poly.subsystems.mtt4.repetitions = 1;
  Poly.subsystems.mtt4.status = -1;
  Poly.subsystems.mtt4.connections = [7 -8 9 ];

# Ordered list of Port names
  Poly.portlist(1,:) = "Pressure_1   ";
  Poly.portlist(2,:) = "Temperature_1";
  Poly.portlist(3,:) = "Pressure_2   ";
  Poly.portlist(4,:) = "Temperature_2";

# Ordered list of subsystem names
  Poly.subsystemlist(1,:) = "r   ";
  Poly.subsystemlist(2,:) = "zero";
  Poly.subsystemlist(3,:) = "mtt1";
  Poly.subsystemlist(4,:) = "mtt2";
  Poly.subsystemlist(5,:) = "mtt3";
  Poly.subsystemlist(6,:) = "mtt4";

# Bonds 
  Poly.bonds = [
      1 1 
      0 0 
      1 1 
      0 0 
      1 1 
      0 0 
      0 0 
      0 0 
      1 -1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Poly.alias.out = "Temperature_2";
Poly.alias.P1 = "Pressure_1";
Poly.alias.P2 = "Pressure_2";
Poly.alias.T1 = "Temperature_1";
Poly.alias.T2 = "Temperature_2";
Poly.alias.alpha = "$1";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Poly_cr.r version [ad1eaacee8].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for Poly (Poly_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Poly;

% Ideal gas

% Temperature output on port [T2]
FOR ALL alpha,P1,P2,T1,Nothing
LET Poly(alpha,effort,4,
	P1,effort,1,
	P2,effort,2,
	T1,effort,3,
	Nothing,flow,4
	) = T1*(P2/P1)^alpha;



END;

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/Pump_abg.m version [3fd343e8e9].





















































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [Pump] =  Pump_abg
# This function is the acausal bond graph representation of Pump
# Generated by MTT on Thu Mar 16 10:38:10 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hydraulic_in
  Pump.ports.Hydraulic_in.type = "SS";
  Pump.ports.Hydraulic_in.cr = "SS";
  Pump.ports.Hydraulic_in.arg = "external,external";
  Pump.ports.Hydraulic_in.repetitions = 1;
  Pump.ports.Hydraulic_in.status = -1;
  Pump.ports.Hydraulic_in.connections = [-5 ];

# Port Hydraulic_out
  Pump.ports.Hydraulic_out.type = "SS";
  Pump.ports.Hydraulic_out.cr = "SS";
  Pump.ports.Hydraulic_out.arg = "external,external";
  Pump.ports.Hydraulic_out.repetitions = 1;
  Pump.ports.Hydraulic_out.status = -1;
  Pump.ports.Hydraulic_out.connections = [6 ];

# Port Shaft
  Pump.ports.Shaft.type = "SS";
  Pump.ports.Shaft.cr = "SS";
  Pump.ports.Shaft.arg = "external,external";
  Pump.ports.Shaft.repetitions = 1;
  Pump.ports.Shaft.status = -1;
  Pump.ports.Shaft.connections = [-12 ];

# Port Thermal_in
  Pump.ports.Thermal_in.type = "SS";
  Pump.ports.Thermal_in.cr = "SS";
  Pump.ports.Thermal_in.arg = "external,external";
  Pump.ports.Thermal_in.repetitions = 1;
  Pump.ports.Thermal_in.status = -1;
  Pump.ports.Thermal_in.connections = [-4 ];

# Port Thermal_out
  Pump.ports.Thermal_out.type = "SS";
  Pump.ports.Thermal_out.cr = "SS";
  Pump.ports.Thermal_out.arg = "external,external";
  Pump.ports.Thermal_out.repetitions = 1;
  Pump.ports.Thermal_out.status = -1;
  Pump.ports.Thermal_out.connections = [16 ];

# Component pipe
  Pump.subsystems.pipe.type = "wPipe";
  Pump.subsystems.pipe.cr = "none";
  Pump.subsystems.pipe.arg = "c_v;density,ideal_gas,r";
  Pump.subsystems.pipe.repetitions = 1;
  Pump.subsystems.pipe.status = -1;
  Pump.subsystems.pipe.connections = [3 -7 14 2 -1 ];

# Component poly
  Pump.subsystems.poly.type = "Poly";
  Pump.subsystems.poly.cr = "Poly";
  Pump.subsystems.poly.arg = "alpha";
  Pump.subsystems.poly.repetitions = 1;
  Pump.subsystems.poly.status = -1;
  Pump.subsystems.poly.connections = [9 8 11 -10 ];

# Component T
  Pump.subsystems.T.type = "SS";
  Pump.subsystems.T.cr = "SS";
  Pump.subsystems.T.arg = "external,0";
  Pump.subsystems.T.repetitions = 1;
  Pump.subsystems.T.status = -1;
  Pump.subsystems.T.connections = [17 ];

# Component k_p
  Pump.subsystems.k_p.type = "TF";
  Pump.subsystems.k_p.cr = "lin";
  Pump.subsystems.k_p.arg = "flow,k_p";
  Pump.subsystems.k_p.repetitions = 1;
  Pump.subsystems.k_p.status = -1;
  Pump.subsystems.k_p.connections = [13 -14 ];

# Component mtt1
  Pump.subsystems.mtt1.type = "0";
  Pump.subsystems.mtt1.cr = "";
  Pump.subsystems.mtt1.arg = "";
  Pump.subsystems.mtt1.repetitions = 1;
  Pump.subsystems.mtt1.status = -1;
  Pump.subsystems.mtt1.connections = [1 10 -15 -17 ];

# Component mtt2
  Pump.subsystems.mtt2.type = "0";
  Pump.subsystems.mtt2.cr = "";
  Pump.subsystems.mtt2.arg = "";
  Pump.subsystems.mtt2.repetitions = 1;
  Pump.subsystems.mtt2.status = -1;
  Pump.subsystems.mtt2.connections = [-6 7 -11 ];

# Component mtt3
  Pump.subsystems.mtt3.type = "0";
  Pump.subsystems.mtt3.cr = "";
  Pump.subsystems.mtt3.arg = "";
  Pump.subsystems.mtt3.repetitions = 1;
  Pump.subsystems.mtt3.status = -1;
  Pump.subsystems.mtt3.connections = [-3 5 -9 ];

# Component mtt4
  Pump.subsystems.mtt4.type = "0";
  Pump.subsystems.mtt4.cr = "";
  Pump.subsystems.mtt4.arg = "";
  Pump.subsystems.mtt4.repetitions = 1;
  Pump.subsystems.mtt4.status = -1;
  Pump.subsystems.mtt4.connections = [-2 4 -8 ];

# Component mtt5
  Pump.subsystems.mtt5.type = "EBTF";
  Pump.subsystems.mtt5.cr = "";
  Pump.subsystems.mtt5.arg = "";
  Pump.subsystems.mtt5.repetitions = 1;
  Pump.subsystems.mtt5.status = -1;
  Pump.subsystems.mtt5.connections = [15 -16 ];

# Component mtt6
  Pump.subsystems.mtt6.type = "1";
  Pump.subsystems.mtt6.cr = "";
  Pump.subsystems.mtt6.arg = "";
  Pump.subsystems.mtt6.repetitions = 1;
  Pump.subsystems.mtt6.status = -1;
  Pump.subsystems.mtt6.connections = [12 -13 ];

# Ordered list of Port names
  Pump.portlist(1,:) = "Hydraulic_in ";
  Pump.portlist(2,:) = "Hydraulic_out";
  Pump.portlist(3,:) = "Shaft        ";
  Pump.portlist(4,:) = "Thermal_in   ";
  Pump.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  Pump.subsystemlist(1,:) = "pipe";
  Pump.subsystemlist(2,:) = "poly";
  Pump.subsystemlist(3,:) = "T   ";
  Pump.subsystemlist(4,:) = "k_p ";
  Pump.subsystemlist(5,:) = "mtt1";
  Pump.subsystemlist(6,:) = "mtt2";
  Pump.subsystemlist(7,:) = "mtt3";
  Pump.subsystemlist(8,:) = "mtt4";
  Pump.subsystemlist(9,:) = "mtt5";
  Pump.subsystemlist(10,:) = "mtt6";

# Bonds 
  Pump.bonds = [
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      -1 -1 
      0 0 
      0 0 
      0 0 
      0 0 
      1 1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Pump.alias.out = "Thermal_out,Hydraulic_out";
Pump.alias.Hy_out = "Hydraulic_out";
Pump.alias.c_v = "$1";
Pump.alias.flow__k_p = "$4";
Pump.alias.Th_in = "Thermal_in";
Pump.alias.Th_out = "Thermal_out";
Pump.alias.Work = "Shaft";
Pump.alias.alpha = "$3";
Pump.alias.in = "Thermal_in,Hydraulic_in";
Pump.alias.Hy_in = "Hydraulic_in";
Pump.alias.density__ideal_gas__r = "$2";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_abg.m version [43a702b612].






































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [SimpleGasTurbineABG] =  SimpleGasTurbineABG_abg
# This function is the acausal bond graph representation of SimpleGasTurbineABG
# Generated by MTT on Thu Mar 16 12:59:12 2000
# The file is in Octave format

# Subsystems and Ports

# Component c1
  SimpleGasTurbineABG.subsystems.c1.type = "Comb";
  SimpleGasTurbineABG.subsystems.c1.cr = "none";
  SimpleGasTurbineABG.subsystems.c1.arg = "m_c;v_c;r";
  SimpleGasTurbineABG.subsystems.c1.repetitions = 1;
  SimpleGasTurbineABG.subsystems.c1.status = -1;
  SimpleGasTurbineABG.subsystems.c1.connections = [14 -15 7 10 -11 ];

# Component j_s
  SimpleGasTurbineABG.subsystems.j_s.type = "I";
  SimpleGasTurbineABG.subsystems.j_s.cr = "lin";
  SimpleGasTurbineABG.subsystems.j_s.arg = "flow,j_s";
  SimpleGasTurbineABG.subsystems.j_s.repetitions = 1;
  SimpleGasTurbineABG.subsystems.j_s.status = -1;
  SimpleGasTurbineABG.subsystems.j_s.connections = [2 ];

# Component comp
  SimpleGasTurbineABG.subsystems.comp.type = "Pump";
  SimpleGasTurbineABG.subsystems.comp.cr = "none";
  SimpleGasTurbineABG.subsystems.comp.arg = "c_v;density,ideal_gas,r;alpha;effort,k";
  SimpleGasTurbineABG.subsystems.comp.repetitions = 1;
  SimpleGasTurbineABG.subsystems.comp.status = -1;
  SimpleGasTurbineABG.subsystems.comp.connections = [16 -14 1 12 -10 ];

# Component turb
  SimpleGasTurbineABG.subsystems.turb.type = "Pump";
  SimpleGasTurbineABG.subsystems.turb.cr = "none";
  SimpleGasTurbineABG.subsystems.turb.arg = "c_v;density,ideal_gas,r;alpha;effort,k";
  SimpleGasTurbineABG.subsystems.turb.repetitions = 1;
  SimpleGasTurbineABG.subsystems.turb.status = -1;
  SimpleGasTurbineABG.subsystems.turb.connections = [15 -17 -6 11 -13 ];

# Component Work
  SimpleGasTurbineABG.subsystems.Work.type = "SS";
  SimpleGasTurbineABG.subsystems.Work.cr = "SS";
  SimpleGasTurbineABG.subsystems.Work.arg = "0,external";
  SimpleGasTurbineABG.subsystems.Work.repetitions = 1;
  SimpleGasTurbineABG.subsystems.Work.status = -1;
  SimpleGasTurbineABG.subsystems.Work.connections = [4 ];

# Component Heat
  SimpleGasTurbineABG.subsystems.Heat.type = "SS";
  SimpleGasTurbineABG.subsystems.Heat.cr = "SS";
  SimpleGasTurbineABG.subsystems.Heat.arg = "0,external";
  SimpleGasTurbineABG.subsystems.Heat.repetitions = 1;
  SimpleGasTurbineABG.subsystems.Heat.status = -1;
  SimpleGasTurbineABG.subsystems.Heat.connections = [9 ];

# Component Speed
  SimpleGasTurbineABG.subsystems.Speed.type = "SS";
  SimpleGasTurbineABG.subsystems.Speed.cr = "SS";
  SimpleGasTurbineABG.subsystems.Speed.arg = "0,external";
  SimpleGasTurbineABG.subsystems.Speed.repetitions = 1;
  SimpleGasTurbineABG.subsystems.Speed.status = -1;
  SimpleGasTurbineABG.subsystems.Speed.connections = [5 ];

# Component T3
  SimpleGasTurbineABG.subsystems.T3.type = "SS";
  SimpleGasTurbineABG.subsystems.T3.cr = "SS";
  SimpleGasTurbineABG.subsystems.T3.arg = "external,external";
  SimpleGasTurbineABG.subsystems.T3.repetitions = 1;
  SimpleGasTurbineABG.subsystems.T3.status = -1;
  SimpleGasTurbineABG.subsystems.T3.connections = [-8 ];

# Component in
  SimpleGasTurbineABG.subsystems.in.type = "In";
  SimpleGasTurbineABG.subsystems.in.cr = "";
  SimpleGasTurbineABG.subsystems.in.arg = "";
  SimpleGasTurbineABG.subsystems.in.repetitions = 1;
  SimpleGasTurbineABG.subsystems.in.status = -1;
  SimpleGasTurbineABG.subsystems.in.connections = [-16 -12 ];

# Component out
  SimpleGasTurbineABG.subsystems.out.type = "Out";
  SimpleGasTurbineABG.subsystems.out.cr = "";
  SimpleGasTurbineABG.subsystems.out.arg = "";
  SimpleGasTurbineABG.subsystems.out.repetitions = 1;
  SimpleGasTurbineABG.subsystems.out.status = -1;
  SimpleGasTurbineABG.subsystems.out.connections = [17 13 ];

# Component mtt1
  SimpleGasTurbineABG.subsystems.mtt1.type = "1";
  SimpleGasTurbineABG.subsystems.mtt1.cr = "";
  SimpleGasTurbineABG.subsystems.mtt1.arg = "";
  SimpleGasTurbineABG.subsystems.mtt1.repetitions = 1;
  SimpleGasTurbineABG.subsystems.mtt1.status = -1;
  SimpleGasTurbineABG.subsystems.mtt1.connections = [-1 -2 -3 -5 6 ];

# Component mtt2
  SimpleGasTurbineABG.subsystems.mtt2.type = "Load";
  SimpleGasTurbineABG.subsystems.mtt2.cr = "";
  SimpleGasTurbineABG.subsystems.mtt2.arg = "";
  SimpleGasTurbineABG.subsystems.mtt2.repetitions = 1;
  SimpleGasTurbineABG.subsystems.mtt2.status = -1;
  SimpleGasTurbineABG.subsystems.mtt2.connections = [3 -4 ];

# Component mtt3
  SimpleGasTurbineABG.subsystems.mtt3.type = "PS";
  SimpleGasTurbineABG.subsystems.mtt3.cr = "";
  SimpleGasTurbineABG.subsystems.mtt3.arg = "";
  SimpleGasTurbineABG.subsystems.mtt3.repetitions = 1;
  SimpleGasTurbineABG.subsystems.mtt3.status = -1;
  SimpleGasTurbineABG.subsystems.mtt3.connections = [8 -7 -9 ];

# Ordered list of subsystem names
  SimpleGasTurbineABG.subsystemlist(1,:) = "c1   ";
  SimpleGasTurbineABG.subsystemlist(2,:) = "j_s  ";
  SimpleGasTurbineABG.subsystemlist(3,:) = "comp ";
  SimpleGasTurbineABG.subsystemlist(4,:) = "turb ";
  SimpleGasTurbineABG.subsystemlist(5,:) = "Work ";
  SimpleGasTurbineABG.subsystemlist(6,:) = "Heat ";
  SimpleGasTurbineABG.subsystemlist(7,:) = "Speed";
  SimpleGasTurbineABG.subsystemlist(8,:) = "T3   ";
  SimpleGasTurbineABG.subsystemlist(9,:) = "in   ";
  SimpleGasTurbineABG.subsystemlist(10,:) = "out  ";
  SimpleGasTurbineABG.subsystemlist(11,:) = "mtt1 ";
  SimpleGasTurbineABG.subsystemlist(12,:) = "mtt2 ";
  SimpleGasTurbineABG.subsystemlist(13,:) = "mtt3 ";

# Bonds 
  SimpleGasTurbineABG.bonds = [
      0 0 
      1 1 
      0 0 
      -1 -1 
      -1 -1 
      0 0 
      0 0 
      1 1 
      -1 -1 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
# Explicit variable declarations
#VAR t_2
#VAR t_3
#VAR t_4
#VAR p_2
#VAR p_3
#VAR p_4
#VAR mdot
#VAR gamma_0
#VAR q_0
#VAR w_0
#VAR omega_0
#VAR r_p
#VAR c_p
#VAR mom_0
endfunction

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_desc.tex version [cfa31dba4b].




























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system SimpleGasTurbineABG (SimpleGasTurbineABG_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/05/18 15:45:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{SimpleGasTurbineABG} is
   displayed in Figure \Ref{SimpleGasTurbineABG_abg} and its label
   file is listed in Section \Ref{sec:SimpleGasTurbineABG_lbl}.
   The subsystems are listed in Section \Ref{sec:SimpleGasTurbineABG_sub}.
   
   \textbf{SimpleGasTurbineABG} can be regarded as an single-spool gas
   turbine (producing shaft power) with an ideal-gas working fluid. It
   corresponds to the simple Joule Cycle as described in Chapter 12 of
   Rogers and Mayhew and in Chapter 2 of Cohen, Rogers and
   Saravanamutto. However, unlike those examples, the system is
   written with dynamics in mind.
   
   The system is described using an energy Bond Graph- this ensures
   that the first law is observed. In particular transformers are used
   to explicitly convert between energy covariables. Although this is
   a simple model, I believe that it provides the basis for building
   complex thermodynamic systems involving gas power cycles.


There are five main components:
\begin{enumerate}
\item p1 -- a \textbf{Pump} component representing the compressor
  stage. This converts shaft work to energy flow in the working fluid.
\item c1 -- a \textbf{Comb} component representing the combustion
  chamber. This converts the heat obtained by burning fuel to energy
  flow in the working fluid.
\item t1 -- a \textbf{Turb} component representing the turbine
  component. This converts the energy flow in the working fluid to
  shaft work
\item j\_s -- an \textbf{I} component representing the combined inertia
  of the shaft and compressor and turbine rotors.
\item a \textbf{Load} component to absorb the shaft power.
\end{enumerate}
The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

Both \textbf{Pump} and \textbf{Turb} are implemented with the
\emph{polytropic} constitutive relationship with index $n$. When
$n=\gamma=\frac{c_p}{c_v}$ this corresponds to isentropic compression
and expansion and thus the \textbf{SimpleGasTurbineABG} achieves its
cycle efficiency. However, other values of $n$ can be used to account
for isentropic efficiency of less than unity.

To obtain a very simple dynamic model (and to avoid the need for an
accurate combustion chamber model) there are no dynamics associated
with the combustion chamber, but rahter it is assumed that the
corresponding temperature is imposed on the component (that is $T_3$
is the system input) the corresponding heat flow is then an output.

Both heat input and work output are measured using the \textbf{PS}
(power sensor) component, that for work output is embedded in the
\textbf{Load} component. These can be monitored to give the efficiency
of the \textbf{SimpleGasTurbineABG}.

A symbolic steady-state for the model was computed -- see Section
\ref{sec:SimpleGasTurbineABG_ss.tex}. In particular, the load
resistance was chosen to absorb all the generated work at the steady
state and the shaft inertia was chosen to give a unit time constant
for the linearised system. The mass flow and shaft speeds were taken
as unity.

For the purposed of simulation, the numerical values given in Examples
12.1 of Chapter 12 of Rogers and Mayhew, except that the isentropic
efficiencies are 100\% ($n=\gamma$) -- see Section
\ref{sec:SimpleGasTurbineABG_numpar.tex}.

Simulations were performed starting at the steady state and increasing
the combustion chamber temperature by 10\% at $t=1$ and reducing by
10\% at $t=5$. Graphs of the various outputs are plotted:
\begin{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-p1-T,SimpleGasTurbineABG-c1-T,SimpleGasTurbineABG-t1-T}
  -- the temperatures at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-Heat,SimpleGasTurbineABG-Work}
  -- the heat input and work output
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-Speed} -- the shaft speed and
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-p1-P,SimpleGasTurbineABG-c1-P,SimpleGasTurbineABG-t1-P}
  -- the pressure at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\end{itemize}

This model can be modified extended in various ways to yield related
dynamic systems. For example:
\begin{itemize}
\item an air cooler is obtained by changing the direction of heat and
  work flows
\item additional \textbf{Turb} and \textbf{Comb} components add reheat
  to the cycle
\item an isentropic nozzle can be added and the work output removed
  to give a jet engine.
\end{itemize}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_input.txt version [a6afb44f57].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (SimpleGasTurbineABG_input.txt)
# Generated by MTT at Tue Mar 31 12:38:39 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

t_3 = 1000;

# Set the inputs
u(1) =	 t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); # SimpleGasTurbineABG (T3)

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_numpar.txt version [9bfc3242f4].














































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (SimpleGasTurbine_numpar.txt)
# Generated by MTT at Tue Mar 31 12:15:00 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 16:55:29  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#Dummies
 alpha = 1;
 c_v = 1;
 density = 1;
 ideal_gas = 1;
 j_s = 1;
 k = 1;
 k_p = 1;
 m = 1;
 m_c = 1;
 p_1 = 1;
 r = 1;
 r_l = 1;
 t_1 = 1;
 v = 1;
 v_c = 1;


# Parameters
c_p = 	1005.0;
c_v = 	718.0; 
gamma_0 =  c_p/c_v;
alpha = (gamma_0-1)/gamma_0;
k = 	1.0;
p_1 = 	1e5; # 1 bar
p_4 = 	p_1; 
r = 	c_p-c_v;
t_1 = 	288.0; # In
v_c = 	1.0;

%Set the CC pressure and temperature
t_3 = 1000.0;
r_p = 6.0;
p_3 = r_p*p_1;

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c = (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 = p_1;
p_2 = p_3;

%Compute ss temperatures (isentropic)
t_2 = t_1*pow((p_2/p_1),alpha);
t_4 = t_3*pow((p_4/p_3),alpha);

%Find the steady-state work output
w_0 = c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Unit mass flow
mdot = 1;

%Corresponding shaft speed
omega_0 = mdot/k;

%Compute the corresponding load resistance (to absorb that work)
r_l = w_0/pow((omega_0),2);

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s = r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 =  omega_0*j_s;

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_rep.txt version [1fdcfffbf7].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system SimpleGasTurbineABG (SimpleGasTurbineABG_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 16:55:29  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%mtt -abg -o -ss SimpleGasTurbineABG abg tex
mtt -abg -o -ss SimpleGasTurbineABG struc tex
mtt -abg -o -ss SimpleGasTurbineABG sympar tex
mtt -abg -o -ss SimpleGasTurbineABG ode tex

mtt -abg -o -ss SimpleGasTurbineABG sspar r
mtt -abg -o -ss SimpleGasTurbineABG ss tex
mtt -abg -o -ss SimpleGasTurbineABG sm tex


mtt -abg -o -ss SimpleGasTurbineABG numpar tex
mtt -abg -o -ss SimpleGasTurbineABG input tex
mtt -abg -o -ss SimpleGasTurbineABG state tex
mtt -abg -o -ss SimpleGasTurbineABG simpar tex
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_p1_T,SimpleGasTurbineABG_c1_T,SimpleGasTurbineABG_t1_T'
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_Heat,SimpleGasTurbineABG_Work'
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_Speed'
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_p1_P,SimpleGasTurbineABG_c1_P,SimpleGasTurbineABG_t1_P'





Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_simp.r version [ca6f515178].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
%% Reduce commands to simplify output for system SimpleGasTurbineABG (SimpleGasTurbineABG_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LET c_v = c_p - r;
END;

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_sspar.r version [8d3c89c1a5].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (SimpleGasTurbineABG_sspar.r)
% Generated by MTT at Thu Mar 26 16:28:59 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c := (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 := p_1;
p_2 := p_3;

%Compute ss temperatures (isentropic)
t_2 := t_1*(p_2/p_1)^alpha;
t_4 := t_3*(p_4/p_3)^alpha;

%Find the steady-state work output
w_0 := c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Compute the corresponding load resistance (to absorb that work)
r_l := w_0/(omega_0)^2;

%Unit mass flow
mdot := 1;

%Corresponding shaft speed
omega_0 := mdot/k;

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s := r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 :=  omega_0*j_s;


% Steady-state states
MTTX1 := 	mom_0;

% Steady-state inputs - combustion temperature
MTTU1 := 	t_3; % SimpleGasTurbineABG (T3)

;;END;

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_state.txt version [ee6857149c].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (SimpleGasTurbineABG_state.txt)
# Generated by MTT at Tue Mar 31 12:37:17 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SimpleGasTurbineABG_numpar;

# Set the states
x(1) =	 j_s/k ; # SimpleGasTurbineABG (j_s)

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/hPipe_abg.m version [32f5edad6e].










































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [hPipe] =  hPipe_abg
# This function is the acausal bond graph representation of hPipe
# Generated by MTT on Thu Mar 16 10:33:07 2000
# The file is in Octave format

# Subsystems and Ports

# Port Heat
  hPipe.ports.Heat.type = "SS";
  hPipe.ports.Heat.cr = "SS";
  hPipe.ports.Heat.arg = "external,external";
  hPipe.ports.Heat.repetitions = 1;
  hPipe.ports.Heat.status = -1;
  hPipe.ports.Heat.connections = [-3 ];

# Port Hydraulic_in
  hPipe.ports.Hydraulic_in.type = "SS";
  hPipe.ports.Hydraulic_in.cr = "SS";
  hPipe.ports.Hydraulic_in.arg = "external,external";
  hPipe.ports.Hydraulic_in.repetitions = 1;
  hPipe.ports.Hydraulic_in.status = -1;
  hPipe.ports.Hydraulic_in.connections = [-5 ];

# Port Hydraulic_out
  hPipe.ports.Hydraulic_out.type = "SS";
  hPipe.ports.Hydraulic_out.cr = "SS";
  hPipe.ports.Hydraulic_out.arg = "external,external";
  hPipe.ports.Hydraulic_out.repetitions = 1;
  hPipe.ports.Hydraulic_out.status = -1;
  hPipe.ports.Hydraulic_out.connections = [6 ];

# Port Thermal_in
  hPipe.ports.Thermal_in.type = "SS";
  hPipe.ports.Thermal_in.cr = "SS";
  hPipe.ports.Thermal_in.arg = "external,external";
  hPipe.ports.Thermal_in.repetitions = 1;
  hPipe.ports.Thermal_in.status = -1;
  hPipe.ports.Thermal_in.connections = [-2 ];

# Port Thermal_out
  hPipe.ports.Thermal_out.type = "SS";
  hPipe.ports.Thermal_out.cr = "SS";
  hPipe.ports.Thermal_out.arg = "external,external";
  hPipe.ports.Thermal_out.repetitions = 1;
  hPipe.ports.Thermal_out.status = -1;
  hPipe.ports.Thermal_out.connections = [7 ];

# Component P2T
  hPipe.subsystems.P2T.type = "TF";
  hPipe.subsystems.P2T.cr = "lin";
  hPipe.subsystems.P2T.arg = "flow,r*m/v";
  hPipe.subsystems.P2T.repetitions = 1;
  hPipe.subsystems.P2T.status = -1;
  hPipe.subsystems.P2T.connections = [5 -1 ];

# Component T2P
  hPipe.subsystems.T2P.type = "TF";
  hPipe.subsystems.T2P.cr = "lin";
  hPipe.subsystems.T2P.arg = "effort,r*m/v";
  hPipe.subsystems.T2P.repetitions = 1;
  hPipe.subsystems.T2P.status = -1;
  hPipe.subsystems.T2P.connections = [4 -6 ];

# Component mtt1
  hPipe.subsystems.mtt1.type = "0";
  hPipe.subsystems.mtt1.cr = "";
  hPipe.subsystems.mtt1.arg = "";
  hPipe.subsystems.mtt1.repetitions = 1;
  hPipe.subsystems.mtt1.status = -1;
  hPipe.subsystems.mtt1.connections = [1 2 3 -4 -7 ];

# Ordered list of Port names
  hPipe.portlist(1,:) = "Heat         ";
  hPipe.portlist(2,:) = "Hydraulic_in ";
  hPipe.portlist(3,:) = "Hydraulic_out";
  hPipe.portlist(4,:) = "Thermal_in   ";
  hPipe.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  hPipe.subsystemlist(1,:) = "P2T ";
  hPipe.subsystemlist(2,:) = "T2P ";
  hPipe.subsystemlist(3,:) = "mtt1";

# Bonds 
  hPipe.bonds = [
      0 0 
      0 0 
      1 1 
      0 0 
      0 0 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
hPipe.alias.out = "Thermal_out,Hydraulic_out";
hPipe.alias.Hy_out = "Hydraulic_out";
hPipe.alias.Th_in = "Thermal_in";
hPipe.alias.r = "$3";
hPipe.alias.Th_out = "Thermal_out";
hPipe.alias.m = "$1";
hPipe.alias.v = "$2";
hPipe.alias.in = "Thermal_in,Hydraulic_in";
hPipe.alias.Hy_in = "Hydraulic_in";

Added mtt/lib/examples/ABG/SimpleGasTurbineABG/wPipe_abg.m version [b1c4a72c91].








































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [wPipe] =  wPipe_abg
# This function is the acausal bond graph representation of wPipe
# Generated by MTT on Thu Mar 16 10:37:39 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hydraulic_in
  wPipe.ports.Hydraulic_in.type = "SS";
  wPipe.ports.Hydraulic_in.cr = "SS";
  wPipe.ports.Hydraulic_in.arg = "external,external";
  wPipe.ports.Hydraulic_in.repetitions = 1;
  wPipe.ports.Hydraulic_in.status = -1;
  wPipe.ports.Hydraulic_in.connections = [-1 ];

# Port Hydraulic_out
  wPipe.ports.Hydraulic_out.type = "SS";
  wPipe.ports.Hydraulic_out.cr = "SS";
  wPipe.ports.Hydraulic_out.arg = "external,external";
  wPipe.ports.Hydraulic_out.repetitions = 1;
  wPipe.ports.Hydraulic_out.status = -1;
  wPipe.ports.Hydraulic_out.connections = [17 ];

# Port Shaft
  wPipe.ports.Shaft.type = "SS";
  wPipe.ports.Shaft.cr = "SS";
  wPipe.ports.Shaft.arg = "external,external";
  wPipe.ports.Shaft.repetitions = 1;
  wPipe.ports.Shaft.status = -1;
  wPipe.ports.Shaft.connections = [-20 ];

# Port Thermal_in
  wPipe.ports.Thermal_in.type = "SS";
  wPipe.ports.Thermal_in.cr = "SS";
  wPipe.ports.Thermal_in.arg = "external,external";
  wPipe.ports.Thermal_in.repetitions = 1;
  wPipe.ports.Thermal_in.status = -1;
  wPipe.ports.Thermal_in.connections = [-14 ];

# Port Thermal_out
  wPipe.ports.Thermal_out.type = "SS";
  wPipe.ports.Thermal_out.cr = "SS";
  wPipe.ports.Thermal_out.arg = "external,external";
  wPipe.ports.Thermal_out.repetitions = 1;
  wPipe.ports.Thermal_out.status = -1;
  wPipe.ports.Thermal_out.connections = [16 ];

# Component rho1
  wPipe.subsystems.rho1.type = "Density";
  wPipe.subsystems.rho1.cr = "none";
  wPipe.subsystems.rho1.arg = "density,ideal_gas,r";
  wPipe.subsystems.rho1.repetitions = 1;
  wPipe.subsystems.rho1.status = -1;
  wPipe.subsystems.rho1.connections = [4 3 -5 ];

# Component rho2
  wPipe.subsystems.rho2.type = "Density";
  wPipe.subsystems.rho2.cr = "none";
  wPipe.subsystems.rho2.arg = "density,ideal_gas,r";
  wPipe.subsystems.rho2.repetitions = 1;
  wPipe.subsystems.rho2.status = -1;
  wPipe.subsystems.rho2.connections = [12 11 -10 ];

# Component p2pv
  wPipe.subsystems.p2pv.type = "EMTF";
  wPipe.subsystems.p2pv.cr = "lin";
  wPipe.subsystems.p2pv.arg = "flow";
  wPipe.subsystems.p2pv.repetitions = 1;
  wPipe.subsystems.p2pv.status = -1;
  wPipe.subsystems.p2pv.connections = [2 -9 5 ];

# Component pv2p
  wPipe.subsystems.pv2p.type = "EMTF";
  wPipe.subsystems.pv2p.cr = "lin";
  wPipe.subsystems.pv2p.arg = "effort";
  wPipe.subsystems.pv2p.repetitions = 1;
  wPipe.subsystems.pv2p.status = -1;
  wPipe.subsystems.pv2p.connections = [7 -18 10 ];

# Component t2u
  wPipe.subsystems.t2u.type = "TF";
  wPipe.subsystems.t2u.cr = "lin";
  wPipe.subsystems.t2u.arg = "effort,c_v";
  wPipe.subsystems.t2u.repetitions = 1;
  wPipe.subsystems.t2u.status = -1;
  wPipe.subsystems.t2u.connections = [15 -6 ];

# Component u2t
  wPipe.subsystems.u2t.type = "TF";
  wPipe.subsystems.u2t.cr = "lin";
  wPipe.subsystems.u2t.arg = "flow,c_v";
  wPipe.subsystems.u2t.repetitions = 1;
  wPipe.subsystems.u2t.status = -1;
  wPipe.subsystems.u2t.connections = [8 -13 ];

# Component mtt1
  wPipe.subsystems.mtt1.type = "0";
  wPipe.subsystems.mtt1.cr = "";
  wPipe.subsystems.mtt1.arg = "";
  wPipe.subsystems.mtt1.repetitions = 1;
  wPipe.subsystems.mtt1.status = -1;
  wPipe.subsystems.mtt1.connections = [-3 14 -15 ];

# Component mtt2
  wPipe.subsystems.mtt2.type = "0";
  wPipe.subsystems.mtt2.cr = "";
  wPipe.subsystems.mtt2.arg = "";
  wPipe.subsystems.mtt2.repetitions = 1;
  wPipe.subsystems.mtt2.status = -1;
  wPipe.subsystems.mtt2.connections = [1 -2 -4 ];

# Component mtt3
  wPipe.subsystems.mtt3.type = "1";
  wPipe.subsystems.mtt3.cr = "";
  wPipe.subsystems.mtt3.arg = "";
  wPipe.subsystems.mtt3.repetitions = 1;
  wPipe.subsystems.mtt3.status = -1;
  wPipe.subsystems.mtt3.connections = [6 -7 -8 9 19 ];

# Component mtt4
  wPipe.subsystems.mtt4.type = "0";
  wPipe.subsystems.mtt4.cr = "";
  wPipe.subsystems.mtt4.arg = "";
  wPipe.subsystems.mtt4.repetitions = 1;
  wPipe.subsystems.mtt4.status = -1;
  wPipe.subsystems.mtt4.connections = [-11 13 -16 ];

# Component mtt5
  wPipe.subsystems.mtt5.type = "0";
  wPipe.subsystems.mtt5.cr = "";
  wPipe.subsystems.mtt5.arg = "";
  wPipe.subsystems.mtt5.repetitions = 1;
  wPipe.subsystems.mtt5.status = -1;
  wPipe.subsystems.mtt5.connections = [-12 -17 18 ];

# Component mtt6
  wPipe.subsystems.mtt6.type = "1";
  wPipe.subsystems.mtt6.cr = "";
  wPipe.subsystems.mtt6.arg = "";
  wPipe.subsystems.mtt6.repetitions = 1;
  wPipe.subsystems.mtt6.status = -1;
  wPipe.subsystems.mtt6.connections = [-19 20 ];

# Ordered list of Port names
  wPipe.portlist(1,:) = "Hydraulic_in ";
  wPipe.portlist(2,:) = "Hydraulic_out";
  wPipe.portlist(3,:) = "Shaft        ";
  wPipe.portlist(4,:) = "Thermal_in   ";
  wPipe.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  wPipe.subsystemlist(1,:) = "rho1";
  wPipe.subsystemlist(2,:) = "rho2";
  wPipe.subsystemlist(3,:) = "p2pv";
  wPipe.subsystemlist(4,:) = "pv2p";
  wPipe.subsystemlist(5,:) = "t2u ";
  wPipe.subsystemlist(6,:) = "u2t ";
  wPipe.subsystemlist(7,:) = "mtt1";
  wPipe.subsystemlist(8,:) = "mtt2";
  wPipe.subsystemlist(9,:) = "mtt3";
  wPipe.subsystemlist(10,:) = "mtt4";
  wPipe.subsystemlist(11,:) = "mtt5";
  wPipe.subsystemlist(12,:) = "mtt6";

# Bonds 
  wPipe.bonds = [
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      -1 -1 
      ];

# Aliases 
# A double underscore __ represents a comma 
wPipe.alias.out = "Thermal_out,Hydraulic_out";
wPipe.alias.Hy_out = "Hydraulic_out";
wPipe.alias.c_v = "$1";
wPipe.alias.Th_in = "Thermal_in";
wPipe.alias.Th_out = "Thermal_out";
wPipe.alias.Work = "Shaft";
wPipe.alias.in = "Thermal_in,Hydraulic_in";
wPipe.alias.Hy_in = "Hydraulic_in";
wPipe.alias.density__ideal_gas__r = "$2";

Added mtt/lib/examples/ABG/rcABG/rcABG_abg.m version [df1614e2f8].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [rc] =  rc_abg
# This function is the acausal bond graph representation of rc
# Generated by MTT on Thu Mar 16 08:45:29 2000
# The file is in Octave format

# Subsystems and Ports

# Component c
  rc.subsystems.c.type = "C";
  rc.subsystems.c.cr = "lin";
  rc.subsystems.c.arg = "effort,c";
  rc.subsystems.c.repetitions = 1;
  rc.subsystems.c.status = -1;
  rc.subsystems.c.connections = [5 ];

# Component r
  rc.subsystems.r.type = "R";
  rc.subsystems.r.cr = "lin";
  rc.subsystems.r.arg = "flow,r";
  rc.subsystems.r.repetitions = 1;
  rc.subsystems.r.status = -1;
  rc.subsystems.r.connections = [4 ];

# Component e1
  rc.subsystems.e1.type = "SS";
  rc.subsystems.e1.cr = "SS";
  rc.subsystems.e1.arg = "external,internal";
  rc.subsystems.e1.repetitions = 1;
  rc.subsystems.e1.status = -1;
  rc.subsystems.e1.connections = [-1 ];

# Component e2
  rc.subsystems.e2.type = "SS";
  rc.subsystems.e2.cr = "SS";
  rc.subsystems.e2.arg = "external,0";
  rc.subsystems.e2.repetitions = 1;
  rc.subsystems.e2.status = -1;
  rc.subsystems.e2.connections = [3 ];

# Component mtt1
  rc.subsystems.mtt1.type = "1";
  rc.subsystems.mtt1.cr = "";
  rc.subsystems.mtt1.arg = "";
  rc.subsystems.mtt1.repetitions = 1;
  rc.subsystems.mtt1.status = -1;
  rc.subsystems.mtt1.connections = [1 -2 -4 ];

# Component mtt2
  rc.subsystems.mtt2.type = "0";
  rc.subsystems.mtt2.cr = "";
  rc.subsystems.mtt2.arg = "";
  rc.subsystems.mtt2.repetitions = 1;
  rc.subsystems.mtt2.status = -1;
  rc.subsystems.mtt2.connections = [2 -3 -5 ];

# Ordered list of subsystem names
  rc.subsystemlist(1,:) = "c   ";
  rc.subsystemlist(2,:) = "r   ";
  rc.subsystemlist(3,:) = "e1  ";
  rc.subsystemlist(4,:) = "e2  ";
  rc.subsystemlist(5,:) = "mtt1";
  rc.subsystemlist(6,:) = "mtt2";

# Bonds 
  rc.bonds = [
      1 1 
      0 0 
      1 1 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
rc.alias.r = "$2";
rc.alias.c = "$1";

Added mtt/lib/examples/ABG/rcABG/rcABG_rep.txt version [55de203c56].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% %% Outline report file for system rcABG (rcABG_rep.txt)
mtt rcABG struc tex
mtt rcABG ode tex
mtt rcABG sm tex
mtt rcABG tf tex
mtt rcABG sro ps
mtt rcABG lmfr ps
mtt rcABG nyfr ps

mtt rcABG numpar txt
mtt rcABG input txt
mtt rcABG odeso ps
mtt rcABG rep txt


Added mtt/lib/examples/AlgebraicLoops/aRC/aRC_abg.fig version [d59bd2ce5c].



















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 4680 630 6570 1620
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4725 1215 5175 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4725 1080 5175 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4950 675 4950 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4950 1215 4950 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 6075 1530 6075 765
4 0 1 1 0 0 20 0.0000 4 180 165 5355 1215 c\001
4 0 1 1 0 0 20 0.0000 4 180 165 6300 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 6390 1305 2\001
-6
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 4500 2925 5400 3150 5175
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 6075 6750 225 675 225 675 6075 6750 6075
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 3600 585 4500 585 4500 765 3600 765 3600 585
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 3600 675
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 2
	 4500 675 5850 675
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 2
	 1755 1575 5850 1575
2 1 0 2 4 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1935 5040 2160 5265
2 1 0 2 4 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2070 5130 2706 4494 2706 4812
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 255 825 5987 4367 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 330 825 2926 2926 R:r_1\001
4 1 -1 0 0 0 20 0.0000 4 255 495 4276 2926 C:c\001
4 1 -1 0 0 0 20 0.0000 4 255 825 1395 4365 SS:e1\001
4 0 1 1 0 0 20 0.0000 4 330 495 2880 450 r_1\001
4 0 1 1 0 0 20 0.0000 4 180 165 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 255 1545 3600 2025 Schematic\001
4 1 1 1 0 0 20 0.0000 4 330 1725 4860 4860 Bond graph\001
4 1 -1 0 0 0 20 0.0000 4 330 825 3015 5715 R:r_2\001
4 0 1 1 0 0 20 0.0000 4 330 495 3870 450 r_2\001
4 1 -1 0 0 0 20 0.0000 4 330 1110 1755 5535 SS:loop\001

Added mtt/lib/examples/AlgebraicLoops/aRC/aRC_desc.tex version [e70a959805].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system aRC (aRC_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:02:29  peterg
% %% To RCS
% %%
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{aRC} is
   displayed in Figure \Ref{aRC_abg} and its label
   file is listed in Section \Ref{sec:aRC_lbl}.
   The subsystems are listed in Section \Ref{sec:aRC_sub}.

The system \textbf{aRC} is the simple electrical rc circuit shown in
Figure \Ref{aRC_abg}. It can be regarded as a single-input
single-output system with input $e_1$ and output $e_2$.

The two resistors ($r_1$ and $r_2$) are in series; this give an
undercausal system with a corresponding algebraic loop. The loop is
broken by adding the {\bf SS} component ``loop'' to localise the
algabraic equation byh choosing the corresponding flow such that the
corresponding effort is zero. This algebraic equation appears in
Section \Ref{sec:aRC_dae-noargs.tex}.

This loop is algbraicly solved to give the ordinary differential
equation of Section \Ref{sec:aRC_ode-A.tex} and the transfer function of
Section \Ref{sec:aRC_tf-A.tex}.

Added mtt/lib/examples/AlgebraicLoops/aRC/aRC_lbl.txt version [b09da23797].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY aRC: Simple RC circuit example with algebraic loop

%% Label file for system aRC (aRC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/20 16:03:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/05/12  15:11:47  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/04/18  13:27:54  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/04/18  13:20:13  peterg
% %% Initial revision
% %% Revision 1.1  1996/09/10 11:37:14  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Source - effort source (e1) flow ignored
e1	SS external,internal

% Sensor - effort sensor (e2)	zero flow
e2	SS external,0

% R component - linear with resistance r (effort = r*flow)
r_1	lin	flow,r_1
r_2	lin	flow,r_2

% C component - linear with capacitance c (state = c*effort)
c	lin	effort,c

% Algebraic loop SS
loop	SS      zero,unknown



Added mtt/lib/examples/AlgebraicLoops/aRC/aRC_rep.txt version [ce544498bf].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system aRC (aRC_rep.txt)
## Generated by MTT on" Fri Oct 15 14:56:13 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:02:29  peterg
## To RCS
##
###############################################################

mtt aRC abg tex			# The system description
mtt aRC cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt aRC struc tex	        # The system structure
mtt aRC dae tex			# The system dae
mtt -A aRC ode tex	        # The system ode 
## mtt aRC sspar tex		# Steady-state parameters
## mtt aRC ss tex 		# Steady state
## mtt aRC dm tex		# Descriptor matrices (of linearised system)
## mtt aRC sm tex		# State matrices (of linearised system)
mtt -A aRC tf tex		# Transfer function (of linearised system)
## mtt aRC lmfr ps		# log modulus of frequency response (of linearised system)
## mtt aRC simpar tex		# Simulation parameters
## mtt aRC numpar tex		# Numerical simulation parameters
## mtt aRC input tex		# Simulation input
## mtt aRC odeso ps		# Simulation output

Added mtt/lib/examples/AlgebraicLoops/aRC/aRC_sspar.r version [c42ae262e6].



1
2
+
+
%% Reduce steady-state parameter file for aRC (aRC_sspar.r) cat /home/peter/mtt_new/mtt/trans/m/aRCs_header.txt
END;

Added mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_abg.fig version [7c16f519c4].




































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Inches
1200 2
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4201 7186 4201 6451 4336 6631
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4201 4801 4201 4066 4336 4246
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4276 7201 4801 6901 4651 6901
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9901 6151 10576 6151 10426 6001
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9901 5026 10576 5026 10426 4876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4501 6226 5176 6226 5026 6076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4501 5026 5176 5026 5026 4876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9601 5266 9601 6001 9466 5821
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9901 3901 10576 3901 10426 3751
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4501 3901 5176 3901 5026 3751
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5401 1876 5701 1876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5551 1201 5551 1876 5401 1726
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5926 1951 5926 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4051 3601 4351 3601
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4501 1951 4501 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 7351 1951 7351 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4201 3601 6751 2326 6451 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7051 2251 9526 3676 9526 3376
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5251 2101 4501 2101 4651 1951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5926 2101 6601 2101 6451 1951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7351 2101 8026 2101 7876 1951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 9376 3676 9676 3676
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 11341 8491 12076 8356 11896
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5491 14941 5491 15676 5356 15496
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5401 8401 5701 8401
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5371 10246 5671 10246
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5326 12076 5626 12076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5326 13876 5626 13876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5326 15676 5626 15676
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 15676 8626 15676
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 13876 8626 13876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 12076 8626 12076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 10276 8626 10276
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 8401 8626 8401
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 14926 7201 14926
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 13126 7201 13126
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 11326 7201 11326
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 9526 7201 9526
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 7651 7201 7651
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 14941 7021 15676 6901 15496
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 13141 7021 13876 6901 13696
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 11341 7021 12076 6901 11896
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 9541 7021 10276 6901 10096
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7051 7651 7051 8386 6931 8206
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 11101 8776 10951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 12901 8776 12751
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 14701 8776 14551
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8476 7651 8476 8386 8341 8206
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 9541 8491 10276 8356 10096
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 13141 8491 13876 8356 13696
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 14941 8491 15676 8356 15496
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5551 7651 5551 8386 5416 8206
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5536 9496 5536 10231 5401 10051
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5491 11341 5491 12076 5356 11896
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5491 13141 5491 13876 5356 13696
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7051 1876 7501 1501 7501 1726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 7501 7801 8101 7651 8101
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 9301 7801 9901 7651 9901
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 11101 7801 11701 7651 11701
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 12901 7801 13501 7651 13501
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 14701 7801 15301 7651 15301
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 4051 9601 4351 9526 4276
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 4576 9601 4876 9526 4801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 6376 9601 6676 9526 6601
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 7051 9601 7351 9526 7276
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 5476 4201 5176 4276 5251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 6076 4201 5776 4276 5851
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 9303 7878 9303 7953 9378
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 9303 7278 9303 7353 9378
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 9152 8177 9452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 11103 7878 11103 7953 11178
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 11103 7278 11103 7353 11178
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 10952 8177 11252
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 12903 7878 12903 7953 12978
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 12903 7278 12903 7353 12978
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 12752 8177 13052
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 14703 7878 14703 7953 14778
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 14703 7278 14703 7353 14778
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 14552 8177 14852
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 14701 5926 14701 6076 14851
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 12901 5926 12901 6076 13051
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 11101 5926 11101 6076 11251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 9301 5926 9301 6076 9451
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 7501 5926 7501 6076 7651
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8776 7501 8971 7636
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 9301 8776 9076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9742 7410 10267 7110 10117 7110
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 7501 7801 7501 7876 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7501 7501 7201 7501 7276 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5102 9302 4802 9302 4877 9377
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5103 11103 4803 11103 4878 11178
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5028 12903 4728 12903 4803 12978
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5028 14703 4728 14703 4803 14778
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 9301 4201 7501 4351 7801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4051 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 3976 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4051 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4426 11101 4051 7576 4201 7801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4426 12901 3901 7576 3976 7726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4426 14701 3676 7501 3826 7801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5177 7502 4877 7502 4952 7577
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4577 7502 4277 7502 4352 7577
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 8700 9000 7050 6600 7050 6600 8700 9000 8700
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 12300 9000 10650 6600 10650 6600 12300 9000 12300
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 14175 9000 12525 6600 12525 6600 14175 9000 14175
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 15975 9000 14325 6600 14325 6600 15975 9000 15975
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 10500 9000 8850 6600 8850 6600 10500 9000 10500
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13800 16125 300 16125 300 600 13800 600 13800 16125
4 0 0 0 0 0 12 0.0000000 4 180 495 10276 7051 C:apc2\001
4 0 0 0 0 0 12 0.0000000 4 180 510 4876 7051 C:vpc2\001
4 0 0 0 0 0 12 0.0000000 4 180 495 10651 5101 C:apc1\001
4 0 0 0 0 0 12 0.0000000 4 180 480 10651 6226 R:apr2\001
4 0 0 0 0 0 12 0.0000000 4 180 480 10651 4051 R:apr1\001
4 0 0 0 0 0 12 0.0000000 4 180 510 5251 5101 C:vpc1\001
4 0 0 0 0 0 12 0.0000000 4 180 495 5251 6301 R:vpr2\001
4 1 0 0 0 0 12 0.0000000 4 180 495 5551 3976 R:vpr1\001
4 1 0 0 0 0 12 0.0000000 4 180 390 9601 6301 1:ap3\001
4 1 0 0 0 0 12 0.0000000 4 180 405 4201 6301 1:vp3\001
4 1 0 0 0 0 12 0.0000000 4 180 390 9601 5101 0:ap2\001
4 1 0 0 0 0 12 0.0000000 4 180 405 4126 5101 0:vp2\001
4 1 0 0 0 0 12 0.0000000 4 180 390 9526 3976 1:ap1\001
4 1 0 0 0 0 12 0.0000000 4 180 405 4126 3976 1:vp1\001
4 0 0 0 0 0 12 0.0000000 4 180 420 7576 1576 SS:ye\001
4 0 0 0 0 0 12 0.0000000 4 135 390 5326 1201 SS:t0\001
4 1 0 0 0 0 12 0.0000000 4 135 270 4201 2176 R:ri\001
4 1 0 0 0 0 12 0.0000000 4 135 240 5551 2176 1:fi\001
4 1 0 0 0 0 12 0.0000000 4 135 225 7051 2176 0:ti\001
4 1 0 0 0 0 12 0.0000000 4 135 285 8401 2176 C:ci\001
4 0 0 0 0 0 12 0.0000000 4 135 345 8251 14776 1:fsa\001
4 0 0 0 0 0 12 0.0000000 4 135 330 8251 12976 1:ffa\001
4 0 0 0 0 0 12 0.0000000 4 135 315 8251 11176 1:fla\001
4 0 0 0 0 0 12 0.0000000 4 135 360 8251 9376 1:fva\001
4 0 0 0 0 0 12 0.0000000 4 135 360 8251 7576 1:fba\001
4 0 0 0 0 0 12 0.0000000 4 135 360 5251 14776 1:fsv\001
4 0 0 0 0 0 12 0.0000000 4 135 345 5251 12976 1:ffv\001
4 0 0 0 0 0 12 0.0000000 4 135 330 5251 11176 1:flv\001
4 0 0 0 0 0 12 0.0000000 4 135 375 5251 9376 1:fvv\001
4 0 0 0 0 0 12 0.0000000 4 180 345 9601 7576 0:tap\001
4 1 0 0 0 0 12 0.0000000 4 135 390 5476 15901 R:rs1\001
4 1 0 0 0 0 12 0.0000000 4 135 405 5551 10501 R:rv1\001
4 1 0 0 0 0 12 0.0000000 4 135 405 5551 8626 R:rb1\001
4 0 0 0 0 0 12 0.0000000 4 180 420 7501 15601 SS:ys\001
4 0 0 0 0 0 12 0.0000000 4 180 405 7501 13801 SS:yf\001
4 1 0 0 0 0 12 0.0000000 4 180 390 7726 12001 SS:yl\001
4 1 0 0 0 0 12 0.0000000 4 180 435 7801 10201 SS:yv\001
4 1 0 0 0 0 12 0.0000000 4 180 435 7801 8326 SS:yb\001
4 1 0 0 0 0 12 0.0000000 4 135 390 8476 15901 R:rs2\001
4 1 0 0 0 0 12 0.0000000 4 135 405 8476 10501 R:rv2\001
4 1 0 0 0 0 12 0.0000000 4 135 405 8476 8626 R:rb2\001
4 1 0 0 0 0 12 0.0000000 4 135 315 6976 15901 C:cs\001
4 1 0 0 0 0 12 0.0000000 4 135 300 7051 14101 C:cf\001
4 1 0 0 0 0 12 0.0000000 4 135 285 6976 12376 C:cl\001
4 1 0 0 0 0 12 0.0000000 4 135 330 6976 10501 C:cv\001
4 1 0 0 0 0 12 0.0000000 4 135 330 7051 8626 C:cb\001
4 1 0 0 0 0 12 0.0000000 4 135 255 7051 14776 0:ts\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7051 12976 0:tf\001
4 1 0 0 0 0 12 0.0000000 4 135 225 7051 11176 0:tl\001
4 1 0 0 0 0 12 0.0000000 4 135 270 7051 9376 0:tv\001
4 1 0 0 0 0 12 0.0000000 4 135 270 7051 7576 0:tb\001
4 1 0 0 0 0 12 0.0000000 4 135 360 8476 12376 R:rl1\001
4 1 0 0 0 0 12 0.0000000 4 135 375 8476 14101 R:rf1\001
4 1 0 0 0 0 12 0.0000000 4 135 360 5476 12376 R:rl2\001
4 1 0 0 0 0 12 0.0000000 4 135 375 5476 14101 R:rf2\001
4 1 0 0 0 0 12 0.0000000 4 135 240 9601 4501 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 9601 6901 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4201 5701 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 9378 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 11178 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 12978 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 14778 AF\001
4 0 0 0 0 0 12 0.0000000 4 135 375 5251 7576 1:fbv\001
4 2 0 0 0 0 12 0.0000000 4 180 360 4126 7501 0:tvp\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7651 7576 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4652 9377 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4653 11178 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4578 12978 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4578 14778 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4727 7577 AF\001

Added mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_desc.tex version [d9550f793f].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system MaplesonModelP (MaplesonModelP_desc.tex)
% Generated by MTT on Wed Dec 10 09:04:14 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MaplesonModelP} is
   displayed in Figure \Ref{MaplesonModelP_abg} and its label
   file is listed in Section \Ref{sec:MaplesonModelP_lbl}.
   The subsystems are listed in Section \Ref{sec:MaplesonModelP_sub}.

This is a Bond Graph interpretation of Mapleson's model P of the
pharmokokinetics of anaesthetic drug delivery. It is discussed in
detail in Chapter 9 of ``Metamodelling''.

It badly needs conversion to hierarchical form.


%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_input.txt version [e19c71456b].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System MaplesonModelP, representation input, language txt; 
## File MaplesonModelP_input.txt; 
## Generated by MTT on Fri Nov 10 10:45:52 GMT 2000; 


MaplesonModelP__t0	= 0.75*760*(t<2); #75% atmospheric pressure for 2 sec.

Added mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_lbl.txt version [30211b8f11].








































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY MaplesonModelP: Pharmokinetic model from section 9.6 of"Metamodelling"
#DESCRIPTION Detailed model with pools
#DESCRIPTION
#DESCRIPTION Note that the bond graph has been redrawn to replace active bonds with
#DESCRIPTION AF components.
#DESCRIPTION This would be much neater using a heirachical model.
#DESCRIPTION 
#DESCRIPTION The following commands make the figures.
#DESCRIPTION 
#DESCRIPTION Fig 9.17	mtt MaplesonModelP abg view
#DESCRIPTION Figs 9.18-19	mtt MaplesonModelP odeso view 'T=[0:0.1:6]'
#DESCRIPTION Fig 9.20	mtt MaplesonModelP lmfr view 'W=logspace(-2,2,100)'
#DESCRIPTION Fig 9.21	mtt MaplesonModelP lpfr view 'W=logspace(-2,2,100)'


# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  1996/08/30  18:37:56  peter
# ## Initial revision
# ##
# ###############################################################

#VAR apools
#VAR breathing_interval
#VAR heart_interval
#VAR k_ap
#VAR k_b
#VAR k_f
#VAR k_i
#VAR k_l
#VAR k_s
#VAR k_v
#VAR k_vp
#VAR kb
#VAR kf
#VAR kl
#VAR ks
#VAR kv
#VAR lambdab
#VAR lambdablood
#VAR lambdaf
#VAR lambdal
#VAR lambdalung
#VAR lambdav
#VAR stroke_volume
#VAR t_1
#VAR t_2
#VAR t_b
#VAR t_f
#VAR t_i
#VAR t_l
#VAR t_s
#VAR t_v
#VAR v_i
#VAR vap
#VAR varterial
#VAR vb
#VAR vbp
#VAR vf
#VAR vfp
#VAR vgas
#VAR vl
#VAR vlp
#VAR vlung
#VAR vplung
#VAR vpools
#VAR vsp
#VAR vv
#VAR vvenous
#VAR vvp

### Common tension junctions ###
ti
tb
tv
tl
tf
ts
tap
tvp

##Common flow junctions - inspiration ###
fi

##Common flow junctions - arteries ###
fba
fva
fla
ffa
fsa

##Common flow junctions - veins ###
fbv
fvv
flv
ffv
fsv

## More junctions
ap3
vp3
ap2
vp2
ap1
vp1

### Resistances ###
rb1	lin	flow,r_b
rv1	lin	flow,r_v
rl1	lin	flow,r_l
rf1	lin	flow,r_f
rs1	lin	flow,r_s

rb2	lin	flow,r_b
rv2	lin	flow,r_v
rl2	lin	flow,r_l
rf2	lin	flow,r_f
rs2	lin	flow,r_s

ri	lin	flow,r_i

## Capacities ###
cb	lin	effort,c_b
cv	lin	effort,c_v
cl	lin	effort,c_l
cf	lin	effort,c_f
cs	lin	effort,c_s
ci	lin	effort,c_i


### Input ###
t0	SS  external,internal

### Outputs ###
yb	SS  external,0	
yv	SS  external,0	
yl	SS  external,0	
yf	SS  external,0	
ys	SS  external,0	
ye	SS  external,0	

### Arterial pool
# ap1	apool1
# ap2	apool2
# ap3	apool3

apc1	lin	effort,c_ap
apc2	lin	effort,c_ap

apr1	lin	flow,r_ap
apr2	lin	flow,r_ap


### Venous pool
# vp1	vpool1
# vp2	vpool2
# vp3	vpool3

vpc1	lin	effort,c_vp
vpc2	lin	effort,c_vp
vpr1	lin	flow,r_vp
vpr2	lin	flow,r_vp


Added mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_numpar.txt version [3482181f7e].






























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (MaplesonModelP_numpar.txt)
# Generated by MTT at Mon Aug 11 14:45:13 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters

# Modified 17/11/93 to correspond to Mapleson's 1973 paper. 
# Like model O except that blood has its own pools distinct form the tissues. 


Heart_interval = 1.0/60.0;
Breathing_interval = 4*Heart_interval;
Stroke_volume = 0.108;
lambdaBlood = 0.46;
vArterial = 1.4;
vVenous = 4.0;

# %%%%%%%%%%%%%%%%%% Inspiration %%%%%%%%%%%%%%%%%%%%%%%%%%%
v_i = 0.4;
r_i = Breathing_interval/v_i;

# %%%%%%%%%%%%%%%%%% Lung %%%%%%%%%%%%%%%%%%%%%%%%%%% 
vLung = 0.6;
vPLung =  0;
vGas = 2.5;
lambdaLung = 0.46;

c_i = lambdaLung*(vLung + vPLung) + vGas;
t_i = r_i*c_i;
# %%%%%%%%%%%%%%%%%% Brain %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kB = 0.000086;

vB = 0.0007;
vBP = 0.0;

lambdaB = 0.46;

c_b = lambdaB*vB + lambdaBlood*vBP;
r_b = Heart_interval/(kB*lambdaBlood*Stroke_volume);
t_b = r_b*c_b;

# %%%%%%%%%%%%%%%%%% Viscera %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kV = 0.63;

vV = 6.2;
lambdaV = 0.46;
vVP = 0;

c_v = lambdaV*vV + lambdaBlood*vVP;
r_v = Heart_interval/(kV*lambdaBlood*Stroke_volume);
t_v = r_v*c_v;

# %%%%%%%%%%%%%%%%%% Lean %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kL = 0.131;

vL = 39.2;
lambdaL = 0.46;
vLP = 0;

c_l = lambdaL*vL + lambdaBlood*vLP;
r_l = Heart_interval/(kL*lambdaBlood*Stroke_volume);
t_l = r_l*c_l;

# %%%%%%%%%%%%%%%%%% Fat %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kF = 0.04;

vF = 12.2;
lambdaF = 1.40;
vFP = 0;

c_f = lambdaF*vF + lambdaBlood*(vFP);
r_f = Heart_interval/(kF*lambdaBlood*Stroke_volume);
t_f = r_f*c_f;

# %%%%%%%%%%%%%%%%%% Shunt %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kS = 0.199;

vSP = 0.126*vVenous;

c_s = lambdaBlood*(vSP);
r_s = Heart_interval/(kS*lambdaBlood*Stroke_volume);
t_s = r_s*c_s;

# %%%%%%%%%%%%%%%%%% Time constants %%%%%%%%%%%%%%%%%%%%%%%%%%% 
t_1 = t_b*t_v*t_l*t_f*t_s;
t_2 = t_1*t_i;


# %%%%%%%%%%%%%%%%%% Convert from rs to ks %%%%%%%%%%%%%%%%%%%% 

k_b = 1/r_b;
k_v = 1/r_v;
k_l = 1/r_l;
k_f = 1/r_f;
k_s = 1/r_s;
k_i = 1/r_i;

# %%%%%%%%%%%%%%%%%% Arterial pools %%%%%%%%%%%%%%%%%%%%%%%%%%% 
# Two pool version 
aPools = 2;

vAP = vArterial;

c_ap = lambdaBlood*(vAP)/aPools;
r_ap  = Heart_interval/(lambdaBlood*Stroke_volume);

# %%%%%%%%%%%%%%%%%% Venous pools %%%%%%%%%%%%%%%%%%%%%%%%%%% 
# Two pool version 
vPools = 2;

vVP = vVenous - vSP;

c_vp = lambdaBlood*(vVP)/vPools;
r_vp  = Heart_interval/(lambdaBlood*Stroke_volume);

k_ap = 1/r_ap;
k_vp = 1/r_vp;


Added mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_rep.txt version [88420fc7c7].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system MaplesonModelP (MaplesonModelP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/02/17 01:46:48  peterg
% %% Included simpar rep.
% %%
% %% Revision 1.1  1999/02/17 00:08:06  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt MaplesonModelP abg tex
mtt MaplesonModelP struc tex
mtt MaplesonModelP ode tex
mtt MaplesonModelP sm tex
mtt MaplesonModelP lmfr ps

mtt MaplesonModelP simpar txt
mtt MaplesonModelP numpar txt
mtt MaplesonModelP input txt
mtt MaplesonModelP odeso ps

Added mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_simpar.txt version [3858c22495].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system MaplesonModelP (MaplesonModelP_simpar.txt)
# Generated by MTT on Fri Nov 10 11:37:00 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Chemical/Reactor/MakeFigure.m version [bcab2a5c23].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


par = Reactor_numpar;		# Parameters
sym = Reactor_sympar;		# Parameter indices

F_s= [90:10:500];		# Range of flows

Z_a = []; Z_b = []; P = [];
for f_s=F_s
  par(sym.f_s) = f_s;
  [A,B,C,D] = Reactor_sm(par);	# Linearised system

  p = sort(eig(A));
  P = [P p];

  C_a = C([1 3],:);		# C vector for c_a and t
  D_a = D([1 3],:);		# D vector for c_a and t
  z_a = tzero(A,B,C_a,D_a);	# Transmission zeros for c_a and t
  Z_a = [Z_a z_a];

  C_b = C(2:3,:);		# C vector for c_b and t
  D_b = D(2:3,:);		# D vector for c_b and t
  z_b = tzero(A,B,C_b,D_b);	# Transmission zeros for c_b and t
  Z_b = [Z_b z_b];
endfor

grid; xlabel("f_s"); ylabel("p1,p2");
plot(F_s,P(1:2,:));
psfig("Reactor_pole_1_2");

grid; xlabel("f_s"); ylabel("p3");
plot(F_s,P(3,:));
psfig("Reactor_pole_3");

grid; xlabel("f_s"); ylabel("z_a");
plot(F_s,Z_a);
psfig("Reactor_zero_a");

grid; xlabel("f_s"); ylabel("z_b");
plot(F_s,Z_b);
psfig("Reactor_zero_b");

Added mtt/lib/examples/Chemical/Reactor/Makefile version [97d3b40e97].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
## Makes the schematic diagram and the (trasmission) zero figure
all: Reactor_pic.ps Reactor_zero_b.ps

Reactor_pic.ps: Reactor_pic.fig
	fig2dev -Lps Reactor_pic.fig> Reactor_pic.ps

Reactor_zero_b.ps: Reactor_abg.fig
	mtt -q Reactor sm m
	mtt -q Reactor numpar m;
	mtt -q Reactor sympar m;
	octave MakeFigure.m


Added mtt/lib/examples/Chemical/Reactor/Reactor_abg.fig version [f1af6b8b3a].










































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3001 8701 3001 7801 3151 7951
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1801 9001 2701 9001 2551 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 8776 2701 9226
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3301 9001 4201 9001 4051 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 9301 3601 9901 3826 9901
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5701 9001 4801 9001 4951 9151
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 6000 2700 6000 2550 6150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 10350 5025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6000 1800 5775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6225 1800 6000
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 10200 600 10200 600 7500 11100 7500 11100 10200
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 6600 600 6600 600 5400 11100 5400 11100 6600
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5700 8775 5700 9225
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4425 9300 3975 9300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4800 4500 8700 4650 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6000 4800 4800 8700 5025 8625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4800 5100 8700 5400 8700
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4800 4275 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4200 4275 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4800 5775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4200 5775 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4800 8775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4200 8775 4200
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 7200 3000 6300 3150 6450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10500 4800 3300 6000 3525 6075
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 5100 600 5100 600 3300 11100 3300 11100 5100
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4485 2395 4485 4130 4633 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 2999 2395 2999 4130 3148 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5970 2395 5970 4130 6119 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 10428 2397 10428 4132 10577 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8943 2397 8943 4132 9091 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 2100 2700 2100 2550 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3300 2100 4200 2100 4050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4800 2100 5700 2100 5550 2250
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4200 1800 3600 1200 3600 1425
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 1875 2700 2325
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 8701 1801 8101 1201 8101 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9301 2101 10201 2101 10051 2251
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6300 2100 7200 2100 7050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7800 2100 8700 2100 8550 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1950 4350 1650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 1950 8850 1650
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 300 600 300 600 2700 11100 2700 11100 300
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 4800 3000 5700 3150 5550
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 9301 1801 9901 1201 9901 1426
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10050 1350 9900 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 1200 9750 1050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4801 1801 5401 1201 5401 1426
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5550 1350 5400 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5400 1200 5250 1050
4 1 0 0 0 0 20 0.0000 4 195 1065 3075 4575 FMR:rfa\001
4 1 0 0 0 0 20 0.0000 4 195 1065 4575 4575 Rate:AD\001
4 1 0 0 0 0 20 0.0000 4 195 1050 6000 4575 Rate:AB\001
4 2 0 0 0 0 20 0.0000 4 255 810 1651 9076 SS:t_0\001
4 2 0 0 0 0 20 0.0000 4 255 690 3451 9976 C:h_r\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 6075 1\001
4 2 0 0 0 0 20 0.0000 4 210 525 1725 6075 SS:f\001
4 1 0 0 0 0 20 0.0000 4 195 150 3001 9076 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4501 9076 0\001
4 1 0 0 0 0 20 0.0000 4 195 1035 9001 4576 Rate:BC\001
4 1 0 0 0 0 20 0.0000 4 210 1080 10576 4576 FMR:rfb\001
4 1 1 1 0 3 20 0.0000 4 195 2595 9600 7800 THERMAL MODEL\001
4 1 1 1 0 3 20 0.0000 4 195 2865 9450 5700 HYDRAULIC MODEL\001
4 1 0 0 0 0 20 0.0000 4 195 915 3000 7575 FMR:rt\001
4 2 0 0 0 0 20 0.0000 4 255 855 1650 2175 SS:c_0\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4500 2175 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 6000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 9001 2176 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 10501 2176 1\001
4 1 0 0 0 0 20 0.0000 4 195 375 7500 2175 AF\001
4 1 0 0 0 0 20 0.0000 4 255 825 8100 1050 C:m_b\001
4 1 0 0 0 0 20 0.0000 4 240 810 3600 1050 C:m_a\001
4 1 1 1 0 3 20 0.0000 4 195 3645 9075 600 CONCENTRATION MODEL\001
4 1 0 0 0 0 20 0.0000 4 210 510 6151 9076 SS:t\001
4 1 0 0 0 0 20 0.0000 4 255 855 9975 1050 SS:c_b\001
4 1 0 0 0 0 20 0.0000 4 255 840 5475 1050 SS:c_a\001
4 1 1 1 0 3 20 0.0000 4 195 2640 9675 3750 REACTION MODEL\001

Added mtt/lib/examples/Chemical/Reactor/Reactor_desc.tex version [b3d301e887].































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Reactor (Reactor_desc.tex)
% Generated by MTT on Fri Mar 3 12:43:33 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{Reactor_pic}
{Reactor_pic} {0.9} {System \textbf{Reactor}, Schematic}

Figure \Ref{fig:Reactor_pic} is the schematic diagram od a chemical reactor.
The acausal bond graph of system \textbf{Reactor} is displayed in
Figure \Ref{fig:Reactor_abg.ps} and its label file is listed in
Section \Ref{sec:Reactor_lbl}.  The subsystems are listed in Section
\Ref{sec:Reactor_sub}.

This example of a (nonlinear) chemical reactor is due to Trickett and
Bogle\footnote{ K. J. Tricket, \emph{Quantification of Inverse
    Responses for Controllability Assessment of Nonlinear Processes},
  PhD Thesis, University College London, 1994} is used in this
section.  The reactor has two reaction mechanisms: $\text{A}
\rightarrow \text{B} \rightarrow \text{C}$ and $\text{2A} \rightarrow
\text{D}$.  The reactor mass inflow and outflow $f_r$ are identical.
$q$ represents the heat inflow to the reactor.

This is a two input, two-output unstable nonlinear system with unstable zero
dynamics.
The following figures illustrate the properties of the
\emph{linearised} system.

\fig{Reactor_pole_1_2}
{Reactor_pole_1_2} {0.9} {System \textbf{Reactor}: poles 1 and 2
  v. steady-state flow $f_s$}

\fig{Reactor_pole_3}
{Reactor_pole_3} {0.9} {System \textbf{Reactor}: pole 3
  v. steady-state flow $f_s$}

\fig{Reactor_zero_a}
{Reactor_zero_a} {0.9} {System \textbf{Reactor}: zero of system with
  $t$ and $c_a$ as output
  v. steady-state flow $f_s$}

\fig{Reactor_zero_b}
{Reactor_zero_b} {0.9} {System \textbf{Reactor}: pole 3
  v. steady-state flow $f_s$}

\begin{itemize}
\item Figures \Ref{fig:Reactor_pole_1_2} and
  \Ref{fig:Reactor_pole_3} show the three poles of the
  \emph{linearised} system as the steady-state flow varies. 
\item Figure \Ref{fig:Reactor_zero_a} shows the system zero (when $t$ and
  $c_a$ are the two system outputs) as the
  \emph{linearised} system as the steady-state flow varies. 
\item Figure \Ref{fig:Reactor_zero_b} shows the system zero (when $t$ and
  $c_b$ are the two system outputs) as the
  \emph{linearised} system as the steady-state flow varies. 
\end{itemize}

Added mtt/lib/examples/Chemical/Reactor/Reactor_input.txt version [f29f445616].







































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (Reactor_input.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2003/06/06 06:38:02  gawthrop
## Made compatible with current MTT.
##
## Revision 1.2  2000/12/28 18:52:24  peterg
## Updated for new formats
##
## Revision 1.1  2000/12/28 17:09:55  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (Reactor_sspar.r)
## as siso_sspar ecxept that inputs/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume Reactor:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
x3 = c_p*t_s*v_r;


#Steady-state input q needed to achieve steady-state t_s
q_s = -( (t_0-t_s)*c_p*f_s + e_1*h_1*k_1*x1 + e_2*h_2*k_2*x2 + e_3*h_3*k_3*pow(x1,2));

## The two inputs at steady-state
u1 = f_s;
u2 = q_s;


# Set the inputs
## Removed by MTT on Thu Dec 28 18:44:39 GMT 2000: mttu(1) = u1 + 0.1*u1*(t>0.01); # f (Reactor)
## Removed by MTT on Thu Dec 28 18:44:39 GMT 2000: mttu(2) = u2 + 0.1*u2*(t>0.05) ; # t (Reactor)



## Removed by MTT on Thu Jun  5 12:48:41 BST 2003: reactor_f	= u1 + 0.1*u1*(t>0.01); # Added by MTT on Thu Dec 28 18:44:47 GMT 2000
## Removed by MTT on Thu Jun  5 12:48:41 BST 2003: reactor_t	= u2 + 0.1*u2*(t>0.05); # Added by MTT on Thu Dec 28 18:44:47 GMT 2000
reactor__f	= u1 + 0.1*u1*(t>0.01); # f (Reactor)
reactor__t	= u2 + 0.1*u2*(t>0.05) ; # t (Reactor)

Added mtt/lib/examples/Chemical/Reactor/Reactor_lbl.txt version [58ee2fa737].













































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Reactor (Reactor_lbl.txt)
%SUMMARY Reactor: Simple reactor model
%DESCRIPTION Pseudo bond graph reactor model (based on ancient version)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:09:55  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%ALIAS Rate Chemical/Rate

% Extra variables
%VAR t_s
%VAR f_s
%VAR t_0
%VAR c_0
%VAR rho
%VAR v_r
%VAR e_1
%VAR e_2
%VAR e_3
%VAR a
%VAR b
%VAR c
%VAR c_A
%VAR c_B
%VAR x1
%VAR x2
%VAR x3
%VAR q_S
%VAR h
%VAR k
%VAR n
%VAR q

%VAR u1
%VAR u2

% Port aliases

% Argument aliases

%% each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m_a	lin		effort,1
	m_b	lin		effort,1
	h_r	lin		effort,c_p

% Component type FMR
	rfa	lin		effort,1		
	rfb	lin		effort,1		
	rt	lin		effort,c_p

% Component type Rate
        AB	Rate	k_1,q_1,h_1,1
	BC	Rate	k_2,q_2,h_2,1
	AD	Rate	k_3,q_3,h_3,2

% Component type SS
	c_0	SS		c_0,internal
	c_a	SS		external,0
	c_b	SS		external,0
	f	SS		internal,external
	t	SS		external,external
	t_0	SS		t_0,internal

Added mtt/lib/examples/Chemical/Reactor/Reactor_numpar.txt version [39eebbbfae].





















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (Reactor_numpar.txt)
# Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:09:55  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Dummies
a = 0;				# Dummy
b = 0;				# Dummy
c = 0;				# Dummy
c_0 = 0;			# Dummy
c_a = 0;			# Dummy
c_b = 0;			# Dummy
c_p = 0;			# Dummy
e_1 = 0;			# Dummy
e_2 = 0;			# Dummy
e_3 = 0;			# Dummy
f_s = 0;			# Dummy
h = 0;				# Dummy
h_1 = 0;			# Dummy
h_2 = 0;			# Dummy
h_3 = 0;			# Dummy
k = 0;				# Dummy
k_1 = 0;			# Dummy
k_2 = 0;			# Dummy
k_3 = 0;			# Dummy
n = 0;				# Dummy
q = 0;				# Dummy
q_1 = 0;			# Dummy
q_2 = 0;			# Dummy
q_3 = 0;			# Dummy
q_s = 0;			# Dummy
rho = 0;			# Dummy
t_0 = 0;			# Dummy
t_s = 0;			# Dummy
v_r = 0;			# Dummy
x1 = 0;				# Dummy
x2 = 0;				# Dummy
x3 = 0;				# Dummy

## The bulk liquid
rho = 900;			# Density
c_p = 5.0;			# Specific heat

## Substance A
k_1 = 2.5e10;			# Reaction rate constant
q_1 = 1e4;			# Exotherm constant
h_1 = 1e4;			# Heat of reaction

## Substance B
k_2 = 2.65e12;			# Reaction rate constant
q_2 = 1.2e4;			# Exotherm constant
h_2 = 1.2e4;			# Heat of reaction

## Substance C
k_3 = 6e7;			# Reaction rate constant
q_3 = 8e3;			# Exotherm constant
h_3 = 3e4;			# Heat of reaction

## Inflow parameters
c_0 = 10;			# Inflow conc
t_0 = 530;			# Inflow temp

## Steady-state values
t_s = 530;			# Steady-state temp
f_s = 100;			# Steady-state flow








u1	= 1.0; # Added by MTT on Thu Jun 05 12:45:35 BST 2003
u2	= 1.0; # Added by MTT on Thu Jun 05 12:45:35 BST 2003

Added mtt/lib/examples/Chemical/Reactor/Reactor_pic.fig version [c396b14562].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Landscape
Center
Inches
Letter  
100.00
Single
-2
1200 2
6 2400 3150 3225 3375
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2625 3300 2925 3300
4 0 -1 0 0 2 20 0.0000 4 210 210 2400 3375 A\001
4 0 -1 0 0 2 20 0.0000 4 210 225 3000 3375 D\001
-6
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 2100 2100 3900 1500 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 1500 4050 3900 4050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 1500 4350 2100 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2100 3600 3900 4200 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 3600 4350 4200 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 3900 4050 4200 4050
2 1 1 2 -1 -1 0 0 -1 6.000 0 0 -1 0 0 2
	 2100 2400 3600 2400
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2400 2925 2700 2925
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 3000 2925 3300 2925
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 2850 4800 2850 3750
4 0 -1 0 0 2 20 0.0000 4 210 210 2175 3000 A\001
4 0 -1 0 0 2 20 0.0000 4 210 195 2775 3000 B\001
4 0 -1 0 0 2 20 0.0000 4 210 210 3375 3000 C\001
4 0 -1 0 0 2 20 0.0000 4 210 150 2250 3375 2\001
4 0 -1 0 0 3 12 0.0000 4 135 90 1875 4950 0\001
4 0 -1 0 0 3 12 0.0000 4 135 90 2250 4950 0\001
4 0 -1 0 0 3 20 0.0000 4 210 150 2775 5025 q\001
4 0 -1 0 0 3 20 0.0000 4 285 765 1500 4800 f , c  , t\001
4 0 -1 0 0 3 20 0.0000 4 285 765 3600 4800 f , c  , t\001
4 0 -1 0 0 3 12 0.0000 4 135 90 3975 4950 b\001
4 0 -1 0 0 3 12 0.0000 4 90 75 4350 4950 r\001

Added mtt/lib/examples/Chemical/Reactor/Reactor_rep.txt version [303d4e3fcb].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Reactor (Reactor_rep.txt)
## Generated by MTT on" Fri Mar  3 12:13:34 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:09:55  peterg
## To RCS
##
###############################################################

mtt Reactor abg tex			# The system description
mtt Reactor cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt Reactor struc tex	        # The system structure
## mtt Reactor dae tex	        # The system dae
mtt Reactor ode tex	        # The system ode 
mtt Reactor sspar tex		# Steady-state parameters
mtt Reactor ss tex 		# Steady state
## mtt Reactor dm tex		# Descriptor matrices (of linearised system)
mtt Reactor sm tex		# State matrices (of linearised system)
## mtt Reactor tf tex		# Transfer function (of linearised system)
## mtt Reactor lmfr ps		# log modulus of frequency response (of linearised system)
mtt Reactor simpar tex		# Simulation parameters
mtt Reactor numpar tex		# Numerical simulation parameters
mtt Reactor input tex		# Simulation input
mtt Reactor state tex		# Simulation initial state

## The system outputs
mtt  Reactor odeso ps 'Reactor__c_a'
mtt  Reactor odeso ps 'Reactor__c_b'
mtt  Reactor odeso ps 'Reactor__t'

Added mtt/lib/examples/Chemical/Reactor/Reactor_simp.r version [c0625028b5].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output (mimo_sim.r)
m_r   := rho*v_r;
%mttx1 := c_a*v_r;
%mttx2 := c_b*v_r;

% THIS MUST BE CHANGED - probs with cp and FMRs
%c_p := 1;

%let mttx3/c_p = t;

let  e^(q_1/(mttx3/c_p)) = 1/epsilon_1;
let  e^(q_2/(mttx3/c_p)) = 1/epsilon_2;
let  e^(q_3/(mttx3/c_p)) = 1/epsilon_3;

let  e^(q_1/t_s) = 1/epsilon_1;
let  e^(q_2/t_s) = 1/epsilon_2;
let  e^(q_3/t_s) = 1/epsilon_3;

FACTOR mttx1,mttx2;

END;

Added mtt/lib/examples/Chemical/Reactor/Reactor_simpar.txt version [5dd7482825].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Reactor (Reactor_simpar.txt)
# Generated by MTT on Fri Mar 3 12:11:48 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/08/24 12:32:25  peterg
## Initial revision
##
###############################################################


LAST        = 0.1;       # Last time in simulation
DT          = 0.0002;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Chemical/Reactor/Reactor_sspar.r version [f8d86e9c44].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file (Reactor_sspar.r)
%% as siso_sspar ecxept that inputs/states have different meaning
%% Steady state for constant c_a, c_b and t=t_s and f=f_s

%% Unit volume Reactor:
v_r := 1;

%% Do the inputs first -- this avoids problems with reduce not
%% recognising that complicated expressions are zero

%% The exponentials.
e_1 := e^(-q_1/t_s);
e_2 := e^(-q_2/t_s);
e_3 := e^(-q_3/t_s);

%Steady-state input q needed to achieve steady-state t_s
q_s := -( 
        + (t_0-t_s)*c_p*f_s
        + e_1*h_1*k_1*x1
        + e_2*h_2*k_2*x2
        + e_3*h_3*k_3*x1^2
       );

%% The two inputs at steady-state
MTTu1 := f_s;
MTTu2 := q_s;

%States (masses)
x1 := c_a*v_r;
x2 := c_b*v_r;

%Thermal state
x3 := c_p*t_s*v_r;

%Load up the vectors
MTTx1 := x1;
MTTx2 := x2;
MTTx3 := x3;

MTTy1 := c_b;
MTTy2 := t_s;

%% Finally, solve for the steady-state concentrations
%% Solve for ca - a quadratic.
a 	:= k_3*e_3;	%ca^2 
b 	:= k_1*e_1 + f_s;	%ca^1 
c 	:= -c_0*f_s;

c_a	:= (-b + sqrt(b^2 - 4*a*c))/(2*a);

%% solve for c_b
c_b 	:= c_a*k_1*e_1/(f_s+k_2*e_2);


END;


Added mtt/lib/examples/Chemical/Reactor/Reactor_state.txt version [a989fd6bf6].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# State specification (Reactor_state.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2003/06/06 06:38:31  gawthrop
## Made compatible with current MTT.
##
## Revision 1.2  2000/12/28 18:52:25  peterg
## Updated for new formats
##
## Revision 1.1  2000/12/28 17:09:55  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (Reactor_sspar.r)
## as siso_sspar ecxept that states/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume Reactor:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
x3 = c_p*t_s*v_r;


#Steady-state state q needed to achieve steady-state t_s
q_s = -((t_0-t_s)*c_p*f_s + e_1*h_1*k_1*x1 + e_2*h_2*k_2*x2 + e_3*h_3*k_3*pow(x1,2));

## The two inputs at steady-state
u1 = f_s;
u2 = q_s;

## Load up the states
## Removed by MTT on Thu Dec 28 18:46:20 GMT 2000: mttx(1) = x1;
## Removed by MTT on Thu Dec 28 18:46:20 GMT 2000: mttx(2) = x2;
## Removed by MTT on Thu Dec 28 18:46:20 GMT 2000: mttx(3) = x3;




## Removed by MTT on Thu Jun  5 12:47:23 BST 2003: reactor_h_r	= x3; # Added by MTT on Thu Dec 28 18:46:25 GMT 2000
## Removed by MTT on Thu Jun  5 12:47:23 BST 2003: reactor_m_a	= x1; # Added by MTT on Thu Dec 28 18:46:25 GMT 2000
## Removed by MTT on Thu Jun  5 12:47:23 BST 2003: reactor_m_b	= x2; # Added by MTT on Thu Dec 28 18:46:25 GMT 2000
reactor__h_r	= x3;
reactor__m_a	= x1;
reactor__m_b	= x2;

Added mtt/lib/examples/Chemical/ReactorTF/MakeFigure.m version [138a415543].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Makes the figures

par = ReactorTF_numpar;		# Parameters
sym = ReactorTF_sympar;		# Parameter indices

F_s= [90:10:500];		# Range of flows

Z = [];
for f_s=F_s
  par(sym.f_s) = f_s;
  z = sort(eig(ReactorTF_sm(par)));
  Z = [Z z];
endfor


grid; xlabel("f_s"); ylabel("z_1");
plot(F_s,Z(1,:));
psfig("ReactorTF_zero_1");

grid; xlabel("f_s"); ylabel("z_2");
plot(F_s,Z(2,:));
psfig("ReactorTF_zero_2");

Added mtt/lib/examples/Chemical/ReactorTF/Makefile version [2d406594de].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Makes the schematic diagram and the zero figure
all: ReactorTF_pic.ps ReactorTF_zero_1.ps ReactorTF_zero_2.ps

ReactorTF_pic.ps: ReactorTF_pic.fig
	fig2dev -Lps ReactorTF_pic.fig> ReactorTF_pic.ps

ReactorTF_zero_1.ps: ReactorTF_abg.fig
	mtt -q ReactorTF sm m; mtt -q ReactorTF numpar m;
	mtt -q ReactorTF sympar m;
	octave MakeFigure.m

ReactorTF_zero_2.ps: ReactorTF_zero_1.ps
	touch ReactorTF_zero_2.ps

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_abg.fig version [c9c0507fc0].



































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3001 8701 3001 7801 3151 7951
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1801 9001 2701 9001 2551 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 8776 2701 9226
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3301 9001 4201 9001 4051 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 9301 3601 9901 3826 9901
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5701 9001 4801 9001 4951 9151
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 6000 2700 6000 2550 6150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 10350 5025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6000 1800 5775
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 10200 600 10200 600 7500 11100 7500 11100 10200
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 6600 600 6600 600 5400 11100 5400 11100 6600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4800 4500 8700 4650 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6000 4800 4800 8700 5025 8625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4800 5100 8700 5400 8700
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4800 4275 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4200 4275 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4800 5775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4200 5775 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4800 8775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4200 8775 4200
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 7200 3000 6300 3150 6450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10500 4800 3300 6000 3525 6075
2 4 1 2 1 7 1 0 -1 4.000 0 0 7 0 0 5
	 11100 5100 600 5100 600 3300 11100 3300 11100 5100
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4485 2395 4485 4130 4633 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 2999 2395 2999 4130 3148 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5970 2395 5970 4130 6119 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 10428 2397 10428 4132 10577 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8943 2397 8943 4132 9091 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 2100 2700 2100 2550 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3300 2100 4200 2100 4050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4800 2100 5700 2100 5550 2250
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4200 1800 3600 1200 3600 1425
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 1875 2700 2325
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 8701 1801 8101 1201 8101 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9301 2101 10201 2101 10051 2251
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 9301 1801 9901 1201 9901 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6300 2100 7200 2100 7050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7800 2100 8700 2100 8550 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1950 4350 1650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10050 1350 9900 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 1200 9750 1050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 1950 8850 1650
2 4 1 2 1 7 1 0 -1 4.000 0 0 7 0 0 5
	 11100 300 600 300 600 2700 11100 2700 11100 300
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 4800 3000 5700 3150 5550
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4800 8775 4800 9000
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5700 9000 5700 9225
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 6225 2700 6000
4 1 0 0 0 0 20 0.0000 4 195 1065 3075 4575 FMR:rfa\001
4 1 0 0 0 0 20 0.0000 4 195 1065 4575 4575 Rate:AD\001
4 1 0 0 0 0 20 0.0000 4 195 1050 6000 4575 Rate:AB\001
4 2 0 0 0 0 20 0.0000 4 255 810 1651 9076 SS:t_0\001
4 2 0 0 0 0 20 0.0000 4 255 690 3451 9976 C:h_r\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 6075 1\001
4 2 0 0 0 0 20 0.0000 4 210 525 1725 6075 SS:f\001
4 1 0 0 0 0 20 0.0000 4 195 150 3001 9076 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4501 9076 0\001
4 1 0 0 0 0 20 0.0000 4 195 1035 9001 4576 Rate:BC\001
4 1 0 0 0 0 20 0.0000 4 210 1080 10576 4576 FMR:rfb\001
4 1 1 1 0 3 20 0.0000 4 195 2595 9600 7800 THERMAL MODEL\001
4 1 0 0 0 0 20 0.0000 4 195 915 3000 7575 FMR:rt\001
4 1 1 1 0 3 20 0.0000 4 195 2640 9675 3750 REACTION MODEL\001
4 2 0 0 0 0 20 0.0000 4 255 855 1650 2175 SS:c_0\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4500 2175 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 6000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 9001 2176 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 10501 2176 1\001
4 1 0 0 0 0 20 0.0000 4 195 375 7500 2175 AF\001
4 1 0 0 0 0 20 0.0000 4 255 825 8100 1050 C:m_b\001
4 1 0 0 0 0 20 0.0000 4 255 855 9975 1050 SS:c_b\001
4 1 0 0 0 0 20 0.0000 4 240 810 3600 1050 C:m_a\001
4 1 1 1 0 3 20 0.0000 4 195 3645 9075 600 CONCENTRATION MODEL\001
4 1 0 0 0 0 20 0.0000 4 210 510 6151 9076 SS:t\001
4 1 1 1 0 3 20 0.0000 4 195 2865 9450 5700 HYDRAULIC MODEL\001

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_args.new version [5936bc7523].


1
+
 

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_desc.tex version [75defbbb1b].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ReactorTF (ReactorTF_desc.tex)
% Generated by MTT on Fri Mar 3 12:43:33 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{ReactorTF_pic}
{ReactorTF_pic} {0.9} {System \textbf{ReactorTF}, Schematic}

Figure \Ref{fig:ReactorTF_pic} is the schematic diagram of a chemical
reactor.

The acausal bond graph of system \textbf{ReactorTF} is displayed in
Figure \Ref{fig:ReactorTF_abg.ps} and its label file is listed in
Section \Ref{sec:ReactorTF_lbl}.  The subsystems are listed in Section
\Ref{sec:ReactorTF_sub}.

This example of a (nonlinear) chemical reactor is due to Trickett and
Bogle\footnote{ K. J. Tricket, \emph{Quantification of Inverse
    Responses for Controllability Assessment of Nonlinear Processes},
  PhD Thesis, University College London, 1994} is used in this
section.  The reactor has two reaction mechanisms: $\text{A}
\rightarrow \text{B} \rightarrow \text{C}$ and $\text{2A} \rightarrow
\text{D}$.  The reactor mass inflow and outflow $f_r$ are identical.
$q$ represents the heat inflow to the reactor.

The control loop $t$/$f$ has been inverted. The resulting SISO
system has two interpretations:
\begin{enumerate}
\item the \emph{dynamics} of the $c_b$/$q$ loop when the $t$/$f$ loop
  is under perfect control and
\item the \emph{inverse} dynamics of the  $t$/$f$ loop.
\end{enumerate}

\fig{ReactorTF_zero_1} {ReactorTF_zero_1} {0.9}
{System\textbf{ReactorTF}: zero 1 v flow} 
\fig{ReactorTF_zero_2} {ReactorTF_zero_2} {0.9}
{System\textbf{ReactorTF}: zero 2 v flow} 

Figures \Ref{fig:ReactorTF_zero_1} and \Ref{fig:ReactorTF_zero_2}
shows the poles of the linearised system as the steady-state flow
varies: these are the \emph{zeros} of the $t$/$f$ control-loop when
the $c_b$/$q$ loop is \emph{open}.


Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_input.txt version [5e10439ee4].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (ReactorTF_input.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:38:44  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:12:57  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTF_sspar.r)
## as siso_sspar ecxept that inputs/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTF:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
#x3 = c_p*t_s*v_r;


#Steady-state input q needed to achieve steady-state t_s
q_s = -( (t_0-t_s)*c_p*f_s + e_1*h_1*k_1*x1 + e_2*h_2*k_2*x2 + e_3*h_3*k_3*pow(x1,2));

# Set the inputs
## Removed by MTT on Thu Jun  5 14:13:24 BST 2003: mttu(1) = q_s + 0.1*q_s*(t>0.01); # q (ReactorTF)
reactortf__t	=  q_s + 0.1*q_s*(t>0.01); # q (ReactorTF)

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_lbl.txt version [254ff21c0a].














































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system ReactorTF (ReactorTF_lbl.txt)
%SUMMARY ReactorTF: Simple reactor model -- TF loop inverted
%DESCRIPTION Pseudo bond graph reactor model (based on ancient version)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:12:57  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%ALIAS Rate Chemical/Rate

% Extra variables
%VAR t_s
%VAR f_s
%VAR t_0
%VAR c_0
%VAR rho
%VAR v_r
%VAR e_1
%VAR e_2
%VAR e_3
%VAR a
%VAR b
%VAR c
%VAR c_A
%VAR c_B
%VAR x1
%VAR x2
%VAR x3
%VAR q_S

%VAR h
%VAR k
%VAR n
%VAR q


% Port aliases

% Argument aliases

%% each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m_a	lin		effort,1
	m_b	lin		effort,1
	h_r	lin		effort,c_p

% Component type FMR
	rfa	lin		effort,1		
	rfb	lin		effort,1		
	rt	lin		effort,c_p

% Component type Rate
        AB	Rate	k_1,q_1,h_1,1
	BC	Rate	k_2,q_2,h_2,1
	AD	Rate	k_3,q_3,h_3,2

% Component type SS
	c_0	SS		c_0,internal
	c_b	SS		external,0
	f	SS		internal,internal
	t	SS		t_s,external
	t_0	SS		t_0,internal



Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_numpar.m version [b474b96e57].



























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttpar = ReactorTF_numpar();
% mttpar = ReactorTF_numpar();
%System ReactorTF, representation numpar, language m;
%File ReactorTF_numpar.m;
%Generated by MTT on Thu Aug 24 14:28:46 BST 2000;
%

#====== Set up the global variables ======#
global ...
     a ...
     b ...
     c ...
     c_0 ...
     c_a ...
     c_b ...
     c_p ...
     e_1 ...
     e_2 ...
     e_3 ...
     f_s ...
     h ...
     h_1 ...
     h_2 ...
     h_3 ...
     k ...
     k_1 ...
     k_2 ...
     k_3 ...
     n ...
     q ...
     q_1 ...
     q_2 ...
     q_3 ...
     q_s ...
     rho ...
     t_0 ...
     t_s ...
     v_r ...
     x1 ...
     x2 ...
     x3 ;
## Set parameters to zero
 a = 0.0;
 b = 0.0;
 c = 0.0;
 c_0 = 0.0;
 c_a = 0.0;
 c_b = 0.0;
 c_p = 0.0;
 e_1 = 0.0;
 e_2 = 0.0;
 e_3 = 0.0;
 f_s = 0.0;
 h = 0.0;
 h_1 = 0.0;
 h_2 = 0.0;
 h_3 = 0.0;
 k = 0.0;
 k_1 = 0.0;
 k_2 = 0.0;
 k_3 = 0.0;
 n = 0.0;
 q = 0.0;
 q_1 = 0.0;
 q_2 = 0.0;
 q_3 = 0.0;
 q_s = 0.0;
 rho = 0.0;
 t_0 = 0.0;
 t_s = 0.0;
 v_r = 0.0;
 x1 = 0.0;
 x2 = 0.0;
 x3 = 0.0;
 %  -*-octave-*- Put Emacs into octave-mode
 %  Numerical parameter file (ReactorTF_numpar.txt)
 %  Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% Version control history
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% $Id$
 %  %% $Log$
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 % 
a =  0;				 %  Dummy
b =  0;				 %  Dummy
c =  0;				 %  Dummy
c_0 =  0;			 %  Dummy
c_a =  0;			 %  Dummy
c_b =  0;			 %  Dummy
c_p =  0;			 %  Dummy
e_1 =  0;			 %  Dummy
e_2 =  0;			 %  Dummy
e_3 =  0;			 %  Dummy
f_s =  0;			 %  Dummy
h =  0;				 %  Dummy
h_1 =  0;			 %  Dummy
h_2 =  0;			 %  Dummy
h_3 =  0;			 %  Dummy
k =  0;				 %  Dummy
k_1 =  0;			 %  Dummy
k_2 =  0;			 %  Dummy
k_3 =  0;			 %  Dummy
n =  0;				 %  Dummy
q =  0;				 %  Dummy
q_1 =  0;			 %  Dummy
q_2 =  0;			 %  Dummy
q_3 =  0;			 %  Dummy
q_s =  0;			 %  Dummy
rho =  0;			 %  Dummy
t_0 =  0;			 %  Dummy
t_s =  0;			 %  Dummy
v_r =  0;			 %  Dummy
x1 =  0;				 %  Dummy
x2 =  0;				 %  Dummy
x3 =  0;				 %  Dummy

 % 
rho =  900;			 %  Density
c_p =  5.0;			 %  Specific heat

 % 
k_1 =  2.5e10;			 %  Reaction rate constant
q_1 =  1e4;			 %  Exotherm constant
h_1 =  1e4;			 %  Heat of reaction

 % 
k_2 =  2.65e12;			 %  Reaction rate constant
q_2 =  1.2e4;			 %  Exotherm constant
h_2 =  1.2e4;			 %  Heat of reaction

 % 
k_3 =  6e7;			 %  Reaction rate constant
q_3 =  8e3;			 %  Exotherm constant
h_3 =  3e4;			 %  Heat of reaction

 % 
c_0 =  10;			 %  Inflow conc
t_0 =  500;			 %  Inflow temp

 % 
t_s =  530;			 %  Steady-state temp
f_s =  100;			 %  Steady-state flow








## Set up the parameter vector
  mttpar(1) 	= a;
  mttpar(2) 	= b;
  mttpar(3) 	= c;
  mttpar(4) 	= c_0;
  mttpar(5) 	= c_a;
  mttpar(6) 	= c_b;
  mttpar(7) 	= c_p;
  mttpar(8) 	= e_1;
  mttpar(9) 	= e_2;
  mttpar(10) 	= e_3;
  mttpar(11) 	= f_s;
  mttpar(12) 	= h;
  mttpar(13) 	= h_1;
  mttpar(14) 	= h_2;
  mttpar(15) 	= h_3;
  mttpar(16) 	= k;
  mttpar(17) 	= k_1;
  mttpar(18) 	= k_2;
  mttpar(19) 	= k_3;
  mttpar(20) 	= n;
  mttpar(21) 	= q;
  mttpar(22) 	= q_1;
  mttpar(23) 	= q_2;
  mttpar(24) 	= q_3;
  mttpar(25) 	= q_s;
  mttpar(26) 	= rho;
  mttpar(27) 	= t_0;
  mttpar(28) 	= t_s;
  mttpar(29) 	= v_r;
  mttpar(30) 	= x1;
  mttpar(31) 	= x2;
  mttpar(32) 	= x3;

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_numpar.txt version [28d37b19ef].
















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (ReactorTF_numpar.txt)
# Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Dummies
a = 0;				# Dummy
b = 0;				# Dummy
c = 0;				# Dummy
c_0 = 0;			# Dummy
c_a = 0;			# Dummy
c_b = 0;			# Dummy
c_p = 0;			# Dummy
e_1 = 0;			# Dummy
e_2 = 0;			# Dummy
e_3 = 0;			# Dummy
f_s = 0;			# Dummy
h = 0;				# Dummy
h_1 = 0;			# Dummy
h_2 = 0;			# Dummy
h_3 = 0;			# Dummy
k = 0;				# Dummy
k_1 = 0;			# Dummy
k_2 = 0;			# Dummy
k_3 = 0;			# Dummy
n = 0;				# Dummy
q = 0;				# Dummy
q_1 = 0;			# Dummy
q_2 = 0;			# Dummy
q_3 = 0;			# Dummy
q_s = 0;			# Dummy
rho = 0;			# Dummy
t_0 = 0;			# Dummy
t_s = 0;			# Dummy
v_r = 0;			# Dummy
x1 = 0;				# Dummy
x2 = 0;				# Dummy
x3 = 0;				# Dummy

## The bulk liquid
rho = 900;			# Density
c_p = 5.0;			# Specific heat

## Substance A
k_1 = 2.5e10;			# Reaction rate constant
q_1 = 1e4;			# Exotherm constant
h_1 = 1e4;			# Heat of reaction

## Substance B
k_2 = 2.65e12;			# Reaction rate constant
q_2 = 1.2e4;			# Exotherm constant
h_2 = 1.2e4;			# Heat of reaction

## Substance C
k_3 = 6e7;			# Reaction rate constant
q_3 = 8e3;			# Exotherm constant
h_3 = 3e4;			# Heat of reaction

## Inflow parameters
c_0 = 10;			# Inflow conc
t_0 = 500;			# Inflow temp

## Steady-state values
t_s = 530;			# Steady-state temp
f_s = 100;			# Steady-state flow








Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_pic.fig version [c396b14562].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Landscape
Center
Inches
Letter  
100.00
Single
-2
1200 2
6 2400 3150 3225 3375
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2625 3300 2925 3300
4 0 -1 0 0 2 20 0.0000 4 210 210 2400 3375 A\001
4 0 -1 0 0 2 20 0.0000 4 210 225 3000 3375 D\001
-6
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 2100 2100 3900 1500 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 1500 4050 3900 4050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 1500 4350 2100 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2100 3600 3900 4200 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 3600 4350 4200 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 3900 4050 4200 4050
2 1 1 2 -1 -1 0 0 -1 6.000 0 0 -1 0 0 2
	 2100 2400 3600 2400
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2400 2925 2700 2925
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 3000 2925 3300 2925
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 2850 4800 2850 3750
4 0 -1 0 0 2 20 0.0000 4 210 210 2175 3000 A\001
4 0 -1 0 0 2 20 0.0000 4 210 195 2775 3000 B\001
4 0 -1 0 0 2 20 0.0000 4 210 210 3375 3000 C\001
4 0 -1 0 0 2 20 0.0000 4 210 150 2250 3375 2\001
4 0 -1 0 0 3 12 0.0000 4 135 90 1875 4950 0\001
4 0 -1 0 0 3 12 0.0000 4 135 90 2250 4950 0\001
4 0 -1 0 0 3 20 0.0000 4 210 150 2775 5025 q\001
4 0 -1 0 0 3 20 0.0000 4 285 765 1500 4800 f , c  , t\001
4 0 -1 0 0 3 20 0.0000 4 285 765 3600 4800 f , c  , t\001
4 0 -1 0 0 3 12 0.0000 4 135 90 3975 4950 b\001
4 0 -1 0 0 3 12 0.0000 4 90 75 4350 4950 r\001

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_rep.tex version [c4b39857a2].

























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


\section{\textbf{ReactorTF}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:ReactorTF_abg.tex}
\index{\textbf{ReactorTF} -- abg}


MTT command:
\begin{verbatim}
mtt ReactorTF abg tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_abg.tex}


\section{\textbf{ReactorTF}: representation \textbf{cbg}, language \textbf{ps}}
\label{sec:ReactorTF_cbg.ps}
\index{\textbf{ReactorTF} -- cbg}


MTT command:
\begin{verbatim}
mtt ReactorTF cbg ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:ReactorTF_cbg.ps}.
\fig{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_cbg}
    {ReactorTF_cbg.ps}
    {0.9}
    {System \textbf{ReactorTF}, representation cbg}


\section{\textbf{ReactorTF}: representation \textbf{struc}, language \textbf{tex}}
\label{sec:ReactorTF_struc.tex}
\index{\textbf{ReactorTF} -- struc}


MTT command:
\begin{verbatim}
mtt ReactorTF struc tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_struc.tex}


\section{\textbf{ReactorTF}: representation \textbf{ode}, language \textbf{tex}}
\label{sec:ReactorTF_ode.tex}
\index{\textbf{ReactorTF} -- ode}


MTT command:
\begin{verbatim}
mtt ReactorTF ode tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_ode.tex}


\section{\textbf{ReactorTF}: representation \textbf{sspar}, language \textbf{tex}}
\label{sec:ReactorTF_sspar.tex}
\index{\textbf{ReactorTF} -- sspar}


MTT command:
\begin{verbatim}
mtt ReactorTF sspar tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_sspar.tex}


\section{\textbf{ReactorTF}: representation \textbf{ss}, language \textbf{tex}}
\label{sec:ReactorTF_ss.tex}
\index{\textbf{ReactorTF} -- ss}


MTT command:
\begin{verbatim}
mtt ReactorTF ss tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_ss.tex}


\section{\textbf{ReactorTF}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:ReactorTF_sm.tex}
\index{\textbf{ReactorTF} -- sm}


MTT command:
\begin{verbatim}
mtt ReactorTF sm tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_sm.tex}


\section{\textbf{ReactorTF}: representation \textbf{simpar}, language \textbf{tex}}
\label{sec:ReactorTF_simpar.tex}
\index{\textbf{ReactorTF} -- simpar}


MTT command:
\begin{verbatim}
mtt ReactorTF simpar tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_simpar.tex}


\section{\textbf{ReactorTF}: representation \textbf{numpar}, language \textbf{tex}}
\label{sec:ReactorTF_numpar.tex}
\index{\textbf{ReactorTF} -- numpar}


MTT command:
\begin{verbatim}
mtt ReactorTF numpar tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_numpar.tex}


\section{\textbf{ReactorTF}: representation \textbf{input}, language \textbf{tex}}
\label{sec:ReactorTF_input.tex}
\index{\textbf{ReactorTF} -- input}


MTT command:
\begin{verbatim}
mtt ReactorTF input tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_input.tex}


\section{\textbf{ReactorTF}: representation \textbf{state}, language \textbf{tex}}
\label{sec:ReactorTF_state.tex}
\index{\textbf{ReactorTF} -- state}


MTT command:
\begin{verbatim}
mtt ReactorTF state tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_state.tex}


\section{\textbf{ReactorTF}: representation \textbf{odeso}, language \textbf{ps}}
\label{sec:ReactorTF_odeso.ps}
\index{\textbf{ReactorTF} -- odeso}


MTT command:
\begin{verbatim}
mtt ReactorTF odeso ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:ReactorTF_odeso.ps}.
\fig{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_odeso}
    {ReactorTF_odeso.ps}
    {0.9}
    {System \textbf{ReactorTF}, representation odeso}

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_rep.txt version [e9c51c0201].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system ReactorTF (ReactorTF_rep.txt)
## Generated by MTT on" Fri Mar  3 12:13:34 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:12:57  peterg
## To RCS
##
###############################################################

mtt ReactorTF abg tex			# The system description
mtt ReactorTF cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt ReactorTF struc tex	        # The system structure
## mtt ReactorTF dae tex	        # The system dae
mtt ReactorTF ode tex	        # The system ode 
mtt ReactorTF sspar tex		# Steady-state parameters
mtt ReactorTF ss tex 		# Steady state
## mtt ReactorTF dm tex		# Descriptor matrices (of linearised system)
mtt ReactorTF sm tex		# State matrices (of linearised system)
## mtt ReactorTF tf tex		# Transfer function (of linearised system)
## mtt ReactorTF lmfr ps		# log modulus of frequency response (of linearised system)
mtt ReactorTF simpar tex		# Simulation parameters
mtt ReactorTF numpar tex		# Numerical simulation parameters
mtt ReactorTF input tex		# Simulation input
mtt ReactorTF state tex		# Simulation initial state
mtt ReactorTF odeso ps		# Simulation

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_simp.r version [c0625028b5].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output (mimo_sim.r)
m_r   := rho*v_r;
%mttx1 := c_a*v_r;
%mttx2 := c_b*v_r;

% THIS MUST BE CHANGED - probs with cp and FMRs
%c_p := 1;

%let mttx3/c_p = t;

let  e^(q_1/(mttx3/c_p)) = 1/epsilon_1;
let  e^(q_2/(mttx3/c_p)) = 1/epsilon_2;
let  e^(q_3/(mttx3/c_p)) = 1/epsilon_3;

let  e^(q_1/t_s) = 1/epsilon_1;
let  e^(q_2/t_s) = 1/epsilon_2;
let  e^(q_3/t_s) = 1/epsilon_3;

FACTOR mttx1,mttx2;

END;

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_simpar.txt version [a9ebdd151e].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ReactorTF (ReactorTF_simpar.txt)
# Generated by MTT on Fri Mar 3 12:11:48 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 0.05;       # Last time in simulation
DT          = 0.0002;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_sm.m version [8997bae617].


























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [mtta,mttb,mttc,mttd] = ReactorTF_sm(mttpar);
% [mtta,mttb,mttc,mttd] = ReactorTF_sm(mttpar);
%System ReactorTF, representation sm, language m;
%File ReactorTF_sm.m;
%Generated by MTT on Thu Aug 24 14:45:50 BST 2000;
%
%====== Set up the global variables ======%
global ...
a ...
b ...
c ...
c_0 ...
c_a ...
c_b ...
c_p ...
e_1 ...
e_2 ...
e_3 ...
f_s ...
h ...
h_1 ...
h_2 ...
h_3 ...
k ...
k_1 ...
k_2 ...
k_3 ...
n ...
q ...
q_1 ...
q_2 ...
q_3 ...
q_s ...
rho ...
t_0 ...
t_s ...
v_r ...
x1 ...
x2 ...
x3 ;
a 	= mttpar(1);
b 	= mttpar(2);
c 	= mttpar(3);
c_0 	= mttpar(4);
c_a 	= mttpar(5);
c_b 	= mttpar(6);
c_p 	= mttpar(7);
e_1 	= mttpar(8);
e_2 	= mttpar(9);
e_3 	= mttpar(10);
f_s 	= mttpar(11);
h 	= mttpar(12);
h_1 	= mttpar(13);
h_2 	= mttpar(14);
h_3 	= mttpar(15);
k 	= mttpar(16);
k_1 	= mttpar(17);
k_2 	= mttpar(18);
k_3 	= mttpar(19);
n 	= mttpar(20);
q 	= mttpar(21);
q_1 	= mttpar(22);
q_2 	= mttpar(23);
q_3 	= mttpar(24);
q_s 	= mttpar(25);
rho 	= mttpar(26);
t_0 	= mttpar(27);
t_s 	= mttpar(28);
v_r 	= mttpar(29);
x1 	= mttpar(30);
x2 	= mttpar(31);
x3 	= mttpar(32);
%a matrix%
mtta = zeros(2,2);
mtt_t1 = exp((2.0*q_1+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s^2*h_3;
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_0*f_s*h_3*k_3;
mtt_t1 = mtt_t1-(exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_1*k_1);
mtt_t1 = mtt_t1+2.0*exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_3*k_1;
mtt_t1 = mtt_t1-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))^2*c_0*h_1*k_1*k_3);
mtt_t1 = mtt_t1+2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))^2*c_0*h_3*k_1*k_3;
mtt_t1 = mtt_t1-(exp(q_3/t_s)*abs(exp(q_1/t_s))^2*h_1*k_1^2);
mtt_t1 = mtt_t1+exp(q_3/t_s)*abs(exp(q_1/t_s))^2*h_3*k_1^2;
mtt_t3 = 2.0*exp((2.0*q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t4 = 2.0*exp((2.0*q_1)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t4 = mtt_t4*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t3*abs(exp(q_1/t_s))*f_s*h_3)-(mtt_t4*abs(exp(q_1/t_s))*c_0*h_3*k_3);
mtt_t5 = 2.0*exp((2.0*q_1)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t5 = mtt_t5*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t3 = 2.0*exp((2.0*q_1)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t5*abs(exp(q_1/t_s))*c_p*k_3*t_0)+mtt_t3*abs(exp(q_1/t_s))*c_p*k_3*t_s;
mtt_t4 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t4 = mtt_t4*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t3 = 2.0*exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1+mtt_t4*abs(exp(q_1/t_s))*h_1*k_1-(mtt_t3*abs(exp(q_1/t_s))*h_3*k_1);
mtt_t1 = mtt_t1+exp((4.0*q_1+q_3)/t_s)*f_s^2*h_3;
mtt_t1 = mtt_t1+4.0*exp((4.0*q_1)/t_s)*c_0*f_s*h_3*k_3;
mtt_t1 = mtt_t1+2.0*exp((3.0*q_1+q_3)/t_s)*f_s*h_3*k_1;
mtt_t1 = mtt_t1+exp((2.0*q_1+q_3)/t_s)*h_3*k_1^2;
mtt_t2 = 2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_3*t_0;
mtta(1,1) = mtt_t1/(mtt_t2-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_3*t_s));
mtt_t1 = -(exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*h_2*k_2);
mtt_t1 = mtt_t1-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_0*h_2*k_2*k_3);
mtt_t3 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(exp(q_3/t_s)*abs(exp(q_1/t_s))*h_2*k_1*k_2)+mtt_t3*h_2*k_2;
mtt_t2 = 2.0*exp((q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_0;
mtta(1,2) = mtt_t1/(mtt_t2-(2.0*exp((q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_s));
mtt_t1 = exp((2.0*q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s^2*h_3*k_1;
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_1*k_3*t_0;
mtt_t1 = mtt_t1-(2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_1*k_3*t_s);
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_1*k_2*k_3*t_0;
mtt_t1 = mtt_t1-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_1*k_2*k_3*t_s);
mtt_t1 = mtt_t1-(exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_1*k_1^2);
mtt_t1 = mtt_t1+2.0*exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_3*k_1^2;
mtt_t1 = mtt_t1-(exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*h_1*k_1^3);
mtt_t1 = mtt_t1+exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*h_3*k_1^3;
mtt_t3 = 2.0*exp((2.0*q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t4 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t4 = mtt_t4*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t3*abs(exp(q_1/t_s))*f_s*h_3*k_1)+mtt_t4*abs(exp(q_1/t_s))*h_1*k_1^2;
mtt_t5 = 2.0*exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t5 = mtt_t5*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t5*abs(exp(q_1/t_s))*h_3*k_1^2);
mtt_t1 = mtt_t1+exp((4.0*q_1+q_2+q_3)/t_s)*f_s^2*h_3*k_1;
mtt_t1 = mtt_t1+4.0*exp((4.0*q_1+q_2)/t_s)*c_0*f_s*h_3*k_1*k_3;
mtt_t1 = mtt_t1+2.0*exp((3.0*q_1+q_2+q_3)/t_s)*f_s*h_3*k_1^2;
mtt_t1 = mtt_t1+exp((2.0*q_1+q_2+q_3)/t_s)*h_3*k_1^3;
mtt_t2 = 2.0*exp((3.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_3*t_0;
mtt_t2 = mtt_t2-(2.0*exp((3.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_3*t_s);
mtt_t2 = mtt_t2+2.0*exp((3.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_2*k_3*t_0;
mtta(2,1) = mtt_t1/(mtt_t2-(2.0*exp((3.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_2*k_3*t_s));
mtt_t1 = -(2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s^2*k_3*t_0);
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s^2*k_3*t_s;
mtt_t1 = mtt_t1-(4.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_2*k_3*t_0);
mtt_t1 = mtt_t1+4.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_2*k_3*t_s;
mtt_t1 = mtt_t1-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2^2*k_3*t_0);
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2^2*k_3*t_s;
mtt_t1 = mtt_t1-(exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*h_2*k_1*k_2);
mtt_t1 = mtt_t1-(exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))*h_2*k_1^2*k_2);
mtt_t3 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1+mtt_t3*h_2*k_1*k_2;
mtt_t2 = 2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_0;
mtt_t2 = mtt_t2-(2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_s);
mtt_t2 = mtt_t2+2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_0;
mtta(2,2) = mtt_t1/(mtt_t2-(2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_s));
%b matrix%
mttb = zeros(2,1);
mtt_t1 = -(exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))*f_s);
mtt_t1 = mtt_t1-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_0*k_3);
mtt_t1 = mtt_t1-(exp(q_3/t_s)*abs(exp(q_1/t_s))*k_1);
mtt_t3 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t1 = mtt_t1+mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t4 = 2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_0;
mttb(1) = mtt_t1/(mtt_t4-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_s));
mtt_t1 = -(exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*k_1);
mtt_t3 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))*k_1^2)+mtt_t3*k_1;
mtt_t2 = 2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_0;
mtt_t2 = mtt_t2-(2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_s);
mtt_t2 = mtt_t2+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_0;
mttb(2) = mtt_t1/(mtt_t2-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_s));
%c matrix%
mttc = zeros(1,2);
mttc(1,2) = 1.0;
%d matrix%
mttd = zeros(1,1);

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_sspar.r version [5ae7de35e5].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file (ReactorTF_sspar.r)
%% as siso_sspar ecxept that inputs/states have different meaning
%% Steady state for constant c_a, c_b and t=t_s and f=f_s

%% Unit volume ReactorTF:
v_r := 1;

%% Do the inputs first -- this avoids problems with reduce not
%% recognising that complicated expressions are zero

%% The exponentials.
e_1 := e^(-q_1/t_s);
e_2 := e^(-q_2/t_s);
e_3 := e^(-q_3/t_s);

%Steady-state input q needed to achieve steady-state t_s
q_s := -( 
        + (t_0-t_s)*c_p*f_s
        + e_1*h_1*k_1*x1
        + e_2*h_2*k_2*x2
        + e_3*h_3*k_3*x1^2
       );

%% The input at steady-state
MTTu1 := q_s;

%States (masses)
x1 := c_a*v_r;
x2 := c_b*v_r;

%Thermal state
x3 := c_p*t_s*v_r;

%Load up the vectors
MTTx1 := x1;
MTTx2 := x2;

MTTy1 := c_b;
%MTTy2 := t_s;

%% Finally, solve for the steady-state concentrations
%% Solve for ca - a quadratic.
a 	:= k_3*e_3;	%ca^2 
b 	:= k_1*e_1 + f_s;	%ca^1 
c 	:= -c_0*f_s;

c_a	:= (-b + sqrt(b^2 - 4*a*c))/(2*a);

%% solve for c_b
c_b 	:= c_a*k_1*e_1/(f_s+k_2*e_2);


END;


Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_state.txt version [9b324c96c8].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# State specification (ReactorTF_state.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:39:05  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:12:57  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTF_sspar.r)
## as siso_sspar ecxept that states/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTF:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
#x3 = c_p*t_s*v_r;

## Load up the states
## Removed by MTT on Thu Jun  5 14:14:18 BST 2003: mttx(1) = x1;
## Removed by MTT on Thu Jun  5 14:14:18 BST 2003: mttx(2) = x2;
## Removed by MTT on Thu Jun  5 14:14:18 BST 2003: mttx(3) = x3;




reactortf__m_a	= x1;
reactortf__m_b	= x2;

Added mtt/lib/examples/Chemical/ReactorTF/ReactorTF_sympar.m version [971206bf83].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function sympar = ReactorTF_sympar();
% sympar = ReactorTF_sympar();
%System ReactorTF, representation sympar, language m;
%File ReactorTF_sympar.m;
%Generated by MTT on Thu Aug 24 14:45:51 BST 2000;
%
global ...
mtt_no_globals ;
  sympar.a 	= 1; # ReactorTF
  sympar.b 	= 2; # ReactorTF
  sympar.c 	= 3; # ReactorTF
  sympar.c_0 	= 4; # ReactorTF
  sympar.c_A 	= 5; # ReactorTF
  sympar.c_B 	= 6; # ReactorTF
  sympar.c_p 	= 7; # ReactorTF
  sympar.e_1 	= 8; # ReactorTF
  sympar.e_2 	= 9; # ReactorTF
  sympar.e_3 	= 10; # ReactorTF
  sympar.f_s 	= 11; # ReactorTF
  sympar.h 	= 12; # Rate
  sympar.h_1 	= 13; # ReactorTF
  sympar.h_2 	= 14; # ReactorTF
  sympar.h_3 	= 15; # ReactorTF
  sympar.k 	= 16; # Rate
  sympar.k_1 	= 17; # ReactorTF
  sympar.k_2 	= 18; # ReactorTF
  sympar.k_3 	= 19; # ReactorTF
  sympar.n 	= 20; # Rate
  sympar.q 	= 21; # Rate
  sympar.q_1 	= 22; # ReactorTF
  sympar.q_2 	= 23; # ReactorTF
  sympar.q_3 	= 24; # ReactorTF
  sympar.q_S 	= 25; # ReactorTF
  sympar.rho 	= 26; # ReactorTF
  sympar.t_0 	= 27; # ReactorTF
  sympar.t_s 	= 28; # ReactorTF
  sympar.v_r 	= 29; # ReactorTF
  sympar.x1 	= 30; # ReactorTF
  sympar.x2 	= 31; # ReactorTF
  sympar.x3 	= 32; # ReactorTF

Added mtt/lib/examples/Chemical/ReactorTQ/MakeFigure.m version [f0f759751c].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Makes the figures

par = ReactorTQ_numpar;		# Parameters
sym = ReactorTQ_sympar;		# Parameter indices

F_s= [90:10:500];		# Range of flows

Z = [];
for f_s=F_s
  par(sym.f_s) = f_s;
  z = sort(eig(ReactorTQ_sm(par)));
  Z = [Z z];
endfor


grid; xlabel("f_s"); ylabel("z");
plot(F_s,Z);
psfig("ReactorTQ_zero");

Added mtt/lib/examples/Chemical/ReactorTQ/Makefile version [1134f9d9da].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
## Makes the schematic diagram and the zero figure
all: ReactorTQ_pic.ps ReactorTQ_zero.ps

ReactorTQ_pic.ps: ReactorTQ_pic.fig
	fig2dev -Lps ReactorTQ_pic.fig> ReactorTQ_pic.ps

ReactorTQ_zero.ps: ReactorTQ_abg.fig
	mtt -q ReactorTQ sm m; mtt -q ReactorTQ numpar m;
	mtt -q ReactorTQ sympar m;
	octave MakeFigure.m

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_abg.fig version [79f241dde0].

































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3001 8701 3001 7801 3151 7951
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1801 9001 2701 9001 2551 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 8776 2701 9226
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3301 9001 4201 9001 4051 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 9301 3601 9901 3826 9901
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5701 9001 4801 9001 4951 9151
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 6000 2700 6000 2550 6150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 10350 5025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6000 1800 5775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6225 1800 6000
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 10200 600 10200 600 7500 11100 7500 11100 10200
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 6600 600 6600 600 5400 11100 5400 11100 6600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4800 4500 8700 4650 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6000 4800 4800 8700 5025 8625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4800 5100 8700 5400 8700
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4800 4275 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4200 4275 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4800 5775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4200 5775 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4800 8775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4200 8775 4200
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 7200 3000 6300 3150 6450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10500 4800 3300 6000 3525 6075
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 5100 600 5100 600 3300 11100 3300 11100 5100
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4485 2395 4485 4130 4633 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 2999 2395 2999 4130 3148 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5970 2395 5970 4130 6119 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 10428 2397 10428 4132 10577 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 2100 2700 2100 2550 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3300 2100 4200 2100 4050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4800 2100 5700 2100 5550 2250
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4200 1800 3600 1200 3600 1425
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 1875 2700 2325
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 8701 1801 8101 1201 8101 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9301 2101 10201 2101 10051 2251
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 9301 1801 9901 1201 9901 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6300 2100 7200 2100 7050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7800 2100 8700 2100 8550 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1950 4350 1650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10050 1350 9900 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 1200 9750 1050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 1950 8850 1650
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 300 600 300 600 2700 11100 2700 11100 300
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 4800 3000 5700 3150 5550
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4800 8775 4800 9225
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8943 2397 8943 4132 9091 3843
4 1 0 0 0 0 20 0.0000 4 195 1065 3075 4575 FMR:rfa\001
4 1 0 0 0 0 20 0.0000 4 195 1065 4575 4575 Rate:AD\001
4 1 0 0 0 0 20 0.0000 4 195 1050 6000 4575 Rate:AB\001
4 2 0 0 0 0 20 0.0000 4 255 810 1651 9076 SS:t_0\001
4 2 0 0 0 0 20 0.0000 4 255 690 3451 9976 C:h_r\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 6075 1\001
4 2 0 0 0 0 20 0.0000 4 210 525 1725 6075 SS:f\001
4 1 0 0 0 0 20 0.0000 4 195 150 3001 9076 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4501 9076 0\001
4 1 0 0 0 0 20 0.0000 4 195 1035 9001 4576 Rate:BC\001
4 1 0 0 0 0 20 0.0000 4 210 1080 10576 4576 FMR:rfb\001
4 1 1 1 0 3 20 0.0000 4 195 2595 9600 7800 THERMAL MODEL\001
4 1 1 1 0 3 20 0.0000 4 195 2865 9450 5700 HYDRAULIC MODEL\001
4 1 0 0 0 0 20 0.0000 4 195 915 3000 7575 FMR:rt\001
4 1 1 1 0 3 20 0.0000 4 195 2640 9675 3750 REACTION MODEL\001
4 2 0 0 0 0 20 0.0000 4 255 855 1650 2175 SS:c_0\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4500 2175 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 6000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 9001 2176 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 10501 2176 1\001
4 1 0 0 0 0 20 0.0000 4 195 375 7500 2175 AF\001
4 1 0 0 0 0 20 0.0000 4 255 825 8100 1050 C:m_b\001
4 1 0 0 0 0 20 0.0000 4 255 855 9975 1050 SS:c_b\001
4 1 0 0 0 0 20 0.0000 4 240 810 3600 1050 C:m_a\001
4 1 1 1 0 3 20 0.0000 4 195 3645 9075 600 CONCENTRATION MODEL\001
4 1 0 0 0 0 20 0.0000 4 210 510 6151 9076 SS:t\001

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_args.new version [5936bc7523].


1
+
 

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_desc.tex version [74095d0a13].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ReactorTQ (ReactorTQ_desc.tex)
% Generated by MTT on Fri Mar 3 12:43:33 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{ReactorTQ_pic}
{ReactorTQ_pic} {0.9} {System \textbf{ReactorTQ}, Schematic}

Figure \Ref{fig:ReactorTQ_pic} is the schematic diagram of a chemical
reactor.

The acausal bond graph of system \textbf{ReactorTQ} is displayed in
Figure \Ref{fig:ReactorTQ_abg.ps} and its label file is listed in
Section \Ref{sec:ReactorTQ_lbl}.  The subsystems are listed in Section
\Ref{sec:ReactorTQ_sub}.

This example of a (nonlinear) chemical reactor is due to Trickett and
Bogle\footnote{ K. J. Tricket, \emph{Quantification of Inverse
    Responses for Controllability Assessment of Nonlinear Processes},
  PhD Thesis, University College London, 1994} is used in this
section.  The reactor has two reaction mechanisms: $\text{A}
\rightarrow \text{B} \rightarrow \text{C}$ and $\text{2A} \rightarrow
\text{D}$.  The reactor mass inflow and outflow $f_r$ are identical.
$q$ represents the heat inflow to the reactor.

The control loop $t$/$q$ has been inverted. The resulting SISO
system has two interpretations:
\begin{enumerate}
\item the \emph{dynamics} of the $c_b$/$f$ loop when the $t$/$q$ loop
  is under perfect control and
\item the \emph{inverse} dynamics of the  $t$/$q$ loop.
\end{enumerate}

\fig{ReactorTQ_zero} {ReactorTQ_zero} {0.9}
{System\textbf{ReactorTQ}: zeros v flow} 

Figure \Ref{fig:ReactorTQ_zero}
shows the poles of the linearised system as the steady-state flow
varies: these are the \emph{zeros} of the $c_b$/$f$ control-loop when
the $t$/$q$ loop is \emph{open}.


Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_input.txt version [f56e13e871].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (ReactorTQ_input.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:39:20  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:19:08  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTQ_sspar.r)
## as siso_sspar ecxept that inputs/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTQ:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
x3 = c_p*t_s*v_r;

# Set the inputs
## Removed by MTT on Thu Jun  5 14:27:42 BST 2003: mttu(1) = f_s + 0.1*f_s*(t>0.01); # f (ReactorTQ)
reactortq__f	=  f_s + 0.1*f_s*(t>0.01); # f (ReactorTQ)

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_lbl.txt version [a344d9fe61].














































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system ReactorTQ (ReactorTQ_lbl.txt)
%SUMMARY ReactorTQ: Simple reactor model - with TQ loop inverted
%DESCRIPTION Pseudo bond graph reactor model (based on ancient version)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:19:08  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%ALIAS Rate Chemical/Rate

% Extra variables
%VAR t_s
%VAR f_s
%VAR t_0
%VAR c_0
%VAR rho
%VAR v_r
%VAR e_1
%VAR e_2
%VAR e_3
%VAR a
%VAR b
%VAR c
%VAR c_A
%VAR c_B
%VAR x1
%VAR x2
%VAR x3
%VAR q_S

%VAR h
%VAR k
%VAR n
%VAR q


% Port aliases

% Argument aliases

%% each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m_a	lin		effort,1
	m_b	lin		effort,1
	h_r	lin		effort,c_p

% Component type FMR
	rfa	lin		effort,1		
	rfb	lin		effort,1		
	rt	lin		effort,c_p

% Component type Rate
        AB	Rate	k_1,q_1,h_1,1
	BC	Rate	k_2,q_2,h_2,1
	AD	Rate	k_3,q_3,h_3,2

% Component type SS
	c_0	SS		c_0,internal
	c_b	SS		external,0
	f	SS		internal,external
	t	SS		t_s,internal
	t_0	SS		t_0,internal



Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_numpar.m version [ae40d20e8b].



























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttpar = ReactorTQ_numpar();
% mttpar = ReactorTQ_numpar();
%System ReactorTQ, representation numpar, language m;
%File ReactorTQ_numpar.m;
%Generated by MTT on Thu Aug 24 14:29:20 BST 2000;
%

#====== Set up the global variables ======#
global ...
     a ...
     b ...
     c ...
     c_0 ...
     c_a ...
     c_b ...
     c_p ...
     e_1 ...
     e_2 ...
     e_3 ...
     f_s ...
     h ...
     h_1 ...
     h_2 ...
     h_3 ...
     k ...
     k_1 ...
     k_2 ...
     k_3 ...
     n ...
     q ...
     q_1 ...
     q_2 ...
     q_3 ...
     q_s ...
     rho ...
     t_0 ...
     t_s ...
     v_r ...
     x1 ...
     x2 ...
     x3 ;
## Set parameters to zero
 a = 0.0;
 b = 0.0;
 c = 0.0;
 c_0 = 0.0;
 c_a = 0.0;
 c_b = 0.0;
 c_p = 0.0;
 e_1 = 0.0;
 e_2 = 0.0;
 e_3 = 0.0;
 f_s = 0.0;
 h = 0.0;
 h_1 = 0.0;
 h_2 = 0.0;
 h_3 = 0.0;
 k = 0.0;
 k_1 = 0.0;
 k_2 = 0.0;
 k_3 = 0.0;
 n = 0.0;
 q = 0.0;
 q_1 = 0.0;
 q_2 = 0.0;
 q_3 = 0.0;
 q_s = 0.0;
 rho = 0.0;
 t_0 = 0.0;
 t_s = 0.0;
 v_r = 0.0;
 x1 = 0.0;
 x2 = 0.0;
 x3 = 0.0;
 %  -*-octave-*- Put Emacs into octave-mode
 %  Numerical parameter file (ReactorTQ_numpar.txt)
 %  Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% Version control history
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% $Id$
 %  %% $Log$
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 % 
a =  0;				 %  Dummy
b =  0;				 %  Dummy
c =  0;				 %  Dummy
c_0 =  0;			 %  Dummy
c_a =  0;			 %  Dummy
c_b =  0;			 %  Dummy
c_p =  0;			 %  Dummy
e_1 =  0;			 %  Dummy
e_2 =  0;			 %  Dummy
e_3 =  0;			 %  Dummy
f_s =  0;			 %  Dummy
h =  0;				 %  Dummy
h_1 =  0;			 %  Dummy
h_2 =  0;			 %  Dummy
h_3 =  0;			 %  Dummy
k =  0;				 %  Dummy
k_1 =  0;			 %  Dummy
k_2 =  0;			 %  Dummy
k_3 =  0;			 %  Dummy
n =  0;				 %  Dummy
q =  0;				 %  Dummy
q_1 =  0;			 %  Dummy
q_2 =  0;			 %  Dummy
q_3 =  0;			 %  Dummy
q_s =  0;			 %  Dummy
rho =  0;			 %  Dummy
t_0 =  0;			 %  Dummy
t_s =  0;			 %  Dummy
v_r =  0;			 %  Dummy
x1 =  0;				 %  Dummy
x2 =  0;				 %  Dummy
x3 =  0;				 %  Dummy

 % 
rho =  900;			 %  Density
c_p =  5.0;			 %  Specific heat

 % 
k_1 =  2.5e10;			 %  Reaction rate constant
q_1 =  1e4;			 %  Exotherm constant
h_1 =  1e4;			 %  Heat of reaction

 % 
k_2 =  2.65e12;			 %  Reaction rate constant
q_2 =  1.2e4;			 %  Exotherm constant
h_2 =  1.2e4;			 %  Heat of reaction

 % 
k_3 =  6e7;			 %  Reaction rate constant
q_3 =  8e3;			 %  Exotherm constant
h_3 =  3e4;			 %  Heat of reaction

 % 
c_0 =  10;			 %  Inflow conc
t_0 =  530;			 %  Inflow temp

 % 
t_s =  530;			 %  Steady-state temp
f_s =  100;			 %  Steady-state flow








## Set up the parameter vector
  mttpar(1) 	= a;
  mttpar(2) 	= b;
  mttpar(3) 	= c;
  mttpar(4) 	= c_0;
  mttpar(5) 	= c_a;
  mttpar(6) 	= c_b;
  mttpar(7) 	= c_p;
  mttpar(8) 	= e_1;
  mttpar(9) 	= e_2;
  mttpar(10) 	= e_3;
  mttpar(11) 	= f_s;
  mttpar(12) 	= h;
  mttpar(13) 	= h_1;
  mttpar(14) 	= h_2;
  mttpar(15) 	= h_3;
  mttpar(16) 	= k;
  mttpar(17) 	= k_1;
  mttpar(18) 	= k_2;
  mttpar(19) 	= k_3;
  mttpar(20) 	= n;
  mttpar(21) 	= q;
  mttpar(22) 	= q_1;
  mttpar(23) 	= q_2;
  mttpar(24) 	= q_3;
  mttpar(25) 	= q_s;
  mttpar(26) 	= rho;
  mttpar(27) 	= t_0;
  mttpar(28) 	= t_s;
  mttpar(29) 	= v_r;
  mttpar(30) 	= x1;
  mttpar(31) 	= x2;
  mttpar(32) 	= x3;

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_numpar.txt version [099621e14f].
















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (ReactorTQ_numpar.txt)
# Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Dummies
a = 0;				# Dummy
b = 0;				# Dummy
c = 0;				# Dummy
c_0 = 0;			# Dummy
c_a = 0;			# Dummy
c_b = 0;			# Dummy
c_p = 0;			# Dummy
e_1 = 0;			# Dummy
e_2 = 0;			# Dummy
e_3 = 0;			# Dummy
f_s = 0;			# Dummy
h = 0;				# Dummy
h_1 = 0;			# Dummy
h_2 = 0;			# Dummy
h_3 = 0;			# Dummy
k = 0;				# Dummy
k_1 = 0;			# Dummy
k_2 = 0;			# Dummy
k_3 = 0;			# Dummy
n = 0;				# Dummy
q = 0;				# Dummy
q_1 = 0;			# Dummy
q_2 = 0;			# Dummy
q_3 = 0;			# Dummy
q_s = 0;			# Dummy
rho = 0;			# Dummy
t_0 = 0;			# Dummy
t_s = 0;			# Dummy
v_r = 0;			# Dummy
x1 = 0;				# Dummy
x2 = 0;				# Dummy
x3 = 0;				# Dummy

## The bulk liquid
rho = 900;			# Density
c_p = 5.0;			# Specific heat

## Substance A
k_1 = 2.5e10;			# Reaction rate constant
q_1 = 1e4;			# Exotherm constant
h_1 = 1e4;			# Heat of reaction

## Substance B
k_2 = 2.65e12;			# Reaction rate constant
q_2 = 1.2e4;			# Exotherm constant
h_2 = 1.2e4;			# Heat of reaction

## Substance C
k_3 = 6e7;			# Reaction rate constant
q_3 = 8e3;			# Exotherm constant
h_3 = 3e4;			# Heat of reaction

## Inflow parameters
c_0 = 10;			# Inflow conc
t_0 = 530;			# Inflow temp

## Steady-state values
t_s = 530;			# Steady-state temp
f_s = 100;			# Steady-state flow








Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_pic.fig version [c396b14562].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Landscape
Center
Inches
Letter  
100.00
Single
-2
1200 2
6 2400 3150 3225 3375
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2625 3300 2925 3300
4 0 -1 0 0 2 20 0.0000 4 210 210 2400 3375 A\001
4 0 -1 0 0 2 20 0.0000 4 210 225 3000 3375 D\001
-6
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 2100 2100 3900 1500 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 1500 4050 3900 4050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 1500 4350 2100 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2100 3600 3900 4200 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 3600 4350 4200 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 3900 4050 4200 4050
2 1 1 2 -1 -1 0 0 -1 6.000 0 0 -1 0 0 2
	 2100 2400 3600 2400
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2400 2925 2700 2925
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 3000 2925 3300 2925
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 2850 4800 2850 3750
4 0 -1 0 0 2 20 0.0000 4 210 210 2175 3000 A\001
4 0 -1 0 0 2 20 0.0000 4 210 195 2775 3000 B\001
4 0 -1 0 0 2 20 0.0000 4 210 210 3375 3000 C\001
4 0 -1 0 0 2 20 0.0000 4 210 150 2250 3375 2\001
4 0 -1 0 0 3 12 0.0000 4 135 90 1875 4950 0\001
4 0 -1 0 0 3 12 0.0000 4 135 90 2250 4950 0\001
4 0 -1 0 0 3 20 0.0000 4 210 150 2775 5025 q\001
4 0 -1 0 0 3 20 0.0000 4 285 765 1500 4800 f , c  , t\001
4 0 -1 0 0 3 20 0.0000 4 285 765 3600 4800 f , c  , t\001
4 0 -1 0 0 3 12 0.0000 4 135 90 3975 4950 b\001
4 0 -1 0 0 3 12 0.0000 4 90 75 4350 4950 r\001

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_rep.txt version [eb12752c52].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system ReactorTQ (ReactorTQ_rep.txt)
## Generated by MTT on" Fri Mar  3 12:13:34 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:19:08  peterg
## To RCS
##
###############################################################

mtt ReactorTQ abg tex			# The system description
mtt ReactorTQ cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt ReactorTQ struc tex	        # The system structure
## mtt ReactorTQ dae tex	        # The system dae
mtt ReactorTQ ode tex	        # The system ode 
## mtt ReactorTQ sspar tex		# Steady-state parameters
## mtt ReactorTQ ss tex 		# Steady state
## mtt ReactorTQ dm tex		# Descriptor matrices (of linearised system)
mtt ReactorTQ sm tex		# State matrices (of linearised system)
## mtt ReactorTQ tf tex		# Transfer function (of linearised system)
## mtt ReactorTQ lmfr ps		# log modulus of frequency response (of linearised system)
mtt ReactorTQ simpar tex		# Simulation parameters
mtt ReactorTQ numpar tex		# Numerical simulation parameters
mtt ReactorTQ input tex		# Simulation input
mtt ReactorTQ state tex		# Simulation initial state

mtt  ReactorTQ odeso ps

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_simp.r version [c0625028b5].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output (mimo_sim.r)
m_r   := rho*v_r;
%mttx1 := c_a*v_r;
%mttx2 := c_b*v_r;

% THIS MUST BE CHANGED - probs with cp and FMRs
%c_p := 1;

%let mttx3/c_p = t;

let  e^(q_1/(mttx3/c_p)) = 1/epsilon_1;
let  e^(q_2/(mttx3/c_p)) = 1/epsilon_2;
let  e^(q_3/(mttx3/c_p)) = 1/epsilon_3;

let  e^(q_1/t_s) = 1/epsilon_1;
let  e^(q_2/t_s) = 1/epsilon_2;
let  e^(q_3/t_s) = 1/epsilon_3;

FACTOR mttx1,mttx2;

END;

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_simpar.txt version [c234b6a60c].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ReactorTQ (ReactorTQ_simpar.txt)
# Generated by MTT on Fri Mar 3 12:11:48 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 0.05;       # Last time in simulation
DT          = 0.0002;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_sm.m version [7b078c7c09].




































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [mtta,mttb,mttc,mttd] = ReactorTQ_sm(mttpar);
% [mtta,mttb,mttc,mttd] = ReactorTQ_sm(mttpar);
%System ReactorTQ, representation sm, language m;
%File ReactorTQ_sm.m;
%Generated by MTT on Thu Aug 24 14:47:46 BST 2000;
%
%====== Set up the global variables ======%
global ...
a ...
b ...
c ...
c_0 ...
c_a ...
c_b ...
c_p ...
e_1 ...
e_2 ...
e_3 ...
f_s ...
h ...
h_1 ...
h_2 ...
h_3 ...
k ...
k_1 ...
k_2 ...
k_3 ...
n ...
q ...
q_1 ...
q_2 ...
q_3 ...
q_s ...
rho ...
t_0 ...
t_s ...
v_r ...
x1 ...
x2 ...
x3 ;
a 	= mttpar(1);
b 	= mttpar(2);
c 	= mttpar(3);
c_0 	= mttpar(4);
c_a 	= mttpar(5);
c_b 	= mttpar(6);
c_p 	= mttpar(7);
e_1 	= mttpar(8);
e_2 	= mttpar(9);
e_3 	= mttpar(10);
f_s 	= mttpar(11);
h 	= mttpar(12);
h_1 	= mttpar(13);
h_2 	= mttpar(14);
h_3 	= mttpar(15);
k 	= mttpar(16);
k_1 	= mttpar(17);
k_2 	= mttpar(18);
k_3 	= mttpar(19);
n 	= mttpar(20);
q 	= mttpar(21);
q_1 	= mttpar(22);
q_2 	= mttpar(23);
q_3 	= mttpar(24);
q_s 	= mttpar(25);
rho 	= mttpar(26);
t_0 	= mttpar(27);
t_s 	= mttpar(28);
v_r 	= mttpar(29);
x1 	= mttpar(30);
x2 	= mttpar(31);
x3 	= mttpar(32);
%a matrix%
mtta = zeros(2,2);
mtt_t1 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t1 = -sqrt((mtt_t1+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtta(1,1) = mtt_t1/abs(exp(q_1/t_s));
mtta(2,1) = k_1/exp(q_1/t_s);
mtta(2,2) = (-(exp(q_2/t_s)*f_s)-k_2)/exp(q_2/t_s);
%b matrix%
mttb = zeros(2,1);
mtt_t1 = exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))*f_s+2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_0*k_3;
mtt_t1 = mtt_t1+exp(q_3/t_s)*abs(exp(q_1/t_s))*k_1;
mtt_t3 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t1 = mtt_t1-(mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s)));
mttb(1) = mtt_t1/(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*k_3);
mtt_t1 = exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*k_1;
mtt_t3 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1+exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))*k_1^2-(mtt_t3*k_1);
mtt_t2 = 2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*f_s*k_3;
mttb(2) = mtt_t1/(mtt_t2+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*k_2*k_3);
%c matrix%
mttc = zeros(1,2);
mttc(1,2) = 1.0;
%d matrix%
mttd = zeros(1,1);

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_sspar.r version [686130de9e].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file (ReactorTQ_sspar.r)
%% as siso_sspar ecxept that inputs/states have different meaning
%% Steady state for constant c_a, c_b and t=t_s and f=f_s

%% Unit volume ReactorTQ:
v_r := 1;

%% Do the inputs first -- this avoids problems with reduce not
%% recognising that complicated expressions are zero

%% The exponentials.
e_1 := e^(-q_1/t_s);
e_2 := e^(-q_2/t_s);
e_3 := e^(-q_3/t_s);

%Steady-state input q needed to achieve steady-state t_s
q_s := -( 
        + (t_0-t_s)*f_s
        + e_1*h_1*k_1*x1
        + e_2*h_2*k_2*x2
        + e_3*h_3*k_3*x1^2
       );

%% The input at steady-state
MTTu1 := f_s;

%States (masses)
x1 := c_a*v_r;
x2 := c_b*v_r;

%Load up the vectors
MTTx1 := x1;
MTTx2 := x2;

MTTy1 := c_b;

%% Finally, solve for the steady-state concentrations
%% Solve for ca - a quadratic.
a 	:= k_3*e_3;	%ca^2 
b 	:= k_1*e_1 + f_s;	%ca^1 
c 	:= -c_0*f_s;

c_a	:= (-b + sqrt(b^2 - 4*a*c))/(2*a);

%% solve for c_b
c_b 	:= c_a*k_1*e_1/(f_s+k_2*e_2);


END;


Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_state.txt version [35bb494f8e].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# State specification (ReactorTQ_state.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:39:39  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:19:08  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTQ_sspar.r)
## as siso_sspar ecxept that states/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTQ:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;


## The two inputs at steady-state
##mttu(1) = f_s;

## Load up the states
## Removed by MTT on Thu Jun  5 14:25:48 BST 2003: mttx(1) = x1;
## Removed by MTT on Thu Jun  5 14:25:48 BST 2003: mttx(2) = x2;
reactortq__m_a	= x1;
reactortq__m_b	= x2;

Added mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_sympar.m version [b5bf2c1d7a].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function sympar = ReactorTQ_sympar();
% sympar = ReactorTQ_sympar();
%System ReactorTQ, representation sympar, language m;
%File ReactorTQ_sympar.m;
%Generated by MTT on Thu Aug 24 14:47:48 BST 2000;
%
global ...
mtt_no_globals ;
  sympar.a 	= 1; # ReactorTQ
  sympar.b 	= 2; # ReactorTQ
  sympar.c 	= 3; # ReactorTQ
  sympar.c_0 	= 4; # ReactorTQ
  sympar.c_A 	= 5; # ReactorTQ
  sympar.c_B 	= 6; # ReactorTQ
  sympar.c_p 	= 7; # ReactorTQ
  sympar.e_1 	= 8; # ReactorTQ
  sympar.e_2 	= 9; # ReactorTQ
  sympar.e_3 	= 10; # ReactorTQ
  sympar.f_s 	= 11; # ReactorTQ
  sympar.h 	= 12; # Rate
  sympar.h_1 	= 13; # ReactorTQ
  sympar.h_2 	= 14; # ReactorTQ
  sympar.h_3 	= 15; # ReactorTQ
  sympar.k 	= 16; # Rate
  sympar.k_1 	= 17; # ReactorTQ
  sympar.k_2 	= 18; # ReactorTQ
  sympar.k_3 	= 19; # ReactorTQ
  sympar.n 	= 20; # Rate
  sympar.q 	= 21; # Rate
  sympar.q_1 	= 22; # ReactorTQ
  sympar.q_2 	= 23; # ReactorTQ
  sympar.q_3 	= 24; # ReactorTQ
  sympar.q_S 	= 25; # ReactorTQ
  sympar.rho 	= 26; # ReactorTQ
  sympar.t_0 	= 27; # ReactorTQ
  sympar.t_s 	= 28; # ReactorTQ
  sympar.v_r 	= 29; # ReactorTQ
  sympar.x1 	= 30; # ReactorTQ
  sympar.x2 	= 31; # ReactorTQ
  sympar.x3 	= 32; # ReactorTQ

Added mtt/lib/examples/Components/OnePorts/OnePorts_abg.fig version [a2d62ed5ea].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 4725 2925 4500 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 2700 4725 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 3600 4725 3600 4500 3825
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 3375 3375 3825
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 4275 4725 4275 4500 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 4725 4950 4500 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 4725 4725 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 5625 4725 5625 4500 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 6300 4725 6300 4500 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 6075 3375 6525
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 5850 6750 2025 6750 2025 2475 5850 2475 5850 6750
4 1 0 100 0 18 18 0.0000 4 270 690 5265 3015 R:r_1\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 3015 SS:ss_1\001
4 1 0 100 0 18 18 0.0000 4 270 690 5265 3690 R:r_2\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 3690 SS:ss_2\001
4 1 0 100 0 18 18 0.0000 4 270 750 5265 4365 C:c_3\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 4365 SS:ss_3\001
4 1 0 100 0 18 18 0.0000 4 270 750 5265 5040 C:c_4\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 5040 SS:ss_4\001
4 1 0 100 0 18 18 0.0000 4 270 540 5265 5715 I:i_5\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 5715 SS:ss_5\001
4 1 0 100 0 18 18 0.0000 4 270 540 5265 6390 I:i_6\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 6390 SS:ss_6\001

Added mtt/lib/examples/Components/OnePorts/OnePorts_desc.tex version [940098c23a].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system OnePorts (OnePorts_desc.tex)
% Generated by MTT on Fri Apr 19 08:12:54 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/04/19 07:42:28  gawthrop
% %% Simple teaching examples
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{OnePorts} is
   displayed in Figure \Ref{fig:OnePorts_abg.ps}; it contains the one
   port components: \textbf{R}, \textbf{C} and \textbf{I} in each of
   the two possible causalities.

   Note that the \textbf{R} has no prefered causality and, in this
   case, a causal stroke must be provided by the user. On the other
   hand, the \textbf{C} and \textbf{I} components are assigned
   prefered causality by MTT in the 3rd and 5th cases where no stroke
   is assigned by ther user. In the 4th and 6th cases, the user
   provides a causal stroke to put the components into derivative
   causality. \Ref{fig:OnePorts_cbg-noargs.ps} shows the causality
   automatically completed for the 3rd and 5th cases.
   
   Section \Ref{sec:OnePorts_ode-noargs.tex} gives the system equations, $y_1$ to
   $y_6$ are the outputs (with the given causality) of the 6
   components and $u_1$ to $u_6$ are the coresponding inputs. $x_1$
   and $x_2$ are the states of the 3rd and 5th cases (ie integrated
   flow and effort respectively), $z_1$ and $z_2$ are the
   corresponding quantities for the the 4th and 6th cases, the two
   components in derivative causality.

Added mtt/lib/examples/Components/OnePorts/OnePorts_rep.txt version [9502ca8e13].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system OnePorts (OnePorts_rep.txt)
## Generated by MTT on" Thu Apr 18 08:49:49 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt OnePorts abg tex			# The system description
mtt OnePorts cbg ps 		        # The causal bond graph
mtt OnePorts struc tex	        # The system structure
mtt OnePorts sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt OnePorts dae tex	        # The system dae
mtt OnePorts ode tex	        # The system ode 
## mtt OnePorts sspar tex		# Steady-state parameters
## mtt OnePorts ss tex 		# Steady state
## mtt OnePorts dm tex		# Descriptor matrices (of linearised system)
## mtt OnePorts sm tex		# State matrices (of linearised system)
## mtt OnePorts tf tex		# Transfer function (of linearised system)
## mtt OnePorts lmfr ps		# log modulus of frequency response (of linearised system)
## mtt OnePorts simpar tex		# Simulation parameters
## mtt OnePorts numpar tex		# Numerical simulation parameters
## mtt OnePorts state tex		# Simulation initial state
## mtt OnePorts input tex		# Simulation input
## mtt OnePorts logic tex		# Logic control
## mtt OnePorts odeso ps		# Simulation output

## mtt OnePorts rep txt		# This file

Added mtt/lib/examples/Components/TwoPorts/TwoPorts_abg.fig version [94a8b07bb2].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2925 4050 2925 3825 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 2925 6525 2925 6300 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2700 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 3825 4050 3825 3825 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 6525 3825 6300 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4725 4050 4725 3825 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 4725 6525 4725 6300 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 4500 5175 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 5625 4050 5625 3825 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 5625 6525 5625 6300 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 5400 4050 5850
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8100 6300 1125 6300 1125 2250 8100 2250 8100 6300
4 1 0 100 0 18 18 0.0000 4 270 900 4635 3015 TF:n_1\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 3015 SS:ss_11\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 3015 SS:ss_12\001
4 1 0 100 0 18 18 0.0000 4 270 900 4635 3915 TF:n_2\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 3915 SS:ss_21\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 3915 SS:ss_22\001
4 1 0 100 0 18 18 0.0000 4 270 960 4635 4815 GY:n_3\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 4815 SS:ss_31\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 4815 SS:ss_32\001
4 1 0 100 0 18 18 0.0000 4 270 960 4635 5715 GY:n_4\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 5715 SS:ss_41\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 5715 SS:ss_42\001

Added mtt/lib/examples/Components/TwoPorts/TwoPorts_desc.tex version [b3da0d8473].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system TwoPorts (TwoPorts_desc.tex)
% Generated by MTT on Fri Apr 19 08:12:54 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/04/19 07:47:45  gawthrop
% %% Simple teaching example.
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoPorts} is
   displayed in Figure \Ref{fig:TwoPorts_abg.ps}; it contains the two
   port components: \textbf{TF} and \textbf{GY} in each of
   the two possible causalities.
   
   Note that the neither component has prefered causality and, in both
   cases, a causal stroke must be provided by the user. 
   
   Section \Ref{sec:TwoPorts_ode-noargs.tex} gives the system equations.

Added mtt/lib/examples/Components/TwoPorts/TwoPorts_rep.txt version [287249d02f].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system TwoPorts (TwoPorts_rep.txt)
## Generated by MTT on" Thu Apr 18 08:45:30 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt TwoPorts abg tex			# The system description
mtt TwoPorts cbg ps 		        # The causal bond graph
mtt TwoPorts struc tex	        # The system structure
mtt TwoPorts sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt TwoPorts dae tex	        # The system dae
   mtt TwoPorts ode tex	        # The system ode 
## mtt TwoPorts sspar tex		# Steady-state parameters
## mtt TwoPorts ss tex 		# Steady state
## mtt TwoPorts dm tex		# Descriptor matrices (of linearised system)
## mtt TwoPorts sm tex		# State matrices (of linearised system)
## mtt TwoPorts tf tex		# Transfer function (of linearised system)
## mtt TwoPorts lmfr ps		# log modulus of frequency response (of linearised system)
## mtt TwoPorts simpar tex		# Simulation parameters
## mtt TwoPorts numpar tex		# Numerical simulation parameters
## mtt TwoPorts state tex		# Simulation initial state
## mtt TwoPorts input tex		# Simulation input
## mtt TwoPorts logic tex		# Logic control
## mtt TwoPorts odeso ps		# Simulation output

## mtt TwoPorts rep txt		# This file

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/INTFX_abg.fig version [d546a8c405].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3151 4501 3151 4276 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 2926 4726 2026 4951 2251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 3151 5851 3151 5626 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6975 4050 6975 1350 450 1350 450 4050 6975 4050
4 1 -1 0 0 0 20 0.0000 4 195 375 3151 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4726 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 600 4726 1891 CX:c\001
4 1 -1 0 0 0 20 0.0000 4 240 810 1306 3241 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 240 960 6346 3241 SS:[out]\001

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/INTFX_desc.tex version [9521268b12].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system INTFX (INTFX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 11:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTFX} is
   displayed in Figure \Ref{INTFX_abg} and its label
   file is listed in Section \Ref{sec:INTFX_lbl}.
   The subsystems are listed in Section \Ref{sec:INTFX_sub}.

\textbf{INTFX} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in].

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/INTFX_lbl.txt version [795adc6745].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY INTFX
%DESCRIPTION <Detailed description here>
%% Label file for system INTFX (INTFX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CX
	c		lin	effort,1

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/Makefile version [bb886d4f73].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Makefile for the Two link GMV example

all: msdp_tf.m twolinkp_obs.m twolinkp_sm.m TwoLinkGMV_numpar.m 

msdP_tf.m: msdP_abg.fig 
	mtt -q msdP tf m

msdp_tf.m: msdP_tf.m
	tr [A-Z] [a-z] <msdP_tf.m >msdp_tf.m

TwoLinkP_obs.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
	mtt -q TwoLinkP obs m

twolinkp_obs.m: TwoLinkP_obs.m
	tr [A-Z] [a-z] <TwoLinkP_obs.m >twolinkp_obs.m

TwoLinkP_sm.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
	mtt -q TwoLinkP sm m

twolinkp_sm.m: TwoLinkP_sm.m
	tr [A-Z] [a-z] <TwoLinkP_sm.m >twolinkp_sm.m

TwoLinkGMV_numpar.m: TwoLinkGMV_numpar.txt
	mtt -q TwoLinkGMV numpar m

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/RODaX_abg.fig version [69d5bf8861].





























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 1800 3375 1800 3600
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 IX:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTFX:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 4 0 0 0 20 0.0000 4 255 1215 1756 3286 SS:[alpha]\001

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/RODaX_desc.tex version [df20b89acf].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system RODaX (RODaX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/12 15:25:35  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{RODaX} is
   displayed in Figure \Ref{RODaX_abg} and its label
   file is listed in Section \Ref{sec:RODaX_lbl}.
   The subsystems are listed in Section \Ref{sec:RODaX_sub}.

{\bf RODaX} is essentially as described in Figure 10.2 of
``Metamodelling''. It has an additional port ``[angle]'' to provide
access to the rod angle.

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/RODaX_lbl.txt version [25a69a9380].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	RODaX: rigid rod in two dimensions - angle port.
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION	Port [alpha]:	rod angle
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system RODaX (RODaX_lbl.txt)




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/04/12 15:24:06  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2



	

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_abg.fig version [b9d6a07d06].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 8550 9225 8550 9000 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 8325 9225 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 9450 9225 9450 9000 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 9225 9225 9675
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10215 2475 10215 2475 7650 11025 7650 11025 10215
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 8325 5625 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 9225 5625 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3825 5625 3825 8550 5625 8550 5400 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3375 6525 3375 9450 5625 9450 5400 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 5400 9225 5400 9000 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 5175 9225 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 6300 9225 6300 9000 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 6075 9225 6525
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 7065 2475 7065 2475 4500 11025 4500 11025 7065
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5400 5625 5400 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 5175 5625 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 6300 5625 6300 5400 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 6075 5625 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 5400 3600 5400 3375 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 5175 3600 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6300 3150 6300 2925 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 6075 3150 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 2250 9225 2250 9000 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2025 9225 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 9225 3150 9000 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2925 9225 3375
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 3915 2475 3915 2475 1350 11025 1350 11025 3915
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2025 5625 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5625 3150 5400 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2925 5625 3375
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 8640 SS:Theta_1_m\001
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 9540 SS:Theta_2_m\001
4 1 -1 0 0 22 20 0.0000 4 210 2445 6750 9090 TwoLinkPX:model\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 8415 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 9315 [Theta_2]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 8415 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 9315 [Joint_2]\001
4 1 1 1 0 3 26 0.0000 4 270 1005 6750 10080 Model\001
4 1 -1 0 0 22 20 0.0000 4 270 2415 6750 5940 TwoLinkP:system\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 5265 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 6165 [Theta_2]\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 5490 SS:Theta_1\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 6390 SS:Theta_2\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 5265 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 6165 [Joint_2]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3825 5490 0\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1935 6390 SS:Tau_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1980 5490 SS:Tau_1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3375 6390 0\001
4 1 1 1 0 3 26 0.0000 4 360 1110 6705 6885 System\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 2340 SS:Theta_1_r\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 3240 SS:Theta_2_r\001
4 1 1 1 0 3 26 0.0000 4 360 2055 6705 3735 Specification\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 2340 msdP:spec_1\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 3195 msdP:spec_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 4005 2340 SS:Ref_1\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 3960 3240 SS:Ref_2\001

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_args.new version [5936bc7523].


1
+
 

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_desc.tex version [430b6e90d4].


































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system TwoLinkGMV (TwoLinkGMV_desc.tex)
% Generated by MTT on Wed Apr 15 18:15:23 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/15 18:41:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkGMV} is
   displayed in Figure \Ref{TwoLinkGMV_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkGMV_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkGMV_sub}.

This composite system provides an illustration of nonlinear
generalised minimum variance (GMV) control (continuous-time) operating on a
twolink manipulator. GMV can also be interpreted as:
\begin{itemize}
\item the exact linearisation (by feedback) followed by a
  pole-placement design on the resulting linear system and
\item a special case of generalised predictive control (GPC) were the
  prediction horizon is zero and the $P(s)$ polynomial is the same as
  the system relative degree and
\item One possible instance of physical-model-based control.
\end{itemize}

The composite system of Figure \Ref{TwoLinkGMV_abg} has three
(visible) parts:
\begin{enumerate}
\item a linear decoupled \emph{specification} system that describes the desired
  closed-loop system in terms of a physical system (two decoupled
  mass-spring-damper systems),
\item the system itself (a two-link manipulator) representing the
  system to be controlled, more details are given in Sections
  \Ref{sec:TwoLinkP_ode.tex} and \Ref{sec:TwoLinkP_rfe.tex}.
\item a model of the system with additional state inputs to be used as
  a state observer.
\end{enumerate}
The invisible parts are implemented in the text file
``TwoLinkGMV\_input.txt'' (see Section \Ref{sec:TwoLinkGMV_input.txt}).
These parts are:
\begin{itemize}
\item the reference signal (joint angles)
  \begin{equation}
    w(t) = 
    \begin{cases}
      \begin{pmatrix}
        \pi \\
        0
      \end{pmatrix} & 0 \ge t > 10 \\
      \begin{pmatrix}
        2\pi \\
        0
      \end{pmatrix} & 10 \ge t > 15 \\
      \begin{pmatrix}
        2\pi \\
        \pi
      \end{pmatrix} & 15 \ge t > 30 \\
    \end{cases}
  \end{equation}
\item The control signal (joint torques) being the solution of 
  \begin{equation}
    \phi^*(t) = O_o(\hat x(t)) + O_h(\hat x(t)) u(t) = w(t)
  \end{equation}
where $\hat x$ is the observed state.
\item The observer feedback signal
  \begin{equation}
    u_x = K ( y - \hat y)
  \end{equation}
where $K$ is the observer gain matrix and $y$ and $\hat y$ are the
system and model outputs respectively.
\end{itemize}
The observer gain is set up on the basis of the \emph{linearised}
system using LQ theory. This is implemented in the text file
``TwoLinkGMV\_state.txt'' (see Section \Ref{sec:TwoLinkGMV_state.txt})
using the Octave function ``lqe'' together with the MTT-generated
linearised system ``TwoLink\_sm''.


The system was simulated using Octave under MTT with the results given
in Figures
\Ref{fig:TwoLinkGMV_odeso.ps-TwoLinkGMV-Theta-1,TwoLinkGMV-Theta-1-r}
and
\Ref{fig:TwoLinkGMV_odeso.ps-TwoLinkGMV-Theta-2,TwoLinkGMV-Theta-2-r}
giving the actual and specification angles for joints 1 and 2
respectively.

The initial \emph{system} state was zero except that the angle of the
first rod was $\frac{\pi}{4}$. The initial \emph{observer} state was
(erroneously but deliberately) set at zero. This explains the
(decaying) discrepancy between the actual and specification angles.
Simulations with zero initial state gave precise matching.

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_input.txt version [4899e515e0].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkGMV_input.txt)
# Generated by MTT at Mon Apr 13 11:02:37 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

# Reference signals
u(1) =	 pi + pi*(t>10) ;			# TwoLinkGMV (Ref_1)
u(2) =	 pi*(t>15) ;			# TwoLinkGMV (Ref_2)

# Control signals
w = u(1:2);			# Reference signal
x_model = x(9:12);		# Observed states
[O_o, O_h] = TwoLinkP_obs(x_model) #GPC O function (affine case)
[spec_n,spec_d] = msdP_tf;	# Spec transfer function
P = spec_d(3:-1:1);		# P poly with ascending coeffs
PP = [eye(2)*P(1) eye(2)*P(2) eye(2)*P(3)]; 
PO_o = PP*O_o;			# Compute Py with u zero
PO_h = PP*O_h;			# Coefficient of u
u_control =  PO_h\(w - PO_o);	# GMV control signal

u(3:4) = u_control;		# TwoLinkGMV (Tau_1)

# Observer
x_system = x(5:8);		# System states
error = x_system-x_model;	# Error in states
ObserverInput = ObserverGain*error;
u(5:8) = ObserverInput;		# Set the state-input to the observer

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_lbl.txt version [ad79cbc64e].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkGMV - GMV control of two-link manipulator
%DESCRIPTION This composite system provides an illustration
%DESCRIPTION of nonlinear generalised minimum variance (GMV) control
%DESCRIPTION (continuous-time) operating on a twolink manipulator. 

%% Label file for system TwoLinkGMV (TwoLinkGMV_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	Ref_1		SS	external,internal
	Ref_2		SS	external,internal
	Tau_1		SS	external,internal
	Tau_2		SS	external,internal

	Theta_1		SS	external,0
	Theta_2		SS	external,0

	Theta_1_m	SS	external,0
	Theta_2_m	SS	external,0

	Theta_1_r	SS	external,0
	Theta_2_r	SS	external,0

% Component type msdP
	spec_1
	spec_2

% Component type TwoLinkP
	system

% Component type TwoLinkPX
	model


Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_numpar.txt version [ccf91065f0].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkGMV_numpar.txt)
# Generated by MTT at Mon Apr 13 10:57:02 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_s = 	1.0; # msdP
j_s = 	1.0; # msdP
r_s = 	1.414; # msdP

j_r = 	1.0; # TwoLinkP,TwoLinkPX
l_r = 	1.0; # TwoLinkP,TwoLinkPX
m_r = 	1.0; # TwoLinkP,TwoLinkPX

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_obspar.r version [c3ef6ba928].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce  GPC observability function parameters for system TwoLinkGMV (TwoLinkGMV_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_rep.txt version [5a83bbbd32].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TwoLinkGMV (TwoLinkGMV_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkGMV abg tex
mtt TwoLinkGMV struc tex
mtt TwoLinkGMV sympar tex

mtt TwoLinkP struc tex
mtt TwoLinkP rfe tex
mtt TwoLinkP ode tex
mtt TwoLinkP obs tex

mtt TwoLinkP ss tex
mtt TwoLinkP sm tex

mtt msdP tf tex

mtt TwoLinkGMV numpar txt
mtt TwoLinkGMV state txt
mtt TwoLinkGMV input txt
mtt TwoLinkGMV odeso ps 'TwoLinkGMV_Theta_1,TwoLinkGMV_Theta_1_r'
mtt TwoLinkGMV odeso ps 'TwoLinkGMV_Theta_2,TwoLinkGMV_Theta_2_r'

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_simpar.txt version [49dd11c4f0].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system TwoLinkGMV (TwoLinkGMV_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30.0
DT=0.2
STEPFACTOR=1

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_simpar.txt_old version [49dd11c4f0].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system TwoLinkGMV (TwoLinkGMV_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30.0
DT=0.2
STEPFACTOR=1

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_sspar.r version [5689628a58].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (TwoLinkGMV_sspar.r)
% Generated by MTT at Tue Apr 14 08:47:47 BST 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	0; % TwoLinkGMV_spec_1 (c_s)
MTTX2 := 	0; % TwoLinkGMV_spec_1 (j_s)
MTTX3 := 	0; % TwoLinkGMV_spec_2 (c_s)
MTTX4 := 	0; % TwoLinkGMV_spec_2 (j_s)
MTTX5 := 	0; % TwoLinkGMV_system_rod1 (J)
MTTX6 := 	0; % TwoLinkGMV_system_rod1_th (3)
MTTX7 := 	0; % TwoLinkGMV_system_rod2 (J)
MTTX8 := 	0; % TwoLinkGMV_system_rod2_th (3)
MTTX9 := 	0; % TwoLinkGMV_model_rod1_J (i)
MTTX10 := 	0; % TwoLinkGMV_model_rod1_th_c (c)
MTTX11 := 	0; % TwoLinkGMV_model_rod2_J (i)
MTTX12 := 	0; % TwoLinkGMV_model_rod2_th_c (c)
% Steady-state inputs
MTTU1 := 	1; % TwoLinkGMV (Ref_1)
MTTU2 := 	1; % TwoLinkGMV (Ref_2)
MTTU3 := 	0; % TwoLinkGMV (Tau_1)
MTTU4 := 	0; % TwoLinkGMV (Tau_2)
MTTU5 := 	0; % TwoLinkGMV_model_rod1_J (X)
MTTU6 := 	0; % TwoLinkGMV_model_rod1_th_c (X)
MTTU7 := 	0; % TwoLinkGMV_model_rod2_J (X)
MTTU8 := 	0; % TwoLinkGMV_model_rod2_th_c (X)
;;END;

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_state.txt version [73974e101a].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkGMV_state.txt)
# Generated by MTT at Tue Apr 14 08:54:28 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

# Set the states
x(1) =	 0 ; # TwoLinkGMV_spec_1 (c_s)
x(2) =	 0 ; # TwoLinkGMV_spec_1 (j_s)
x(3) =	 0 ; # TwoLinkGMV_spec_2 (c_s)
x(4) =	 0 ; # TwoLinkGMV_spec_2 (j_s)
x(5) =	 0 ; # TwoLinkGMV_system_rod1 (J)
x(6) =	 pi/4 ; # TwoLinkGMV_system_rod1_th (3)
x(7) =	 0 ; # TwoLinkGMV_system_rod2 (J)
x(8) =	 0 ; # TwoLinkGMV_system_rod2_th (3)
x(9) =	 0 ; # TwoLinkGMV_model_rod1_J (i)
x(10) =	 0 ; # TwoLinkGMV_model_rod1_th_c (c)
x(11) =	 0 ; # TwoLinkGMV_model_rod2_J (i)
x(12) =	 0 ; # TwoLinkGMV_model_rod2_th_c (c)

# Observer design
[A,B,C] = TwoLinkP_sm;		# Get the linearised system
sigma = 0.1;			# Measurement noise variance (pretend)
k = lqe(A,eye(4),C,eye(4),sigma*eye(2))
ObserverGain = k*C;		# This system happens to have a linear output

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkPX_abg.fig version [9ab26d89d5].









































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3285 1575 3285 1800 3510
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3195 8055 1620 8055 1845 8280
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2025 1575 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 8325 1350 9450 1575 9225
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 7875 1350 3600 1575 3825
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4729 3379 RODaX:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4731 8196 RODaX:rod2\001
4 1 4 0 0 0 20 0.0000 4 255 1410 4771 946 SS:[Joint_1]\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5850 945 SS:v_y\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2882 5717 SS:[Joint_2]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3510 3375 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3555 8145 [alpha]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1308 8193 1\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1397 1892 SS:[Theta_1]\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1352 9767 SS:[Theta_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1263 3468 0\001

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkPX_desc.tex version [df58265a5a].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoLinkPX (TwoLinkPX_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkPX} is
   displayed in Figure \Ref{TwoLinkPX_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkPX_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkPX_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkPX_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkPX_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkPX_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkPX_lbl.txt version [fbab683c87].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkPX: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkPX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_abg.fig version [44cfade14b].









































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3285 1575 3285 1800 3510
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3195 8055 1620 8055 1845 8280
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2025 1575 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 8325 1350 9450 1575 9225
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 7875 1350 3600 1575 3825
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4729 3379 RODa:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4731 8196 RODa:rod2\001
4 1 4 0 0 0 20 0.0000 4 255 1410 4771 946 SS:[Joint_1]\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5850 945 SS:v_y\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2882 5717 SS:[Joint_2]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3510 3375 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3555 8145 [alpha]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1308 8193 1\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1397 1892 SS:[Theta_1]\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1352 9767 SS:[Theta_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1263 3468 0\001

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_cr.txt version [981cde0c6a].




1
2
3
+
+
+
lcos
lin
lsin

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_desc.tex version [6d2b3ecef6].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoLinkP (TwoLinkP_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkP} is
   displayed in Figure \Ref{TwoLinkP_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkP_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkP_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkP_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkP_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkP_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_lbl.txt version [a70a30e484].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkP: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_obspar.r version [ea44a77131].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce  GPC observability function parameters for system TwoLinkP (TwoLinkP_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_subs.r version [87b1a943f2].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce  substitution statements for system TwoLinkPX (TwoLinkPX_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/22 20:13:25  peterg
% %% Trig simplification added
% %%
% %% Revision 1.1  1998/03/22 20:12:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/msdP_abg.fig version [783d02bd00].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 6975 8325 1125 1125 1125 1125 6975 8325 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 5355 4815 6345 Mass-spring-damper system (position output)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 0 4 0 0 0 20 0.0000 4 240 960 6660 4140 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/msdP_desc.tex version [be83adfdb1].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system msdP (msdP_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msdP} is
   displayed in Figure \Ref{msdP_abg} and its label
   file is listed in Section \Ref{sec:msdP_lbl}.
   The subsystems are listed in Section \Ref{sec:msdP_sub}.


 \textbf{msdP} is a simple Mass-Spring-Damper system with 
 force input and position output. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GMV/TwoLinkGMV/msdP_lbl.txt version [dee478e657].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY msdP
%DESCRIPTION <Detailed description here>
%% Label file for system msdP (msdP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_s		lin	effort,c_s

% Component type I
	j_s		lin	flow,j_s

% Component type R
	r_s		lin	flow,r_s

% Component type SS
	[in]		SS	external,internal
	[out]		SS	external,0

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/INTFX_abg.fig version [d546a8c405].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3151 4501 3151 4276 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 2926 4726 2026 4951 2251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 3151 5851 3151 5626 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6975 4050 6975 1350 450 1350 450 4050 6975 4050
4 1 -1 0 0 0 20 0.0000 4 195 375 3151 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4726 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 600 4726 1891 CX:c\001
4 1 -1 0 0 0 20 0.0000 4 240 810 1306 3241 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 240 960 6346 3241 SS:[out]\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/INTFX_desc.tex version [9521268b12].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system INTFX (INTFX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 11:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTFX} is
   displayed in Figure \Ref{INTFX_abg} and its label
   file is listed in Section \Ref{sec:INTFX_lbl}.
   The subsystems are listed in Section \Ref{sec:INTFX_sub}.

\textbf{INTFX} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in].

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/INTFX_lbl.txt version [795adc6745].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY INTFX
%DESCRIPTION <Detailed description here>
%% Label file for system INTFX (INTFX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CX
	c		lin	effort,1

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/RODaX_abg.fig version [69d5bf8861].





























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 1800 3375 1800 3600
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 IX:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTFX:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 4 0 0 0 20 0.0000 4 255 1215 1756 3286 SS:[alpha]\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/RODaX_desc.tex version [df20b89acf].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system RODaX (RODaX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/12 15:25:35  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{RODaX} is
   displayed in Figure \Ref{RODaX_abg} and its label
   file is listed in Section \Ref{sec:RODaX_lbl}.
   The subsystems are listed in Section \Ref{sec:RODaX_sub}.

{\bf RODaX} is essentially as described in Figure 10.2 of
``Metamodelling''. It has an additional port ``[angle]'' to provide
access to the rod angle.

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/RODaX_lbl.txt version [1c79a51b36].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	RODaX: rigid rod in two dimensions - angle port.
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION	Port [alpha]:	rod angle
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system RODaX (RODaX_lbl.txt)




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/04/12 15:24:06  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/Sensor_abg.fig version [8f5341f4f9].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2025 3825 2025 3600 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 2025 5850 2025 5625 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3600 7875 3600 7650 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 1800 2475 2295
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 3375 6075 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 1800 5850 2295
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3600 3825 3600 3600 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3600 6075 3600 5850 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 3330 6300 2205 6525 2430
4 2 4 0 0 0 20 0.0000 4 240 720 2385 2115 SS:[v]\001
4 1 -1 0 0 0 20 0.0000 4 195 420 4140 2115 GY\001
4 1 -1 0 0 0 20 0.0000 4 195 840 6345 2070 AE:tau\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6300 3690 1\001
4 2 4 0 0 0 20 0.0000 4 255 720 2475 3690 SS:[p]\001
4 0 4 0 0 0 20 0.0000 4 240 690 8055 3645 SS:[s]\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4050 3690 AE\001
4 2 4 0 0 0 20 0.0000 4 240 405 5760 1755 [in]\001
4 2 4 0 0 0 20 0.0000 4 240 555 6255 2565 [out]\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/Sensor_lbl.txt version [c79dfd35bb].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Sensor
%DESCRIPTION <Detailed description here>
%% Label file for system Sensor (Sensor_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type AE
	tau		lin	tau

% Component type SS
	[p]		SS	external,external
	[s]		SS	external,external
	[v]		SS	external,external

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_abg.fig version [0183aa4021].































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 8550 9225 8550 9000 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 8325 9225 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 9450 9225 9450 9000 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 9225 9225 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 8325 5625 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 9225 5625 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3825 5625 3825 8550 5625 8550 5400 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3375 6525 3375 9450 5625 9450 5400 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 5400 9225 5400 9000 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 5175 9225 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 6300 9225 6300 9000 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 6075 9225 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5400 5625 5400 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 5175 5625 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 6300 5625 6300 5400 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 6075 5625 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 5400 3600 5400 3375 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 5175 3600 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6300 3150 6300 2925 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 6075 3150 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 2250 9225 2250 9000 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2025 9225 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 9225 3150 9000 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2925 9225 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2025 5625 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5625 3150 5400 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2925 5625 3375
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3915 2475 3915 2475 1350 11475 1350 11475 3915
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 7020 2475 7020 2475 4500 11475 4500 11475 7020
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 10215 2475 10215 2475 7650 11475 7650 11475 10215
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 8640 SS:Theta_1_m\001
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 9540 SS:Theta_2_m\001
4 1 -1 0 0 22 20 0.0000 4 210 2640 6750 9090 TwoLinkPSX:model\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 8415 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 9315 [Theta_2]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 8415 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 9315 [Joint_2]\001
4 1 1 1 0 3 26 0.0000 4 270 1005 6750 10080 Model\001
4 1 -1 0 0 22 20 0.0000 4 270 2610 6750 5940 TwoLinkPS:system\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 5265 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 6165 [Theta_2]\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 5490 SS:Theta_1\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 6390 SS:Theta_2\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 5265 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 6165 [Joint_2]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3825 5490 0\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1935 6390 SS:Tau_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1980 5490 SS:Tau_1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3375 6390 0\001
4 1 1 1 0 3 26 0.0000 4 360 1110 6705 6885 System\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 2340 SS:Theta_1_r\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 3240 SS:Theta_2_r\001
4 1 1 1 0 3 26 0.0000 4 360 2055 6705 3735 Specification\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 2340 msdP:spec_1\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 3195 msdP:spec_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 4005 2340 SS:Ref_1\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 3960 3240 SS:Ref_2\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_desc.tex version [98eee8129d].
















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system TwoLinkGPC (TwoLinkGPC_desc.tex)
% Generated by MTT on Wed Apr 15 18:15:23 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/15 18:41:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkGPC} is
   displayed in Figure \Ref{TwoLinkGPC_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkGPC_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkGPC_sub}.
   
   This example provides an illustration of nonlinear generalised
   predictive control (GPC) (continuous-time) operating on a twolink
   manipulator with a modified sensor.  The  sensor is modified in a
   rather contrived way to give a nonlinear system with an
   \emph{unstable} inverse. The idea is that the sensor approximates a
   pure delay of $\tau$ as:
   \begin{equation}
     e^{-s\tau} \approx 1 - s \tau
   \end{equation}
   
   The example contrasts GPC with GMV, which can also be interpreted
   as:
\begin{itemize}
\item the exact linearisation (by feedback) followed by a
  pole-placement design on the resulting linear system and
\item a special case of generalised predictive control (GPC) were the
  prediction horizon is zero and the $P(s)$ polynomial is the same as
  the system relative degree and
\end{itemize}


The composite system of Figure \Ref{TwoLinkGPC_abg} has three
(visible) parts:
\begin{enumerate}
\item a linear decoupled \emph{specification} system that describes the desired
  closed-loop system in terms of a physical system (two decoupled
  mass-spring-damper systems),
\item the system itself (a two-link manipulator) representing the
  system to be controlled, more details are given in Sections
  \Ref{sec:TwoLinkP_ode.tex} and \Ref{sec:TwoLinkP_rfe.tex}.
\item a model of the system with additional state inputs to be used as
  a state observer.
\end{enumerate}
The invisible parts are implemented in the text file
``TwoLinkGPC\_input.txt'' (see Section \Ref{sec:TwoLinkGPC_input.txt}).
These parts are:
\begin{itemize}
\item the reference signal (joint angles)
  \begin{equation}
    w(t) = 
    \begin{cases}
      \begin{pmatrix}
        \pi \\
        0
      \end{pmatrix} & 0 \ge t > 10 \\
      \begin{pmatrix}
        2\pi \\
        0
      \end{pmatrix} & 10 \ge t > 15 \\
      \begin{pmatrix}
        2\pi \\
        \pi
      \end{pmatrix} & 15 \ge t > 30 \\
    \end{cases}
  \end{equation}
\item The control signal (joint torques) being the solution of 
  \begin{equation}
    \phi^*(t) = O_o(\hat x(t)) + O_h(\hat x(t)) u(t) = w(t)
  \end{equation}
where $\hat x$ is the observed state.
\item The observer feedback signal
  \begin{equation}
    u_x = K ( y - \hat y)
  \end{equation}
where $K$ is the observer gain matrix and $y$ and $\hat y$ are the
system and model outputs respectively.
\end{itemize}
The observer gain is set up on the basis of the \emph{linearised}
system using LQ theory. This is implemented in the text file
``TwoLinkGPC\_state.txt'' (see Section \Ref{sec:TwoLinkGPC_state.txt})
using the Octave function ``lqe'' together with the MTT-generated
linearised system ``TwoLink\_sm''.


The system was simulated using Octave under MTT with the results given
in Figures
\Ref{fig:TwoLinkGPC_odeso.ps-TwoLinkGPC-Theta-1,TwoLinkGPC-Theta-1-r}
and
\Ref{fig:TwoLinkGPC_odeso.ps-TwoLinkGPC-Theta-2,TwoLinkGPC-Theta-2-r}
giving the actual and specification angles for joints 1 and 2
respectively.

The initial \emph{system} state was zero except that the angle of the
first rod was $\frac{\pi}{4}$. The initial \emph{observer} state was
(erroneously but deliberately) set at zero. This explains the
(decaying) discrepancy between the actual and specification angles.
Simulations with zero initial state gave precise matching.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_input.tex version [96bb3408b5].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Tex file (TwoLinkGPC_input.txt)
%% Generated by MTT at Wed Apr 29 11:21:32 BST 1998
\begin{verbatim}
# Numerical parameter file (TwoLinkGPC_input.txt)
# Generated by MTT at Mon Apr 13 11:02:37 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

if t<10
  tau = 0;
elseif t<20
  tau = 0.1;
else
  tau = 0.2;
end

# Reference signals
Period = 20;
u(1) =	 -pi*sign(cos(2*pi*t/Period))*(t>5); # TwoLinkGPC (Ref_1)
u(2) =	 pi*sign(sin(2*pi*t/Period)); # TwoLinkGPC (Ref_2)
w = u(1:2);			      # Reference signal

# Control signals
x_model = x(9:12);		# Observed states
[O_o, O_h] = TwoLinkPS_obs(x_model) #GPC O function (affine case)
[spec_n,spec_d] = msdP_tf;	# Spec transfer function
P = spec_d(3:-1:1);		# P poly with ascending coeffs
PP = [eye(2)*P(1) eye(2)*P(2) eye(2)*P(3)]; # Matrix version
PO_o = PP*O_o;			# Compute Py with u zero
PO_h = PP*O_h;			# Coefficient of u
u_control =  PO_h\(w - PO_o);	# GMV control signal

u(3:4) = u_control;		# TwoLinkGPC (Tau_1)

# Observer
x_system = x(5:8);		# System states
error = x_system-x_model;	# Error in states
ObserverInput = ObserverGain*error;
u(5:8) = ObserverInput;		# Set the state-input to the observer

\end{verbatim}

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_input.txt version [cc63da7250].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkGPC_input.txt)
# Generated by MTT at Mon Apr 13 11:02:37 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

if t<10
  tau = 0;
else
  tau = 0.1;
end

# Reference signals
Period = 20;
u(1) =	 -pi*sign(cos(2*pi*t/Period))*(t>5); # TwoLinkGPC (Ref_1)
u(2) =	 pi*sign(sin(2*pi*t/Period)); # TwoLinkGPC (Ref_2)
w = u(1:2);			      # Reference signal

# Control signals
x_model = x(9:12);		# Observed states
[O_o, O_h] = TwoLinkPS_obs(x_model) #GPC O function (affine case)
[spec_n,spec_d] = msdP_tf;	# Spec transfer function
P = spec_d(3:-1:1);		# P poly with ascending coeffs
PP = [eye(2)*P(1) eye(2)*P(2) eye(2)*P(3)]; # Matrix version
PO_o = PP*O_o;			# Compute Py with u zero
PO_h = PP*O_h;			# Coefficient of u
u_control =  PO_h\(w - PO_o);	# GMV control signal

u(3:4) = u_control;		# TwoLinkGPC (Tau_1)

# Observer
x_system = x(5:8);		# System states
error = x_system-x_model;	# Error in states
ObserverInput = ObserverGain*error;
u(5:8) = ObserverInput;		# Set the state-input to the observer

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_lbl.txt version [8c71877011].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkGPC - GPC control of two-link manipulator with delay
%DESCRIPTION This composite system provides an illustration
%DESCRIPTION of nonlinear GPC (Generalised Predictive Control) control
%DESCRIPTION (continuous-time) operating on a twolink manipulator. 

%% Label file for system TwoLinkGPC (TwoLinkGPC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/29 09:01:43  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	Ref_1		SS	external,internal
	Ref_2		SS	external,internal
	Tau_1		SS	external,internal
	Tau_2		SS	external,internal
	Theta_1		SS	external,0
	Theta_2		SS	external,0
	Theta_1_m	SS	external,0
	Theta_2_m	SS	external,0
	Theta_1_r	SS	external,0
	Theta_2_r	SS	external,0

% Component type msdP
	spec_1
	spec_2

% Component type TwoLinkP
	system

% Component type TwoLinkPX
	model

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_numpar.txt version [de52e6ae7d].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkGPC_numpar.txt)
# Generated by MTT at Mon Apr 13 10:57:02 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_s = 	1.0; # msdP
j_s = 	1.0; # msdP
r_s = 	2.0; # msdP
tau =   0.1; # msdP
l_r = 	0.5; # TwoLinkP,TwoLinkPX
m_r = 	1.0; # TwoLinkP,TwoLinkPX
j_r = 	m_r*l_r*l_r/3; # TwoLinkP,TwoLinkPX

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_obspar.r version [9796c5f718].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce  GPC observability function parameters for system TwoLinkGPC (TwoLinkGPC_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_rep.txt version [68da84bc7f].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TwoLinkGPC (TwoLinkGPC_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkGPC abg tex
mtt TwoLinkGPC struc tex
mtt TwoLinkGPC sympar tex

mtt TwoLinkPS struc tex
mtt TwoLinkPS rfe tex
mtt TwoLinkPS ode tex
mtt TwoLinkPS obs tex

mtt TwoLinkPS ss tex
mtt TwoLinkPS sm tex

mtt msdP tf tex

mtt TwoLinkGPC numpar txt
mtt TwoLinkGPC state txt
mtt TwoLinkGPC input txt

mtt TwoLinkGPC odeso ps 'TwoLinkGPC_Theta_1,TwoLinkGPC_Theta_1_r'
mtt TwoLinkGPC odeso ps 'TwoLinkGPC_Theta_2,TwoLinkGPC_Theta_2_r'



Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_simpar.txt version [85c8e666bb].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system TwoLinkGPC (TwoLinkGPC_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30
DT=0.1
STEPFACTOR=2

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_simpar.txt_old version [85c8e666bb].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system TwoLinkGPC (TwoLinkGPC_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30
DT=0.1
STEPFACTOR=2

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_state.txt version [50c9fbc84f].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkGPC_state.txt)
# Generated by MTT at Thu Apr 23 09:10:43 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

# Set the states
x(1) =	 0 ; # TwoLinkGPC_spec_1 (c_s)
x(2) =	 0 ; # TwoLinkGPC_spec_1 (j_s)
x(3) =	 0 ; # TwoLinkGPC_spec_2 (c_s)
x(4) =	 0 ; # TwoLinkGPC_spec_2 (j_s)
x(5) =	 0 ; # TwoLinkGPC_system_rod1 (J)
x(6) =	 0 ; # TwoLinkGPC_system_rod1_th (3)
x(7) =	 0 ; # TwoLinkGPC_system_rod2 (J)
x(8) =	 0 ; # TwoLinkGPC_system_rod2_th (3)
x(9) =	 0 ; # TwoLinkGPC_model_rod1_J (i)
x(10) =	 0 ; # TwoLinkGPC_model_rod1_th_c (c)
x(11) =	 0 ; # TwoLinkGPC_model_rod2_J (i)
x(12) =	 0 ; # TwoLinkGPC_model_rod2_th_c (c)

# Observer design
[A,B,C] = TwoLinkPS_sm;		# Get the linearised system
sigma = 0.1;			# Measurement noise variance (pretend)
k = lqe(A,eye(4),C,eye(4),sigma*eye(2))
ObserverGain = k*C;		# This system happens to have a linear output

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPSX_abg.fig version [9ab26d89d5].









































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3285 1575 3285 1800 3510
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3195 8055 1620 8055 1845 8280
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2025 1575 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 8325 1350 9450 1575 9225
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 7875 1350 3600 1575 3825
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4729 3379 RODaX:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4731 8196 RODaX:rod2\001
4 1 4 0 0 0 20 0.0000 4 255 1410 4771 946 SS:[Joint_1]\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5850 945 SS:v_y\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2882 5717 SS:[Joint_2]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3510 3375 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3555 8145 [alpha]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1308 8193 1\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1397 1892 SS:[Theta_1]\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1352 9767 SS:[Theta_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1263 3468 0\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPSX_desc.tex version [61db22c233].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoLinkPSX (TwoLinkPSX_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkPSX} is
   displayed in Figure \Ref{TwoLinkPSX_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkPSX_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkPSX_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkPSX_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkPSX_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkPSX_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPSX_lbl.txt version [b2d7b7efd0].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkPSX: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkPSX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_abg.fig version [7c9d2b5819].































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 11700 1800 485 485 11700 1800 11880 2250
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 11700 6300 485 485 11700 6300 12185 6785
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11745 11925 11745 450 45 450 45 11925 11745 11925
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7650 900 4725 900 4725 3375 3375 3375 3600 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 8505 4950 4230 5175 4455
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 6300 4052 6302 3827 6527
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4275 6525 4275 8325 3150 8325 3375 8550
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 7652 6300 7427 6525
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6618 1803 6888 1803
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8870 1805 9140 1805
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7743 3378 8013 3378
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7878 1125 7878 3378 8103 3153
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7652 6167 7652 6437
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 6526 7876 8101 8101 7876
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6622 9322 6892 9322
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7747 9322 8017 9322
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8874 9324 9144 9324
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7880 9320 7880 10895 8105 10670
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9005 9320 9005 10895 9230 10670
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6751 4501 6751 8101 6976 7876
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 4501 9001 8101 9226 7876
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 9450 9675 7875 6075 7875 6075 9450 9675 9450
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 7110 9675 5535 6075 5535 6075 7110 9675 7110
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 11925 9675 10350 6075 10350 6075 11925 9675 11925
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6753 1803 6753 3378 6978 3153
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9003 1803 9003 3378 9228 3153
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 4501 7876 6076 8101 5851
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 4725 6075 4725 6075 3150 9675 3150 9675 4725
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 9297 6750 10872 6975 10647
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 5850 11925 2250 11475 2250 11475 5850 11925 5850
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 10350 11925 6750 11475 6750 11475 10350 11925 10350
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 10800 1125 12555 1125 12555 1350 10800 1350 10800 1125
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9630 2745 9630 1170 6030 1170 6030 2745 9630 2745
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8910 900 8145 900 8370 1125
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2790 3735 2115 3735 2340 3960
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4725 3960 3330 3960 3555 4185
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3960 5040 3960 5265 4185
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 8550 2025 8550 2250 8775
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 8775 3150 8775 3375 9000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 8775 4905 8775 5130 9000
4 0 -1 0 0 0 20 0.0000 4 195 135 4863 4053 0\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2702 6392 SS:[Joint_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4188 6393 1\001
4 1 -1 0 0 0 20 0.0000 4 255 810 6753 1623 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 7833 6393 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 6758 11348 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 7883 11348 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 9053 11348 SS:F_y\001
4 0 1 1 0 3 20 0.0000 4 210 720 9945 4050 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 9900 6435 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 9900 8865 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 9900 11160 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 9900 1935 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 7875 3645 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 6750 4455 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 7875 4455 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 9000 4455 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 9000 3645 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 6755 8510 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 7880 8510 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 6757 9187 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 7883 9188 [alpha_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 9000 1620 SS:v_y\001
4 1 4 0 0 0 16 0.0000 4 210 495 6750 3645 [x_a]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 7788 993 1\001
4 0 4 0 0 0 20 0.0000 4 255 1410 9046 991 SS:[Joint_1]\001
4 2 4 0 0 0 20 0.0000 4 255 1530 1892 3827 SS:[Theta_1]\001
4 1 4 0 0 0 16 0.0000 4 210 240 2700 3555 [s]\001
4 1 -1 0 0 0 20 1.5708 4 195 780 3154 3731 Sensor\001
4 1 4 0 0 0 16 0.0000 4 225 270 3420 3825 [p]\001
4 1 4 0 0 0 16 0.0000 4 210 270 3330 3195 [v]\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 7879 4009 RODa:rod1\001
4 1 4 0 0 0 16 0.0000 4 225 675 6885 4005 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 210 270 3375 8235 [v]\001
4 1 4 0 0 0 16 0.0000 4 210 240 2655 8460 [s]\001
4 1 -1 0 0 0 20 1.5708 4 195 780 3064 8546 Sensor\001
4 2 4 0 0 0 20 0.0000 4 255 1530 1937 8642 SS:[Theta_2]\001
4 1 4 0 0 0 16 0.0000 4 225 270 3375 8730 [p]\001
4 1 4 0 0 0 16 0.0000 4 225 495 8780 8510 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 225 510 8739 9189 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 675 7065 8820 [alpha]\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 8061 8826 RODa:rod2\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4593 8823 1\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_desc.tex version [72bea7d311].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoLinkPS (TwoLinkPS_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkPS} is
   displayed in Figure \Ref{TwoLinkPS_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkPS_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkPS_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkPS_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkPS_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkPS_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_lbl.txt version [23b89fb091].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkPS: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkPS_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_obspar.r version [887f4afee4].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce  GPC observability function parameters for system TwoLinkPS (TwoLinkPS_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_simp.r version [5fa9cf5d7f].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce commands to simplify output for system TwoLinkP (TwoLinkP_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LET cos(mttx2) = c_2;
LET sin(mttx2) = s_2;

LET cos(mttx4) = c_4;
LET sin(mttx4) = s_4;

LET cos(mttx2-mttx4) = c;
LET sin(mttx2-mttx4) = s;

END;

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_subs.r version [47554050fc].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce  substitution statements for system TwoLinkPSX (TwoLinkPSX_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/22 20:13:25  peterg
% %% Trig simplification added
% %%
% %% Revision 1.1  1998/03/22 20:12:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_abg.fig version [9434c7d473].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4050 8100 4050 7875 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9000 4050 10125 4050 9900 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 6975 11475 1125 1125 1125 1125 6975 11475 6975
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 7035 4815 6345 Mass-spring-damper system (position output with extra lag)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001
4 1 -1 0 0 0 20 0.0000 4 195 390 6750 4140 AE\001
4 1 -1 0 0 0 20 0.0000 4 195 690 8550 4140 RC:rc\001
4 0 4 0 0 0 20 0.0000 4 240 960 10260 4140 SS:[out]\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_abg.fig.bak version [783d02bd00].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 6975 8325 1125 1125 1125 1125 6975 8325 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 5355 4815 6345 Mass-spring-damper system (position output)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 0 4 0 0 0 20 0.0000 4 240 960 6660 4140 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_desc.tex version [c342c284c0].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system msdPS (msdPS_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msdPS} is
   displayed in Figure \Ref{msdPS_abg} and its label
   file is listed in Section \Ref{sec:msdPS_lbl}.
   The subsystems are listed in Section \Ref{sec:msdPS_sub}.


 \textbf{msdPS} is a simple Mass-Spring-Damper system with 
 force input and position output. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_lbl.txt version [79760470ab].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY msdPS
%DESCRIPTION <Detailed description here>
%% Label file for system msdPS (msdPS_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_s		lin	effort,c_s

% Component type I
	j_s		lin	flow,j_s

% Component type R
	r_s		lin	flow,r_s

% Component type RC
	rc		none	tau;1

% Component type SS
	[in]		SS	external,internal
	[out]		SS	external,0

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/msdP_abg.fig version [783d02bd00].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 6975 8325 1125 1125 1125 1125 6975 8325 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 5355 4815 6345 Mass-spring-damper system (position output)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 0 4 0 0 0 20 0.0000 4 240 960 6660 4140 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/msdP_desc.tex version [be83adfdb1].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system msdP (msdP_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msdP} is
   displayed in Figure \Ref{msdP_abg} and its label
   file is listed in Section \Ref{sec:msdP_lbl}.
   The subsystems are listed in Section \Ref{sec:msdP_sub}.


 \textbf{msdP} is a simple Mass-Spring-Damper system with 
 force input and position output. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/GPC/TwoLinkGPC/msdP_lbl.txt version [dee478e657].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY msdP
%DESCRIPTION <Detailed description here>
%% Label file for system msdP (msdP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_s		lin	effort,c_s

% Component type I
	j_s		lin	flow,j_s

% Component type R
	r_s		lin	flow,r_s

% Component type SS
	[in]		SS	external,internal
	[out]		SS	external,0

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Fixed_abg.fig version [59be0b9ae0].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 0 0 100 0 18 20 0.0000 4 225 810 5625 1890 SS:z1\001
4 0 0 100 0 18 20 0.0000 4 240 810 5625 2790 SS:z2\001
4 2 4 100 0 18 20 0.0000 4 285 1305 4140 1890 SS:[y_in]\001
4 2 4 100 0 18 20 0.0000 4 285 1860 4140 2790 SS:[theta_in]\001

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Fixed_lbl.txt version [2f6cde2cc7].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Fixed (Fixed_lbl.txt)
%SUMMARY Fixed
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	y_in,theta_in

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_in]	SS		external,external
	[y_in]		SS		external,external
	z1		SS		internal,0
	z2		SS		internal,0

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Free_abg.fig version [c03c8c2488].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 2 0 100 0 18 20 0.0000 4 225 810 4140 1890 SS:z1\001
4 2 0 100 0 18 20 0.0000 4 240 810 4140 2790 SS:z2\001
4 0 4 100 0 18 20 0.0000 4 285 1500 5490 1890 SS:[y_out]\001
4 0 4 100 0 18 20 0.0000 4 285 2055 5445 2790 SS:[theta_out]\001

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Free_lbl.txt version [517bb24436].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Free (Free_lbl.txt)
%SUMMARY Free
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	y_out,theta_out

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_out]	SS		external,external
	[y_out]		SS		external,external
	z1		SS		0,internal
	z2		SS		0,internal



Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Make_figures.m version [7ca19d2a8a].





1
2
3
4
+
+
+
+
#!/bin/sh
## Script file Make_figures.

ppp_1("PPPCantileverBeam",1:2,[1 2;1 3]); # 2 inputs; modes 1 2 and 1 and 3

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_abg.fig version [3a565598a0].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1125 2700 2250 2700 2025 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8775 2700 9900 2700 9675 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 3825 2700 3600 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4095 6300 4095 4500 4320 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3870 4500 4320 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 2700 6975 2700 6750 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7380 2700 8505 2700 8280 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7245 6300 7245 4500 7470 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 7020 4500 7470 4500
4 1 0 100 0 18 20 1.5708 4 225 630 1035 2700 Free\001
4 1 0 100 0 18 20 1.5708 4 225 780 10260 2700 Fixed\001
4 1 0 100 0 18 20 1.5708 4 285 3690 8775 2700 BernoulliEuler:Chunk_3*3\001
4 1 0 100 0 18 20 1.5708 4 285 3690 2610 2700 BernoulliEuler:Chunk_1*3\001
4 1 0 100 0 18 20 1.5708 4 300 3480 4140 2700 pBernoulliEuler:Patch_1\001
4 1 4 100 0 18 16 0.0000 4 240 900 4095 4455 [torque]\001
4 1 0 100 0 18 20 0.0000 4 285 1275 4050 6660 SS:tau_1\001
4 1 0 100 0 18 20 1.5708 4 285 3690 5760 2700 BernoulliEuler:Chunk_2*8\001
4 1 0 100 0 18 20 1.5708 4 300 3480 7290 2700 pBernoulliEuler:Patch_2\001
4 1 4 100 0 18 16 0.0000 4 240 900 7245 4455 [torque]\001
4 1 0 100 0 18 20 0.0000 4 285 1275 7200 6660 SS:tau_2\001

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_desc.tex version [c5991e9114].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PPPCantileverBeam (PPPCantileverBeam_desc.tex)
% Generated by MTT on Mon Apr 19 07:04:54 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/05/18 04:01:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{PPPCantileverBeam} is displayed in
Figure \Ref{fig:PPPCantileverBeam_abg.ps} and its label file is listed in
Section \Ref{sec:PPPCantileverBeam_lbl}.  The subsystems are listed in Section
\Ref{sec:PPPCantileverBeam_sub}.
   
This example represents the dynamics of a uniform beam with one fixed
and one free end.  The beam is approximated by 16 equal lumps using
the Bernoulli-Euler approximation with damping. The ouputs are taken
to be the 16 lump velocities, the two inputs are taken to be torques
applied to lumps 3 away from each end; this approximates the effect of
two piezoelectric patches.

The system parameters are given in Section
\Ref{sec:PPPCantileverBeam_numpar.tex}.
The system has 32 states (16 modes of vibration), 2 inputs and 12
outputs.
The first 8 modal frequencies are given in Table \ref{tab:modes}.
\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{||c|c||c|c||}
      \hline
      Mode & $\omega_i$ & Mode & $\omega_i$\\
      \hline
      \hline
      1 & 0.0079504 & 5 & 0.4352376\\
      2 & 0.0498140 & 6 & 0.6338899\\
      3 & 0.1386209 & 7 & 0.8573604\\
      4 & 0.2682835 & 8 & 1.0976942\\
      \hline
    \end{tabular}
    \caption{Modal frequencies}
    \label{tab:modes}
  \end{center}
\end{table}

Figure \Ref{fig:PPPCantileverBeam_lmfr.ps} shows the log modulus of the frequency
response and Figure \Ref{fig:PPPCantileverBeam_pppy0.ps} shows the system transient
reponse with no control and an initial unit twist.

Figure \Ref{fig:PPPCantileverBeam_pppy.ps} shows closed loop reponse when
controlled by a PPP controller attempting to damp modes 1 and 2 from
input 1 and modes 1 and three from input 2. Figure
\Ref{fig:PPPCantileverBeam_pppy.ps} shows the corresponding control signals.







Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_input.txt version [d4ae1b0a98].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (PPPCantileverBeam_input.txt)
# Generated by MTT at Thu Apr 22 00:12:54 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
mttu(1) = exp(-t/0.1); 	# tau (PPPCantileverBeam)

# Set the switches

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_lbl.txt version [5eda0fc64e].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system PPPCantileverBeam (PPPCantileverBeam_lbl.txt)
%SUMMARY PPPCantileverBeam
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Declare some variables
%VAR Area
%VAR AreaMoment
%VAR BeamLength
%VAR BeamThickness
%VAR BeamWidth
%VAR Density
%VAR N
%VAR Youngs
%VAR EI
%VAR rhoA

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type BenoulliEuler
  Chunk_1
  Patch_1
  Chunk_2
  Patch_2
  Chunk_3


% Component type SS
	tau_1	SS		external,external
	tau_2	SS		external,external

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_numpar.txt version [45ea043915].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (PPPCantileverBeam_numpar.txt)
# Generated by MTT at Mon Apr 19 06:24:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:27:26  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
N = 16;
BeamLength = 0.58;
BeamWidth = 0.05;
BeamThickness = 0.005;
Youngs = 1e6;
Density = 1e5;
Area = BeamWidth*BeamThickness;
AreaMoment = (BeamThickness*pow(BeamWidth,2))/12;


EI= 58.6957			# from Reza
rhoA= 0.7989			# from Reza
 
dz = BeamLength/N;		# Incremental length
dm = rhoA*dz;			# Incremental mass
dk = EI/dz;			# Incremental stiffness
dr = 1e-2;			# Damping

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_rep.txt version [49cce86377].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system PPPCantileverBeam (PPPCantileverBeam_rep.txt)
## Generated by MTT on" Mon Apr 19 06:43:08 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt PPPCantileverBeam abg tex			# The system description
## mtt PPPCantileverBeam cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt PPPCantileverBeam struc tex	        # The system structure
## mtt PPPCantileverBeam dae tex	        # The system dae
## mtt PPPCantileverBeam ode tex	        # The system ode 
## mtt PPPCantileverBeam sspar tex		# Steady-state parameters
## mtt PPPCantileverBeam ss tex 		# Steady state
## mtt PPPCantileverBeam dm tex		# Descriptor matrices (of linearised system)
## mtt PPPCantileverBeam sm tex		# State matrices (of linearised system)
## mtt PPPCantileverBeam tf tex		# Transfer function (of linearised system)
mtt PPPCantileverBeam simpar tex		# Simulation parameters
mtt PPPCantileverBeam numpar tex		# Numerical simulation parameters
## mtt PPPCantileverBeam input tex		# Simulation input
## mtt PPPCantileverBeam odeso ps		# Simulation output
mtt PPPCantileverBeam lmfr ps		# log modulus of frequency response (of linearised system)

mtt PPPCantileverBeam pppy ps		# PPP output
mtt PPPCantileverBeam pppu ps		# PPP input
mtt PPPCantileverBeam pppy0 ps		# PPP open-loop op

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_simpar.txt version [7c1db12c6b].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system PPPCantileverBeam (PPPCantileverBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 500;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_simpar.txt_old version [df1ea30bc7].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system PPPCantileverBeam (PPPCantileverBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
METHOD      = Implicit;   # Integration method
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 500;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/ppp_1.m version [4acd8828e7].

















































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function  ppp_1(Name,Inputs,Modes);

# Name = "CantileverBeam"
# Inputs = 1:2
# Modes = [1 2;1 3]

  path(path,"~/Research/CGPC/PPP");  
  
  Name,Inputs,Modes

  ## System
  system(sprintf("mtt -q %s numpar m", Name));
  system(sprintf("mtt -q %s sm m", Name));
  par = eval(sprintf("%s_numpar;",Name));
  eval(sprintf("[A,B,C,D]=%s_sm(par);",Name));
  [n_x,n_u,n_y] = abcddim(A,B,C,D)


  ## Change B
  B = B(:,Inputs);
  [junk,n_u]=size(B);
  n_u

  ## Redo C and D to reveal ALL velocities
   n_y = n_x/2
   C = zeros(n_y,n_x);
   for i = 1:n_y
     C(i,2*i-1) = 1;
   endfor

  ## Sort out D
  D = zeros(n_y,n_u);

  e = eig(A);			# Eigenvalues
  N = length(e);
  frequencies = sort(imag(e));
  frequencies = frequencies(N/2+1:N); # Modal frequencies

  ## Controller
  ## Controller design parameters
  t = [0.9:0.01:1.0];		# Optimisation horizon

  ## Specify input basis functions 
  ##  - damped sinusoids with same frequencies as beam
  damping_ratio = [0.1 0.1];		# Damping ratio of inputs
  A_u=[];
#   Modes = [1  3  
# 	   1  2];		# Choose modes to be controlled by each input 
  if n_u == 1			# Put all modes on each input
    Modes = [Modes; Modes];
  endif
  
  Modes

  for i=Inputs
    A_ui = damped_matrix(frequencies(Modes(i,:)),damping_ratio(i)*ones(size(Modes(i,:))));
    A_u = [A_u;A_ui];
    u_0 = ones(n_x,1);		# Initial conditions
  endfor
  

  A_w = 0;			# Setpoint
  Q = ones(n_y,1);		# Output weighting

  ## Design 
  disp("Control design - unconstrained");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t); # Unconstrained design

  ## Organise some plots
   dt = 0.002;		# Time increment
#   T =  0:dt:t(length(t));	# Time starting at zero but past horizon
   T =  0:dt:1.0;		# Time 

  ## Set up an "typical" initial condition
  x_0 = zeros(n_x,1);
  x_0(2:2:n_x) = ones(1,n_x/2);	# Set initial twist to 1.
#  disp("Computing OL response");
#  [Ys,Us] = ppp_transient (T,A_u,-(K_x*x_0)',u_0,A,B,C,D,x_0); # Compute open-loop control
  
  
  disp("Computing OL response (no control)");
  [Y_0] = ppp_sm2sr(A, B, C, D, T, zeros(n_u,1), x_0); # Compute Closed-loop control
  title("Y (no control)");
  xlabel("Time")
  grid; 
  plot(T,Y_0);
  psfig(sprintf("%s_pppy0",Name));

  disp("Computing Unconstrained CL response");
  [y_u,X_u] = ppp_sm2sr(A-B*k_x, B, C, D, T, zeros(n_u,1), x_0);
  u_u = -k_x*X_u';


  title("Unconstrained closed-loop control - y");
  xlabel("Time")
  grid; 
  plot(T,y_u);
  psfig(sprintf("%s_pppy",Name));

  title("Unconstrained closed-loop control - u");
  xlabel("Time")
  grid; 
  plot(T,u_u);
  psfig(sprintf("%s_pppu",Name));

#   ## Constrained version
  
#   ## Constraints - u
#   Tau_u = [0:0.01:1];
#   one = ones(size(Tau_u));
#   limit = 1e10;
#   Min_u = -limit*one;
#   Max_u =  limit*one;
#   Order_u = 0*one;

#   ## Constraints - y
#   Tau_y = [];
#   one = ones(size(Tau_y));
#   limit = 1e5; 
#   Min_y = -limit*one;
#   Max_y =  limit*one;
#   Order_y = 0*one;

#   ## Simulation

#   ## Constrained - open-loop
#   Gamma = [];
#   gamma = [];
#   for i=1:n_u			# Put same constraints on each input
#     [Gamma_i,gamma_i] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u,Order_u,i,n_u);
#     Gamma = [Gamma; Gamma_i];
#     gamma = [gamma; gamma_i];
#   endfor


#   disp("Open-loop simulations...");
#   ## Constrained OL simulation
#   W = zeros(n_y,1);
#   [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
#   T = [0:t(2)-t(1):t(length(t))];
#   [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

#   title("Constrained y*");
#   xlabel("t");
#   grid;
#   plot(T,ys)

#   ## Unconstrained OL simulation
#   [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]); 
#   [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

#   title("Unconstrained y*");
#   xlabel("t");
#   grid;
#   plot(T,ysu)

#   ## Non-linear - closed-loop
#   disp("Closed-loop simulation");
#   Tc = [0:4e-4:1.0];	
#   Delta_ol = 1.0;
#   [yc,uc,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, T, Tau_u,Min_u,Max_u,Order_u, Tau_y,Min_y,Max_y,Order_y,W,x_0,Delta_ol);

#   title("y,y*,u and u*");
#   xlabel("t");
#   grid;
#   plot(T1,y,T,ys,T1,u,T,us);

endfunction








Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/pppu_rep.make version [111a3668c7].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Make file for the ppp output rep
## Symlinked to:
##	pppy
##	pppy0
##	pppu

all: $(SYS)_pppy.ps $(SYS)_pppy0.ps $(SYS)_pppu.ps

$(SYS)_pppy.ps: Make_figures.m ppp_1.m $(SYS)_sm.m $(SYS)_numpar.m
	octave Make_figures.m
$(SYS)_pppy0.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppy0.ps
$(SYS)_pppu.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppu.ps

$(SYS)_sm.m: 
	mtt $(SYS) sm m

$(SYS)_numpar.m: 
	mtt $(SYS) numpar m

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/pppy0_rep.make version [111a3668c7].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Make file for the ppp output rep
## Symlinked to:
##	pppy
##	pppy0
##	pppu

all: $(SYS)_pppy.ps $(SYS)_pppy0.ps $(SYS)_pppu.ps

$(SYS)_pppy.ps: Make_figures.m ppp_1.m $(SYS)_sm.m $(SYS)_numpar.m
	octave Make_figures.m
$(SYS)_pppy0.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppy0.ps
$(SYS)_pppu.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppu.ps

$(SYS)_sm.m: 
	mtt $(SYS) sm m

$(SYS)_numpar.m: 
	mtt $(SYS) numpar m

Added mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/pppy_rep.make version [111a3668c7].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Make file for the ppp output rep
## Symlinked to:
##	pppy
##	pppy0
##	pppu

all: $(SYS)_pppy.ps $(SYS)_pppy0.ps $(SYS)_pppu.ps

$(SYS)_pppy.ps: Make_figures.m ppp_1.m $(SYS)_sm.m $(SYS)_numpar.m
	octave Make_figures.m
$(SYS)_pppy0.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppy0.ps
$(SYS)_pppu.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppu.ps

$(SYS)_sm.m: 
	mtt $(SYS) sm m

$(SYS)_numpar.m: 
	mtt $(SYS) numpar m

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AE3_abg.fig version [06166c49e9].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4747 5175 6097 5175 5872 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7447 5175 8797 5175 8572 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2677 5175 4027 5175 3802 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6772 3375 6772 4725 6997 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 6750 6750 5400 6975 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 8550 6750 7200 6975 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 1575 6750 2925 6975 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9472 5175 10822 5175 10597 5400
4 1 0 100 0 18 20 0.0000 4 225 405 6750 3240 AE\001
4 1 0 100 0 18 20 0.0000 4 225 405 6750 7110 AE\001
4 1 0 100 0 18 20 0.0000 4 225 405 4365 5265 AE\001
4 1 4 100 0 18 20 0.0000 4 285 975 2115 5265 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1335 6795 1485 SS:[mod]\001
4 1 4 100 0 18 20 0.0000 4 285 1500 6705 8820 SS:[smod]\001
4 1 0 100 0 18 30 0.0000 4 330 660 6750 5265 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 5985 4995 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 7560 4995 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 4590 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 5625 [4]\001
4 1 0 100 0 18 20 0.0000 4 225 405 9135 5265 AE\001
4 1 4 100 0 18 20 0.0000 4 285 1170 11475 5265 SS:[out]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AE3_lbl.txt version [d1dfd6ef4f].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system AE3 (AE3_lbl.txt)
%SUMMARY AE3
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	mod	mod
%ALIAS	out	out
%ALIAS	smod	smod

% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	slsin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type R
	r		slsin	-1*l

% Component type SS
	[in]	SS		external,external
	[mod]	SS		external,external
	[out]	SS		external,external
	[smod]	SS		external,external




Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AF3_abg.fig version [bbf355643a].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4747 5175 6097 5175 5872 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7447 5175 8797 5175 8572 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2677 5175 4027 5175 3802 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6772 3375 6772 4725 6997 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 6750 6750 5400 6975 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 8550 6750 7200 6975 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 1575 6750 2925 6975 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9472 5175 10822 5175 10597 5400
4 1 0 100 0 18 20 0.0000 4 225 405 6750 3240 AE\001
4 1 0 100 0 18 20 0.0000 4 225 405 6750 7110 AE\001
4 1 4 100 0 18 20 0.0000 4 285 975 2115 5265 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1335 6795 1485 SS:[mod]\001
4 1 4 100 0 18 20 0.0000 4 285 1500 6705 8820 SS:[smod]\001
4 1 0 100 0 18 30 0.0000 4 330 660 6750 5265 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 5985 4995 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 7560 4995 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 4590 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 5625 [4]\001
4 1 0 100 0 18 20 0.0000 4 225 390 4365 5310 AF\001
4 1 0 100 0 18 20 0.0000 4 225 390 9135 5265 AF\001
4 1 4 100 0 18 20 0.0000 4 285 1170 11610 5265 SS:[out]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AF3_lbl.txt version [fe6985b952].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system AE3 (AE3_lbl.txt)
%SUMMARY AE3
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	mod	mod
%ALIAS	out	out
%ALIAS	smod	smod

% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	slsin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type R
	r		slsin	l

% Component type SS
	[in]	SS		external,external
	[mod]	SS		external,external
	[out]	SS		external,external
	[smod]	SS		external,external

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Cart_abg.fig version [dd76f4c478].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 4950 4275 4725 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5400 3600 5400 3825 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 4950 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3015 3150 4365 3150 4140 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4815 3150 6165 3150 5940 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4590 2925 4590 1575 4815 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4815 1575 4365 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4793 2934 6153 1574 6153 1893
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4387 2947 3027 1587 3346 1587
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 3150 9000 3150 8775 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 4050 3600 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 5400 6750 5400 6525 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6750 5175 6750 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 4275 6750 4275 6525 4500
4 2 0 100 0 18 18 0.0000 4 270 2130 3510 4365 Sf:zero_velocity\001
4 1 1 101 0 3 18 0.0000 4 255 1125 5310 4725 y-velocity\001
4 1 1 101 0 3 18 0.0000 4 255 1155 5265 3735 x-velocity\001
4 1 1 101 0 3 18 0.0000 4 255 1905 5175 5940 angular-velocity\001
4 2 0 100 0 18 18 0.0000 4 270 720 3555 5490 R:r_p\001
4 1 0 100 0 18 18 0.0000 4 195 150 4590 3240 1\001
4 1 4 100 0 18 18 0.0000 4 270 765 6390 1440 SS:[x]\001
4 1 0 100 0 18 18 0.0000 4 270 870 4635 1440 IS:m_c\001
4 1 0 100 0 18 18 0.0000 4 270 690 2880 1440 R:r_c\001
4 1 4 100 0 18 18 0.0000 4 270 1290 2250 3240 SS:[drive]\001
4 0 0 100 0 18 18 0.0000 4 210 1560 9090 3240 De:Position\001
4 1 0 100 0 18 18 0.0000 4 210 1035 6975 3240 INTFS:x\001
4 1 0 100 0 18 18 0.0000 4 195 150 5175 5490 1\001
4 1 4 100 0 18 18 0.0000 4 270 780 7245 5490 SS:[a]\001
4 1 0 100 0 18 18 0.0000 4 195 150 5175 4365 1\001
4 1 4 100 0 18 18 0.0000 4 270 765 7245 4365 SS:[y]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Cart_lbl.txt version [53f4dac4d3].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Cart (Cart_lbl.txt)
%SUMMARY Cart
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	drive
%ALIAS	pendulum|out	x,y,a

% Argument aliases
%ALIAS	$1	m_c
%ALIAS	$2	r_c
%ALIAS	$3	r_p

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type IS
	m_c		lin	flow,m_c;v_0

% Component type R
	r_c		lin	flow,r_c
	r_p		lin	flow,r_p

% Component type INTFS
	x               none    x_0

% Component type SS
	[a]	SS		internal,0
	[drive]	SS		external,internal
	[x]	SS		0,internal
	[y]	SS		0,internal

% Component type De
	Position		SS	external

% Component type Sf
	zero_velocity		SS	0




Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DCS_abg.fig version [b47c5c7578].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3330 1305 3870 1395
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 1350 3825 1350
-6
6 7965 2475 8505 2565
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8010 2520 8460 2520
-6
6 3330 2475 3420 3015
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2520 3375 2970
-6
6 9810 2475 9900 3015
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9855 2520 9855 2970
-6
6 7965 2430 8055 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8010 2475 8010 2925
-6
6 3735 2430 3825 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3780 2475 3780 2925
-6
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4860 4730 4860 494 2293 494 2293 4730 4860 4730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2036 2724 3371 2724 3063 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2501 3576 1342 3833 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3782 2724 5116 2724 4808 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2947 3576 4106 3833 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6656 2724 7991 2724 7683 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8196 2947 8196 4106 8453 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8453 2724 9788 2724 9480 2947
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9480 4730 9480 494 6913 494 6913 4730 9480 4730
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12150 5175 45 5175 45 316 12150 316 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8190 2501 8190 1341 8447 1609
4 2 4 0 0 0 18 0.0000 4 240 1605 1980 2790 SS:[Electrical]\001
4 1 -1 0 0 0 18 0.0000 4 195 135 3525 2858 1\001
4 1 -1 0 0 0 18 0.0000 4 255 945 5938 2813 GY:k_m\001
4 1 -1 0 0 0 18 0.0000 4 195 135 8196 2813 1\001
4 1 -1 0 0 0 18 0.0000 4 255 630 3525 1252 IS:l_a\001
4 1 -1 0 0 0 18 0.0000 4 255 600 3628 4463 R:r_a\001
4 1 -1 0 0 0 18 0.0000 4 255 735 8248 4463 R:b_m\001
4 1 1 1 0 0 18 0.0000 4 195 1065 3576 5043 Electrical\001
4 1 1 1 0 0 18 0.0000 4 195 1290 8196 5043 Mechanical\001
4 1 1 1 0 0 18 0.0000 4 195 600 10404 3170 Shaft\001
4 1 1 1 0 0 18 0.0000 4 195 1155 1472 3170 Terminals\001
4 0 4 0 0 0 18 0.0000 4 240 1830 9945 2835 SS:[Mechanical]\001
4 1 -1 0 0 0 18 0.0000 4 255 585 8235 1215 I:j_m\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DCS_lbl.txt version [085bf103ca].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY DCS: DCS motor 
%DESCRIPTION A special for the inverted pendulum system
%DESCRIPTION Derivative causality on the  shaft
%DESCRIPTION No aliased parameters
%DESCRIPTION Built in causality - speeds things up
%DESCRIPTION Only the armature state and shaft resistance are variable

%ALIAS in	Electrical
%ALIAS out	Mechanical


%% Label file for system DCS (DCS_lbl.txt)


%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin		flow,k_m

% Electrical components
%Inductance
l_a	lin		flow,l_a;i_0

%Resistance
r_a	lin		flow,r_a

% Mechanical components
%Inertia
j_m	lin		flow,j_m

%Friction
b_m	lin		flow,b_m

% Ports
	[Electrical]	SS	external,external
	[Mechanical]	SS	external,external

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_abg.fig version [7ddc7b16cb].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3555 4005 3645 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 4050 3600 4500
-6
6 6255 4005 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 4050 6300 4500
-6
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 7650 4725 5850 4725 5850 3825 7650 3825 7650 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 4275 3600 4275 3375 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 4275 6300 4275 6075 4500
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 5175 4725 3375 4725 3375 3825 5175 3825 5175 4725
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 2610 4725 585 4725 585 3825 2610 3825 2610 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 4275 8775 4275 8550 4500
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 10125 4950 10125 2025 225 2025 225 4950 10125 4950
4 1 0 100 0 18 20 0.0000 4 360 1815 1620 4410 OpenLoop\001
4 1 0 100 0 18 20 0.0000 4 285 960 4320 4410 Drive\001
4 1 0 100 0 18 20 0.0000 4 285 765 6795 4410 Cart\001
4 1 0 100 0 18 20 0.0000 4 285 810 9225 4410 Zero\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_input.txt version [b342c864df].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (DriveCart_input.txt)
# Generated by MTT at Thu Aug  5 09:17:30 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
#mttu(1) = 1.0*(t<1) -1.0*((t>=1)&&(t<2)); 	# u (DriveCart_F)
mttu(1) = 1;
mttu(2) = 0;
mttu(3) = 0;
mttu(4) = 0;

# Set the switches

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_lbl.txt version [3e401170aa].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system DriveCart (DriveCart_lbl.txt)
%SUMMARY DriveCart
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR l_p		#Pendulum length

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----






Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_numpar.txt version [9986736335].




























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (DriveCart_numpar.txt)
# Generated by MTT at Wed Aug 25 22:57:05 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	1.5;			# Cart friction

# l_p =   0.61;			# Pendulum length
# m_p =   0.210;			# Pendulum mass
# r_p = 	0.0;			# Pendulum friction

# j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

# g = 9.81;			# Gravity


## Sensitivity parameters
# m_cs = 0;			# Cart mass
# b_ms = 0;			# Motor friction 
# r_cs = 0;			# Cart friction
# r_ps = 0;			# Pendulum friction


## Control parameters
k_1 = 1;
k_2 = 0;
k_3 = 0;

## States
i_0 = 0;			# Initial armature current
v_0 = 0;			# Initial cart velocity
x_0 = 0;			# Initial cart position

# omega_0 = 0;			# Initial pendulum velocity
# theta_0 = 0;			# Initial pendulum angle

## Control sensitivity parameters
# k_1s = 0;
# k_2s = 0;
# k_3s = 0;

# ## Argument list
# if (mtt_n_parameters>1)
#   r_cs= mtt_parameters(1);
#   r_c = mtt_parameters(2);
# endif;

# if (mtt_n_parameters>3)
#   m_cs= mtt_parameters(3);
#   m_c = mtt_parameters(4);
# endif;

# if (mtt_n_parameters>5)
#   k_1s= mtt_parameters(5);
#   k_1 = mtt_parameters(6);
# endif;

# if (mtt_n_parameters>7)
#   k_2s= mtt_parameters(7);
#   k_2 = mtt_parameters(8);
# endif;

# if (mtt_n_parameters>9)
#   k_3s= mtt_parameters(9);
#   k_3 = mtt_parameters(10);
# endif;







Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_rep.txt version [5d95394934].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system DriveCart (DriveCart_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:29:11  peterg
## To RCS
##
###############################################################

mtt DriveCart abg tex			# The system description
mtt DriveCart cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt DriveCart struc tex	        # The system structure
mtt DriveCart dae tex	        # The system dae
## mtt DriveCart ode tex	        # The system ode 
## mtt DriveCart sspar tex		# Steady-state parameters
## mtt DriveCart ss tex 		# Steady state
## mtt DriveCart dm tex		# Descriptor matrices (of linearised system)
mtt DriveCart sm tex		# State matrices (of linearised system)
## mtt DriveCart tf tex		# Transfer function (of linearised system)
## mtt DriveCart lmfr ps		# log modulus of frequency response (of linearised system)
mtt DriveCart simpar tex		# Simulation parameters
mtt DriveCart numpar tex		# Numerical simulation parameters
mtt DriveCart input tex		# Simulation input
mtt DriveCart odeso ps		# Simulation output

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_simpar.txt version [c95de2a7c5].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system DriveCart (DriveCart_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;      # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1000;		# Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Drive_abg.fig version [12e17c139d].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2475 3825 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 2700 3825 2700 3600 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 2700 6975 2700 6750 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8325 2700 9675 2700 9450 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10575 2700 11925 2700 11700 2925
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 14400 4725 14400 675 225 675 225 4725 14400 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 2475 6975 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11925 2475 11925 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9675 2475 9675 2925
4 1 1 101 0 3 20 0.0000 4 255 1530 4590 3330 DC motor\001
4 1 1 101 0 3 20 0.0000 4 330 2745 2205 3330 Power supply unit\001
4 2 4 100 0 18 18 0.0000 4 270 1845 2430 2790 SS:[Electrical]\001
4 1 0 100 0 18 18 0.0000 4 210 1470 4725 2790 DCS:motor\001
4 1 0 100 0 18 18 0.0000 4 270 915 7695 2790 TF:k_g\001
4 1 0 100 0 18 18 0.0000 4 210 540 10125 2790 TF:r\001
4 0 4 100 0 18 18 0.0000 4 270 2115 12015 2790 SS:[Mechanical]\001
4 1 1 101 0 3 20 0.0000 4 330 2010 7515 3330 Internal gear\001
4 1 1 101 0 3 20 0.0000 4 330 1710 10080 3330 Motor gear\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Drive_lbl.txt version [99fb16d915].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Drive (Drive_lbl.txt)
%SUMMARY Drive
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Electrical
%ALIAS	out	Mechanical

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type DC
	motor

% Component type SS
	[Electrical]	SS		external,external
	[Mechanical]	SS		external,external

% Component type TF
	k_g		lin	flow,k_g
	r		lin	flow,r

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/INTFS_abg.fig version [0f2cfc3a7b].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10575 4950 45 4950 45 1350 10575 1350 10575 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3150 2475 3150 2250 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 3150 7426 3150 7201 3375
4 1 -1 0 0 0 20 0.0000 4 255 180 4501 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 255 1110 4501 1891 CS:unit\001
4 2 4 0 0 0 20 0.0000 4 315 1455 1530 3240 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 255 825 2925 3240 AF:af\001
4 1 -1 0 0 0 20 0.0000 4 255 900 6075 3240 AE:ae\001
4 0 4 0 0 0 20 0.0000 4 330 3045 7470 3240 SS:[Integrated_flow]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/INTFS_lbl.txt version [566f080c2f].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system INTFS (INTFS_lbl.txt)
%SUMMARY	INTFS: flow integrator
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/16 07:35:10  peterg
% %% Aliased version
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow
%ALIAS	out	Integrated_flow

% Argument aliases
%ALIAS	$1 x_0	

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


% Component type CS
	unit			lin		effort,1;x_0

% Component type AE
	ae			lin		1

% Component type AF
	af			lin		1

% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/IS_abg.fig version [833b9d0b1e].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 0 100 0 18 20 0.0000 4 270 195 2475 4185 0\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
4 1 0 100 0 18 20 0.0000 4 285 315 2475 2295 I:i\001
4 0 0 100 0 18 20 0.0000 4 360 1035 4185 4185 Sf:f_0\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2475 6030 SS:[in]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/IS_lbl.txt version [fd9f48ad6f].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system IS (IS_lbl.txt)
%SUMMARY IS I component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	i		lin	flow,i

% Component type SS
	[in]	 SS	external,external

% Component type Sf
	f_0		SS	f_0


Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_abg.fig version [f7dd4e7606].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3555 4005 3645 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 4050 3600 4500
-6
6 6255 4005 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 4050 6300 4500
-6
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 7650 4725 5850 4725 5850 3825 7650 3825 7650 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 4275 3600 4275 3375 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 4275 6300 4275 6075 4500
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 5175 4725 3375 4725 3375 3825 5175 3825 5175 4725
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 2610 4725 585 4725 585 3825 2610 3825 2610 4725
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9675 4950 9675 2025 225 2025 225 4950 9675 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3825 7705 2870 7705 3189
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 5
	 6952 3487 8347 2092 8527 2272 7177 3622 6997 3442
4 1 0 100 0 18 20 0.0000 4 360 1815 1620 4410 OpenLoop\001
4 1 0 100 0 18 20 0.0000 4 285 960 4320 4410 Drive\001
4 1 0 100 0 18 20 0.0000 4 285 3255 7830 2835 InvertedPendulum\001
4 1 0 100 0 18 20 0.0000 4 285 765 6795 4410 Cart\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_desc.tex version [bf8d448bf0].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system InvertedPendulumOnCart (InvertedPendulumOnCart_desc.tex)
% Generated by MTT on Thu Aug 5 10:38:16 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{InvertedPendulumOnCart} is
   displayed in Figure \Ref{fig:InvertedPendulumOnCart_abg.ps} and its label
   file is listed in Section \Ref{sec:InvertedPendulumOnCart_lbl}.
   The subsystems are listed in Section \Ref{sec:InvertedPendulumOnCart_sub}.

This is a one input, two output nonlinear system comprising an
inverted pendulum attached by a hinge to a cart constrained to move in
the horizontal direction. The input is the horizontal force acting on
the cart, and the two outputs are the horizontal position and the
pendulum angle respectively.

The bond graph in Figure \Ref{InvertedPendulumOnCartPPP_abg} is augmented with the {\em
open-loop\/} controller comprising
\begin{itemize}
\item two effort source \textbf{Se} components ``u1'' and ``u2''
\item two effort amplifier \textbf{AE} components ``ppp\_1'' and `ppp\_2''
\end{itemize}

This is a \emph{nonlinear} system and it is used to illustate
\emph{nonlinear} PPP control. Section
\Ref{sec:InvertedPendulumOnCartPPP_nppp.ps} shows the cart position
$x$ and the pendulum angle $\theta$  when the pendulum starts from the
initial condition of  $\theta = \frac{\pi}{2}$ (ie the pendulum is
horizontal).
 

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_input.txt version [e48379ad1c].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (InvertedPendulumOnCartPPP_input.txt)
# Generated by MTT at Thu Aug  5 09:17:30 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
#mttu(1) = 1.0*(t<1) -1.0*((t>=1)&&(t<2)); 	# u (InvertedPendulumOnCartPPP_F)
mttu(1) = 1;
mttu(2) = 0;
mttu(3) = 0;
mttu(4) = 0;

# Set the switches

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_lbl.txt version [a0840e2c8b].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system InvertedPendulumOnCartPPP (InvertedPendulumOnCartPPP_lbl.txt)
%SUMMARY InvertedPendulumOnCartPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR l_p		#Pendulum length

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----






Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_nppp.m version [95e3aca505].














































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Figures.m
## Makes figures for the InvertedPendulumOnCart_PPP exasmple.
## $Log$
## Revision 1.4  2000/08/17 12:34:58  peterg
## *** empty log message ***
##
## Revision 1.3  2000/08/11 16:01:27  peterg
## Fixed documentation error
##
## Revision 1.2  2000/05/21 06:39:40  peterg
## Parameterised _sm
##
## Revision 1.1  2000/05/20 11:30:41  peterg
## Initial revision
##
## Revision 1.2  2000/05/17 16:59:57  peterg
## Revised for Inverted pendulum - it works !!!!
##
## Revision 1.1  2000/05/17 14:07:53  peterg
## Initial revision
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "InvertedPendulumOnCartPPP";

## Uncomment the following the first time
## (Or do ./Make InvertedPendulumOnCartPPP in this directory)

## MTT stuff for the system simulation
##system("Make InvertedPendulumOnCartPPP");

t_s=1.0*[0:0.1:10];
u = [ones(4,length(t_s))];
x_0 = InvertedPendulumOnCartPPP_state;
par  = InvertedPendulumOnCartPPP_numpar;

## Simulate the system
tick=time;
[y,x] = InvertedPendulumOnCartPPP_sim(x_0,u,t_s,par);
Elapsed = time-tick
plot(t_s,y, t_s,x);

## Simulate the system to give just the final few points
t_s1 = 10*[9:0.1:10];
tick=time;
[y,x] = InvertedPendulumOnCartPPP_sim(x_0,u,t_s1,par);
Elapsed = time-tick
plot(t_s1,y,t_s1,x);

## Sensitivity system simulation parameters
x_0s = sInvertedPendulumOnCartPPP_state;
pars  = sInvertedPendulumOnCartPPP_numpar;
sympars  = sInvertedPendulumOnCartPPP_sympar;

## Simulate the sensitivity system
sensitivities = [sympars.ppp_1s,sympars.ppp_2s,sympars.r_cs]
tick=time;
[y,ys] = sInvertedPendulumOnCartPPP_sim(x_0s,u,t_s,pars,sensitivities);
Elapsed = time-tick
plot(t_s,y,t_s,ys);

### PPP parameters
A_w = [0;0];
A_u = laguerre_matrix(4,20); # Specify basis functions: constant &
			     # exp(-5t)
tau = 0.5*[0.9:0.01:1];             # Optimisation interval
t_ol =0.5*[0:0.01:0.2];            # Open-loop interval
N = 20;                          # Number of open-loop intervals in simulation
w = [0;0];                         # Setpoint

## Linear system
## Linear system
[A,B,C,D] = InvertedPendulumOnCartPPP_sm(par);
Q = [1;1];
ppp_lin_plot (A,B(:,1),C,D(:,1),A_u,A_w,tau,Q,w,x_0);
psfig("InvertedPendulumOnCartPPP_lin");

## Simulate non-linear PPP (on this nonlinear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.v = 0;
extras.verbose = 0;

# ##  -- with no optimisation using linear PPP with continuation
# extras.U_initial = "linear";
# extras.U_next = "continuation";
# extras.criterion = 1e-5;
# extras.max_iterations = 0;
# [y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

# ##  -- with no optimisation using linear PPP at each step
# extras.U_initial = "linear";
# extras.U_next = "linear";
# extras.criterion = 1e-5;
# extras.max_iterations = 0;
# [y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with optimisation using nonlinear PPP with continuation
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-4;
extras.max_iterations = 100;
extras.v = 1e-3;
extras.verbose = 0;
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);


## Plots
title("");

## U, U_c and U_l
I = 1:N;
IU1 = [I' U(1,:)'];
IU1_c = [I' U_c(1,:)'];
IU1_l = [I' U_l(1,:)'];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("InvertedPendulumOnCartPPP_U1");

IU2 = [I' U(2,:)'];
IU2_c = [I' U_c(2,:)'];
IU2_l = [I' U_l(2,:)'];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("InvertedPendulumOnCartPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
tu =  [t' u']; 
gplot tu title "Output"
psfig("InvertedPendulumOnCartPPP_u");

gset grid; xlabel "Time (sec)"
ty_th = [t' y(1,:)'] ;
ty_x = [t' y(2,:)'] ;
gplot ty_th title "Theta",ty_x title "x"
psfig("InvertedPendulumOnCartPPP_nppp");

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_numpar.txt version [9aa45f03b2].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sInvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Tue Apr 18 18:07:52 BST 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Default parameters
b_m = 	0.0; # sDCS
c = 	0.0; # sC,sC,sCS,sCS
e_0 = 	0.0; # sCS,sCS
e_s = 	0.0; # Se,Se,Se,sSe,sSe,sSe
f_0 = 	0.0; # sIS,sIS,sIS
f_s = 	0.0; # Sf,Sf,Sf,sSf,sSf,sSf
g = 	0.0; # AFe,AFe,sInvertedPendulum,sROD
i = 	0.0; # sI,sI,sI,sI,sI,sI,sIS,sIS,sIS
i_0 = 	0.0; # sDCS
j_m = 	0.0; # sDCS,sROD
j_p = 	0.0; # sInvertedPendulum
ppp_1 = 	1.0; # sOpenLoop
ppp_2 = 	0.0; # sOpenLoop
ppp_3 = 	0.0; # sOpenLoop
ppp_4 = 	0.0; # sOpenLoop
k_g = 	0.0; # sDrive
k_m = 	0.0; # sDCS
l_a = 	0.0; # sDCS,sROD
l_b = 	0.0; # sROD
l_p = 	0.0; # sInvertedPendulum,sInvertedPendulumOnCart
m = 	0.0; # sROD
m_c = 	0.0; # sCart
m_p = 	0.0; # sInvertedPendulum
m_t = 	0.0; # sInvertedPendulum
omega_0 = 	0.0; # sInvertedPendulum,sROD
r = 	0.0; # sDrive,sR,sR
r_a = 	0.0; # sDCS
r_c = 	0.0; # sCart
r_p = 	0.0; # sCart
theta_0 = 	0.0; # sInvertedPendulum,sROD
v_0 = 	0.0; # sCart
x_0 = 	0.0; # sCart,sINTFS,sINTFS


## Pysical Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	1.5;			# Cart friction

l_p =   0.61;			# Pendulum length
m_p =   0.210;			# Pendulum mass
r_p = 	0.0;			# Pendulum friction

j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

g = 9.81;			# Gravity

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_rep.txt version [9c0f6beadc].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system InvertedPendulumOnCartPPP (InvertedPendulumOnCartPPP_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:29:10  peterg
## To RCS
##
## Revision 1.3  2000/08/29 13:57:23  peterg
## Zapped some steps which prevent ppp from working ????
##
## Revision 1.2  2000/05/20 17:45:38  peterg
## Tidied
##
## Revision 1.1  2000/05/20 17:43:40  peterg
## Initial revision
##
###############################################################

mtt InvertedPendulumOnCartPPP abg tex # The system description
mtt InvertedPendulumOnCartPPP cbg ps # The causal bond graph
mtt InvertedPendulumOnCartPPP struc tex	# The system structure
mtt InvertedPendulumOnCartPPP dae tex # The system dae
# mtt InvertedPendulumOnCartPPP sm tex # State matrices (of linearised system)

# mtt InvertedPendulumOnCartPPP simpar tex # Simulation parameters
# mtt InvertedPendulumOnCartPPP numpar tex # Numerical simulation parameters
# mtt InvertedPendulumOnCartPPP input tex	# Simulation input
# mtt InvertedPendulumOnCartPPP odeso ps # Simulation output

mtt InvertedPendulumOnCartPPP nppp m # How its done
mtt InvertedPendulumOnCartPPP nppp ps # The PPP output

mtt InvertedPendulumOnCartPPP rep txt # The report outline



Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_simpar.txt version [6ec8d445cd].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system InvertedPendulumOnCartPPP (InvertedPendulumOnCartPPP_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;      # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;		# Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_state.txt version [009c83cce5].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (InvertedPendulumOnCartPPP_state.txt)
# Generated by MTT at Thu May  4 16:13:13 BST 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the states
mttx(1) 	= 0.0; 	# i (InvertedPendulumOnCartPPP_mtt2_motor_l_a)
mttx(2) 	= 0.0; 	# i (InvertedPendulumOnCartPPP_mtt3_rod_J)
mttx(3) 	= -pi/2; 	# c (InvertedPendulumOnCartPPP_mtt3_rod_th_unit)
mttx(4) 	= 0.0; 	# i (InvertedPendulumOnCartPPP_mtt4_m_c)
mttx(5) 	= 0.0; 	# c (InvertedPendulumOnCartPPP_mtt4_x_unit)

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulum_abg.fig version [66be544a7f].




























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3555 5085 6345 5310
4 1 4 100 0 18 14 0.0000 4 210 510 3825 5265 [x_b]\001
4 1 4 100 0 18 14 0.0000 4 210 525 4950 5265 [y_b]\001
4 1 4 100 0 18 14 0.0000 4 210 525 6075 5265 [a_b]\001
-6
6 3555 4545 6345 4770
4 1 4 100 0 18 14 0.0000 4 210 495 3825 4725 [x_a]\001
4 1 4 100 0 18 14 0.0000 4 210 510 4950 4725 [y_a]\001
4 1 4 100 0 18 14 0.0000 4 210 510 6075 4725 [a_a]\001
-6
6 5805 5355 6345 5445
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5850 5400 6300 5400
-6
6 3600 4455 4140 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3645 4500 4095 4500
-6
6 4635 4455 5175 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4680 4500 5130 4500
-6
6 5805 4455 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5850 4500 6300 4500
-6
6 8505 4680 8595 5220
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8550 4725 8550 5175
-6
6 4770 2790 5040 3060
4 1 0 100 0 18 20 0.0000 4 270 195 4905 3060 1\001
-6
6 3690 2790 3960 3060
4 1 0 100 0 18 20 0.0000 4 270 195 3825 3060 1\001
-6
6 3555 2655 4095 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 2700 4050 2700
-6
6 4680 2655 5220 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 2700 5175 2700
-6
6 4950 2520 5355 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5008 2552 5327 2870
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 4950 8550 4950 8325 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 4950 1350 5175 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 3825 1350 4050 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5143 2687 6098 1732 6098 2050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 6750 4050 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 6750 5175 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 6750 3825 5400 4050 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 6750 4950 5400 5175 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 6750 6075 5400 6300 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 4500 6075 3150 6300 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 4500 4950 3150 5175 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4500 3825 3150 4050 3375
4 1 0 100 0 18 20 0.0000 4 285 1515 4964 5040 ROD:rod\001
4 1 0 100 0 18 18 0.0000 4 270 885 6030 3015 Se:a_0\001
4 1 4 100 0 18 20 0.0000 4 360 1050 3780 7155 SS:[x]\001
4 1 4 100 0 18 20 0.0000 4 360 1080 4950 7155 SS:[y]\001
4 1 4 100 0 18 20 0.0000 4 360 1065 6075 7155 SS:[a]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6300 4995 [a]\001
4 0 0 100 0 18 20 0.0000 4 285 1515 8685 5085 De:theta\001
4 1 0 100 0 18 18 0.0000 4 270 675 4995 1170 I:m_y\001
4 1 0 100 0 18 18 0.0000 4 270 675 3870 1170 I:m_x\001
4 0 0 100 0 18 20 0.0000 4 360 1110 6120 1800 Se:mg\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulum_lbl.txt version [ff2b5f8890].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system InvertedPendulum (InvertedPendulum_lbl.txt)
%SUMMARY InvertedPendulum
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x,y,a


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


% Component type I
        m_x     lin             flow,m_t
        m_y     lin             flow,m_t

% Component type Se
	mg			SS		m_t*g

% Component type De
	theta			SS	external

% Component type SS
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	a_0	 SS	0

% Component type gRod
	rod	 none		l_p;l_p;j_p;m_p;g;omega_0;theta_0
 

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Make version [e246f48d9d].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Makes the files needed for Figures.m
## Copyright (C) 2000 by Peter J. Gawthrop

if [ -z "$1" ]; then
    echo Usage ./Make system_name
    exit
else
    echo "Making simulation for system $1 (for use in Figures.m)"
fi

## System
mtt -q -c -stdin $1 ode2odes out
mtt -q -c -stdin $1 sim m
mtt -q  $1 state m
mtt -q  $1 sympar m
mtt -q  $1 numpar m

## Sensitivity system
mtt -q -c -stdin -s s$1 ode2odes out
mtt -q -c -stdin -s s$1 sim m
mtt -q  -s s$1 state m
mtt -q  -s s$1 sympar m
mtt -q  -s s$1 numpar m

## Additional system reps for PPP
mtt -q  $1 sm m
mtt -q  $1 def m
mtt -q  -s s$1 def m

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/OpenLoop_abg.fig version [014e1e18a1].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 6570 1530 7200 1935
4 1 1 101 0 3 20 0.0000 4 270 495 6885 1845 u ( )\001
4 1 1 101 0 0 20 0.0000 4 135 150 6840 1800 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 7065 1845 t\001
-6
6 1800 1530 2520 2025
4 1 1 101 0 3 20 0.0000 4 270 555 2160 1845 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 2025 1\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 1800 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 1845 t\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6345 2250 7695 2250 7470 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2250 5850 2250 5625 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 5400 2925 5400 2700 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4545 5400 5895 5400 5670 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 5175 6075 4050 6300 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 3825 2925 3825 2700 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4545 3825 5895 3825 5670 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 3600 6075 2475 6300 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 6975 2925 6975 2700 7200
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4545 6975 5895 6975 5670 7200
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 6750 6075 5625 6300 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2250 2925 2250 2700 2475
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9000 7875 9000 1125 225 1125 225 7875 9000 7875
4 2 0 100 0 18 20 0.0000 4 300 1170 1485 2340 Se:Us_1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 2340 AE:U_1\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 2340 1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 5490 AE:U_3\001
4 2 0 100 0 18 20 0.0000 4 300 1170 1530 5535 Se:Us_3\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 5535 1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 3915 AE:U_2\001
4 2 0 100 0 18 20 0.0000 4 300 1170 1530 3960 Se:Us_2\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 3960 1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 7065 AE:U_4\001
4 2 0 100 0 18 20 0.0000 4 300 1170 1530 7110 Se:Us_4\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 7110 1\001
4 1 1 101 0 3 20 0.0000 4 270 555 2160 3420 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 3600 2\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 3375 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 3420 t\001
4 1 1 101 0 3 20 0.0000 4 270 555 2160 4995 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 5175 3\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 4950 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 4995 t\001
4 1 1 101 0 3 20 0.0000 4 270 555 2160 6570 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 6750 4\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 6525 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 6570 t\001
4 0 4 100 0 18 20 0.0000 4 300 1005 7830 2340 SS:[us]\001
4 1 1 101 0 3 20 0.0000 4 285 2370 3825 7695 Open-loop control\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/OpenLoop_lbl.txt version [da3b550155].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system OpenLoop (OpenLoop_lbl.txt)
%SUMMARY OpenLoop
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	us

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	U_1	 lin		ppp_1
	U_2	 lin		ppp_2
	U_3	 lin		ppp_3
	U_4	 lin		ppp_4

% Component type SS
	[us]	SS		external,external

% Component type Se
	Us_1		SS	external
	Us_2		SS	external
	Us_3		SS	external
	Us_4		SS	external


Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/ROD_abg.fig version [9da8669d9a].
































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9225 6075 8955 6075
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 5175 2025 3825 2250 3825
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 4950 8550 5400
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 5400
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 6525 3150 7650 3150 7425
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5425 5419 4750 6094 4750 5869
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4273 3823 3148 2698 3373 2698
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4950 4725 4275 4950 4275
4 1 -1 0 0 0 20 0.0000 4 255 180 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 255 570 6933 5268 IS:J\001
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 255 180 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 255 180 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 330 870 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 330 900 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 255 1440 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 255 1440 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 255 1425 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 255 1425 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 255 180 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 240 675 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 255 1425 4681 5266 INTFS:th\001
4 1 1 1 0 0 20 0.0000 4 255 270 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 195 240 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 255 240 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 240 675 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 240 675 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 240 675 3960 6210 [mod]\001
4 1 4 0 0 0 20 0.0000 4 330 1785 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000 4 330 1800 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000 4 330 1755 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000 4 330 1770 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000 4 330 2700 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000 4 330 2715 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000 4 330 765 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 255 1800 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 330 780 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000 4 330 930 9360 6345 Se:mg\001
4 2 4 0 0 0 20 0.0000 4 330 1515 1935 3735 SS:[angle]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/ROD_lbl.txt version [02fb4fd7ae].






































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	ROD: rigid rod in two dimensions - with gravity and angle port
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS angle|a		angle	# Angle port

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/10/22 02:01:45  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/08/05 08:04:40  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/11/30 10:47:53  peterg
% %% Added extra a_a and a_b aliases
% %%
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m;omega_0
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th	none	   theta_0

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b


% Component type Se
	mg			SS		m*g

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external
	[angle]			SS		external,external


	

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Zero_abg.fig version [10a50da953].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 4050 2700 3825 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 3375 4050 3375 3825 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
4 1 4 100 0 18 18 0.0000 4 270 765 2160 2790 SS:[x]\001
4 1 0 100 0 18 18 0.0000 4 210 570 4545 2790 Se:x\001
4 1 4 100 0 18 18 0.0000 4 270 765 2160 3465 SS:[y]\001
4 1 0 100 0 18 18 0.0000 4 270 570 4545 3465 Se:y\001
4 1 4 100 0 18 18 0.0000 4 270 780 2160 4140 SS:[a]\001
4 1 0 100 0 18 18 0.0000 4 210 525 4545 4140 Sf:a\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Zero_lbl.txt version [651d1a7e40].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Zero (Zero_lbl.txt)
%SUMMARY Zero
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x,y,a

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	x	SS		0
	y	SS		0

% Component type Sf
	a	SS		external


Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sCart_lbl.txt version [825772b7ca].




























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sCart (sCart_lbl.txt)
%SUMMARY sCart
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	        drive_1,drive_2
%ALIAS	pendulum|out	x_1,x_2,y_1,y_2,a_1,a_2

% Argument aliases
%ALIAS	$1	m_c
%ALIAS	$2	r_c
%ALIAS	$3	r_p

%ALIAS	$4	m_cs
%ALIAS	$5	r_cs
%ALIAS	$6	r_ps

%ALIAS  $7	v_0
%ALIAS  $8	v_0s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	m_c		lin	flow,m_c;v_0;m_cs;v_0s

% Component type R
	r_c		lin	flow,r_c;r_cs
	r_p		lin	flow,r_p;r_ps

% Component type sINTFS
	x               none    x_0;x_0s

% Component type SS
	[a]	SS		external,external
	[drive]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type De
	Position		SS	external;external

% Component type Sf
	zero_velocity		SS	0;0



Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDCS_lbl.txt version [8f818cd526].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY sDCS: DC motor - sensitivity 
%DESCRIPTION A special for the inverted pendulum system
%DESCRIPTION Derivative causality on the  shaft
%DESCRIPTION No aliased parameters
%DESCRIPTION Built in causality - speeds things up
%DESCRIPTION Only the armature state and shaft resistance are variable

%ALIAS in	Electrical_1,Electrical_2
%ALIAS out	Mechanical_1,Mechanical_2


%% Label file for system sDCS (sDCS_lbl.txt)


%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin		flow,k_m;0

% Electrical components
%Inductance
l_a	lin		flow,l_a;i_0;0;i_0s

%Resistance
r_a	lin		flow,r_a;0

% Mechanical components
%Inertia
j_m	lin		flow,j_m;0

%Friction
b_m	lin		flow,b_m;b_ms

% Ports
	[Electrical]	SS	external,external
	[Mechanical]	SS	external,external

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDriveCart_identify.m version [6868c24a26].














































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function sDriveCart_identify ()

  ## usage:  sDriveCart_identify ()
  ##
  ## 

  ## Identify the Drive/cart friction
  ## 	$Id$	

  system_name = "sDriveCart";	# Name of this system
  input_name = sprintf("%s_input.dat", system_name);
  ## disp("Create programs");
  ## system(sprintf("mtt -q -c -s -stdin %s ode2odes out", system_name)); # Create sim. code
  ## system(sprintf("mtt -q -c -s -stdin %s numpar m", system_name)); # Create sim. code
  ## system(sprintf("mtt -q -c -s -stdin %s def m", system_name)); # Create sim. code

  ## Optimisation parameters
  crite = 1e-5;			# Convergence criterion
  alpha = 0.5;			# Step reduction factor
  max = 30;			# Maximum iterations
  View = 1			# View the optimisation process

  ## Parameters
  global mtt_n_parameters
  mtt_n_parameters = 0;

  eval(sprintf("%s_numpar;", system_name));

  alpha = 0.75;
  criterion = 1e-9;
  max_iterations = 20;

  ## Real data
  disp("Loading data");
  load -force data_020999.dat;
  [N_data,M_data] = size(data_020999);
  M = 10;
  t = data_020999(1:M:N_data,1);
  u = data_020999(1:M:N_data,2);
  y = data_020999(1:M:N_data,3)/100; # convert from cm to m

  gset grid
  gset title ""
  gset xlabel "Time (sec)"
  tu = [t u];
  ty = [t y];
  gplot tu title "input (V)", ty title "output (m)"
  psfig("sDriveCart_yu");


  y_s = [u y];			# u is first o/p of system.
  ## Start time at zero
  t = t-t(1)*ones(size(t));
  
  T_last = 40;
  DT = t(2)-t(1);

  tu = [t u u u u];		# Put same signal on all inputs (only
				# first used
  save -ascii junk.dat tu
  ## zap the octave comments
  system(sprintf("grep -v \'#\' junk.dat > %s; rm -f junk.dat", input_name));

  ## Set up theta
  control = [1 0 0 0];		# Initial control parameters
  unused = 0;			# Unused parameter slot
  r_c = 0;
  parameters = [r_c m_c unused unused unused];
  i_r = 4+1;
  i_m = 4+2;
  state = [0 unused unused 0 0];
  i_v = 4+5+4;
  i_x = 4+5+5;
  i_i = 4+5+1;
  theta_0 = [control parameters state]';

  ## Weighting function - select output, not input
  weight = ones(size(t))*[0 1];

  ## Estimate r only
  free = [i_r i_i i_v i_x];
  disp("Estimate cart friction ...");
  [theta,Theta,Error,Y] = mtt_optimise(system_name,y_s,theta_0,"time",\
				       free,weight,crite,max,alpha,View);

  ## Plot results
#   ix = [its Theta(i_x,:)'];
#   iv = [its Theta(i_v,:)'];
#   ii = [its Theta(i_i,:)'];

#   gplot \
#       ix with linespoints title "x_0",\
#       iv with linespoints title "p_0",\
#       ii with linespoints title "i_0"

#   psfig("sDriveCart_ident_x");

  [N_th,M_th] = size(Theta);
  its = [0:M_th-1]';
  gset grid
  gset title ""
  gset xlabel "Iterations"
  ir = [its Theta(i_r,:)'];
  gplot ir with linespoints title "r"
  psfig("sDriveCart_ident_r");

  r_c = theta(i_r)

endfunction

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDriveCart_numpar.txt version [1efc3b6766].









































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sInvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Wed Aug 25 22:57:05 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1999/12/03 00:50:28  peterg
# %% Initial revision
# %%
# %% Revision 1.1  1999/11/12 06:47:50  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Same as sInvertedpendulumOnCart with pendulum stuff removed.

# Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	5.0;			# Cart friction

# l_p =   0.61;			# Pendulum length
# m_p =   0.210;			# Pendulum mass
# r_p = 	0.0;			# Pendulum friction
# j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

# g = +9.81;			# Gravity

# m_t = 0.0; # Tip mass

## Sensitivity parameters
m_cs = 0;			# Cart mass
b_ms = 0;			# Motor friction 
r_cs = 0;			# Cart friction

# j_ps = 0;			# Pendulum inertia
# m_ps = 0;			# Pendulum mass
# r_ps = 0;			# Pendulum friction

# m_ts = 0;			# Tip mass

## Initial states
i_0 = 0;			# Initial armature current
# omega_0 = 0;			# Initial pendulum velocity
# theta_0 = 0;			# Initial pendulum angle
v_0 = 0;			# Initial cart velocity
x_0 = 0;			# Initial cart position

## Sensitivity parameters
i_0s = 0;			# Initial armature current
# omega_0s = 0;			# Initial pendulum velocity
# theta_0s = 0;			# Initial pendulum angle
v_0s = 0;			# Initial cart velocity
x_0s = 0;			# Initial cart position

## Control parameters
k_1 = 1;
k_2 = 0;
k_3 = 0;
k_4 = 0;

## Control sensitivity parameters
k_1s = 0;
k_2s = 0;
k_3s = 0;
k_4s = 0;


## Which sensitivity function? NB all other sens. coeffs MUST be zero -
## see above
if (mtt_n_parameters>=1)
  mtti = mtt_parameters(1);

  if mtti==1
    k_1s = 1;
  endif
  
  if mtti==2
    k_2s = 1;
  endif
  
  if mtti==3
    k_3s = 1;
  endif

  if mtti==4
    k_4s = 1;
  endif

  if mtti==5
    r_cs = 1;
  endif
  
  if mtti==6
    m_cs = 1;
  endif

#   if mtti==7
#     r_ps = 1;
#   endif

#   if mtti==8
#     m_ts = 1;
#   endif

#   if mtti==9
#     j_ps = 1;
#   endif
  
  if mtti==10
    i_0s = 1;			# Initial armature current
  endif
  
#   if mtti==11
#     omega_0s = 1;		# Initial pendulum velocity
#   endif
  
#   if mtti==12
#     theta_0s = 1;		# Initial pendulum position
#   endif
  
  if mtti==13
    v_0s = 1;			# Initial cart velocity
  endif
  
  if mtti==14
    x_0s = 1;			# Initial cart angle
  endif
  
endif;

## Control parameters

if (mtt_n_parameters>=2)
  k_1 = mtt_parameters(2);
endif;

if (mtt_n_parameters>=3)
  k_2 = mtt_parameters(3);
endif;

if (mtt_n_parameters>=4)
  k_3 = mtt_parameters(4);
endif;

if (mtt_n_parameters>=5)
  k_4 = mtt_parameters(5);
endif;

## Physical parameters
if (mtt_n_parameters>=6)
  r_c = mtt_parameters(6);
endif;

if (mtt_n_parameters>=7)
  m_c = mtt_parameters(7);
endif;

# if (mtt_n_parameters>=8)
#   r_p = mtt_parameters(8);
# endif;

# if (mtt_n_parameters>=9)
#   m_t = mtt_parameters(9);
# endif;

# if (mtt_n_parameters>=10)
#   j_p = mtt_parameters(10);
# endif;

## Initial condition parameters - states are read in
if (mtt_n_parameters>=15)	# 
  i_0 = mtt_parameters(11); # Initial armature current
#   omega_0 = mtt_parameters(12); # Initial cart velocity
#   theta_0 = mtt_parameters(13);	# Initial cart position
  v_0 = mtt_parameters(14); # Initial pendulum velocity
  x_0 = mtt_parameters(15); # Initial pendulum angle
endif;

## Simulation stuff

if (mtt_n_parameters>=16)
  LAST = mtt_parameters(16);
endif;
if (mtt_n_parameters>=17)
  DT = mtt_parameters(17);
endif;

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDriveCart_simpar.txt version [66769d1708].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system sDriveCart (sDriveCart_simpar.txt)
# Generated by MTT on Fri Dec 3 10:30:48 EST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 40.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDrive_lbl.txt version [5a461fb90b].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sDrive (sDrive_lbl.txt)
%SUMMARY sDrive
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Electrical_1,Electrical_2
%ALIAS	out	Mechanical_1,Mechanical_2

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type sDCS
	motor

% Component type SS
	[Electrical]	SS		external,external
	[Mechanical]	SS		external,external

% Component type sTF
	k_g		lin	flow,k_g;0
	r		lin	flow,r;0



Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sEMTF_abg.fig version [06c2007d04].








































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 7155 2295 7695
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 7200 2250 7650
-6
6 3510 4005 4050 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4005 4050 3555 4050
-6
6 3645 5850 4185 5940
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4140 5895 3690 5895
-6
6 8730 5355 9270 5445
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9225 5400 8775 5400
-6
6 3600 7155 4140 7245
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4095 7200 3645 7200
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 7425 3600 7425 3375 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 7425 5400 7425 5175 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 7425 8775 7425 8550 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 7425 10575 7425 10350 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 3600 3825 3375 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3825 5400 3825 5175 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 3825 8775 3825 8550 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 3825 10575 3825 10350 4050
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5895 9000 7200 9000 6975
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9006 5873 3831 7178 3831 6953
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 450 6300 1800 6525 1575
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2250 6300 3600 6525 3375
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 1800 6525 1800
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 2025 4275 2025 4275 5400 4500 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 3825 5400 4050 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4050 9000 5400 9225 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 2250 6525 7200 6750 6975
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 2025 8550 2025 8550 5400 8775 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 8550 9225 8550 9225 5850 9450 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 8550 3600 8550 3600 5850 3375 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 10125 6300 8775 6525 9000
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 8775 6525 8775
4 1 4 100 0 18 20 0.0000 4 285 2415 6210 360 SS:[Actual_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6300 2115 0\001
4 1 4 100 0 18 20 0.0000 4 285 1845 1215 7515 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 7515 1\001
4 1 0 100 0 18 20 0.0000 4 225 1590 6435 7515 EMTF:sens\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 7515 0\001
4 1 4 100 0 18 20 0.0000 4 285 2040 11790 7515 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 285 2055 1215 3915 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3915 1\001
4 1 0 100 0 18 20 0.0000 4 225 1785 6435 3915 EMTF:actual\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 3915 0\001
4 1 4 100 0 18 20 0.0000 4 285 2250 11790 3915 SS:[Actual_out]\001
4 1 0 100 0 18 20 0.0000 4 225 1170 8955 5715 AE3:ae3\001
4 1 0 100 0 18 20 0.0000 4 225 1095 3825 5715 AF3:af3\001
4 2 4 100 0 18 14 0.0000 4 210 600 6255 3600 [mod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 6435 7155 [mod]\001
4 1 4 100 0 18 20 0.0000 4 285 2205 6300 10395 SS:[Sens_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6345 8640 0\001
4 2 4 100 0 18 14 0.0000 4 210 720 3420 5985 [smod]\001
4 0 4 100 0 18 14 0.0000 4 210 720 9540 5940 [smod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 8505 5355 [mod]\001
4 0 4 100 0 18 14 0.0000 4 210 600 4455 5400 [mod]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sEMTF_lbl.txt version [740377120d].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sEMTF (sEMTF_lbl.txt)
%SUMMARY sEMTF Effort modulated TF - sensitivity version
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out
%ALIAS	mod	Actual_mod,Sens_mod


% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	lsin
%ALIAS	$2	slsin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type EMTF
	actual		lsin	flow,l
	sens		lsin	flow,l

% Component type AE3 (????NB NEGATIVE GAIN HERE!!!!)
	ae3             slsin   l

% Component type AF3
	af3             slsin   l

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Actual_mod]	SS		external,internal
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external
	[Sens_mod]	SS		external,internal



Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sINTFS_abg.fig version [3690b29bfb].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10575 4950 45 4950 45 1350 10575 1350 10575 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3150 2475 3150 2250 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 3150 7426 3150 7201 3375
4 1 6 0 0 0 20 0.0000 4 256 181 4502 3242 [1,2]\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4502 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 255 1110 4501 1891 sCS:unit\001
4 2 6 0 0 0 20 0.0000 4 316 1456 1531 3241 [1,2]\001
4 2 4 0 0 0 20 0.0000 4 315 1455 1531 3240 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 255 825 2925 3240 sAF:af\001
4 1 -1 0 0 0 20 0.0000 4 255 900 6075 3240 sAE:ae\001
4 0 6 0 0 0 20 0.0000 4 331 3046 7471 3241 [1,2]\001
4 0 4 0 0 0 20 0.0000 4 330 3045 7471 3240 SS:[Integrated_flow]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sINTFS_lbl.txt version [04b43b7e2f].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sINTFS (sINTFS_lbl.txt)
%SUMMARY	sINTFS: flow integrator
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/16 07:35:10  peterg
% %% Aliased version
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow_1,Flow_2
%ALIAS	out	Integrated_flow_1,Integrated_flow_2

% Argument aliases
%ALIAS	$1 x_0	
%ALIAS	$2 x_0s	

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% CS
	unit			SS		effort,1;x_0;0;x_0s

% Component type AE
	ae			lin		1;0

% Component type AF
	af			lin		1;0


% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sIS_abg.fig version [917d2513e9].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 6 100 0 18 20 0.0000 4 271 196 2476 4186 [1,2]\001
4 1 0 100 0 18 20 0.0000 4 270 195 2476 4185 0\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
4 1 0 100 0 18 20 0.0000 4 285 315 2475 2295 sI:i\001
4 0 0 100 0 18 20 0.0000 4 360 1035 4185 4185 sSf:f_0\001
4 1 6 100 0 18 20 0.0000 4 361 1186 2476 6031 [1,2]\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2476 6030 SS:[in]\001

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sIS_lbl.txt version [9a121bfbfe].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sIS (sIS_lbl.txt)
%SUMMARY sIS
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Port aliases
%ALIAS	in	in_1,in_2

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0
%ALIAS	$3	i_s
%ALIAS	$4	f_0s

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[in]	SS		external,external

% Component type sI
	i       lin             flow,i;i_s

% Component type sSf
	f_0     SS	        f_0;f_0s

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCartPPP_numpar.txt version [7f13064103].





























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sInvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Tue Apr 18 18:07:52 BST 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Default parameters
b_m = 	0.0; # sDCS
b_ms = 	0.0; # sDCS
c = 	0.0; # sC,sC,sCS,sCS
c_s = 	0.0; # sCS,sCS
e_0 = 	0.0; # sCS,sCS
e_0s = 	0.0; # sCS,sCS
e_s = 	0.0; # Se,Se,Se,sSe,sSe,sSe
f_0 = 	0.0; # sIS,sIS,sIS
f_0s = 	0.0; # sIS,sIS,sIS
f_s = 	0.0; # Sf,Sf,Sf,sSf,sSf,sSf
g = 	0.0; # AFe,AFe,sInvertedPendulum,sROD
i = 	0.0; # sI,sI,sI,sI,sI,sI,sIS,sIS,sIS
i_0 = 	0.0; # sDCS
i_0s = 	0.0; # sDCS
i_s = 	0.0; # sIS,sIS,sIS
j_m = 	0.0; # sDCS,sROD
j_p = 	0.0; # sInvertedPendulum
j_ps = 	0.0; # sInvertedPendulum
j_s = 	0.0; # sROD
k = 	0.0; # sAE,sAE,sAE,sAF,sAF,sGY,sTF
ppp_1 = 	1.0; # sOpenLoop
ppp_1s = 	0.0; # sOpenLoop
ppp_2 = 	0.0; # sOpenLoop
ppp_2s = 	0.0; # sOpenLoop
ppp_3 = 	0.0; # sOpenLoop
ppp_3s = 	0.0; # sOpenLoop
ppp_4 = 	0.0; # sOpenLoop
ppp_4s = 	0.0; # sOpenLoop
k_g = 	0.0; # sDrive
k_m = 	0.0; # sDCS
k_s = 	0.0; # sAE,sAE,sAE,sAF,sAF,sC,sC,sGY,sI,sI,sI,sI,sI,sI,sR,sR,sSe,sSe,sSe,sSf,sSf,sSf,sTF
l = 	0.0; # AE3,AF3,sEMTF
l_a = 	0.0; # sDCS,sROD
l_b = 	0.0; # sROD
l_p = 	0.0; # sInvertedPendulum,sInvertedPendulumOnCart
m = 	0.0; # sROD
m_c = 	0.0; # sCart
m_cs = 	0.0; # sCart
m_p = 	0.0; # sInvertedPendulum
m_ps = 	0.0; # sInvertedPendulum
m_s = 	0.0; # sROD
m_t = 	0.0; # sInvertedPendulum
m_ts = 	0.0; # sInvertedPendulum
omega_0 = 	0.0; # sInvertedPendulum,sROD
omega_0s = 	0.0; # sInvertedPendulum,sROD
r = 	0.0; # sDrive,sR,sR
r_a = 	0.0; # sDCS
r_c = 	0.0; # sCart
r_cs = 	0.0; # sCart
r_p = 	0.0; # sCart
r_ps = 	0.0; # sCart
theta_0 = 	0.0; # sInvertedPendulum,sROD
theta_0s = 	0.0; # sInvertedPendulum,sROD
v_0 = 	0.0; # sCart
v_0s = 	0.0; # sCart
x_0 = 	0.0; # sCart,sINTFS,sINTFS
x_0s = 	0.0; # sCart,sINTFS,sINTFS


## Pysical Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	1.5;			# Cart friction

l_p =   0.61;			# Pendulum length
m_p =   0.210;			# Pendulum mass
r_p = 	0.0;			# Pendulum friction

j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

g = 9.81;			# Gravity

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCartPPP_state.txt version [3b214e7bb5].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (sInvertedPendulumOnCartPPP_state.txt)
# Generated by MTT at Thu May  4 14:57:10 BST 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the states
mttx(1) 	= 0.0; 	# i_1 (sInvertedPendulumOnCartPPP_mtt2_motor_l_a_i)
mttx(2) 	= 0.0; 	# i_2 (sInvertedPendulumOnCartPPP_mtt2_motor_l_a_i)
mttx(3) 	= 0.0; 	# i_1 (sInvertedPendulumOnCartPPP_mtt3_rod_J_i)
mttx(4) 	= 0.0; 	# i_2 (sInvertedPendulumOnCartPPP_mtt3_rod_J_i)
mttx(5) 	= pi/2; 	# c_1 (sInvertedPendulumOnCartPPP_mtt3_rod_th_unit_c)
mttx(6) 	= 0.0; 	# c_2 (sInvertedPendulumOnCartPPP_mtt3_rod_th_unit_c)
mttx(7) 	= 0.0; 	# i_1 (sInvertedPendulumOnCartPPP_mtt4_m_c_i)
mttx(8) 	= 0.0; 	# i_2 (sInvertedPendulumOnCartPPP_mtt4_m_c_i)
mttx(9) 	= 0.0; 	# c_1 (sInvertedPendulumOnCartPPP_mtt4_x_unit_c)
mttx(10) 	= 0.0; 	# c_2 (sInvertedPendulumOnCartPPP_mtt4_x_unit_c)

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_input.txt version [c3ea90775c].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (sInvertedPendulumOnCart_input.txt)
# Generated by MTT at Thu Aug  5 09:17:30 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
# mttu(1) = 1.0*(t<1) -1.0*((t>=1)&&(t<2)); 	# u (sInvertedPendulumOnCart_F)

  ## Doing control
#   if (mtt_n_parameters>=1)	
#     if (mtt_parameters(1)<5)
      mttu(1) = exp(-0.0*t);
      mttu(2) = exp(-2.0*t);
      mttu(3) = exp(-5.0*t);
      mttu(4) = exp(-10.0*t);

#       mttu(1) = 1;
#       mttu(2) = exp(-0.5*t);;
#       mttu(3) = exp(-t);
#       mttu(4) = exp(-2*t);

#       mttu(1) = (t<0.1);
#       mttu(2) = ((t>=0.1)&&(t<0.2));
#       mttu(3) = ((t>=0.2)&&(t<0.3));
#       mttu(4) = ((t>=0.3)&&(t<0.4));
#     else			
#       ## Identification 
#       mttu(1) = (-1*((t>=3.37966)&&(t<= 5.36946)) + ((t>=10.36896)&&(t<=12.36876))); 
#     endif
#   endif


Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_lbl.txt version [6c0ec1a387].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sInvertedPendulumOnCart (sInvertedPendulumOnCart_lbl.txt)
%SUMMARY sInvertedPendulumOnCart
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR l_p		#Pendulum length

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_rep.txt version [d081dbadd3].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sInvertedPendulumOnCart (sInvertedPendulumOnCart_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:29:10  peterg
## To RCS
##
###############################################################

mtt sInvertedPendulumOnCart abg tex			# The system description
mtt sInvertedPendulumOnCart cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt sInvertedPendulumOnCart struc tex	        # The system structure
mtt sInvertedPendulumOnCart dae tex	        # The system dae
## mtt sInvertedPendulumOnCart ode tex	        # The system ode 
## mtt sInvertedPendulumOnCart sspar tex		# Steady-state parameters
## mtt sInvertedPendulumOnCart ss tex 		# Steady state
## mtt sInvertedPendulumOnCart dm tex		# Descriptor matrices (of linearised system)
mtt sInvertedPendulumOnCart sm tex		# State matrices (of linearised system)
## mtt sInvertedPendulumOnCart tf tex		# Transfer function (of linearised system)
## mtt sInvertedPendulumOnCart lmfr ps		# log modulus of frequency response (of linearised system)
mtt sInvertedPendulumOnCart simpar tex		# Simulation parameters
mtt sInvertedPendulumOnCart numpar tex		# Numerical simulation parameters
mtt sInvertedPendulumOnCart input tex		# Simulation input
mtt -cse sInvertedPendulumOnCart odeso ps		# Simulation output

mtt sInvertedPendulumOnCart ppp ps		# PPP control

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_simpar.txt version [2fbcb7b3c6].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system sInvertedPendulumOnCart (sInvertedPendulumOnCart_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;      # Last time in simulation
DT          = 0.05;		# Print interval
STEPFACTOR  = 1;		# Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input


Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulum_lbl.txt version [19c18e9e54].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sInvertedPendulum (sInvertedPendulum_lbl.txt)
%SUMMARY sInvertedPendulum
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x_1,x_2,y_1,y_2,a_1,a_2


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
        m_x     lin             flow,m_t;m_ts
        m_y     lin             flow,m_t;m_ts

% Component type Se
	mg			SS		m_t*g;0

% Component type De
	theta			SS	external;external



% Component type SS
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	a_0	 SS	0;0

% Component type ROD
	rod	 none		l_p;l_p;j_p;m_p;g;omega_0;theta_0;j_ps;m_ps;omega_0s;theta_0s
 

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sOpenLoop_lbl.txt version [6832b95589].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sOpenLoop (sOpenLoop_lbl.txt)
%SUMMARY sOpenLoop
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	us_1,us_2

% Argument aliases
%ALIAS	$1	U_1
%ALIAS	$2	U_1s
%ALIAS	$3	U_2
%ALIAS	$4	U_2s
%ALIAS	$5	U_3
%ALIAS	$6	U_3s
%ALIAS	$7	U_4
%ALIAS	$8	U_4s
%ALIAS	$9	us
%ALIAS	$10	uss
%ALIAS	$11	Us_1
%ALIAS	$12	Us_1s
%ALIAS	$13	Us_2
%ALIAS	$14	Us_2s
%ALIAS	$15	Us_3
%ALIAS	$16	Us_3s
%ALIAS	$17	Us_4
%ALIAS	$18	Us_4s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	[us]	SS		external,external

% Component type AE
	U_1	lin		ppp_1;ppp_1s
	U_2	lin		ppp_2;ppp_2s
	U_3	lin		ppp_3;ppp_3s
	U_4	lin		ppp_4;ppp_4s

% Component type Se
	Us_1	SS		external;0
	Us_2	SS		external;0
	Us_3	SS		external;0
	Us_4	SS		external;0

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sROD_lbl.txt version [710dd08bb5].











































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	sROD: rigid rod in two dimensions - with gravity and angle port
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS $6	omega_0 # Initial angular velocity 
%ALIAS $7	theta_0 # Initial angular velocity 

## Sensitivities
%ALIAS $8	j_s 
%ALIAS $9	m_s 

%ALIAS $10	omega_0s # Initial angular velocity 
%ALIAS $11	theta_0s # Initial angular velocity 


%ALIAS in|Tip_a		xTip_a_1,xTip_a_2,angularTip_a_1,angularTip_a_2,yTip_a_1,yTip_a_2 	
%ALIAS out|Tip_b	xTip_b_1,xTip_b_2,angularTip_b_1,angularTip_b_2,yTip_b_1,yTip_b_2 	

%ALIAS x_a		xTip_a_1,xTip_a_2 # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a_1,yTip_a_2 # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a_1,angularTip_a_2 # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b_1,xTip_b_2 # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b_1,yTip_b_2 # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b_1,angularTip_b_2 # Torque/angular velocity at tip b

%ALIAS angle|a		angle_1,angle_2	# Angle port

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system sROD (sROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/10/22 02:01:45  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/08/05 08:04:40  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/11/30 10:47:53  peterg
% %% Added extra a_a and a_b aliases
% %%
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m;omega_0;j_s;omega_0s
m_x	lin	flow,m;m_s
m_y	lin	flow,m;m_s

%Integrate angular velocity to get angle
th	   none	   theta_0;theta_0s

%Modulated transformers
s1	lsin;slsin	l_a
s2	lsin;slsin	l_b
c1	lcos;slcos	l_a
c2	lcos;slcos	l_b


% Component type Se
	mg			SS		m*g;0

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external
	[angle]			SS		external,external

Added mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sZero_lbl.txt version [c03b79280f].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sZero (sZero_lbl.txt)
%SUMMARY sZero
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x_1,x_2,y_1,y_2,a_1,a_2


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	x	SS		0;0
	y	SS		0;0

% Component type Sf
	a	SS		0;0

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_abg.fig version [bb4e1ded8d].
























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
6 8550 825 13500 3375
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 1725 11695 1725 11845 1875
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 1350 11695 1350 11845 1500
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 975 11695 975 11845 1125
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 2100 11695 2100 11845 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 2475 11695 2475 11845 2625
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 2850 11695 2850 11845 3000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 3225 11695 3225 11845 3375
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10200 2100 9300 2100 9450 2250
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 975 8700 975 8700 1875 8550 1725
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 1275 9000 1275 9000 1875 8850 1725
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 1725 9300 1725 9300 1875 9150 1725
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 3225 8700 3225 8700 2325 8550 2475
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 2925 9000 2925 9000 2325 8850 2475
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 2475 9300 2475 9300 2325 9150 2475
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 2175 AE:ppp_4\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 1800 Se:u_3\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 1800 AE:ppp_3\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 1425 Se:u_2\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 1425 AE:ppp_2\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 1050 Se:u_1\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 1050 AE:ppp_1\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 2550 AE:ppp_5\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 2925 AE:ppp_6\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 3300 AE:ppp_7\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 2550 Se:u_5\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 2925 Se:u_6\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 3300 Se:u_7\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 2175 Se:u_4\001
4 1 -1 0 0 0 20 0.0000 4 210 150 9000 2175 1\001
-6
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2706 7206 3606 7206 3456 7356
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2406 7506 2406 8406 2556 8256
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3906 7506 3906 8406 4056 8256
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 7208 8108 7208 7958 7358
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 7208 9608 7208 9458 7358
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8408 7508 8408 8408 8558 8258
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 6908 8108 6008 8108 6233
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 6008 9608 6908 9383 6908
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9909 7509 9909 8409 10059 8259
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6908 7508 6908 8408 7058 8258
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11407 7507 11407 8407 11557 8257
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11406 5706 11406 4806 11556 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 7206 5106 7206 4956 7356
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5406 7506 5406 8406 5556 8256
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 6906 5106 6006 5106 6231
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 5705 5405 4805 5555 4955
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2405 5705 2405 4805 2555 4955
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 7207 12607 7207 12457 7357
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 6007 12607 6907 12382 6907
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2105 4205 2105 3305 2255 3455
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2705 4205 2705 3305 2855 3455
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 7206 6606 7206 6456 7356
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 6006 6606 6906 6381 6906
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2704 6004 3604 6904 3379 6904
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 7208 2108 7208 1958 7358
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 6908 2108 6008 2108 6233
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 681 6006 1131 6006
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 906 6906 906 6006 1056 6156
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12905 6905 12905 6005 13055 6155
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 7207 11107 7207 10957 7357
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 6907 11107 6007 11107 6232
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8400 5700 8625 5700
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12900 6000 13125 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12675 6000 12900 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8175 5700 8400 5700
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 1501 7801 301 7801 301 5401 1501 5401 1501 7801
2 2 1 2 1 7 1 0 -1 6.000 1 0 0 0 0 5
	 1502 2852 3302 2852 3302 5777 1502 5777 1502 2852
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 4501 9001 3301 9001 3301 6301 4501 6301 4501 9001
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 6000 9000 4800 9000 4800 4200 6000 4200 6000 9000
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7501 9001 6301 9001 6301 6301 7501 6301 7501 9001
2 4 1 2 1 7 2 0 -1 6.000 0 0 7 0 0 5
	 9000 9000 7800 9000 7800 4200 9000 4200 9000 9000
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 10501 9001 9301 9001 9301 6301 10501 6301 10501 9001
2 4 1 2 1 -1 1 0 -1 6.000 0 0 7 0 0 5
	 12000 9000 10800 9000 10800 4200 12000 4200 12000 9000
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 13501 7801 12301 7801 12301 5401 13501 5401 13501 7801
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 8700 2100 8400 2100 8400 5700 8550 5550
2 2 1 2 1 7 101 0 -1 6.000 0 0 -1 0 0 5
	 8100 600 13800 600 13800 3600 8100 3600 8100 600
4 1 -1 0 0 0 20 0.0000 4 210 150 2406 7281 0\001
4 1 -1 0 0 0 20 0.0000 4 285 690 3906 8781 I:m_1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 2405 8780 R:b_1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 2405 6080 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3906 7281 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 8408 7283 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 8408 6083 0\001
4 1 -1 0 0 0 20 0.0000 4 285 705 8483 8783 R:b_3\001
4 1 -1 0 0 0 20 0.0000 4 285 690 9906 8781 I:m_3\001
4 1 -1 0 0 0 20 0.0000 4 285 690 6905 8780 I:m_2\001
4 1 -1 0 0 0 20 0.0000 4 210 150 11407 7282 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 11407 6082 0\001
4 1 -1 0 0 0 20 0.0000 4 285 645 11406 4581 C:k_t\001
4 1 -1 0 0 0 20 0.0000 4 285 645 11482 8782 R:b_t\001
4 1 -1 0 0 0 20 0.0000 4 210 150 5406 7281 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 5406 6081 0\001
4 1 -1 0 0 0 20 0.0000 4 285 705 5481 8781 R:b_2\001
4 1 -1 0 0 0 20 0.0000 4 210 150 12909 7284 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 6908 7283 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 2404 4579 1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 2779 3154 C:p_1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 2104 3154 R:d_1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 910 7285 1\001
4 1 -1 0 0 0 20 0.0000 4 285 765 902 5777 Sf:v_b\001
4 1 -1 0 0 0 20 0.0000 4 285 735 12905 5780 De:f_t\001
4 1 -1 0 0 0 20 0.0000 4 210 150 9909 7284 1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 5405 4580 C:k_2\001
4 1 1 1 0 3 20 0.0000 4 210 1515 3901 9301 Macro mass\001
4 1 1 1 0 3 20 0.0000 4 210 1770 2401 2776 Macro control\001
4 1 1 1 0 3 20 0.0000 4 210 1470 900 8100 Macro base\001
4 1 1 1 0 3 20 0.0000 4 285 1845 5400 4050 Compliant link\001
4 1 1 1 0 3 20 0.0000 4 210 1425 6901 9301 Micro mass\001
4 1 1 1 0 3 20 0.0000 4 210 1860 8475 4050 Micro actuator\001
4 1 1 1 0 3 20 0.0000 4 285 1095 9901 9301 Tip mass\001
4 1 1 1 0 3 20 0.0000 4 285 2940 11400 4050 Compliant environment\001
4 1 1 1 0 3 20 0.0000 4 285 1275 12901 8101 Tip sensor\001
4 1 1 1 0 3 20 0.0000 4 285 2370 6750 1275 Open-loop control\001

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_desc.tex version [4de8b8a9c3].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system MacroMicroPPP (MacroMicroPPP_desc.tex)
% Generated by MTT on Tue Dec 9 17:55:41 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/21 16:10:07  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MacroMicroPPP} is
   displayed in Figure \Ref{MacroMicroPPP_abg} and its label
   file is listed in Section \Ref{sec:MacroMicroPPP_lbl}.
   The subsystems are listed in Section \Ref{sec:MacroMicroPPP_sub}.

This is a Bond Graph model of the macro-micro manipulation system
discussed by Sharon in his thesis and BY Sharon, Hogan and Hardt in
various papers.

It can be regarded as a single-input single-output system with input
$e_1$ and output $e_2$.  The bond graph in Figure \Ref{rcPPP_abg} is
augmented with the {\em open-loop\/} controller comprising
\begin{itemize}
\item seven effort source \textbf{Se} components ``u1'' to``u7''
\item seven effort amplifier \textbf{AE} components ``ppp\_1'' to `ppp\_7''
\end{itemize}
This allows up to 7 input basis functions.

This is a \emph{linear} system; but it is used to illustate
\emph{nonlinear} PPP control. 
Section \Ref{sec:rcPPP_nppp.ps} compares
\begin{itemize}
\item linear open-loop PPP control
\item linear closed-loop PPP control
\item nonlinear PPP control
\end{itemize}
as linear open and closed-loop control.

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_lbl.txt version [1618b01e61].






















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system MacroMicroPPP (MacroMicroPPP_lbl.txt)
%SUMMARY MacroMicroPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/21 16:05:48  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_2
%ALIAS	$3	ppp_3
%ALIAS	$4	ppp_4
%ALIAS	$5	k_2
%ALIAS	$6	k_t
%ALIAS	$7	p_1
%ALIAS	$8	f_t
%ALIAS	$9	m_1
%ALIAS	$10	m_2
%ALIAS	$11	m_3
%ALIAS	$12	b_1
%ALIAS	$13	b_2
%ALIAS	$14	b_3
%ALIAS	$15	b_t
%ALIAS	$16	d_1
%ALIAS	$17	u_1
%ALIAS	$18	u_2
%ALIAS	$19	u_3
%ALIAS	$20	u_4
%ALIAS	$21	v_b

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	ppp_1	lin		ppp_1
	ppp_2	lin		ppp_2
	ppp_3	lin		ppp_3
	ppp_4	lin		ppp_4
	ppp_5	lin		ppp_5
	ppp_6	lin		ppp_6
	ppp_7	lin		ppp_7

% Component type C
	k_2	lin		state,k_2
	k_t	lin		state,k_t
	p_1	lin		state,p_1

% Component type De
	f_t	SS		external

% Component type I
	m_1	lin		flow,m_1
	m_2	lin		flow,m_2
	m_3	lin		flow,m_3

% Component type R
	b_1	lin		flow,b_1
	b_2	lin		flow,b_2
	b_3	lin		flow,b_3
	b_t	lin		flow,b_t
	d_1	lin		flow,d_1

% Component type Se
	u_1	SS		external
	u_2	SS		external
	u_3	SS		external
	u_4	SS		external
	u_5	SS		external
	u_6	SS		external
	u_7	SS		external

% Component type Sf
	v_b	SS		0

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_nppp.m version [cfbc4c4ad7].



























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## MacroMicroPPP_nppp.m
## Makes figures for the MacroMicro_PPP exasmple.
## $Log$
## Revision 1.4  2000/05/21 16:11:53  peterg
## 7 basis funs.
##
## Revision 1.3  2000/05/21 15:59:34  peterg
## Made into _nppp.m file
## Parameterised _sm
##
## Revision 1.2  2000/05/17 17:01:39  peterg
## Modified for Macro Micro example -- works!!
##
## Revision 1.1  2000/05/17 10:03:04  peterg
## Initial revision
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "MacroMicroPPP";

## Uncomment the following the first time
## (Or do ./Make MacroMicroPPP in this directory)

## MTT stuff for the system simulation
##system("Make MacroMicroPPP");



t_s=0.1*[0:0.01:1];
u = [ones(7,length(t_s))];
x_0 = MacroMicroPPP_state;
par  = MacroMicroPPP_numpar;

## Simulate the system
tick=time;
[y] = MacroMicroPPP_sim(x_0,u,t_s,par);
Elapsed = time-tick
plot(t_s,y)

## Simulate the system to give just the final few point
t_s1 = 0.1*[0.91:0.01:1];
tick=time;
[y,x] = MacroMicroPPP_sim(x_0,u,t_s1,par);
Elapsed = time-tick
plot(t_s1,y,t_s1,x);

## Sensitivity system simulation parameters
x_0s = sMacroMicroPPP_state;
pars  = sMacroMicroPPP_numpar;
sympars  = sMacroMicroPPP_sympar;

## Simulate the sensitivity system
sensitivities = \
    [sympars.ppp_1s,\
     sympars.ppp_2s,\
     sympars.ppp_3s,\
     sympars.ppp_4s,\
     sympars.ppp_5s,\
     sympars.ppp_6s,\
     sympars.ppp_7s]
tick=time;
[y,ys] = sMacroMicroPPP_sim(x_0s,u,t_s,pars,sensitivities);
Elapsed = time-tick
plot(t_s,y,t_s,ys);


### PPP parameters
A_w = 0;
A_u = ppp_aug(A_w,laguerre_matrix(6,25)); # Specify basis functions

tau = 0.5*[0.9:0.01:1];         # Optimisation interval
t_ol = 0.5*[0:0.01:0.1];	# Open-loop interval
N = 10;                          # Number of open-loop intervals in simulation
w = 1;                          # Setpoint

## Linear system
[A,B,C,D] = MacroMicroPPP_sm(par);
Q = 1;
w = 1;
ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau,Q,w,x_0);
psfig("MacroMicroPPP_lin");

## Simulate non-linear PPP (on this linear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-8;
extras.max_iterations = 10;
extras.v = 0.1;
extras.verbose = 0;

##  -- with no optimisation using linear PPP with continuation
extras.U_initial = "linear";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 0;

[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with no optimisation using linear PPP at each step
extras.U_initial = "linear";
extras.U_next = "linear";
extras.criterion = 1e-5;
extras.max_iterations = 0;
[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with optimisation using nonlinear PPP with continuation
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations=100;
extras.verbose = 0;
extras.v = 1e-5;
disp("Non-linear optimisation ....");
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);


## Plots
title("");

## U, U_c and U_l
I = 1:N;
IU1 = [I' U(1,:)'];
IU1_c = [I' U_c(1,:)'];
IU1_l = [I' U_l(1,:)'];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("MacroMicroPPP_U1");

IU2 = [I' U(2,:)'];
IU2_c = [I' U_c(2,:)'];
IU2_l = [I' U_l(2,:)'];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("MacroMicroPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
ty = [t' y'] ; tu =  [t' u']; 
gplot ty title "Output", tu title "Input"

psfig("MacroMicroPPP_yu");

title("");
gset grid; xlabel "Time (sec)"
ty_c = [t' y_c'] ; 
ty_l = [t' y_l'] ; 
ty = [t' y'] ; 
tu =  [t' u']; 
gplot ty_c title "Continuation", ty_l title "Linear", ty title "Optimisation"
psfig("MacroMicroPPP_nppp");



Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_numpar.txt version [7601b7d25d].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Dummies
b_1 = 0.0;
b_2 = 0.0;
b_3 = 0.0;
b_t = 0.0;
d_1 = 0.0;
e_s = 0.0;
f_s = 0.0;
k_2 = 0.0;
k_t = 0.0;
m_1 = 0.0;
m_2 = 0.0;
m_3 = 0.0;
p_1 = 0.0;
ppp_1 = 0.0;
ppp_2 = 0.0;
ppp_3 = 0.0;
ppp_4 = 0.0;
ppp_5 = 0.0;
ppp_6 = 0.0;
ppp_7 = 0.0;

m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;


ppp_1 = 1.0;

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_rep.txt version [24152c31ed].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system MacroMicroPPP (MacroMicroPPP_rep.txt)
## Generated by MTT on" Wed May 10 09:22:52 BST 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/05/20 17:44:47  peterg
## Initial revision
##
###############################################################

mtt MacroMicroPPP abg tex		# The system description
#mtt -s sMacroMicroPPP abg tex		# The system description

mtt MacroMicroPPP struc tex	        # The system structure
mtt -s sMacroMicroPPP struc tex	        # The system structure

mtt MacroMicroPPP nppp m		# How its done
mtt MacroMicroPPP nppp ps	        # PPP output

mtt MacroMicroPPP rep txt	        # The report.

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/Make version [e246f48d9d].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Makes the files needed for Figures.m
## Copyright (C) 2000 by Peter J. Gawthrop

if [ -z "$1" ]; then
    echo Usage ./Make system_name
    exit
else
    echo "Making simulation for system $1 (for use in Figures.m)"
fi

## System
mtt -q -c -stdin $1 ode2odes out
mtt -q -c -stdin $1 sim m
mtt -q  $1 state m
mtt -q  $1 sympar m
mtt -q  $1 numpar m

## Sensitivity system
mtt -q -c -stdin -s s$1 ode2odes out
mtt -q -c -stdin -s s$1 sim m
mtt -q  -s s$1 state m
mtt -q  -s s$1 sympar m
mtt -q  -s s$1 numpar m

## Additional system reps for PPP
mtt -q  $1 sm m
mtt -q  $1 def m
mtt -q  -s s$1 def m

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/sMacroMicroPPP_lbl.txt version [510a291607].








































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sMacroMicroPPP (sMacroMicroPPP_lbl.txt)
%SUMMARY sMacroMicroPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_1s
%ALIAS	$3	ppp_2
%ALIAS	$4	ppp_2s
%ALIAS	$5	ppp_3
%ALIAS	$6	ppp_3s
%ALIAS	$7	ppp_4
%ALIAS	$8	ppp_4s
%ALIAS	$9	k_2
%ALIAS	$10	k_2s
%ALIAS	$11	k_t
%ALIAS	$12	k_ts
%ALIAS	$13	p_1
%ALIAS	$14	p_1s
%ALIAS	$15	f_t
%ALIAS	$16	f_ts
%ALIAS	$17	m_1
%ALIAS	$18	m_1s
%ALIAS	$19	m_2
%ALIAS	$20	m_2s
%ALIAS	$21	m_3
%ALIAS	$22	m_3s
%ALIAS	$23	b_1
%ALIAS	$24	b_1s
%ALIAS	$25	b_2
%ALIAS	$26	b_2s
%ALIAS	$27	b_3
%ALIAS	$28	b_3s
%ALIAS	$29	b_t
%ALIAS	$30	b_ts
%ALIAS	$31	d_1
%ALIAS	$32	d_1s
%ALIAS	$33	u_1
%ALIAS	$34	u_1s
%ALIAS	$35	u_2
%ALIAS	$36	u_2s
%ALIAS	$37	u_3
%ALIAS	$38	u_3s
%ALIAS	$39	u_4
%ALIAS	$40	u_4s
%ALIAS	$41	v_b
%ALIAS	$42	v_bs

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	ppp_1	lin		ppp_1;ppp_1s
	ppp_2	lin		ppp_2;ppp_2s
	ppp_3	lin		ppp_3;ppp_3s
	ppp_4	lin		ppp_4;ppp_4s
	ppp_5	lin		ppp_5;ppp_5s
	ppp_6	lin		ppp_6;ppp_6s
	ppp_7	lin		ppp_7;ppp_7s

% Component type C
	k_2	lin		state,k_2;k_2s
	k_t	lin		state,k_t;k_ts
	p_1	lin		state,p_1;p_1s

% Component type De
	f_t	SS		external

% Component type I
	m_1	lin		flow,m_1;m_1s
	m_2	lin		flow,m_2;m_2s
	m_3	lin		flow,m_3;m_3s

% Component type R
	b_1	lin		flow,b_1;b_1s
	b_2	lin		flow,b_2;b_2s
	b_3	lin		flow,b_3;b_3s
	b_t	lin		flow,b_t;b_ts
	d_1	lin		flow,d_1;d_1s

% Component type Se
	u_1	SS		external;u_1s
	u_2	SS		external;u_2s
	u_3	SS		external;u_3s
	u_4	SS		external;u_4s
	u_5	SS		external;u_5s
	u_6	SS		external;u_6s
	u_7	SS		external;u_7s

% Component type Sf
	v_b	SS		0;0

Added mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/sMacroMicroPPP_numpar.txt version [cc73edbaf8].







































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Dummies
b_1 = 0.0;
b_1s = 0.0;
b_2 = 0.0;
b_2s = 0.0;
b_3 = 0.0;
b_3s = 0.0;
b_t = 0.0;
b_ts = 0.0;
c = 0.0;
d_1 = 0.0;
d_1s = 0.0;
e_s = 0.0;
f_s = 0.0;
g = 0.0;
i = 0.0;
k = 0.0;
k_2 = 0.0;
k_2s = 0.0;
k_s = 0.0;
k_t = 0.0;
k_ts = 0.0;
m_1 = 0.0;
m_1s = 0.0;
m_2 = 0.0;
m_2s = 0.0;
m_3 = 0.0;
m_3s = 0.0;
p_1 = 0.0;
p_1s = 0.0;
ppp_1 = 0.0;
ppp_1s = 0.0;
ppp_2 = 0.0;
ppp_2s = 0.0;
ppp_3 = 0.0;
ppp_3s = 0.0;
ppp_4 = 0.0;
ppp_4s = 0.0;
ppp_5 = 0.0;
ppp_5s = 0.0;
ppp_6 = 0.0;
ppp_6s = 0.0;
ppp_7 = 0.0;
ppp_7s = 0.0;
r = 0.0;
u_1s = 0.0;
u_2s = 0.0;
u_3s = 0.0;
u_4s = 0.0;
u_5s = 0.0;
u_6s = 0.0;
u_7s = 0.0;

## Physical parameters
m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;

## First gain
ppp_1 = 1.0;


Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Figures.m version [0d87023b1f].

















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Figures.m
## Makes figures for the rc_PPP exasmple.
## $Log$
## Revision 1.2  2000/05/17 17:02:58  peterg
## Fixed documentation
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "rcPPP";

## Uncomment the following the first time
## (Or do ./Make rcPPP in this directory)

## MTT stuff for the system simulation
##system("Make rcPPP");

# ## System info
par  = rcPPP_numpar;
simpar  = rcPPP_simpar;
x_0 = rcPPP_state(par);

# ## Set up the input
# t = [0:simpar.dt:simpar.last];
# A_w = 0;
# A_u = ppp_aug(A_w,laguerre_matrix(1,2.0)) # Specify basis functions: constant & exp(-t/T)
# u = ppp_ustar(A_u,1,t,0,0);

# ## Simulate the system
# tick=time;
# [y,x] = rcPPP_sim(x_0,par,simpar,u);
# Elapsed = time-tick
# plot(t,y)

## Sensitivity system simulation parameters
simpars  = srcPPP_simpar;
sympars  = srcPPP_sympar;
pars  = srcPPP_numpar;
x_0s = srcPPP_state(pars);

t = [0:simpars.dt:simpars.last];
A_w = 0;
A_u = ppp_aug(A_w,laguerre_matrix(1,2.0)) # Specify basis functions: constant & exp(-t/T)
u = ppp_ustar(A_u,1,t,0,0);


## Setup the indices of the adjustable stuff
i_ppp = [sympars.ppp_1, sympars.ppp_1s
	 sympars.ppp_2, sympars.ppp_2s]; # PPP params
i_par = [sympars.x_0,  sympars.x_0s
	 sympars.r,    sympars.rs]; # State and r component

## Simulate the sensitivity system
sensitivities = [i_ppp(:,2); i_par(:,2)]
u = ppp_ustar(A_u,1,t,0,0); 
tick=time;
[y,ys,x] = srcPPP_ssim(x_0s,pars,simpars,u,sensitivities);
Elapsed = time-tick
plot(t,y,t,ys);

### PPP parameters
tau = [0.9:0.01:1];		# Optimisation interval
t_ol = [0:0.01:0.2];		# Open-loop interval
N = 10;				# Number of open-loop intervals in simulation
w = 1;				# Setpoint
w_s = w*ones(10,1);                  # The setpoint witnin the horizon

## Linear system
n_Tau = round(simpars.last/simpars.dt);
dtau = simpars.dt;
Tau = [0:n_Tau-1]'*dtau;
[n_tau,n_w] = size(w_s);
tau = Tau(n_Tau-n_tau+1:n_Tau)
[A,B,C,D] = rcPPP_sm(par);
Q = 1;
w = 1;
ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau',Q,w);
psfig("rcPPP_lin");

## Simulate non-linear PPP (on this linear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.alpha = 0.1;
extras.verbose = 0;
extras.v = 1e-5;

##  -- with no optimisation using linear PPP with continuation
extras.U_initial = "linear";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 0;
[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras);

##  -- with no optimisation using linear PPP at each step
extras.U_initial = "linear";
extras.U_next = "linear";
extras.criterion = 1e-5;
extras.max_iterations = 0;
[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras);

##  -- with optimisation using nonlinear PPP with continuation
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 100;
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras);


## Plots
title("");

## U, U_c and U_l
I = [1:N]';
IU1 = [I U(:,1)];
IU1_c = [I U_c(:,1)];
IU1_l = [I U_l(:,1)];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("rcPPP_U1");

IU2 = [I U(:,2)];
IU2_c = [I U_c(:,2)];
IU2_l = [I U_l(:,2)];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("rcPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
ty = [t y] ; tu =  [t u]; 
gplot ty title "Output", tu title "Input"

psfig("rcPPP_yu");

gset grid; xlabel "Time (sec)"
ty_c = [t y_c] ; 
ty_l = [t y_l] ; 
ty = [t y] ; 
tu =  [t u]; 
gplot ty_c title "Continuation", ty_l title "Linear", ty title "Optimisation"
psfig("rcPPP_ylco");
 

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Make version [37eadad62c].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh

## Makes the files needed for Figures.m
## Copyright (C) 2000 by Peter J. Gawthrop

sys=$1

if [ -z "$2" ]; then
    code=oct
else
    code=$2
fi

if [ -z "$1" ]; then
    echo 'Usage ./Make system_name [m|oct]'
    exit
else
    echo "Making sensitivity simulation for system ${sys} (code ${code})"
fi

if [ "${code}" == "oct" ]; then
    oct='-oct'
fi

echo Switches ${oct}

## System
mtt -q ${sys} sympar m
mtt -q ${sys} simpar m
mtt -q ${sys} numpar m
mtt -q ${sys} state m


## Sensitivity system
mtt -q -stdin -s s${sys} ssim m
mtt -q -stdin -s s${sys} sympar m
mtt -q -stdin -s s${sys} simpar m
mtt -q -stdin ${oct} -s s${sys} input ${code}
mtt -q -stdin ${oct} -s s${sys} ode2odes ${code}
mtt -q -stdin ${oct} -s s${sys} state ${code}
mtt -q -stdin ${oct} -s s${sys} numpar ${code}

## Additional system reps for PPP
mtt -q -stdin  ${sys} sm m
mtt -q -stdin  ${sys} def m
mtt -q -stdin  -s s${sys} def m

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_abg.fig version [34f1b0eb45].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 3600 1125 162 162 3600 1125 3690 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4952 4277 5852 4277 5627 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6302 4277 7202 4277 6977 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 4051 4726 3151 4951 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 4051 6076 3151 6301 3376
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 4275 585 5175 585 5175 765 4275 765 4275 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5850 1215 6300 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5850 1080 6300 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 675 4275 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5175 675 7200 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6075 675 6075 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6075 1215 6075 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 1575 7200 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 945 3600 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 1575 3600 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 7200 1530 7200 765
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3866 3414 4502 4050 4184 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3870 5130 4505 4494 4505 4812
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 3375 2702 3375 2477 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 5175 2702 5175 2477 5400
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 5625 8550 225 900 225 900 5625 8550 5625
4 1 -1 0 0 0 20 0.0000 4 210 150 4727 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 6077 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 285 540 7787 4367 De:y\001
4 1 -1 0 0 0 20 0.0000 4 210 375 4726 2926 R:r\001
4 1 -1 0 0 0 20 0.0000 4 210 555 6076 2926 CS:c\001
4 0 1 1 0 0 20 0.0000 4 150 120 4680 450 r\001
4 0 1 1 0 0 20 0.0000 4 150 135 6480 1215 c\001
4 0 1 1 0 0 20 0.0000 4 150 135 7425 1170 e\001
4 0 1 1 0 0 20 0.0000 4 210 150 7515 1305 2\001
4 0 1 1 0 0 20 0.0000 4 150 135 3060 1170 e\001
4 0 1 1 0 0 20 0.0000 4 210 150 3150 1305 1\001
4 1 1 1 0 0 20 0.0000 4 285 1425 5400 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 210 1275 5400 2025 Schematic\001
4 1 -1 0 0 0 20 0.0000 4 285 930 3285 5265 AE:ppp_2\001
4 1 -1 0 0 0 20 0.0000 4 285 930 3285 3465 AE:ppp_1\001
4 1 -1 0 0 0 20 0.0000 4 210 660 1440 3465 Se:u1\001
4 1 -1 0 0 0 20 0.0000 4 210 660 1440 5265 Se:u2\001

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_desc.tex version [89911249a1].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system rcPPP (rcPPP_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{rcPPP} is
displayed in Figure \Ref{rcPPP_abg} and its label
file is listed in Section \Ref{sec:rcPPP_lbl}.
The subsystems are listed in Section \Ref{sec:rcPPP_sub}.
The system \textbf{rcPPP} is based on the simple electrical rc circuit shown in
Figure \Ref{rcPPP_abg}. 

It can be regarded as a single-input
single-output system with input $e_1$ and output $e_2$.
The bond graph in Figure \Ref{rcPPP_abg} is augmented with the {\em
open-loop\/} controller comprising
\begin{itemize}
\item two effort source \textbf{Se} components ``u1'' and ``u2''
\item two effort amplifier \textbf{AE} components ``ppp\_1'' and `ppp\_2''
\end{itemize}

This is a \emph{linear} system; but it is used to illustate
\emph{nonlinear} PPP control. Not surprisingly, the \emph{nonlinear}
PPP control gives nearly the same result (Section \Ref{sec:rcPPP_nppp.ps})
as linear open and closed-loop control.





Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_lbl.txt version [3a358dce4f].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system rcPPP (rcPPP_lbl.txt)
%SUMMARY rcPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_2
%ALIAS	$3	c
%ALIAS	$4	y
%ALIAS	$5	r
%ALIAS	$6	u1
%ALIAS	$7	u2

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	ppp_1	lin		ppp_1
	ppp_2	lin		ppp_2

% Component type CS
	c	lin	        effort,c;q_0		

% Component type De
	y	SS		external

% Component type R
	r	lin		flow,r

% Component type Se
	u1	SS		external
	u2	SS		external

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_nppp.m version [df8a9ed25f].



















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Figures.m
## Makes figures for the rc_PPP exasmple.
## $Log$
## Revision 1.3  2000/08/12 10:39:33  peterg
## Levenberg-Marquardt version
##
## Revision 1.2  2000/05/21 06:39:23  peterg
## Parameterised _sm
##
## Revision 1.1  2000/05/19 13:15:38  peterg
## Initial revision
##
## Revision 1.2  2000/05/17 17:02:58  peterg
## Fixed documentation
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "rcPPP";

## Uncomment the following the first time
## (Or do ./Make rcPPP in this directory)

## MTT stuff for the system simulation
##system("Make rcPPP");



t_s=[0:0.1:10];
u = [ones(1,length(t_s));ones(1,length(t_s))];
x_0 = rcPPP_state;
par  = rcPPP_numpar;

## Simulate the system
tick=time;
[y,x] = rcPPP_sim(x_0,u,t_s,par);
Elapsed = time-tick
plot(t_s,y,t_s,x);

## Simulate the system to give just the final few point
t_s1 = [9:0.1:10];
tick=time;
[y,x] = rcPPP_sim(x_0,u,t_s1,par);
Elapsed = time-tick
plot(t_s1,y,t_s1,x);

## Sensitivity system simulation parameters
x_0s = srcPPP_state;
pars  = srcPPP_numpar
sympars  = srcPPP_sympar;

## Simulate the sensitivity system
sensitivities = [sympars.ppp_1s,sympars.ppp_2s,sympars.rs]
tick=time;
[y,ys] = srcPPP_sim(x_0s,u,t_s,[sympars.r,2.0],sensitivities);
Elapsed = time-tick
plot(t_s,y,t_s,ys);

### PPP parameters
A_w = 0;
A_u = ppp_aug(A_w,laguerre_matrix(1,10)); # Specify basis functions: constant & exp(-5t)
tau = [0.9:0.01:1];		# Optimisation interval
t_ol = [0:0.01:0.2];		# Open-loop interval
N = 5;				# Number of open-loop intervals in simulation
w = 1;				# Setpoint

## Linear system
[A,B,C,D] = rcPPP_sm(par);
Q = 1;
w = 1;
ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau,Q,w,x_0);
psfig("rcPPP_lin");

## Simulate non-linear PPP (on this linear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.v = 0;
extras.verbose = 0;

##  -- with no optimisation using linear PPP with continuation
disp("Linear PPP at time zero with continuation trajectories")
extras.U_initial = "linear";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.v = 0;
extras.max_iterations = 0;
[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with no optimisation using linear PPP at each step
disp("Linear PPP at each step")
extras.U_initial = "linear";
extras.U_next = "linear";
extras.criterion = 1e-5;
extras.max_iterations = 0;
extras.v = 0;
[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with optimisation using nonlinear PPP with continuation
disp("Nonlinear PPP");
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.v = 1e-5;
extras.criterion = 1e-5;
extras.max_iterations = 100;
extras.verbose = 0;
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);


## Plots
title("");

## U, U_c and U_l
I = 1:N;
IU1 = [I' U(1,:)'];
IU1_c = [I' U_c(1,:)'];
IU1_l = [I' U_l(1,:)'];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("rcPPP_U1");

IU2 = [I' U(2,:)'];
IU2_c = [I' U_c(2,:)'];
IU2_l = [I' U_l(2,:)'];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("rcPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
ty = [t' y'] ; tu =  [t' u']; 
gplot ty title "Output", tu title "Input"

psfig("rcPPP_yu");

title("");
gset grid; xlabel "Time (sec)"
ty_c = [t' y_c'] ; 
ty_l = [t' y_l'] ; 
ty = [t' y'] ; 
tu =  [t' u']; 
gplot ty_c title "Continuation", ty_l title "Linear", ty title "Optimisation"
psfig("rcPPP_nppp");
 

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_numpar.txt version [e921254017].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (rcPPP_numpar.txt)
# Generated by MTT at Tue Apr 18 18:53:40 BST 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:31:27  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c = 	1.0; # CS,rcPPP
## Removed by MTT on Sat May 26 07:46:29 BST 2001: e_0 = 	1.0; # CS
## Removed by MTT on Sat May 26 07:46:29 BST 2001: e_s = 	1.0; # Se

ppp_1 = 	1.0; # rcPPP
ppp_2 = 	0.0; # rcPPP

## Physical parameters
c =     1.0;
q_0 =   0.0;
r =     1.0;

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_rep.txt version [11b8899772].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system rcPPP (rcPPP_rep.txt)
## Generated by MTT on" Wed May 10 09:22:52 BST 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/05/20 17:44:47  peterg
## Initial revision
##
###############################################################

mtt rcPPP abg tex		# The system description
#mtt -s srcPPP abg tex		# The system description

mtt rcPPP struc tex	        # The system structure
mtt -s srcPPP struc tex	        # The system structure

mtt rcPPP nppp m		# How its done
mtt rcPPP nppp ps	        # PPP output

mtt rcPPP rep txt	        # PPP output

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_input.txt version [10068bd604].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (srcPPP_input.txt)
# Generated by MTT at Fri Apr 14 17:44:36 BST 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
mttu(1) = 1.0; 	# u (srcPPP_u1_se_1)
mttu(2) = 0.0;#exp(-mttt); 	# u (srcPPP_u2_se_1)

# Set the switches

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_lbl.txt version [bea2eabf2a].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system srcPPP (srcPPP_lbl.txt)
%SUMMARY srcPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:31:27  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_1s
%ALIAS	$3	ppp_2
%ALIAS	$4	ppp_2s
%ALIAS	$5	c
%ALIAS	$6	cs
%ALIAS	$7	y
%ALIAS	$8	ys
%ALIAS	$9	r
%ALIAS	$10	rs
%ALIAS	$11	u1
%ALIAS	$12	u1s
%ALIAS	$13	u2
%ALIAS	$14	u2s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type Ae
	ppp_1	slin		ppp_1;ppp_1s
	ppp_2	slin		ppp_2;ppp_2s

% Component type CS
	c	slin		effort,c;x_0;cs;x_0s

% Component type De
	y	SS		external

% Component type R
	r	slin		flow,r;rs

% Component type Se
	u1	SS		external;0
	u2	SS		external;0


Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_numpar.txt version [00ff26769b].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System srcPPP, representation numpar, language txt; 
## File srcPPP_numpar.txt; 
## Generated by MTT on Sat May 26 08:47:19 BST 2001; 


## Parameters
c	= 1.0;
r	= 1.0;

## PPP coefficients
ppp_1	= 0.0; # Default
ppp_2	= 1.0; # Default

## State
x_0	= 0.0; # Default

## Sensitivities
cs	= 0.0; # Default
ppp_1s	= 0.0; # Default
ppp_2s	= 0.0; # Default
rs	= 0.0; # Default
x_0s	= 0.0; # Default

Added mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_simpar.txt version [370b8dff18].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system srcPPP (srcPPP_simpar.txt)
# Generated by MTT on Fri Apr 14 17:43:36 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:31:27  peterg
## To RCS
##
###############################################################


FIRST        = 0.0;       # Last time in simulation
LAST        = 2.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_abg.fig version [b1632d46ab].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2700 2835 4050 3060 3825
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 4725 4500 4725 450 225 450 225 4500 4725 4500
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 4365 R:b\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 765 I:m\001

Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_desc.tex version [f6267dbda0].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Cruise (Cruise_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cruise} is
   displayed in Figure \Ref{Cruise_abg} and its label
   file is listed in Section \Ref{sec:Cruise_lbl}.
   The subsystems are listed in Section \Ref{sec:Cruise_sub}.


This is a simple teaching example to illustrare compensator design via
observer/state-feedback methods.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_lbl.txt version [c6eb913146].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Cruise: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system Cruise (Cruise_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/20 16:26:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m		lin	flow,m

% Component type R
	b		lin	flow,b

% Component type SS
	u		SS	external,external

Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_numpar.txt version [52092fa333].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Cruise_numpar.txt)
# Generated by MTT at Mon Jan 12 15:43:19 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # Parameter b for Cruise
b_m = 	1.0; # Parameter b_m for Cruise
j = 	1.0; # Parameter j for Cruise
j_m = 	1.0; # Parameter j_m for Cruise
k = 	1.0; # Parameter k for Cruise
k_m = 	1.0; # Parameter k_m for Cruise
l = 	1.0; # Parameter l for Cruise
l_a = 	1.0; # Parameter l_a for Cruise
l_m = 	1.0; # Parameter l_m for Cruise
r = 	1.0; # Parameter r for Cruise
r_a = 	1.0; # Parameter r_a for Cruise
r_m = 	1.0; # Parameter r_m for Cruise

# Initial states
x(1) = 	0.0; # Initial state for Cruise_motor (l_a)
x(2) = 	0.0; # Initial state for Cruise_motor (j_m)

Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_params.r version [27872281d7].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
%% Parameter file for system Cruise (Cruise_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_rep.txt version [58f8bc4e60].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Cruise (Cruise_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Cruise abg tex

mtt -o Cruise sm tex
mtt -o Cruise tf tex

mtt -o Cruise smc tex
mtt -o Cruise ssk tex

mtt -o Cruise smo tex
mtt -o Cruise ssl tex

mtt -o Cruise ctf tex



Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_simp.r version [8ae10835d9].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system Cruise (Cruise_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% System
%J_m := 1; L_m := 0.1; k_m := 1; b_m := 0.1; r_m := 1;

% Controller - poles at -2 and -10
%alpha_c1 := 12; alpha_c2 := 20;

% Observer -  poles at -10 -50
%alpha_o1 := 60; alpha_o2 := 500;

END;

Added mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_sspar.r version [08e36df648].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for Cruise (Cruise_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_abg.fig version [d7820cb52a].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2700 2835 4050 3060 3825
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4500 2475 4275 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 6750 2475 6525 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 450 225 450 225 4455 7650 4455
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 4365 R:b\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 765 I:m\001
4 0 -1 0 0 0 20 0.0000000 4 270 570 6930 2565 SS:y\001
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 1 -1 0 0 0 20 0.0000000 4 210 1080 4950 2565 INTF:int\001

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_desc.tex version [6888f94b02].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system CruiseP (CruiseP_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods.

The system represents a simple model of a vehicle moving along a road.
The vehicle
\begin{itemize}
\item has mass $m$
\item is driven by a force $u=F$
\item has velocity $v$ 
\item has momentum $p=mv$ 
\item has a distance along the road $y=d$
\item The system states are taken to be:
  \begin{equation}
    x = 
    \begin{pmatrix}
      p \\ d
    \end{pmatrix}
  \end{equation}\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_lbl.txt version [78c0dfb69d].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CruiseP: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system CruiseP (CruiseP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m		lin	flow,m

% Component type INTF
	int		lin	flow,int

% Component type R
	b		lin	flow,b

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_numpar.txt version [8f4fd9371e].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (CruiseP_numpar.txt)
# Generated by MTT at Fri Feb 13 17:15:12 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # CruiseP
int = 	1.0; # CruiseP
m = 	1.0; # CruiseP

# Initial states
x(1) = 	0.0; # CruiseP (m)
x(2) = 	0.0; # CruiseP_int (3)

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_pic.fig version [7cbcc3e0e1].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Inches
1200 2
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 3900 3900 309 309 3900 3900 4209 4209
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 2700 3900 309 309 2700 3900 3009 4209
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 2400 2400 4200 2400 4200 3600 2400 3600 2400 2400
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 4500 2700 5700 2700
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 1200 3000 2400 3000
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 3900 1800 2700 1800
4 0 -1 0 0 3 20 0.0000000 4 270 1380 5700 2400 v (velocity)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1095 525 2700 u (force)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1425 5700 3150 y (position)\001
4 0 -1 0 0 3 20 0.0000000 4 255 1155 2700 3075 m (mass)\001
4 0 -1 0 0 3 20 0.0000000 4 270 2235 3150 1575 bv (friction force)\001
4 0 -1 0 0 3 16 0.0000000 4 195 2490 2325 5100 states:  p=momentum=mv\001
4 0 -1 0 0 3 16 0.0000000 4 210 1725 2325 5442             y=position\001

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_pic.tex version [e76f40dd94].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
\makebox[5.541in][l]{
  \vbox to 3.458in{
    \vfill
    \special{psfile=CruiseP_pic.ps}
  }
  \vspace{-\baselineskip}
}

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_rep.tex version [863e452b9f].













































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


\section{\textbf{CruiseP}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:CruiseP_abg.tex}
\index{\textbf{CruiseP} -- abg}


MTT command:
\begin{verbatim}
mtt CruiseP abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_abg.tex}


\section{\textbf{CruiseP}: representation \textbf{ode}, language \textbf{tex}}
\label{sec:CruiseP_ode.tex}
\index{\textbf{CruiseP} -- ode}


MTT command:
\begin{verbatim}
mtt -o CruiseP ode tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ode.tex}


\section{\textbf{CruiseP}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:CruiseP_sm.tex}
\index{\textbf{CruiseP} -- sm}


MTT command:
\begin{verbatim}
mtt -o CruiseP sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_sm.tex}


\section{\textbf{CruiseP}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:CruiseP_tf.tex}
\index{\textbf{CruiseP} -- tf}


MTT command:
\begin{verbatim}
mtt -o CruiseP tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_tf.tex}


\section{\textbf{CruiseP}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:CruiseP_smc.tex}
\index{\textbf{CruiseP} -- smc}


MTT command:
\begin{verbatim}
mtt -o CruiseP smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_smc.tex}


\section{\textbf{CruiseP}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:CruiseP_ssk.tex}
\index{\textbf{CruiseP} -- ssk}


MTT command:
\begin{verbatim}
mtt -o CruiseP ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ssk.tex}


\section{\textbf{CruiseP}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:CruiseP_smo.tex}
\index{\textbf{CruiseP} -- smo}


MTT command:
\begin{verbatim}
mtt -o CruiseP smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_smo.tex}


\section{\textbf{CruiseP}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:CruiseP_ssl.tex}
\index{\textbf{CruiseP} -- ssl}


MTT command:
\begin{verbatim}
mtt -o CruiseP ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ssl.tex}


\section{\textbf{CruiseP}: representation \textbf{ctf}, language \textbf{tex}}
\label{sec:CruiseP_ctf.tex}
\index{\textbf{CruiseP} -- ctf}


MTT command:
\begin{verbatim}
mtt -o CruiseP ctf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ctf.tex}

Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_rep.txt version [5d5e21401e].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system CruiseP (CruiseP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt CruiseP abg tex

mtt -o CruiseP ode tex
mtt -o CruiseP sm tex
mtt -o CruiseP tf tex

mtt -o CruiseP smc tex
mtt -o CruiseP ssk tex

mtt -o CruiseP smo tex
mtt -o CruiseP ssl tex

mtt -o CruiseP ctf tex


Added mtt/lib/examples/Control/SimpleStateSpace/CruiseP/Makefile version [02aec829a2].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#
# TransFig makefile
#

all: CruiseP_pic.tex 

# translation into ps

CruiseP_pic.tex: CruiseP_pic.ps Makefile
	fig2ps2tex CruiseP_pic.ps >CruiseP_pic.tex
clean::
	rm -f CruiseP_pic.tex

CruiseP_pic.ps: CruiseP_pic.fig Makefile
	fig2dev -L ps CruiseP_pic.fig > CruiseP_pic.ps
clean::
	rm -f CruiseP_pic.ps

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_abg.fig version [d7820cb52a].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2700 2835 4050 3060 3825
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4500 2475 4275 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 6750 2475 6525 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 450 225 450 225 4455 7650 4455
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 4365 R:b\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 765 I:m\001
4 0 -1 0 0 0 20 0.0000000 4 270 570 6930 2565 SS:y\001
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 1 -1 0 0 0 20 0.0000000 4 210 1080 4950 2565 INTF:int\001

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_desc.tex version [820fce3156].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system CruisePN (CruisePN_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods. The equations are presented in
numerical (as opposed to symbolic) form.

The system represents a simple model of a vehicle moving along a road.
The vehicle
\begin{itemize}
\item has mass $m$
\item is driven by a force $u=F$
\item has velocity $v$ 
\item has momentum $p=mv$ 
\item has a distance along the road $y=d$
\item The system states are taken to be:
  \begin{equation}
    x = 
    \begin{pmatrix}
      p \\ d
    \end{pmatrix}
  \end{equation}\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_lbl.txt version [59330369ec].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY CruisePN: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system CruisePN (CruisePN_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m		lin	flow,m

% Component type INTF
	int		lin	flow,int

% Component type R
	b		lin	flow,b

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_numpar.txt version [b93d73c639].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (CruisePN_numpar.txt)
# Generated by MTT at Fri Feb 13 17:15:12 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # CruisePN
int = 	1.0; # CruisePN
m = 	1.0; # CruisePN

# Initial states
x(1) = 	0.0; # CruisePN (m)
x(2) = 	0.0; # CruisePN_int (3)

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_pic.fig version [7cbcc3e0e1].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Inches
1200 2
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 3900 3900 309 309 3900 3900 4209 4209
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 2700 3900 309 309 2700 3900 3009 4209
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 2400 2400 4200 2400 4200 3600 2400 3600 2400 2400
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 4500 2700 5700 2700
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 1200 3000 2400 3000
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 3900 1800 2700 1800
4 0 -1 0 0 3 20 0.0000000 4 270 1380 5700 2400 v (velocity)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1095 525 2700 u (force)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1425 5700 3150 y (position)\001
4 0 -1 0 0 3 20 0.0000000 4 255 1155 2700 3075 m (mass)\001
4 0 -1 0 0 3 20 0.0000000 4 270 2235 3150 1575 bv (friction force)\001
4 0 -1 0 0 3 16 0.0000000 4 195 2490 2325 5100 states:  p=momentum=mv\001
4 0 -1 0 0 3 16 0.0000000 4 210 1725 2325 5442             y=position\001

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_pic.tex version [c999a1fdcd].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
\makebox[5.541in][l]{
  \vbox to 3.458in{
    \vfill
    \special{psfile=CruisePN_pic.ps}
  }
  \vspace{-\baselineskip}
}

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_rep.tex version [dd5b960981].













































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


\section{\textbf{CruisePN}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:CruisePN_abg.tex}
\index{\textbf{CruisePN} -- abg}


MTT command:
\begin{verbatim}
mtt CruisePN abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_abg.tex}


\section{\textbf{CruisePN}: representation \textbf{ode}, language \textbf{tex}}
\label{sec:CruisePN_ode.tex}
\index{\textbf{CruisePN} -- ode}


MTT command:
\begin{verbatim}
mtt -o CruisePN ode tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ode.tex}


\section{\textbf{CruisePN}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:CruisePN_sm.tex}
\index{\textbf{CruisePN} -- sm}


MTT command:
\begin{verbatim}
mtt -o CruisePN sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_sm.tex}


\section{\textbf{CruisePN}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:CruisePN_tf.tex}
\index{\textbf{CruisePN} -- tf}


MTT command:
\begin{verbatim}
mtt -o CruisePN tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_tf.tex}


\section{\textbf{CruisePN}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:CruisePN_smc.tex}
\index{\textbf{CruisePN} -- smc}


MTT command:
\begin{verbatim}
mtt -o CruisePN smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_smc.tex}


\section{\textbf{CruisePN}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:CruisePN_ssk.tex}
\index{\textbf{CruisePN} -- ssk}


MTT command:
\begin{verbatim}
mtt -o CruisePN ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ssk.tex}


\section{\textbf{CruisePN}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:CruisePN_smo.tex}
\index{\textbf{CruisePN} -- smo}


MTT command:
\begin{verbatim}
mtt -o CruisePN smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_smo.tex}


\section{\textbf{CruisePN}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:CruisePN_ssl.tex}
\index{\textbf{CruisePN} -- ssl}


MTT command:
\begin{verbatim}
mtt -o CruisePN ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ssl.tex}


\section{\textbf{CruisePN}: representation \textbf{ctf}, language \textbf{tex}}
\label{sec:CruisePN_ctf.tex}
\index{\textbf{CruisePN} -- ctf}


MTT command:
\begin{verbatim}
mtt -o CruisePN ctf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ctf.tex}

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_rep.txt version [d9e7301ff2].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system CruisePN (CruisePN_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt CruisePN abg tex

mtt -o CruisePN ode tex
mtt -o CruisePN sm tex
mtt -o CruisePN tf tex

mtt -o CruisePN smc tex
mtt -o CruisePN ssk tex

mtt -o CruisePN smo tex
mtt -o CruisePN ssl tex

mtt -o CruisePN ctf tex


Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_simp.r version [87a70b56bc].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system CruisePN (CruisePN_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


m  := 1;
b := 0;

alpha_o1 := 4;
alpha_o2 := 4;

alpha_c1 := 2;
alpha_c2 := 1;

END;

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_sspar.r version [269881705f].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for CruisePN (CruisePN_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruiseP_pic.tex version [e76f40dd94].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
\makebox[5.541in][l]{
  \vbox to 3.458in{
    \vfill
    \special{psfile=CruiseP_pic.ps}
  }
  \vspace{-\baselineskip}
}

Added mtt/lib/examples/Control/SimpleStateSpace/CruisePN/Makefile version [c3cd8e3dfa].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#
# TransFig makefile
#

all: CruisePN_pic.tex 

# translation into ps

CruisePN_pic.tex: CruisePN_pic.ps Makefile
	fig2ps2tex CruisePN_pic.ps >CruisePN_pic.tex
clean::
	rm -f CruisePN_pic.tex

CruisePN_pic.ps: CruisePN_pic.fig Makefile
	fig2dev -L ps CruisePN_pic.fig > CruisePN_pic.ps
clean::
	rm -f CruisePN_pic.ps

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DC_abg.fig version [3daa31e601].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4050 4500 4050 225 1800 225 1800 4500 4050 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 2475 2745 2475 2475 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 2250 2925 1080 3150 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3105 2475 4275 2475 4005 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 2700 2925 3870 3150 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 2475 6795 2475 6525 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 2295 6975 1125 7200 1395
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 2700 6975 3870 7200 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 2475 8370 2475 8100 2700
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8100 4500 8100 225 5850 225 5850 4500 8100 4500
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 4950 225 4950 225 45 9450 45 9450 4950
4 1 -1 0 0 0 20 0.0000 4 195 135 2880 2610 1\001
4 1 -1 0 0 0 20 0.0000 4 255 990 4995 2565 GY:k_m\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6975 2565 1\001
4 1 4 0 0 0 20 0.0000 4 240 810 1080 2565 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 510 2880 990 I:l_a\001
4 1 -1 0 0 0 20 0.0000 4 255 600 7065 990 I:j_m\001
4 1 -1 0 0 0 20 0.0000 4 255 645 2970 4230 R:r_a\001
4 1 -1 0 0 0 20 0.0000 4 255 765 7020 4230 R:b_m\001
4 1 1 1 0 0 20 0.0000 4 195 1095 2925 4815 Electrical\001
4 1 1 1 0 0 20 0.0000 4 195 1335 6975 4815 Mechanical\001
4 1 1 1 0 0 20 0.0000 4 195 630 8910 2925 Shaft\001
4 1 1 1 0 0 20 0.0000 4 195 1170 1080 2925 Terminals\001
4 1 4 0 0 0 20 0.0000 4 240 960 8910 2565 SS:[out]\001

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DC_desc.tex version [77c4d38d75].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system DC (DC_desc.tex)
% Generated by MTT on Thu Sep 11 10:09:58 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{DC} is
   displayed in Figure \Ref{DC_abg} and its label
   file is listed in Section \Ref{sec:DC_lbl}.
   The subsystems are listed in Section \Ref{sec:DC_sub}.

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|}
        \hline
        Index & Parameter\\
        \hline
         1 & Motor gain ($k_m$) \\
         2 & Armature inductance ($l_a$) \\
         3 & Armature resistance ($r_a$) \\
         4 & Inertia ($j_m$) \\
         5 & Friction coefficient ($b_m$) \\
        \hline
       \end{tabular}
       \caption{DC motor parameters}
       \label{tab:DC_components}
     \end{center}
   \end{table}
{\bf DC} is a two-port component representing a DC motor. It has the 5
parameters listed in Table \Ref{tab:DC_components}.


Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DC_lbl.txt version [bd004f0f0a].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY DC: DC motor (or generator)
%DESCRIPTION Port [in]: Electrical (in)
%DESCRIPTION Port [out]: Mechanical (out)
%DESCRIPTION Parameter 1: Motor gain (k_m)
%DESCRIPTION Parameter 2: Armature inductance (l_a)
%DESCRIPTION Parameter 3: Armature resistance (r_a)
%DESCRIPTION Parameter 4: Inertia (j_m)
%DESCRIPTION Parameter 5: Friction coefficient (b_m)


%% Label file for system DC (DC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/04  16:01:42  peterg
% %% Documantation added.
% %%
% %% Revision 1.1  1996/12/04  16:00:56  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin	flow,$1

% Electrical components
%Inductance
l_a	lin	effort,$2
%Resistance
r_a	lin	flow,$3

% Mechanical components
%Inertia
j_m	lin	flow,$4
%Friction
b_m	lin	flow,$5

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_abg.fig version [d436a5df4d].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2475 5175 2475 4950 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 3150 6075 1800 225 1800 225 3150 6075 3150
4 1 -1 0 0 0 20 0.0000000 4 210 1230 3195 2565 DC:motor\001
4 0 -1 0 0 0 20 0.0000000 4 210 570 5310 2565 SS:v\001
4 2 -1 0 0 0 20 0.0000000 4 210 555 1035 2565 SS:e\001

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_args.new version [5936bc7523].


1
+
 

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_desc.tex version [9905aeccc5].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system DCexample (DCexample_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods.

The system represents a simple model of a DC motor including armature
resistance $r_m$, armature inductance $l_m$, motor constant $k_m$,
inertia $j_m$ and friction $b_m$.

The DC motor has
\begin{itemize}
\item output angular velocity $y = \omega$
\item input voltage $u = v$
\item $\lambda = Li$ where $i$ is the armature current
\item angular momentum $p=j_m \omega$.
\item system states given by
  \begin{equation}
    x = 
    \begin{pmatrix}
      \lambda \\ \omega
    \end{pmatrix}
  \end{equation}
\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_lbl.txt version [ee4ead091c].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY DCexample: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system DCexample (DCexample_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type DC
	motor		lin	k_m;l_m;r_m;j_m;b_m

% Component type SS
	e		SS	external,internal
	v		SS	0,external

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_numpar.txt version [515bf1c141].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (DCexample_numpar.txt)
# Generated by MTT at Mon Jan 12 15:43:19 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # Parameter b for DCexample
b_m = 	1.0; # Parameter b_m for DCexample
j = 	1.0; # Parameter j for DCexample
j_m = 	1.0; # Parameter j_m for DCexample
k = 	1.0; # Parameter k for DCexample
k_m = 	1.0; # Parameter k_m for DCexample
l = 	1.0; # Parameter l for DCexample
l_a = 	1.0; # Parameter l_a for DCexample
l_m = 	1.0; # Parameter l_m for DCexample
r = 	1.0; # Parameter r for DCexample
r_a = 	1.0; # Parameter r_a for DCexample
r_m = 	1.0; # Parameter r_m for DCexample

# Initial states
x(1) = 	0.0; # Initial state for DCexample_motor (l_a)
x(2) = 	0.0; # Initial state for DCexample_motor (j_m)

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_params.r version [336c7256e5].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
%% Parameter file for system DCexample (DCexample_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_pic.fig version [6593ec6ec8].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Inches
1200 2
6 3900 1725 7575 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 4801 1801 5701 1801
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 5701 1726 6601 1726 6601 1876 5701 1876 5701 1726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 6601 1801 7501 1801 7501 2401
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 3901 1726 4801 1726 4801 1876 3901 1876 3901 1726
-6
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 7500 2700 270 270 7500 2700 7650 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 3000 1800 3900 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 7500 3000 7500 3600 3000 3600
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 7950 2625 10800 2625 10800 2775 7950 2775 7950 2625
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 10800 1200 11400 1200 11400 4200 10800 4200 10800 1200
4 0 -1 0 0 3 20 0.0000000 4 150 135 3000 2775 v\001
4 0 -1 0 0 3 20 0.0000000 4 210 90 3300 1650 i\001
4 2 -1 0 0 3 20 0.0000000 4 255 540 6675 2775 k_m\001
4 2 -1 0 0 32 20 0.0000000 4 135 210 6975 2775 w\001

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_pic.tex version [274fd15af3].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
\makebox[7.055in][l]{
  \vbox to 2.555in{
    \vfill
    \special{psfile=DCexample_pic.ps}
  }
  \vspace{-\baselineskip}
}

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_rep.tex version [03d36bd17b].





















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


\section{\textbf{DCexample}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:DCexample_abg.tex}
\index{\textbf{DCexample} -- abg}


MTT command:
\begin{verbatim}
mtt DCexample abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_abg.tex}


\section{\textbf{DCexample}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:DCexample_sm.tex}
\index{\textbf{DCexample} -- sm}


MTT command:
\begin{verbatim}
mtt -o DCexample sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_sm.tex}


\section{\textbf{DCexample}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:DCexample_tf.tex}
\index{\textbf{DCexample} -- tf}


MTT command:
\begin{verbatim}
mtt -o DCexample tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_tf.tex}


\section{\textbf{DCexample}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:DCexample_smc.tex}
\index{\textbf{DCexample} -- smc}


MTT command:
\begin{verbatim}
mtt -o DCexample smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_smc.tex}


\section{\textbf{DCexample}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:DCexample_ssk.tex}
\index{\textbf{DCexample} -- ssk}


MTT command:
\begin{verbatim}
mtt -o DCexample ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_ssk.tex}


\section{\textbf{DCexample}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:DCexample_smo.tex}
\index{\textbf{DCexample} -- smo}


MTT command:
\begin{verbatim}
mtt -o DCexample smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_smo.tex}


\section{\textbf{DCexample}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:DCexample_ssl.tex}
\index{\textbf{DCexample} -- ssl}


MTT command:
\begin{verbatim}
mtt -o DCexample ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_ssl.tex}

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_rep.txt version [9e1428c8ee].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system DCexample (DCexample_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt DCexample abg tex

mtt -o DCexample sm tex
mtt -o DCexample tf tex

mtt -o DCexample smc tex
mtt -o DCexample ssk tex

mtt -o DCexample smo tex
mtt -o DCexample ssl tex


Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_simp.r version [f380d89b00].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system DCexample (DCexample_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% System
%J_m := 1; L_m := 0.1; k_m := 1; b_m := 0.1; r_m := 1;

% Controller - poles at -2 and -10
%alpha_c1 := 12; alpha_c2 := 20;

% Observer -  poles at -10 -50
%alpha_o1 := 60; alpha_o2 := 500;

END;

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_sspar.r version [559cfc0faa].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for DCexample (DCexample_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Control/SimpleStateSpace/DCexample/Makefile version [902affeab5].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#
# TransFig makefile
#

all: DCexample_pic.tex 

# translation into ps

DCexample_pic.tex: DCexample_pic.ps Makefile
	fig2ps2tex DCexample_pic.ps >DCexample_pic.tex
clean::
	rm -f DCexample_pic.tex

DCexample_pic.ps: DCexample_pic.fig Makefile
	fig2dev -L ps DCexample_pic.fig > DCexample_pic.ps
clean::
	rm -f DCexample_pic.ps

Added mtt/lib/examples/Control/SimpleStateSpace/Differential/Differential_abg.fig version [6c87d44baf].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2880 2655 2970 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2925 2700 2925 3150
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2700 3150 1350 3375 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3172 3172 3172 4522 3397 4297
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2925 2925 2925 2700 3150
4 1 0 100 0 18 18 0.0000 4 195 150 3150 3015 0\001
4 1 0 100 0 18 18 0.0000 4 270 540 3195 1215 I:j_1\001
4 1 0 100 0 18 18 0.0000 4 270 540 3150 4860 I:j_2\001
4 1 0 100 0 18 18 0.0000 4 270 750 990 3015 SS:yu\001

Added mtt/lib/examples/Control/SimpleStateSpace/Differential/Differential_rep.txt version [00561dcbde].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Differential (Differential_rep.txt)
## Generated by MTT on" Wed Jan 26 10:13:44 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt Differential abg tex			# The system description
mtt Differential cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt Differential struc tex	        # The system structure
## mtt Differential dae tex	        # The system dae
mtt Differential ode tex	        # The system ode 
## mtt Differential sspar tex		# Steady-state parameters
## mtt Differential ss tex 		# Steady state
## mtt Differential dm tex		# Descriptor matrices (of linearised system)
mtt Differential sm tex		# State matrices (of linearised system)
mtt Differential tf tex		# Transfer function (of linearised

## mtt Differential lmfr ps		# log modulus of frequency response (of linearised system)
## mtt Differential simpar tex		# Simulation parameters
## mtt Differential numpar tex		# Numerical simulation parameters
## mtt Differential input tex		# Simulation input
mtt Differential odeso ps		# Simulation output

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_abg.fig version [d065af5e98].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 8550 1125 485 485 8550 1125 8730 1575
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 8100 9450 225 855 225 855 8100 9450 8100
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3871 3600 5446 3825 5221
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 3871 5850 5446 6075 5221
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 3870 3735 3870
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4590 3825 4860 3825
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5715 3870 5985 3870
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 1125 3735 1125
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4635 2700 4905 2700
4 1 -1 0 0 0 20 0.0000000 4 240 870 3603 948 SS:v_x\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5850 2970 [y_a]\001
4 1 -1 0 0 0 20 0.0000000 4 270 870 5850 945 SS:v_y\001
4 1 -1 0 0 0 20 0.0000000 4 210 1110 4729 3379 ROD:rod\001
4 1 -1 0 0 0 20 0.0000000 4 240 825 3510 5760 SS:f_x\001
4 1 -1 0 0 0 20 0.0000000 4 270 825 5760 5760 SS:f_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 810 4635 5760 SS:f_a\001
4 0 1 1 0 3 20 0.0000000 4 240 720 6750 1260 Joint \001
4 0 1 1 0 3 20 0.0000000 4 210 495 6795 3375 Rod\001
4 1 -1 0 0 0 20 0.0000000 4 210 570 4771 946 SS:u\001

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_desc.tex version [7fb9ed2fd5].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system InvertedPendulumT (InvertedPendulumT_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{InvertedPendulumT} is
   displayed in Figure \Ref{InvertedPendulumT_abg} and its label
   file is listed in Section \Ref{sec:InvertedPendulumT_lbl}.
   The subsystems are listed in Section \Ref{sec:InvertedPendulumT_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:InvertedPendulumT_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:InvertedPendulumT_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:InvertedPendulumT_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_input.txt version [1c6fb421ed].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (InvertedPendulumT_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	(t<1.0);
u(2) =	0.0; # 
u(3) =	0.0; # gravity

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_lbl.txt version [66a8b967a4].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY InvertedPendulumT: Pendulum with torque input at lower end

%% Label (InvertedPendulumT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod	none	l_1;l_1;j_1;m_1

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
f_x	SS	   0,internal
f_a	SS	   0,internal
f_y	SS	   0,internal


%Torque/velocity at joint
u	SS	 external,internal


Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_numpar.txt version [43ee56016c].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (InvertedPendulumT_numpar.txt)
# Generated by MTT at Mon Jan 19 13:53:15 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
j_1 = 	1.0; # Parameter j_1 for InvertedPendulumT
j_2 = 	1.0; # Parameter j_2 for InvertedPendulumT
l_1 = 	1.0; # Parameter l_1 for InvertedPendulumT
l_2 = 	1.0; # Parameter l_2 for InvertedPendulumT
m_1 = 	1.0; # Parameter m_1 for InvertedPendulumT
m_2 = 	1.0; # Parameter m_2 for InvertedPendulumT

# Initial states
x(1) = 	0.0; # Initial state for InvertedPendulumT_rod1 (J)
x(2) = 	0.0; # Initial state for InvertedPendulumT_rod1_th (3)
x(3) = 	0.0; # Initial state for InvertedPendulumT_rod2 (J)
x(4) = 	0.0; # Initial state for InvertedPendulumT_rod2_th (3)

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_rep.txt version [074582e484].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system InvertedPendulumT (InvertedPendulumT_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt InvertedPendulumT abg tex

mtt -o InvertedPendulumT ode tex
mtt -o InvertedPendulumT sm tex
mtt -o InvertedPendulumT tf tex

mtt -o InvertedPendulumT smc tex
mtt -o InvertedPendulumT ssk tex

mtt -o InvertedPendulumT smo tex
mtt -o InvertedPendulumT ssl tex


Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_simp.r version [5cb387141c].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system InvertedPendulumT (InvertedPendulumT_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;


m_1 := m;
l_1 := l;
j_1 := j;
mg := m*g;
j := m*l*l/12;

%l:=1;

alpha_c1 := 2;
alpha_c2 := 1;

alpha_o1 := 20;
alpha_o2 := 100;


ORDER s,m,g;


END;

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_sspar.r version [37046d7f6d].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for InvertedPendulumT (InvertedPendulumT_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTx1 := 0;
MTTx2 := 0;

END;

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/ROD_abg.fig version [afa8c63279].






































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 8550 7650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1372 3490 1372 3172 3375 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1507 3037 1237 3307
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9180 5724 9180 6042 8544 5406
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 1065 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000000 4 240 1080 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1065 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1080 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1575 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1590 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000000 4 270 810 9225 6300 SS:mg\001
4 2 -1 0 0 0 20 0.0000000 4 210 1020 1395 3060 SS:theta\001

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/ROD_desc.tex version [58e21e2b67].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/ROD_lbl.txt version [03080ab3ad].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system ROD (ROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2

%Gravity
mg	mg	internal

% Angle
theta	external	0

	

Added mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_abg.fig version [3da14bbf94].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4500 2475 4275 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5872 2497 7222 2497 6997 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8145 3150 8145 450 270 450 270 3150 8145 3150
4 1 -1 0 0 0 20 0.0000000 4 210 1080 5265 2565 INTF:int\001
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 0 -1 0 0 0 20 0.0000000 4 270 570 7380 2565 SS:y\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 270 285 2880 765 I:j\001

Added mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_desc.tex version [f32b0f51ab].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Satellite (Satellite_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Satellite} is
   displayed in Figure \Ref{Satellite_abg} and its label
   file is listed in Section \Ref{sec:Satellite_lbl}.
   The subsystems are listed in Section \Ref{sec:Satellite_sub}.


This is a simple teaching example to illustrare compensator design via
observer/state-feedback methods.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_lbl.txt version [782e83919f].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Satellite: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system Satellite (Satellite_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	j		lin	flow,1

% Component type INTF
	int		

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Added mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_numpar.txt version [1f955bd38c].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Satellite_numpar.txt)
# Generated by MTT at Mon Jan 12 15:43:19 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # Parameter b for Satellite
b_m = 	1.0; # Parameter b_m for Satellite
j = 	1.0; # Parameter j for Satellite
j_m = 	1.0; # Parameter j_m for Satellite
k = 	1.0; # Parameter k for Satellite
k_m = 	1.0; # Parameter k_m for Satellite
l = 	1.0; # Parameter l for Satellite
l_a = 	1.0; # Parameter l_a for Satellite
l_m = 	1.0; # Parameter l_m for Satellite
r = 	1.0; # Parameter r for Satellite
r_a = 	1.0; # Parameter r_a for Satellite
r_m = 	1.0; # Parameter r_m for Satellite

# Initial states
x(1) = 	0.0; # Initial state for Satellite_motor (l_a)
x(2) = 	0.0; # Initial state for Satellite_motor (j_m)

Added mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_rep.txt version [0143a6f353].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Satellite (Satellite_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Satellite abg tex

mtt -o Satellite ode tex
mtt -o Satellite sm tex
mtt -o Satellite tf tex

mtt -o Satellite smc tex
mtt -o Satellite ssk tex

mtt -o Satellite smo tex
mtt -o Satellite ssl tex
mtt -o Satellite ctf tex


Added mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_simp.r version [6ee2a71759].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system Satellite (Satellite_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% System

% Controller - poles -1
alpha_c1 := 2; alpha_c2 := 1;

% Observer -  poles at -1 
alpha_o1 := 2; alpha_o2 := 1;

ON FACTOR;

END;

Added mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_sspar.r version [0ae589b8c8].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for Satellite (Satellite_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/Makefile version [57b513cffa].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#
# TransFig makefile
#

all: TwoTanks_pic.tex 

# translation into ps

TwoTanks_pic.tex: TwoTanks_pic.ps Makefile
	fig2ps2tex TwoTanks_pic.ps >TwoTanks_pic.tex
clean::
	rm -f TwoTanks_pic.tex

TwoTanks_pic.ps: TwoTanks_pic.fig Makefile
	fig2dev -L ps TwoTanks_pic.fig > TwoTanks_pic.ps
clean::
	rm -f TwoTanks_pic.ps

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_abg.fig version [c6ae3ce4c5].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1351 4276 2701 4276 2476 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4501 3826 5401 3601 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2971 4051 3871 3151 3871 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 3150 5625 3150 5400 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 5400 5625 5400 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 2925 4051 1575 4276 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5670 4050 7020 4275 6795
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2880 5850 1530 6075 1755
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 5670 5850 7020 6075 6795
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 7425 3150 7200 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5400 7425 5400 7200 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 8775 4050 8505 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 5400 8775 4500 8775 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 4275 10351 4275 10126 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1350 4050 1350 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9000 4050 9000 4500
4 1 -1 0 0 0 20 0.0000000 4 210 150 2926 4366 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 4096 5491 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 4096 3241 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5895 3240 1\001
4 1 -1 0 0 0 20 0.0000000 4 240 690 5895 1440 R:r_1\001
4 1 -1 0 0 0 20 0.0000000 4 240 720 4050 1440 C:c_1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5850 5490 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 375 7650 3240 AF\001
4 1 -1 0 0 0 20 0.0000000 4 210 375 7695 5490 AF\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8775 4365 0\001
4 0 -1 0 0 0 20 0.0000000 4 240 825 10620 4320 SS:f_2\001
4 2 -1 0 0 0 20 0.0000000 4 240 825 1260 4365 SS:f_1\001
4 1 -1 0 0 0 20 0.0000000 4 240 720 4005 7335 C:c_2\001
4 1 -1 0 0 0 20 0.0000000 4 240 690 5850 7335 R:r_2\001

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_desc.tex version [fc1416584e].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoTanks (TwoTanks_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods.

\begin{itemize}
\item Each tank is identical and of unit cross section.
\item Each tank has an identical inflow $f_1 = u$
\item Each outflow is different and given by $\sigma_i v_i$ for $i=1$
  and $i=2$ where $v_i$ is the volume of liquid in tank i and
  $\sigma_i$ the corresponding discharge coefficient. The net outflow
  is thus $y = f_2 = \sigma_1 v_1 + \sigma_2 v_2$.
\item The system states are taken to be:
  \begin{equation}
    x = 
    \begin{pmatrix}
      v_1 \\ v_2
    \end{pmatrix}
  \end{equation}
\end{itemize}




%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_lbl.txt version [c838a1da5c].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoTanks: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system TwoTanks (TwoTanks_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,1
	c_2		lin	effort,1

% Component type R
	r_1		lin	effort,sigma_1
	r_2		lin	effort,sigma_2

% Component type SS
	f_1		SS	internal,external
	f_2		SS	0,external

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_params.r version [e6fd98b650].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
%% Parameter file for system TwoTanks (TwoTanks_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_pic.fig version [9031f3f49a].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Inches
1200 2
6 2099 1799 3974 3974
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 1800 2100 3900 3900 3900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3300 1800 3300 3600 3900 3600
-6
6 5025 1800 6900 3975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6899 1801 6899 3901 5099 3901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5699 1801 5699 3601 5099 3601
-6
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 3600 3750 4200 3750 4200 4800
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 5400 3750 4800 3750 4800 4800
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 1800 1050 2400 1050 2400 2100
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 7200 1050 6600 1050 6600 2100
4 0 -1 0 0 3 20 0.0000000 4 270 2610 3225 5250 y=total outflow = f_2\001
4 0 -1 0 0 3 20 0.0000000 4 270 405 1950 900 f_1\001
4 0 -1 0 0 3 20 0.0000000 4 270 405 6825 900 f_1\001
4 0 -1 0 0 3 20 0.0000000 4 270 3525 2775 1500 u= inflow to each tank = f_1\001

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_pic.tex version [d9789ea80b].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
\makebox[4.569in][l]{
  \vbox to 3.861in{
    \vfill
    \special{psfile=TwoTanks_pic.ps}
  }
  \vspace{-\baselineskip}
}

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_rep.tex version [c0c0a0dc5d].





















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


\section{\textbf{TwoTanks}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:TwoTanks_abg.tex}
\index{\textbf{TwoTanks} -- abg}


MTT command:
\begin{verbatim}
mtt TwoTanks abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_abg.tex}


\section{\textbf{TwoTanks}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:TwoTanks_sm.tex}
\index{\textbf{TwoTanks} -- sm}


MTT command:
\begin{verbatim}
mtt -o TwoTanks sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_sm.tex}


\section{\textbf{TwoTanks}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:TwoTanks_tf.tex}
\index{\textbf{TwoTanks} -- tf}


MTT command:
\begin{verbatim}
mtt -o TwoTanks tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_tf.tex}


\section{\textbf{TwoTanks}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:TwoTanks_smc.tex}
\index{\textbf{TwoTanks} -- smc}


MTT command:
\begin{verbatim}
mtt -o TwoTanks smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_smc.tex}


\section{\textbf{TwoTanks}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:TwoTanks_ssk.tex}
\index{\textbf{TwoTanks} -- ssk}


MTT command:
\begin{verbatim}
mtt -o TwoTanks ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_ssk.tex}


\section{\textbf{TwoTanks}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:TwoTanks_smo.tex}
\index{\textbf{TwoTanks} -- smo}


MTT command:
\begin{verbatim}
mtt -o TwoTanks smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_smo.tex}


\section{\textbf{TwoTanks}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:TwoTanks_ssl.tex}
\index{\textbf{TwoTanks} -- ssl}


MTT command:
\begin{verbatim}
mtt -o TwoTanks ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_ssl.tex}

Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_rep.txt version [6dfe1f9e05].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TwoTanks (TwoTanks_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoTanks abg tex

mtt -o TwoTanks sm tex
mtt -o TwoTanks tf tex

mtt -o TwoTanks smc tex
mtt -o TwoTanks ssk tex

mtt -o TwoTanks smo tex
mtt -o TwoTanks ssl tex


Added mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_simp.r version [6a85134c77].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system TwoTanks (TwoTanks_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/RigidBar2D_abg.dia version [98ed84b855].









































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="2.7,9.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.65,9.6;46.95,22.25"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.7,9.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="44.200000000000003"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="12.550000000000001"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#b1a381"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="2.85,2.75"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.85,1.35;19.9,3.75"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Rigid 2-dimensional bar#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="2.85,2.75"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="0.4375,29.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.3875,29;9.87138,30.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="0.4375,29.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="9.3838834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="5.12944,30.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="4.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.1,19.2;6.2,21.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="5.15,20.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="1.40625,4.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.35625,4.05;8.90263,5.95711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1.40625,4.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.4463834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="5.12944,5.30355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="9.1,19.3"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.05,19.25;11.15,21.1571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="9.1,19.3"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="10.1,20.5036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="24.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.1,19.2;26.2,21.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25.15,20.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="39.05,19.2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39,19.15;41.1,21.0571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39.05,19.2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="40.05,20.4036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="44.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="44.1,19.2;46.2,21.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="44.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="45.15,20.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="39.95,29.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39.9,29.05;50.2589,30.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39.95,29.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="10.258883476483181"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="45.0794,30.3036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="40.9688,4.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="40.9188,4;49.3402,5.90711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="40.9688,4.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="8.3213834764831809"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="45.1295,5.25355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="8.55,10.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.5,10;11.8589,11.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="8.55,10.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.2588834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:a#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="10.1794,11.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="38.4,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.35,9.95;41.7089,11.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="38.4,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.2588834764831813"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:b#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="40.0294,11.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="24.6,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.55,9.95;26.65,11.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24.6,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25.6,11.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="16.15,14.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.1,14.4;24.5839,16.3071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="16.15,14.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="8.3838834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#I:translational#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="20.3419,15.6536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="27.35,15.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.3,15.1;34.2214,17.0071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="27.35,15.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.8213834764831818"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#I:rotational#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="30.7607,16.3536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="22,29"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.95,28.95;28.1214,30.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="22,29"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.0713834764831853"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Se:weight#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25.0357,30.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="5.12944,29.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.05578,20.0061;6.34895,29.6561"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="5.12944,29.9536"/>
        <dia:point val="5.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O2" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="5.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.03673,4.85192;6.34932,19.852"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="5.15,20.1536"/>
        <dia:point val="5.12944,5.00355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O3" connection="0"/>
        <dia:connection handle="1" to="O4" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="5.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.59947,18.3087;9.71169,21.0281"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="5.15,20.1536"/>
        <dia:point val="10.1,20.2036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O3" connection="0"/>
        <dia:connection handle="1" to="O5" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="10.1,20.2036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.5498,18.3053;24.7616,21.0031"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="10.1,20.2036"/>
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O5" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.6215,14.2076;25.644,19.8711"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.15,20.1536"/>
        <dia:point val="20.3419,15.3536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O14" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="45.0794,30.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.0326,20.0122;46.3464,29.7122"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="45.0794,30.0036"/>
        <dia:point val="45.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O9" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="45.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.0367,4.80192;46.3493,19.852"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="45.15,20.1536"/>
        <dia:point val="45.1294,4.95355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="45.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="40.4384,18.2586;44.7005,20.9651"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="45.15,20.1536"/>
        <dia:point val="40.05,20.1036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O7" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="40.05,20.1036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.5384,18.2553;39.6002,20.9907"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="40.05,20.1036"/>
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O7" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="10.1,20.2036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.0539,10.8139;11.3751,19.9139"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="10.1,20.2036"/>
        <dia:point val="10.1794,10.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O5" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="10.1794,10.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.6292,9.05523;25.2116,11.7529"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="10.1794,10.9536"/>
        <dia:point val="25.6,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O13" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="25.6,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.8832,9.75738;31.2544,15.7745"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.6,10.9036"/>
        <dia:point val="30.7607,16.0536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O15" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="25.6,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.05,9.0536;39.641,11.7469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.6,10.9036"/>
        <dia:point val="40.0294,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O12" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O30">
      <dia:attribute name="obj_pos">
        <dia:point val="40.0294,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39.9557,10.7509;41.2489,19.8009"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="40.0294,10.9036"/>
        <dia:point val="40.05,20.1036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O12" connection="0"/>
        <dia:connection handle="1" to="O7" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O31">
      <dia:attribute name="obj_pos">
        <dia:point val="24,24"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.95,23.95;26.05,25.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24,24"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25,25.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O32">
      <dia:attribute name="obj_pos">
        <dia:point val="25.0357,29.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.9166,25.6986;26.2253,28.6413"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.0357,29.9036"/>
        <dia:point val="25,24.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O16" connection="0"/>
        <dia:connection handle="1" to="O31" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O33">
      <dia:attribute name="obj_pos">
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.9507,20.995;26.3035,23.6879"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.15,20.1536"/>
        <dia:point val="25,24.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O31" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/RigidBar2D_lbl.txt version [95bc109297].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY RigidBar2D
#DESCRIPTION A rigid bar capable of motion in two directions:
#DESCRIPTION vertical translation and rotation about its centre of gravity.
#DESCRIPTION Parameters "a" and "b" are moment arms,
#DESCRIPTION "m" is the bar's mass and "J" is a moment of inertia.

## System RigidBar2D, representation lbl, language txt
## File RigidBar2D_lbl.txt
## Generated by MTT on Thu Aug 12 21:04:24 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	left_bottom,right_bottom
#ALIAS	out	left_top,right_top

## Argument aliases
#ALIAS	$1	length_a
#ALIAS	$2	length_b
#ALIAS	$3	inertial_mass
#ALIAS	$4	moment_of_inertia

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[left_bottom]	SS		external,external
	[left_top]	SS		external,external
	[right_bottom]	SS		external,external
	[right_top]	SS		external,external

## Component type Se
	weight		SS		inertial_mass*gravity

## Component type I
	rotational	lin		flow,moment_of_inertia		
	translational	lin		flow,inertial_mass	

## Component type TF
	a		lin		flow,length_a		
	b		lin		flow,length_b		

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							
	# 1							
	# 1							

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_abg.dia version [97772ada2d].

























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O0">
        <dia:attribute name="obj_pos">
          <dia:point val="5.16,4.215"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="5.11,4.165;49.41,16.815"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="5.16,4.215"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="44.200000000000003"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="12.550000000000001"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#b1a381"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O1">
          <dia:attribute name="obj_pos">
            <dia:point val="5.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="5.11,27.165;21.21,29.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O2">
          <dia:attribute name="obj_pos">
            <dia:point val="5.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="5.11,17.165;21.21,19.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O3">
          <dia:attribute name="obj_pos">
            <dia:point val="9.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09292,19.1479;9.22708,20.2821"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="9.16,19.215"/>
            <dia:point val="7.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O4">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,20.165;10.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,20.215"/>
            <dia:point val="10.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O5">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,20.1518;10.2232,21.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,20.215"/>
            <dia:point val="7.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O6">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,21.165;10.21,21.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,21.215"/>
            <dia:point val="10.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O7">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,26.165;10.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,26.215"/>
            <dia:point val="10.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O8">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,25.165;10.21,25.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,25.215"/>
            <dia:point val="10.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O9">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,24.165;10.21,24.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,24.215"/>
            <dia:point val="10.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O10">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,23.165;10.21,23.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,23.215"/>
            <dia:point val="10.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O11">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,22.165;10.21,22.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,22.215"/>
            <dia:point val="10.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O12">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,25.1518;10.2232,26.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,25.215"/>
            <dia:point val="7.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O13">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,24.1518;10.2232,25.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,24.215"/>
            <dia:point val="7.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O14">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,23.1518;10.2232,24.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,23.215"/>
            <dia:point val="7.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O15">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,22.1518;10.2232,23.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,22.215"/>
            <dia:point val="7.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O16">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,21.1518;10.2232,22.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,21.215"/>
            <dia:point val="7.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O17">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,26.1518;10.2232,27.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,26.215"/>
            <dia:point val="7.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O18">
          <dia:attribute name="obj_pos">
            <dia:point val="17.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.11,20.165;19.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="17.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O19">
          <dia:attribute name="obj_pos">
            <dia:point val="18.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="18.11,26.165;18.21,27.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18.16,27.215"/>
            <dia:point val="18.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O18" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O20">
          <dia:attribute name="obj_pos">
            <dia:point val="18.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="18.11,19.165;18.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18.16,19.215"/>
            <dia:point val="18.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O18" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O21">
          <dia:attribute name="obj_pos">
            <dia:point val="33.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="33.11,27.165;49.21,29.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O22">
          <dia:attribute name="obj_pos">
            <dia:point val="33.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="33.11,17.165;49.21,19.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O23">
          <dia:attribute name="obj_pos">
            <dia:point val="37.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0929,19.1479;37.2271,20.2821"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="37.16,19.215"/>
            <dia:point val="35.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O24">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,20.165;38.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,20.215"/>
            <dia:point val="38.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O25">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,20.1518;38.2232,21.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,20.215"/>
            <dia:point val="35.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O26">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,21.165;38.21,21.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,21.215"/>
            <dia:point val="38.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O27">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,26.165;38.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,26.215"/>
            <dia:point val="38.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O28">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,25.165;38.21,25.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,25.215"/>
            <dia:point val="38.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O29">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,24.165;38.21,24.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,24.215"/>
            <dia:point val="38.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O30">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,23.165;38.21,23.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,23.215"/>
            <dia:point val="38.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O31">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,22.165;38.21,22.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,22.215"/>
            <dia:point val="38.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O32">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,25.1518;38.2232,26.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,25.215"/>
            <dia:point val="35.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O33">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,24.1518;38.2232,25.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,24.215"/>
            <dia:point val="35.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O34">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,23.1518;38.2232,24.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,23.215"/>
            <dia:point val="35.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O35">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,22.1518;38.2232,23.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,22.215"/>
            <dia:point val="35.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O36">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,21.1518;38.2232,22.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,21.215"/>
            <dia:point val="35.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O37">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,26.1518;38.2232,27.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,26.215"/>
            <dia:point val="35.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O38">
          <dia:attribute name="obj_pos">
            <dia:point val="45.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.11,20.165;47.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="45.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O39">
          <dia:attribute name="obj_pos">
            <dia:point val="46.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="46.11,26.165;46.21,27.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46.16,27.215"/>
            <dia:point val="46.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O38" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O40">
          <dia:attribute name="obj_pos">
            <dia:point val="46.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="46.11,19.165;46.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46.16,19.215"/>
            <dia:point val="46.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O38" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O41">
        <dia:attribute name="obj_pos">
          <dia:point val="5,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="4.95,28.95;49.25,41.6"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="5,29"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="44.200000000000003"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="12.550000000000001"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#b1a381"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O42">
          <dia:attribute name="obj_pos">
            <dia:point val="5,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,51.95;21.05,54.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,52"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O43">
          <dia:attribute name="obj_pos">
            <dia:point val="5,42"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,41.95;21.05,44.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,42"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O44">
          <dia:attribute name="obj_pos">
            <dia:point val="9,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93292,43.9329;9.06708,45.0671"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="9,44"/>
            <dia:point val="7,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O45">
          <dia:attribute name="obj_pos">
            <dia:point val="7,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,44.95;10.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,45"/>
            <dia:point val="10,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O46">
          <dia:attribute name="obj_pos">
            <dia:point val="10,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,44.9368;10.0632,46.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,45"/>
            <dia:point val="7,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O47">
          <dia:attribute name="obj_pos">
            <dia:point val="7,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,45.95;10.05,46.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,46"/>
            <dia:point val="10,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O48">
          <dia:attribute name="obj_pos">
            <dia:point val="7,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,50.95;10.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,51"/>
            <dia:point val="10,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O49">
          <dia:attribute name="obj_pos">
            <dia:point val="7,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,49.95;10.05,50.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,50"/>
            <dia:point val="10,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O50">
          <dia:attribute name="obj_pos">
            <dia:point val="7,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,48.95;10.05,49.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,49"/>
            <dia:point val="10,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O51">
          <dia:attribute name="obj_pos">
            <dia:point val="7,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,47.95;10.05,48.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,48"/>
            <dia:point val="10,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O52">
          <dia:attribute name="obj_pos">
            <dia:point val="7,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,46.95;10.05,47.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,47"/>
            <dia:point val="10,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O53">
          <dia:attribute name="obj_pos">
            <dia:point val="10,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,49.9368;10.0632,51.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,50"/>
            <dia:point val="7,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O54">
          <dia:attribute name="obj_pos">
            <dia:point val="10,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,48.9368;10.0632,50.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,49"/>
            <dia:point val="7,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O55">
          <dia:attribute name="obj_pos">
            <dia:point val="10,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,47.9368;10.0632,49.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,48"/>
            <dia:point val="7,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O56">
          <dia:attribute name="obj_pos">
            <dia:point val="10,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,46.9368;10.0632,48.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,47"/>
            <dia:point val="7,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O57">
          <dia:attribute name="obj_pos">
            <dia:point val="10,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,45.9368;10.0632,47.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,46"/>
            <dia:point val="7,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O58">
          <dia:attribute name="obj_pos">
            <dia:point val="10,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,50.9368;10.0632,52.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,51"/>
            <dia:point val="7,52"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O59">
          <dia:attribute name="obj_pos">
            <dia:point val="17,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="16.95,44.95;19.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="17,45"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O60">
          <dia:attribute name="obj_pos">
            <dia:point val="18,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,50.95;18.05,52.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,52"/>
            <dia:point val="18,51"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O59" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O61">
          <dia:attribute name="obj_pos">
            <dia:point val="18,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,43.95;18.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,44"/>
            <dia:point val="18,45"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O59" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O62">
          <dia:attribute name="obj_pos">
            <dia:point val="33,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,51.95;49.05,54.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,52"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O63">
          <dia:attribute name="obj_pos">
            <dia:point val="33,42"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,41.95;49.05,44.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,42"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O64">
          <dia:attribute name="obj_pos">
            <dia:point val="37,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9329,43.9329;37.0671,45.0671"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="37,44"/>
            <dia:point val="35,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O65">
          <dia:attribute name="obj_pos">
            <dia:point val="35,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,44.95;38.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,45"/>
            <dia:point val="38,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O66">
          <dia:attribute name="obj_pos">
            <dia:point val="38,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,44.9368;38.0632,46.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,45"/>
            <dia:point val="35,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O67">
          <dia:attribute name="obj_pos">
            <dia:point val="35,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,45.95;38.05,46.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,46"/>
            <dia:point val="38,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O68">
          <dia:attribute name="obj_pos">
            <dia:point val="35,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,50.95;38.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,51"/>
            <dia:point val="38,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O69">
          <dia:attribute name="obj_pos">
            <dia:point val="35,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,49.95;38.05,50.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,50"/>
            <dia:point val="38,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O70">
          <dia:attribute name="obj_pos">
            <dia:point val="35,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,48.95;38.05,49.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,49"/>
            <dia:point val="38,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O71">
          <dia:attribute name="obj_pos">
            <dia:point val="35,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,47.95;38.05,48.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,48"/>
            <dia:point val="38,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O72">
          <dia:attribute name="obj_pos">
            <dia:point val="35,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,46.95;38.05,47.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,47"/>
            <dia:point val="38,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O73">
          <dia:attribute name="obj_pos">
            <dia:point val="38,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,49.9368;38.0632,51.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,50"/>
            <dia:point val="35,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O74">
          <dia:attribute name="obj_pos">
            <dia:point val="38,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,48.9368;38.0632,50.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,49"/>
            <dia:point val="35,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O75">
          <dia:attribute name="obj_pos">
            <dia:point val="38,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,47.9368;38.0632,49.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,48"/>
            <dia:point val="35,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O76">
          <dia:attribute name="obj_pos">
            <dia:point val="38,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,46.9368;38.0632,48.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,47"/>
            <dia:point val="35,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O77">
          <dia:attribute name="obj_pos">
            <dia:point val="38,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,45.9368;38.0632,47.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,46"/>
            <dia:point val="35,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O78">
          <dia:attribute name="obj_pos">
            <dia:point val="38,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,50.9368;38.0632,52.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,51"/>
            <dia:point val="35,52"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O79">
          <dia:attribute name="obj_pos">
            <dia:point val="45,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="44.95,44.95;47.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="45,45"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O80">
          <dia:attribute name="obj_pos">
            <dia:point val="46,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,50.95;46.05,52.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,52"/>
            <dia:point val="46,51"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O79" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O81">
          <dia:attribute name="obj_pos">
            <dia:point val="46,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,43.95;46.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,44"/>
            <dia:point val="46,45"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O79" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O82">
        <dia:attribute name="obj_pos">
          <dia:point val="5,-21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="4.95,-21.05;49.25,-8.4"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="5,-21"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="44.200000000000003"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="12.550000000000001"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#b1a381"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O83">
          <dia:attribute name="obj_pos">
            <dia:point val="5,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,1.95;21.05,4.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,2"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O84">
          <dia:attribute name="obj_pos">
            <dia:point val="5,-8"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,-8.05;21.05,-5.95"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,-8"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O85">
          <dia:attribute name="obj_pos">
            <dia:point val="9,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93292,-6.06708;9.06708,-4.93292"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="9,-6"/>
            <dia:point val="7,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O86">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-5.05;10.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-5"/>
            <dia:point val="10,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O87">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-5.06325;10.0632,-3.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-5"/>
            <dia:point val="7,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O88">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-4.05;10.05,-3.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-4"/>
            <dia:point val="10,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O89">
          <dia:attribute name="obj_pos">
            <dia:point val="7,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,0.95;10.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,1"/>
            <dia:point val="10,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O90">
          <dia:attribute name="obj_pos">
            <dia:point val="7,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-0.05;10.05,0.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,0"/>
            <dia:point val="10,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O91">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-1.05;10.05,-0.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-1"/>
            <dia:point val="10,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O92">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-2.05;10.05,-1.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-2"/>
            <dia:point val="10,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O93">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-3.05;10.05,-2.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-3"/>
            <dia:point val="10,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O94">
          <dia:attribute name="obj_pos">
            <dia:point val="10,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-0.0632456;10.0632,1.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,0"/>
            <dia:point val="7,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O95">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-1.06325;10.0632,0.0632456"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-1"/>
            <dia:point val="7,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O96">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-2.06325;10.0632,-0.936754"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-2"/>
            <dia:point val="7,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O97">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-3.06325;10.0632,-1.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-3"/>
            <dia:point val="7,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O98">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-4.06325;10.0632,-2.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-4"/>
            <dia:point val="7,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O99">
          <dia:attribute name="obj_pos">
            <dia:point val="10,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,0.936754;10.0632,2.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,1"/>
            <dia:point val="7,2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O100">
          <dia:attribute name="obj_pos">
            <dia:point val="17,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="16.95,-5.05;19.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="17,-5"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O101">
          <dia:attribute name="obj_pos">
            <dia:point val="18,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,0.95;18.05,2.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,2"/>
            <dia:point val="18,1"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O100" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O102">
          <dia:attribute name="obj_pos">
            <dia:point val="18,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,-6.05;18.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,-6"/>
            <dia:point val="18,-5"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O100" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O103">
          <dia:attribute name="obj_pos">
            <dia:point val="33,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,1.95;49.05,4.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,2"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O104">
          <dia:attribute name="obj_pos">
            <dia:point val="33,-8"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,-8.05;49.05,-5.95"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,-8"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O105">
          <dia:attribute name="obj_pos">
            <dia:point val="37,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9329,-6.06708;37.0671,-4.93292"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="37,-6"/>
            <dia:point val="35,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O106">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-5.05;38.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-5"/>
            <dia:point val="38,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O107">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-5.06325;38.0632,-3.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-5"/>
            <dia:point val="35,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O108">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-4.05;38.05,-3.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-4"/>
            <dia:point val="38,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O109">
          <dia:attribute name="obj_pos">
            <dia:point val="35,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,0.95;38.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,1"/>
            <dia:point val="38,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O110">
          <dia:attribute name="obj_pos">
            <dia:point val="35,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-0.05;38.05,0.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,0"/>
            <dia:point val="38,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O111">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-1.05;38.05,-0.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-1"/>
            <dia:point val="38,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O112">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-2.05;38.05,-1.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-2"/>
            <dia:point val="38,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O113">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-3.05;38.05,-2.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-3"/>
            <dia:point val="38,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O114">
          <dia:attribute name="obj_pos">
            <dia:point val="38,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-0.0632456;38.0632,1.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,0"/>
            <dia:point val="35,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O115">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-1.06325;38.0632,0.0632456"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-1"/>
            <dia:point val="35,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O116">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-2.06325;38.0632,-0.936754"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-2"/>
            <dia:point val="35,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O117">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-3.06325;38.0632,-1.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-3"/>
            <dia:point val="35,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O118">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-4.06325;38.0632,-2.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-4"/>
            <dia:point val="35,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O119">
          <dia:attribute name="obj_pos">
            <dia:point val="38,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,0.936754;38.0632,2.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,1"/>
            <dia:point val="35,2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O120">
          <dia:attribute name="obj_pos">
            <dia:point val="45,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="44.95,-5.05;47.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="45,-5"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O121">
          <dia:attribute name="obj_pos">
            <dia:point val="46,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,0.95;46.05,2.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,2"/>
            <dia:point val="46,1"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O120" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O122">
          <dia:attribute name="obj_pos">
            <dia:point val="46,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,-6.05;46.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,-6"/>
            <dia:point val="46,-5"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O120" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
    </dia:group>
    <dia:object type="Standard - Box" version="0" id="O123">
      <dia:attribute name="obj_pos">
        <dia:point val="-10,54"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-10.05,53.95;66.05,67.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-10,54"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="76"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="13"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#90ee90"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O124">
      <dia:attribute name="obj_pos">
        <dia:point val="4,-36"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4,-38.75;41.25,-34"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#A stack of supported bars#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="4,-36"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O125">
      <dia:attribute name="obj_pos">
        <dia:point val="4,33"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="3.95,32.95;49.6839,37.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4,33"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="45.633883476483177"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SupportedBar:bottom#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26.8169,36.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O126">
      <dia:attribute name="obj_pos">
        <dia:point val="4,-17"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="3.95,-17.05;49.6839,-12.1429"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4,-17"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="45.633883476483177"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SupportedBar:top#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26.8169,-13.9464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O127">
      <dia:attribute name="obj_pos">
        <dia:point val="2.125,8"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.075,7.95;51.5589,12.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.125,8"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="49.383883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SupportedBar:middle*3#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26.8169,11.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O128">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,35.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.7236,12.7011;28.0169,32.6561"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,35.4036"/>
        <dia:point val="26.8169,10.4036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O125" connection="0"/>
        <dia:connection handle="1" to="O127" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O129">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,10.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.7236,-14.7464;36.2669,10.1036"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,10.4036"/>
        <dia:point val="26.8169,-14.5964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[left_top,right_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[left_bottom,right_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O127" connection="0"/>
        <dia:connection handle="1" to="O126" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O130">
      <dia:attribute name="obj_pos">
        <dia:point val="-9.3125,58"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-9.3625,57.95;13.6839,62.0036"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-9.3125,58"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="22.946383476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:ground_left#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="2.16069,60.5536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O131">
      <dia:attribute name="obj_pos">
        <dia:point val="39,58"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.95,57.95;64.4339,62.0036"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39,58"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="25.383883476483188"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:ground_right#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="51.6919,60.5536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O132">
      <dia:attribute name="obj_pos">
        <dia:point val="51.6919,59.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.0983,34.2495;52.1777,59.6235"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="51.6919,59.9036"/>
        <dia:point val="26.8169,35.4036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[right_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O131" connection="0"/>
        <dia:connection handle="1" to="O125" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O133">
      <dia:attribute name="obj_pos">
        <dia:point val="5,-34"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.95,-34.05;24.2464,-29.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5,-34"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="19.196383476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:load_left#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="14.5982,-31.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O134">
      <dia:attribute name="obj_pos">
        <dia:point val="28,-34"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.95,-34.05;49.6839,-29.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="28,-34"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="21.633883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:load_right#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="38.8169,-31.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O135">
      <dia:attribute name="obj_pos">
        <dia:point val="16,-26"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.95,-26.05;18.9964,-21.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="16,-26"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.9463834764831822"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865462"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="17.4732,-23.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O136">
      <dia:attribute name="obj_pos">
        <dia:point val="35,-26"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="34.95,-26.05;37.9964,-21.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="35,-26"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.9463834764831951"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="36.4732,-23.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O137">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,-14.5964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.7141,-25.2314;30.1718,-14.8822"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,-14.5964"/>
        <dia:point val="17.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[left_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O126" connection="0"/>
        <dia:connection handle="1" to="O135" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O138">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,-14.5964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.1026,-23.8555;36.9584,-13.8916"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,-14.5964"/>
        <dia:point val="36.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[right_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O126" connection="0"/>
        <dia:connection handle="1" to="O136" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O139">
      <dia:attribute name="obj_pos">
        <dia:point val="14.5982,-32.0964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.7033,-32.6817;18.4334,-24.2324"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="14.5982,-32.0964"/>
        <dia:point val="17.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O133" connection="0"/>
        <dia:connection handle="1" to="O135" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O140">
      <dia:attribute name="obj_pos">
        <dia:point val="38.8169,-32.0964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="35.784,-31.9292;39.8279,-24.0389"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="38.8169,-32.0964"/>
        <dia:point val="36.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O134" connection="0"/>
        <dia:connection handle="1" to="O136" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O141">
      <dia:attribute name="obj_pos">
        <dia:point val="2.16069,59.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.44465,35.6464;31.3581,60.6024"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="2.16069,59.9036"/>
        <dia:point val="26.8169,35.4036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[left_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O130" connection="0"/>
        <dia:connection handle="1" to="O125" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_input.txt version [e76dccd8b2].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System StackOfSupportedBars, representation input, language txt; 
## File StackOfSupportedBars_input.txt; 
## Generated by MTT on Fri Aug 13 02:22:37 BST 2004; 



StackOfSupportedBars__ground_left__u	= 0.0;			 # vertical velocity
StackOfSupportedBars__ground_right__u	= 0.0;			 # vertical velocity
StackOfSupportedBars__load_left		= 10.0 * (mttt > 5);	 # vertical load
StackOfSupportedBars__load_right	= 0.0;			 # vertical load

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_lbl.txt version [a98f24e28a].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY StackOfSupportedBars
#DESCRIPTION A stack of rigid 2D bars supported by spring-dampers.
#DESCRIPTION The model demonstrates hierarchical modelling in dia
#DESCRIPTION including vector ports, repeated components and
#DESCRIPTION aliasing of parameters and ports.

## System StackOfSupportedBars, representation lbl, language txt
## File StackOfSupportedBars_lbl.txt
## Generated by MTT on Thu Aug 12 21:27:46 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	load_left	SS	external,external		
	load_right	SS	external,external		

## Component type Sf
	ground_left	SS	external		
	ground_right	SS	external		

## Component type SupportedBar
	bottom		none	a;b;m_b;J_b;R_d;K_s
	middle	  	none	a;b;m_b;J_b;R_d;K_s
	top		none	a;b;m_b;J_b;R_d;K_s

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							


Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_numpar.txt version [f24ff30a96].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System StackOfSupportedBars, representation numpar, language txt; 
## File StackOfSupportedBars_numpar.txt; 
## Generated by MTT on Fri Aug 13 02:22:33 BST 2004; 



J_b	= 3.0e-3;		# bar's moment of inertia
K_s	= 1.0e3;		# spring's stiffness
R_d	= 1.0;			# damper's resistance
a	= 0.5;			# bar's half-length
b	= 0.5;			# bar's half-length
gravity	= 9,81;			# gravitational acceleration
m_b	= 5.0;			# bar's mass

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/Support_abg.dia version [fa88b774d8].












































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="13,20"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.95,19.95;29.05,22.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="13,20"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="16"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="13,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.95,9.95;29.05,12.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="13,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="16"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="17,12"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9329,11.9329;17.0671,13.0671"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="17,12"/>
        <dia:point val="15,13"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="15,13"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,12.95;18.05,13.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,13"/>
        <dia:point val="18,13"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="18,13"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,12.9368;18.0632,14.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,13"/>
        <dia:point val="15,14"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="15,14"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,13.95;18.05,14.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,14"/>
        <dia:point val="18,14"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="15,19"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,18.95;18.05,19.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,19"/>
        <dia:point val="18,19"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="15,18"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,17.95;18.05,18.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,18"/>
        <dia:point val="18,18"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="15,17"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,16.95;18.05,17.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,17"/>
        <dia:point val="18,17"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="15,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,15.95;18.05,16.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,16"/>
        <dia:point val="18,16"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,14.95;18.05,15.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,15"/>
        <dia:point val="18,15"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="18,18"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,17.9368;18.0632,19.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,18"/>
        <dia:point val="15,19"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="18,17"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,16.9368;18.0632,18.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,17"/>
        <dia:point val="15,18"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="18,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,15.9368;18.0632,17.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,16"/>
        <dia:point val="15,17"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="18,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,14.9368;18.0632,16.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,15"/>
        <dia:point val="15,16"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="18,14"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,13.9368;18.0632,15.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,14"/>
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="18,19"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,18.9368;18.0632,20.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,19"/>
        <dia:point val="15,20"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="25,13"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.95,12.95;27.05,19.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="25,13"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="6"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Line" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="26,20"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.95,18.95;26.05,20.05"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,20"/>
        <dia:point val="26,19"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="1" to="O17" connection="6"/>
      </dia:connections>
    </dia:object>
    <dia:object type="Standard - Line" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="26,12"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.95,11.95;26.05,13.05"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,12"/>
        <dia:point val="26,13"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="1" to="O17" connection="1"/>
      </dia:connections>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="6,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="6,4.6;11.65,7"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Support#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="6,6"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="18.6831,25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.6331,24.95;23.367,26.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="18.6831,25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.6338834764831827"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[in]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,26.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="20,20"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.95,19.95;22.05,21.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20,20"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,21.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,14.95;17.05,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="16,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="25,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.95,14.95;27.05,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="25,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="20,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.95,9.95;22.05,11.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,11.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="18.3393,5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.2893,4.95;23.7107,6.85711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="18.3393,5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3213834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[out]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,6.20355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="5,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.95,14.95;10.4964,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.4463834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#C:spring#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="7.72319,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="31,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="30.95,14.95;37.1214,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="31,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.0713834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#R:damper#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="34.0357,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="21,25.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.9067,20.7536;22.2,25.6036"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,25.9036"/>
        <dia:point val="21,20.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O21" connection="0"/>
        <dia:connection handle="1" to="O22" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O30">
      <dia:attribute name="obj_pos">
        <dia:point val="21,20.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.2794,14.7586;21.495,20.6208"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,20.9036"/>
        <dia:point val="16,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O22" connection="0"/>
        <dia:connection handle="1" to="O23" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O31">
      <dia:attribute name="obj_pos">
        <dia:point val="16,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.2828,11.1476;21.495,16.5986"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="16,15.9036"/>
        <dia:point val="21,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O23" connection="0"/>
        <dia:connection handle="1" to="O25" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O32">
      <dia:attribute name="obj_pos">
        <dia:point val="21,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.9067,5.75355;22.2,10.6036"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,10.9036"/>
        <dia:point val="21,5.90355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O25" connection="0"/>
        <dia:connection handle="1" to="O26" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O33">
      <dia:attribute name="obj_pos">
        <dia:point val="21,20.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.2828,16.1476;26.495,21.5986"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,20.9036"/>
        <dia:point val="26,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O22" connection="0"/>
        <dia:connection handle="1" to="O24" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O34">
      <dia:attribute name="obj_pos">
        <dia:point val="26,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.2794,9.75863;26.495,15.6208"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,15.9036"/>
        <dia:point val="21,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O24" connection="0"/>
        <dia:connection handle="1" to="O25" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O35">
      <dia:attribute name="obj_pos">
        <dia:point val="16,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.11159,14.0536;15.55,16.7469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="16,15.9036"/>
        <dia:point val="7.72319,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O23" connection="0"/>
        <dia:connection handle="1" to="O27" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O36">
      <dia:attribute name="obj_pos">
        <dia:point val="26,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.45,14.0536;33.6473,16.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,15.9036"/>
        <dia:point val="34.0357,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O24" connection="0"/>
        <dia:connection handle="1" to="O28" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/Support_lbl.txt version [46cbbfd33f].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Support
#DESCRIPTION Spring-damper support

## System Support, representation lbl, language txt
## File Support_lbl.txt
## Generated by MTT on Thu Aug 12 21:14:12 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases
#ALIAS	$1	resistance
#ALIAS	$2	stiffness

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[in]	  SS		external,external		
	[out]	  SS		external,external		

## Component type C
	spring	  lin		effort,1/stiffness		

## Component type R
	damper	  lin		flow,resistance		

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/SupportedBar_abg.dia version [084ff9aedc].










































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="1,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.95,5.95;45.25,18.6"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="44.200000000000003"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="12.550000000000001"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#b1a381"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O1">
        <dia:attribute name="obj_pos">
          <dia:point val="1,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="0.95,28.95;17.05,31.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1,29"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O2">
        <dia:attribute name="obj_pos">
          <dia:point val="1,19"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="0.95,18.95;17.05,21.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1,19"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O3">
        <dia:attribute name="obj_pos">
          <dia:point val="5,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93292,20.9329;5.06708,22.0671"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="5,21"/>
          <dia:point val="3,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O4">
        <dia:attribute name="obj_pos">
          <dia:point val="3,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,21.95;6.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,22"/>
          <dia:point val="6,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O5">
        <dia:attribute name="obj_pos">
          <dia:point val="6,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,21.9368;6.06325,23.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,22"/>
          <dia:point val="3,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O6">
        <dia:attribute name="obj_pos">
          <dia:point val="3,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,22.95;6.05,23.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,23"/>
          <dia:point val="6,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O7">
        <dia:attribute name="obj_pos">
          <dia:point val="3,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,27.95;6.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,28"/>
          <dia:point val="6,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O8">
        <dia:attribute name="obj_pos">
          <dia:point val="3,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,26.95;6.05,27.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,27"/>
          <dia:point val="6,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O9">
        <dia:attribute name="obj_pos">
          <dia:point val="3,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,25.95;6.05,26.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,26"/>
          <dia:point val="6,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O10">
        <dia:attribute name="obj_pos">
          <dia:point val="3,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,24.95;6.05,25.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,25"/>
          <dia:point val="6,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O11">
        <dia:attribute name="obj_pos">
          <dia:point val="3,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,23.95;6.05,24.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,24"/>
          <dia:point val="6,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O12">
        <dia:attribute name="obj_pos">
          <dia:point val="6,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,26.9368;6.06325,28.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,27"/>
          <dia:point val="3,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O13">
        <dia:attribute name="obj_pos">
          <dia:point val="6,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,25.9368;6.06325,27.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,26"/>
          <dia:point val="3,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O14">
        <dia:attribute name="obj_pos">
          <dia:point val="6,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,24.9368;6.06325,26.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,25"/>
          <dia:point val="3,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O15">
        <dia:attribute name="obj_pos">
          <dia:point val="6,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,23.9368;6.06325,25.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,24"/>
          <dia:point val="3,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O16">
        <dia:attribute name="obj_pos">
          <dia:point val="6,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,22.9368;6.06325,24.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,23"/>
          <dia:point val="3,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O17">
        <dia:attribute name="obj_pos">
          <dia:point val="6,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,27.9368;6.06325,29.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,28"/>
          <dia:point val="3,29"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O18">
        <dia:attribute name="obj_pos">
          <dia:point val="13,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="12.95,21.95;15.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="13,22"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="6"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O19">
        <dia:attribute name="obj_pos">
          <dia:point val="14,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="13.95,27.95;14.05,29.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="14,29"/>
          <dia:point val="14,28"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O18" connection="6"/>
        </dia:connections>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O20">
        <dia:attribute name="obj_pos">
          <dia:point val="14,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="13.95,20.95;14.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="14,21"/>
          <dia:point val="14,22"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O18" connection="1"/>
        </dia:connections>
      </dia:object>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O21">
        <dia:attribute name="obj_pos">
          <dia:point val="29,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="28.95,28.95;45.05,31.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="29,29"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O22">
        <dia:attribute name="obj_pos">
          <dia:point val="29,19"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="28.95,18.95;45.05,21.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="29,19"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O23">
        <dia:attribute name="obj_pos">
          <dia:point val="33,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9329,20.9329;33.0671,22.0671"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="33,21"/>
          <dia:point val="31,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O24">
        <dia:attribute name="obj_pos">
          <dia:point val="31,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,21.95;34.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,22"/>
          <dia:point val="34,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O25">
        <dia:attribute name="obj_pos">
          <dia:point val="34,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,21.9368;34.0632,23.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,22"/>
          <dia:point val="31,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O26">
        <dia:attribute name="obj_pos">
          <dia:point val="31,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,22.95;34.05,23.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,23"/>
          <dia:point val="34,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O27">
        <dia:attribute name="obj_pos">
          <dia:point val="31,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,27.95;34.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,28"/>
          <dia:point val="34,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O28">
        <dia:attribute name="obj_pos">
          <dia:point val="31,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,26.95;34.05,27.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,27"/>
          <dia:point val="34,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O29">
        <dia:attribute name="obj_pos">
          <dia:point val="31,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,25.95;34.05,26.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,26"/>
          <dia:point val="34,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O30">
        <dia:attribute name="obj_pos">
          <dia:point val="31,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,24.95;34.05,25.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,25"/>
          <dia:point val="34,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O31">
        <dia:attribute name="obj_pos">
          <dia:point val="31,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,23.95;34.05,24.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,24"/>
          <dia:point val="34,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O32">
        <dia:attribute name="obj_pos">
          <dia:point val="34,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,26.9368;34.0632,28.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,27"/>
          <dia:point val="31,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O33">
        <dia:attribute name="obj_pos">
          <dia:point val="34,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,25.9368;34.0632,27.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,26"/>
          <dia:point val="31,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O34">
        <dia:attribute name="obj_pos">
          <dia:point val="34,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,24.9368;34.0632,26.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,25"/>
          <dia:point val="31,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O35">
        <dia:attribute name="obj_pos">
          <dia:point val="34,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,23.9368;34.0632,25.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,24"/>
          <dia:point val="31,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O36">
        <dia:attribute name="obj_pos">
          <dia:point val="34,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,22.9368;34.0632,24.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,23"/>
          <dia:point val="31,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O37">
        <dia:attribute name="obj_pos">
          <dia:point val="34,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,27.9368;34.0632,29.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,28"/>
          <dia:point val="31,29"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O38">
        <dia:attribute name="obj_pos">
          <dia:point val="41,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="40.95,21.95;43.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="41,22"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="6"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O39">
        <dia:attribute name="obj_pos">
          <dia:point val="42,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="41.95,27.95;42.05,29.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="42,29"/>
          <dia:point val="42,28"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O38" connection="6"/>
        </dia:connections>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O40">
        <dia:attribute name="obj_pos">
          <dia:point val="42,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="41.95,20.95;42.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="42,21"/>
          <dia:point val="42,22"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O38" connection="1"/>
        </dia:connections>
      </dia:object>
    </dia:group>
    <dia:object type="Standard - Text" version="0" id="O41">
      <dia:attribute name="obj_pos">
        <dia:point val="1.205,1.87"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.205,0.47;11.505,2.87"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Supported bar#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="1.205,1.87"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O42">
      <dia:attribute name="obj_pos">
        <dia:point val="9.875,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.825,9.95;35.3089,13.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="9.875,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="25.383883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#RigidBar2D:bar#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="22.5669,12.3536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O43">
      <dia:attribute name="obj_pos">
        <dia:point val="2.03125,18.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.98125,18.45;15.2151,21.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.03125,18.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.133883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Support:left#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.59819,20.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O44">
      <dia:attribute name="obj_pos">
        <dia:point val="29.6563,18.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="29.6063,18.45;44.4652,21.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="29.6563,18.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="14.758883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Support:right#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.0357,20.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O45">
      <dia:attribute name="obj_pos">
        <dia:point val="3.8375,33.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="3.7875,33;13.2714,34.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="3.8375,33.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="9.3838834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.52944,34.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O46">
      <dia:attribute name="obj_pos">
        <dia:point val="5.40625,2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.35625,1.95;12.9026,3.85711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5.40625,2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.4463834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865467"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="9.12944,3.20355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O47">
      <dia:attribute name="obj_pos">
        <dia:point val="31.9,33.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="31.85,33.05;42.2089,34.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="31.9,33.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="10.258883476483179"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.0294,34.3036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O48">
      <dia:attribute name="obj_pos">
        <dia:point val="33.9688,2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="33.9188,1.95;42.3402,3.85711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="33.9688,2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="8.3213834764831809"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865467"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="38.1295,3.20355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O49">
      <dia:attribute name="obj_pos">
        <dia:point val="8.52944,33.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.48631,21.2001;9.78868,32.7055"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.52944,33.9536"/>
        <dia:point val="8.59819,19.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O45" connection="0"/>
        <dia:connection handle="1" to="O43" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O50">
      <dia:attribute name="obj_pos">
        <dia:point val="8.59819,19.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.96384,12.0405;26.7794,20.8964"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.59819,19.9036"/>
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[left_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O43" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O51">
      <dia:attribute name="obj_pos">
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.45587,1.53476;25.6693,11.6947"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="22.5669,11.9036"/>
        <dia:point val="9.12944,2.90355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[left_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O42" connection="0"/>
        <dia:connection handle="1" to="O46" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O52">
      <dia:attribute name="obj_pos">
        <dia:point val="37.0294,34.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.9416,21.2077;38.2348,32.7502"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.0294,34.0036"/>
        <dia:point val="37.0357,19.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O47" connection="0"/>
        <dia:connection handle="1" to="O44" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O53">
      <dia:attribute name="obj_pos">
        <dia:point val="37.0357,19.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.91,10.4454;37.1788,19.7296"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.0357,19.9036"/>
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[right_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O44" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O54">
      <dia:attribute name="obj_pos">
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9314,3.04226;38.2973,12.8921"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="22.5669,11.9036"/>
        <dia:point val="38.1294,2.90355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[right_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O42" connection="0"/>
        <dia:connection handle="1" to="O48" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/SupportedBar_lbl.txt version [cd511778a3].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY SupportedBar
#DESCRIPTION Rigid 2D bar with two spring-damper supports.

## System SupportedBar, representation lbl, language txt
## File SupportedBar_lbl.txt
## Generated by MTT on Thu Aug 12 21:17:30 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	left_bottom,right_bottom
#ALIAS	out	left_top,right_top

## Argument aliases
#ALIAS	$1	length_a
#ALIAS	$2	length_b
#ALIAS	$3	inertial_mass
#ALIAS	$4	moment_of_inertia
#ALIAS	$5	resistance
#ALIAS	$6	stiffness

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[left_bottom]	SS	external,external
	[left_top]	SS	external,external
	[right_bottom]	SS	external,external
	[right_top]	SS	external,external

## Component type RigidBar2D
	bar		none	length_a;length_b;inertial_mass;moment_of_inertia

## Component type Support
	left		none	resistance;stiffness
	right		none	resistance;stiffness

Added mtt/lib/examples/Dia/doubleOscillator/diaOscillator_abg.dia version [5b84649c7c].

















































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="2,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.95,8.95;5.62138,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.5713834764831831"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865465"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[in]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="3.78569,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="12,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="11.95,8.95;14.05,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="12,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="13,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="11,2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.95,1.95;14.9964,3.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="11,2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.9463834764831822"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#I:inductance#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="12.9732,3.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="10,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.95,15.95;15.9339,17.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="10,16"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#R:resistance#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="12.9419,17.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="22,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.95,8.95;24.05,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="22,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="19.55,2.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.5,2;26.1714,3.70711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="19.55,2.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.5713834764831898"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#C:capacitance#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="22.8357,3.10355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="30,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="29.95,8.95;34.2464,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="30,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.1963834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[out]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="32.0982,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="3.78569,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.73569,7.95355;12.1116,10.6469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="3.78569,9.80355"/>
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O0" connection="0"/>
        <dia:connection handle="1" to="O1" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.8835,3.14895;14.1962,8.99896"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="13,9.80355"/>
        <dia:point val="12.9732,2.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O2" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.8564,10.1635;14.1917,16.0136"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="13,9.80355"/>
        <dia:point val="12.9419,16.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="13.95,7.95355;22.1116,10.6469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="13,9.80355"/>
        <dia:point val="23,9.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O4" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="23,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.7848,4.02881;24.1558,8.12156"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23,9.80355"/>
        <dia:point val="22.8357,2.85355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O4" connection="0"/>
        <dia:connection handle="1" to="O5" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="23,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.95,7.95355;31.2098,10.6469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23,9.80355"/>
        <dia:point val="32.0982,9.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O4" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/doubleOscillator/diaOscillator_lbl.txt version [880a7a089a].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY diaOscillator
#DESCRIPTION Detailed description here

## System diaOscillator, representation lbl, language txt
## File diaOscillator_lbl.txt
## Generated by MTT on Thu Aug  5 00:44:20 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	capacitance
#ALIAS	$2	inductance
#ALIAS	$3	resistance

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type C
	capacitance	lin		effort,capacitance		

## Component type SS
	[in]		SS		external,external		

## Component type I
	inductance	lin		flow,inductance		

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type R
	resistance	lin		flow,resistance		

## Component type SS
	[out]		SS		external,external		

Added mtt/lib/examples/Dia/doubleOscillator/doubleOscillator_abg.dia version [bff195aa42].

























































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="2,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.95,5.95;4.99638,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.9463834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:in#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="3.47319,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="11,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.95,5.95;18.1214,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="11,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.0713834764831853"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811864905"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#diaOscillator:do#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="14.5357,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="24,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.95,5.95;31.1214,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.0713834764831791"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#xfigOscillator:xo#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="27.5357,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="37,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.95,5.95;40.6214,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="37,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.5713834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:out#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="38.7857,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="3.47319,6.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.42319,4.95355;13.6473,7.64685"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="3.47319,6.80355"/>
        <dia:point val="14.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O0" connection="0"/>
        <dia:connection handle="1" to="O1" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="14.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.4857,4.95355;26.6473,7.64685"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="14.5357,6.80355"/>
        <dia:point val="27.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O2" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="27.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="28.4857,4.95355;37.8973,7.64685"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="27.5357,6.80355"/>
        <dia:point val="38.7857,6.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O2" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/doubleOscillator/doubleOscillator_lbl.txt version [0873041d17].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY doubleOscillator
#DESCRIPTION Detailed description here

## System doubleOscillator, representation lbl, language txt
## File doubleOscillator_lbl.txt
## Generated by MTT on Thu Aug  5 00:44:56 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases
#ALIAS	$1	capacitance
#ALIAS	$2	inductance
#ALIAS	$3	resistance

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type diaOscillator
	do	lin		C_d;L_d;R_d

## Component type SS
	in	SS		external,external		

## Component type xfigOscillator
	xo	lin		C_x;L_x;R_x

## Component type SS
	out	SS		external,external		

Added mtt/lib/examples/Dia/doubleOscillator/xfigOscillator_abg.fig version [3b0f42ccdb].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 720 3105 1620 3420
4 2 4 100 0 18 18 0.0000 4 270 900 1620 3330 SS:[in]\001
-6
6 1800 3150 3240 3465
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1845 3195 3195 3195 2970 3420
-6
6 3420 1530 3780 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3465 2925 3465 1575 3690 1800
-6
6 3150 3510 3510 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3465 3555 3465 4905 3240 4680
-6
6 3780 3150 5220 3465
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 3195 5175 3195 4950 3420
-6
6 3420 3105 3600 3330
4 1 0 100 0 18 18 0.0000 4 195 150 3510 3330 1\001
-6
6 5310 3015 5490 3240
4 1 0 100 0 18 18 0.0000 4 195 150 5400 3240 0\001
-6
6 5400 1440 5760 2880
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5445 2835 5445 1485 5670 1710
-6
6 5670 3150 7110 3465
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5715 3195 7065 3195 6840 3420
-6
6 7245 3105 8370 3420
4 0 4 100 0 18 18 0.0000 4 270 1095 7245 3330 SS:[out]\001
-6
6 2970 990 4050 1260
4 1 0 100 0 18 18 0.0000 4 210 1005 3510 1260 I:inductance\001
-6
6 4410 990 6480 1350
4 1 0 100 0 18 18 0.0000 4 270 1965 5445 1260 C:capacitance\001
-6
6 2610 5040 4410 5310
4 1 0 100 0 18 18 0.0000 4 210 1725 3510 5310 R:resistance\001
-6

Added mtt/lib/examples/Dia/doubleOscillator/xfigOscillator_lbl.txt version [294f2256a6].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY xfigOscillator
#DESCRIPTION Detailed description here

## System xfigOscillator, representation lbl, language txt
## File xfigOscillator_lbl.txt
## Generated by MTT on Thu Aug  5 00:41:52 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	capacitance
#ALIAS	$2	inductance
#ALIAS	$3	resistance

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type C
	capacitance	lin		effort,capacitance		

## Component type I
	inductance	lin		flow,inductance		

## Component type R
	resistance	lin		flow,resistance		

## Component type SS
	[in]		SS		external,external		
	[out]		SS		external,external		

Added mtt/lib/examples/Dia/robotrain/make_trajectory.sh version [4193eb4c97].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
mtt -cc -no-reduce robotrain odeso ps
cd MTT_work
#set data style lines
cat <<EOF | gnuplot
set timestamp
set key left
set xlabel 'x'
set ylabel 'y'
set grid 
set title 'MTT model "robotrain": trajectory of trailer links'
plot   'robotrain_odes.dat2' using 4:5   title 'front'
replot 'robotrain_odes.dat2' using 8:9   title 'middle'
replot 'robotrain_odes.dat2' using 12:13 title 'rear'
set terminal postscript eps
set output "trajectory.ps"
replot
EOF
cd ..
cp MTT_work/trajectory.ps .
gv trajectory.ps

Added mtt/lib/examples/Dia/robotrain/robotrain_abg.dia version [b25c902b91].









































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O0">
        <dia:attribute name="obj_pos">
          <dia:point val="-19.4638,25.0343"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-19.5138,24.9843;-15.7138,25.9843"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-19.4638,25.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O1">
        <dia:attribute name="obj_pos">
          <dia:point val="-19.5338,9.06926"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-19.5838,9.01926;-15.7838,10.0193"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-19.5338,9.06926"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O2">
        <dia:attribute name="obj_pos">
          <dia:point val="-25.5138,10.0343"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-25.5638,9.98426;-9.66383,25.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-25.5138,10.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O3">
        <dia:attribute name="obj_pos">
          <dia:point val="-23.6138,7.18426"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-23.6638,7.13426;-11.5638,9.08426"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-23.6138,7.18426"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O4">
        <dia:attribute name="obj_pos">
          <dia:point val="-23.6131,25.9486"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-23.6631,25.8986;-11.5631,27.8486"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-23.6131,25.9486"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O5">
        <dia:attribute name="obj_pos">
          <dia:point val="-9.71383,16.0343"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-9.76383,15.9843;3.63617,17.9843"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-9.71383,16.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O6">
        <dia:attribute name="obj_pos">
          <dia:point val="-38.8338,16.1193"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-38.8838,16.0693;-25.4838,18.0693"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-38.8338,16.1193"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O7">
        <dia:attribute name="obj_pos">
          <dia:point val="1.98617,16.4843"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="1.93617,16.4343;3.03617,17.5343"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1.98617,16.4843"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O8">
        <dia:attribute name="obj_pos">
          <dia:point val="-38.3138,16.5843"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-38.3638,16.5343;-37.2638,17.6343"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-38.3138,16.5843"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
    <dia:object type="Standard - Text" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="-38.601,4.96345"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-38.601,3.8797;-10.2172,6.28095"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Train of passive off-hooked trailers pulled by a tractor#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-38.601,4.96345"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O10">
        <dia:attribute name="obj_pos">
          <dia:point val="21.15,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="21.1,24.95;24.9,25.95"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="21.15,25"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O11">
        <dia:attribute name="obj_pos">
          <dia:point val="21.08,9.035"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="21.03,8.985;24.83,9.985"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="21.08,9.035"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O12">
        <dia:attribute name="obj_pos">
          <dia:point val="15.1,10"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="15.05,9.95;30.95,25"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="15.1,10"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O13">
        <dia:attribute name="obj_pos">
          <dia:point val="17,7.15"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="16.95,7.1;29.05,9.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="17,7.15"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O14">
        <dia:attribute name="obj_pos">
          <dia:point val="17.0007,25.9143"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="16.9507,25.8643;29.0507,27.8143"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="17.0007,25.9143"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O15">
        <dia:attribute name="obj_pos">
          <dia:point val="30.9,16"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.85,15.95;44.25,17.95"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="30.9,16"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O16">
        <dia:attribute name="obj_pos">
          <dia:point val="1.78,16.085"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="1.73,16.035;15.13,18.035"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1.78,16.085"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O17">
        <dia:attribute name="obj_pos">
          <dia:point val="42.6,16.45"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="42.55,16.4;43.65,17.5"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="42.6,16.45"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O18">
        <dia:attribute name="obj_pos">
          <dia:point val="2.3,16.55"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.25,16.5;3.35,17.6"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="2.3,16.55"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O19">
        <dia:attribute name="obj_pos">
          <dia:point val="61.8543,24.9636"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="61.8043,24.9136;65.6043,25.9136"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="61.8543,24.9636"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O20">
        <dia:attribute name="obj_pos">
          <dia:point val="61.7843,8.99855"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="61.7343,8.94855;65.5343,9.94855"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="61.7843,8.99855"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O21">
        <dia:attribute name="obj_pos">
          <dia:point val="55.8043,9.96355"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="55.7543,9.91355;71.6543,24.9636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="55.8043,9.96355"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O22">
        <dia:attribute name="obj_pos">
          <dia:point val="57.7043,7.11355"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="57.6543,7.06355;69.7543,9.01355"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="57.7043,7.11355"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O23">
        <dia:attribute name="obj_pos">
          <dia:point val="57.705,25.8779"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="57.655,25.8279;69.755,27.7779"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="57.705,25.8779"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O24">
        <dia:attribute name="obj_pos">
          <dia:point val="71.6043,15.9636"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="71.5543,15.9136;84.9543,17.9136"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="71.6043,15.9636"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O25">
        <dia:attribute name="obj_pos">
          <dia:point val="42.4843,16.0486"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="42.4343,15.9986;55.8343,17.9986"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="42.4843,16.0486"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O26">
        <dia:attribute name="obj_pos">
          <dia:point val="83.3043,16.4136"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="83.2543,16.3636;84.3543,17.4636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="83.3043,16.4136"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O27">
        <dia:attribute name="obj_pos">
          <dia:point val="43.0043,16.5136"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="42.9543,16.4636;44.0543,17.5636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="43.0043,16.5136"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O28">
        <dia:attribute name="obj_pos">
          <dia:point val="102.295,24.8586"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="102.245,24.8086;106.045,25.8086"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="102.295,24.8586"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O29">
        <dia:attribute name="obj_pos">
          <dia:point val="102.225,8.89358"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="102.175,8.84358;105.975,9.84358"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="102.225,8.89358"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O30">
        <dia:attribute name="obj_pos">
          <dia:point val="96.245,9.85858"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="96.195,9.80858;112.095,24.8586"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="96.245,9.85858"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O31">
        <dia:attribute name="obj_pos">
          <dia:point val="98.145,7.00858"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="98.095,6.95858;110.195,8.90858"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="98.145,7.00858"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O32">
        <dia:attribute name="obj_pos">
          <dia:point val="98.1457,25.7729"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="98.0957,25.7229;110.196,27.6729"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="98.1457,25.7729"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O33">
        <dia:attribute name="obj_pos">
          <dia:point val="82.925,15.9436"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="82.875,15.8936;96.275,17.8936"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="82.925,15.9436"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O34">
        <dia:attribute name="obj_pos">
          <dia:point val="83.696,16.4136"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="83.646,16.3636;84.746,17.4636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="83.696,16.4136"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O35">
      <dia:attribute name="obj_pos">
        <dia:point val="85.5336,31.7414"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="85.4836,31.6914;116.405,36.895"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="85.5336,31.7414"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="30.821383476483206"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865431"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#tractor:tractor#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="100.944,34.945"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O36">
      <dia:attribute name="obj_pos">
        <dia:point val="48.5625,31.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="48.5125,31.45;74.1839,36.6536"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="48.5625,31.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="25.571383476483181"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#trailer:front#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="61.3482,34.7036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O37">
      <dia:attribute name="obj_pos">
        <dia:point val="-26.1285,31.6414"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-26.1785,31.5914;-2.19462,36.795"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-26.1285,31.6414"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="23.883883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#trailer:rear#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-14.1866,34.845"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O38">
      <dia:attribute name="obj_pos">
        <dia:point val="7.47476,31.4293"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.42476,31.3793;36.8461,36.5829"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="7.47476,31.4293"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="29.321383476483192"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#trailer:middle#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="22.1355,34.6329"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O39">
      <dia:attribute name="obj_pos">
        <dia:point val="100.944,34.145"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="62.1251,32.0597;100.045,34.855"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="100.944,34.145"/>
        <dia:point val="61.3482,33.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.20000000000000001"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O35" connection="0"/>
        <dia:connection handle="1" to="O36" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O40">
      <dia:attribute name="obj_pos">
        <dia:point val="61.3482,33.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9123,31.9846;60.4484,34.7738"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="61.3482,33.9036"/>
        <dia:point val="22.1355,33.8328"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.20000000000000001"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O36" connection="0"/>
        <dia:connection handle="1" to="O38" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O41">
      <dia:attribute name="obj_pos">
        <dia:point val="22.1355,33.8328"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-13.4099,31.9887;21.2361,34.9674"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="22.1355,33.8328"/>
        <dia:point val="-14.1866,34.045"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.20000000000000001"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O38" connection="0"/>
        <dia:connection handle="1" to="O37" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O42">
      <dia:attribute name="obj_pos">
        <dia:point val="-22.8801,23.9695"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-22.9301,23.9195;-18.8212,25.8266"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-22.8801,23.9695"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.0088834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811866759"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:Fx#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-20.8757,25.1731"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O43">
      <dia:attribute name="obj_pos">
        <dia:point val="-22.1529,41.1213"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-22.2029,41.0713;-18.094,42.9784"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-22.1529,41.1213"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.0088834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:Fy#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-20.1485,42.3249"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O44">
      <dia:attribute name="obj_pos">
        <dia:point val="-14.1866,34.045"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-20.3981,24.3239;-12.6063,33.7783"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="-14.1866,34.045"/>
        <dia:point val="-20.8757,24.873"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O37" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O45">
      <dia:attribute name="obj_pos">
        <dia:point val="-14.1866,34.045"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-19.6616,34.2973;-12.6238,42.142"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="-14.1866,34.045"/>
        <dia:point val="-20.1485,42.0249"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O37" connection="0"/>
        <dia:connection handle="1" to="O43" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/robotrain/robotrain_abg.ps version [2650070c06].





























































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%!PS-Adobe-2.0 EPSF-2.0
%%Title: robotrain_abg.dia
%%Creator: Dia v0.94
%%CreationDate: Tue Sep 14 20:01:52 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 4402 1118
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
38.883800 -42.978407 translate
%%EndProlog


0.749020 0.749020 0.749020 srgb
n -19.463800 25.034300 m -19.463800 25.934300 l -15.763800 25.934300 l -15.763800 25.034300 l f
n -19.463800 25.034300 m -19.463800 25.034300 0.000000 0.000000 180.000000 270.000000 ellipse f
n -15.763800 25.034300 m -15.763800 25.034300 0.000000 0.000000 270.000000 360.000000 ellipse f
n -19.463800 25.034300 m -19.463800 25.934300 l -15.763800 25.934300 l -15.763800 25.034300 l f
n -19.463800 25.934300 m -19.463800 25.934300 0.000000 0.000000 90.000000 180.000000 ellipse f
n -15.763800 25.934300 m -15.763800 25.934300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n -19.463800 25.034300 m -15.763800 25.034300 l s
n -19.463800 25.934300 m -15.763800 25.934300 l s
n -19.463800 25.034300 0.000000 0.000000 180.000000 270.000000 ellipse s
n -15.763800 25.034300 0.000000 0.000000 270.000000 360.000000 ellipse s
n -19.463800 25.034300 m -19.463800 25.934300 l s
n -15.763800 25.034300 m -15.763800 25.934300 l s
n -19.463800 25.934300 0.000000 0.000000 90.000000 180.000000 ellipse s
n -15.763800 25.934300 0.000000 0.000000 0.000000 90.000000 ellipse s
n -19.533800 9.069260 m -19.533800 9.969260 l -15.833800 9.969260 l -15.833800 9.069260 l f
n -19.533800 9.069260 m -19.533800 9.069260 0.000000 0.000000 180.000000 270.000000 ellipse f
n -15.833800 9.069260 m -15.833800 9.069260 0.000000 0.000000 270.000000 360.000000 ellipse f
n -19.533800 9.069260 m -19.533800 9.969260 l -15.833800 9.969260 l -15.833800 9.069260 l f
n -19.533800 9.969260 m -19.533800 9.969260 0.000000 0.000000 90.000000 180.000000 ellipse f
n -15.833800 9.969260 m -15.833800 9.969260 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n -19.533800 9.069260 m -15.833800 9.069260 l s
n -19.533800 9.969260 m -15.833800 9.969260 l s
n -19.533800 9.069260 0.000000 0.000000 180.000000 270.000000 ellipse s
n -15.833800 9.069260 0.000000 0.000000 270.000000 360.000000 ellipse s
n -19.533800 9.069260 m -19.533800 9.969260 l s
n -15.833800 9.069260 m -15.833800 9.969260 l s
n -19.533800 9.969260 0.000000 0.000000 90.000000 180.000000 ellipse s
n -15.833800 9.969260 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n -25.513800 10.034300 m -25.513800 24.984300 l -9.713800 24.984300 l -9.713800 10.034300 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -25.513800 10.034300 m -25.513800 24.984300 l -9.713800 24.984300 l -9.713800 10.034300 l cp s
0.749020 0.749020 0.749020 srgb
n -23.613800 7.184260 m -23.613800 9.034260 l -11.613800 9.034260 l -11.613800 7.184260 l f
n -23.613800 7.184260 m -23.613800 7.184260 0.000000 0.000000 180.000000 270.000000 ellipse f
n -11.613800 7.184260 m -11.613800 7.184260 0.000000 0.000000 270.000000 360.000000 ellipse f
n -23.613800 7.184260 m -23.613800 9.034260 l -11.613800 9.034260 l -11.613800 7.184260 l f
n -23.613800 9.034260 m -23.613800 9.034260 0.000000 0.000000 90.000000 180.000000 ellipse f
n -11.613800 9.034260 m -11.613800 9.034260 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -23.613800 7.184260 m -11.613800 7.184260 l s
n -23.613800 9.034260 m -11.613800 9.034260 l s
n -23.613800 7.184260 0.000000 0.000000 180.000000 270.000000 ellipse s
n -11.613800 7.184260 0.000000 0.000000 270.000000 360.000000 ellipse s
n -23.613800 7.184260 m -23.613800 9.034260 l s
n -11.613800 7.184260 m -11.613800 9.034260 l s
n -23.613800 9.034260 0.000000 0.000000 90.000000 180.000000 ellipse s
n -11.613800 9.034260 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n -23.613100 25.948600 m -23.613100 27.798600 l -11.613100 27.798600 l -11.613100 25.948600 l f
n -23.613100 25.948600 m -23.613100 25.948600 0.000000 0.000000 180.000000 270.000000 ellipse f
n -11.613100 25.948600 m -11.613100 25.948600 0.000000 0.000000 270.000000 360.000000 ellipse f
n -23.613100 25.948600 m -23.613100 27.798600 l -11.613100 27.798600 l -11.613100 25.948600 l f
n -23.613100 27.798600 m -23.613100 27.798600 0.000000 0.000000 90.000000 180.000000 ellipse f
n -11.613100 27.798600 m -11.613100 27.798600 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -23.613100 25.948600 m -11.613100 25.948600 l s
n -23.613100 27.798600 m -11.613100 27.798600 l s
n -23.613100 25.948600 0.000000 0.000000 180.000000 270.000000 ellipse s
n -11.613100 25.948600 0.000000 0.000000 270.000000 360.000000 ellipse s
n -23.613100 25.948600 m -23.613100 27.798600 l s
n -11.613100 25.948600 m -11.613100 27.798600 l s
n -23.613100 27.798600 0.000000 0.000000 90.000000 180.000000 ellipse s
n -11.613100 27.798600 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n -9.713830 16.034300 m -9.713830 17.934300 l 3.586170 17.934300 l 3.586170 16.034300 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -9.713830 16.034300 m -9.713830 17.934300 l 3.586170 17.934300 l 3.586170 16.034300 l cp s
1.000000 1.000000 1.000000 srgb
n -38.833800 16.119300 m -38.833800 18.019300 l -25.533800 18.019300 l -25.533800 16.119300 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -38.833800 16.119300 m -38.833800 18.019300 l -25.533800 18.019300 l -25.533800 16.119300 l cp s
1.000000 1.000000 1.000000 srgb
n 2.486170 16.984300 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.486170 16.984300 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n -37.813800 17.084300 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n -37.813800 17.084300 0.500000 0.500000 0 360 ellipse cp s
/Helvetica-latin1 ff 1.400000 scf sf
(Train of passive off-hooked trailers pulled by a tractor) -38.601000 4.963450 m gs 1 -1 sc sh gr
0.749020 0.749020 0.749020 srgb
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.000000 m 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.850000 25.000000 m 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.900000 m 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.850000 25.900000 m 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.150000 25.000000 m 24.850000 25.000000 l s
n 21.150000 25.900000 m 24.850000 25.900000 l s
n 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.150000 25.000000 m 21.150000 25.900000 l s
n 24.850000 25.000000 m 24.850000 25.900000 l s
n 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.035000 m 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.780000 9.035000 m 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.935000 m 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.780000 9.935000 m 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.080000 9.035000 m 24.780000 9.035000 l s
n 21.080000 9.935000 m 24.780000 9.935000 l s
n 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l s
n 24.780000 9.035000 m 24.780000 9.935000 l s
n 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l cp s
0.749020 0.749020 0.749020 srgb
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 7.150000 m 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000000 7.150000 m 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 9.000000 m 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000000 9.000000 m 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000000 7.150000 m 29.000000 7.150000 l s
n 17.000000 9.000000 m 29.000000 9.000000 l s
n 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000000 7.150000 m 17.000000 9.000000 l s
n 29.000000 7.150000 m 29.000000 9.000000 l s
n 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 25.914300 m 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000700 25.914300 m 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 27.764300 m 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000700 27.764300 m 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000700 25.914300 m 29.000700 25.914300 l s
n 17.000700 27.764300 m 29.000700 27.764300 l s
n 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000700 25.914300 m 17.000700 27.764300 l s
n 29.000700 25.914300 m 29.000700 27.764300 l s
n 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l cp s
1.000000 1.000000 1.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l cp s
1.000000 1.000000 1.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse cp s
0.749020 0.749020 0.749020 srgb
n 61.854300 24.963600 m 61.854300 25.863600 l 65.554300 25.863600 l 65.554300 24.963600 l f
n 61.854300 24.963600 m 61.854300 24.963600 0.000000 0.000000 180.000000 270.000000 ellipse f
n 65.554300 24.963600 m 65.554300 24.963600 0.000000 0.000000 270.000000 360.000000 ellipse f
n 61.854300 24.963600 m 61.854300 25.863600 l 65.554300 25.863600 l 65.554300 24.963600 l f
n 61.854300 25.863600 m 61.854300 25.863600 0.000000 0.000000 90.000000 180.000000 ellipse f
n 65.554300 25.863600 m 65.554300 25.863600 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 61.854300 24.963600 m 65.554300 24.963600 l s
n 61.854300 25.863600 m 65.554300 25.863600 l s
n 61.854300 24.963600 0.000000 0.000000 180.000000 270.000000 ellipse s
n 65.554300 24.963600 0.000000 0.000000 270.000000 360.000000 ellipse s
n 61.854300 24.963600 m 61.854300 25.863600 l s
n 65.554300 24.963600 m 65.554300 25.863600 l s
n 61.854300 25.863600 0.000000 0.000000 90.000000 180.000000 ellipse s
n 65.554300 25.863600 0.000000 0.000000 0.000000 90.000000 ellipse s
n 61.784300 8.998550 m 61.784300 9.898550 l 65.484300 9.898550 l 65.484300 8.998550 l f
n 61.784300 8.998550 m 61.784300 8.998550 0.000000 0.000000 180.000000 270.000000 ellipse f
n 65.484300 8.998550 m 65.484300 8.998550 0.000000 0.000000 270.000000 360.000000 ellipse f
n 61.784300 8.998550 m 61.784300 9.898550 l 65.484300 9.898550 l 65.484300 8.998550 l f
n 61.784300 9.898550 m 61.784300 9.898550 0.000000 0.000000 90.000000 180.000000 ellipse f
n 65.484300 9.898550 m 65.484300 9.898550 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 61.784300 8.998550 m 65.484300 8.998550 l s
n 61.784300 9.898550 m 65.484300 9.898550 l s
n 61.784300 8.998550 0.000000 0.000000 180.000000 270.000000 ellipse s
n 65.484300 8.998550 0.000000 0.000000 270.000000 360.000000 ellipse s
n 61.784300 8.998550 m 61.784300 9.898550 l s
n 65.484300 8.998550 m 65.484300 9.898550 l s
n 61.784300 9.898550 0.000000 0.000000 90.000000 180.000000 ellipse s
n 65.484300 9.898550 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 55.804300 9.963550 m 55.804300 24.913550 l 71.604300 24.913550 l 71.604300 9.963550 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 55.804300 9.963550 m 55.804300 24.913550 l 71.604300 24.913550 l 71.604300 9.963550 l cp s
0.749020 0.749020 0.749020 srgb
n 57.704300 7.113550 m 57.704300 8.963550 l 69.704300 8.963550 l 69.704300 7.113550 l f
n 57.704300 7.113550 m 57.704300 7.113550 0.000000 0.000000 180.000000 270.000000 ellipse f
n 69.704300 7.113550 m 69.704300 7.113550 0.000000 0.000000 270.000000 360.000000 ellipse f
n 57.704300 7.113550 m 57.704300 8.963550 l 69.704300 8.963550 l 69.704300 7.113550 l f
n 57.704300 8.963550 m 57.704300 8.963550 0.000000 0.000000 90.000000 180.000000 ellipse f
n 69.704300 8.963550 m 69.704300 8.963550 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 57.704300 7.113550 m 69.704300 7.113550 l s
n 57.704300 8.963550 m 69.704300 8.963550 l s
n 57.704300 7.113550 0.000000 0.000000 180.000000 270.000000 ellipse s
n 69.704300 7.113550 0.000000 0.000000 270.000000 360.000000 ellipse s
n 57.704300 7.113550 m 57.704300 8.963550 l s
n 69.704300 7.113550 m 69.704300 8.963550 l s
n 57.704300 8.963550 0.000000 0.000000 90.000000 180.000000 ellipse s
n 69.704300 8.963550 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 57.705000 25.877900 m 57.705000 27.727900 l 69.705000 27.727900 l 69.705000 25.877900 l f
n 57.705000 25.877900 m 57.705000 25.877900 0.000000 0.000000 180.000000 270.000000 ellipse f
n 69.705000 25.877900 m 69.705000 25.877900 0.000000 0.000000 270.000000 360.000000 ellipse f
n 57.705000 25.877900 m 57.705000 27.727900 l 69.705000 27.727900 l 69.705000 25.877900 l f
n 57.705000 27.727900 m 57.705000 27.727900 0.000000 0.000000 90.000000 180.000000 ellipse f
n 69.705000 27.727900 m 69.705000 27.727900 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 57.705000 25.877900 m 69.705000 25.877900 l s
n 57.705000 27.727900 m 69.705000 27.727900 l s
n 57.705000 25.877900 0.000000 0.000000 180.000000 270.000000 ellipse s
n 69.705000 25.877900 0.000000 0.000000 270.000000 360.000000 ellipse s
n 57.705000 25.877900 m 57.705000 27.727900 l s
n 69.705000 25.877900 m 69.705000 27.727900 l s
n 57.705000 27.727900 0.000000 0.000000 90.000000 180.000000 ellipse s
n 69.705000 27.727900 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 71.604300 15.963600 m 71.604300 17.863600 l 84.904300 17.863600 l 84.904300 15.963600 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 71.604300 15.963600 m 71.604300 17.863600 l 84.904300 17.863600 l 84.904300 15.963600 l cp s
1.000000 1.000000 1.000000 srgb
n 42.484300 16.048600 m 42.484300 17.948600 l 55.784300 17.948600 l 55.784300 16.048600 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 42.484300 16.048600 m 42.484300 17.948600 l 55.784300 17.948600 l 55.784300 16.048600 l cp s
1.000000 1.000000 1.000000 srgb
n 83.804300 16.913600 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 83.804300 16.913600 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n 43.504300 17.013600 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 43.504300 17.013600 0.500000 0.500000 0 360 ellipse cp s
0.749020 0.749020 0.749020 srgb
n 102.295000 24.858600 m 102.295000 25.758600 l 105.995000 25.758600 l 105.995000 24.858600 l f
n 102.295000 24.858600 m 102.295000 24.858600 0.000000 0.000000 180.000000 270.000000 ellipse f
n 105.995000 24.858600 m 105.995000 24.858600 0.000000 0.000000 270.000000 360.000000 ellipse f
n 102.295000 24.858600 m 102.295000 25.758600 l 105.995000 25.758600 l 105.995000 24.858600 l f
n 102.295000 25.758600 m 102.295000 25.758600 0.000000 0.000000 90.000000 180.000000 ellipse f
n 105.995000 25.758600 m 105.995000 25.758600 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 102.295000 24.858600 m 105.995000 24.858600 l s
n 102.295000 25.758600 m 105.995000 25.758600 l s
n 102.295000 24.858600 0.000000 0.000000 180.000000 270.000000 ellipse s
n 105.995000 24.858600 0.000000 0.000000 270.000000 360.000000 ellipse s
n 102.295000 24.858600 m 102.295000 25.758600 l s
n 105.995000 24.858600 m 105.995000 25.758600 l s
n 102.295000 25.758600 0.000000 0.000000 90.000000 180.000000 ellipse s
n 105.995000 25.758600 0.000000 0.000000 0.000000 90.000000 ellipse s
n 102.225000 8.893580 m 102.225000 9.793580 l 105.925000 9.793580 l 105.925000 8.893580 l f
n 102.225000 8.893580 m 102.225000 8.893580 0.000000 0.000000 180.000000 270.000000 ellipse f
n 105.925000 8.893580 m 105.925000 8.893580 0.000000 0.000000 270.000000 360.000000 ellipse f
n 102.225000 8.893580 m 102.225000 9.793580 l 105.925000 9.793580 l 105.925000 8.893580 l f
n 102.225000 9.793580 m 102.225000 9.793580 0.000000 0.000000 90.000000 180.000000 ellipse f
n 105.925000 9.793580 m 105.925000 9.793580 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 102.225000 8.893580 m 105.925000 8.893580 l s
n 102.225000 9.793580 m 105.925000 9.793580 l s
n 102.225000 8.893580 0.000000 0.000000 180.000000 270.000000 ellipse s
n 105.925000 8.893580 0.000000 0.000000 270.000000 360.000000 ellipse s
n 102.225000 8.893580 m 102.225000 9.793580 l s
n 105.925000 8.893580 m 105.925000 9.793580 l s
n 102.225000 9.793580 0.000000 0.000000 90.000000 180.000000 ellipse s
n 105.925000 9.793580 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 96.245000 9.858580 m 96.245000 24.808580 l 112.045000 24.808580 l 112.045000 9.858580 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 96.245000 9.858580 m 96.245000 24.808580 l 112.045000 24.808580 l 112.045000 9.858580 l cp s
0.749020 0.749020 0.749020 srgb
n 98.145000 7.008580 m 98.145000 8.858580 l 110.145000 8.858580 l 110.145000 7.008580 l f
n 98.145000 7.008580 m 98.145000 7.008580 0.000000 0.000000 180.000000 270.000000 ellipse f
n 110.145000 7.008580 m 110.145000 7.008580 0.000000 0.000000 270.000000 360.000000 ellipse f
n 98.145000 7.008580 m 98.145000 8.858580 l 110.145000 8.858580 l 110.145000 7.008580 l f
n 98.145000 8.858580 m 98.145000 8.858580 0.000000 0.000000 90.000000 180.000000 ellipse f
n 110.145000 8.858580 m 110.145000 8.858580 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 98.145000 7.008580 m 110.145000 7.008580 l s
n 98.145000 8.858580 m 110.145000 8.858580 l s
n 98.145000 7.008580 0.000000 0.000000 180.000000 270.000000 ellipse s
n 110.145000 7.008580 0.000000 0.000000 270.000000 360.000000 ellipse s
n 98.145000 7.008580 m 98.145000 8.858580 l s
n 110.145000 7.008580 m 110.145000 8.858580 l s
n 98.145000 8.858580 0.000000 0.000000 90.000000 180.000000 ellipse s
n 110.145000 8.858580 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 98.145700 25.772900 m 98.145700 27.622900 l 110.145700 27.622900 l 110.145700 25.772900 l f
n 98.145700 25.772900 m 98.145700 25.772900 0.000000 0.000000 180.000000 270.000000 ellipse f
n 110.145700 25.772900 m 110.145700 25.772900 0.000000 0.000000 270.000000 360.000000 ellipse f
n 98.145700 25.772900 m 98.145700 27.622900 l 110.145700 27.622900 l 110.145700 25.772900 l f
n 98.145700 27.622900 m 98.145700 27.622900 0.000000 0.000000 90.000000 180.000000 ellipse f
n 110.145700 27.622900 m 110.145700 27.622900 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 98.145700 25.772900 m 110.145700 25.772900 l s
n 98.145700 27.622900 m 110.145700 27.622900 l s
n 98.145700 25.772900 0.000000 0.000000 180.000000 270.000000 ellipse s
n 110.145700 25.772900 0.000000 0.000000 270.000000 360.000000 ellipse s
n 98.145700 25.772900 m 98.145700 27.622900 l s
n 110.145700 25.772900 m 110.145700 27.622900 l s
n 98.145700 27.622900 0.000000 0.000000 90.000000 180.000000 ellipse s
n 110.145700 27.622900 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 82.925000 15.943600 m 82.925000 17.843600 l 96.225000 17.843600 l 96.225000 15.943600 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 82.925000 15.943600 m 82.925000 17.843600 l 96.225000 17.843600 l 96.225000 15.943600 l cp s
1.000000 1.000000 1.000000 srgb
n 84.196000 16.913600 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 84.196000 16.913600 0.500000 0.500000 0 360 ellipse cp s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(tractor:tractor) dup sw 2 div 100.944292 ex sub 34.944953 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(trailer:front) dup sw 2 div 61.348192 ex sub 34.703553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(trailer:rear) dup sw 2 div -14.186558 ex sub 34.844953 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(trailer:middle) dup sw 2 div 22.135452 ex sub 34.632853 m gs 1 -1 sc sh gr
0.200000 slw
[] 0 sd
[] 0 sd
1 slc
n 84.483555 34.044647 m 75.184070 33.987952 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 75.184070 33.987952 m 76.478511 34.745857 l s
0.200000 slw
[] 0 sd
[] 0 sd
1 slc
n 47.512349 33.878619 m 37.845646 33.861165 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 37.845646 33.861165 m 39.143328 34.613509 l s
0.200000 slw
[] 0 sd
[] 0 sd
1 slc
n 6.428436 33.924563 m -1.194715 33.969099 l s
/Helvetica-latin1 ff 0.560000 scf sf
n -1.194715 33.969099 m 0.108682 34.711497 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:Fx) dup sw 2 div -20.875658 ex sub 25.173053 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:Fy) dup sw 2 div -20.148458 ex sub 42.324853 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n -16.559165 30.791773 m -19.592400 26.632642 l s
n -16.559165 30.791773 m -15.953196 30.349842 l s
n -16.559165 30.791773 m -17.165133 31.233703 l s
n -19.592400 26.632642 m -18.220986 27.240280 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n -16.618011 37.299401 m -18.837856 40.270626 l s
n -16.618011 37.299401 m -16.017180 37.748291 l s
n -16.618011 37.299401 m -17.218842 36.850512 l s
n -18.837856 40.270626 m -17.459526 39.678846 l s
showpage

Added mtt/lib/examples/Dia/robotrain/robotrain_desc.tex version [0e2575aeb0].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system robotrain (robotrain_desc.tex)
% Generated by MTT on Sun Sep 12 20:03:30 BST 2004.

The acausal bond graph of system \textbf{robotrain} is
displayed in Figure \Ref{fig:robotrain_abg.ps}.
The model is based on an off-hooked design of a passive multiple
trailer system for indoor service robots
\footnote{{Jaehyoung Lee, Woojin Chung, Munsang Kim, Chongwon Lee and Jeabok-Song,
    A passive multiple trailer system for indoor service robots,
    \emph{Proceedings of the 2001 IEEE/RSJ International Conference on Intelligent Robots and Systems},
    Maui, Hawaii, USA, 2001}}
The equations of motion for each trailer are given by:
\begin{align}
  v_i &= v_{i-1}\cos \phi_i+D_{i-1}\dot\theta_{i-1}\sin \phi_i\\
  \dot\theta_i &= \frac{1}{L_i}\left(v_{i-1}\sin \phi_i+D_{i-1}\dot\theta_{i-1}\cos \phi_i\right)\\
  \phi_i &= \theta_{i-1}-\theta_i
\end{align}
where $v$ and $\dot\theta$ are the translational and rotational velocity of each trailer (in the body axis system), $L$ and $D$ are the lengths of the front and rear moment arms, and the subscripts $_i$ and $_{i-1}$ refer to any trailer and the one in front of it.

The label file is listed in Section \Ref{sec:robotrain_lbl} and the
subsystems are listed in Section \Ref{sec:robotrain_sub}.

\subsection{Trajectory}
The trajectory of each of the trailer hooks in response to a constant forward and rotational velocity is shown in figure \Ref{fig:trajectory.ps}. 
\fig{trajectory}{trajectory.ps}{0.9}{Trajectory of trailer links}
The plot was generated with the following script:
\footnotesize
\verbatiminput{make_trajectory.sh}
\normalsize

Added mtt/lib/examples/Dia/robotrain/robotrain_input.txt version [cac5b175aa].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System robotrain, representation input, language txt; 
## File robotrain_input.txt; 
## Generated by MTT on Fri Sep 10 00:39:34 BST 2004; 

robotrain__Fx			= 0.0;
robotrain__Fy			= 0.0;
robotrain__tractor__omega__u	= 1.0;
robotrain__tractor__v__u	= 1.0;

Added mtt/lib/examples/Dia/robotrain/robotrain_lbl.txt version [c96da6fc3e].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY robotrain
#DESCRIPTION Detailed description here

## System robotrain, representation lbl, language txt
## File robotrain_lbl.txt
## Generated by MTT on Sun Sep 12 19:26:13 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases
#ALIAS	$1	D
#ALIAS	$2	L

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	Fx	SS		external,external		
	Fy	SS		external,external		

## Component type tractor
	tractor	lin		D

## Component type trailer
	front	lin		D;L
	middle	lin		D;L
	rear	lin		D;L

Added mtt/lib/examples/Dia/robotrain/robotrain_rep.pdf version [18154cee66].

cannot compute difference between binary files

Added mtt/lib/examples/Dia/robotrain/robotrain_rep.txt version [9f54dfcd22].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system robotrain (robotrain_rep.txt)
## Generated by MTT on" Sun Sep 12 20:02:40 BST 2004.

mtt robotrain abg tex			# The system description
#mtt robotrain cbg ps 		        # The causal bond graph
mtt robotrain struc tex	        # The system structure
mtt robotrain sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt robotrain dae tex	        # The system dae
## mtt robotrain ode tex	        # The system ode 
## mtt robotrain sspar tex		# Steady-state parameters
## mtt robotrain ss tex 		# Steady state
## mtt robotrain dm tex		# Descriptor matrices (of linearised system)
## mtt robotrain sm tex		# State matrices (of linearised system)
## mtt robotrain tf tex		# Transfer function (of linearised system)
## mtt robotrain lmfr ps		# log modulus of frequency response (of linearised system)
## mtt robotrain simpar txt		# Simulation parameters
## mtt robotrain numpar txt		# Numerical simulation parameters
mtt robotrain state txt		# Simulation initial state
mtt robotrain input txt		# Simulation input
## mtt robotrain logic txt		# Logic control
## mtt robotrain odeso ps		# Simulation output

## mtt robotrain rep txt		# This file

Added mtt/lib/examples/Dia/robotrain/robotrain_simpar.txt version [9624a81d99].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system robotrain (robotrain_simpar.txt)
# Generated by MTT on Sun Sep 12 18:45:47 BST 2004.

FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Dia/robotrain/robotrain_state.txt version [4f90410063].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System robotrain, representation state, language txt; 
## File robotrain_state.txt; 
## Generated by MTT on Sun Sep 12 18:46:40 BST 2004; 

robotrain__tractor__yaw__mttC	= 0.0;

robotrain__front__x_e__mttC	= -D;
robotrain__front__y_e__mttC	= 0.0;
robotrain__front__yaw__mttC	= 0.0;

robotrain__middle__x_e__mttC	= -(D+L+D);
robotrain__middle__y_e__mttC	= 0.0;
robotrain__middle__yaw__mttC	= 0.0;

robotrain__rear__x_e__mttC	= -(D+L+D+L+D);
robotrain__rear__y_e__mttC	= 0.0;
robotrain__rear__yaw__mttC	= 0.0;

Added mtt/lib/examples/Dia/robotrain/rotate_z.cr version [b08e480b1c].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
operator rotate_z;

let rotate_z (R,~out_causality,1,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% x1
      x2*cos(psi)-y2*sin(psi);

let rotate_z (R,~out_causality,2,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% y1
      x2*sin(psi)+y2*sin(psi);

let rotate_z (R,~out_causality,3,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% x2
      x1*cos(psi)+y1*sin(psi);

let rotate_z (R,~out_causality,4,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% y2
      -x1*sin(psi)+y1*cos(psi);

let rotate_z (R,~out_causality,5,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% x1
      0;

;end;

Added mtt/lib/examples/Dia/robotrain/rotate_z.pm version [3d31fd12d1].


























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package rotate_z;

#-------------------------------------------------------------------------------
#		rotation of x-y plane about z
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&rotate_z);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub rotate_z_R(@);		# R

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub rotate_z (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^R|r$/)	{ $retval = rotate_z_R	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# R
#-------------------------------------------------------------------------------
sub rotate_z_R (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 18-1)
    {
	my ($component,
	    $out_causality, $out_port,
	    $x1, $causality1, $port1,
	    $y1, $causality2, $port2,
	    $x2, $causality3, $port3,
	    $y2, $causality4, $port4,
	    $psi, $causality5, $port5) = @args;

	# [ x2 ]   [ +cos(psi) +sin(psi) 0 ] [ x1 ]
	# [ y2 ] = [ -sin(psi) +cos(psi) 0 ] [ y1 ]
	# [ z2 ]   [    0          0     1 ] [ z1 ]

	# for reverse transformation (x2->x1) use psi=-psi
	# note that cos(-psi)=cos(psi) and sin(-psi)=-sin(psi)

	if ($out_port == 1)	# x1
	{
	    $retval = "(($x2)*(+cos($psi))+($y2)*(-sin($psi)))";
	}
	elsif ($out_port == 2)	# y1
	{
	    $retval = "(($x2)*(+sin($psi))+($y2)*(+cos($psi)))";
	}
	elsif ($out_port == 3)	# x2
	{
	    $retval = "(($x1)*(+cos($psi))+($y1)*(+sin($psi)))";
	}
	elsif ($out_port == 4)	# y2
	{
	    $retval = "(($x1)*(-sin($psi))+($y1)*(+cos($psi)))";
	}
	elsif ($out_port == 5)
	{
	    $retval = "(0)";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Added mtt/lib/examples/Dia/robotrain/rotation_abg.dia version [df991c37a8].




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:object type="Standard - Text" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="0.9,-1.0125"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.9,-2.4125;13,-0.0125"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Rotation about Z#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="0.9,-1.0125"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="2.14556,1.95"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.09556,1.9;7.57944,3.80711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.14556,1.95"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3838834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x_1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="4.8375,3.10355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="4.2875,22.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.2375,22.45;9.65888,24.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4.2875,22.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3213834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y_1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="6.94819,23.6536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="33.6125,11.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="33.5625,11.05;39.0464,12.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="33.6125,11.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3838834764832004"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865464"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x_2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="36.3044,12.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="15.75,-2.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.7,-2.1;21.1214,-0.192893"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.75,-2.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.321383476483188"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y_2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.4107,-0.896447"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="16.1562,24.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.1062,24.4;20.7776,26.3071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="16.1562,24.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.5713834764831827"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[psi]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.4419,25.6036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a020f0"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="15.3831,11.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.3331,11;21.567,12.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.3831,11.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.1338834764831853"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186546"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#R:rotation#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.45,12.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a020f0"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="4.8375,2.85355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.06373,2.70029;10.6949,6.32361"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="4.8375,2.85355"/>
        <dia:point val="11.7419,7.36855"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O9" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="27.1,11.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.05,11.05;28.7839,12.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="27.1,11.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="27.9169,12.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="10.925,6.465"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.875,6.415;12.6089,8.32211"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="10.925,6.465"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="11.7419,7.61855"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="12.025,16.615"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="11.975,16.565;13.7089,18.4721"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="12.025,16.615"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="12.8419,17.7686"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="17.575,4.565"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.525,4.515;19.2589,6.42211"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.575,4.565"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.3919,5.71855"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="6.94819,23.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.53478,18.9813;12.1152,22.7979"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="6.94819,23.4036"/>
        <dia:point val="12.8419,17.5186"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O2" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="27.9169,12.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="29.7336,10.1536;32.6739,12.8469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="27.9169,12.0036"/>
        <dia:point val="36.3044,12.0036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="18.3919,5.46855"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.312,0.16061;19.6051,3.71831"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.3919,5.46855"/>
        <dia:point val="18.4107,-1.14645"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O4" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="11.7419,7.36855"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.498,6.29215;19.2016,11.4588"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="11.7419,7.36855"/>
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O9" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="12.8419,17.5186"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="13.481,12.5484;19.4854,17.866"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="12.8419,17.5186"/>
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O10" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.3997,10.1089;27.0286,12.8344"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.45,11.9536"/>
        <dia:point val="27.9169,12.0036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[3]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.307,5.80776;20.541,11.1429"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.45,11.9536"/>
        <dia:point val="18.3919,5.46855"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[4]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="17.3,17.8"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.25,17.75;19.6714,19.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.3,17.8"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.3213834764831809"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.80710678118655"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#AE#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.4607,18.9536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a020f0"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="18.4419,25.3536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.6575,19.057;19.6579,24.557"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.4419,25.3536"/>
        <dia:point val="18.4607,18.7036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a020f0"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O5" connection="0"/>
        <dia:connection handle="1" to="O19" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="18.4607,18.7036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.657,12.3017;20.5516,17.9017"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.4607,18.7036"/>
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a020f0"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[5]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/robotrain/rotation_abg.ps version [aeb5619686].
























































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%!PS-Adobe-2.0 EPSF-2.0
%%Title: rotation_abg.dia
%%Creator: Dia v0.94+bondgraph
%%CreationDate: Sun Sep 12 21:15:37 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 1082 815
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
-0.900000 -26.307107 translate
%%EndProlog


/Helvetica-latin1 ff 1.400000 scf sf
0.000000 0.000000 0.000000 srgb
(Rotation about Z) 0.900000 -1.012500 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.000000 0.000000 1.000000 srgb
(SS:[x_1]) dup sw 2 div 4.837502 ex sub 3.103553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(SS:[y_1]) dup sw 2 div 6.948192 ex sub 23.653553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
1.000000 0.000000 0.000000 srgb
(SS:[x_2]) dup sw 2 div 36.304442 ex sub 12.253553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(SS:[y_2]) dup sw 2 div 18.410692 ex sub -0.896447 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.627451 0.125490 0.941176 srgb
(SS:[psi]) dup sw 2 div 18.441892 ex sub 25.603553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(R:rotation) dup sw 2 div 18.450042 ex sub 12.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
0.000000 0.000000 1.000000 srgb
n 7.132941 4.354610 m 10.038120 6.254396 l s
n 10.038120 6.254396 m 8.540433 6.171136 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
1.000000 0.000000 0.000000 srgb
(0) dup sw 2 div 27.916942 ex sub 12.253553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.000000 0.000000 1.000000 srgb
(0) dup sw 2 div 11.741942 ex sub 7.618553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(0) dup sw 2 div 12.841942 ex sub 17.768553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
1.000000 0.000000 0.000000 srgb
(0) dup sw 2 div 18.391942 ex sub 5.718553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
0.000000 0.000000 1.000000 srgb
n 8.605490 21.748750 m 11.267337 19.090836 l s
n 11.267337 19.090836 m 10.878037 20.539437 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
1.000000 0.000000 0.000000 srgb
n 29.783602 12.003600 m 32.563514 12.003600 l s
n 32.563514 12.003600 m 31.264476 12.753600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.397452 3.514902 m 18.405148 0.807198 l s
n 18.405148 0.807198 m 19.151453 2.108362 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
0.000000 0.000000 1.000000 srgb
n 13.434240 8.525280 m 16.232361 10.437823 l s
n 16.232361 10.437823 m 14.736688 10.323972 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 14.418753 15.953866 m 16.780386 13.610382 l s
n 16.780386 13.610382 m 16.386571 15.057763 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
1.000000 0.000000 0.000000 srgb
n 22.566713 11.975343 m 26.049616 11.993738 l s
n 26.049616 11.993738 m 24.746634 12.736867 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.432499 10.000119 m 18.409401 7.422031 l s
n 18.409401 7.422031 m 19.171009 8.714298 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.627451 0.125490 0.941176 srgb
(AE) dup sw 2 div 18.460692 ex sub 18.953553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.447422 23.400183 m 18.455178 20.657017 l s
n 18.455178 20.657017 m 19.201502 21.958170 l s
n 18.455178 20.657017 m 17.701508 21.953930 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.457604 16.750263 m 18.453096 13.906937 l s
n 18.453096 13.906937 m 19.205155 15.204785 l s
n 18.453096 13.906937 m 17.705157 15.207163 l s
showpage

Added mtt/lib/examples/Dia/robotrain/rotation_desc.tex version [585cc1ed33].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system rotation (rotation_desc.tex)
% Generated by MTT on Sun Sep 12 22:06:34 BST 2004.

The acausal bond graph of system \textbf{rotation} is
displayed in Figure \Ref{fig:rotation_abg.ps}  
.
The label file is listed in Section \Ref{sec:rotation_lbl} and the
subsystems are listed in Section \Ref{sec:rotation_sub}.

\subsubsection{rotate\_z constitutive relationship}
The rotation between body and Earth axes is achieved using the ``rotate\_z'' constitutive relationship which is implemented as a Reduce file (.cr) and a Perl module (.pm) to permit the model to be built with or without MTT's -no-reduce option.

\paragraph{rotate\_z.cr}
\footnotesize
\verbatiminput{rotate_z.cr}
\normalsize

\paragraph{rotate\_z.pm}
\footnotesize
\verbatiminput{rotate_z.pm}
\normalsize

Added mtt/lib/examples/Dia/robotrain/rotation_lbl.txt version [6ff5537fca].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY rotation
#DESCRIPTION Detailed description here

## System rotation, representation lbl, language txt
## File rotation_lbl.txt
## Generated by MTT on Tue Sep  7 16:59:01 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	x_earth,y_earth
#ALIAS	out	x_body,y_body

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							
	# 0							
	# 0							
	# 0							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type R
	rotation	rotate_z

## Component type SS
	[psi]		SS	external,external		
	[x_body]	SS	external,external		
	[x_earth]	SS	external,external		
	[y_body]	SS	external,external		
	[y_earth]	SS	external,external		

Added mtt/lib/examples/Dia/robotrain/tractor_abg.dia version [68d89c2e44].



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.1,24.95;24.9,25.95"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.03,8.985;24.83,9.985"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.05,9.95;30.95,25"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="15.799999999999999"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="14.949999999999999"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.95,7.1;29.05,9.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.9507,25.8643;29.0507,27.8143"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.73,16.035;15.13,18.035"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.299999999999997"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.9000000000000021"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Ellipse" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.25,16.5;3.35,17.6"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="aspect">
        <dia:enum val="2"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="-3.80407,8.9651"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-3.80407,7.5651;1.24593,9.9651"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Tractor#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-3.80407,8.9651"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="5.15,34.9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.1,34.85;11.8339,36.7571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5.15,34.9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.6338834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#rotation:z2#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.46694,36.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="14.25,42.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.2,42.4;17.7464,44.3071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="14.25,42.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831915"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865451"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:D#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="15.9732,43.6536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="-5,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-5.05,34.95;-0.128617,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-5,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-2.58931,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.95,27.95;10.8714,29.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.41069,29.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,34.95;24.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="23.4,50.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.35,50.6;25.0839,52.5071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23.4,50.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="24.2169,51.8536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.7216,33.9821;22.0006,36.6842"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,35.9036"/>
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[x_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O12" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="24.2169,51.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.6078,42.558;24.3542,50.9191"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.2169,51.5536"/>
        <dia:point val="15.9732,43.3536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O9" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="15.9732,43.3536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.0103,35.9701;15.1712,41.7617"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="15.9732,43.3536"/>
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[y_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O9" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.759721,33.9931;5.58945,36.7033"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.46694,35.8036"/>
        <dia:point val="-2.58931,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.60063,30.1977;11.151,34.04"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.46694,35.8036"/>
        <dia:point val="8.41069,28.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="32,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="31.95,34.95;35.1839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="32,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.1338834764831893"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:v#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="33.5669,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="30.45,50.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="30.4,50.6;36.4464,52.5071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="30.45,50.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.9463834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:omega#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="33.4232,51.8536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="21.25,46.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.2,46.2;27.1839,48.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.25,46.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831889"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:yaw#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="24.1919,47.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="24.2169,51.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.4085,47.4968;25.4112,50.7468"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.2169,51.5536"/>
        <dia:point val="24.1919,47.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O21" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="23.4,42"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.35,41.95;25.0839,43.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23.4,42"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.633883476483186"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="24.2169,43.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="24.1919,47.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.4066,43.2606;25.411,46.3607"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.1919,47.1536"/>
        <dia:point val="24.2169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O21" connection="0"/>
        <dia:connection handle="1" to="O23" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="18.2857,39.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.05839,34.4316;17.8253,39.551"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.2857,39.9036"/>
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[psi]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O28" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="33.5669,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.7053,34.0536;32.6169,36.7469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="33.5669,35.9036"/>
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O12" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="33.4232,51.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.1053,49.7036;32.4732,52.3969"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="33.4232,51.5536"/>
        <dia:point val="24.2169,51.5536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O20" connection="0"/>
        <dia:connection handle="1" to="O13" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="14.8437,39"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.7937,38.95;21.7776,40.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="14.8437,39"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.8838834764831871"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#AE:negative#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="0" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.2856,40.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="24.2169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.1267,38.6341;23.8662,42.4858"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.2169,42.9036"/>
        <dia:point val="18.2857,39.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O23" connection="0"/>
        <dia:connection handle="1" to="O28" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/robotrain/tractor_abg.ps version [9f0629015e].



































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%!PS-Adobe-2.0 EPSF-2.0
%%Title: tractor_abg.dia
%%Creator: Dia v0.94+bondgraph
%%CreationDate: Sun Sep 12 21:15:57 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 1177 1288
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
5.050000 -52.507107 translate
%%EndProlog


0.749020 0.749020 0.749020 srgb
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.000000 m 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.850000 25.000000 m 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.900000 m 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.850000 25.900000 m 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.150000 25.000000 m 24.850000 25.000000 l s
n 21.150000 25.900000 m 24.850000 25.900000 l s
n 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.150000 25.000000 m 21.150000 25.900000 l s
n 24.850000 25.000000 m 24.850000 25.900000 l s
n 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.035000 m 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.780000 9.035000 m 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.935000 m 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.780000 9.935000 m 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.080000 9.035000 m 24.780000 9.035000 l s
n 21.080000 9.935000 m 24.780000 9.935000 l s
n 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l s
n 24.780000 9.035000 m 24.780000 9.935000 l s
n 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l cp s
0.749020 0.749020 0.749020 srgb
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 7.150000 m 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000000 7.150000 m 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 9.000000 m 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000000 9.000000 m 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000000 7.150000 m 29.000000 7.150000 l s
n 17.000000 9.000000 m 29.000000 9.000000 l s
n 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000000 7.150000 m 17.000000 9.000000 l s
n 29.000000 7.150000 m 29.000000 9.000000 l s
n 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 25.914300 m 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000700 25.914300 m 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 27.764300 m 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000700 27.764300 m 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000700 25.914300 m 29.000700 25.914300 l s
n 17.000700 27.764300 m 29.000700 27.764300 l s
n 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000700 25.914300 m 17.000700 27.764300 l s
n 29.000700 25.914300 m 29.000700 27.764300 l s
n 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l cp s
1.000000 1.000000 1.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse cp s
/Helvetica-latin1 ff 1.400000 scf sf
(Tractor) -3.804070 8.965100 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(rotation:z2) dup sw 2 div 8.466942 ex sub 36.053553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(TF:D) dup sw 2 div 15.973192 ex sub 43.653553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[x2]) dup sw 2 div -2.589308 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[y2]) dup sw 2 div 8.410692 ex sub 29.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 23.816942 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 24.216942 ex sub 51.853553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 21.950301 35.891440 m 12.833155 35.832044 l s
n 12.833155 35.832044 m 14.127279 36.590491 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.641483 49.986534 m 17.640695 45.012255 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 17.640695 45.012255 m 18.032772 46.460107 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 14.320247 41.691015 m 10.119893 37.466185 l s
n 10.119893 37.466185 m 11.567648 37.858621 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 4.100304 35.843095 m 0.871380 35.872299 l s
n 4.100304 35.843095 m 4.107087 36.593064 l s
n 4.100304 35.843095 m 4.093521 35.093125 l s
n 0.871380 35.872299 m 2.177148 36.610520 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 8.451012 33.849745 m 8.426618 30.857455 l s
n 8.451012 33.849745 m 9.200987 33.843631 l s
n 8.451012 33.849745 m 7.701037 33.855859 l s
n 8.426618 30.857455 m 9.187183 32.150336 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Sf:v) dup sw 2 div 33.566942 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Sf:omega) dup sw 2 div 33.423192 ex sub 51.853553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF:yaw) dup sw 2 div 24.191942 ex sub 47.453553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 24.205823 49.604007 m 24.202977 49.103193 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 24.202977 49.103193 m 24.960346 50.397949 l s
n 24.202977 49.103193 m 23.460370 50.406472 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(0) dup sw 2 div 24.216942 ex sub 43.203553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 24.203373 45.203178 m 24.205412 44.856616 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 24.205412 44.856616 m 24.947757 46.160043 l s
n 24.205412 44.856616 m 23.447783 46.151220 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 15.079625 38.564846 m 11.673015 37.142354 l s
n 11.673015 37.142354 m 12.582750 38.334991 l s
n 11.673015 37.142354 m 13.160736 36.950819 l s
n 11.673015 37.142354 m 11.384022 37.834440 l s
n 11.673015 37.142354 m 11.962008 36.450268 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 30.950033 35.903600 m 25.683950 35.903600 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 25.683950 35.903600 m 26.982988 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 29.399573 51.553600 m 26.082238 51.553600 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 26.082238 51.553600 m 27.381276 52.303600 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(AE:negative) dup sw 2 div 18.285642 ex sub 40.153553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.457897 42.013896 m 21.061956 41.307830 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 21.061956 41.307830 m 21.882638 42.563410 l s
n 21.061956 41.307830 m 22.559662 41.224889 l s
showpage

Added mtt/lib/examples/Dia/robotrain/tractor_lbl.txt version [9aa5974a3e].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY tractor
#DESCRIPTION Detailed description here

## System tractor, representation lbl, language txt
## File tractor_lbl.txt
## Generated by MTT on Wed Sep  8 00:42:45 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	out	x2,y2

## Argument aliases
#ALIAS	$1	D

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							
	# 1							

## Component type AE
	negative  lin		effort,-1

## Component type INTF
	yaw	  none				

## Component type SS
	[x2]	  SS		external,external		
	[y2]	  SS		external,external		

## Component type Sf
	omega	  SS		external		
	v	  SS		external		

## Component type TF
	D	  lin		flow,-D		

## Component type rotation
	z2	  rotate_z		

Added mtt/lib/examples/Dia/robotrain/trailer_abg.dia version [39ca1b3683].

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.1,24.95;24.9,25.95"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.03,8.985;24.83,9.985"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.05,9.95;30.95,25"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="15.799999999999999"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="14.949999999999999"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.95,7.1;29.05,9.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.9507,25.8643;29.0507,27.8143"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="30.9,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="30.85,15.95;44.25,17.95"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="30.9,16"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.299999999999997"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.9000000000000021"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.73,16.035;15.13,18.035"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.299999999999997"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.9000000000000021"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Ellipse" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="42.6,16.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="42.55,16.4;43.65,17.5"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="42.6,16.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="aspect">
        <dia:enum val="2"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Ellipse" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.25,16.5;3.35,17.6"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="aspect">
        <dia:enum val="2"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="-3.80407,8.9651"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-3.80407,7.5651;14.3959,9.9651"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Passive off-hooked trailer#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-3.80407,8.9651"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="34,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="33.95,34.95;40.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="34,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.6338834764831827"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#rotation:z1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.3169,36.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="5,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.95,34.95;11.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.6338834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#rotation:z2#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.31694,36.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="13,42"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.95,41.95;16.4964,43.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="13,42"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831915"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865451"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:D#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="14.7232,43.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="29,43"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="28.95,42.95;32.3714,44.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="29,43"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.3213834764831964"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:L#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="30.6607,44.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="-4,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-4.05,34.95;0.871383,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-4,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-1.58931,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.95,27.95;10.8714,29.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.41069,29.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="47.4169,36.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.2053,34.0636;46.4674,36.7702"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="47.4169,36.0036"/>
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[x_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O40" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3084,28.9743"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="37.2224,29.3228;40.0157,35.1021"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3084,28.9743"/>
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[y_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O41" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,34.95;24.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="23,52"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,51.95;24.6839,53.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,52"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,53.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.7053,34.0536;37.8169,36.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3169,35.9036"/>
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O10" connection="0"/>
        <dia:connection handle="1" to="O18" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="31.1892,36.0902;39.0998,44.1024"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3169,35.9036"/>
        <dia:point val="30.6607,43.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O10" connection="0"/>
        <dia:connection handle="1" to="O13" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.20534,34.0536;22.8669,36.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,35.9036"/>
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[x_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O18" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="30.6607,43.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.3106,44.6295;31.0106,53.034"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="30.6607,43.9036"/>
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O19" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.2855,42.1861;24.0319,52.2344"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,52.9036"/>
        <dia:point val="14.7232,42.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O12" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="14.7232,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.88165,35.1811;14.9333,42.7766"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="14.7232,42.9036"/>
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[y_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O12" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-0.700913,34.0536;8.81694,36.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.31694,35.9036"/>
        <dia:point val="-1.58931,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O14" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.47974,29.2696;11.0302,35.1198"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.31694,35.9036"/>
        <dia:point val="8.41069,28.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O15" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="21.8438,29"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.7938,28.95;25.3402,30.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.8438,29"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Df:v#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.567,30.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="20.9,56"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.85,55.95;26.8339,57.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20.9,56"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Df:omega#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8419,57.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O30">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.5128,30.2028;24.9742,35.0545"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,35.9036"/>
        <dia:point val="23.567,29.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O18" connection="0"/>
        <dia:connection handle="1" to="O28" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O31">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.7295,53.2461;25.0356,56.0961"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,52.9036"/>
        <dia:point val="23.8419,56.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O29" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O32">
      <dia:attribute name="obj_pos">
        <dia:point val="20.8,47.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.75,47;26.7339,48.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20.8,47.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831889"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:yaw#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.7419,48.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O33">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9806,48.2853;25.0016,52.0855"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,52.9036"/>
        <dia:point val="23.7419,47.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O32" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O34">
      <dia:attribute name="obj_pos">
        <dia:point val="23,42"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,41.95;24.6839,43.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,42"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.633883476483186"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,43.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O35">
      <dia:attribute name="obj_pos">
        <dia:point val="23.7419,47.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9857,43.2713;25.0019,47.1715"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.7419,47.9536"/>
        <dia:point val="23.8169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O32" connection="0"/>
        <dia:connection handle="1" to="O34" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O36">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.671,35.6422;38.3815,43.7086"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,42.9036"/>
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[psi]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O34" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O37">
      <dia:attribute name="obj_pos">
        <dia:point val="18.9357,39.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.97894,34.4438;18.3801,39.2603"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.9357,39.5536"/>
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[psi]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O38" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O38">
      <dia:attribute name="obj_pos">
        <dia:point val="15.4937,38.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.4437,38.6;22.4276,40.5071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.4937,38.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.8838834764831871"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#AE:negative#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="0" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.9356,39.8036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O39">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.7084,38.4801;23.6714,42.3725"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,42.9036"/>
        <dia:point val="18.9357,39.5536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O34" connection="0"/>
        <dia:connection handle="1" to="O38" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O40">
      <dia:attribute name="obj_pos">
        <dia:point val="46.6,35.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.55,35.05;48.2839,36.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="46.6,35.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="47.4169,36.3036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O41">
      <dia:attribute name="obj_pos">
        <dia:point val="36.4914,28.0707"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.4414,28.0207;38.1753,29.9278"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="36.4914,28.0707"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.3083,29.2743"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O42">
      <dia:attribute name="obj_pos">
        <dia:point val="44.6812,39.7"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="44.6312,39.65;50.2401,41.5571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="44.6812,39.7"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.5088834764831933"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:x_e#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="47.4357,40.9036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O43">
      <dia:attribute name="obj_pos">
        <dia:point val="39.7456,28.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39.6956,28;45.3044,29.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39.7456,28.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.5088834764831791"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:y_e#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="42.5,29.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O44">
      <dia:attribute name="obj_pos">
        <dia:point val="34.85,20.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="34.8,20.45;39.7214,22.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="34.85,20.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.821383476483188"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.2607,21.7036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O45">
      <dia:attribute name="obj_pos">
        <dia:point val="53.7,34.95"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="53.65,34.9;58.5714,36.8071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="53.7,34.95"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831871"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="56.1107,36.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O46">
      <dia:attribute name="obj_pos">
        <dia:point val="56.1107,35.8536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="48.305,34.021;55.1755,36.8061"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="56.1107,35.8536"/>
        <dia:point val="47.4169,36.0036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O45" connection="0"/>
        <dia:connection handle="1" to="O40" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O47">
      <dia:attribute name="obj_pos">
        <dia:point val="37.2607,21.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.4167,21.746;38.5021,28.1668"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.2607,21.4036"/>
        <dia:point val="37.3084,28.9743"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O44" connection="0"/>
        <dia:connection handle="1" to="O41" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O48">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3084,28.9743"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.6399,27.1169;40.0535,29.7601"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3084,28.9743"/>
        <dia:point val="42.5,28.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O41" connection="0"/>
        <dia:connection handle="1" to="O43" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O49">
      <dia:attribute name="obj_pos">
        <dia:point val="47.4169,36.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.6256,37.2919;48.6277,38.8449"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="47.4169,36.0036"/>
        <dia:point val="47.4357,40.6036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O40" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O50">
      <dia:attribute name="obj_pos">
        <dia:point val="46.5983,28.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.5483,28.1;50.0947,30.0071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="46.5983,28.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831773"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#De:y#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="48.3215,29.3536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O51">
      <dia:attribute name="obj_pos">
        <dia:point val="45.667,44.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.617,44;49.2259,45.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="45.667,44.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.5088834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#De:x#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="47.4214,45.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O52">
      <dia:attribute name="obj_pos">
        <dia:point val="42.5,28.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.5148,27.1565;46.9382,29.8257"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="42.5,28.9536"/>
        <dia:point val="48.3215,29.0536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O43" connection="0"/>
        <dia:connection handle="1" to="O50" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O53">
      <dia:attribute name="obj_pos">
        <dia:point val="47.4357,40.6036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.6356,41.6437;48.6293,43.2049"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="47.4357,40.6036"/>
        <dia:point val="47.4215,44.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O42" connection="0"/>
        <dia:connection handle="1" to="O51" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Added mtt/lib/examples/Dia/robotrain/trailer_abg.ps version [a0fab52c92].























































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%!PS-Adobe-2.0 EPSF-2.0
%%Title: trailer_abg.dia
%%Creator: Dia v0.94+bondgraph
%%CreationDate: Sun Sep 12 21:16:23 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 1776 1439
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
4.050000 -57.857107 translate
%%EndProlog


0.749020 0.749020 0.749020 srgb
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.000000 m 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.850000 25.000000 m 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.900000 m 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.850000 25.900000 m 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.150000 25.000000 m 24.850000 25.000000 l s
n 21.150000 25.900000 m 24.850000 25.900000 l s
n 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.150000 25.000000 m 21.150000 25.900000 l s
n 24.850000 25.000000 m 24.850000 25.900000 l s
n 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.035000 m 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.780000 9.035000 m 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.935000 m 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.780000 9.935000 m 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.080000 9.035000 m 24.780000 9.035000 l s
n 21.080000 9.935000 m 24.780000 9.935000 l s
n 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l s
n 24.780000 9.035000 m 24.780000 9.935000 l s
n 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l cp s
0.749020 0.749020 0.749020 srgb
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 7.150000 m 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000000 7.150000 m 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 9.000000 m 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000000 9.000000 m 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000000 7.150000 m 29.000000 7.150000 l s
n 17.000000 9.000000 m 29.000000 9.000000 l s
n 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000000 7.150000 m 17.000000 9.000000 l s
n 29.000000 7.150000 m 29.000000 9.000000 l s
n 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 25.914300 m 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000700 25.914300 m 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 27.764300 m 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000700 27.764300 m 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000700 25.914300 m 29.000700 25.914300 l s
n 17.000700 27.764300 m 29.000700 27.764300 l s
n 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000700 25.914300 m 17.000700 27.764300 l s
n 29.000700 25.914300 m 29.000700 27.764300 l s
n 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l cp s
1.000000 1.000000 1.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l cp s
1.000000 1.000000 1.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse cp s
/Helvetica-latin1 ff 1.400000 scf sf
(Passive off-hooked trailer) -3.804070 8.965100 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(rotation:z1) dup sw 2 div 37.316942 ex sub 36.153553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(rotation:z2) dup sw 2 div 8.316942 ex sub 36.153553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(TF:D) dup sw 2 div 14.723192 ex sub 43.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(TF:L) dup sw 2 div 30.660692 ex sub 44.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[x2]) dup sw 2 div -1.589308 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[y2]) dup sw 2 div 8.410692 ex sub 29.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 45.549905 35.985115 m 41.683312 35.946832 l s
n 41.683312 35.946832 m 42.974861 36.709656 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 37.310793 30.925048 m 37.314507 33.952852 l s
n 37.314507 33.952852 m 38.062913 32.652895 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 23.816942 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 23.816942 ex sub 53.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 32.949728 35.903600 m 25.684133 35.903600 l s
n 32.949728 35.903600 m 32.949728 36.653600 l s
n 32.949728 35.903600 m 32.949728 35.153600 l s
n 25.684133 35.903600 m 26.983171 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 35.883879 37.625929 m 32.093721 42.181271 l s
n 35.883879 37.625929 m 36.460416 38.105622 l s
n 35.883879 37.625929 m 35.307342 37.146236 l s
n 32.093721 42.181271 m 33.501110 41.662373 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 21.949852 35.903600 m 12.681067 35.903600 l s
n 21.949852 35.903600 m 21.949852 36.653600 l s
n 21.949852 35.903600 m 21.949852 35.153600 l s
n 12.681067 35.903600 m 13.980105 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 29.331926 45.651016 m 25.145674 51.156184 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 25.145674 51.156184 m 26.528977 50.576121 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.322407 51.260163 m 16.263229 44.597112 l s
n 16.263229 44.597112 m 17.692081 45.053599 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 13.176908 41.213996 m 9.863232 37.593204 l s
n 13.176908 41.213996 m 13.730183 40.707649 l s
n 13.176908 41.213996 m 12.623633 41.720342 l s
n 9.863232 37.593204 m 11.293525 38.045159 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 3.949758 35.903600 m 1.870928 35.903600 l s
n 3.949758 35.903600 m 3.949758 36.653600 l s
n 3.949758 35.903600 m 3.949758 35.153600 l s
n 1.870928 35.903600 m 3.169966 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 8.343080 33.951785 m 8.384550 30.855415 l s
n 8.343080 33.951785 m 9.093013 33.961829 l s
n 8.343080 33.951785 m 7.593148 33.941742 l s
n 8.384550 30.855415 m 9.117086 32.164380 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Df:v) dup sw 2 div 23.566992 ex sub 30.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Df:omega) dup sw 2 div 23.841942 ex sub 57.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.735599 33.951585 m 23.648301 31.855615 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.648301 31.855615 m 24.451710 33.122317 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.829110 54.857194 m 23.829690 54.950006 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.829110 54.857194 m 24.587214 56.151519 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF:yaw) dup sw 2 div 23.741942 ex sub 48.253553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.787299 50.949909 m 23.771501 49.907291 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.771501 49.907291 m 24.541095 51.194817 l s
n 23.771501 49.907291 m 23.041268 51.217542 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(0) dup sw 2 div 23.816942 ex sub 43.203553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.770904 46.000671 m 23.787896 44.856529 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.787896 44.856529 m 24.518523 46.166562 l s
n 23.787896 44.856529 m 23.018688 46.144287 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 25.571888 41.993606 m 34.593330 37.315821 l s
n 34.593330 37.315821 m 33.785341 38.579607 l s
n 34.593330 37.315821 m 33.094865 37.247975 l s
n 34.593330 37.315821 m 34.938568 37.981637 l s
n 34.593330 37.315821 m 34.248092 36.650006 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 15.214768 38.274599 m 12.037872 37.182601 l s
n 12.037872 37.182601 m 13.022564 38.314140 l s
n 12.037872 37.182601 m 13.510160 36.895602 l s
n 12.037872 37.182601 m 11.794074 37.891870 l s
n 12.037872 37.182601 m 12.281670 36.473332 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(AE:negative) dup sw 2 div 18.935642 ex sub 39.803553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.129609 41.745601 m 21.148531 41.072280 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 21.148531 41.072280 m 21.795193 42.425730 l s
n 21.148531 41.072280 m 22.643984 41.188979 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 47.416942 ex sub 36.303553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 37.308342 ex sub 29.274253 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF) dup sw 2 div 47.435692 ex sub 40.903553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF) dup sw 2 div 42.499992 ex sub 29.253553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[y1]) dup sw 2 div 37.260692 ex sub 21.703553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[x1]) dup sw 2 div 56.110692 ex sub 36.153553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 52.650329 35.913304 m 49.283266 35.971398 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 52.650329 35.913304 m 52.663268 36.663193 l s
n 52.650329 35.913304 m 52.637391 35.163416 l s
n 49.283266 35.971398 m 50.595049 36.698877 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 37.272986 23.353614 m 37.296114 27.024286 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 37.272986 23.353614 m 38.022971 23.348889 l s
n 37.272986 23.353614 m 36.523001 23.358340 l s
n 37.296114 27.024286 m 38.037914 25.720548 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 39.172814 28.966866 m 39.664062 28.964907 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 39.664062 28.964907 m 38.368025 29.720081 l s
n 39.664062 28.964907 m 38.362044 28.220093 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 47.424885 37.957339 m 47.427716 38.650142 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 47.427716 38.650142 m 48.172401 37.348049 l s
n 47.427716 38.650142 m 46.672413 37.354179 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(De:y) dup sw 2 div 48.321492 ex sub 29.353553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(De:x) dup sw 2 div 47.421442 ex sub 45.253553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 45.333284 29.002269 m 45.570649 29.006347 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 45.570649 29.006347 m 44.258922 29.733925 l s
n 45.570649 29.006347 m 44.284684 28.234146 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 47.429326 42.556219 m 47.427874 43.000981 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 47.427874 43.000981 m 48.182111 41.704398 l s
n 47.427874 43.000981 m 46.682119 41.699501 l s
showpage

Added mtt/lib/examples/Dia/robotrain/trailer_lbl.txt version [be088eb97e].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY trailer
#DESCRIPTION Detailed description here

## System trailer, representation lbl, language txt
## File trailer_lbl.txt
## Generated by MTT on Wed Sep  8 00:41:53 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	x1,y1
#ALIAS	out	x2,y2

## Argument aliases
#ALIAS	$1	D
#ALIAS	$2	L

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							
	# 1							

## Component type AE
	negative  lin		effort,-1

## Component type De
	x	  SS		external		
	y	  SS		external		

## Component type Df
	omega	  SS		external		
	v	  SS		external		

## Component type INTF
	x_e	  none
	y_e	  none
	yaw	  none				

## Component type SS
	[x1]	  SS		external,external		
	[x2]	  SS		external,external		
	[y1]	  SS		external,external		
	[y2]	  SS		external,external		

## Component type TF
	D	  lin		flow,-D		
	L	  lin		effort,L		

## Component type rotation
	z1	  rotate_z		
	z2	  rotate_z		

Added mtt/lib/examples/Dia/robotrain/trajectory.ps version [a9bf91e4a0].
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%!PS-Adobe-2.0 EPSF-2.0
%%Title: trajectory.eps
%%Creator: gnuplot 4.0 patchlevel 0
%%CreationDate: Sun Sep 12 19:59:53 2004
%%DocumentFonts: (atend)
%%BoundingBox: 50 50 410 302
%%Orientation: Portrait
%%EndComments
/gnudict 256 dict def
gnudict begin
/Color false def
/Solid false def
/gnulinewidth 5.000 def
/userlinewidth gnulinewidth def
/vshift -46 def
/dl {10.0 mul} def
/hpt_ 31.5 def
/vpt_ 31.5 def
/hpt hpt_ def
/vpt vpt_ def
/Rounded false def
/M {moveto} bind def
/L {lineto} bind def
/R {rmoveto} bind def
/V {rlineto} bind def
/N {newpath moveto} bind def
/C {setrgbcolor} bind def
/f {rlineto fill} bind def
/vpt2 vpt 2 mul def
/hpt2 hpt 2 mul def
/Lshow { currentpoint stroke M
  0 vshift R show } def
/Rshow { currentpoint stroke M
  dup stringwidth pop neg vshift R show } def
/Cshow { currentpoint stroke M
  dup stringwidth pop -2 div vshift R show } def
/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def
  /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def
/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }
 {pop pop pop 0 setgray Solid {pop []} if 0 setdash} ifelse } def
/BL { stroke userlinewidth 2 mul setlinewidth
      Rounded { 1 setlinejoin 1 setlinecap } if } def
/AL { stroke userlinewidth 2 div setlinewidth
      Rounded { 1 setlinejoin 1 setlinecap } if } def
/UL { dup gnulinewidth mul /userlinewidth exch def
      dup 1 lt {pop 1} if 10 mul /udl exch def } def
/PL { stroke userlinewidth setlinewidth
      Rounded { 1 setlinejoin 1 setlinecap } if } def
/LTw { PL [] 1 setgray } def
/LTb { BL [] 0 0 0 DL } def
/LTa { AL [1 udl mul 2 udl mul] 0 setdash 0 0 0 setrgbcolor } def
/LT0 { PL [] 1 0 0 DL } def
/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def
/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def
/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def
/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def
/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def
/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def
/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def
/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def
/Pnt { stroke [] 0 setdash
   gsave 1 setlinecap M 0 0 V stroke grestore } def
/Dia { stroke [] 0 setdash 2 copy vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V closepath stroke
  Pnt } def
/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V
  currentpoint stroke M
  hpt neg vpt neg R hpt2 0 V stroke
  } def
/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M
  0 vpt2 neg V hpt2 0 V 0 vpt2 V
  hpt2 neg 0 V closepath stroke
  Pnt } def
/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M
  hpt2 vpt2 neg V currentpoint stroke M
  hpt2 neg 0 R hpt2 vpt2 V stroke } def
/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V closepath stroke
  Pnt  } def
/Star { 2 copy Pls Crs } def
/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M
  0 vpt2 neg V  hpt2 0 V  0 vpt2 V
  hpt2 neg 0 V  closepath fill } def
/TriUF { stroke [] 0 setdash vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V closepath fill } def
/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V closepath stroke
  Pnt  } def
/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V closepath fill} def
/DiaF { stroke [] 0 setdash vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V closepath fill } def
/Pent { stroke [] 0 setdash 2 copy gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  closepath stroke grestore Pnt } def
/PentF { stroke [] 0 setdash gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  closepath fill grestore } def
/Circle { stroke [] 0 setdash 2 copy
  hpt 0 360 arc stroke Pnt } def
/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def
/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450  arc } bind def
/C1 { BL [] 0 setdash 2 copy        moveto
       2 copy  vpt 0 90 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C2 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 90 180 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C3 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 0 180 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C4 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 180 270 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C5 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 0 90 arc
       2 copy moveto
       2 copy  vpt 180 270 arc closepath fill
               vpt 0 360 arc } bind def
/C6 { BL [] 0 setdash 2 copy moveto
      2 copy  vpt 90 270 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C7 { BL [] 0 setdash 2 copy moveto
      2 copy  vpt 0 270 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C8 { BL [] 0 setdash 2 copy moveto
      2 copy vpt 270 360 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C9 { BL [] 0 setdash 2 copy moveto
      2 copy  vpt 270 450 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill
       2 copy moveto
       2 copy vpt 90 180 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C11 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 0 180 arc closepath fill
       2 copy moveto
       2 copy  vpt 270 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C12 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 180 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C13 { BL [] 0 setdash  2 copy moveto
       2 copy  vpt 0 90 arc closepath fill
       2 copy moveto
       2 copy  vpt 180 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C14 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 90 360 arc closepath fill
               vpt 0 360 arc } bind def
/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/Rec   { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto
       neg 0 rlineto closepath } bind def
/Square { dup Rec } bind def
/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def
/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def
/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def
/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def
/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill
       exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def
/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill
       2 copy vpt Square fill
       Bsquare } bind def
/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def
/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def
/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill
       Bsquare } bind def
/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill
       Bsquare } bind def
/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def
/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
       2 copy vpt Square fill Bsquare } bind def
/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
       2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def
/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def
/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def
/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def
/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def
/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def
/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def
/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def
/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def
/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def
/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def
/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def
/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def
/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def
/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def
/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def
/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def
/DiaE { stroke [] 0 setdash vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V closepath stroke } def
/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M
  0 vpt2 neg V hpt2 0 V 0 vpt2 V
  hpt2 neg 0 V closepath stroke } def
/TriUE { stroke [] 0 setdash vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V closepath stroke } def
/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V closepath stroke } def
/PentE { stroke [] 0 setdash gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  closepath stroke grestore } def
/CircE { stroke [] 0 setdash 
  hpt 0 360 arc stroke } def
/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def
/DiaW { stroke [] 0 setdash vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V Opaque stroke } def
/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M
  0 vpt2 neg V hpt2 0 V 0 vpt2 V
  hpt2 neg 0 V Opaque stroke } def
/TriUW { stroke [] 0 setdash vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V Opaque stroke } def
/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V Opaque stroke } def
/PentW { stroke [] 0 setdash gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  Opaque stroke grestore } def
/CircW { stroke [] 0 setdash 
  hpt 0 360 arc Opaque stroke } def
/BoxFill { gsave Rec 1 setgray fill grestore } def
/BoxColFill {
  gsave Rec
  /Fillden exch def
  currentrgbcolor
  /ColB exch def /ColG exch def /ColR exch def
  /ColR ColR Fillden mul Fillden sub 1 add def
  /ColG ColG Fillden mul Fillden sub 1 add def
  /ColB ColB Fillden mul Fillden sub 1 add def
  ColR ColG ColB setrgbcolor
  fill grestore } def
%
% PostScript Level 1 Pattern Fill routine
% Usage: x y w h s a XX PatternFill
%	x,y = lower left corner of box to be filled
%	w,h = width and height of box
%	  a = angle in degrees between lines and x-axis
%	 XX = 0/1 for no/yes cross-hatch
%
/PatternFill { gsave /PFa [ 9 2 roll ] def
    PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate
    PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec
    gsave 1 setgray fill grestore clip
    currentlinewidth 0.5 mul setlinewidth
    /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def
    0 0 M PFa 5 get rotate PFs -2 div dup translate
	0 1 PFs PFa 4 get div 1 add floor cvi
	{ PFa 4 get mul 0 M 0 PFs V } for
    0 PFa 6 get ne {
	0 1 PFs PFa 4 get div 1 add floor cvi
	{ PFa 4 get mul 0 2 1 roll M PFs 0 V } for
    } if
    stroke grestore } def
%
/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont
dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall
currentdict end definefont pop
end
%%EndProlog
gnudict begin
gsave
50 50 translate
0.050 0.050 scale
0 setgray
newpath
(Helvetica) findfont 140 scalefont setfont
1.000 UL
LTb
1.000 UL
LTa
714 560 M
6248 0 V
1.000 UL
LTb
714 560 M
63 0 V
6185 0 R
-63 0 V
630 560 M
gsave 0 setgray
(-1) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 1140 M
6248 0 V
1.000 UL
LTb
714 1140 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
(-0.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 1720 M
6248 0 V
1.000 UL
LTb
714 1720 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 0) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 2300 M
6248 0 V
1.000 UL
LTb
714 2300 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 0.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 2880 M
6248 0 V
1.000 UL
LTb
714 2880 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 1) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 3460 M
6248 0 V
1.000 UL
LTb
714 3460 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 1.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 4040 M
6248 0 V
1.000 UL
LTb
714 4040 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 2) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 4620 M
6248 0 V
1.000 UL
LTb
714 4620 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 2.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 560 M
0 4060 V
1.000 UL
LTb
714 560 M
0 63 V
0 3997 R
0 -63 V
714 420 M
gsave 0 setgray
(-5) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
1607 560 M
0 3577 V
0 420 R
0 63 V
1.000 UL
LTb
1607 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-4) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
2499 560 M
0 4060 V
1.000 UL
LTb
2499 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-3) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
3392 560 M
0 4060 V
1.000 UL
LTb
3392 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-2) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
4284 560 M
0 4060 V
1.000 UL
LTb
4284 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-1) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
5177 560 M
0 4060 V
1.000 UL
LTb
5177 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
( 0) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
6069 560 M
0 4060 V
1.000 UL
LTb
6069 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
( 1) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
6962 560 M
0 4060 V
1.000 UL
LTb
6962 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
( 2) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTb
714 560 M
6248 0 V
0 4060 V
-6248 0 V
714 560 L
LTb
140 2590 M
gsave 0 setgray
currentpoint gsave translate 90 rotate 0 0 M
(y) Cshow
grestore
grestore
LTb
3838 210 M
gsave 0 setgray
(x) Cshow
grestore
LTb
3838 4830 M
gsave 0 setgray
(MTT model "robotrain": trajectory of trailer links) Cshow
grestore
210 70 M
gsave 0 setgray
(Sun Sep 12 19:59:53 2004) Lshow
grestore
1.000 UP
1.000 UP
1.000 UL
LT0
LTb
1302 4487 M
gsave 0 setgray
(front) Rshow
grestore
LT0
4284 1720 Pls
4377 1609 Pls
4479 1511 Pls
4587 1427 Pls
4701 1357 Pls
4820 1302 Pls
4942 1263 Pls
5067 1240 Pls
5193 1234 Pls
5319 1244 Pls
5444 1270 Pls
5566 1312 Pls
5684 1369 Pls
5797 1442 Pls
5904 1529 Pls
6004 1630 Pls
6095 1743 Pls
6178 1867 Pls
6250 2001 Pls
6312 2144 Pls
6362 2294 Pls
6401 2451 Pls
6427 2611 Pls
6441 2774 Pls
6443 2938 Pls
6431 3101 Pls
6408 3262 Pls
6372 3419 Pls
6324 3571 Pls
6265 3716 Pls
6195 3852 Pls
6114 3979 Pls
6025 4094 Pls
5927 4198 Pls
5822 4288 Pls
5710 4364 Pls
5593 4425 Pls
5472 4471 Pls
5347 4500 Pls
5222 4514 Pls
5096 4511 Pls
4970 4492 Pls
4847 4456 Pls
4727 4405 Pls
4612 4338 Pls
4502 4257 Pls
4399 4162 Pls
4304 4054 Pls
4218 3935 Pls
4141 3804 Pls
4075 3665 Pls
4020 3517 Pls
3976 3363 Pls
3945 3205 Pls
3926 3043 Pls
3919 2879 Pls
3925 2715 Pls
3943 2553 Pls
3974 2394 Pls
4017 2240 Pls
4072 2092 Pls
4138 1952 Pls
4214 1821 Pls
4299 1701 Pls
4394 1592 Pls
4496 1496 Pls
4606 1414 Pls
4721 1347 Pls
4840 1295 Pls
4963 1258 Pls
5089 1238 Pls
5215 1234 Pls
5340 1247 Pls
5465 1276 Pls
5586 1320 Pls
5703 1381 Pls
5816 1456 Pls
5921 1545 Pls
6020 1648 Pls
6110 1763 Pls
6190 1889 Pls
6261 2025 Pls
6321 2169 Pls
6369 2320 Pls
6406 2477 Pls
6430 2638 Pls
6442 2801 Pls
6442 2965 Pls
6428 3128 Pls
6403 3289 Pls
6365 3445 Pls
6315 3596 Pls
6254 3740 Pls
6182 3874 Pls
6100 3999 Pls
6009 4113 Pls
5910 4214 Pls
5803 4302 Pls
5690 4375 Pls
5573 4434 Pls
5451 4477 Pls
1585 4487 Pls
1.000 UP
1.000 UL
LT1
LTb
1302 4347 M
gsave 0 setgray
(middle) Rshow
grestore
LT1
2499 1720 Crs
2599 1820 Crs
2715 1882 Crs
2839 1910 Crs
2965 1909 Crs
3090 1884 Crs
3212 1840 Crs
3330 1784 Crs
3446 1719 Crs
3560 1647 Crs
3672 1573 Crs
3784 1497 Crs
3897 1423 Crs
4011 1352 Crs
4126 1285 Crs
4243 1223 Crs
4362 1168 Crs
4483 1121 Crs
4605 1083 Crs
4730 1055 Crs
4855 1037 Crs
4981 1031 Crs
5107 1036 Crs
5233 1054 Crs
5357 1085 Crs
5479 1128 Crs
5597 1184 Crs
5712 1253 Crs
5821 1334 Crs
5925 1428 Crs
6022 1533 Crs
6111 1649 Crs
6192 1775 Crs
6264 1910 Crs
6325 2053 Crs
6377 2203 Crs
6417 2358 Crs
6446 2518 Crs
6463 2680 Crs
6468 2844 Crs
6461 3008 Crs
6442 3170 Crs
6410 3329 Crs
6368 3483 Crs
6313 3631 Crs
6248 3772 Crs
6173 3903 Crs
6088 4025 Crs
5995 4135 Crs
5893 4232 Crs
5785 4317 Crs
5671 4386 Crs
5552 4441 Crs
5430 4481 Crs
5305 4504 Crs
5179 4511 Crs
5053 4502 Crs
4928 4477 Crs
4806 4436 Crs
4688 4379 Crs
4574 4308 Crs
4467 4222 Crs
4366 4122 Crs
4274 4011 Crs
4191 3887 Crs
4117 3754 Crs
4055 3612 Crs
4003 3462 Crs
3963 3306 Crs
3935 3146 Crs
3920 2984 Crs
3917 2820 Crs
3927 2656 Crs
3950 2495 Crs
3984 2337 Crs
4031 2185 Crs
4089 2039 Crs
4157 1902 Crs
4237 1774 Crs
4325 1657 Crs
4422 1552 Crs
4527 1460 Crs
4638 1383 Crs
4754 1320 Crs
4875 1272 Crs
4999 1241 Crs
5124 1225 Crs
5251 1226 Crs
5376 1244 Crs
5500 1277 Crs
5620 1326 Crs
5736 1391 Crs
5846 1471 Crs
5950 1564 Crs
6046 1670 Crs
6133 1789 Crs
6211 1918 Crs
6279 2056 Crs
6335 2203 Crs
6380 2356 Crs
6413 2514 Crs
1585 4347 Crs
1.000 UP
1.000 UL
LT2
LTb
1302 4207 M
gsave 0 setgray
(rear) Rshow
grestore
LT2
714 1720 Star
819 1631 Star
942 1601 Star
1068 1614 Star
1190 1655 Star
1309 1711 Star
1426 1771 Star
1544 1830 Star
1664 1882 Star
1786 1925 Star
1910 1956 Star
2035 1973 Star
2161 1977 Star
2287 1968 Star
2412 1946 Star
2536 1912 Star
2658 1869 Star
2777 1817 Star
2895 1758 Star
3011 1694 Star
3126 1625 Star
3240 1554 Star
3353 1481 Star
3466 1409 Star
3579 1337 Star
3693 1267 Star
3809 1199 Star
3925 1136 Star
4043 1078 Star
4163 1025 Star
4284 979 Star
4406 940 Star
4530 909 Star
4655 887 Star
4781 874 Star
4907 871 Star
5033 879 Star
5159 897 Star
5283 927 Star
5405 968 Star
5524 1021 Star
5641 1085 Star
5752 1161 Star
5859 1249 Star
5960 1347 Star
6055 1455 Star
6142 1574 Star
6221 1702 Star
6292 1838 Star
6353 1981 Star
6404 2131 Star
6444 2287 Star
6474 2446 Star
6492 2608 Star
6499 2772 Star
6494 2936 Star
6478 3099 Star
6450 3259 Star
6411 3414 Star
6360 3565 Star
6299 3708 Star
6227 3843 Star
6146 3969 Star
6056 4084 Star
5958 4187 Star
5853 4278 Star
5742 4355 Star
5625 4417 Star
5504 4465 Star
5381 4497 Star
5255 4513 Star
5129 4513 Star
5003 4497 Star
4880 4465 Star
4759 4417 Star
4642 4355 Star
4531 4277 Star
4426 4186 Star
4329 4082 Star
4240 3965 Star
4160 3838 Star
4090 3702 Star
4031 3557 Star
3984 3405 Star
3948 3247 Star
3925 3086 Star
3914 2923 Star
3915 2759 Star
3929 2596 Star
3955 2436 Star
3994 2279 Star
4044 2129 Star
4106 1986 Star
4178 1851 Star
4260 1727 Star
4351 1614 Star
4451 1513 Star
4557 1425 Star
4670 1352 Star
4788 1294 Star
4910 1251 Star
1585 4207 Star
1.000 UL
LTb
714 560 M
6248 0 V
0 4060 V
-6248 0 V
714 560 L
1.000 UP
stroke
grestore
end
showpage
%%Trailer
%%DocumentFonts: Helvetica

Added mtt/lib/examples/Electrical/rc/pulse/rc_input.txt version [c92e3fb3b1].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System rc, representation input, language txt; 
## File rc_input.txt; 
## Generated by MTT on Wed May  1 08:47:22 BST 2002; 



rc__e1	= 1.0*(t<1);		# On for t<1

Added mtt/lib/examples/Electrical/rc/r10/rc_numpar.txt version [e7765b3a02].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System rc, representation numpar, language txt; 
## File rc_numpar.txt; 
## Generated by MTT on Wed May  1 10:18:33 BST 2002; 



c	= 1.0;			# c = 1 F
r	= 10.0;			# r = 10 ohms

Added mtt/lib/examples/Electrical/rc/rc_abg.fig version [cf0ab5e284].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1215 4500 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1080 4500 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 5400 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 675 4275 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1215 4275 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 5400 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 5400 1530 5400 765
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 5625 6750 225 675 225 675 5625 6750 5625
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 195 660 5987 4367 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 195 375 2926 2926 R:r\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4276 2926 C:c\001
4 1 -1 0 0 0 20 0.0000 4 195 660 1395 4365 SS:e1\001
4 0 1 1 0 0 20 0.0000 4 135 105 2880 450 r\001
4 0 1 1 0 0 20 0.0000 4 135 120 4680 1215 c\001
4 0 1 1 0 0 20 0.0000 4 135 120 5625 1170 e\001
4 0 1 1 0 0 20 0.0000 4 195 135 5715 1305 2\001
4 0 1 1 0 0 20 0.0000 4 135 120 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 195 135 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 255 1350 3600 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 195 1200 3600 2025 Schematic\001

Added mtt/lib/examples/Electrical/rc/rc_desc.tex version [9fdb693fc1].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system rc (rc_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{rc} is
   displayed in Figure \Ref{rc_abg} and its label
   file is listed in Section \Ref{sec:rc_lbl}.
   The subsystems are listed in Section \Ref{sec:rc_sub}.

The system \textbf{rc} is the simple electrical rc circuit shown in
Figure \Ref{rc_abg}. It can be regarded as a single-input
single-output system with input $e_1$ and output $e_2$.

Added mtt/lib/examples/Electrical/rc/rc_lbl.txt version [e0d18235d2].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Label file for system rc (rc_lbl.txt)
#SUMMARY rc a simple rc circuit
#DESCRIPTION A basic linear voltage-in voltage-out RC circuit
#DESCRIPTION A standard test example for MTT

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  2000/12/28 17:40:36  peterg
# ## To RCS
# ##
# ###############################################################


# Port aliases

# Argument aliases
#ALIAS	$1	c
#ALIAS	$2	r

## Each line should be of one of the following forms:
#	     a comment (ie starting with #)
#	     component-name	cr_name	arg1,arg2,..argn
#	     blank

# ---- Component labels ----
	c	lin		effort,c

# Component type R
	r	lin		flow,r

# Component type SS
	e1	SS		external,internal
	e2	SS		external,0

Added mtt/lib/examples/Electrical/rc/rc_rep.txt version [2fcb8f9572].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system rc (rc_rep.txt)
## Generated by MTT on" Wed May  1 08:56:38 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt rc abg tex			# The system description
mtt rc cbg ps 		        # The causal bond graph
mtt rc struc tex	        # The system structure
mtt rc sympar txt	        # The system parameters
## Uncomment the following lines or add others
## mtt rc dae tex	        # The system dae
mtt rc ode tex			# The system ode 
## mtt rc sspar tex		# Steady-state parameters
## mtt rc ss tex 		# Steady state
## mtt rc dm tex		# Descriptor matrices (of linearised system)
mtt rc sm tex			# State matrices (of linearised system)
mtt rc tf tex			# Transfer function (of linearised system)
mtt rc lmfr ps			# log modulus of frequency response (of linearised system)
mtt rc simpar txt		# Simulation parameters
## mtt rc state tex		# Simulation initial state

## Default
mtt rc numpar txt		# Numerical simulation parameters
mtt rc input txt		# Simulation input
mtt rc odeso ps			# Simulation output

## Step input
mtt -dr step rc input txt	# Simulation input
mtt -dr step rc odeso ps	# Simulation output

## Pulse input
mtt -dr pulse rc input txt	# Simulation input
mtt -dr pulse rc odeso ps	# Simulation output

## r = 10
## Step input
mtt -dr step -dr r10 rc numpar txt # Numerical simulation parameters
mtt -dr step -dr r10 rc input txt # Simulation input
mtt -dr step -dr r10 rc odeso ps # Simulation output

## Pulse input
mtt -dr pulse -dr r10 rc numpar txt # Numerical simulation parameters
mtt -dr pulse -dr r10 rc input txt # Simulation input
mtt -dr pulse -dr r10 rc odeso ps # Simulation output

mtt rc rep txt			# This file

Added mtt/lib/examples/Electrical/rc/step/rc_input.txt version [ae6bcdc7ad].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System rc, representation input, language txt; 
## File rc_input.txt; 
## Generated by MTT on Wed May  1 08:51:26 BST 2002; 



rc__e1	= 1.0;			# Step

Added mtt/lib/examples/Electrical/rc2/rc2_abg.fig version [11a0341b79].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 1800 2700 1800 2475 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 1800 8100 1800 7875 2025
4 1 0 100 0 18 18 0.0000 4 270 1050 3330 1890 RC:rc_1\001
4 1 0 100 0 18 18 0.0000 4 270 1050 6075 1890 RC:rc_2\001
4 1 0 100 0 18 18 0.0000 4 270 600 8550 1890 De:y\001
4 1 0 100 0 18 18 0.0000 4 210 600 945 1845 Se:u\001

Added mtt/lib/examples/Electrical/rc2/rc2_lbl.txt version [a4c4b7c15c].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY rc2 Simple example of a heirachical system
#DESCRIPTION Uses 2 copies of the RC subsystem

## System rc2, representation lbl, language txt
## File rc2_lbl.txt
## Generated by MTT on Thu Mar 13 16:27:26 GMT 2003

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type De
	y	SS		external		

## Component type RC
	rc_1	lin		c_1;r_1
	rc_2	lin		c_2;r_2

## Component type Se
	u	SS		external		

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_abg.fig version [a81a2c225b].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 900 2925 2475 2925 2250 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2970 2925 4545 2925 4320 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 2700 1125 2925 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2700 2475 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 2925 7200 2925 6975 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7447 2722 7447 1147 7672 1372
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 2925 9225 2925 9000 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7650 2700 7650 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 3150 7425 4725 7650 4500
4 1 -1 0 0 0 20 0.0000 4 195 135 2700 3015 1\001
4 2 -1 0 0 0 20 0.0000 4 195 615 855 3015 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 195 375 2745 990 R:r\001
4 1 -1 0 0 0 20 0.0000 4 195 870 5130 3015 CM:cm\001
4 1 -1 0 0 0 20 0.0000 4 195 135 7425 3015 1\001
4 1 -1 0 0 0 20 0.0000 4 195 405 7425 1035 C:k\001
4 0 -1 0 0 0 20 0.0000 4 195 540 9495 3015 SS:v\001
4 1 -1 0 0 0 20 0.0000 4 195 405 7380 5040 R:d\001

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_desc.tex version [fb1246fe80].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Electrostatic (Electrostatic_desc.tex)
% Generated by MTT on Fri Sep 19 18:07:08 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Electrostatic} is
   displayed in Figure \Ref{Electrostatic_abg} and its label
   file is listed in Section \Ref{sec:Electrostatic_lbl}.
   The subsystems are listed in Section \Ref{sec:Electrostatic_sub}.

This is a simple electrostatic speaker using the \textbf{CM}
transducer component together with an electrical \textbf{R} and a
mechanical \textbf{R} and \textbf{C} components to model a compliant
support for the moving plate. See Karnopp, Margolis and Rosenberg
Section 8.2 for a similar example.

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_input.txt version [25020041f1].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Electrostatic_input.txt)
# Generated by MTT at Fri Sep 19 17:34:53 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:42:25  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Thu Jun  5 15:47:51 BST 2003: u(1) =	1.0; # V (Default value)
electrostatic__v	= 1.0; # Added by MTT on Thu Jun 05 15:47:54 BST 2003

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_lbl.txt version [f7c965ed2d].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Electrostatic: Simple electrostatic speaker model (uses CM)
%DESCRIPTION See Karnopp, Margolis & Rosenberg Section 8.2
%% Label file for system Electrostatic (Electrostatic_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	k		lin	state,k	

% Component type CM
	cm		none	c_0;x_0;m	

% Component type R
	d		lin	flow,d
	r		lin	flow,r

% Component type SS
	V		SS	external,internal
	v		SS	0,external

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_numpar.txt version [6073a2643a].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Electrostatic_numpar.txt)
# Generated by MTT at Fri Sep 19 17:43:25 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:42:25  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_0 = 	1.0; # Parameter c_0 for Electrostatic
d = 	1.0; # Parameter d for Electrostatic
k = 	100.0; # Parameter k for Electrostatic
m = 	1.0; # Parameter m for Electrostatic
r = 	1.0; # Parameter r for Electrostatic
x_0 = 	1.0; # Parameter x_0 for Electrostatic

# Initial states
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(1) = 	0.0; # Initial state for Electrostatic (k)
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(2) = 	0.0; # Initial state for Electrostatic_cm (transducer)
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(3) = 	1.0; # Initial state for Electrostatic_cm (transducer)
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(4) = 	0.0; # Initial state for Electrostatic_cm (mass)

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_rep.txt version [6fccff7b53].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Electrostatic (Electrostatic_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:42:25  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Electrostatic abg tex
mtt Electrostatic struc tex
mtt Electrostatic ode tex
mtt Electrostatic numpar txt
mtt Electrostatic input txt
mtt Electrostatic simpar txt
mtt Electrostatic odeso ps

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_simp.r version [d5350ddac2].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system Electrostatic (Electrostatic_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_state.txt version [2359358d24].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System Electrostatic, representation state, language txt; 
## File Electrostatic_state.txt; 
## Generated by MTT on Mon Feb  5 16:40:35 GMT 2001; 



## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_cm_1_mass	= 0.0; # Default
## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_cm_1_transducer	= 0.0; # Default
## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: ## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_cm_1_transducer_2	= 1.0; #  plate displacement
## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_k	= 0.0; # Default
electrostatic__cm__mass	= 0.0; 
electrostatic__cm__transducer	= 0.0;
electrostatic__cm__transducer_2	= 1.0;
electrostatic__k	= 0.0;

Added mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_abg.fig version [41ab75b11d].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 6930 405 13770 3600
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8328 2028 9903 2028 9903 2928 8328 2928 8328 2028
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 2475 8190 2475 7965 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11475 2250 11475 1035 11700 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11700 2475 12915 2475 12690 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12915 2250 12915 2700
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 12150 3150 10800 3150 10800 450 12150 450 12150 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10035 2475 11250 2475 11025 2700
4 1 -1 0 0 0 20 0.0000 4 255 1110 9138 2568 DC:gener\001
4 1 1 1 0 3 20 0.0000 4 255 1575 9225 3510 DC generator\001
4 1 -1 0 0 0 20 0.0000 4 195 135 11475 2610 0\001
4 1 -1 0 0 0 20 0.0000 4 195 675 13410 2610 SS:v2\001
4 1 -1 0 0 0 20 0.0000 4 255 585 11475 900 R:r_l\001
4 1 1 1 0 3 20 0.0000 4 210 1575 11475 3510 Resistive load\001
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1170 2475 2385 2475 2160 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4186 2476 5401 2476 5176 2701
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13185 4275 13185 225 45 225 45 4275 13185 4275
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 2476 2026 4051 2026 4051 2926 2476 2926 2476 2026
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7245 2925 4950 2925 4950 2025 7245 2025 7245 2925
4 1 -1 0 0 0 20 0.0000 4 195 1170 3286 2566 DC:motor\001
4 1 1 1 0 3 20 0.0000 4 195 1155 3285 3510 DC motor\001
4 1 -1 0 0 0 20 0.0000 4 195 1275 6120 2520 Shaft:shaft\001
4 1 1 1 0 3 20 0.0000 4 270 1605 6165 3510 Flexible shaft\001
4 1 4 100 0 18 14 0.0000 4 210 1110 2250 1890 [Electrical]\001
4 1 4 100 0 18 14 0.0000 4 210 1110 10170 1980 [Electrical]\001
4 1 4 100 0 18 14 0.0000 4 210 1335 4140 1890 [Mechanical]\001
4 1 4 100 0 18 14 0.0000 4 210 1335 8325 1980 [Mechanical]\001
4 1 -1 0 0 0 20 0.0000 4 195 885 675 2565 PSU:v1\001

Added mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_desc.tex version [3ad4972bd4].






















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system MotorGenerator (MotorGenerator_desc.tex)
% Generated by MTT on Thu Nov 16 13:11:36 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:43:16  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MotorGenerator} is
   displayed in Figure \Ref{fig:MotorGenerator_abg.ps} and its label
   file is listed in Section \Ref{sec:MotorGenerator_lbl}.
   The subsystems are listed in Section \Ref{sec:MotorGenerator_sub}.

This example illustates:
\begin{itemize}
\item The reuse of the DC model as both a motor and a generator
\item The assignment of a \emph{domain} and \emph{units} to component ports.
\end{itemize}

The command:
\begin{verbatim}
mtt -I MotorGenerator ese r
\end{verbatim}
gives the following output (irrelevant parts ommitted)
\begin{verbatim}
MTT (Model Transformation Tools) version 4.8
($Date$)
This is free software with ABSOLUTELY NO WARRANTY.
Type `mtt warranty' for details.

Creating MotorGenerator_rbg.m
Creating MotorGenerator_cmp.m
Creating MotorGenerator_fig.fig
Creating MotorGenerator_sabg.fig
Creating MotorGenerator_alias.txt
Creating MotorGenerator_alias.m
Creating MotorGenerator_sub.sh
Copying DC from /home/peterg/mtt_new/mtt-lib/comp/compound/Electromechanical/DC to .
Creating DC_rbg.m
Creating DC_cmp.m
Creating DC_fig.fig
Creating DC_sabg.fig
Creating DC_alias.txt
Creating DC_alias.m
Creating DC_sub.sh
Creating DC_abg.m
Checking port domains and units
     domains and units are OK

...

Creating PSU_rbg.m
Creating PSU_cmp.m
Creating PSU_fig.fig
Creating PSU_sabg.fig
Creating PSU_alias.txt
Creating PSU_alias.m
Creating PSU_sub.sh
Copying Se from /home/peterg/mtt_new/mtt-lib/comp/compound/General/Se to .
Creating Se_rbg.m
Creating Se_cmp.m
Creating Se_fig.fig
Creating Se_sabg.fig
Creating Se_alias.txt
Creating Se_alias.m
Creating Se_sub.sh
Creating Se_abg.m
Checking port domains and units
  no domains or units declared
.... 

Creating PSU_abg.m
Checking port domains and units
     domains and units are OK
...

Creating Shaft_rbg.m
Creating Shaft_cmp.m
Creating Shaft_fig.fig
Creating Shaft_sabg.fig
Creating Shaft_alias.txt
Creating Shaft_alias.m
Creating Shaft_sub.sh
Creating Shaft_abg.m
Checking port domains and units
     domains and units are OK
....

Creating MotorGenerator_abg.m
Checking port domains and units
  no domains or units declared

Creating MotorGenerator_cbg.m (maximise integral causality)
Creating MotorGenerator_type.sh
 .....
Creating MotorGenerator_ese.r
Creating MotorGenerator_def.r
Creating MotorGenerator_struc.txt
...
INFORMATION: Component MotorGenerator connects ports with units volt and volt
INFORMATION: Component MotorGenerator connects ports with units amp and amp
...
INFORMATION: Component MotorGenerator connects ports with units N*m and N*m
INFORMATION: Component MotorGenerator connects ports with units radians/s and radians/s
...
INFORMATION: Component MotorGenerator connects ports with units N*m and N*m
INFORMATION: Component MotorGenerator connects ports with units radians/s and radians/s
Creating MotorGenerator_aliased.txt
Copying MotorGenerator_ese.r

\end{verbatim}

Added mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_input.txt version [887fa90928].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System MotorGenerator, representation input, language txt; 
## File MotorGenerator_input.txt; 
## Generated by MTT on Mon Dec  9 09:08:54 UTC 2002; 



## Removed by MTT on Thu Jun  5 16:43:47 BST 2003: MotorGenerator_v1_v_u	= 1.0; # Default
motorgenerator__v1__v__u	= 1.0; # Added by MTT on Thu Jun 05 16:43:50 BST 2003

Added mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_lbl.txt version [d4522ab96a].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY MotorGenerator: Motor-generator example
%DESCRIPTION A simple example of DC motor driving a generator via
%DESCRIPTION a flexible shaft

%% Label file for system MotorGenerator (MotorGenerator_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/11/16 09:58:49  peterg
% %% Initial revision
% %%
% %% Revision 1.3  2000/05/20 16:38:40  peterg
% %% New SS foramt
% %%
% %% Revision 1.2  1998/04/04 10:51:59  peterg
% %% New version using port coercion
% %%
% %% Revision 1.1  1996/12/04  16:24:01  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Voltage in
v1	SS	external,internal

% Voltage out
v2	SS	external,0

%Motor
motor		lin	k_m;l_m;r_m;j_m;b_m

%Shaft
shaft	        lin     c_s

%Generator
gener		lin	k_g;l_g;r_g;j_g;b_g

% Resistive load
r_l		lin	flow,r_l

Added mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_numpar.txt version [6fa5d2a477].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (MotorGenerator_numpar.txt)
# Generated by MTT at Wed Dec 10 08:29:31 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/04 14:42:47  peterg
# %% Initial revision
# %%
# %% Revision 1.1  2000/08/01 12:26:48  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b_g = 	0.0; # Parameter b_g for MotorGenerator
b_m = 	0.0; # Parameter b_m for MotorGenerator
c_s = 	0.01; # Parameter c_s for MotorGenerator
j_g = 	1.0; # Parameter j_g for MotorGenerator
j_m = 	1.0; # Parameter j_m for MotorGenerator
k_g = 	1.0; # Parameter k_g for MotorGenerator
k_m = 	1.0; # Parameter k_m for MotorGenerator
l_g = 	0.1; # Parameter l_g for MotorGenerator
l_m = 	0.1; # Parameter l_m for MotorGenerator
r_g = 	0.1; # Parameter r_g for MotorGenerator
r_l = 	1.0; # Parameter r_l for MotorGenerator
## Removed by MTT on Mon Dec  4 14:44:19 GMT 2000: r_m_1 = 	0.1; # Parameter r_m for MotorGenerator

r_m	= 0.1; # Added by MTT on Mon Dec 04 14:44:44 GMT 2000

Added mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_rep.txt version [e2275ca135].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system MotorGenerator (MotorGenerator_rep.txt)
## Generated by MTT on" Thu Nov 16 13:37:07 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt MotorGenerator abg tex			# The system description
mtt MotorGenerator cbg ps 		        # The causal bond graph
mtt MotorGenerator struc tex	        # The system structure
mtt MotorGenerator sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt MotorGenerator dae tex	        # The system dae
mtt MotorGenerator ode tex	        # The system ode 
## mtt MotorGenerator sspar tex		# Steady-state parameters
## mtt MotorGenerator ss tex 		# Steady state
## mtt MotorGenerator dm tex		# Descriptor matrices (of linearised system)
mtt MotorGenerator sm tex		# State matrices (of linearised system)
##mtt MotorGenerator tf tex		# Transfer function (of linearised system)
## mtt MotorGenerator lmfr ps		# log modulus of frequency response (of linearised system)
## mtt MotorGenerator simpar tex		# Simulation parameters
## mtt MotorGenerator numpar tex		# Numerical simulation parameters
## mtt MotorGenerator state tex		# Simulation initial state
## mtt MotorGenerator input tex		# Simulation input
## mtt MotorGenerator logic tex		# Logic control
mtt MotorGenerator odeso ps		# Simulation output

mtt MotorGenerator rep txt		# This file

Added mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_simpar.txt version [75937c9851].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system MotorGenerator (MotorGenerator_simpar.txt)
# Generated by MTT on Fri Dec 1 18:03:55 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Electromechanical/MotorGenerator/PSU_abg.fig version [ee661e106f].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 1710 4860 2025
4 0 4 100 0 18 18 0.0000 4 270 1065 3780 1935 SS:[out]\001
-6
6 1530 675 4995 3015
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 4950 2970 1575 2970 1575 720 4950 720 4950 2970
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1845 3600 1845 3375 2070
4 1 0 100 0 18 18 0.0000 4 210 570 1890 1935 Se:v\001

Added mtt/lib/examples/Electromechanical/MotorGenerator/PSU_lbl.txt version [0875be2315].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system PSU (PSU_lbl.txt)
%SUMMARY PSU
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%UNITS out electrical volt amp 
% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[out]	SS		external,external

% Component type Se
	v	SS		external

Added mtt/lib/examples/Electromechanical/MotorGenerator/Shaft_abg.fig version [7e87b19fce].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 1440 405 4410 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 2250 2925 1035 3150 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1486 2476 2701 2476 2476 2701
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 3600 3150 2250 3150 2250 450 3600 450 3600 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4365 2475 4140 2700
4 1 -1 0 0 0 20 0.0000 4 195 135 2925 2565 0\001
4 1 -1 0 0 0 20 0.0000 4 255 630 2925 900 C:c_s\001
4 1 1 1 0 3 20 0.0000 4 270 1605 2925 3510 Flexible shaft\001
-6
6 540 2340 1440 2655
4 2 4 100 0 18 18 0.0000 4 270 870 1440 2565 SS:[in]\001
-6
6 4455 2340 5535 2655
4 0 4 100 0 18 18 0.0000 4 270 1065 4455 2565 SS:[out]\001
-6
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 5850 3825 450 3825 450 225 5850 225 5850 3825

Added mtt/lib/examples/Electromechanical/MotorGenerator/Shaft_lbl.txt version [b9f5e1ab44].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Shaft (Shaft_lbl.txt)
%SUMMARY Shaft
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:43:16  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases


% Unit definitions
%UNITS in  rotational N*m radians/s
%UNITS out rotational N*m radians/s

% Argument aliases
%ALIAS	$1	c_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c_s	lin		effort,c_s

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_abg.fig version [0983c47273].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 4 1 7 1 0 -1 0.000 0 0 -1 0 0 4
	 2700 2025 7875 2025 7875 9450 2700 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 6525 5625 7875 5850 7650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3780 5625 5130 5850 4905
2 2 0 2 1 3 1 0 20 0.000 0 0 0 0 0 5
	 2700 5175 7875 5175 7875 6525 2700 6525 2700 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 855 2835 5850 3060 5625
2 2 0 2 1 3 1 0 20 0.000 0 0 0 0 0 5
	 2700 1575 2970 1575 2970 5175 2700 5175 2700 1575
2 1 1 2 1 7 1 0 -1 6.000 0 0 -1 0 0 2
	 2700 585 2700 9855
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 10125 9450 225 1125 225 1125 10125 9450 10125
4 1 4 0 0 0 20 0.0000 4 240 3075 5625 8190 [mechanical,mass,thermal]\001
4 1 -1 0 0 0 30 0.0000 4 300 1950 5625 8595 CG:bottom\001
4 1 4 0 0 0 20 0.0000 4 255 3885 5625 6345 [mechanical_b,mass_b,thermal_b]\001
4 1 -1 0 0 0 30 0.0000 4 405 3345 5625 5940 LeakyPiston:piston\001
4 1 -1 0 0 0 30 0.0000 4 405 1260 5625 3285 CG:top\001
4 1 4 0 0 0 20 0.0000 4 240 3075 5625 3600 [mechanical,mass,thermal]\001
4 1 4 0 0 0 20 0.0000 4 255 3750 5625 5400 [mechanical_t,mass_t,thermal_t]\001
4 1 4 0 0 0 20 0.0000 4 240 750 3375 5895 [shaft]\001
4 0 -1 0 0 0 20 0.0000 4 195 975 2925 900 SS:shaft\001

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_desc.tex version [0efd064e91].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system LeakyCylinder (LeakyCylinder_desc.tex)
% Generated by MTT on Tue Nov 25 17:22:29 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:44:35  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{LeakyCylinder} is
   displayed in Figure \Ref{LeakyCylinder_abg} and its label
   file is listed in Section \Ref{sec:LeakyCylinder_lbl}.
   The subsystems are listed in Section \Ref{sec:LeakyCylinder_sub}.

This example roughly corresponds to the Example in section 12.4.3
(Fig. 12.17) of Karnopp, Margolis and Rosenberg (1990). It is a pseudo bond
graph representation based on the ``thermal accumulator'' of  section
12.4.1 and the ``isentropic nozzle'' of section 12.4.2 of that book.

[
Notes added by PJG 10 June 03. 
\begin{enumerate}
\item The parameters/states used in the simulation (odeso) are
  meaningless at the moment.
\item The steady-state parameters (sspar.r) need to be calculated; at
  the moment, the state mattrices (sm) are in terms of the
  steady-state states.  
\end{enumerate}
]

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_input.txt version [8ad664ff23].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (LeakyCylinder_input.txt)
# Generated by MTT at Tue Nov 25 17:00:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	0.0; # shaft

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_lbl.txt version [b1e5813551].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY LeakyCylinder: Pseudo bond graph model of compressible gas dynamics

%DESCRIPTION This example roughly corresponds to the Example in
%DESCRIPTION section 12.4.3 (Fig. 12.17) of Karnopp, Margolis and Rosenberg
%DESCRIPTION (1990). It is a pseudo bond graph representation based on the
%DESCRIPTION "thermal acummulator" of section 12.4.1 and the "isentropic
%DESCRIPTION nozzle" of section 12.4.2 of that book.

%% Label file for system LeakyCylinder (LeakyCylinder_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/04 09:56:05  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CG
	bottom		none	c_v;r
	top		none	c_v;r

% Component type LeakyPiston
	piston		none	m_p;a_b;a_t;gamma;r;0

% Component type SS
	shaft		SS	external,external

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_numpar.txt version [e23dfd6a5b].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (LeakyCylinder_numpar.txt)
# Generated by MTT at Mon Dec  1 08:59:51 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:44:35  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
a_b = 	1.0; # Parameter a_b for LeakyCylinder
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: a_l = 	1.0; # Parameter a_l for LeakyCylinder
a_t = 	1.0; # Parameter a_t for LeakyCylinder
c_v = 	1.0; # Parameter c_v for LeakyCylinder
gamma = 	1.0; # Parameter gamma for LeakyCylinder
m_p = 	1.0; # Parameter m_p for LeakyCylinder
r = 	1.0; # Parameter r for LeakyCylinder

# Initial states
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: x(3) = 	0.0; # Initial state for LeakyCylinder_bottom (cg)
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: x(6) = 	0.0; # Initial state for LeakyCylinder_top (cg)
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: x(7) = 	0.0; # Initial state for LeakyCylinder_piston_piston (m_p)

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_rep.txt version [163616dd5e].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system LeakyCylinder (LeakyCylinder_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2003/06/11 15:57:57  gawthrop
% %% Updated examples for latest MTT.
% %%
% %% Revision 1.1  2000/12/28 17:44:35  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt LeakyCylinder abg tex
mtt LeakyCylinder struc tex
mtt LeakyCylinder sympar tex
mtt LeakyCylinder ode tex
mtt LeakyCylinder ss tex
mtt LeakyCylinder sm tex
##mtt LeakyCylinder odeso ps

mtt LeakyCylinder rep txt


Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_simp.r version [163e4c6595].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system LeakyCylinder (LeakyCylinder_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_sspar.r version [e6e5a3aadc].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for LeakyCylinder (LeakyCylinder_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyPiston_abg.fig version [c4c5b004af].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 3375 6300 4725 6525 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 3375 7200 4725 7425 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 6075 6300 8122 6525 7897
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7245 6075 7245 8100 7470 7875
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4500 9000 9225 9000
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 450 9000 4050 9000
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4050 9675 4050 450 450 450 450 9675 4050 9675
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9225 9675 4500 9675 4500 450 9225 450 9225 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 6300 1575 6525 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 2925 7200 1575 7425 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2925 3150 1575 3375 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 3150 4725 3375 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2056 4711 1101 3756 1101 4074
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 6075 3150 7425 3375 7200
4 0 4 0 0 0 20 0.0000 4 255 1440 7200 5040 [thermal_in]\001
4 1 4 0 0 0 20 0.0000 4 255 1110 6300 5040 [mass_in]\001
4 1 4 0 0 0 20 0.0000 4 255 1260 6300 5895 [mass_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1590 7200 5895 [thermal_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1755 7155 8505 SS:[thermal_b]\001
4 2 4 0 0 0 20 0.0000 4 255 1425 6255 8505 SS:[mass_b]\001
4 1 1 1 0 0 20 0.0000 4 195 1335 6750 9450 Leak model\001
4 1 1 1 0 0 20 0.0000 4 195 1515 2250 9405 Piston Model\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6300 3240 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 7200 3240 0\001
4 2 4 0 0 0 20 0.0000 4 255 2115 3195 1305 SS:[mechanical_t]\001
4 2 4 0 0 0 20 0.0000 4 255 1380 6345 1305 SS:[mass_t]\001
4 0 4 0 0 0 20 0.0000 4 255 1710 7155 1350 SS:[thermal_t]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3150 3240 0\001
4 1 4 0 0 0 20 0.0000 4 255 540 3150 5040 [top]\001
4 1 4 0 0 0 20 0.0000 4 240 750 2070 5040 [shaft]\001
4 1 4 0 0 0 20 0.0000 4 240 1155 1080 3645 SS:[shaft]\001
4 2 4 0 0 0 20 0.0000 4 255 2160 3150 7785 SS:[mechanical_b]\001
4 1 4 0 0 0 20 0.0000 4 240 990 3150 5940 [bottom]\001
4 1 -1 0 0 0 30 0.0000 4 300 1425 6885 5535 RG:leak\001
4 1 -1 0 0 0 30 0.0000 4 405 2295 2700 5535 Piston:piston\001

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyPiston_desc.tex version [56fe000716].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system LeakyPiston (LeakyPiston_desc.tex)
% Generated by MTT on Fri Nov 28 12:09:15 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{LeakyPiston} is
   displayed in Figure \Ref{LeakyPiston_abg} and its label
   file is listed in Section \Ref{sec:LeakyPiston_lbl}.
   The subsystems are listed in Section \Ref{sec:LeakyPiston_sub}.

Added mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyPiston_lbl.txt version [552b5840bb].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY LeakyPiston: Leaky piston sub model
%DESCRIPTION <Detailed description here>
%% Label file for system LeakyPiston (LeakyPiston_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/04 10:00:11  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Piston
	piston		lin	$1;$2;$3

% Component type RG
	leak		lin	$4;$5;$6

% Component type SS
	[mass_b]	SS	external,external
	[mass_t]	SS	external,external
	[mechanical_b]	SS	external,external
	[mechanical_t]	SS	external,external
	[shaft]		SS	external,external
	[thermal_b]	SS	external,external
	[thermal_t]	SS	external,external

Added mtt/lib/examples/GasDynamics/LeakyCylinder/Piston_abg.fig version [357fe6faa9].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 1575 6075 3150 6300 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3600 6075 4275 6300 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 4636 6075 5311 6300 5086
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 4500 4500 4500 4725 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5905 4281 4950 3326 4950 3645
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5850 6075 7200 6300 6975
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 8100 6975 8100
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6975 8775 6975 900 3375 900 3375 8775 6975 8775
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9945 9225 9945 450 450 450 450 9225 9945 9225
4 1 -1 0 0 0 20 0.0000 4 255 780 6120 3465 TF:a_t\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6075 4590 1\001
4 2 4 0 0 0 20 0.0000 4 240 1155 4905 3240 SS:[shaft]\001
4 1 -1 0 0 0 20 0.0000 4 255 660 4050 4545 I:m_p\001
4 1 -1 0 0 0 20 0.0000 4 255 825 6075 5670 TF:a_b\001
4 2 4 0 0 0 20 0.0000 4 240 1395 6120 7650 SS:[bottom]\001
4 1 1 1 0 0 20 0.0000 4 195 1515 5175 8505 Piston Model\001
4 2 4 0 0 0 20 0.0000 4 255 945 6120 1395 SS:[top]\001

Added mtt/lib/examples/GasDynamics/LeakyCylinder/Piston_desc.tex version [76d5324126].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Piston (Piston_desc.tex)
% Generated by MTT on Fri Nov 28 12:09:27 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Piston} is
   displayed in Figure \Ref{Piston_abg} and its label
   file is listed in Section \Ref{sec:Piston_lbl}.
   The subsystems are listed in Section \Ref{sec:Piston_sub}.

The two {\bf TF} components convert pressure to force. The {\bf I}
component represents piston inertia.

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/GasDynamics/LeakyCylinder/Piston_lbl.txt version [a07bef4048].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Piston: simple model of the piston
%DESCRIPTION Inludes inertia and pressure effects.
%% Label file for system Piston (Piston_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/04 10:01:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m_p		lin	flow,$1

% Component type SS
	[bottom]	SS	external,external
	[shaft]		SS	external,external
	[top]		SS	external,external

% Component type TF
	a_b		lin	flow,$2
	a_t		lin	effort,$3

Added mtt/lib/examples/Hybrid/Bounce/Bounce_abg.fig version [4d929f234d].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
6 3150 4410 5940 4995
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 3154 4730 5449 4730 5404 4730
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3379 4730 3154 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3604 4730 3379 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3829 4730 3604 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4054 4730 3829 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4279 4730 4054 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4505 4731 4280 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4730 4731 4505 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4955 4731 4730 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5180 4731 4955 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5405 4731 5180 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 5897 4413 5627 4683
-6
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 4276 2206 612 612 4276 2206 4636 2701
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 5176 1531 4906 1801
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 2475 5175 3600 5175 3330
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2250 2925 2250 3150 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2070 4275 946 4500 1171
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 4275 2475 4500 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4297 4522 4297 5646 4522 5421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3600 7875 3600 7650 3825
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 6300 8775 225 225 225 225 6300 8775 6300
4 2 -1 0 0 2 20 0.0000000 4 240 2130 2835 2250 R:air_resistance\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4276 2341 1\001
4 1 1 1 0 3 20 0.0000000 4 210 525 5176 1441 Ball\001
4 0 -1 0 0 2 20 0.0000000 4 270 1365 5760 2340 SS:gravity\001
4 1 -1 0 0 2 20 0.0000000 4 240 1515 4275 810 I:ball_mass\001
4 1 -1 0 0 2 20 0.0000000 4 270 1710 4320 5940 CSW:ground\001
4 1 1 1 0 3 20 0.0000000 4 210 960 6030 4275 Ground\001
4 1 1 1 0 3 20 0.0000000 4 150 135 4590 3465 v\001
4 1 1 1 0 3 20 0.0000000 4 150 315 4590 5220 -v\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4275 4365 0\001
4 1 -1 0 0 2 20 0.0000000 4 210 1275 5985 3690 INTF:intf\001
4 0 -1 0 0 2 20 0.0000000 4 210 585 8010 3690 SS:x\001

Added mtt/lib/examples/Hybrid/Bounce/Bounce_desc.tex version [422d8be2ce].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Bounce (Bounce_desc.tex)
% Generated by MTT on Wed Jul 2 10:55:51 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:45:24  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Bounce}, togehter with a
   schematic diagram is
   displayed in Figure \Ref{Bounce_abg} and its label
   file is listed in Section \Ref{sec:Bounce_lbl}.
   The subsystems are listed in Section \Ref{sec:Bounce_sub}.

The model uses the {\bf CSW} switched {\bf C} element to simulate
contact with the ground. The corresponding switching function (See
Section \ref{sec:Bounce_input-noargs.txt}), is based on the height above the
ground $h$ as follows:
\begin{equation}
i_{sw} = 
  \begin{cases}
    0 & \text{if $h > 0$}\\
    -1 & \text{if $h \le 0$}
  \end{cases}
\end{equation}

In other words, the component acts as an ideal spring when the ball is
in contact with the ground yet has no effect when the ball is not in
contact with the ground.

The ball is modelled as a point mass (the \textbf{I} component) and  a
linear resistance to motion (the  (the \textbf{R} component).

The system was simulated for 100 time units and the resultant height
is plotted in Figure \ref{fig:Bounce_odeso-noargs.ps}. The ball was released at zero
velocity from a height of ten units. The bounce height decreases due to
the effect of the modelled air resistance.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Hybrid/Bounce/Bounce_input.txt version [c668d16412].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Bounce_input.txt)
# Generated by MTT at Wed Jul  2 10:47:49 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.4  2001/10/05 11:24:29  gawthrop
# %% Updated for new mtt features - input.txt etc
# %%
# %% Revision 1.3  2000/05/18 11:30:14  peterg
# %% Moved switch logic to logic.txt
# %%
# %% Revision 1.2  1998/10/01 19:20:33  peterg
# %% Cahged switch function
# %%
# %% Revision 1.1  1998/07/25 18:35:02  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Fri Oct  5 10:37:56 BST 2001: mttu(1) = 9.81;


## Removed by MTT on Tue Jun 10 10:22:08 BST 2003: bounce_gravity	= 9.81; # Added by MTT on Fri Oct 05 10:37:59 BST 2001
bounce__gravity	= 9.81;

Added mtt/lib/examples/Hybrid/Bounce/Bounce_lbl.txt version [3c29396b81].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Bounce: Bouncing ball example (hybrid)
%DESCRIPTION <Detailed description here>
%% Label file for system Bounce (Bounce_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 09:54:22  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type INTF
	intf

% Component type CSW
	ground		lin	state,k_g

% Component type I
	ball_mass		lin	flow,m

% Component type R
	air_resistance		lin	flow,r

% Component type SS
	gravity			SS	external,internal
	x			SS	external,0

Added mtt/lib/examples/Hybrid/Bounce/Bounce_logic.txt version [68ac8bc9fe].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Bounce (Bounce_logic.txt)
# Generated by MTT on Thu May 18 12:29:15 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 13:14:12  geraint
## Updated names.
##
## Revision 1.2  2000/12/28 17:45:24  peterg
## To RCS
##
## Revision 1.1  2000/05/18 11:29:58  peterg
## Initial revision
##
###############################################################


# Set the switches

## On when below ground level
bounce__ground__mtt_switch_logic	= (bounce__intf__mttc < 0);

Added mtt/lib/examples/Hybrid/Bounce/Bounce_numpar.txt version [3190429a19].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Bounce_numpar.txt)
# Generated by MTT at Wed Jul  2 10:47:47 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:45:24  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
k_g = 	100.0; # Ground stiffness
m = 	1.0; # Ball mass
r = 	1.0; # Air resistance

Added mtt/lib/examples/Hybrid/Bounce/Bounce_rep.txt version [d2abad5353].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Bounce (Bounce_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/19 07:09:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Bounce abg tex
mtt Bounce struc tex
mtt Bounce ode tex


mtt Bounce simpar txt
mtt Bounce input txt
mtt Bounce logic txt
mtt Bounce numpar txt

mtt Bounce odeso ps

mtt Bounce rep txt

Added mtt/lib/examples/Hybrid/Bounce/Bounce_simpar.txt version [17a4ac93f9].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Simulation parameters for system Bounce (Bounce_simpar.txt)
# Generated by MTT on Sat Jul 25 15:57:56 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/10/01 19:21:04  peterg
## Initial revision
##
###############################################################
FIRST=0.0;
LAST=10.0;
DT=0.02;
STEPFACTOR=1;

Added mtt/lib/examples/Hybrid/Bounce/Bounce_state.txt version [975ae5de24].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*-
# Initial state  file (Bounce_state.txt)
# Generated by MTT at Sat Jul 25 15:56:57 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2002/09/29 13:14:12  geraint
## Updated names.
##
## Revision 1.3  2001/10/05 11:24:30  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.2  1998/07/25 20:34:05  peterg
## *** empty log message ***
##
## Revision 1.1  1998/07/25 14:59:11  peterg
## Initial revision
##
###############################################################

# Set the states
## Removed by MTT on Tue Jun 10 10:23:07 BST 2003: bounce_ball_mass		=  0.0; # 
## Removed by MTT on Tue Jun 10 10:23:07 BST 2003: bounce_ground_mtt_switch	=  0.0; #
## Removed by MTT on Tue Jun 10 10:23:07 BST 2003: bounce_intf_mttc		= 10.0; #
bounce__ball_mass	= 0.0;	# Zero velocity
bounce__ground__mtt_switch	= 0.0; # Not on ground
bounce__intf__mttc	= 10.0; # 10m above ground

Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_abg.fig version [c0c525deaf].


































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
6 3513 9498 8733 9858
6 3513 9498 4953 9813
6 3513 9498 4233 9768
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3514 9724 3739 9499
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3739 9724 3964 9499
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3964 9724 4189 9499
-6
6 4189 9499 4909 9769
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4190 9725 4415 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4415 9725 4640 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4640 9725 4865 9500
-6
-6
6 4864 9499 6304 9814
6 4864 9499 5584 9769
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4865 9725 5090 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5090 9725 5315 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5315 9725 5540 9500
-6
6 5540 9500 6260 9770
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5541 9726 5766 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5766 9726 5991 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5991 9726 6216 9501
-6
-6
6 6214 9499 6934 9769
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6215 9725 6440 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6440 9725 6665 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6665 9725 6890 9500
-6
6 6890 9500 7610 9770
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6891 9726 7116 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7116 9726 7341 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7341 9726 7566 9501
-6
6 7565 9500 8285 9770
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7566 9726 7791 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7791 9726 8016 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 8016 9726 8241 9501
-6
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3514 9499 8689 9499
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 8242 9727 8467 9502
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 8467 9727 8692 9502
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 2072 4727 3647 4952 3422
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6077 2072 6077 3647 6302 3422
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 3647 4952 3647
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5852 3647 6302 3647
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7202 3647 7652 3647
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 8823 4728 10398 4953 10173
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 6571 2926 6571 3151 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2251 6797 2251 8372 2476 8147
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9923 6774 9923 8349 10148 8124
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5851 4771 6301 4771
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 8372 4726 6797 4951 7022
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4501 6346 4501 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7651 6346 7651 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7629 6571 9204 6571 8979 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 6347 4726 4772 4951 4997
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2521 4186 4096 4186 3871 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4096 3961 4096 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 4770 7426 6345 7651 6120
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 6795 7426 8370 7651 8145
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 4186 9676 4186 9451 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8101 3961 8101 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 3647 7426 2072 7651 2297
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 4772 6076 6347 6301 6122
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 8820 7426 10395 7651 10170
2 2 0 2 1 3 1 0 20 0.000 0 0 0 0 0 5
	 3827 3422 8327 3422 8327 4997 3827 4997 3827 3422
2 1 0 3 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 3.00 180.00 360.00
	 9226 2521 8371 3196
2 1 0 3 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 3.00 180.00 360.00
	 11458 7718 10603 8393
2 1 0 3 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 3.00 180.00 360.00
	 701 7685 1556 8360
4 1 -1 0 0 2 20 0.0000000 4 210 1470 2115 6660 INTF:intfL\001
4 1 -1 0 0 2 20 0.0000000 4 210 1215 6077 4322 ROD:rod\001
4 1 4 0 0 2 20 0.0000000 4 240 360 6077 3962 [p7]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 6077 4637 [p8]\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4727 6662 1\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 7427 6662 1\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4728 8688 0\001
4 1 -1 0 0 2 20 0.0000000 4 270 1905 4728 10713 CSW:groundL\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 7428 8688 0\001
4 1 -1 0 0 2 20 0.0000000 4 270 1365 6077 6662 SS:gravity\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 10217 4277 SS:aR\001
4 1 -1 0 0 2 20 0.0000000 4 210 1485 10126 6661 INTF:intfR\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 2251 8641 SS:hL\001
4 1 -1 0 0 2 20 0.0000000 4 210 810 9946 8641 SS:hR\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 6077 1937 SS:xC\001
4 1 -1 0 0 2 20 0.0000000 4 270 1920 7426 10711 CSW:groundR\001
4 1 -1 0 0 2 20 0.0000000 4 210 780 4727 1937 SS:xL\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 7427 1937 SS:xR\001
4 1 4 0 0 2 20 0.0000000 4 240 360 4727 3962 [p3]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 7427 3962 [p4]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 4727 4637 [p5]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 7426 4636 [p6]\001
4 1 -1 0 0 2 20 0.0000000 4 210 780 2026 4276 SS:aL\001
4 1 4 0 0 2 20 0.0000000 4 240 360 4411 4276 [p1]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 7876 4321 [p2]\001
4 0 1 1 0 3 30 0.0000000 4 300 1470 5311 10171 Ground\001
4 0 1 1 0 3 30 0.0000000 4 390 2685 8326 2476 Bouncing Rod\001
4 0 1 1 0 3 30 0.0000000 4 390 3315 11026 7651 Height of right tip\001
4 2 1 1 0 3 30 0.0000000 4 390 3000 1800 7515 Height of left tip\001

Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_desc.tex version [924a60ed36].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system BouncingRod (BouncingRod_desc.tex)
% Generated by MTT on Sun Jul 6 17:21:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/20 09:36:24  peterg
% %% *** empty log message ***
% %%
% Revision 1.1  1997/07/06  16:35:20  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{BouncingRod} is displayed in
Figure \Ref{BouncingRod_abg} and its label file is listed in Section
\Ref{sec:BouncingRod_lbl}. 
 The subsystems are listed in Section
\Ref{sec:BouncingRod_sub}.

The system consists of a uniform rod of mass 1kg, length 2m (and
therefore of inertia about the mass centre of $\frac{1}{3}
\text{kgm}^2$. The rod is released at an angle of $\frac{\pi}{4}$ from
the vertical, the mass centre is $10\text{m}$ above the ground and all
velocities are initially zero. The gravitational constant is taken as unity.

The ground is modeled as an ideal compliance in the vertical
direction with compliance of $0.1 \text{mN}^{-1}$ and it is assumed
that contact takes place at the rod tips only. There is no
horizontal resistance to motion. This idealised setup is modeled by a
two {\bf CSW} components, one for each rod tip, modulated by the
height of each rod tip above the ground: each  {\bf CSW} is off when
the corresponding height is positive.

The system was simulated for 100 time units and the resultant height
of each tip is plotted in Figure \ref{fig:BouncingRod_odeso-noargs.ps}. The rod was
released at zero velocity from a height of ten units and at an angle
of $\frac{\pi}{4}$ radians to the vertical. The oscillations in height
are due to rod rotation about its mass centre.  The bounce height
changes due to energy transfer to and from the rod rotation about its
mass centre.




%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: "yes"
%%% End: 

Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_input.txt version [205c4ea63e].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (BouncingRod_input.txt)
# Generated by MTT at Fri Jul  4 14:09:14 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2000/12/04 08:27:42  peterg
# %% New version
# %%
# %% Revision 1.1  1997/07/06 16:17:48  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Mon Dec  4 08:27:04 GMT 2000: u(1) =	9.81; # gravity (Default value)
## Removed by MTT on Tue Jun 10 10:33:30 BST 2003: bouncingrod_gravity	= 9.81; # Added by MTT on Mon Dec 04 08:27:10 GMT 2000
bouncingrod__gravity	= 9.81; # Gravity

Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_lbl.txt version [60967407da].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY BouncingRod: Two-dimensional bouncing rod (hybrid)
%DESCRIPTION A uniform rod bounces on a compliant surface -- the
%DESCRIPTION CSW component is used.

%% Label file for system BouncingRod (BouncingRod_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.5  2000/12/04 08:36:23  peterg
% %% Declare pi
% %%
% %% Revision 1.4  2000/05/18 10:30:39  peterg
% %% New SS form
% %%
% %% Revision 1.3  1997/09/11 09:55:25  peterg
% %% Added documentation
% %%
% %% Revision 1.2  1997/09/11 08:37:29  peterg
% %% Added description
% %%
% %% Revision 1.1  1997/07/06 16:18:37  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CSW
	groundL		lin	effort,epsilon
	groundR		lin	effort,epsilon

% Component type INTF
	intfL
	intfR

% Component type ROD
	rod		none	l;l;j;m

% Component type SS
	aL		SS	0,internal
	aR		SS	0,internal
	gravity		SS	external,internal
	hL		SS	external,0
	hR		SS	external,0
	xC		SS	0,internal
	xL		SS	0,internal
	xR		SS	0,internal

Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_logic.txt version [dfa5eb6acf].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system BouncingRod (BouncingRod_logic.txt)
# Generated by MTT on Thu May 18 12:14:35 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/09/29 15:31:39  geraint
## Updated names.
##
## Revision 1.1  2000/12/28 17:45:59  peterg
## To RCS
##
###############################################################

# Set the switches
## Removed by MTT on Tue Jun 10 10:45:53 BST 2003: bouncingrod_groundl_mtt_switch_logic	= (bouncingrod_intfl_mttc <= 0);
## Removed by MTT on Tue Jun 10 10:45:53 BST 2003: bouncingrod_groundr_mtt_switch_logic	= (bouncingrod_intfr_mttc <= 0);
bouncingrod__groundl__mtt_switch_logic	= (bouncingrod__intfl__mttc <= 0); 
bouncingrod__groundr__mtt_switch_logic	= (bouncingrod__intfr__mttc <= 0);

Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_numpar.txt version [653e854f15].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (BouncingRod_numpar.txt)
# Generated by MTT at Fri Jul  4 14:09:11 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2000/12/28 17:45:59  peterg
# %% To RCS
# %%
# %% Revision 1.1  1997/07/06 16:17:27  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
epsilon = 	0.01; 
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	l*l*m/3;



Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_odes.h version [8e08760d76].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
/*
%% Parameter file for system BouncingRod (BouncingRod_odes.h)
%% This file provides the params for simulation:
*/
#define DT 0.1 /* Time step (for printing) */
#define LAST 99.9 /* Last time */
#define STEPFACTOR 1000 /* Integration steps per time step */

Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_rep.txt version [1e32455526].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system BouncingRod (BouncingRod_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 17:45:59  peterg
% %% To RCS
% %%
% %% Revision 1.1  1997/07/06 16:20:44  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt BouncingRod abg tex
mtt BouncingRod struc tex
mtt BouncingRod ode tex
mtt BouncingRod numpar txt
mtt BouncingRod input txt
mtt BouncingRod logic txt
mtt BouncingRod odeso ps



Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_simpar.txt version [b247367777].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Simulation parameters for system BouncingRod (BouncingRod_simpar.txt)
# Generated by MTT on Sun Jul 26 12:14:17 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/12/21 08:07:38  peterg
## Initial revision
##
###############################################################

LAST=20;
DT=0.01;
STEPFACTOR=1;


Added mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_state.txt version [0f22d94928].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Initial state  file (BouncingRod_state.txt)
# Generated by MTT at Sun Jul 26 12:19:13 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 15:31:39  geraint
## Updated names.
##
## Revision 1.2  2002/05/10 12:38:11  gawthrop
## Updated to new format
##
## Revision 1.1  2000/12/28 17:45:59  peterg
## To RCS
##
###############################################################


# Set the states

## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_groundl_mtt_switch	= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_groundr_mtt_switch	= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_intfl_mttc		= 10 + sin(pi/4);
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_intfr_mttc		= 10 - sin(pi/4);
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_j		= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_m_x		= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_m_y		= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_th_mttc		= pi/4;
bouncingrod__groundl__mtt_switch	= 0.0;
bouncingrod__groundr__mtt_switch	= 0.0;
bouncingrod__intfl__mttc	= 10 + sin(pi/4); # Start at 45 degree angle
bouncingrod__intfr__mttc	= 10 - sin(pi/4); # Start at 45 degree angle
bouncingrod__rod__j	= 0.0; 
bouncingrod__rod__m_x	= 0.0; 
bouncingrod__rod__m_y	= 0.0; 
bouncingrod__rod__th__mttc	= pi/4; # Start at 45 degree angle

Added mtt/lib/examples/Hybrid/BouncingRod/CSW_lbl.txt version [1a99199c4e].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY ISW: Switched I component
%DESCRIPTION ISW acts as an I component except when the -s -c option is used.
%DESCRIPTION When the -s -c option is used:
%DESCRIPTION   The component label is used as a variable name (eg Name)
%DESCRIPTION   In the ode simulation:
%DESCRIPTION     Name = 1 implies normal I (closed switch)
%DESCRIPTION     Name = 0 implies state=0 (open switch)
%DESCRIPTION     Name = -1 implies state>0 (Diode)

%% Label file for system ISW (ISW_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/06/03 15:26:09  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	MTT_SWITCH		$1	$1

Added mtt/lib/examples/Hybrid/BouncingRod/ROD_abg.fig version [34663585aa].






























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 3600 675 2250 675 2250 9675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 4 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 4 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 4 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 5625 2700 5400 1800 6300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 5401 5625 9001 5850 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 7875 2925 9000 3195 8730
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 7875 8325 9000 8595 8730
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9450 6300 9225 6300
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 -1 0 0 0 20 0.0000 4 240 720 8372 1217 SS:[p5]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 5671 9361 SS:[p2]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 8417 9362 SS:[p6]\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 270 4501 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4501 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 3826 4051 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6301 4006 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6211 6526 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4591 5896 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4591 6841 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 3916 6526 [mod]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 2971 1216 SS:[p3]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 5671 1216 SS:[p1]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 2971 9361 SS:[p4]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4411 5446 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4906 5446 [in]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 1 4 1 0 0 20 0.0000 4 255 390 1350 2700 Tip\001
4 1 4 1 0 0 20 0.0000 4 255 390 1350 9855 Tip\001
4 1 4 1 0 0 20 0.0000 4 195 1380 1080 6120 Mass centre\001
4 1 -1 0 0 0 20 0.0000 4 240 720 1710 6615 SS:[p7]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 9495 6570 SS:[p8]\001

Added mtt/lib/examples/Hybrid/BouncingRod/ROD_desc.tex version [da144b910f].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Jul 4 10:30:17 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.


This is a special version just for this problem.

Added mtt/lib/examples/Hybrid/BouncingRod/ROD_lbl.txt version [77bb98cc7c].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	Port [1]:	Angular torque/velocity - end 1
%DESCRIPTION	Port [2]:	Angular torque/velocity - end 2
%DESCRIPTION	Port [3]:	x force/velocity - end 1
%DESCRIPTION	Port [4]:	x force/velocity - end 2
%DESCRIPTION	Port [5]:	y force/velocity - end 1
%DESCRIPTION	Port [6]:	y force/velocity - end 2
%DESCRIPTION	Port [7]:	x force/velocity - centre
%DESCRIPTION	Port [8]:	y force/velocity - centre
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system ROD (ROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2

% ports
	
[p1]	SS	external,external
[p2]	SS	external,external
[p3]	SS	external,external
[p4]	SS	external,external
[p5]	SS	external,external
[p6]	SS	external,external
[p7]	SS	external,external
[p8]	SS	external,external

Added mtt/lib/examples/Hybrid/Clutch/Clutch_abg.fig version [e07876e4d0].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4726 3376 4726 2026 2476 2026 2476 3376 4726 3376
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8101 3376 8101 2026 5851 2026 5851 3376 8101 3376
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11476 3376 11476 2026 9226 2026 9226 3376 11476 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2701 6076 2701 5941 2836
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 2701 9451 2701 9316 2836
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 2701 2701 2701 2566 2836
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 5400 11925 225 225 225 225 5400 11925 5400
4 1 -1 0 0 0 20 0.0000 4 195 1170 3511 2791 DC:motor\001
4 1 -1 0 0 0 20 0.0000 4 195 1140 10306 2791 Load:load\001
4 1 -1 0 0 0 20 0.0000 4 195 1290 7021 2791 Drive:drive\001
4 1 -1 0 0 0 20 0.0000 4 195 525 765 2790 SS:e\001

Added mtt/lib/examples/Hybrid/Clutch/Clutch_desc.tex version [46fab8044d].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Clutch (Clutch_desc.tex)
% Generated by MTT on Thu Jul 3 13:57:59 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:46:44  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Clutch} is displayed in
   Figure \Ref{Clutch_abg} and its label file is listed in Section
   \Ref{sec:Clutch_lbl}.  The subsystems are listed in Section
   \Ref{sec:Clutch_sub}.  The details of the DC motor and the load are
   hidden behind a word bond graph so as to focus on the clutch
   mechanism as modelled by the \textbf{CSW} component.
  It is natural to model the clutch shaft by a
compliance to absorb the shock of engaging the clutch; therefore the
drive model contains a \textbf{CSW} component.


Figure \ref{fig:Clutch_odeso-noargs.ps}, shows the angular velocities of the motor
and load.  The clutch is engaged from time $t$ given by $0<t<15$; and
a unit input voltage is applied at time $t=0$. All initial conditions
are zero.

Added mtt/lib/examples/Hybrid/Clutch/Clutch_input.txt version [bd0caf2748].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Clutch_input.txt)
# Generated by MTT at Thu Jul  3 12:17:46 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2002/09/29 13:47:35  geraint
# %% Updated names.
# %%
# %% Revision 1.1  2000/05/19 07:10:03  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
clutch__e	= 1.0; # e (Default value)

Added mtt/lib/examples/Hybrid/Clutch/Clutch_lbl.txt version [60b6b4f3da].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Clutch: Simple model of a clutch system (Hybrid)
%DESCRIPTION Uses CSW component to model the clutch/flexi shaft
%% Label file for system Clutch (Clutch_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 09:38:48  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type DC
	motor		lin	k_m;l_a;r_a;j_m;b_m

% Component type Drive
	drive	

% Component type Load
	load	

% Component type SS
	e		SS	external,internal

Added mtt/lib/examples/Hybrid/Clutch/Clutch_logic.txt version [581d8453ec].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Clutch (Clutch_logic.txt)
# Generated by MTT on Thu May 18 12:29:15 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 13:47:35  geraint
## Updated names.
##
## Revision 1.2  2001/10/05 11:24:35  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.1  2000/05/19 07:11:36  peterg
## Initial revision
##
## Revision 1.1  2000/05/18 11:29:58  peterg
## Initial revision
##
###############################################################

# Set the switches
clutch__drive__clutch__mtt_switch_logic	= ((t >= 5)&&(t < 15)); # 

Added mtt/lib/examples/Hybrid/Clutch/Clutch_numpar.txt version [240d38c694].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Clutch_numpar.txt)
# Generated by MTT at Thu Jul  3 12:12:35 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b_m = 	0.1; # Default value
epsilon = 	0.01;
j_l = 	1.0; # Default value
j_m = 	10.0; # Default value
k_m = 	1.0; # Default value
l_a = 	0.1; # Default value
r_a = 	1.0; # Default value
r_l = 	5.0; # Default value

Added mtt/lib/examples/Hybrid/Clutch/Clutch_rep.txt version [334e6789c3].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Clutch (Clutch_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/19 07:16:07  peterg
% %% Added logic
% %%
% %% Revision 1.1  1999/02/21 08:18:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt  Clutch abg tex
mtt  Clutch struc tex
mtt  Clutch ode tex
mtt  Clutch dm tex

mtt  Clutch simpar txt
mtt  Clutch input txt
mtt  Clutch logic txt
mtt  Clutch numpar txt

mtt  Clutch odeso ps

mtt  Clutch rep txt

Added mtt/lib/examples/Hybrid/Clutch/Clutch_simpar.txt version [e28a1ca3b7].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Simulation parameters for system Clutch (Clutch_simpar.txt)
# Generated by MTT on Sun Jul 26 13:26:44 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/12/21 09:13:19  peterg
## Initial revision
##
###############################################################

LAST=20.0;
DT=0.1;
STEPFACTOR=1;

Added mtt/lib/examples/Hybrid/Clutch/Drive_abg.fig version [220398ec6b].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2475 2925 2475 2700 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3397 2497 4522 2497 4297 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 2475 6075 2475 5850 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6547 2497 7672 2497 7447 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2700 3150 3825 3375 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2700 6300 3825 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4725 2250 4725 1125 4950 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2925 2700 3375 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6030 2700 6525 2700
4 1 -1 0 0 0 20 0.0000 4 195 135 3150 2565 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6300 2565 1\001
4 1 4 0 0 0 20 0.0000 4 240 810 1305 2565 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 960 8235 2565 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 195 675 3150 4185 SS:v1\001
4 1 -1 0 0 0 20 0.0000 4 195 675 6300 4185 SS:v2\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4725 2610 0\001
4 1 -1 0 0 0 20 0.0000 4 195 1410 4725 945 CSW:clutch\001

Added mtt/lib/examples/Hybrid/Clutch/Drive_desc.tex version [f20953ff3a].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Drive (Drive_desc.tex)
% Generated by MTT on Thu Jul 3 13:58:26 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Drive} is
   displayed in Figure \Ref{Drive_abg} and its label
   file is listed in Section \Ref{sec:Drive_lbl}.
   The subsystems are listed in Section \Ref{sec:Drive_sub}.

Added mtt/lib/examples/Hybrid/Clutch/Drive_lbl.txt version [0bb1dbab24].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Drive: The clutch/shaft drive subsystem
%DESCRIPTION <Detailed description here>
%% Label file for system Drive (Drive_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/18 10:32:32  peterg
% %% New SS form
% %%
% %% Revision 1.1  1997/09/11 09:39:16  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CSW
	clutch		lin	effort,epsilon

% Component type R
%	r_d		lin	flow,r_d

% Component type SS
	v1		SS	0,external
	v2		SS	0,external
	[in]		SS	external,external
	[out]		SS	external,external

Added mtt/lib/examples/Hybrid/Clutch/Load_abg.fig version [f6ba5521a1].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3376 2926 3376 2701 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3151 3151 2251 3376 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3601 3151 4501 3376 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2476 1801 3826 1801 3826 4951 2476 4951 2476 1801
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2026 3151 2476 3151 2476 3601 2026 3601 2026 3151
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 5400 6075 900 495 900 495 5400 6075 5400
4 1 -1 0 0 0 20 0.0000 4 195 135 3151 3466 1\001
4 1 -1 0 0 0 20 0.0000 4 255 450 3151 2161 I:j_l\001
4 1 -1 0 0 0 20 0.0000 4 255 585 3196 4816 R:r_l\001
4 1 4 0 0 0 20 0.0000 4 240 810 1576 3466 SS:[in]\001
4 1 1 1 0 0 20 0.0000 4 255 4395 3331 1531 Rotating load with inertia and friction\001

Added mtt/lib/examples/Hybrid/Clutch/Load_desc.tex version [0e613d5fe7].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Load (Load_desc.tex)
% Generated by MTT on Thu Jul 3 13:58:38 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Load} is
   displayed in Figure \Ref{Load_abg} and its label
   file is listed in Section \Ref{sec:Load_lbl}.
   The subsystems are listed in Section \Ref{sec:Load_sub}.

Added mtt/lib/examples/Hybrid/Clutch/Load_lbl.txt version [522a352692].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Load: An inertial/frictional load
%DESCRIPTION <Detailed description here>
%% Label file for system Load (Load_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 09:39:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	j_l		lin	flow,j_l

% Component type R
	r_l		lin	flow,r_l

% Component type SS
	[in]		SS	external,external

Added mtt/lib/examples/Hybrid/Weirs/Weir_abg.fig version [23c0cd3485].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2025 2475 2025 2250 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1800 2700 675 2925 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 2025 4050 2025 3825 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2025 5625 2025 5400 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 4275 675 4500 900
2 4 0 2 31 7 99 0 -1 6.000 0 0 7 0 0 5
	 6975 3600 6975 180 225 180 225 3600 6975 3600
4 1 0 100 0 0 20 0.0000 4 195 150 2700 2115 1\001
4 1 0 100 0 0 20 0.0000 4 210 1065 2700 585 ISW:isw\001
4 1 4 100 0 0 20 0.0000 4 255 870 765 2115 SS:[in]\001
4 1 4 100 0 0 20 0.0000 4 255 1020 6255 2115 SS:[out]\001
4 1 0 100 0 0 20 0.0000 4 195 150 4275 2115 1\001
4 1 0 100 0 0 20 0.0000 4 195 390 4230 585 R:r\001
4 1 1 99 0 1 20 0.0000 4 270 2250 3375 2835 Simple weir model\001

Added mtt/lib/examples/Hybrid/Weirs/Weir_desc.tex version [3eff224837].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Weir (Weir_desc.tex)
% Generated by MTT on Tue Mar 2 22:05:29 GMT 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Weir} is
   displayed in Figure \Ref{Weir_abg} and its label
   file is listed in Section \Ref{sec:Weir_lbl}.
   The subsystems are listed in Section \Ref{sec:Weir_sub}.


The weir is modelled by an \textbf{ISW} component in series with an
\textbf{R} component. Physicaly, the former represents the inertia of
the fluid together with the switching effect of the weir; the latter
represents the flow resistance.

The switching logic is on if the level on either side of the weir
reaches the level of the weir.

Added mtt/lib/examples/Hybrid/Weirs/Weir_lbl.txt version [17d01f59e7].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Weir
#DESCRIPTION Detailed description here

## System Weir, representation lbl, language txt
## File Weir_lbl.txt
## Generated by MTT on Fri Oct  5 10:50:46 BST 2001

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	i_s
#ALIAS	$2	r

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type ISW
	isw	lin		flow,i_s

## Component type R
	r	lin		flow,r		

## Component type R
	[in]	SS		external,external		
	[out]	SS		external,external		









Added mtt/lib/examples/Hybrid/Weirs/Weirs_abg.fig version [fea78e06f0].










































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6075 2025 4950 2250 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 675 6300 1800 6300 1530 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6525 2025 7650 2250 7425
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 675 6075 675 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 7650 2250 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 6525 6750 7200 6570 7200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 6300 3375 6300 3105 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 5625 6300 5355 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 6300 7200 6300 6930 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 6300 9450 6300 9180 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 6076 5851 4951 6076 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 6525 5850 7650 6075 7425
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 7650 6075 7650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9677 6077 9677 4952 9902 5177
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9675 6525 9675 7650 9900 7425
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 7650 9900 7650
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4860 3150 4860 1980
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7110 3150 7110 1395
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 3
	1 0 2.00 120.00 240.00
	 2610 450 3285 450 3285 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 3060 675 3060 3150 5760 3150
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 5985 3150 8955 3150 8955 675
2 1 0 2 1 7 99 0 -1 0.000 0 0 -1 1 0 2
	1 0 1.00 60.00 120.00
	 5850 2925 5850 3600
4 1 -1 0 0 0 20 0.0000 4 195 150 2025 6390 0\001
4 1 -1 0 0 0 20 0.0000 4 210 960 2025 4815 C:tank1\001
4 1 -1 0 0 0 20 0.0000 4 270 720 1980 7965 SS:p1\001
4 1 -1 0 0 0 20 0.0000 4 210 525 315 6390 SS:f\001
4 0 -1 0 0 0 20 0.0000 4 210 795 6300 7515 R:leak\001
4 1 -1 0 0 0 20 0.0000 4 195 1065 3960 6390 Weir:w1\001
4 1 -1 0 0 0 20 0.0000 4 195 1065 7785 6390 Weir:w2\001
4 1 -1 0 0 0 20 0.0000 4 210 960 5851 4816 C:tank2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5851 6391 0\001
4 1 -1 0 0 0 20 0.0000 4 270 720 5850 7965 SS:p2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 9677 6392 0\001
4 1 -1 0 0 0 20 0.0000 4 210 960 9677 4817 C:tank3\001
4 1 -1 0 0 0 20 0.0000 4 270 720 9630 7965 SS:p3\001
4 1 1 1 0 3 20 0.0000 4 270 105 2970 315 f\001
4 1 1 99 0 1 20 0.0000 4 210 825 3780 2565 Tank 1\001
4 1 1 99 0 1 20 0.0000 4 210 825 5940 2565 Tank 2\001
4 1 1 99 0 1 20 0.0000 4 210 825 8055 2565 Tank 3\001
4 1 1 99 0 1 20 0.0000 4 210 585 5895 3870 Leak\001

Added mtt/lib/examples/Hybrid/Weirs/Weirs_desc.tex version [75ce1911ff].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Weirs (Weirs_desc.tex)
% Generated by MTT on Thu Jul 3 10:27:26 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:47:43  peterg
% %% To RCS
% %%
% Revision 1.1  1997/09/11  10:31:48  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Weirs} is
   displayed in Figure \Ref{Weirs_abg} and its label
   file is listed in Section \Ref{sec:Weirs_lbl}.
   The subsystems are listed in Section \Ref{sec:Weirs_sub}.

%Each weir is modeled by two {\bf ISW} components: one for flow
%left-right and one for flow right-left. The switching is such that
%they become non-return valves when the left hand (respectively
%right-hand) level reaches an appropriate value. The parameters appear
%in Section \Ref{sec:Weirs_numpar.txt} and the switching conditions in
%Section \Ref{sec:Weirs_input.txt}.

Aircraft fuel tanks are often fitted with baffles to reduce fuel
slosh. A simple model relating to such a system is shown in Figure
\Ref{Weirs_abg} which corresponds to a single tank containing two
dividing weirs. Liquid with flow rate $f$ enters the left-hand
compartment; liquid leaks out of the centre compartment at a flow rate
determined by gravity and the properties of the corresponding orifice.

The Bond Graph appearing in Figure \Ref{Weirs_abg} represents each of
the three compartments by a \textbf{C} component (labelled tank1 to
tank3), the corresponding pressures are measured by the \textbf{SS}
elements p1--p3. The leak is represented by the \textbf{R} component
labelled leak. The flows over the two weirs are represented by the four
\textbf{ISW} components; each weir has a separate \textbf{ISW}
component for each flow direction. Each \textbf{ISW} component is
switched by the appropriate level.

%It could be argued that, when switched on, each \textbf{ISW} component
%corresponds to flow inertia; but it is admitted that ideal
%\textbf{Sw} components would give a simpler approximation in this
%case. So the modeller has the choice of having a simple simulation
%problem but with four extra states, or a complex simulation with model
%switching but without the four extra states.

The system was simulated for 20 time units and the resultant level of
each tank partition is plotted in Figure \Ref{fig:Weirs_odeso-noargs.ps}. Each
partition has unit cross section, and the two weir heights are $1$ and
$2$ respectively; the inflow $f$ is given by:
\begin{equation}
  f = 
  \begin{cases}
    1 & \text{if $t \le 10$}\\
    0 & \text{if $t > 10$}
  \end{cases}
\end{equation}
and the leak resistance is linear with flow resistance 5.


%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Hybrid/Weirs/Weirs_input.txt version [d802cb3522].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (Weirs_input.txt)
# Generated by MTT at Tue Mar  2 07:48:04 GMT 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2001/10/05 11:24:35  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.1  2000/05/19 07:12:04  peterg
## Initial revision
##
###############################################################

# Set the inputs
## Removed by MTT on Fri Oct  5 10:47:20 BST 2001: mttu(1) = 1.0*(t<10); 	# f (Weirs)



## Removed by MTT on Tue Jun 10 10:53:48 BST 2003: weirs_f	= 1.0*(t<10); # Added by MTT on Fri Oct 05 10:48:01 BST 2001


weirs__f	= 1.0*(t<10);

Added mtt/lib/examples/Hybrid/Weirs/Weirs_lbl.txt version [2f0e26ecdf].
















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Weirs (Weirs_lbl.txt)
%SUMMARY Weirs Double-weir tanks system (hybrid)
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/03/09 00:12:12  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	tank1
%ALIAS	$2	tank2
%ALIAS	$3	tank3
%ALIAS	$4	leak

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	tank1		lin	effort,c_1
	tank2		lin	effort,c_2
	tank3		lin	effort,c_3

% Component type R
	leak		lin	flow,r_l

% Component type SS
	f	SS		internal,external
	p1	SS		external,0
	p2	SS		external,0
	p3	SS		external,0

% Component type Weir
	w1      none		epsilon_i;epsilon_r
	w2      none		epsilon_i;epsilon_r

Added mtt/lib/examples/Hybrid/Weirs/Weirs_logic.txt version [85668391bb].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Weirs (Weirs_logic.txt)
# Generated by MTT on Thu May 18 12:29:15 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 14:23:16  geraint
## Updated switch names.
##
## Revision 1.2  2001/10/05 11:24:35  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.1  2000/05/19 07:13:29  peterg
## Initial revision
##
## Revision 1.1  2000/05/18 11:29:58  peterg
## Initial revision
##
###############################################################


# Set the switches
# First weir - height 1
# Second weir - height 2
## Removed by MTT on Tue Jun 10 10:54:35 BST 2003: weirs_w1_isw_mtt_switch_logic	= ((weirs_tank1 > 1) | (weirs_tank2 > 1));
## Removed by MTT on Tue Jun 10 10:54:35 BST 2003: weirs_w2_isw_mtt_switch_logic	= ((weirs_tank2 > 2) | (weirs_tank3 > 2));
weirs__w1__isw__mtt_switch_logic	= ((weirs__tank1 > 1) | (weirs__tank2 > 1));
weirs__w2__isw__mtt_switch_logic	= ((weirs__tank2 > 2) | (weirs__tank3 > 2));

Added mtt/lib/examples/Hybrid/Weirs/Weirs_numpar.txt version [f82fcef096].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (Weirs_numpar.txt)
# Generated by MTT at Tue Mar  2 07:55:47 GMT 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # Weirs
c_2 = 	1.0; # Weirs
c_3 = 	1.0; # Weirs
epsilon_i = 	0.01; # weir
epsilon_r = 	0.1; # weir
r_l = 	5.0; # Weirs

Added mtt/lib/examples/Hybrid/Weirs/Weirs_rep.txt version [9f4c394b93].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Weirs (Weirs_rep.txt)
## Generated by MTT on" Tue Mar  2 22:02:59 GMT 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/05/19 07:15:04  peterg
## Added logic
##
## Revision 1.4  1999/12/21 09:24:26  peterg
## Euler integration - compiled
##
## Revision 1.3  1999/03/02 22:19:22  peterg
## Added switch rep
##
## Revision 1.2  1999/03/02 22:09:49  peterg
## Addded switch rep
##
## Revision 1.1  1999/03/02 22:04:11  peterg
## Initial revision
##
###############################################################

mtt Weirs abg tex			# The system description
## mtt Weirs cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt Weirs struc tex	        # The system structure
## mtt Weirs dae tex	        # The system dae
mtt Weirs ode tex	        # The system ode 
mtt Weirs switch txt	        # The system switches 
## mtt Weirs sspar tex		# Steady-state parameters
## mtt Weirs ss tex 		# Steady state
## mtt Weirs dm tex		# Descriptor matrices (of linearised system)
## mtt Weirs sm tex		# State matrices (of linearised system)
## mtt Weirs tf tex		# Transfer function (of linearised system)
## mtt Weirs lmfr ps		# log modulus of frequency response (of linearised system)
mtt Weirs simpar tex		# Simulation parameters
mtt Weirs numpar tex		# Numerical simulation parameters
mtt Weirs input tex		# Simulation input
mtt Weirs logic tex		# Switch logic
mtt Weirs odeso ps		# Simulation output

mtt Weirs rep txt

Added mtt/lib/examples/Hybrid/Weirs/Weirs_simpar.txt version [9ebb65f3fe].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Simulation parameters for system Weirs (Weirs_simpar.txt)
# Generated by MTT on Sun Jul 26 13:55:27 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/12/21 09:22:43  peterg
## Initial revision
##
###############################################################


LAST=19.9;
DT=0.01;
STEPFACTOR=1;

Added mtt/lib/examples/Hybrid/Weirs/weir_abg.fig version [9adb302ec2].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2025 2475 2025 2250 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1800 2700 675 2925 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2250 2700 3375 2925 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 2025 4050 2025 3825 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2025 5625 2025 5400 2250
4 1 0 100 0 0 20 0.0000 4 195 150 2700 2115 1\001
4 1 0 100 0 0 20 0.0000 4 210 1065 2700 585 ISW:isw\001
4 1 0 100 0 0 20 0.0000 4 195 390 2700 3690 R:r\001
4 1 0 100 0 0 20 0.0000 4 255 870 765 2115 SS:[in]\001
4 1 0 100 0 0 20 0.0000 4 255 1020 6255 2115 SS:[out]\001
4 1 0 100 0 0 20 0.0000 4 195 150 4275 2115 1\001

Added mtt/lib/examples/Hybrid/Weirs/weir_lbl.txt version [d74bf1486c].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system weir (weir_lbl.txt)
%SUMMARY weir
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	r

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type ISW
	isw             lin     effort,epsilon_i

% Component type R
	r		lin	flow,epsilon_r

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external


Added mtt/lib/examples/Identification/idNonlinearTanks/README version [64f32ec93d].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
This is the example from:
@Article{Gaw00c,
  author =       {Peter J Gawthrop},
  title =        {Sensitivity Bond Graphs},
  journal =      JFI,
  year =         {2000}
}


NB Compile with -i euler

Added mtt/lib/examples/Identification/idNonlinearTanks/conical.cr version [91a01114ea].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
%% CR for conical tank example

OPERATOR conical;
%% State input.
FOR ALL COMP, rho,g,V_0,V LET
    conical(COMP, rho,g,V_0,effort,1,V,state,1) = rho*g*(12*(V+V_0)/pi)^(1/3);


END;;

Added mtt/lib/examples/Identification/idNonlinearTanks/discharge.cr version [aa3df12262].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
%% CR for pipe discharge


OPERATOR discharge;
%% Flow input
FOR ALL COMP, alpha,beta,F LET
    discharge(COMP, alpha,beta,effort,1,F,flow,1) = beta*F^alpha;

%% Effort input
FOR ALL COMP, alpha,beta,P LET
    discharge(COMP, alpha,beta,flow,1,P,effort,1) = (P/beta)^(1/alpha);

END;;

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_abg.fig version [62dde3975f].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2925 2745 2925 2520 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2925 4320 2925 4095 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 2925 5895 2925 5670 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 7470 2925 7245 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 2700 2925 1530 3150 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2700 4500 1530 4725 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 2700 6075 1530 6300 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 2700 7650 1530 7875 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 6075 4320 6300 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1575 2700 1575 3150
4 1 0 100 0 18 20 0.0000 4 270 195 2925 3015 0\001
4 1 0 100 0 18 20 0.0000 4 270 195 4500 3015 1\001
4 1 0 100 0 18 20 0.0000 4 270 195 7650 3015 1\001
4 1 0 100 0 18 20 0.0000 4 285 705 2925 1440 C:t1\001
4 1 0 100 0 18 20 0.0000 4 360 780 4545 1440 R:p1\001
4 1 0 100 0 18 20 0.0000 4 360 780 7695 1440 R:p2\001
4 1 0 100 0 18 20 0.0000 4 285 705 6075 1440 C:t2\001
4 1 0 100 0 18 20 0.0000 4 270 195 6075 3015 0\001
4 1 0 100 0 18 20 0.0000 4 360 825 6075 4680 De:y\001
4 1 0 100 0 18 20 0.0000 4 285 720 1125 3060 Sf:u\001

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_desc.tex version [3e4f2fb3e7].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system idNonlinearTanks (idRC_desc.tex)
% Generated by MTT on Thu Apr 5 11:04:33 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{idNonlinearTanks} is
   displayed in Figure \Ref{fig:idRC_abg.ps} and its label
   file is listed in Section \Ref{sec:idRC_lbl}.
   The subsystems are listed in Section \Ref{sec:idRC_sub}.

   
   This example illustrates the sensitivity approach to model-based
   system identification\footnote{Peter J Gawthrop, \emph{Sensitivity
       Bond Graphs}, Journal Franklin Institute, \textbf{337}, 2000,
     pp 907--922}.

   The system compprises two non-linear tanks (see the paper for details).
   The method identifies four parameters: the two initial states ans
   the two parameters of the non-linear flow resistance.

   To see the results, type: 
\begin{verbatim}
mtt -oct -i euler -pdf idNonlinearTanks ippp view
\end{verbatim}

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_ippp.m version [3864de3022].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

## Set up parameters
name = "idNonlinearTanks";
sim = sidNonlinearTanks_simpar;	# Simulation parameter
sym = sidNonlinearTanks_sympar;	# Parameter names
par = sidNonlinearTanks_numpar;	# Parameter values
x0  = sidNonlinearTanks_state(par); # Initial state

## Simulation of "actual" system
t = [0:sim.dt:sim.last]';
T = 5;				# Period
u = ones(size(t));
y_0 = sidNonlinearTanks_ssim(x0,par,sim,u,2);

plot(t,y_0);

## The initial parameters
par_0 = par;
par_0(sym.V_1) = 2.0;
par_0(sym.V_2) = 1.0;
par_0(sym.alpha) = 1.0;
par_0(sym.beta) = 2.0;

## Identify
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.v = 10;			# Use a really big initial value
extras.verbose = 1;		# Show what is going on
[par,Par,Error,Y] = ppp_identify (name,u,y_0,["V_1  ";"V_2  ";"alpha";"beta "],par_0,extras);

par = par

grid;
xlabel("Time")
title("Output");
plot(t,y_0);
figfig("idNonlinearTanks_output","pdf");
figfig("idNonlinearTanks_output","ps");
grid;

xlabel("Time")
title("Estimated output");
plot(t,y_0,t,Y);
figfig("idNonlinearTanks_outputs","pdf");
figfig("idNonlinearTanks_outputs","ps");

xlabel("Iteration")
title("Estimation error");
plot(Error);
figfig("idNonlinearTanks_error","pdf");
figfig("idNonlinearTanks_error","ps");

xlabel("Iteration")
title("Estimated Parameter");
plot(Par');
figfig("idNonlinearTanks_parameters","pdf");
figfig("idNonlinearTanks_parameters","ps");

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_lbl.txt version [833116b223].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system idNonlinearTanks (NonlinearTanks_lbl.txt)
%SUMMARY NonlinearTanks
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Component type C
	t1		conical		rho,g,V_1
	t2		conical		rho,g,V_2

% Component type R
	p1		discharge	alpha,beta
	p2		discharge	alpha,beta

% Component type Sf
        u		SS		external

% Component type De
        y		SS		external

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_numpar.txt version [01084da6b8].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sNonlinearTanks_numpar.txt)
# Generated by MTT at Mon Nov 29 17:36:54 EST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Parameters

## States 
v_1 = 	0.5;			# Tank 1
v_2 = 	0.25;			# Tank 2

## Tank parameters
g = 	1;			#Gravity
rho = 	1;			# sC,sNonlinearTanks
alpha = 	1.5;

## Pipe parameters
beta = 	1; 


Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_rep.tex version [d07140a9ae].






































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


\section{\textbf{abg.tex}: System idNonlinearTanks, representation \textbf{abg}, language \textbf{tex}}
\label{sec:idNonlinearTanks_abg.tex}
\index{\textbf{idNonlinearTanks} -- abg}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_abg.tex}


\section{\textbf{cbg.ps}: System idNonlinearTanks, representation \textbf{cbg}, language \textbf{ps}}
\label{sec:idNonlinearTanks_cbg.ps}
\index{\textbf{idNonlinearTanks} -- cbg}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks cbg ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:idNonlinearTanks_cbg.ps}.
\fig{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_cbg}
    {idNonlinearTanks_cbg.ps}
    {0.9}
    {System \textbf{idNonlinearTanks}, representation cbg}


\section{\textbf{struc.tex}: System idNonlinearTanks, representation \textbf{struc}, language \textbf{tex}}
\label{sec:idNonlinearTanks_struc.tex}
\index{\textbf{idNonlinearTanks} -- struc}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks struc tex 
\end{verbatim}
  \input{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_struc.tex}


\section{\textbf{sympar.tex}: System idNonlinearTanks, representation \textbf{sympar}, language \textbf{tex}}
\label{sec:idNonlinearTanks_sympar.tex}
\index{\textbf{idNonlinearTanks} -- sympar}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks sympar tex 
\end{verbatim}
  \input{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_sympar.tex}


\section{\textbf{odeso.ps}: System sidNonlinearTanks, representation \textbf{odeso}, language \textbf{ps}}
\label{sec:sidNonlinearTanks_odeso.ps}
\index{\textbf{sidNonlinearTanks} -- odeso}


MTT command:
\begin{verbatim}
mtt -oct -s sidNonlinearTanks odeso ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:sidNonlinearTanks_odeso.ps}.
\fig{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/sidNonlinearTanks_odeso}
    {sidNonlinearTanks_odeso.ps}
    {0.9}
    {System \textbf{sidNonlinearTanks}, representation odeso}


\section{\textbf{ippp.ps}: System idNonlinearTanks, representation \textbf{ippp}, language \textbf{ps}}
\label{sec:idNonlinearTanks_ippp.ps}
\index{\textbf{idNonlinearTanks} -- ippp}


MTT command:
\begin{verbatim}
mtt -oct -i euler idNonlinearTanks ippp ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:idNonlinearTanks_ippp.ps}.
\fig{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_ippp}
    {idNonlinearTanks_ippp.ps}
    {0.9}
    {System \textbf{idNonlinearTanks}, representation ippp}


\section{\textbf{rep.txt}: System idNonlinearTanks, representation \textbf{rep}, language \textbf{txt}}
\label{sec:idNonlinearTanks_rep.txt}
\index{\textbf{idNonlinearTanks} -- rep}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks rep txt 
\end{verbatim}
  \begin{verbatim}
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system idNonlinearTanks (idRC_rep.txt)
## Generated by MTT on" Thu Apr  5 11:17:27 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt idNonlinearTanks abg tex			# The system description
mtt idNonlinearTanks cbg ps 		        # The causal bond graph
mtt idNonlinearTanks struc tex	        # The system structure
mtt idNonlinearTanks sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt idNonlinearTanks dae tex	        # The system dae
## mtt idNonlinearTanks ode tex	        # The system ode 
## mtt idNonlinearTanks sspar tex		# Steady-state parameters
## mtt idNonlinearTanks ss tex 		# Steady state
## mtt idNonlinearTanks dm tex		# Descriptor matrices (of linearised system)
## mtt idNonlinearTanks sm tex		# State matrices (of linearised system)
## mtt idNonlinearTanks tf tex		# Transfer function (of linearised system)
## mtt idNonlinearTanks lmfr ps		# log modulus of frequency response (of linearised system)
## mtt idNonlinearTanks simpar tex		# Simulation parameters
## mtt idNonlinearTanks numpar tex		# Numerical simulation parameters
## mtt idNonlinearTanks state tex		# Simulation initial state
## mtt idNonlinearTanks input tex		# Simulation input
## mtt idNonlinearTanks logic tex		# Logic control
 mtt -oct -s sidNonlinearTanks odeso ps		# Simulation output
 mtt -oct -i euler idNonlinearTanks ippp ps

mtt idNonlinearTanks rep txt		# This file
  \end{verbatim}

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_rep.txt version [b96574c869].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system idNonlinearTanks (idRC_rep.txt)
## Generated by MTT on" Thu Apr  5 11:17:27 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/04/05 12:00:18  gawthrop
## Identification example
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt idNonlinearTanks abg tex			# The system description
mtt idNonlinearTanks cbg ps 		        # The causal bond graph
mtt idNonlinearTanks struc tex	        # The system structure
mtt idNonlinearTanks sympar tex	        # The system parameters
## Uncomment the following lines or add others
##mtt idNonlinearTanks dae tex	        # The system dae
 mtt idNonlinearTanks ode tex	        # The system ode 
## mtt idNonlinearTanks sspar tex		# Steady-state parameters
## mtt idNonlinearTanks ss tex 		# Steady state
## mtt idNonlinearTanks dm tex		# Descriptor matrices (of linearised system)
## mtt idNonlinearTanks sm tex		# State matrices (of linearised system)
## mtt idNonlinearTanks tf tex		# Transfer function (of linearised system)
## mtt idNonlinearTanks lmfr ps		# log modulus of frequency response (of linearised system)
## mtt idNonlinearTanks simpar tex		# Simulation parameters
## mtt idNonlinearTanks numpar tex		# Numerical simulation parameters
## mtt idNonlinearTanks state tex		# Simulation initial state
## mtt idNonlinearTanks input tex		# Simulation input
## mtt idNonlinearTanks logic tex		# Logic control
## mtt -oct -s sidNonlinearTanks odeso ps		# Simulation output
 mtt -i euler idNonlinearTanks ident ps

mtt idNonlinearTanks rep txt		# This file

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_simpar.txt version [1629ef8da3].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system idNonlinearTanks (sidNonlinearTanks_simpar.txt)
# Generated by MTT on Wed Apr 4 15:25:33 BST 2001.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_subs.r version [254628ce3b].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Default SUBS file
% File idRC_subs.r
% Generated by MTT on Tue Apr  3 09:43:38 BST 2001.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Put algebraic substitution commands here

%The following is now done automatically
% FOR ALL x,y LET x^y = pow(x,y);
END;

Added mtt/lib/examples/Identification/idNonlinearTanks/sC_abg.fig version [28ce05ebfc].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3105 3105 3195 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 3150 3150 3600
-6
6 6705 3105 6795 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6750 3150 6750 3600
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 450 4950 3465 C:c\001

Added mtt/lib/examples/Identification/idNonlinearTanks/sC_lbl.txt version [d300c10d36].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sC (sC_lbl.txt)
%SUMMARY sC
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	rho,g,V_0,V_0s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	c	sconical 	rho,g,V_0,V_0s

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external

Added mtt/lib/examples/Identification/idNonlinearTanks/sR_abg.fig version [7ee767975f].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 4455 3105 4545 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 3150 4500 3600
-6
6 5355 3105 5445 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 3150 5400 3600
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 390 4950 3465 R:r\001

Added mtt/lib/examples/Identification/idNonlinearTanks/sR_lbl.txt version [663f556b3d].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sR (sR_lbl.txt)
%SUMMARY sR
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	alpha,beta,alpha_s,beta_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	r	sdischarge 	alpha,beta,alpha_s,beta_s

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external

Added mtt/lib/examples/Identification/idNonlinearTanks/sconical.cr version [8f55376ab8].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% CR for conical tank example - sensitivity

in "conical.cr";

OPERATOR sconical;
%% The actual port (1) 
FOR ALL COMP, rho,g,V_0,V_0s,V,sV LET
    sconical(COMP, rho,g,V_0,V_0s,effort,1,
               V,state,1,
               sV,state,2)
    = conical(COMP, rho,g,V_0,effort,1,V,state,1);

%% The sensitivity port (2) 
FOR ALL COMP, rho,g,V_0,V_0s,V,sV LET
    sconical(COMP, rho,g,V_0,V_0s,effort,2,
               V,state,1,
               sV,state,2)
    = df(conical(COMP, rho,g,V_0,effort,1,V,state,1),V) * sV
    + df(conical(COMP, rho,g,V_0,effort,1,V,state,1),V_0)* V_0s;

END;;

Added mtt/lib/examples/Identification/idNonlinearTanks/sdischarge.cr version [12ca25468f].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% CR file for the sR component. - 2 port.
%% Special version just for this example.

%% CR for non-linear pipe discharge
%% Just do for flow input causality.

in "discharge.cr";

PROCEDURE l_discharge(COMP, alpha,beta,P);
BEGIN
  result := sub({x=P},df(discharge(COMP, alpha,beta,flow,1,x,effort,1), x));
  return result;
END;

OPERATOR sdischarge;
%% The actual port (1) -- Pressure input
FOR ALL COMP, alpha,beta,alpha_s,beta_s,P,sP LET
    sdischarge(COMP, alpha,beta,alpha_s,beta_s,flow,1,
               P,effort,1,
               sP,effort,2)
    = discharge(COMP, alpha,beta,flow,1,P,effort,1);

%% The sensitivity port (2) -- Pressure input
FOR ALL COMP, alpha,beta,alpha_s,beta_s,P,sP LET
    sdischarge(COMP, alpha,beta,alpha_s,beta_s,flow,2,
               P,effort,1,
               sP,effort,2)
    =  l_discharge(COMP, alpha,beta,P) * sP
    + df(discharge(COMP, alpha,beta,flow,1,P,effort,1), alpha)* alpha_s
    + df(discharge(COMP, alpha,beta,flow,1,P,effort,1), beta) * beta_s;
END;;

Added mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_lbl.txt version [fe01918d62].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system NonlinearTanks (NonlinearTanks_lbl.txt)
%SUMMARY NonlinearTanks
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	t1		sconical	rho,g,V_1,V_1s
	t2		sconical	rho,g,V_2,V_2s

% Component type R
	p1		sdischarge	alpha,beta,alphas,betas
	p2		sdischarge	alpha,beta,alphas,betas

% Component type Sf
        u		SS		external;0

% Component type De
        y		SS		external;external

Added mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_numpar.txt version [9e73863b4f].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sNonlinearTanks_numpar.txt)
# Generated by MTT at Mon Nov 29 17:36:54 EST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2001/04/05 12:00:18  gawthrop
# %% Identification example
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Parameters

## States 
v_1 = 	2.0;			# Tank 1
v_2 = 	1.0;			# Tank 2

## Tank parameters
g = 	1;			#Gravity
rho = 	1;			# sC,sNonlinearTanks
alpha = 	1.0;

## Pipe parameters
beta = 	2.0; 

## Sensitivity.
v_1s = 	0;			# Tank 1
v_2s = 	0;			# Tank 2

alphas = 	0;
betas  = 	0;

Added mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_simpar.txt version [a95d2a72de].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system sidNonlinearTanks (sidNonlinearTanks_simpar.txt)
# Generated by MTT on Wed Apr 4 15:25:33 BST 2001.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_subs.r version [2949fe13a0].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Default SUBS file
% File idRC_subs.r
% Generated by MTT on Tue Apr  3 09:43:38 BST 2001.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Put algebraic substitution commands here

FOR ALL x,y LET x^y = pow(x,y); % Use the pow function

ON ROUNDED; % No integer output

END;

Added mtt/lib/examples/Identification/idRC/create_data.m version [0dc531b79c].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
## Create some data
  c = 1;
  r = 5;
  tau = r*c;

  t = [0:0.1:10]';		# time
  one = ones(size(t));
  u = one;			# Step input
  y = one - exp(-t/tau);	# Exact step response

  save idRC_ident_data.dat y u t

Added mtt/lib/examples/Identification/idRC/idRC_abg.fig version [d7e806eb37].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2475 3600 2475 3375 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2475 5850 2475 5625 2700
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6975 3600 1125 3600 1125 1800 6975 1800 6975 3600
4 1 0 100 0 18 18 0.0000 4 210 600 1800 2565 Se:u\001
4 1 0 100 0 18 18 0.0000 4 210 750 4050 2565 RC:rc\001
4 1 0 100 0 18 18 0.0000 4 270 600 6345 2565 De:y\001

Added mtt/lib/examples/Identification/idRC/idRC_desc.tex version [fe46d73a25].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system idRC (idRC_desc.tex)
% Generated by MTT on Thu Apr 5 11:04:33 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2003/08/18 08:06:11  gawthrop
% %% A working version with more explantion
% %%
% %% Revision 1.2  2002/09/23 11:16:27  gawthrop
% %% New example for ident representation
% %%
% %% Revision 1.1  2001/04/05 11:57:29  gawthrop
% %% Identification example
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{idRC} is
   displayed in Figure \Ref{fig:idRC_abg.ps} and its label
   file is listed in Section \Ref{sec:idRC_lbl}.
   The subsystems are listed in Section \Ref{sec:idRC_sub}.

   
   This example illustrates the sensitivity approach to model-based
   system identification\footnote{Peter J Gawthrop, \emph{Sensitivity
       Bond Graphs}, Journal Franklin Institute, \textbf{337}, 2000,
     pp 907--922}.

   The system is a simple RC circuit with zero initial condition; the
   method identifies the resitance $r$.

   The data is created by typing:
\begin{verbatim}
make
\end{verbatim}
To see the results, type: 
\begin{verbatim}
mtt -oct -i euler  idRC ident view
\end{verbatim}

   \paragraph{NB} All sensitivity coefficients in idRC\_simpar.txt must
   be set to zero.

Added mtt/lib/examples/Identification/idRC/idRC_ident_numpar.m version [1e49a50185].








































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [y,u,t,par_names,Q,extras] = idRC_ident_numpar;

  ## usage: [y,u,t,par_names,Q,extras] = idRC_ident_numpar;
  ## Edit for your own requirements
  ## Created by MTT on 

    
  ## This section sets up the data source
  ## simulate = 0  Real data (you supply idRC_ident_data.dat)
  ## simulate = 1  Real data input, simulated output
  ## simulate = 2  Unit step input, simulated output
  simulate = 0;
  

  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = idRC_def;
  simpars = sidRC_simpar;

  ## Access or create data
  if (simulate<2)		# Get the real data
    if (exist("idRC_ident_data.dat")==2)
      printf("Loading idRC_ident_data.dat\n");
      load idRC_ident_data.dat
    else
      printf("Please create a loadable file idRC_ident_data.dat containing y,u and t\n");
      return
    endif
  else 
    switch simulate
      case 2			# Step simulation
	t = [0:simpars.dt:simpars.last]';
	u = ones(size(t));
      otherwise
	error(sprintf("simulate = %i not implemented", simulate));
    endswitch
  endif
  
  if (simulate>0)
    par = idRC_numpar();
    x_0 = idRC_state(par);
    dt = t(2)-t(1);
    simpars.dt = dt;
    simpars.last = t(length(t));
    y =  idRC_sim(zeros(n_x,1), par, simpars, u);
  endif

  ## Default parameter names - Put in your own here
  sympar = idRC_sympar;	# Symbolic params as structure
  par_names = struct_elements (sympar);	# Symbolic params as strings
  [n,m] = size(par_names);	# Size the string list

  ## Sort by index
  for [i,name] = sympar
    par_names(i,:) = sprintf("%s%s",name, blanks(m-length(name)));
  endfor
  
  par_names = "r";		# Estimate r only

  ## Output weighting vector
  Q = ones(n_y,1);
  
  ## Extra parameters
  extras.criterion = 1e-5;
  extras.emulate_timing = 0;
  extras.max_iterations = 10;
  extras.simulate = simulate;
  extras.v =  1e-2;
  extras.verbose = 1;
  extras.visual = 1;

endfunction

Added mtt/lib/examples/Identification/idRC/idRC_rep.txt version [643d9abc64].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system idRC (idRC_rep.txt)
## Generated by MTT on" Thu Jun 27 17:03:00 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/09/23 11:42:14  gawthrop
## Example uses simulated data from idRC_ident_data
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt idRC abg tex			# The system description
##mtt idRC cbg ps 		        # The causal bond graph
mtt idRC struc tex	        # The system structure
mtt idRC sympar tex	        # The system parameters

## Uncomment the following lines or add others
## mtt idRC dae tex	        # The system dae
## mtt idRC ode tex	        # The system ode 
## mtt idRC sspar tex		# Steady-state parameters
## mtt idRC ss tex 		# Steady state
## mtt idRC dm tex		# Descriptor matrices (of linearised system)
## mtt idRC sm tex		# State matrices (of linearised system)
## mtt idRC tf tex		# Transfer function (of linearised system)
## mtt idRC lmfr ps		# log modulus of frequency response (of linearised system)
## mtt idRC simpar txt		# Simulation parameters
## mtt idRC numpar txt		# Numerical simulation parameters
## mtt idRC state txt		# Simulation initial state
## mtt idRC input txt		# Simulation input
## mtt idRC logic txt		# Logic control
## mtt idRC odeso ps		# Simulation output


## Linear identificationm
##mtt idRC ident_numpar tex
mtt idRC ident ps
##mtt idRC ident_comparison ps
mtt idRC ident_par tex

mtt idRC rep txt		# This file

Added mtt/lib/examples/Identification/idRC/sidRC_numpar.txt version [118b6b97f6].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System sidRC, representation numpar, language txt; 
## File sidRC_numpar.txt; 
## Generated by MTT on Mon Sep 23 11:39:27 BST 2002; 



c	= 1.0; # Default
cs	= 0.0; # MUST BE ZERO
r	= 1.0; # Default
rs	= 0.0; # MUST BE ZERO
us	= 0.0; # MUST BE ZERO

Added mtt/lib/examples/Inverse/iMacroMicro/Make version [d0363e1a1b].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
%Makes the figures for the paper/report.
mtt macmic cbg ps
mtt imacmic cbg ps
mtt imacmic sm  m
mtt imacmic numpar m

octave figures.m

Added mtt/lib/examples/Inverse/iMacroMicro/figures.m version [6e0d24fe3b].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Set up the parameters
imacmic_numpar;   

% Range of damping for the macro controller
D_1 = [0:0.1:2];

% Compute the damping factor d and save in arrray DD
% -- uses zeros of system
% $$$ DD = [];
% $$$ for d_1 = D_1
% $$$  [A,B,C,D] = macmic_dm(m_1,m_2,b_1,b_2,k_2,k_t,b_t,b_3,m_3,p_1,d_1);
% $$$  zz = ss2zp(A,B,C,D,1);
% $$$  z = (zz(:,2));
% $$$  re = sort(real(z));
% $$$  im = sort(imag(z));
% $$$  d = -re./sqrt(re.^2 + im.^2);
% $$$  d = sort(d);
% $$$  DD = [DD d];
% $$$ end;
% $$$ 
% $$$ plot(D_1,min(DD)); grid
% $$$ xlabel('Derivative gain');
% $$$ ylabel('Damping factor');
% $$$ 
% $$$ 

% Compute the damping factor d and save in arrray DD
% -- uses poles of inverse system
DD1 = [];
for d_1 = D_1
 [A] = imacmic_sm;
 z = eig(A);

 re = (real(z));
 im = (imag(z));
 d = -re./sqrt(re.^2 + im.^2);
 d = sort(d);
 DD1 = [DD1 d];
end;
minDD1 = min(DD1);

plot(D_1,minDD1); grid
xlabel('Derivative gain');
ylabel('Damping factor');

Maximum_Damping = max(minDD1)
index = minDD1 == Maximum_Damping*ones(size(minDD1));
Opt_gain = index*D_1'

% Plot on disk
set term postscript
set output "damping.ps"
plot(D_1,minDD1); grid


 

Added mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_abg.fig version [cf9545f928].
























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2706 4806 3606 4806 3456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2406 5106 2406 6006 2556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3906 5106 3906 6006 4056 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4808 8108 4808 7958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 4808 9608 4808 9458 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8408 5108 8408 6008 8558 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4508 8108 3608 8108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 3608 9608 4508 9383 4508
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9909 5109 9909 6009 10059 5859
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6908 5108 6908 6008 7058 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8405 2405 8405 3305 8555 3155
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11407 5107 11407 6007 11557 5857
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11406 3306 11406 2406 11556 2556
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4806 5106 4806 4956 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5406 5106 5406 6006 5556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4506 5106 3606 5106 3831
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 3305 5405 2405 5555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2405 3305 2405 2405 2555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 4807 12607 4807 12457 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 3607 12607 4507 12382 4507
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2105 1805 2105 905 2255 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2705 1805 2705 905 2855 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 4806 6606 4806 6456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 3606 6606 4506 6381 4506
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2704 3604 3604 4504 3379 4504
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4808 2108 4808 1958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4508 2108 3608 2108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 681 3606 1131 3606
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 906 4506 906 3606 1056 3756
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12905 4505 12905 3605 13055 3755
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4807 11107 4807 10957 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4507 11107 3607 11107 3832
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8400 3300 8625 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12900 3600 13125 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12675 4500 12900 4500
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8175 2400 8400 2400
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 1501 5401 301 5401 301 3001 1501 3001 1501 5401
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 3300 2700 1500 2700 1500 450 3300 450 3300 2700
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 3000 6600 1800 6600 1800 3000 3000 3000 3000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 4501 6601 3301 6601 3301 3901 4501 3901 4501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 6000 6600 4800 6600 4800 1800 6000 1800 6000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7501 6601 6301 6601 6301 3901 7501 3901 7501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9000 6600 7800 6600 7800 1800 9000 1800 9000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 10501 6601 9301 6601 9301 3901 10501 3901 10501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 12000 6600 10800 6600 10800 1800 12000 1800 12000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 13501 5401 12301 5401 12301 3001 13501 3001 13501 5401
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11700 4575 11700 4800
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 12600 4800 12600 5025
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 10200 4575 10200 4800
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11100 4800 11100 5025
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9600 4500 9450 4650
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8700 3600 8850 3450
4 1 -1 0 0 0 20 0.0000 4 195 150 2406 4881 0\001
4 1 -1 0 0 0 20 0.0000 4 195 585 3906 6381 I:m1\001
4 1 -1 0 0 0 20 0.0000 4 210 585 2405 6380 R:b1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2405 3680 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3906 4881 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 8408 4883 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 8408 3683 0\001
4 1 -1 0 0 0 20 0.0000 4 210 585 8483 6383 R:b3\001
4 1 -1 0 0 0 20 0.0000 4 210 675 8407 2182 SS:f2\001
4 1 -1 0 0 0 20 0.0000 4 195 585 9906 6381 I:m3\001
4 1 -1 0 0 0 20 0.0000 4 195 585 6905 6380 I:m2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 11407 4882 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 11407 3682 0\001
4 1 -1 0 0 0 20 0.0000 4 210 525 11406 2181 C:kt\001
4 1 -1 0 0 0 20 0.0000 4 210 525 11482 6382 R:bt\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5406 4881 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5406 3681 0\001
4 1 -1 0 0 0 20 0.0000 4 210 585 5481 6381 R:b2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 12909 4884 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 6908 4883 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2404 2179 1\001
4 1 -1 0 0 0 20 0.0000 4 255 585 2779 754 C:p1\001
4 1 -1 0 0 0 20 0.0000 4 210 585 2104 754 R:d1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 910 4885 1\001
4 1 -1 0 0 0 20 0.0000 4 210 675 902 3377 SS:fb\001
4 1 -1 0 0 0 20 0.0000 4 210 615 12905 3380 SS:ft\001
4 1 -1 0 0 0 20 0.0000 4 195 150 9909 4884 1\001
4 1 -1 0 0 0 20 0.0000 4 210 585 5405 2180 C:k2\001
4 1 1 1 0 3 20 0.0000 4 210 1455 900 5700 Macro base\001
4 1 1 1 0 3 20 0.0000 4 210 1800 2401 376 Macro control\001
4 1 1 1 0 3 20 0.0000 4 195 1950 2400 6900 Macro actuator\001
4 1 1 1 0 3 20 0.0000 4 195 1530 3900 3825 Macro mass\001
4 1 1 1 0 3 20 0.0000 4 195 1470 6900 3825 Micro mass\001
4 1 1 1 0 3 20 0.0000 4 270 1890 5400 1650 Compliant link\001
4 1 1 1 0 3 20 0.0000 4 195 1890 8475 1650 Micro actuator\001
4 1 1 1 0 3 20 0.0000 4 255 1125 9900 3825 Tip mass\001
4 1 1 1 0 3 20 0.0000 4 270 2985 11400 1650 Compliant environment\001
4 1 1 1 0 3 20 0.0000 4 255 1305 12901 5701 Tip sensor\001

Added mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_desc.tex version [52d78b057e].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system iMacroMicro (iMacroMicro_desc.tex)
% Generated by MTT on Tue Dec 9 18:13:04 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/02/22 22:24:27  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iMacroMicro} is
   displayed in Figure \Ref{iMacroMicro_abg} and its label
   file is listed in Section \Ref{sec:iMacroMicro_lbl}.
   The subsystems are listed in Section \Ref{sec:iMacroMicro_sub}.

This is a Bond Graph model of the macro-micro manipulation system
discussed by Sharon in his thesis and by Sharon, Hogan and Hardt in
various papers. The micro loop is inverted whilst leaving the macro
control in place. This {\em partial inverse\/} gives information about
the {\em zero dynamics\/} of the micro control system with the
particular macro controller in place and allows desidn of the macro
controller to ease the design of the micro controller.


%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_lbl.txt version [eda41e1822].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file (macmic_lbl.txt)
%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Masses
m1	lin	flow,m_1
m2	lin	flow,m_2
m3	lin	flow,m_3

%Springs
k2	lin	state,k_2
kt	lin	state,k_t

%Dampers
b1	lin	flow,b_1
b2	lin	flow,b_2
b3	lin	flow,b_3
bt	lin	flow,b_t

%Source/sensors
f2	SS	external,internal
ft	SS	external,0
fb	SS	internal,0

%Control
p1	lin	flow,p_1
d1	lin	flow,d_1



Added mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_numpar.txt version [b385767fcd].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;

Added mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_rep.txt version [e84c5723e2].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system iMacroMicro (iMacroMicro_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:49:22  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iMacroMicro abg tex
mtt iMacroMicro cbg ps
mtt iMacroMicro struc tex
mtt iMacroMicro dae tex
mtt iMacroMicro dm tex
mtt iMacroMicro tf tex
mtt iMacroMicro numpar txt
mtt iMacroMicro lmfr ps 
mtt iMacroMicro lpfr ps 
mtt iMacroMicro sro ps 
mtt iMacroMicro odeso ps 

Added mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_simpar.txt version [1372589ac1].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system iMacroMicro (iMacroMicro_simpar.txt)
# Generated by MTT on Wed Nov 18 10:08:20 GMT 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -2;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Inverse/iNMP/NMP/NMP_abg.fig version [514aa7b44f].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3903 2403 4803 2403 4653 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5403 2403 6303 2403 6153 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 2103 3603 1203 3753 1353
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3002 3302 2402 3302 2627
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3905 4201 4805 4201 4655 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 4201 6305 4201 6155 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3605 4501 3605 5401 3755 5251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3602 3302 4202 3077 4202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7803 3302 8703 3302 8553 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1203 3302 2103 3302 1953 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2101 3076 2101 3301
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2101 3301 2101 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8701 3076 8701 3301
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8701 3301 8701 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5103 2103 5103 1203 5253 1353
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 3000 5700 600 3000 600 3000 3000 5700 3000
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 6000 5700 3600 3000 3600 3000 6000 5700 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4200 7650 3600 7650 3825
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7052 2402 7652 3002 7427 3002
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5100 4500 5100 5400 5250 5250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4800 4501 4164 5137 4376 5137
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 2478 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 2478 0\001
4 1 -1 0 0 0 20 0.0000 4 240 660 3602 1052 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2402 3377 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 4278 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 4278 0\001
4 1 -1 0 0 0 20 0.0000 4 195 720 6603 4278 AE:m\001
4 1 -1 0 0 0 20 0.0000 4 240 645 3603 5778 R:r_f\001
4 1 -1 0 0 0 20 0.0000 4 195 150 7577 3377 1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 751 3376 SS:e1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 9151 3376 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 240 690 5102 1052 C:c_s\001
4 1 1 1 0 3 20 0.0000 4 270 1515 4200 375 Slow system\001
4 1 1 1 0 3 20 0.0000 4 255 1470 4200 6450 Fast system\001
4 1 -1 0 0 0 20 0.0000 4 255 630 6678 2478 AE:p\001
4 1 -1 0 0 0 20 0.0000 4 240 675 5104 5779 C:c_f\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4203 5478 R:r\001

Added mtt/lib/examples/Inverse/iNMP/NMP/NMP_desc.tex version [f95b4585ef].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system NMP (NMP_desc.tex)
% Generated by MTT on Tue Dec 9 17:34:06 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{NMP} is
   displayed in Figure \Ref{NMP_abg} and its label
   file is listed in Section \Ref{sec:NMP_lbl}.
   The subsystems are listed in Section \Ref{sec:NMP_sub}.

This is a simple non-minimum phase system with an inverse-type
response.  It is the standard fast negative and slow positive systems
in parallel. The corresponding inverse system \textbf{iNMP} is
unstable.


Added mtt/lib/examples/Inverse/iNMP/NMP/NMP_lbl.txt version [dfd1521cff].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system NMP (NMP_lbl.txt)
%SUMMARY NMP A simple non-minimum phase system
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/20 16:40:54  peterg
% %% New SS format
% %%
% %% Revision 1.1  1999/03/09 00:08:21  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	c_f
%ALIAS	$2	c_s
%ALIAS	$3	r_f
%ALIAS	$4	r_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	m		lin	-1
	p		lin	1

% Component type C
	c_f		lin	effort,c_f
	c_s		lin	effort,c_s

% Component type R
	r		lin	flow,r
	r_f		lin	flow,r_f
	r_s		lin	flow,r_s

% Component type SS
	e1		SS	external,internal
	e2		SS	external,0

Added mtt/lib/examples/Inverse/iNMP/NMP/NMP_numpar.txt version [1d7033f948].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (NMP_numpar.txt)
# Generated by MTT at Thu Oct  8 09:25:16 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_f = 	0.5; # NMP
c_s = 	1.0; # NMP
r = 	1.0; # NMP
r_f = 	1.0; # NMP
r_s = 	1.0; # NMP

Added mtt/lib/examples/Inverse/iNMP/NMP/NMP_rep.txt version [0e160c8365].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system NMP (NMP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt NMP abg tex
mtt NMP struc tex
mtt NMP ode tex
mtt NMP sm tex
mtt NMP tf tex

mtt NMP sro ps
mtt NMP lmfr ps
mtt NMP lpfr ps

Added mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_abg.fig version [ac324604a1].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3903 2403 4803 2403 4653 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5403 2403 6303 2403 6153 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 2103 3603 1203 3753 1353
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3002 3302 2402 3302 2627
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3905 4201 4805 4201 4655 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 4201 6305 4201 6155 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3605 4501 3605 5401 3755 5251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3602 3302 4202 3077 4202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7803 3302 8703 3302 8553 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1203 3302 2103 3302 1953 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2101 3301 2101 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8701 3301 8701 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5103 2103 5103 1203 5253 1353
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 3000 5700 600 3000 600 3000 3000 5700 3000
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 6000 5700 3600 3000 3600 3000 6000 5700 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4200 7650 3600 7650 3825
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7052 2402 7652 3002 7427 3002
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5100 4500 5100 5400 5250 5250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4800 4501 4164 5137 4376 5137
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1200 3075 1200 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7800 3075 7800 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6300 2400 6300 2625
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5400 2175 5400 2400
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 2478 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 2478 0\001
4 1 -1 0 0 0 20 0.0000 4 240 660 3602 1052 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2402 3377 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 4278 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 4278 0\001
4 1 -1 0 0 0 20 0.0000 4 195 720 6603 4278 AE:m\001
4 1 -1 0 0 0 20 0.0000 4 240 645 3603 5778 R:r_f\001
4 1 -1 0 0 0 20 0.0000 4 195 150 7577 3377 1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 751 3376 SS:e1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 9151 3376 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 240 690 5102 1052 C:c_s\001
4 1 1 1 0 3 20 0.0000 4 270 1515 4200 375 Slow system\001
4 1 1 1 0 3 20 0.0000 4 255 1470 4200 6450 Fast system\001
4 1 -1 0 0 0 20 0.0000 4 255 630 6678 2478 AE:p\001
4 1 -1 0 0 0 20 0.0000 4 240 675 5104 5779 C:c_f\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4203 5478 R:r\001

Added mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_desc.tex version [183722d9b6].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system iNMP (iNMP_desc.tex)
% Generated by MTT on Tue Dec 9 17:34:06 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iNMP} is
   displayed in Figure \Ref{iNMP_abg} and its label
   file is listed in Section \Ref{sec:iNMP_lbl}.
   The subsystems are listed in Section \Ref{sec:iNMP_sub}.

This is a simple non-minimum phase system with an inverse-type
response.  It is the standard fast negative and slow positive systems
in parallel. The corresponding inverse system \textbf{iiNMP} is
unstable.


Added mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_lbl.txt version [2b065592af].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system iNMP (iNMP_lbl.txt)
%SUMMARY iNMP Inverse simple non-minimum phase system
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/20 16:42:42  peterg
% %% New SS format
% %%
% %% Revision 1.1  1999/03/09 00:10:07  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	c_f
%ALIAS	$2	c_s
%ALIAS	$3	r_f
%ALIAS	$4	r_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	m		lin	-1
	p		lin	1

% Component type C
	c_f		lin	effort,c_f
	c_s		lin	effort,c_s

% Component type R
	r		lin	flow,r
	r_f		lin	flow,r_f
	r_s		lin	flow,r_s

% Component type SS
	e1		SS	external,internal
	e2		SS	external,0

Added mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_numpar.txt version [1d7033f948].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (NMP_numpar.txt)
# Generated by MTT at Thu Oct  8 09:25:16 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_f = 	0.5; # NMP
c_s = 	1.0; # NMP
r = 	1.0; # NMP
r_f = 	1.0; # NMP
r_s = 	1.0; # NMP

Added mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_rep.txt version [1261b95adc].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system iNMP (iNMP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iNMP abg tex
mtt iNMP struc tex
mtt iNMP ode tex
mtt iNMP dm tex
mtt iNMP tf tex

mtt iNMP lmfr ps
mtt iNMP lpfr ps

Added mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_abg.fig version [88a5a6ef61].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3600 3375 3600 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3375 5175 2475 5400 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 3376 8325 2476 8550 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3600 4950 3600 4725 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 3601 8100 3601 7875 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 3780 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3600 6525 3600 6300 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3345 3600 2445 3825 2670
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3346 6750 2446 6975 2671
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 3780 2475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 3600 2475 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 3375 3780 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3780 4050 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4995 3375 5310 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8145 3375 8460 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6615 2475 6930 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 3600 6525 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7200 3780 7200 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7200 3555 7200 3375
4 0 -1 0 0 2 20 0.0000000 4 210 150 5085 3735 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3510 3690 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6660 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8235 3736 0\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 3465 2250 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4995 2250 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 6525 2250 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8100 2295 C:c_2\001
4 2 -1 0 0 2 20 0.0000000 4 270 750 2385 3690 SS:uy\001

Added mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_desc.tex version [5eddc121b6].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system iRC2c (iRC2c_desc.tex)
% Generated by MTT on Mon Apr 6 10:46:00 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iRC2c} is
   displayed in Figure \Ref{iRC2c_abg} and its label
   file is listed in Section \Ref{sec:iRC2c_lbl}.
   The subsystems are listed in Section \Ref{sec:iRC2c_sub}.

This example gives the inverse of a double RC circuit with
\emph{collocated} sensor/actuator pairing.


Added mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_input.txt version [bae2b6c20a].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (iRC2c_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	 1 ; # iRC2c (u_s)

Added mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_lbl.txt version [970ccd463e].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY iRC2c Inverse of double RC circuit with collocated io
%DESCRIPTION <Detailed description here>
%% Label file for system iRC2c (iRC2c_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_2		lin	effort,c_2

% Component type R
	r_1		lin	flow,r_1
	r_2		lin	flow,r_2

% Component type SS
	uy		SS	external,external


Added mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_numpar.txt version [434e56074d].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (iRC2c_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # iRC2c
c_1s = 	0.1; # iRC2c
c_2 = 	1.0; # iRC2c
c_2s = 	0.1; # iRC2c
r_1 = 	1.0; # iRC2c
r_1s = 	1.0; # iRC2c
r_2 = 	1.0; # iRC2c
r_2s = 	1.0; # iRC2c

# Initial states
x(1) = 	0.0; # iRC2c (c_1)
x(2) = 	0.0; # iRC2c (c_1s)
x(3) = 	0.0; # iRC2c (c_2)
x(4) = 	0.0; # iRC2c (c_2s)

Added mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_rep.txt version [0627609c1c].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system iRC2c (iRC2c_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iRC2c abg tex
mtt iRC2c struc tex
mtt iRC2c dae tex
mtt iRC2c dm tex
mtt iRC2c tf tex


Added mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_abg.fig version [094799a629].





































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 3600 5625 3420
2 1 2 2 1 7 1 0 -1 4.500 0 0 7 0 0 4
	 9585 3465 8325 3465 8190 3375 8190 2565
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3600 3375 3600 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3375 5175 2475 5400 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 3376 8325 2476 8550 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3600 4950 3600 4725 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 3601 8100 3601 7875 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8775 3601 9675 3601 9450 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 3375 3780 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5040 2475 5355 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6615 3375 6930 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8190 2475 8505 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 3600 2475 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3375 3780 3375 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 3780 4950 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 3780 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3600 6525 3600 6300 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7200 3600 7200 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8100 3780 8100 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8775 3600 8775 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 3600 9675 3780
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3345 3600 2445 3825 2670
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3346 6750 2446 6975 2671
2 1 1 1 1 7 1 0 -1 4.000 0 0 7 0 0 4
	 9585 3510 5400 3510 5310 3420 5310 2790
2 1 2 2 1 -1 1 0 -1 3.000 0 0 7 0 0 9
	 8392 2632 8392 3712 6862 3712 6862 2497 6727 2362 6592 2497
	 6592 3442 5242 3442 5242 2632
4 0 -1 0 0 2 20 0.0000000 4 210 150 5085 3735 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3510 3690 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6660 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8235 3736 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 2295 3645 SS:u\001
4 0 -1 0 0 2 20 0.0000000 4 270 585 9810 3690 SS:y\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 3465 2250 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4995 2250 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 6525 2250 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8100 2295 C:c_2\001

Added mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_desc.tex version [9163d2db1b].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system iRC2n (iRC2n_desc.tex)
% Generated by MTT on Mon Apr 6 10:46:52 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iRC2n} is
   displayed in Figure \Ref{iRC2n_abg} and its label
   file is listed in Section \Ref{sec:iRC2n_lbl}.
   The subsystems are listed in Section \Ref{sec:iRC2n_sub}.

This example gives the inverse of a double RC circuit with
\emph{non-collocated} sensor/actuator pairing.

Added mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_input.txt version [8fa4a991b7].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (iRC2n_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	 1 ; # iRC2n (u_s)

Added mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_lbl.txt version [3c4a501e9c].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY iRC2n Inverse of double RC circuit with non-collocated io
%DESCRIPTION <Detailed description here>
%% Label file for system iRC2n (iRC2n_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/20 16:43:52  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_2		lin	effort,c_2

% Component type R
	r_1		lin	flow,r_1
	r_2		lin	flow,r_2

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Added mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_numpar.txt version [3f9b896142].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (iRC2n_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # iRC2n
c_1s = 	0.1; # iRC2n
c_2 = 	1.0; # iRC2n
c_2s = 	0.1; # iRC2n
r_1 = 	1.0; # iRC2n
r_1s = 	1.0; # iRC2n
r_2 = 	1.0; # iRC2n
r_2s = 	1.0; # iRC2n

# Initial states
x(1) = 	0.0; # iRC2n (c_1)
x(2) = 	0.0; # iRC2n (c_1s)
x(3) = 	0.0; # iRC2n (c_2)
x(4) = 	0.0; # iRC2n (c_2s)

Added mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_rep.txt version [683a8983e4].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system iRC2n (iRC2n_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iRC2n abg tex
mtt iRC2n struc tex
mtt iRC2n dae tex
mtt iRC2n dm tex
mtt iRC2n tf tex



Added mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_simp.r version [a8454e246a].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce commands to simplify output for system iRC2n (iRC2n_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTu1 := y;

END;

Added mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_abg.fig version [64973640f8].







































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3601 4051 3601 3826 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3376 5851 2476 6076 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 3377 9001 2477 9226 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3601 5626 3601 5401 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 3602 8776 3602 8551 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 3601 4726 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3781 7201 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3601 7201 3601 6976 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 3346 4276 2446 4501 2671
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 3347 7426 2447 7651 2672
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 3376 5986 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 3376 9136 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 2476 7606 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3601 7201 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 3781 7876 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 3825 2925 4725 3150 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 5175 2925 6075 3150 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 6301 4051 6301 3826 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 6076 5851 5176 6076 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 6077 9001 5177 9226 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 6301 5626 6301 5401 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 6302 8776 6302 8551 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6301 4726 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6481 7201 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 6301 7201 6301 6976 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 6046 4276 5146 4501 5371
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 6047 7426 5147 7651 5372
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6481 3151 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6301 3151 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 6076 4456 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6481 4726 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 6076 5986 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 6076 9136 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 5176 7606 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6301 7201 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 6481 7876 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1756 6301 2656 6301 2431 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3780 4050 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 2475 4456 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 3781 4725 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 3645 7875 3465
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 6300 7875 6120
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3375 2700 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3600 2701 3600 2476 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3105 5175 2925 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2925 5175 2745 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 6480 1755 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 6300 1755 6120
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 4050 9900 1530 3600 1530 3600 4050 9900 4050
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 7020 9900 4500 3600 4500 3600 7020 9900 7020
4 2 -1 0 0 2 20 0.0000000 4 240 870 1710 3645 SS:u_s\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 3692 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 3737 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 3736 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 6392 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 6437 0\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4141 4951 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 5671 4951 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 7201 4951 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 6391 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 6436 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 1665 6345 SS:u\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8775 4950 C:c_2\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 4141 2251 R:r_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 5671 2251 C:c_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 7201 2251 R:r_2s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 8775 2250 C:c_2s\001
4 0 -1 0 0 2 20 0.0000000 4 210 390 2835 5040 AF\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 6391 0\001
4 1 1 1 0 0 20 0.0000000 4 210 450 2565 4455 e=0\001
4 1 1 1 0 0 20 0.0000000 4 210 420 2070 6570 f=0\001
4 1 1 1 0 0 20 0.0000000 4 270 2550 6750 1845 Specification system\001
4 1 1 1 0 0 20 0.0000000 4 270 1830 6615 6840 Inverse system\001

Added mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_desc.tex version [b9cbbd7602].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system saRC2c (saRC2c_desc.tex)
% Generated by MTT on Mon Apr 6 10:47:43 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{saRC2c} is
   displayed in Figure \Ref{saRC2c_abg} and its label
   file is listed in Section \Ref{sec:saRC2c_lbl}.
   The subsystems are listed in Section \Ref{sec:saRC2c_sub}.

This example gives the inverse of a double RC circuit with
\begin{itemize}
\item specification system,
\item amplifier connection and
\item collocated sensor/actuator pairing.
\end{itemize}


Added mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_input.txt version [5f23f78e18].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (saRC2c_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:53:33  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 16:20:22 BST 2003: u(1) =	 1 ; # saRC2c (u_s)
sarc2c__u_s	= 1.0; 

Added mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_lbl.txt version [a4d16b5d03].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY saRC2c
%DESCRIPTION <Detailed description here>
%% Label file for system saRC2c (saRC2c_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_1s		lin	effort,c_1s
	c_2		lin	effort,c_2
	c_2s		lin	effort,c_2s

% Component type R
	r_1		lin	flow,r_1
	r_1s		lin	flow,r_1s
	r_2		lin	flow,r_2
	r_2s		lin	flow,r_2s

% Component type SS
	u		SS	external,0
	u_s		SS	external,external

Added mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_numpar.txt version [f33e6310a9].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (saRC2c_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:53:33  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # saRC2c
c_1s = 	0.1; # saRC2c
c_2 = 	1.0; # saRC2c
c_2s = 	0.1; # saRC2c
r_1 = 	1.0; # saRC2c
r_1s = 	1.0; # saRC2c
r_2 = 	1.0; # saRC2c
r_2s = 	1.0; # saRC2c

# Initial states
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(1) = 	0.0; # saRC2c (c_1)
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(2) = 	0.0; # saRC2c (c_1s)
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(3) = 	0.0; # saRC2c (c_2)
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(4) = 	0.0; # saRC2c (c_2s)

Added mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_rep.txt version [89a6a7bd2f].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system saRC2c (saRC2c_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:53:33  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt saRC2c abg tex
mtt saRC2c struc tex
mtt saRC2c dae tex
mtt saRC2c dm tex
mtt saRC2c tf tex

mtt saRC2c odeso ps
mtt saRC2c lmfr ps


Added mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_abg.fig version [ac27af0e16].














































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3601 4051 3601 3826 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3376 5851 2476 6076 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 3377 9001 2477 9226 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3601 5626 3601 5401 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 3602 8776 3602 8551 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 3601 4726 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3781 7201 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3601 7201 3601 6976 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 3346 4276 2446 4501 2671
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 3347 7426 2447 7651 2672
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 3376 5986 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 3376 9136 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 2476 7606 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3601 7201 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 3781 7876 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 3825 2925 4725 3150 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 5175 2925 6075 3150 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 6301 4051 6301 3826 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 6076 5851 5176 6076 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 6077 9001 5177 9226 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 6301 5626 6301 5401 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 6302 8776 6302 8551 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6301 4726 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6481 7201 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 6301 7201 6301 6976 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 6046 4276 5146 4501 5371
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 6047 7426 5147 7651 5372
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6481 3151 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6301 3151 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 6076 4456 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6481 4726 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 6076 5986 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 6076 9136 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 5176 7606 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6301 7201 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 6481 7876 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1756 6301 2656 6301 2431 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 4950 2701 4950 2476 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 4770
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 5130 1800 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2655 6480 2655 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3780 4050 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 2475 4456 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 3781 4725 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 3645 7875 3465
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 6300 7875 6120
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3375 2700 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3600 2701 3600 2476 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2925 6075 2745 6075
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3105 5175 2925 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 6300 1755 6120
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 4275 9900 1125 3600 1125 3600 4275 9900 4275
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 7650 9900 4500 3600 4500 3600 7650 9900 7650
4 2 -1 0 0 2 20 0.0000000 4 240 870 1710 3645 SS:u_s\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 3692 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 3737 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 3736 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 6392 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 6437 0\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4141 4951 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 5671 4951 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 7201 4951 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 6391 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 6436 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 1665 6345 SS:u\001
4 2 -1 0 0 2 20 0.0000000 4 210 990 1620 5040 SS:zero\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8775 4950 C:c_2\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 2835 5040 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 6391 1\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 4141 2251 R:r_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 5671 2251 C:c_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 7201 2251 R:r_2s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 8775 2250 C:c_2s\001
4 1 1 1 0 3 20 0.0000000 4 210 450 2250 4860 e=0\001
4 1 1 1 0 3 20 0.0000000 4 270 420 2250 5220 f=0\001
4 1 1 1 0 3 20 0.0000000 4 270 1845 6525 7110 Inverse system\001
4 1 1 1 0 3 20 0.0000000 4 270 2565 6660 1665 Specification system\001

Added mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_desc.tex version [26c739d9e0].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system szRC2c (szRC2c_desc.tex)
% Generated by MTT on Mon Apr 6 10:50:51 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{szRC2c} is
   displayed in Figure \Ref{szRC2c_abg} and its label
   file is listed in Section \Ref{sec:szRC2c_lbl}.
   The subsystems are listed in Section \Ref{sec:szRC2c_sub}.


This example gives the inverse of a double RC circuit with
\begin{itemize}
\item specification system,
\item zero-zero \textbf{SS} connection and
\item collocated sensor/actuator pairing.
\end{itemize}

Added mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_input.txt version [979b0df214].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (szRC2c_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:15  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 16:39:19 BST 2003: u(1) =	 1 ; # szRC2c (u_s)
szrc2c__u_s	= 1.0; 

Added mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_lbl.txt version [6c7ddb1b45].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY szRC2c Specification inverse of double RC circuit with collocated io
%DESCRIPTION <Detailed description here>
%% Label file for system szRC2c (szRC2c_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:15  peterg
% %% To RCS
% %%
% %% Revision 1.1  2000/05/20 16:44:55  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_1s		lin	effort,c_1s
	c_2		lin	effort,c_2
	c_2s		lin	effort,c_2s

% Component type R
	r_1		lin	flow,r_1
	r_1s		lin	flow,r_1s
	r_2		lin	flow,r_2
	r_2s		lin	flow,r_2s

% Component type SS
	u_s		SS	external,external
	zero		SS	0,0
	u		SS	external,internal

Added mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_numpar.txt version [f4e95e7050].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (szRC2c_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:15  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # szRC2c
c_1s = 	0.1; # szRC2c
c_2 = 	1.0; # szRC2c
c_2s = 	0.1; # szRC2c
r_1 = 	1.0; # szRC2c
r_1s = 	1.0; # szRC2c
r_2 = 	1.0; # szRC2c
r_2s = 	1.0; # szRC2c

# Initial states
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(1) = 	0.0; # szRC2c (c_1)
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(2) = 	0.0; # szRC2c (c_1s)
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(3) = 	0.0; # szRC2c (c_2)
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(4) = 	0.0; # szRC2c (c_2s)

Added mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_rep.txt version [2a2641f9d2].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system szRC2c (szRC2c_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:15  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt szRC2c abg tex
mtt szRC2c struc tex
mtt szRC2c dae tex
mtt szRC2c dm tex
mtt szRC2c tf tex

mtt zRC2c odeso ps
mtt szRC2c lmfr ps


Added mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_abg.fig version [2bd65cadb4].
























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2251 4726 3151 4726 2926 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 4501 4951 3601 5176 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 4502 8101 3602 8326 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4726 4726 4726 4501 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 4727 7876 4727 7651 4952
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 4727 9451 4727 9226 4952
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 4906 3151 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4726 3826 4546
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6301 4906 6301 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5401 4726 6301 4726 6076 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6976 4726 6976 4546
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 4905 3825 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4770 4500 5085 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6345 3600 6660 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 4905 6975 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7920 4500 8235 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 4725 9450 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 4680 9450 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10126 6301 9901 6076 11026 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9901 6076 9901 5896
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11026 6256 11026 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9675 4950 9675 5850 9900 5625
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5402 7427 5402 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 7427 3152 7427 2927 7652
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4952 7202 4952 6302 5177 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8102 7203 8102 6303 8327 6528
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3827 7427 4727 7427 4502 7652
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 7428 7877 7428 7652 7653
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8552 7428 9452 7428 9227 7653
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3242 7202 3557 7202
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4817 6302 5132 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6392 7202 6707 7202
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7967 6302 8282 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2252 7427 2252 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3152 7607 3152 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3827 7427 3827 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4727 7607 4727 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6302 7607 6302 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5402 7427 6302 7427 6077 7652
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6977 7427 6977 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7877 7607 7877 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8552 7427 8552 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3377 7172 3377 6272 3602 6497
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6527 7173 6527 6273 6752 6498
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 7425 9450 7605
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 4725 3150 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3240 3600 3555 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9901 4725 10801 4725 10576 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10800 4725 10800 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10800 4725 10800 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4516 3375 3616 3600 3841
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 4517 6525 3617 6750 3842
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9495 5850 9810 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 6300 9855 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9675 6313 9675 7213 9900 6988
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 7245 9495 7245
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9045 5355 9045 2250 2475 2250 2475 5355 9045 5355
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9045 8730 9045 5625 2475 5625 2475 8730 9045 8730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6300 4680 6300 4500
4 0 -1 0 0 2 20 0.0000000 4 210 150 4861 4861 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3286 4816 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6436 4817 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8011 4862 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 9586 4816 0\001
4 2 -1 0 0 2 20 0.0000000 4 240 870 2071 4771 SS:u_s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 3241 3376 R:r_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 6301 3376 R:r_2s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 4771 3376 C:c_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 7875 3375 C:c_2s\001
4 0 -1 0 0 2 20 0.0000000 4 210 990 11206 6166 SS:zero\001
4 1 1 1 0 3 20 0.0000000 4 210 450 10441 5986 e=0\001
4 1 1 1 0 3 20 0.0000000 4 270 420 10441 6346 f=0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 9585 6210 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4862 7562 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3287 7517 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6437 7518 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8012 7563 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 2072 7472 SS:u\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 3242 6077 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4772 6077 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 6302 6077 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 7876 6076 C:c_2\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 9630 7515 0\001
4 0 -1 0 0 2 20 0.0000000 4 270 855 10935 4815 SS:y_s\001
4 1 1 1 0 3 20 0.0000000 4 270 420 10260 5085 f=0\001
4 1 1 1 0 3 20 0.0000000 4 270 2565 5625 2745 Specification system\001
4 1 1 1 0 3 20 0.0000000 4 270 1845 5535 8280 Inverse system\001

Added mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_desc.tex version [c87760ad0d].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system szRC2n (szRC2n_desc.tex)
% Generated by MTT on Mon Apr 6 10:52:26 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{szRC2n} is
   displayed in Figure \Ref{szRC2n_abg} and its label
   file is listed in Section \Ref{sec:szRC2n_lbl}.
   The subsystems are listed in Section \Ref{sec:szRC2n_sub}.

This example gives the inverse of a double RC circuit with
\begin{itemize}
\item specification system,
\item zero-zero \textbf{SS} connection and
\item non-collocated sensor/actuator pairing.
\end{itemize}



%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_input.txt version [b039d69e85].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (szRC2n_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:46  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 16:43:05 BST 2003: u(1) =	 1 ; # szRC2n (u_s)
szrc2n__u_s	= 1.0; 

Added mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_lbl.txt version [3ac9c98526].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY szRC2n Specification inverse of double RC circuit with noncollocated io
%DESCRIPTION <Detailed description here>
%% Label file for system szRC2n (szRC2n_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:46  peterg
% %% To RCS
% %%
% %% Revision 1.1  2000/05/20 16:45:37  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_1s		lin	effort,c_1s
	c_2		lin	effort,c_2
	c_2s		lin	effort,c_2s

% Component type R
	r_1		lin	flow,r_1
	r_1s		lin	flow,r_1s
	r_2		lin	flow,r_2
	r_2s		lin	flow,r_2s

% Component type SS
	u_s		SS	external,internal
	y_s		SS	external,0
	zero		SS	0,0
	u		SS	external,internal

Added mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_numpar.txt version [73f4af03d4].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (szRC2n_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:46  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # szRC2n
c_1s = 	0.1; # szRC2n
c_2 = 	1.0; # szRC2n
c_2s = 	0.1; # szRC2n
r_1 = 	1.0; # szRC2n
r_1s = 	1.0; # szRC2n
r_2 = 	1.0; # szRC2n
r_2s = 	1.0; # szRC2n

# Initial states
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(1) = 	0.0; # szRC2n (c_1)
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(2) = 	0.0; # szRC2n (c_1s)
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(3) = 	0.0; # szRC2n (c_2)
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(4) = 	0.0; # szRC2n (c_2s)

Added mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_rep.txt version [57d3f6478f].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system szRC2n (szRC2n_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:46  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt szRC2n abg tex
mtt szRC2n struc tex
mtt szRC2n dae tex
mtt szRC2n dm tex
mtt szRC2n tf tex

mtt szRC2n odeso ps
mtt szRC2n lmfr ps


Added mtt/lib/examples/Inverse/iTanks/iTanks_abg.fig version [4413ea1185].














































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 900 3150 2025 3150 1755 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3150 3600 3150 3330 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 2925 2250 1800 2520 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 3151 8326 3151 8056 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8776 3151 9901 3151 9631 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 2926 6976 1801 7246 2071
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 2926 8551 1801 8821 2071
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5175 3150 4905 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3150 6750 3150 6480 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2925 3825 1800 4095 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2925 5400 1800 5670 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3375 6975 4500 7245 4230
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11295 5625 11295 450 45 450 45 5625 11295 5625
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 3150 1125 3150 2700 1305 2700
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 4
	 4500 1125 4500 2700 6300 2700 6300 1125
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 7650 1125 7650 2700 9675 2700
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1350 3600 9720 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 3375 3825 4500 4095 4230
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 900 2925 900 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2025 3150 2025 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 3375 3825 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 4500 4095 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2925 9900 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8775 3150 8775 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6705 3375 6930 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 4500 7200 4500
4 1 -1 0 0 2 20 0.0000 4 195 135 2250 3240 1\001
4 1 -1 0 0 2 20 0.0000 4 195 210 2250 1665 R\001
4 1 -1 0 0 2 20 0.0000 4 195 135 8551 3241 1\001
4 1 -1 0 0 2 20 0.0000 4 195 135 6976 3241 0\001
4 1 -1 0 0 2 20 0.0000 4 195 210 8551 1666 R\001
4 1 -1 0 0 2 20 0.0000 4 195 210 6976 1666 C\001
4 1 -1 0 0 2 20 0.0000 4 195 135 5400 3240 1\001
4 1 -1 0 0 2 20 0.0000 4 195 135 3825 3240 0\001
4 1 -1 0 0 2 20 0.0000 4 195 210 5400 1665 R\001
4 1 -1 0 0 2 20 0.0000 4 195 210 3825 1665 C\001
4 1 -1 0 0 2 20 0.0000 4 195 705 495 3240 SS:u1\001
4 1 -1 0 0 2 20 0.0000 4 195 705 10440 3240 SS:u2\001
4 1 -1 0 0 2 20 0.0000 4 255 675 3825 4725 SS:y1\001
4 1 -1 0 0 2 20 0.0000 4 255 675 6975 4770 SS:y2\001
4 1 1 1 0 3 20 0.0000 4 270 510 2295 1125 Pipe\001
4 1 1 1 0 3 20 0.0000 4 270 510 5445 1125 Pipe\001
4 1 1 1 0 3 20 0.0000 4 270 510 8595 1125 Pipe\001
4 1 1 1 0 3 20 0.0000 4 210 600 3870 1125 Tank\001
4 1 1 1 0 3 20 0.0000 4 210 600 6975 1125 Tank\001
4 1 1 1 0 3 20 0.0000 4 270 1665 5265 5445 System inverse\001

Added mtt/lib/examples/Inverse/iTanks/iTanks_desc.tex version [d912f0defd].


































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system iTanks (iTanks_desc.tex)
% Generated by MTT on Wed Nov 18 11:04:33 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Figure \Ref{iTanks_abg} shows the bond graph of a two-tank system
superimposed on a schematic diagram. 
The two \textbf{C} components corresponds to the fluid storage and how
it relates to the pressure at the base of the tanks. In this case, for
simplicity, each tank ($i=1$ or $i=2$) is assumed to have a unity constitutive relationship:
\begin{equation}
  \text{pressure} = p_i = v_i = \text{volume}
\end{equation}
The volumetric flow rate into the first, and out of the second, tank
is represented by the two unlabelled \textbf{R} components. Again,
each is assumed to have a unit constitutive relationship:
\begin{equation}
  \text{flow} = f_i = \Delta_i = \text{pressure drop}
\end{equation}
The volumetric flow rate between the first and the second  tanks
is represented  \textbf{R} component labelled $k$. The constitutive relationship is assumed
linear of the form:
\begin{equation}
  \text{flow} = f = k \Delta  = \text{pressure drop}
\end{equation}

The system has two inputs:
\begin{equation}
  \begin{aligned}
    u_1 &= \text{input pressure at left-hand pipe} \\
    u_2 &= \text{input pressure at right-hand pipe} 
  \end{aligned}
\end{equation}
and two outputs:
\begin{equation}
  \begin{aligned}
    y_1 &= p_1 = \text{pressure at left-hand tank} \\
    y_2 &= p_2 = \text{pressure at right-hand tank} 
  \end{aligned}
\end{equation}
The system transfer-function matrix is given by:
\begin{equation}
  \begin{aligned}
G_{11} = G_{22} &= \frac{(s + k + 1)}{(s^2 + 2 s {(k + 1)} + 2 k + 1)}\\
G_{12} = G_{21} &= \frac{k}{(s^2 + 2 s {(k + 1)} + 2 k + 1)}
\end{aligned}
\end{equation}

However, Figure \Ref{iTanks_abg} shows the causality of the
\textbf{SS} components to \emph{invert} the system with respect to its
inputs and outputs. Figure \Ref{fig:iTanks_cbg.ps} shows the causally
complete bond graph; this system has no dynamic components in integral
causality -- the inverse has no poles and therefore the system has no
zeros.

Some further representations of the inverse appear in the following
sections.


Added mtt/lib/examples/Inverse/iTanks/iTanks_lbl.txt version [51b222a0af].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY iTanks: Inversion of a two-tanks system
%DESCRIPTION This inverse system has no poles thus
%DESCRIPTION the system itself has no (multivariable) zeros
%% Label file for system iTanks (iTanks_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	u1		SS	external,internal
	u2		SS	external,internal
	y1		SS	external,0
	y2		SS	external,0

Added mtt/lib/examples/Inverse/iTanks/iTanks_rep.txt version [a71249d1e5].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system iTanks (iTanks_rep.txt)
# Generated by MTT on" Wed Nov 18 10:44:55 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt iTanks abg tex			# The system description
mtt iTanks cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
 mtt iTanks struc tex	        # The system structure
# mtt iTanks dae tex	        # The system dae
# mtt iTanks ode tex	        # The system ode 
# mtt iTanks sspar tex		# Steady-state parameters
# mtt iTanks ss tex 		# Steady state
mtt iTanks dm tex			# Descriptor matrices (of linearised system)
mtt iTanks tf tex
mtt iTanks lmfr ps		# log modulus of frequency response (of linearised system)
mtt iTanks lpfr ps		# log modulus of frequency response (of linearised system)
# mtt iTanks simpar tex		# Simulation parameters
# mtt iTanks numpar tex		# Numerical simulation parameters
# mtt iTanks input tex		# Simulation input
# mtt iTanks odeso ps		# Simulation output

Added mtt/lib/examples/Inverse/iTwoLink/ROD_abg.fig version [81af279f2a].




























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 4950 5850 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 4950 8550 5400
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 1065 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000000 4 240 1080 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1065 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1080 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1575 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1590 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001

Added mtt/lib/examples/Inverse/iTwoLink/ROD_desc.tex version [740b974979].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/examples/Inverse/iTwoLink/ROD_lbl.txt version [1f86f162c8].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system ROD (ROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2


	

Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_abg.fig version [b300b8132c].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 2476 4951 2701 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 3376 4051 4726 4276 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3781 4726 4276 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2476 4726 2476 5221
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4951 5626 4951 5401 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4681 6526 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2250 2475 2250 2700 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3780 2025 4275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2025 2475 2520
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 1980 6525 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 2250 7875 2250 7650 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 4950 7875 4950 7650 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8371 3376 7876 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 3376 8101 4726 8326 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8326 4726 8326 5221
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8370 675 7875 675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8100 675 8100 2025 8325 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8325 2025 8325 2520
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 5175 6075 675 6075 675 225 5175 225 5175 6075
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 675 5625 5175 5625
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 6075 6975 6075 6975 225 11475 225 11475 6075
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6975 5625 11475 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2250 9450 3375 9225 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 4950 9450 3825 9225 3825
4 1 -1 0 0 0 20 0.0000000 4 210 150 4051 5041 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 4050 2340 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 780 4050 585 SS:t1s\001
4 1 -1 0 0 0 20 0.0000000 4 210 750 6120 2340 AF:a1\001
4 1 -1 0 0 0 20 0.0000000 4 270 1290 1845 2340 msd:spec1\001
4 1 -1 0 0 0 20 0.0000000 4 270 1290 1846 5041 msd:spec2\001
4 1 -1 0 0 0 20 0.0000000 4 210 780 4051 3286 SS:t2s\001
4 1 -1 0 0 0 20 0.0000000 4 210 750 6121 5041 AF:a2\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8101 5041 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8100 2340 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 660 8100 585 SS:t1\001
4 1 1 1 0 0 20 0.0000000 4 270 1620 2880 5940 Specification\001
4 1 1 1 0 0 20 0.0000000 4 270 900 9270 5940 System\001
4 1 -1 0 0 0 20 0.0000000 4 210 660 8101 3286 SS:t2\001
4 1 -1 0 0 0 20 0.0000000 4 270 1500 9900 3690 twolink:syst\001
4 0 4 0 0 0 20 0.0000000 4 270 1080 9585 3330 [joint_1]\001
4 0 4 0 0 0 20 0.0000000 4 270 1080 9540 4140 [joint_2]\001

Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_desc.tex version [81019ef0b9].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system iTwoLink (iTwoLink_desc.tex)
% Generated by MTT on Mon Nov 17 10:42:48 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/01/19 10:08:21  peterg
% %% Added comment about linearisation point
% %%
% %% Revision 1.2  1998/01/19 09:57:26  peterg
% %% Added a discussion of the relevance of G(s).
% %%
% Revision 1.1  1997/12/09  16:53:27  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iTwoLink} is
   displayed in Figure \Ref{iTwoLink_abg} and its label
   file is listed in Section \Ref{sec:iTwoLink_lbl}.
   The subsystems are listed in Section \Ref{sec:iTwoLink_sub}.

This example illustrates the inversion of  two link manipulator
dynamics using two identical  simple mass-spring-damper systems as
specification systems.

The velocities $\omega_1=\omega_2$ specified by the specification
systems are given in Figure \Ref{fig:iTwoLink_odeso.ps-iTwoLink-t1s}
together with the input defined in Section \Ref{sec:iTwoLink_input.txt}.
The torques $\tau_1$ and $\tau_2$ required to give the these
velocities specified by the specification system are given in Figures
\Ref{fig:iTwoLink_odeso.ps-iTwoLink-t1} and
\Ref{fig:iTwoLink_odeso.ps-iTwoLink-t2} respectively.

The corresponding velocity/torque diagrams for joints 1 and 2 appear in
Figures \Ref{fig:iTwoLink_odeso.ps-iTwoLink-t1s:iTwoLink-t1}
\Ref{fig:iTwoLink_odeso.ps-iTwoLink-t2s:iTwoLink-t2} respectively.
Such diagrams can be used for actuator sizing in terms of torque,
velocity and power.

 
This non-linear system can be linearised (about the various
configurations) and small-signal frequency response methods applied.
For example, the four transfer functions $G_11$ to $G_22$ in Section
\Ref{sec:iTwoLink_tf} (representing the system linearised about zero
angles and velocities), give the small-signal relations between the
two spec. torques and the required system torques. Used together with
$G_31$ and $G_42$ (relating the spec. torques and the joint
velocities) gives, in principle, a method for evaluating actuator
requirements (for small signals) as a function of frequency.

Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_input.txt version [86101d6ed8].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (iTwoLink_input.txt)
# Generated by MTT at Mon Nov 17 10:40:37 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:56:50  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Mon Aug 18 18:15:41 BST 2003: u(1) =	1.0 - 2.0*(t>5.0) + 2.0*(t>15.0);; # t1s input torque
## Removed by MTT on Mon Aug 18 18:15:41 BST 2003: u(2) =	1.0 - 2.0*(t>5.0) + (t>15.0); # t2s input torque
itwolink__t1s	=	1.0 - 2.0*(t>5.0) + 2.0*(t>15.0); # t1s input torque
itwolink__t2s	=	1.0 - 2.0*(t>5.0) + (t>15.0); # t2s input torque

Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_lbl.txt version [d83014c071].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY iTwoLink: Inverse of two-link manipulator
%DESCRIPTION Uses the specification system idea to get an ordinary
%DESCRIPTION differential equation inverse.
%% Label file for system iTwoLink (iTwoLink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/17 15:50:45  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ALIAS INTF	General/INTF

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type AF
	a1		lin	flow,1
	a2		lin	flow,1

% Component type SS
	t1		SS	external,0
	t2		SS	external,0
	t1s		SS	external,external
	t2s		SS	external,external

% Component type msd
	spec1
	spec2

% Component type onelink
	syst

Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_numpar.txt version [8f4f09e883].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (iTwoLink_numpar.txt)
# Generated by MTT at Mon Nov 17 10:40:34 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
d_s = 	1.0; # Parameter d_s for msd
k_s = 	1.0; # Parameter k_s for msd
m_s = 	1.0; # Parameter m_s for msd
j_s = 	1.0; # Parameter j_s for twolink
l = 	1.0; # Parameter l for twolink
m_s = 	1.0; # Parameter m_s for twolink

Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_rep.txt version [7215155dba].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system iTwoLink (iTwoLink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:56:50  peterg
% %% To RCS
% %%
% %% Revision 1.1  1997/12/09 16:53:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iTwoLink abg tex
mtt iTwoLink struc tex
mtt iTwoLink simp r
mtt iTwoLink dae tex
mtt iTwoLink ode tex
mtt iTwoLink sspar r
mtt iTwoLink sm tex
mtt iTwoLink tf tex

mtt iTwoLink numpar txt
mtt iTwoLink input txt
mtt iTwoLink odeso ps  'iTwoLink__t1'
mtt iTwoLink odeso ps  'iTwoLink__t2'
mtt iTwoLink odeso ps  'iTwoLink__t1s'
mtt iTwoLink odeso ps  'iTwoLink__t1s:iTwoLink__t1'
mtt iTwoLink odeso ps  'iTwoLink__t2s:iTwoLink__t2'






Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_simp.r version [654a42ab54].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system twolink (twolink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Inverse/iTwoLink/iTwoLink_sspar.r version [d89c4eea57].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for ionelink (ionelink_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mttx1 := 0;
mttx2 := 0;
mttx3 := 0;
mttx4 := 0;
mttx5 := 0;
mttx6 := 0;

END;

Added mtt/lib/examples/Inverse/iTwoLink/itwolink_rep.txt version [e6822537da].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system itwolink (itwolink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -c itwolink abg tex
mtt -c itwolink struc tex
mtt -c itwolink simp r
mtt -c itwolink dae tex
mtt -c itwolink cse tex
mtt -c itwolink ode tex
mtt -c itwolink sspar r
mtt -c itwolink dm tex
mtt -c itwolink sm tex
mtt -c itwolink tf tex
mtt -c itwolink lmfr ps

mtt -c itwolink odes h
mtt -c itwolink numpar txt
mtt -c itwolink input txt
mtt -c itwolink odeso ps  'itwolink_t1'
mtt -c itwolink odeso ps  'itwolink_t2'
mtt -c itwolink odeso ps  'itwolink_t1s'
mtt -c itwolink odeso ps  'itwolink_t1s:itwolink_t1'
mtt -c itwolink odeso ps  'itwolink_t1s:itwolink_t2'
mtt -c itwolink rep txt





Added mtt/lib/examples/Inverse/iTwoLink/msd_abg.fig version [97c8be2457].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 6975 6750 1125 900 1125 900 6975 6750 6975
4 1 -1 0 0 0 20 0.0000000 4 210 150 3600 4185 1\001
4 0 -1 0 0 0 20 0.0000000 4 270 1200 5085 4140 R:damper\001
4 1 1 1 0 0 20 0.0000000 4 270 3585 3555 6300 Mass-spring-damper system\001
4 2 4 0 0 0 20 0.0000000 4 240 870 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000000 4 210 990 3600 5715 I:inertia\001
4 1 -1 0 0 0 20 0.0000000 4 270 1050 3555 2610 C:spring\001

Added mtt/lib/examples/Inverse/iTwoLink/msd_desc.tex version [47aeb1c32d].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system msd (msd_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msd} is
   displayed in Figure \Ref{msd_abg} and its label
   file is listed in Section \Ref{sec:msd_lbl}.
   The subsystems are listed in Section \Ref{sec:msd_sub}.


 \textbf{msd} is a simple Mass-Spring-Damper system with collocated
 force and velocity. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Inverse/iTwoLink/msd_lbl.txt version [4ba1d7187e].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY msd: Simple mass-spring damper
%DESCRIPTION <Detailed description here>
%% Label file for system msd (msd_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	spring		lin	state,k_s

% Component type I
	inertia		lin	flow,m_s

% Component type R
	damper		lin	flow,d_s

% Component type SS
	[in]		SS	external,external

Added mtt/lib/examples/Inverse/iTwoLink/oldROD_abg.fig version [81af279f2a].




























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 4950 5850 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 4950 8550 5400
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 1065 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000000 4 240 1080 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1065 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1080 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1575 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1590 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001

Added mtt/lib/examples/Inverse/iTwoLink/oldROD_desc.tex version [995adfaa28].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system oldROD (oldROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{oldROD} is
   displayed in Figure \Ref{oldROD_abg} and its label
   file is listed in Section \Ref{sec:oldROD_lbl}.
   The subsystems are listed in Section \Ref{sec:oldROD_sub}.

{\bf oldROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Added mtt/lib/examples/Inverse/iTwoLink/oldROD_lbl.txt version [0ac94f22b1].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY	oldROD: rigid rod in two dimensions
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system oldROD (oldROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2


	

Added mtt/lib/examples/Inverse/iTwoLink/twolink_abg.fig version [4bb685d60b].



















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 5625 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 2025 2250 4725 2250 4725 2700 4950 2475
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 2 4 0 0 0 20 0.0000 4 255 1380 1936 2341 SS:[joint_1]\001
4 2 4 0 0 0 20 0.0000 4 255 1380 1936 5716 SS:[joint_2]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5808 948 SS:v_y\001

Added mtt/lib/examples/Inverse/iTwoLink/twolink_desc.tex version [40badf236c].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system twolink (twolink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{twolink} is
   displayed in Figure \Ref{twolink_abg} and its label
   file is listed in Section \Ref{sec:twolink_lbl}.
   The subsystems are listed in Section \Ref{sec:twolink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses two compound components: {\bf ROD} and {\bf
GRAV}.  {\bf ROD} is essentially as described in Figure 10.2 {\bf
GRAV} represents gravity by a vertical accelleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Inverse/iTwoLink/twolink_lbl.txt version [d7401fba34].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY twolink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (twolink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j_s;m_s
rod2	none	l;l;j_s;m_s

%Zero velocity sources
v_x	 SS     internal,0
v_y	 SS	internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal


%Torque at joints
%f_a1	SS external,external
%f_a2	SS external,external

%Gravity
%g

Added mtt/lib/examples/Makefile version [96c3362987].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/make -f

# DESTDIR prefix required by Debian build process
INSTDIR=$(DESTDIR)/usr/share/mtt/lib/examples

configure: configure-stamp
configure-stamp:
	@touch configure-stamp

build: configure build-stamp
build-stamp:
	@touch build-stamp

clean:
	@touch clean.sh
	@-chmod a+x clean.sh
	@./clean.sh
	@rm -f clean.sh

distclean: clean

install: build clean.sh
	@install -d $(INSTDIR)
	@cp -a $(filter-out CVS Makefile debian, $(wildcard *)) $(INSTDIR)

.PHONY: FORCE

clean.sh: FORCE
	@echo '#! /bin/sh'					>>clean.sh
	@echo '# This file is auto-generated - do not edit'	>>clean.sh
	@echo "rm -f  $(INSTDIR)/examples"			>>clean.sh

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_abg.fig version [fc9a7335dd].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1125 2700 2250 2700 2025 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2745 2700 3870 2700 3645 2925
4 1 0 100 0 18 20 1.5708 4 225 675 1035 2700 Free\001
4 1 0 100 0 18 20 1.5708 4 300 3405 2610 2700 BernoulliEuler:Lump*20\001
4 1 0 100 0 18 20 1.5708 4 225 795 4230 2700 Fixed\001

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_desc.tex version [b37e0425c2].




























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system CantileverBeam (CantileverBeam_desc.tex)
% Generated by MTT on Mon Apr 19 07:04:54 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/05/18 04:01:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{CantileverBeam} is displayed in
Figure \Ref{fig:CantileverBeam_abg.ps} and its label file is listed in
Section \Ref{sec:CantileverBeam_lbl}.  The subsystems are listed in Section
\Ref{sec:CantileverBeam_sub}.
   
This example represents the dynamics of a uniform beam with one fixed
and one free end.  The beam is approximated by 20 equal lumps using
the Bernoulli-Euler approximation with damping. 
The input is the angular velocity of the fixed end, the output is the
linear velocity of the free end.

The system parameters are given in Section
\Ref{sec:CantileverBeam_numpar.tex}. Note that the numer of ban
segments has been set to 21. 

 The system has 20 states (10
modes of vibration), 1 inputs and 1 outputs.

The first 5 vibration frequencies are given in Table \ref{tab:freq}
togtherr with the theoretical (based on the Bernoulli-Euler beam with
the same values of $EI$ and $\rho A$. 
\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{||l|l|l||}
      \hline
      \hline
      Mode & Frequency & Theoretical frequency\\
      \hline
      1 &  76.14 &  76.14\\
      2 & 477.11 & 484.50\\
      3 &1330.62 &1334.55\\
      4 &2586.77 &2617.19\\
      5 &4225.14 &4323.77\\
       \hline
      \hline
    \end{tabular}
    \caption{Mode frequencies (rad $s^{-1}$)}
    \label{tab:freq}
  \end{center}
\end{table}





Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_input.txt version [0c2d8a210e].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (CantileverBeam_input.txt)
# Generated by MTT at Thu Apr 22 00:12:54 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/05/08 18:48:49  gawthrop
## Modified for new format with __
##
## Revision 1.1  2000/12/28 17:58:27  peterg
## To RCS
##
###############################################################

# Set the inputs
## Removed by MTT on Thu May  8 16:55:10 BST 2003: mttu(1) = exp(-t/0.1); 	# tau (CantileverBeam)
cantileverbeam__mttfixed__u__u	= exp(-t/0.1); 	# tau (CantileverBeam)

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_lbl.txt version [948cc2e88c].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system CantileverBeam (CantileverBeam_lbl.txt)
%SUMMARY CantileverBeam
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR n
%VAR BeamLength
%VAR BeamWidth
%VAR BeamThickness
%VAR Youngs
%VAR Density
%VAR Area
%VAR AreaMoment
%VAR EI
%VAR rhoA
%VAR k

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type BernoulliEuler
	Lump

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_numpar.txt version [c6d8e94627].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (CantileverBeam_numpar.txt)
# Generated by MTT at Mon Apr 19 06:24:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:58:27  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
N = 21;
BeamLength = 0.58;
BeamWidth = 0.05;
BeamThickness = 0.005;
Youngs = 68.94e9;
Density =  2712.8;
Area = BeamWidth*BeamThickness;
AreaMoment = (BeamWidth*pow(BeamThickness,3))/12;

EI = Youngs*AreaMoment;
rhoA = Density*Area;

dz = BeamLength/N;		# Incremental length
dm = rhoA*dz;			# Incremental mass
dk = EI/dz;			# Incremental stiffness
dr = 0;				# Damping

K = sqrt(EI/rhoA)/pow(BeamLength,2);	# Normalising factor


# EI= 58.6957			# from Reza
# rhoA= 0.7989			# from Reza
 







Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_rep.txt version [f61fd41422].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system CantileverBeam (CantileverBeam_rep.txt)
## Generated by MTT on" Mon Apr 19 06:43:08 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt CantileverBeam abg tex			# The system description
## mtt CantileverBeam cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt CantileverBeam struc tex	        # The system structure
## mtt CantileverBeam dae tex	        # The system dae
## mtt CantileverBeam ode tex	        # The system ode 
## mtt CantileverBeam sspar tex		# Steady-state parameters
## mtt CantileverBeam ss tex 		# Steady state
## mtt CantileverBeam dm tex		# Descriptor matrices (of linearised system)
## mtt CantileverBeam sm tex		# State matrices (of linearised system)
## mtt CantileverBeam tf tex		# Transfer function (of linearised system)
mtt CantileverBeam simpar tex		# Simulation parameters
mtt CantileverBeam numpar tex		# Numerical simulation parameters
## mtt CantileverBeam input tex		# Simulation input
## mtt CantileverBeam odeso ps		# Simulation output
mtt CantileverBeam lmfr ps		# log modulus of frequency response (of linearised system)

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_simpar.txt version [bbb93af30e].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system CantileverBeam (CantileverBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.001;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 200;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Fixed_abg.fig version [e0ba4ffe54].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 0 0 100 0 18 20 0.0000 4 225 1065 5625 1890 Sf:zero\001
4 0 0 100 0 18 20 0.0000 4 225 585 5625 2790 Sf:u\001
4 2 4 100 0 18 20 0.0000 4 300 1230 4140 1890 SS:[y_in]\001
4 2 4 100 0 18 20 0.0000 4 300 1785 4140 2790 SS:[theta_in]\001

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Fixed_lbl.txt version [8de3fd38c9].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Fixed (Fixed_lbl.txt)
%SUMMARY Fixed
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	y_in,theta_in

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_in]	SS		external,external
	[y_in]		SS		external,external

% Component type Sf
	u		SS		external
	zero		SS		0

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Free_abg.fig version [6e75a503c3].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 2 0 100 0 18 20 0.0000 4 300 585 4140 1890 Df:y\001
4 2 0 100 0 18 20 0.0000 4 225 1125 4140 2790 Se:zero\001
4 0 4 100 0 18 20 0.0000 4 300 1440 5490 1890 SS:[y_out]\001
4 0 4 100 0 18 20 0.0000 4 300 1995 5445 2790 SS:[theta_out]\001

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Free_lbl.txt version [623dab72b6].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Free (Free_lbl.txt)
%SUMMARY Free
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	y_out,theta_out

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Df
	y	SS	external

% Component type SS
	[theta_out]	SS		external,external
	[y_out]		SS		external,external

% Component type Se
	zero		SS		0


Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/frequencies.m version [2bba72298d].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [w_r,w_a,n_null] = frequencies (A,B,C,D)

  ## usage:  [w_r,w_a] = frequencies (A,B,C,D)
  ##
  ## Resonant and antiresonant frequencies for undampled beam

  poles = eig(A);
  Np = length(poles);
  zeros = tzero(A,B,C,D);
  Nz = length(zeros);
  w_r = sort(imag(poles)); w_r = w_r(Np/2+1:Np);
  w_a = sort(imag(zeros)); w_a = nozeros(w_a(Nz/2+1:Nz))';
  n_null = (Nz/2-length(w_a))*2;
endfunction

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/Fixed_lbl.txt version [8de3fd38c9].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Fixed (Fixed_lbl.txt)
%SUMMARY Fixed
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	y_in,theta_in

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_in]	SS		external,external
	[y_in]		SS		external,external

% Component type Sf
	u		SS		external
	zero		SS		0

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/Free_lbl.txt version [623dab72b6].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Free (Free_lbl.txt)
%SUMMARY Free
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	y_out,theta_out

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Df
	y	SS	external

% Component type SS
	[theta_out]	SS		external,external
	[y_out]		SS		external,external

% Component type Se
	zero		SS		0


Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/MakeFreqTable.m version [71cecf4031].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# ## Makes the table of resonant frequencies

# ## Actual resonant freqs
# fr_measured = [
# 	2.0683e+01
# 	7.5310e+01
# 	1.7080e+02
# 	3.0532e+02
# 	4.7414e+02];

# fa_measured = [
# 	 2.0896e+01
# 	 7.6867e+01
# 	 1.7794e+02
# 	 3.1890e+02
# 	 4.8768e+02];

## Parameters - ideal pinned beam
PinnedBeam_numpar;

## Ideal pinned beam - theory
[fr_theory] = beam_frequencies("pinned",ei,rhoa,beamlength)/(2*pi);
[fa_theory] = beam_frequencies("clamped-pinned",ei,rhoa,beamlength)/(2*pi);

## SM form to get poles and zeros of the model
# ## Ideal pinned
# [A,B,C,D] = PinnedBeam_sm;
# fr_model_ideal  = frequencies(A,B,C,D)/(2*pi);

# ## Actual with non-ideal pins 
# PinnedBeam_numpar;

[A,B,C,D] = PinnedBeam_sm;

[w_r, w_a]  = frequencies(A,B,C,D);
fr_model = w_r/(2*pi);
fa_model = w_a/(2*pi);


printf("\nIndex \t& Theory   \t& Model \t& Theory  \t& Model \\\\ \n");
printf("\\hline\n");
for i = 1:5
  printf("%i \t& %3.2f \t& %3.2f \t& %3.2f  \t& %3.2f\\\\ \n", i, \
	 fr_theory(i), fr_model(i), fa_theory(i), fa_model(i));
endfor

# printf("\nMode \t& Theory   \t& Model(ideal) \t& Model  \t& Actual \\\\ \n");
# printf("\\hline\n");
# for i = 1:5
#   printf("%i \t& %3.2f \t& %3.2f \t& %3.2f  \t& %3.2f\\\\ \n", i, fr_theory(i), \
# 	 fr_model_ideal(i), fr_model(i), fr_measured(i));
# endfor
	 
# printf("\nMode  \t& Theory  \t& Model  \t& Actual \\\\ \n");
# printf("\\hline\n");
# for i = 1:5
#   printf("%i \t& %3.2f \t& %3.2f \t& %3.2f \\\\ \n", i, fa_theory(i), fa_model(i), fa_measured(i));
# endfor
	





Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_abg.fig version [624a6ece3a].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2925 1980 3015 2520
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2970 2025 2970 2475
-6
6 4005 2880 4095 3420
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 2925 4050 3375
-6
6 8955 1980 9045 2520
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9000 2025 9000 2475
-6
6 7830 2880 7920 3420
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 7875 2925 7875 3375
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4770 2700 5895 2700 5670 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2700 7425 2700 7200 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2970 2250 4095 2250 3870 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 3150 4050 3150 3825 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 2250 9000 2250 8775 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 9000 3150 8775 3375
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 1125 225 1125 5400 10800 5400 10800 225 1125 225
4 1 0 100 0 18 20 1.5708 4 360 3855 4635 2700 BernoulliEuler:LumpL\001
4 1 0 100 0 18 20 1.5708 4 360 4170 6165 2700 BernoulliEuler:Lump*18\001
4 1 0 100 0 18 20 1.5708 4 360 3885 7740 2700 BernoulliEuler:LumpR\001
4 2 4 100 0 18 14 0.0000 4 210 585 3915 2070 [y_in]\001
4 2 4 100 0 18 14 0.0000 4 210 990 3915 2970 [theta_in]\001
4 0 4 100 0 18 14 0.0000 4 210 735 7965 1980 [y_out]\001
4 0 4 100 0 18 14 0.0000 4 210 1140 7965 2970 [theta_out]\001
4 2 0 100 0 18 20 0.0000 4 285 1230 2835 3285 SS:ssL\001
4 0 0 100 0 18 20 0.0000 4 285 1515 9135 2385 Sf:zeroR\001
4 0 0 100 0 18 20 0.0000 4 285 1260 9135 3285 SS:ssR\001
4 2 0 100 0 18 20 0.0000 4 285 1485 2835 2385 Sf:zeroL\001

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_desc.tex version [81085b5b72].






































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PinnedBeam (PinnedBeam_desc.tex)
% Generated by MTT on Mon Apr 19 07:04:54 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/11/24 22:17:26  peterg
% %% Updated to correspond to Reza's beam
% %%
% %% Revision 1.1  1999/10/11 05:08:14  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/05/18 04:01:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{PinnedBeam} is displayed in
Figure \Ref{fig:PinnedBeam_abg.ps} and its label file is listed in
Section \Ref{sec:PinnedBeam_lbl}.  The subsystems are listed in Section
\Ref{sec:PinnedBeam_sub}.
   
This example represents the dynamics of a uniform beam with two pinned
ends. The left-hand end is driven by a torque input and the
corresponding collocated angular velocity is measured.  The beam is
approximated by 20 equal lumps using the Bernoulli-Euler.  Because the
two end lumps have different causality to the rest of the beam lumps,
they are represented seperately.  The system has 40 states (20 modes
of vibration), 1 input and 1 output.

\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{|l|l|}
      \hline
      Name & Value\\
      \hline
      Beam Length, $L$       & 0.60 m\\
      Beam Width $w$             & 0.05 m\\
      Beam Thickness $t_b$   & 0.003\\
      Young's Modulus  $E$       & $68.94 \times 10^9$ \\
      Density          $\rho$    & 2712.8\\
      \hline
      Derived quantities & \\
      \hline
      $EI$                     & 7.76\\
      $\rho A$   & 0.40692 \\
      \hline
    \end{tabular}
    \caption{Beam parameters}
    \label{tab:beam}
  \end{center}
\end{table}


The beam was made of aluminium with physical dimensions and constants
given in Table \ref{tab:beam}. The derived beam constants are given by the
formulae:
\begin{equation}
  \label{eq:formulae}
  \begin{align}
    EI &= E \times w \frac{1}{12} t_b^3\\
    \rho A &= \rho \times w t_b
  \end{align}
\end{equation}

The system parameters are also given in Section
\Ref{sec:PinnedBeam_numpar.tex}.


\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{||l|l|l|l|l||}
      \hline
      \hline
Index   & $f_r$ (theory) & $f_r$ (model)& $f_a$ (theory) & $f_a$ (model) \\ 
\hline
1       & 19.05         & 19.01         & 29.72         & 31.28\\ 
2       & 76.24         & 75.57         & 96.50         & 100.80\\ 
3       & 171.58        & 168.29        & 200.73        & 208.20\\ 
4       & 304.76        & 294.89        & 344.13        & 350.88\\ 
5       & 476.34        & 452.25        & 524.98        & 525.23\\ 
      \hline
      \hline
    \end{tabular}
    \caption{Resonant and anti-resonant frequencies (Hz)}
    \label{tab:freq}
  \end{center}
\end{table}

Standard modal analysis give the theoretical system resonant
frequencies $f_r$ (based on the Bernoulli-Euler beam with the same values of
$EI$ and $\rho A$). The system anti-resonances $f_a$ correspond to those of
the \emph{inverse} system with reversed causality, that the driven
pinned end is replaced by a clamped end; again modal analysis of the
inverse system gives the system anti resonances. The model and
theoretical values are compared in Table \ref{tab:freq} for the first
5 modes. (This table was generated using the script MakeFreqTable.m)

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_input.txt version [5d573c78a5].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (PinnedBeam_input.txt)
# Generated by MTT at Thu Apr 22 00:12:54 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:59:05  peterg
## To RCS
##
###############################################################

# Set the inputs
pinnedbeam__mttfixed__u__u = exp(-t/0.1); 	# tau (PinnedBeam)

# Set the switches

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_lbl.txt version [a9ffe495c3].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system PinnedBeam (PinnedBeam_lbl.txt)
%SUMMARY PinnedBeam
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/08/01 12:11:57  peterg
% %% Added %Vars
% %%
% %% Revision 1.1  1999/10/11 05:08:22  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR Lumps
%VAR BeamLength
%VAR BeamWidth
%VAR BeamThickness
%VAR Youngs
%VAR Density
%VAR Area
%VAR AreaMoment
%VAR EI
%VAR rhoA

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type BernoulliEuler
	Lump
	LumpL
	LumpR

% Component type SS
	ssL	SS		external,external
	ssR	SS		0,internal

% Component type Sf
	zeroL	 none		0
	zeroR	 none		0


Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_numpar.txt version [ff4455d3d9].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (pPinnedBeam_numpar.txt)
# Generated by MTT at Mon Apr 19 06:24:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2003/06/11 16:03:06  gawthrop
# %% Updated examples for latest MTT.
# %%
# %% Revision 1.1  2000/12/28 17:59:05  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Number of lumps
Lumps = 20;			# Number of lumps

## Beam physical parameters
BeamLength = 0.60;
BeamWidth  = 0.05;
BeamThickness = 0.003;
Youngs = 68.94e9;
Density =  2712.8;
Area = BeamWidth*BeamThickness;
AreaMoment = (BeamWidth*pow(BeamThickness,3))/12;
EI = Youngs*AreaMoment;
rhoA = Density*Area;

## Segments
dz = BeamLength/Lumps;	        # Incremental length
dm = rhoA*dz;			# Incremental mass
dk = EI/dz;			# Incremental stiffness
dr = 0;				# Damping

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_rep.txt version [b3b35e35ca].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system PinnedBeam (PinnedBeam_rep.txt)
## Generated by MTT on" Mon Apr 19 06:43:08 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt PinnedBeam abg tex			# The system description
## mtt PinnedBeam cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt PinnedBeam struc tex	        # The system structure
## mtt PinnedBeam dae tex	        # The system dae
## mtt PinnedBeam ode tex	        # The system ode 
## mtt PinnedBeam sspar tex		# Steady-state parameters
## mtt PinnedBeam ss tex 		# Steady state
## mtt PinnedBeam dm tex		# Descriptor matrices (of linearised system)
## mtt PinnedBeam sm tex		# State matrices (of linearised system)
## mtt PinnedBeam tf tex		# Transfer function (of linearised system)
mtt PinnedBeam simpar tex		# Simulation parameters
mtt PinnedBeam numpar tex		# Numerical simulation parameters
## mtt PinnedBeam input tex		# Simulation input
## mtt PinnedBeam odeso ps		# Simulation output
mtt PinnedBeam lmfr ps		# log modulus of frequency response (of linearised system)

Added mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_simpar.txt version [3f7404ca28].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system PinnedBeam (PinnedBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 200;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_abg.fig version [7358b66296].





































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Inches
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2706 4806 3606 4806 3456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2406 5106 2406 6006 2556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3906 5106 3906 6006 4056 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4808 8108 4808 7958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 4808 9608 4808 9458 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8408 5108 8408 6008 8558 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4508 8108 3608 8108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 3608 9608 4508 9383 4508
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9909 5109 9909 6009 10059 5859
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6908 5108 6908 6008 7058 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8405 2405 8405 3305 8555 3155
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11407 5107 11407 6007 11557 5857
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11406 3306 11406 2406 11556 2556
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4806 5106 4806 4956 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5406 5106 5406 6006 5556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4506 5106 3606 5106 3831
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 3305 5405 2405 5555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2405 3305 2405 2405 2555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 4807 12607 4807 12457 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 3607 12607 4507 12382 4507
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2105 1805 2105 905 2255 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2705 1805 2705 905 2855 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 4806 6606 4806 6456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 3606 6606 4506 6381 4506
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2704 3604 3604 4504 3379 4504
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4808 2108 4808 1958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4508 2108 3608 2108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 681 3606 1131 3606
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 906 4506 906 3606 1056 3756
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12905 4505 12905 3605 13055 3755
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4807 11107 4807 10957 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4507 11107 3607 11107 3832
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8400 3300 8625 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12900 3600 13125 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12675 3600 12900 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8175 3300 8400 3300
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 1501 5401 301 5401 301 3001 1501 3001 1501 5401
2 2 1 2 1 7 1 0 -1 6.000 1 0 0 0 0 5
	 1502 452 3302 452 3302 3377 1502 3377 1502 452
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 4501 6601 3301 6601 3301 3901 4501 3901 4501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 6000 6600 4800 6600 4800 1800 6000 1800 6000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7501 6601 6301 6601 6301 3901 7501 3901 7501 6601
2 4 1 2 1 7 2 0 -1 6.000 0 0 7 0 0 5
	 9000 6600 7800 6600 7800 1800 9000 1800 9000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 10501 6601 9301 6601 9301 3901 10501 3901 10501 6601
2 4 1 2 1 -1 1 0 -1 6.000 0 0 7 0 0 5
	 12000 6600 10800 6600 10800 1800 12000 1800 12000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 13501 5401 12301 5401 12301 3001 13501 3001 13501 5401
4 1 -1 0 0 0 20 0.0000000 4 210 150 2406 4881 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 3906 6381 I:m1\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 2405 6380 R:b1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2405 3680 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 3906 4881 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8408 4883 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8408 3683 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 8483 6383 R:b3\001
4 1 -1 0 0 0 20 0.0000000 4 210 675 8407 2182 SS:f2\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 9906 6381 I:m3\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 6905 6380 I:m2\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 11407 4882 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 11407 3682 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 525 11406 2181 C:kt\001
4 1 -1 0 0 0 20 0.0000000 4 210 525 11482 6382 R:bt\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5406 4881 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5406 3681 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 5481 6381 R:b2\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 12909 4884 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 6908 4883 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2404 2179 1\001
4 1 -1 0 0 0 20 0.0000000 4 270 585 2779 754 C:p1\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 2104 754 R:d1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 910 4885 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 675 902 3377 SS:fb\001
4 1 -1 0 0 0 20 0.0000000 4 210 615 12905 3380 SS:ft\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 9909 4884 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 5405 2180 C:k2\001
4 1 1 1 0 3 20 0.0000000 4 240 1530 3901 6901 Macro mass\001
4 1 1 1 0 3 20 0.0000000 4 240 1800 2401 376 Macro control\001
4 1 1 1 0 3 20 0.0000000 4 240 1455 900 5700 Macro base\001
4 1 1 1 0 3 20 0.0000000 4 270 1890 5400 1650 Compliant link\001
4 1 1 1 0 3 20 0.0000000 4 240 1470 6901 6901 Micro mass\001
4 1 1 1 0 3 20 0.0000000 4 240 1890 8475 1650 Micro actuator\001
4 1 1 1 0 3 20 0.0000000 4 270 1125 9901 6901 Tip mass\001
4 1 1 1 0 3 20 0.0000000 4 270 2985 11400 1650 Compliant environment\001
4 1 1 1 0 3 20 0.0000000 4 270 1305 12901 5701 Tip sensor\001

Added mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_desc.tex version [3e936ec3d0].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system MacroMicro (MacroMicro_desc.tex)
% Generated by MTT on Tue Dec 9 17:55:41 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MacroMicro} is
   displayed in Figure \Ref{MacroMicro_abg} and its label
   file is listed in Section \Ref{sec:MacroMicro_lbl}.
   The subsystems are listed in Section \Ref{sec:MacroMicro_sub}.

This is a Bond Graph model of the macro-micro manipulation system
discussed by Sharon in his thesis and BY Sharon, Hogan and Hardt in
various papers.

Added mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_lbl.txt version [eda41e1822].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file (macmic_lbl.txt)
%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Masses
m1	lin	flow,m_1
m2	lin	flow,m_2
m3	lin	flow,m_3

%Springs
k2	lin	state,k_2
kt	lin	state,k_t

%Dampers
b1	lin	flow,b_1
b2	lin	flow,b_2
b3	lin	flow,b_3
bt	lin	flow,b_t

%Source/sensors
f2	SS	external,internal
ft	SS	external,0
fb	SS	internal,0

%Control
p1	lin	flow,p_1
d1	lin	flow,d_1



Added mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_numpar.txt version [d5d101b825].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+

m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;

Added mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_rep.txt version [420def6255].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system MacroMicro (MacroMicro_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt MacroMicro abg tex
mtt MacroMicro cbg ps
mtt MacroMicro struc tex
mtt MacroMicro dae tex
mtt MacroMicro dm tex
mtt MacroMicro tf tex
mtt MacroMicro numpar txt
mtt MacroMicro lmfr ps 
mtt MacroMicro sro ps 

Added mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_simpar.txt version [479d1e287e].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system MacroMicro (MacroMicro_simpar.txt)
# Generated by MTT on Thu Nov 9 15:19:17 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.01;        # Print interval
LAST        = 1.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_state.txt version [7abde731cb].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System MacroMicro, representation state, language txt; 
## File MacroMicro_state.txt; 
## Generated by MTT on Thu Nov  9 15:19:28 GMT 2000; 


MacroMicro_k2	= 0.0; # Default
MacroMicro_kt	= 0.0; # Default
MacroMicro_m1	= 0.0; # Default
MacroMicro_m2	= 0.0; # Default
MacroMicro_m3	= 0.0; # Default
MacroMicro_p1	= 0.0; # Default

Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_abg.fig version [6195b18731].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
0 32 #969296
0 33 #e7e7cf
0 34 #9e9a9e
0 35 #cf9200
0 36 #f761ae
0 37 #7171ff
0 38 #595d59
1 3 0 3 1 7 55 0 -1 0.000 1 0.0000 1845 2430 186 186 1845 2430 2031 2430
2 2 0 1 1 7 55 0 47 0.000 0 0 -1 0 0 5
	 1800 2475 4500 2475 4500 2925 1800 2925 1800 2475
2 1 0 3 1 7 55 0 -1 0.000 0 0 -1 0 0 2
	 1830 2467 3180 129
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 5625 4725 5625 4500 5850
2 1 0 3 1 7 55 0 -1 0.000 0 0 -1 0 0 12
	 4453 2442 4177 1964 3884 2024 4282 1579 3700 1707 4103 1268
	 3521 1396 3914 946 3337 1077 3749 632 3445 696 3158 215
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 5625 1575 5625 1800 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 5400 3150 4050 3375 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 7200 3150 5850 3375 6075
4 1 1 55 0 32 30 0.0000 4 315 240 2385 2295 q\001
4 0 1 55 0 3 30 0.0000 4 300 270 2025 1260 L\001
4 0 1 55 0 3 30 0.0000 4 300 270 3105 3510 L\001
4 1 1 55 0 32 30 0.0000 4 225 195 1530 2250 t\001
4 1 0 100 0 18 18 0.0000 4 195 150 3150 5715 1\001
4 1 0 100 0 18 18 0.0000 4 210 390 3195 3915 R:r\001
4 1 4 100 0 18 18 0.0000 4 270 930 3060 7515 SS:[yu]\001
4 1 0 100 0 18 18 0.0000 4 270 240 1305 5715 I:j\001
4 0 0 100 0 18 18 0.0000 4 270 8610 4860 5715 C:k:mtt_e=k*(l^2)*cos(mtt_f/2)*2*(sin(mtt_f/2)-sin(alpha/2))+0*eta\001
4 0 1 101 0 3 20 0.0000 4 270 3255 4950 675 Rod (length L) hinged at left\001
4 0 1 101 0 3 20 0.0000 4 270 4275 4950 1125 Spring (stiffness k) unstretched when \001
4 0 1 101 0 32 20 0.0000 4 210 510 9225 1125 q=a\001
4 0 1 101 0 3 20 0.0000 4 270 3120 4950 1575 eta is the equilibrium angle\001

Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_desc.tex version [84c725288d].
































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system NonlinearMSD (NonlinearMSD_desc.tex)
% Generated by MTT on Thu Mar 7 14:48:47 GMT 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This example illustrates the use of \textbf{MTT} to \emph{linaerise} a
nonlinear system -- a non-linear mass-spring-damper system called
\textbf{NonlinearMSD}. The model is considered in Section
\ref{sec:model} and linearisation in Section \Ref{sec:linearisation}.

Further work is suggested in Section \Ref{sec:further}.

\subsection{Bond Graph model}\label{sec:model}

The schematic diagram  of the system
\textbf{NonlinearMSD} is displayed in Figure
\ref{fig:NonlinearMSD_abg.ps}. The system comprises
\begin{itemize}
\item a rigid foundation,
\item a rod of length $L$ hinged at the left-hand end and
\item a linear spring of stiffness $k$ attached to the rigid
  foundation a distance $L$ from the hinge and to the free end of the rod.
\end{itemize}
The spring is unstretched when the rod makes an angle $\theta = \alpa
= \frac{pi}{3}$ with the foundation.

Using elementary geometry, the effectice angular spring generates a
torque $\tau$ given by (\ref{eq:spring})
\begin{equation}\label{eq:spring}
  \tau = -2kl^2 \cos{\frac{\theta}{2}} (\sin{\frac{\theta}{2}}-\sin{\frac{\alpha}{2}})
\end{equation}

The acausal bond graph of system \textbf{NonlinearMSD} is also
displayed in Figure \Ref{fig:NonlinearMSD_abg.ps}. This shows the
three bond graph components representing the friction \textbf{R}, the
inertia \textbf{I} and the spring \textbf{C} components. The
non-linear spring characteristic is given explicitly\footnote{The
  additional 0*eta term has no effect - it merely introduced the
  variable $\eta$ -- the equilibrium angle -- into the model}.

The (nonlinear) system ordinary differential equation is given by
\textbf{MTT} in Section \Ref{sec:NonlinearMSD_ode.tex}. This is a
special case of the general non-linear ordinary differential equation:
\begin{equation}
  \label{eq:non-state}
  \begin{cases}
    \dot{x} = f(x,u)\\
    y = g(x,u)
  \end{cases}
\end{equation}

\subsection{Linearisation}
\label{sec:linearisation}

The first step in linearisation is to determine a set of (constant)
states $x_e$ and (constant) inputs $u_e$ so that the system is in
equilibrium - that is
\begin{equation}
  \label{eq:eqilibrium}
 \dot{x} = f(x_e,u_e) = 0
\end{equation}

In this case, choosing an angle $\theta=\eta$ and an input:
\begin{equation}\label{eq:u_e}
  u_e = -\tau = 2kl^2 \cos{\frac{\eta}{2}} (\sin{\frac{\eta}{2}}-\sin{\frac{\alpha}{2}})
\end{equation}
together with zero velocity gives an equilibrium.

With this choice
The linearised system is given in terms of the $A$, $B$, $C$ and $D$
matrices appearing in the state equation:
\begin{equation}
  \label{eq:state}
  \begin{cases}
    \dot{x} = Ax + Bu\\
    y = Cx + Du
  \end{cases}
\end{equation}

\textbf{MTT} automatically generates these matrices -- see Section
\Ref{sec:NonlinearMSD_sm.tex}.

\subsection{Further work}
\label{sec:further}
\begin{enumerate}
\item Derive the system ordinary differential equation appearing in
  Section \Ref{sec:NonlinearMSD_ode.tex}.
\item Explain how the input of (\ref{eq:u_e}) gives equilibrium for
  all $\eta$.
\item Explain how the elements of the $A$, $B$, $C$ and $D$ appearing
  Section \Ref{sec:NonlinearMSD_sm.tex} arise from the ordinary
  differential equation of Section \Ref{sec:NonlinearMSD_ode.tex}
  together with the input of (\ref{eq:u_e}).
\item Setting up parameters, inputs and initial state as in Sections
  \Ref{sec:NonlinearMSD_numpar.tex}, \Ref{sec:NonlinearMSD_input.tex}
  and \Ref{sec:NonlinearMSD_state.tex}, perform simulations as in
  Section \Ref{sec:NonlinearMSD_state.tex} - the figure shows the
  angular \emph{velocity} $\dot{\theta}$.
\item Repeat the simulation with different perturbations by modifying
  the file ``NonlinearMSD\_input.tex'' (see Section
  \Ref{sec:NonlinearMSD_input.tex})
  \begin{enumerate}
  \item note that for smaller perturbations, the graphs are of similar
    shape (scaled by the perturbation input)
  \item note that for larger perturbations the graphs are quite
    different - this is a non-linear system.
  \end{enumerate}
\item \label{item:1} Repeat the simulation with different equilibrium angles $\eta$ by modifying
  the file ``NonlinearMSD\_numpar.tex'' (see Section
  \Ref{sec:NonlinearMSD_numpar.tex}) appropriately. Note that when
  $\eta=\pi$, the linearised system is \emph{unstable}.
\item The (2,1) element of the $A$ matrix in Section
  \Ref{sec:NonlinearMSD_sm.tex} is the \emph{linearised} stiffness
  $k_l$. Plot this against $\eta$ and explain the observation in item
  \ref{item:1}.
\end{enumerate}


Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_input.txt version [2e637411bf].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System NonlinearMSD, representation input, language txt; 
## File NonlinearMSD_input.txt; 
## Generated by MTT on Thu Mar  7 10:50:46 GMT 2002; 

## First term is the equilibrium input; last term is the perturbation input.

nonlinearmsd__yu = k*(pow(l,2))*cos(eta/2)*2*(sin(eta/2)-sin(alpha/2)) + 1e-2;

Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_numpar.txt version [da778d0db5].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System NonlinearMSD, representation numpar, language txt; 
## File NonlinearMSD_numpar.txt; 
## Generated by MTT on Thu Mar  7 14:03:19 GMT 2002; 



alpha	= pi/3; # Angle for unstretched string
eta	= pi/3; #  Equilibrium angle
j	= 1.0; # Inertia
k	= 1.0; # Spring constant
l	= 1.0; # Rod length
r	= 1.0; # Rotational resistance

Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_rep.txt version [b54172b254].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system NonlinearMSD (NonlinearMSD_rep.txt)
## Generated by MTT on" Thu Mar  7 14:44:37 GMT 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt NonlinearMSD abg tex			# The system description
mtt NonlinearMSD sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt NonlinearMSD dae tex	        # The system dae
mtt NonlinearMSD ode tex	        # The system ode 
mtt NonlinearMSD sspar tex		# Steady-state parameters
mtt NonlinearMSD ss tex 		# Steady state
## mtt NonlinearMSD dm tex		# Descriptor matrices (of linearised system)
mtt NonlinearMSD sm tex		# State matrices (of linearised system)
## mtt NonlinearMSD tf tex		# Transfer function (of linearised system)
## mtt NonlinearMSD lmfr ps		# log modulus of frequency response (of linearised system)
## mtt NonlinearMSD simpar tex		# Simulation parameters
mtt NonlinearMSD numpar tex		# Numerical simulation parameters
mtt NonlinearMSD state tex		# Simulation initial state
mtt NonlinearMSD input tex		# Simulation input
## mtt NonlinearMSD logic tex		# Logic control
mtt NonlinearMSD odeso ps		# Simulation output

## mtt NonlinearMSD rep txt		# This file

Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_sspar.r version [7911451fd5].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (NonlinearMSD_sspar.r)
% Generated by MTT at Thu Mar  7 10:39:15 GMT 2002

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 09:32:04  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% This one corresponds to the unstretched spring at theta = pi/3 
%% Note that U is calculated to give equilibrium for all angles

alpha := pi/3;

% Steady-state states
MTTX1 := 	eta;     %Initial angle (corresponds to u=0)
MTTX2 := 	0;        %Initial anglular velocity
% Steady-state inputs
MTTU1 := 	k*(l^2)*cos(MTTX1/2)*2*(sin(MTTX1/2)-sin(alpha/2));
;;END;

Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_state.txt version [9a3645e5d6].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System NonlinearMSD, representation state, language txt; 
## File NonlinearMSD_state.txt; 
## Generated by MTT on Thu Mar  7 10:50:45 GMT 2002; 



## Removed by MTT on Tue Jun 10 16:51:50 BST 2003: NonlinearMSD_j	= 0.0;  % Initial angular momentum
## Removed by MTT on Tue Jun 10 16:51:50 BST 2003: NonlinearMSD_k	= eta; % Initial angle
nonlinearmsd__j	= 0.0; # Added by MTT on Tue Jun 10 16:51:52 BST 2003
nonlinearmsd__k	= eta;		# initial angle

Added mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/plot_k.m version [7f6ea9ee11].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Plots the effective spring constant.

p = NonlinearMSD_numpar;	# Numerical parameters
s = NonlinearMSD_sympar		# Symbolic parameters

Eta = eta=[0:0.01:1]*pi; K = [];
for eta=Eta
  p(s.eta) = eta;		# Change the eta parameter
  A = NonlinearMSD_sm(p);	# SS A matrix
  k = -A(2,1);
  K = [K k];
endfor

grid;
ylabel("k");
xlabel("eta");
plot(Eta,K);
figfig("k","eps");

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_abg.fig version [dd7eb4aed9].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2925 4050 1575 4275 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 3150 5625 3150 5400 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4950 5625 4950 5400 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2475 3825 2475 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3150 3825 3150 3600 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4950 2475 4950 2700 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2925 2870 1970 2870 2289
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4288 2957 5243 2002 5243 2320
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 3150 7875 3150 7650 3375
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 5850 225 5850 225 900 9900 900 9900 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 4050 3825 4050 3600 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4275 3780 4275 4230
4 1 1 101 0 3 20 0.0000 4 270 1215 4140 3600 x-velocity\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 3240 1\001
4 1 4 100 0 18 20 0.0000 4 285 1425 1710 3240 SS:[drive]\001
4 1 1 101 0 3 20 0.0000 4 270 1200 4185 4500 y-velocity\001
4 1 1 101 0 3 20 0.0000 4 270 2055 4050 5490 angular-velocity\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 5040 1\001
4 1 4 100 0 18 20 0.0000 4 285 870 6165 5040 SS:[a]\001
4 2 0 100 0 18 20 0.0000 4 300 780 2430 5040 R:r_p\001
4 1 0 100 0 18 20 0.0000 4 285 765 2835 1845 R:r_c\001
4 1 4 100 0 18 20 0.0000 4 285 870 4050 1440 SS:[x]\001
4 1 0 100 0 18 20 0.0000 4 285 795 5355 1845 I:m_c\001
4 1 0 100 0 18 20 0.0000 4 225 660 6075 3240 INTF\001
4 0 0 100 0 18 20 0.0000 4 225 1665 8010 3240 De:Position\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 4140 1\001
4 1 4 100 0 18 20 0.0000 4 285 870 6165 4140 SS:[y]\001
4 2 0 100 0 18 20 0.0000 4 285 2310 2430 4140 Sf:zero_velocity\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_lbl.txt version [947eebb4f2].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Cart (Cart_lbl.txt)
%SUMMARY Cart
%DESCRIPTION Simple cart model

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	drive
%ALIAS	pendulum|out	x,y,a
%UNITS  drive     translational N m/s
b%UNITS  x         translational N m/s
%UNITS  y         translational N m/s
%UNITS  a         rotational N*m radian/s


% Argument aliases
%ALIAS	$1	m_c

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	m_c		lin	flow,m_c

% Component type R
	r_c		lin	flow,r_c
	r_p		lin	flow,r_p

% Component type SS
	[a]	SS		external,external
	[drive]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type De
	Position			SS	external

% Component type Sf
	zero_velocity		SS	0



Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_abg.fig version [95293b57ef].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 4005 3870 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 4050 3825 4500
-6
1 4 0 2 1 7 51 0 -1 0.000 1 0.0000 3700 4909 203 203 3497 4909 3903 4909
1 4 0 2 1 7 51 0 -1 0.000 1 0.0000 4817 4902 203 203 4614 4902 5020 4902
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 4275 3825 4275 3600 4500
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 5175 4725 3375 4725 3375 3825 5175 3825 5175 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5230 3095 5230 3414
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 5
	 4477 3712 5872 2317 6052 2497 4702 3847 4522 3667
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6750 5400 1125 5400 1125 2025 6750 2025 6750 5400
4 1 0 100 0 18 20 0.0000 4 210 570 4275 4365 Cart\001
4 1 0 100 0 18 20 0.0000 4 270 840 2070 4365 SS:[F]\001
4 1 0 100 0 18 20 0.0000 4 210 2445 5355 3060 InvertedPendulum\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_desc.tex version [1fb76406fa].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system InvertedPendulumOnCart (InvertedPendulumOnCart_desc.tex)
% Generated by MTT on Thu Aug 5 10:38:16 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{InvertedPendulumOnCart} is
   displayed in Figure \Ref{fig:InvertedPendulumOnCart_abg.ps} and its label
   file is listed in Section \Ref{sec:InvertedPendulumOnCart_lbl}.
   The subsystems are listed in Section \Ref{sec:InvertedPendulumOnCart_sub}.

This is a one input, two output nonlinear system comprising an
inverted pendulum attached by a hinge to a cart constrained to move in
the horizontal direction. The input is the horizontal force acting on
the cart, and the two outputs are the horizontal position and the
pendulum angle respectively.

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_input.txt version [eed0316c02].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System InvertedPendulumOnCart, representation input, language txt; 
## File idInvertedPendulumOnCart_input.txt; 
## Generated by MTT on Thu Apr  5 15:27:30 BST 2001; 



InvertedPendulumOnCart_f	= 1.0*(t<1); # Force for 1 sec

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_lbl.txt version [f7c8e12ace].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system InvertedPendulumOnCart (InvertedPendulumOnCart_lbl.txt)
%SUMMARY InvertedPendulumOnCart
%DESCRIPTION An Inverted Pendulum on a Cart

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS in   F
%UNITS F    translational  N m/s

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[F]   SS	 external,internal




Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_numpar.txt version [553e3e5c8b].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (InvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Thu Aug  5 10:07:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: e_s = 	1.0;			# Se
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: f_s = 	1.0;			# Sf
g = 	1.0;			# Pendulum,gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: j_m = 	1.0;			# gRODa
j_r = 	1.0;			# Pendulum
l = 	1.0;			# Pendulum
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: l_a = 	1.0;			# gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: l_b = 	1.0;			# gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: m = 	1.0;			# gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: m_c = 	1.0;			# Cart
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: m_r = 	1.0;			# Pendulum
r_c = 	0.1;			# Cart
r_p = 	0.1;			# Cart
m_c	= 1.0; # Added by MTT on Thu Nov 09 17:22:55 GMT 2000
m_r	= 1.0; # Added by MTT on Thu Nov 09 17:22:55 GMT 2000

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_rep.txt version [7bce6ceacb].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system InvertedPendulumOnCart (InvertedPendulumOnCart_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:00:45  peterg
## To RCS
##
###############################################################

mtt InvertedPendulumOnCart abg tex			# The system description
mtt InvertedPendulumOnCart cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt InvertedPendulumOnCart struc tex	        # The system structure
mtt InvertedPendulumOnCart dae tex	        # The system dae
## mtt InvertedPendulumOnCart ode tex	        # The system ode 
## mtt InvertedPendulumOnCart sspar tex		# Steady-state parameters
## mtt InvertedPendulumOnCart ss tex 		# Steady state
## mtt InvertedPendulumOnCart dm tex		# Descriptor matrices (of linearised system)
## mtt InvertedPendulumOnCart dm tex		# State matrices (of linearised system)
## mtt InvertedPendulumOnCart tf tex		# Transfer function (of linearised system)
## mtt InvertedPendulumOnCart lmfr ps		# log modulus of frequency response (of linearised system)
## mtt InvertedPendulumOnCart simpar tex		# Simulation parameters
## mtt InvertedPendulumOnCart numpar tex		# Numerical simulation parameters
## mtt InvertedPendulumOnCart input tex		# Simulation input
## mtt InvertedPendulumOnCart odeso ps		# Simulation output

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_simpar.txt version [fa514a3154].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system InvertedPendulumOnCart (InvertedPendulumOnCart_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 100.0;      # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_subs.r version [752962d684].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Default SUBS file
% File InvertedPendulumOnCart_subs.r
% Generated by MTT on Thu Nov  9 18:55:44 GMT 2000.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2001/04/02 10:57:57  gawthrop
% %% Added missing ;
% %%
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Put algebraic substitution commands here

for all x let cos(x)^2+sin(x)^2 = 1;

FOR ALL x,y LET x^y = pow(x,y); % Use the pow function

ON ROUNDED; % No integer output

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_abg.fig version [b643b2a567].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 3105 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 3150 4950 4500 5175 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 6075 4500 6300 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 3150 3825 4500 4050 4275
-6
6 3780 5355 6345 6795
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5400 4950 6750 5175 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 5400 6075 6750 6300 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5400 3825 6750 4050 6525
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6840 4950 8190 4950 7965 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9675 7425 3150 7425 3150 2475 9675 2475 9675 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 6750 3600 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 6750 4725 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 5400 5850 5400
4 1 4 100 0 18 20 0.0000 4 285 870 3825 7065 SS:[x]\001
4 1 4 100 0 18 20 0.0000 4 285 870 4950 7065 SS:[y]\001
4 1 4 100 0 18 20 0.0000 4 285 870 6075 7065 SS:[a]\001
4 1 0 100 0 18 20 0.0000 4 285 1590 4964 5040 gRODa:rod\001
4 1 0 100 0 18 20 0.0000 4 285 960 3825 3015 Se:x_0\001
4 1 0 100 0 18 20 0.0000 4 285 960 4950 3015 Se:y_0\001
4 1 0 100 0 18 20 0.0000 4 285 960 6030 3015 Se:a_0\001
4 1 4 100 0 18 14 0.0000 4 195 270 6660 4995 [a]\001
4 1 0 100 0 18 20 0.0000 4 225 1200 8865 5040 De:theta\001
4 1 4 100 0 18 14 0.0000 4 195 510 3825 4725 [x_a]\001
4 1 4 100 0 18 14 0.0000 4 195 510 4950 4725 [y_a]\001
4 1 4 100 0 18 14 0.0000 4 195 510 6075 4725 [a_a]\001
4 1 4 100 0 18 14 0.0000 4 195 525 3825 5265 [x_b]\001
4 1 4 100 0 18 14 0.0000 4 195 525 4950 5265 [y_b]\001
4 1 4 100 0 18 14 0.0000 4 195 525 6075 5265 [a_b]\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_lbl.txt version [4d5db894bb].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system InvertedPendulum (InvertedPendulum_lbl.txt)
%SUMMARY InvertedPendulum
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%UNITS  x         translational N m/s
%UNITS  y         translational N m/s
%UNITS  a         rotational N*m radian/s


%ALIAS	in|cart	x,y,a


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type De
	theta			SS	external

% Component type SS
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	a_0	 SS	0
	x_0      SS     0
	y_0      SS     0

% Component type gRod
	rod	 none		l;l;j_r;m_r;g
 

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_abg.fig version [795633633a].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3017 1577 3287 1577
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5269 1579 5539 1579
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 1577 3152 3152 3377 2927
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4142 3152 4412 3152
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4277 1577 4277 3152 4502 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5402 1577 5402 3152 5627 2927
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3019 4279 3289 4279
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4144 4279 4414 4279
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5271 4281 5541 4281
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4277 4277 4277 5852 4502 5627
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5402 4277 5402 5852 5627 5627
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 2250 7200 675 1575 675 1575 2250 7200 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 4500 7200 2925 1575 2925 1575 4500 7200 4500
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 6750 7200 5175 1575 5175 1575 6750 7200 6750
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 4299 3150 5874 3375 5649
4 1 -1 0 0 0 20 0.0000000 4 240 870 3152 1397 SS:v_x\001
4 1 -1 0 0 0 20 0.0000000 4 240 810 4277 1397 SS:f_a\001
4 1 -1 0 0 0 20 0.0000000 4 210 1110 4278 3828 ROD:rod\001
4 1 -1 0 0 0 20 0.0000000 4 240 885 3155 6305 SS:F_x\001
4 1 -1 0 0 0 20 0.0000000 4 240 870 4280 6305 SS:F_a\001
4 1 -1 0 0 0 20 0.0000000 4 270 885 5450 6305 SS:F_y\001
4 1 -1 0 0 0 20 0.0000000 4 270 1920 5986 1396 ACCEL:gravity\001
4 1 1 1 0 3 20 0.0000000 4 240 1245 7965 1440 Fixed end\001
4 1 1 1 0 3 20 0.0000000 4 240 1110 7920 6075 Free end\001
4 1 1 1 0 3 20 0.0000000 4 270 1755 8280 3735 Rod dynamics\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3152 3467 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4277 3467 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5402 3467 [y_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3154 4144 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4280 4145 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5406 4146 [y_b]\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_desc.tex version [8fffb820c7].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Pendulum (Pendulum_desc.tex)
% Generated by MTT on Fri Aug 15 09:52:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pendulum} is
   displayed in Figure \Ref{Pendulum_abg} and its label
   file is listed in Section \Ref{sec:Pendulum_lbl}.
   The subsystems are listed in Section \Ref{sec:Pendulum_sub}.

This is a heirachical version of the example from Section 10.3 of
``Metamodelling''.  It uses two compound components: {\bf ROD} and {\bf
GRAV}. {\bf ROD} is
essentially as described in Figure 10.2 {\bf GRAV} represents gravity by a
vertical accelleration as in Section 10.9 of "Metamodelling".

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_input.txt version [d36e078d3f].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode' 
# Numerical parameter file (Pendulum_input.txt)
# Generated by MTT at Fri Aug 15 09:02:02 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  1998/07/27 11:27:05  peterg
# %% Reformatted
# %%
# Revision 1.1  1997/08/15  08:04:01  peterg
# Initial revision
#
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 17:17:50 BST 2003: u(1) =	0.0;			# no torque at joint
## Removed by MTT on Tue Jun 10 17:17:50 BST 2003: u(2) =	9.81;			# g
pendulum__f_a	= 0.0;		# No joint torque
pendulum__gravity__force	= 9.81;	# g

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_lbl.txt version [a4f4c9c248].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Pendulum: Pendulum example from Section 10.3 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.3 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling".

%ALIAS ACCEL	Mechanical-2D/ACCEL # Constant acceleration
%% Label file for system pend (pend_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:46:22  peterg
% %% New labeled ports version
% %%
% Revision 1.1  1996/11/09  18:44:58  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters
rod	none	l;l;j;m

%Zero velocity sources
v_x	SS     internal,0

%Zero force/torque sources
F_x	SS	   0,internal
F_y	SS	   0,internal
F_a	SS	   0,internal

%Torque at end
f_a	SS external,external

%Gravity
gravity





Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_numpar.txt version [1aa95a298a].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (Pendulum_numpar.txt)
# Generated by MTT at Mon Jul 27 12:38:25 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0;			# Pendulum
m = 	1.0;			# Pendulum
j = 	m*l*l/12.0;		# Pendulum

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_rep.txt version [706ef8c12b].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Pendulum (Pendulum_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/19 17:34:30  peterg
% %% Put in -c
% %%
% %% Revision 1.1  1999/02/22 09:17:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Pendulum abg tex
mtt Pendulum struc tex
mtt Pendulum dae tex
mtt Pendulum cse tex
## mtt Pendulum rfe tex
mtt Pendulum ode tex
mtt Pendulum input txt
mtt Pendulum numpar txt
mtt Pendulum odeso ps

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_simpar.txt version [18a566dbec].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Pendulum (Pendulum_simpar.txt)
# Generated by MTT on Mon Jul 27 12:27:43 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1999/12/23 20:16:47  peterg
## Removed MTHOD
##
## Revision 1.2  1999/02/22 10:08:05  peterg
## 
##
## Revision 1.1  1998/07/27 11:29:13  peterg
## Initial revision
##
###############################################################


LAST=10.0;			# Last time in simulation
DT=0.1;				# Print interval
STEPFACTOR=10;			# Integration steps per print interval

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_state.txt version [57d68aa055].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (Pendulum_state.txt)
# Generated by MTT at Mon Jul 27 12:34:12 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/27 11:41:39  peterg
## Initial revision
##
###############################################################

# Set the states
## Removed by MTT on Tue Jun 10 17:16:38 BST 2003: mttx(1) 	= 0.0; 	# J (Pendulum_rod)
## Removed by MTT on Tue Jun 10 17:16:38 BST 2003: mttx(2) 	= pi/4;	# 3 (Pendulum_rod_th)
## Removed by MTT on Tue Jun 10 17:16:38 BST 2003: mttx(3) 	= 0.0; 	# 2 (Pendulum_gravity)
pendulum__gravity__mtti	= 0.0;
pendulum__rod__j	= 0.0;
pendulum__rod__th__mttc	= pi/4;

Added mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_subs.r version [7a6dcb4fcb].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to sunstitute in system Pendulum (Pendulum_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_abg.fig version [e0aed8f131].

























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
4 1 -1 0 0 0 20 0.0000000 4 240 870 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000000 4 240 960 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000000 4 240 885 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000000 4 240 870 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000000 4 270 885 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000000 4 210 1260 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1260 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000000 4 240 960 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000000 4 240 810 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000000 4 240 870 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000000 4 240 810 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000000 4 270 420 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000000 4 240 870 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000000 4 270 870 5850 945 SS:v_y\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_desc.tex version [1b0381b9ba].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoLink (TwoLink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLink} is
   displayed in Figure \Ref{TwoLink_abg} and its label
   file is listed in Section \Ref{sec:TwoLink_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to
translation motion) in derivative causality, thus the system is
represnted as a Differential-Algebraic Equation (Section
\Ref{sec:TwoLink_dae.tex}). Hovever, this is of contrained-state form
and therfore can be written as a set of constrained-state equations
(Section \Ref{sec:TwoLink_cse.tex}). The corresponding ordinary
differential equation is complicated due to the trig functions
involved in inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLink_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_input.txt version [9c3ec92995].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLink_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/07/27 10:44:59  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 17:24:08 BST 2003: u(1) =	(t<1.0);		# Torque on Joint 1
## Removed by MTT on Tue Jun 10 17:24:08 BST 2003: u(2) =	-(t>10.0)&&(t<11.0);	# Torque on Joint 2
## Removed by MTT on Tue Jun 10 17:24:08 BST 2003: u(3) =	0.0;			# Gravity
twolink__f_a1	= (t<1.0);		# Torque on Joint 1
twolink__f_a2	= -(t>10.0)&&(t<11.0);	# Torque on Joint 2

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_lbl.txt version [9f787960d1].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/27 10:45:22  peterg
% %% Initial revision
% %%
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_1;l_1;j_1;m_1
rod2	none	l_2;l_2;j_2;m_2

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal


%Torque/velocity at joints
f_a1	SS	 external,external
f_a2	SS	 external,external


Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_numpar.txt version [0fbe82c500].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLink_numpar.txt)
# Generated by MTT at Mon Jan 19 13:53:15 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
j_1 = 	1.0; # Parameter j_1 for TwoLink
j_2 = 	1.0; # Parameter j_2 for TwoLink
l_1 = 	1.0; # Parameter l_1 for TwoLink
l_2 = 	1.0; # Parameter l_2 for TwoLink
m_1 = 	1.0; # Parameter m_1 for TwoLink
m_2 = 	1.0; # Parameter m_2 for TwoLink

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_rep.txt version [21a223e372].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TwoLink (TwoLink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  2000/05/19 17:35:34  peterg
% %% -c
% %%
% %% Revision 1.3  1999/02/22 09:18:33  peterg
% %% Removed -c
% %%
% %% Revision 1.2  1998/01/19 14:21:21  peterg
% %% Removed ordinary differential equation representation - its to
% %% verbose.
% %%
% %% Revision 1.1  1998/01/19 14:15:52  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLink abg tex
mtt TwoLink struc tex
mtt TwoLink sympar tex
mtt TwoLink dae tex
mtt TwoLink cse tex
## mtt TwoLink rfe tex

mtt TwoLink input txt
mtt TwoLink numpar txt
mtt -i euler TwoLink odeso ps

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_simp.r version [78d66bdfd1].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system TwoLink (TwoLink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_simpar.txt version [825ca8bdde].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Simulation parameters for system TwoLink (TwoLink_simpar.txt)
# Generated by MTT on Mon Jul 27 08:16:50 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$

## Revision 1.3  1999/02/22 10:07:24  peterg
## Step facttor 10
##
## Revision 1.2  1999/02/22 10:06:13  peterg
##
## Revision 1.1  1998/07/27 10:46:30  peterg
## Initial revision
##
###############################################################


LAST=50.0;
DT=0.1;
STEPFACTOR=10;


Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_subs.r version [cceaeb9eae].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce  substitution statements for system TwoLink (TwoLink_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/22 20:12:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_desc.tex version [bb657d852c].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system twolink (twolink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{twolink} is
   displayed in Figure \Ref{twolink_abg} and its label
   file is listed in Section \Ref{sec:twolink_lbl}.
   The subsystems are listed in Section \Ref{sec:twolink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses two compound components: {\bf ROD} and {\bf
GRAV}.  {\bf ROD} is essentially as described in Figure 10.2 {\bf
GRAV} represents gravity by a vertical accelleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_lbl.txt version [e8bd693d1c].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY twolink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (twolink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m
rod2	none	l;l;j;m

%Zero velocity sources
v_x	internal	0


%Zero force/torque sources
F_x	0	internal
F_a	0	internal
F_y	0	internal


%Torque at joints
f_a1	external external
f_a2	external external


%Gravity
g

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_params.r version [eb6c0cbeba].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Parameter file for system twolink (twolink_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Useful trig simplifications


        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

% Some simplifications -- see book
j := m*l*l/3;

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_rep.txt version [26658efeb2].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Outline report file for system twolink (twolink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

abg tex
struc tex
dae tex
csm tex
sro ps
lmfr ps
odeso ps
input txt
numpar txt

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_simp.r version [322b9f1b83].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system twolink (twolink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%simplify the output equations
% Joint  angles
mttx2 := theta_1;
mttx4 := theta_1 + theta_2;
END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_abg.fig version [b1caa985f3].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 900 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000 4 255 900 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1170 5850 945 ACCEL:g\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_desc.tex version [6281d6e316].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoLinkxyc (TwoLinkxyc_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkxyc} is
   displayed in Figure \Ref{TwoLinkxyc_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkxyc_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkxyc_sub}.

This system is identical to  \textbf{twolink} except that the two
colocated {\bf SS} components act at the tip in the $x$ and $y$
directions instead of at the two joints.

It uses two compound components: {\bf ROD} and {\bf GRAV}.  {\bf ROD}
is essentially as described in Figure 10.2 of "Metamodelling" and {\bf
GRAV} represents gravity by a vertical acceleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_input.txt version [c8c2ef8960].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkxyc_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:02:44  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Jun 11 14:02:21 BST 2003: u(1) =	(t<1.0);
## Removed by MTT on Wed Jun 11 14:02:21 BST 2003: u(2) =	0.0; # 
## Removed by MTT on Wed Jun 11 14:02:21 BST 2003: u(3) =	0.0; # gravity
twolinkxyc__f_x	= (t<1.0);
twolinkxyc__f_y	= 0.0; 
twolinkxyc__g__force	= 0.0;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_lbl.txt version [3994ea9709].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkxyc: two-link manipulator with collocated tip source-sensors.
%DESCRIPTION This is related to a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"
%DESCRIPTION except that the  collocated  source-sensors act at the
%DESCRIPTION tip rather than at the joints.

%% Label (TwoLinkxyc_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/06  15:56:31  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m;mg
rod2	none	l;l;j;m;mg

%Zero velocity sources
v_x	SS     internal,0


%Zero force/torque sources
F_a	SS	   0,internal


%Torque at joints
f_a1	SS	0,internal
f_a2	SS	0,internal

%Forces at tip
F_x	SS	external,external
F_y	SS	external,external


%Gravity
g

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_numpar.txt version [7b7519bf11].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkxyc_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2000/05/20 15:44:26  peterg
# %% Split from old numpar file
# %%
# %% Revision 1.1  2000/05/20 15:43:27  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	m*l*l/12.0; # Uniform rod
mg	= m*9.81;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_rep.txt version [5d1a320820].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TwoLinkxyc (TwoLinkxyc_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:02:44  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkxyc abg tex
mtt TwoLinkxyc struc tex
mtt TwoLinkxyc dae tex
mtt TwoLinkxyc cse tex
mtt TwoLinkxyc input txt
mtt TwoLinkxyc numpar txt
mtt  -i euler TwoLinkxyc odeso ps

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_simp.r version [e44c55285d].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system TwoLinkxyc (TwoLinkxyc_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_simpar.txt version [2d422722b4].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system TwoLinkxyc (TwoLinkxyc_simpar.txt)
# Generated by MTT on Mon Feb 22 09:44:37 GMT 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/02/22 10:09:34  peterg
## Initial revision
##
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_sspar.r version [77f6d0b61a].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for TwoLinkxyc (TwoLinkxyc_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_state.txt version [e1fccc7ae9].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# State initialisation file  file (TwoLinkxyc_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/05/20 15:44:48  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(1) = 	0.0; # Initial state for TwoLinkxyc_rod1 (J)
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(2) = 	0.0; # Initial state for TwoLinkxyc_rod1_th (3)
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(3) = 	0.0; # Initial state for TwoLinkxyc_rod2 (J)
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(4) = 	3.142/4; # Initial state for TwoLinkxyc_rod2_th (3) - 45 deg.
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(5) = 	0.0; # Initial state for TwoLinkxyc_g (2)
twolinkxyc__g__mtti	= 0.0; 
twolinkxyc__rod1__j	= 0.0; 
twolinkxyc__rod1__th__mttc	= 0.0;
twolinkxyc__rod2__j	= 0.0; 
twolinkxyc__rod2__th__mttc	= 3.142/4;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_abg.fig version [b1caa985f3].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 900 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000 4 255 900 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1170 5850 945 ACCEL:g\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_desc.tex version [4b8a2c615b].
































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TwoLinkxyn (TwoLinkxyn_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1998/01/06  17:36:33  peterg
% Initial revision
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkxyn} is
   displayed in Figure \Ref{TwoLinkxyn_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkxyn_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkxyn_sub}.

This system is identical to  \textbf{twolink} except that there are
now two non-collocated input-output pairs: The torque input to joint 1
-- x velocity of the tip and the torque input to joint 2
-- y velocity of the tip. 

It uses two compound components: {\bf ROD} and {\bf GRAV}.  {\bf ROD}
is essentially as described in Figure 10.2 of "Metamodelling" and {\bf
GRAV} represents gravity by a vertical acceleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_input.txt version [5266242257].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkxyn_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:03:12  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Jun 11 14:14:40 BST 2003: u(1) =	(t<1.0);
## Removed by MTT on Wed Jun 11 14:14:40 BST 2003: u(2) =	0.0; # 
## Removed by MTT on Wed Jun 11 14:14:40 BST 2003: u(3) =	0.0; # gravity
twolinkxyn__f_a1	= (t<1.0);
twolinkxyn__f_a2	= 0.0;
twolinkxyn__g__force	= 0.0;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_lbl.txt version [2f9773334c].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TwoLinkxyn: two-link manipulator with collocated tip source-sensors.
%DESCRIPTION This is related to a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"
%DESCRIPTION except that the source sensors are not collocated:
%DESCRIPTION sources at the joints, sensors at the xy motion of the tip.

%% Label (TwoLinkxyn_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/06  17:37:55  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m;mg
rod2	none	l;l;j;m;mg

%Zero velocity sources
v_x	SS     internal,0


%Zero force/torque sources
F_a	SS	   0,internal


%Torque at joints
f_a1	SS	external,internal
f_a2	SS	external,internal

%Forces at tip
F_x	SS	0,external
F_y	SS	0,external


%Gravity
g

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_numpar.txt version [394b813c98].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (TwoLinkxyn_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/05/20 15:50:31  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	m*l*l/12.0; # Uniform rod
mg	= m*9.81;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_rep.txt version [af9435c555].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TwoLinkxyn (TwoLinkxyn_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/19 17:36:55  peterg
% %% -c
% %%
% %% Revision 1.1  1999/02/22 10:01:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkxyn abg tex
mtt TwoLinkxyn struc tex
mtt TwoLinkxyn dae tex
mtt TwoLinkxyn cse tex
##mtt TwoLinkxyn rfe tex
##mtt TwoLinkxyn ode tex
mtt TwoLinkxyn input txt
mtt TwoLinkxyn numpar txt
mtt -i euler TwoLinkxyn odeso ps

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_simp.r version [f03e08b08b].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system TwoLinkxyn (TwoLinkxyn_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_simpar.txt version [5eae2d65c3].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system TwoLinkxyn (TwoLinkxyn_simpar.txt)
# Generated by MTT on Mon Feb 22 09:53:04 GMT 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_sspar.r version [f8140e05f7].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce steady-state parameter file for TwoLinkxyn (TwoLinkxyn_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_state.txt version [cdad8f6fcb].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# State file (TwoLinkxyn_state.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/05/20 15:50:57  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(1) = 	0.0; # Initial state for TwoLinkxyn_rod1 (J)
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(2) = 	0.0; # Initial state for TwoLinkxyn_rod1_th (3)
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(3) = 	0.0; # Initial state for TwoLinkxyn_rod2 (J)
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(4) = 	3.142/4; # Initial state for TwoLinkxyn_rod2_th (3) - 45 deg.
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(5) = 	0.0; # Initial state for TwoLinkxyn_g (2)
twolinkxyn__g__mtti	= 0.0;
twolinkxyn__rod1__j	= 0.0;
twolinkxyn__rod1__th__mttc	= 0.0;
twolinkxyn__rod2__j	= 0.0;
twolinkxyn__rod2__th__mttc	= 3.142/4;

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_abg.fig version [b1caa985f3].























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 900 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000 4 255 900 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1170 5850 945 ACCEL:g\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_desc.tex version [c73da6dfdc].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system gTwoLink (gTwoLink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{gTwoLink} is
   displayed in Figure \Ref{gTwoLink_abg} and its label
   file is listed in Section \Ref{sec:gTwoLink_lbl}.
   The subsystems are listed in Section \Ref{sec:gTwoLink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
Gravity is included as discussed in "Metamodelling" by accelerating
the manipulator vertically using the {\bf ACCEL} component.

This system has a number of dynamic elements (those corresponding to
translation motion) in derivative causality, thus the system is
represnted as a Differential-Algebraic Equation (Section
\Ref{sec:gTwoLink_dae.tex}). Hovever, this
is of contrained-state form and therfore can be written as a set of
constrained-state equations (Section \Ref{sec:gTwoLink_cse.tex}). The
corresponding ordinary differential equation is complicated due to the
trig functions involved in inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:gTwoLink_rfe.tex}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_input.txt version [c054ad63f9].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (gTwoLink_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:03:41  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Jun 11 14:23:00 BST 2003: u(1) =	(t<1.0);
## Removed by MTT on Wed Jun 11 14:23:00 BST 2003: u(2) =	0.0; # 
## Removed by MTT on Wed Jun 11 14:23:00 BST 2003: u(3) =	0.0; # gravity
gtwolink__f_a1	= (t<1.0);
gtwolink__f_a2	= 0.0;
gtwolink__g__force	= 0.0;

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_lbl.txt version [ef35e2beef].






















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY gTwoLink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (gTwoLink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m;mg
rod2	none	l;l;j;m;mg

%Zero velocity sources
v_x	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal


%Torque at joints
f_a1	SS	external,external
f_a2	SS	external,external

%Gravity
g

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_numpar.txt version [545d5baf0d].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (gTwoLink_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:03:41  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	m*l*l/12.0; # Uniform rod

mg	= m*9.81; 

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_rep.txt version [abfc1962b1].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system gTwoLink (gTwoLink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:03:41  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/22 09:18:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt gTwoLink abg tex
mtt gTwoLink struc tex
mtt gTwoLink sympar tex
mtt gTwoLink dae tex
mtt gTwoLink cse tex
mtt gTwoLink input txt
mtt gTwoLink numpar txt
mtt -i euler gTwoLink odeso ps

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_simp.r version [db95ebfddb].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system gTwoLink (gTwoLink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_simpar.txt version [d1bd9350e6].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Simulation parameters for system gTwoLink (gTwoLink_simpar.txt)
# Generated by MTT on Mon Jul 27 08:11:02 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1999/12/23 20:18:54  peterg
## Removed METHOD
##
## Revision 1.1  1999/02/22 10:06:54  peterg
## Initial revision
##
###############################################################


LAST=5.0;
DT=0.1;
STEPFACTOR=10;

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_state.txt version [c5b2ae4018].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Initial state  file (gTwoLink_state.txt)
# Generated by MTT at Mon Jul 27 07:54:23 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/27 06:59:25  peterg
## Initial revision
##
###############################################################

# Set the states
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(1) 	= 0.0; 	# J (gTwoLink_rod1)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(2) 	= 0.0; 	# 3 (gTwoLink_rod1_th)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(3) 	= 0.0; 	# J (gTwoLink_rod2)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(4) 	= pi/4;	# 3 (gTwoLink_rod2_th)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(5) 	= 0.0; 	# 2 (gTwoLink_g)
gtwolink__g__mtti	= 0.0; 
gtwolink__rod1__j	= 0.0; 
gtwolink__rod1__th__mttc	= 0.0;
gtwolink__rod2__j	= 0.0; 
gtwolink__rod2__th__mttc	= pi/4;

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_desc.tex version [bb657d852c].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system twolink (twolink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{twolink} is
   displayed in Figure \Ref{twolink_abg} and its label
   file is listed in Section \Ref{sec:twolink_lbl}.
   The subsystems are listed in Section \Ref{sec:twolink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses two compound components: {\bf ROD} and {\bf
GRAV}.  {\bf ROD} is essentially as described in Figure 10.2 {\bf
GRAV} represents gravity by a vertical accelleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_lbl.txt version [e8bd693d1c].



















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY twolink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (twolink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m
rod2	none	l;l;j;m

%Zero velocity sources
v_x	internal	0


%Zero force/torque sources
F_x	0	internal
F_a	0	internal
F_y	0	internal


%Torque at joints
f_a1	external external
f_a2	external external


%Gravity
g

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_params.r version [eb6c0cbeba].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Parameter file for system twolink (twolink_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Useful trig simplifications


        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

% Some simplifications -- see book
j := m*l*l/3;

END;

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_rep.txt version [26658efeb2].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Outline report file for system twolink (twolink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

abg tex
struc tex
dae tex
csm tex
sro ps
lmfr ps
odeso ps
input txt
numpar txt

Added mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_simp.r version [322b9f1b83].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system twolink (twolink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%simplify the output equations
% Joint  angles
mttx2 := theta_1;
mttx4 := theta_1 + theta_2;
END;

Added mtt/lib/examples/Sensitivity/sRCc/sRCc_abg.fig version [ccb1b9cb1f].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1215 4500 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1080 4500 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 5400 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 675 4275 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1215 4275 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 5400 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 5400 1530 5400 765
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 5625 6750 225 675 225 675 5625 6750 5625
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 255 600 2926 2926 sR:r\001
4 1 -1 0 0 0 20 0.0000 4 255 645 4276 2926 sC:c\001
4 1 -1 0 0 0 20 0.0000 4 255 945 1395 4365 sSe:e1\001
4 0 1 1 0 0 20 0.0000 4 180 120 2880 450 r\001
4 0 1 1 0 0 20 0.0000 4 180 165 4680 1215 c\001
4 0 1 1 0 0 20 0.0000 4 180 165 5625 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 5715 1305 2\001
4 0 1 1 0 0 20 0.0000 4 180 165 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 330 1725 3600 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 255 1545 3600 2025 Schematic\001
4 1 -1 0 0 0 20 0.0000 4 255 1005 5987 4367 sDe:e2\001
4 1 4 100 0 18 4 0.0000 4 120 270 4500 4005 [1,2]\001
4 1 4 100 0 18 4 0.0000 4 120 270 3105 4005 [1,2]\001

Added mtt/lib/examples/Sensitivity/sRCc/sRCc_desc.tex version [765c3fe2e6].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system sRCc (sRCc_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 05:17:04  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sRCc} is
   displayed in Figure \Ref{sRCc_abg} and its label
   file is listed in Section \Ref{sec:sRCc_lbl}.
   The subsystems are listed in Section \Ref{sec:sRCc_sub}.

The system \textbf{sRCc} is the the sensitivity version of the simple
electrical sRCc circuit shown in Figure \Ref{sRCc_abg}. The circuit itself can be
regarded as a single-input single-output system with input $e_1$ and
output $e_2$; the sensitivity system has {\em two\/} outputs: $e_2$
and $\frac{\partial e_2}{\partial r}$.

All bonds are two-bond vector bonds, and the {\bf sR} and {\bf sC}
components are two-port versions of the usual {\bf R} and {\bf C}
components respectively. One port conveys the usual effort/flow pair;
the other port conveys the sensitivity of the effort and flow with
respect to the $c$ parameter.

Added mtt/lib/examples/Sensitivity/sRCc/sRCc_lbl.txt version [3400946923].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sRCc (sRCc_lbl.txt)
%SUMMARY sRCc Sensitivity of output of RC circuit wrt value of r
%DESCRIPTION Uses the sR and sC components and vector bonds

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/10/18 07:34:32  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/07/29 05:18:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type sSe
	e1       slin		external;0	

% Component type sDe
	e2

% Component type sC
	c	 slin		effort,c;1

% Component type sR
	r	 slin		flow,r;0

Added mtt/lib/examples/Sensitivity/sRCc/sRCc_rep.txt version [17b4c98377].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sRCc (sRCc_rep.txt)
## Generated by MTT on" Thu Jul 29 06:02:47 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt sRCc abg tex			# The system description
## mtt sRCc cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt sRCc struc tex	        # The system structure
## mtt sRCc dae tex	        # The system dae
mtt sRCc ode tex	        # The system ode 
## mtt sRCc sspar tex		# Steady-state parameters
## mtt sRCc ss tex 		# Steady state
## mtt sRCc dm tex		# Descriptor matrices (of linearised system)
mtt sRCc sm tex		# State matrices (of linearised system)
mtt sRCc tf tex		# Transfer function (of linearised system)
mtt sRCc lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sRCc simpar tex		# Simulation parameters
## mtt sRCc numpar tex		# Numerical simulation parameters
## mtt sRCc input tex		# Simulation input
 mtt sRCc odeso ps		# Simulation output

Added mtt/lib/examples/Sensitivity/sRCr/sRCr_abg.fig version [d99238c53e].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1215 4500 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1080 4500 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 5400 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 675 4275 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1215 4275 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 5400 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 5400 1530 5400 765
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 5625 6750 225 675 225 675 5625 6750 5625
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 255 600 2926 2926 sR:r\001
4 1 -1 0 0 0 20 0.0000 4 255 645 4276 2926 sC:c\001
4 1 -1 0 0 0 20 0.0000 4 255 945 1395 4365 sSe:e1\001
4 0 1 1 0 0 20 0.0000 4 180 120 2880 450 r\001
4 0 1 1 0 0 20 0.0000 4 180 165 4680 1215 c\001
4 0 1 1 0 0 20 0.0000 4 180 165 5625 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 5715 1305 2\001
4 0 1 1 0 0 20 0.0000 4 180 165 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 330 1725 3600 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 255 1545 3600 2025 Schematic\001
4 1 -1 0 0 0 20 0.0000 4 255 1005 5987 4367 sDe:e2\001
4 1 4 100 0 18 10 0.0000 4 150 345 4545 4005 [1,2]\001
4 1 4 100 0 18 10 0.0000 4 150 345 3195 4005 [1,2]\001

Added mtt/lib/examples/Sensitivity/sRCr/sRCr_desc.tex version [78a9a2ed8d].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system sRCr (sRCr_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 05:17:04  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sRCr} is
   displayed in Figure \Ref{sRCr_abg} and its label
   file is listed in Section \Ref{sec:sRCr_lbl}.
   The subsystems are listed in Section \Ref{sec:sRCr_sub}.

The system \textbf{sRCr} is the the sensitivity version  of the simple
electrical sRCr circuit shown in Figure \Ref{sRCr_abg}. The circuit itself can be
regarded as a single-input single-output system with input $e_1$ and
output $e_2$; the sensitivity system has {\em two\/} outputs: $e_2$
and $\frac{\partial e_2}{\partial r}$.

All bonds are two-bond vector bonds, and the {\bf sR} and {\bf sC}
components are two-port versions of the usual {\bf R} and {\bf C}
components respectively. One port conveys the usual effort/flow pair;
the other port conveys the sensitivity of the effort and flow with
respect to the $r$ parameter.

Added mtt/lib/examples/Sensitivity/sRCr/sRCr_lbl.txt version [8da53abbab].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system sRCr (sRCr_lbl.txt)
%SUMMARY sRCr Sensitivity of output of RC circuit wrt value of r
%DESCRIPTION Uses the sR and sC components and vector bonds

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:04:59  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/07/29 05:18:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type sSe
	e1       slin		external;0	

% Component type sDe
	e2

% Component type sC
	c	 slin		effort,c;0

% Component type sR
	r	 slin		flow,r;1

Added mtt/lib/examples/Sensitivity/sRCr/sRCr_rep.txt version [e24284fd27].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sRCr (sRCr_rep.txt)
## Generated by MTT on" Thu Jul 29 06:02:47 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt sRCr abg tex			# The system description
## mtt sRCr cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt sRCr struc tex	        # The system structure
## mtt sRCr dae tex	        # The system dae
mtt sRCr ode tex	        # The system ode 
## mtt sRCr sspar tex		# Steady-state parameters
## mtt sRCr ss tex 		# Steady state
## mtt sRCr dm tex		# Descriptor matrices (of linearised system)
mtt sRCr sm tex		# State matrices (of linearised system)
mtt sRCr tf tex		# Transfer function (of linearised system)
mtt sRCr lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sRCr simpar tex		# Simulation parameters
## mtt sRCr numpar tex		# Numerical simulation parameters
## mtt sRCr input tex		# Simulation input
 mtt sRCr odeso ps		# Simulation output

Added mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_abg.fig version [f4fec756c1].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3150 5850 3150 5625 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4275 5850 4275 5625 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 2925 3150 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 4050 1800 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1777 4275 3127 4275 2902 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 4095 4500 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 8325 3150 8100 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 2925 6975 3375
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2925 2025 4725 2025 4725 5400 2925 5400 2925 2025
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 5850 9450 1575 450 1575 450 5850 9450 5850
4 0 -1 0 0 0 20 0.0000000 4 240 870 6030 3240 RT:r_2\001
4 2 4 0 0 0 20 0.0000000 4 240 690 2835 3060 [t_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 840 4770 3015 [t_out]\001
4 2 4 0 0 0 20 0.0000000 4 240 735 2880 4185 [e_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 885 4770 4185 [e_out]\001
4 2 -1 0 0 0 20 0.0000000 4 240 900 1620 3240 SS:T_1\001
4 0 -1 0 0 0 20 0.0000000 4 240 900 8460 3240 SS:T_2\001
4 2 -1 0 0 0 20 0.0000000 4 240 780 1665 4365 SS:I_r\001
4 0 -1 0 0 0 20 0.0000000 4 240 930 5985 4365 SS:V_0\001
4 1 -1 0 0 0 20 0.0000000 4 270 1575 3780 3825 Segment:s*100\001

Added mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_input.txt version [c54d6fa852].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (BigHeatedRod_input.txt)
# Generated by MTT at Thu Sep  4 16:11:06 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:06:11  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Sun Aug 17 13:03:18 BST 2003: u(1) =	10.0*(t<5.0); # I_r 
bigheatedrod__i_r	=	10.0*(t<5.0); # I_r 

Added mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_lbl.txt version [a943d5cb3b].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY BigHeatedRod: Thermal/Electrical model of Electric rod
#DESCRIPTION Introduces the idea of the ES component which
#DESCRIPTION transforms a relative-temperature/enthalpy pseudo bond 
#DESCRIPTION (at the [e]port) into an absolute-temperature/enntropy 
#DESCRIPTION energy bond (at the [s] port) and vice versa.

#PAR rod_length
#PAR rod_radius
#PAR electrical_resistivity
#PAR thermal_resistivity
#PAR thermal_capacity
#PAR segments
#PAR area
#PAR delta_x
#PAR volume
#PAR density
#PAR mass
#PAR pi

## Label file for system BigHeatedRod (BigHeatedRod_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  2000/12/28 18:06:11  peterg
# ## To RCS
# ##
# ## Revision 1.1  1997/09/11 16:16:29  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type RT
	r_2		lin	flow,r_2

# Component type SS
	I_r	SS	internal,external
	T_1	SS	t_0,internal
	T_2	SS	t_0,internal
	V_0	SS	internal,internal

# Component type Segment
	s

Added mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_numpar.txt version [92cb1f9ee5].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (BigHeatedRod_numpar.txt)
# Generated by MTT at Thu Sep  4 16:11:04 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:06:11  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Constants for copper
density = 8.96;
rod_length = 1.0;
rod_radius = 1e-3;
electrical_resistivity = 16.8*0.000000001;
thermal_resistivity = 1/390.0;
thermal_capacity = 380.0;

pi = 3.142;

segments = 100;
area = pi*rod_radius*rod_radius;
delta_x = rod_length/segments;
volume = area*delta_x;
mass = volume*density;

# Parameters
c_t = 	thermal_capacity*mass;
r = 	electrical_resistivity*delta_x/area;
r_t = 	thermal_resistivity*delta_x/area;
r_2 = 	r_t;
t_0 = 	300; # Ambient




Added mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_rep.txt version [47c8424834].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system BigHeatedRod (BigHeatedRod_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2003/08/17 17:02:31  gawthrop
% %% Updated for new MTT
% %%
% %% Revision 1.1  1998/11/23 13:37:55  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o BigHeatedRod abg tex

mtt -o BigHeatedRod numpar txt
mtt -o BigHeatedRod input txt
mtt -o BigHeatedRod odeso ps

Added mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_simpar.txt version [4609d162a5].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system BigHeatedRod (BigHeatedRod_simpar.txt)
# Generated by MTT on Tue Aug 24 01:20:41 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

DT          = 1.0;        # Print interval

Added mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_state.txt version [d77a055614].























































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (BigHeatedRod_state.txt)
# Generated by MTT at Friday August 14 18:38:47 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:06:11  peterg
## To RCS
##
###############################################################

# Set the states
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(1) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(2) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(3) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(4) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(5) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(6) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(7) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(8) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(9) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(10) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(11) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(12) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(13) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(14) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(15) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(16) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(17) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(18) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(19) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(20) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(21) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(22) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(23) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(24) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(25) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(26) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(27) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(28) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(29) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(30) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(31) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(32) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(33) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(34) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(35) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(36) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(37) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(38) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(39) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(40) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(41) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(42) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(43) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(44) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(45) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(46) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(47) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(48) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(49) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(50) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(51) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(52) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(53) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(54) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(55) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(56) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(57) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(58) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(59) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(60) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(61) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(62) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(63) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(64) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(65) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(66) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(67) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(68) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(69) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(70) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(71) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(72) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(73) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(74) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(75) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(76) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(77) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(78) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(79) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(80) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(81) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(82) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(83) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(84) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(85) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(86) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(87) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(88) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(89) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(90) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(91) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(92) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(93) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(94) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(95) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(96) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(97) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(98) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(99) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(100) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
bigheatedrod__s__100__c_t__c	=  c_t*t_0;
bigheatedrod__s__10__c_t__c	=  c_t*t_0;
bigheatedrod__s__11__c_t__c	=  c_t*t_0;
bigheatedrod__s__12__c_t__c	=  c_t*t_0;
bigheatedrod__s__13__c_t__c	=  c_t*t_0;
bigheatedrod__s__14__c_t__c	=  c_t*t_0;
bigheatedrod__s__15__c_t__c	=  c_t*t_0;
bigheatedrod__s__16__c_t__c	=  c_t*t_0;
bigheatedrod__s__17__c_t__c	=  c_t*t_0;
bigheatedrod__s__18__c_t__c	=  c_t*t_0;
bigheatedrod__s__19__c_t__c	=  c_t*t_0;
bigheatedrod__s__20__c_t__c	=  c_t*t_0;
bigheatedrod__s__21__c_t__c	=  c_t*t_0;
bigheatedrod__s__22__c_t__c	=  c_t*t_0;
bigheatedrod__s__23__c_t__c	=  c_t*t_0;
bigheatedrod__s__24__c_t__c	=  c_t*t_0;
bigheatedrod__s__25__c_t__c	=  c_t*t_0;
bigheatedrod__s__26__c_t__c	=  c_t*t_0;
bigheatedrod__s__27__c_t__c	=  c_t*t_0;
bigheatedrod__s__28__c_t__c	=  c_t*t_0;
bigheatedrod__s__29__c_t__c	=  c_t*t_0;
bigheatedrod__s__2__c_t__c	=  c_t*t_0;
bigheatedrod__s__30__c_t__c	=  c_t*t_0;
bigheatedrod__s__31__c_t__c	=  c_t*t_0;
bigheatedrod__s__32__c_t__c	=  c_t*t_0;
bigheatedrod__s__33__c_t__c	=  c_t*t_0;
bigheatedrod__s__34__c_t__c	=  c_t*t_0;
bigheatedrod__s__35__c_t__c	=  c_t*t_0;
bigheatedrod__s__36__c_t__c	=  c_t*t_0;
bigheatedrod__s__37__c_t__c	=  c_t*t_0;
bigheatedrod__s__38__c_t__c	=  c_t*t_0;
bigheatedrod__s__39__c_t__c	=  c_t*t_0;
bigheatedrod__s__3__c_t__c	=  c_t*t_0;
bigheatedrod__s__40__c_t__c	=  c_t*t_0;
bigheatedrod__s__41__c_t__c	=  c_t*t_0;
bigheatedrod__s__42__c_t__c	=  c_t*t_0;
bigheatedrod__s__43__c_t__c	=  c_t*t_0;
bigheatedrod__s__44__c_t__c	=  c_t*t_0;
bigheatedrod__s__45__c_t__c	=  c_t*t_0;
bigheatedrod__s__46__c_t__c	=  c_t*t_0;
bigheatedrod__s__47__c_t__c	=  c_t*t_0;
bigheatedrod__s__48__c_t__c	=  c_t*t_0;
bigheatedrod__s__49__c_t__c	=  c_t*t_0;
bigheatedrod__s__4__c_t__c	=  c_t*t_0;
bigheatedrod__s__50__c_t__c	=  c_t*t_0;
bigheatedrod__s__51__c_t__c	=  c_t*t_0;
bigheatedrod__s__52__c_t__c	=  c_t*t_0;
bigheatedrod__s__53__c_t__c	=  c_t*t_0;
bigheatedrod__s__54__c_t__c	=  c_t*t_0;
bigheatedrod__s__55__c_t__c	=  c_t*t_0;
bigheatedrod__s__56__c_t__c	=  c_t*t_0;
bigheatedrod__s__57__c_t__c	=  c_t*t_0;
bigheatedrod__s__58__c_t__c	=  c_t*t_0;
bigheatedrod__s__59__c_t__c	=  c_t*t_0;
bigheatedrod__s__5__c_t__c	=  c_t*t_0;
bigheatedrod__s__60__c_t__c	=  c_t*t_0;
bigheatedrod__s__61__c_t__c	=  c_t*t_0;
bigheatedrod__s__62__c_t__c	=  c_t*t_0;
bigheatedrod__s__63__c_t__c	=  c_t*t_0;
bigheatedrod__s__64__c_t__c	=  c_t*t_0;
bigheatedrod__s__65__c_t__c	=  c_t*t_0;
bigheatedrod__s__66__c_t__c	=  c_t*t_0;
bigheatedrod__s__67__c_t__c	=  c_t*t_0;
bigheatedrod__s__68__c_t__c	=  c_t*t_0;
bigheatedrod__s__69__c_t__c	=  c_t*t_0;
bigheatedrod__s__6__c_t__c	=  c_t*t_0;
bigheatedrod__s__70__c_t__c	=  c_t*t_0;
bigheatedrod__s__71__c_t__c	=  c_t*t_0;
bigheatedrod__s__72__c_t__c	=  c_t*t_0;
bigheatedrod__s__73__c_t__c	=  c_t*t_0;
bigheatedrod__s__74__c_t__c	=  c_t*t_0;
bigheatedrod__s__75__c_t__c	=  c_t*t_0;
bigheatedrod__s__76__c_t__c	=  c_t*t_0;
bigheatedrod__s__77__c_t__c	=  c_t*t_0;
bigheatedrod__s__78__c_t__c	=  c_t*t_0;
bigheatedrod__s__79__c_t__c	=  c_t*t_0;
bigheatedrod__s__7__c_t__c	=  c_t*t_0;
bigheatedrod__s__80__c_t__c	=  c_t*t_0;
bigheatedrod__s__81__c_t__c	=  c_t*t_0;
bigheatedrod__s__82__c_t__c	=  c_t*t_0;
bigheatedrod__s__83__c_t__c	=  c_t*t_0;
bigheatedrod__s__84__c_t__c	=  c_t*t_0;
bigheatedrod__s__85__c_t__c	=  c_t*t_0;
bigheatedrod__s__86__c_t__c	=  c_t*t_0;
bigheatedrod__s__87__c_t__c	=  c_t*t_0;
bigheatedrod__s__88__c_t__c	=  c_t*t_0;
bigheatedrod__s__89__c_t__c	=  c_t*t_0;
bigheatedrod__s__8__c_t__c	=  c_t*t_0;
bigheatedrod__s__90__c_t__c	=  c_t*t_0;
bigheatedrod__s__91__c_t__c	=  c_t*t_0;
bigheatedrod__s__92__c_t__c	=  c_t*t_0;
bigheatedrod__s__93__c_t__c	=  c_t*t_0;
bigheatedrod__s__94__c_t__c	=  c_t*t_0;
bigheatedrod__s__95__c_t__c	=  c_t*t_0;
bigheatedrod__s__96__c_t__c	=  c_t*t_0;
bigheatedrod__s__97__c_t__c	=  c_t*t_0;
bigheatedrod__s__98__c_t__c	=  c_t*t_0;
bigheatedrod__s__99__c_t__c	=  c_t*t_0;
bigheatedrod__s__9__c_t__c	=  c_t*t_0;
bigheatedrod__s__c_t__c	=  c_t*t_0;

Added mtt/lib/examples/Simulation/BigHeatedRod/HR_input.txt version [e8bdef2d26].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (HR_input.txt)
# Generated by MTT at Thu Sep  4 16:11:06 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	10.0*(t<5.0); # I_r 

Added mtt/lib/examples/Simulation/BigHeatedRod/HR_numpar.txt version [c4b7dfe06b].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (HR_numpar.txt)
# Generated by MTT at Thu Sep  4 16:11:04 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Constants for copper
density = 8.96;
rod_length = 1.0;
rod_radius = 1e-3;
electrical_resistivity = 16.8*0.000000001;
thermal_resistivity = 1/390.0;
thermal_capacity = 380.0;


segments = 2;
area = pi*rod_radius*rod_radius;
delta_x = rod_length/segments;
volume = area*delta_x;
mass = volume*density;

# Parameters
c_t = 	thermal_capacity*mass;
r = 	electrical_resistivity*delta_x/area;
r_t = 	thermal_resistivity*delta_x/area;
r_2 = 	r_t/100;
t_0 = 	300; # Ambient




Added mtt/lib/examples/Simulation/BigHeatedRod/HR_simpar.txt version [8e33457c64].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system HR (HR_simpar.txt)
# Generated by MTT on Wednesday July 29 13:59:50 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10;       # Last time in simulation
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps

STEPFACTOR = 1; # Added automatically
METHOD = IMPLICIT;         # Added automatically
DT = 0.25;                 # Added automatically

Added mtt/lib/examples/Simulation/BigHeatedRod/HeatedRod_desc.tex version [ca122af254].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system HeatedRod (HeatedRod_desc.tex)
% Generated by MTT on Thu Sep 4 18:05:09 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





   The acausal bond graph of system \textbf{HeatedRod} is
   displayed in Figure \Ref{HeatedRod_abg} and its label
   file is listed in Section \Ref{sec:HeatedRod_lbl}.
The subsystems are listed in Section \Ref{sec:HeatedRod_sub}.

 System \textbf{HeatedRod} is a model of a rod of copper with an
 electric current passing through it which warms it up. The two ends of
 the rod are fixed at ambient temperature; this is where all the heat
 loss occurs. 

 This system introduces the idea of the {\bf ES} component which
 transforms a relative-temperature/enthalpy pseudo bond (at the [e]
 port) into an absolute-temperature/enntropy energy bond (at the [s]
 port) and vice versa.

 The model is similar to that described in chapter 8 of
 Cellier's book. However, instead of representing the thermal
 resistance by {\bf RS} components and reinserting the entropy flow,
 the {\bf RT} component uses two {\bf ES} components to convert from
 true to pseudo bonds and back again. Similary, the thermal capacity is
 modelled by the {\bf CT} component.


 The rod parameters are given in the numpar file and the input current
 in the input file.

Added mtt/lib/examples/Simulation/BigHeatedRod/HeatedRod_lbl.txt version [bce0ff1c0a].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY HeatedRod: Thermal/Electrical model of Electric rod
%DESCRIPTION Introduces the idea of the ES component which
%DESCRIPTION transforms a relative-temperature/enthalpy pseudo bond 
%DESCRIPTION (at the [e]port) into an absolute-temperature/enntropy 
%DESCRIPTION energy bond (at the [s] port) and vice versa.

%% Label file for system HeatedRod (HeatedRod_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RT
	r_2		lin	flow,r_2

% Component type SS
	I_r		internal	external
	T_1		t_0		internal
	T_2		t_0		internal
	V_0		0		internal

% Component type Segment
	s

Added mtt/lib/examples/Simulation/BigHeatedRod/Run version [5d09d2ea7c].


































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# Shell script for running the large HeatedRod systems to compare
# four integration methods.
# Usage example: Run 100 0.25 runf the 100 segment example at interval 0.25

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/08/17 09:42:26  peterg
## Third argument gives the desired methods.
##
## Revision 1.2  1998/08/15 14:07:11  peterg
## Don't do ImplicitL
##
## Revision 1.1  1998/08/15 13:58:27  peterg
## Initial revision
##
###############################################################


n=$1
DT=$2

if [ -z "$n" ]; then
    echo "First argument is N: number of segments (eg 100)"
    exit
fi
if [ -z "$DT" ]; then
    echo "Second argument is DT: the sample interval (eg 0.25)"
    exit
fi
if [ -z "$3" ]; then
    METHODS='ImplicitS Euler Implicit'
else
    METHODS=$3
fi

echo "Running system HR$1 with DT = $DT"
echo "using methods $METHODS"

#Create the system
mtt -q rename HR HR$n >/dev/null
rm -f MTT_work/HR$1_state.* #Why ??

# Is it already correct?
count=`grep -c "*$n" HR$1_abg.fig`

# if not, then set the correct number of segments
if [ "$count" = "0" ]; then
    echo Setting number of segments to $n
    mv HR$1_abg.fig  HR$1_abg.old
    sed "s/\*[0-9]*/*$1/"<HR$1_abg.old>HR$1_abg.fig

    mv HR$1_numpar.txt  HR$1_numpar.old
    sed "s/segments = [0-9]*/segments = $1/"<HR$1_numpar.old >HR$1_numpar.txt

   echo "Making the default HR$1_state.txt"
   rm -f HR$1_state.txt MTT_work/HR$1_state.txt
   mtt -q  HR$1 state txt
   echo "Setting $n states to c_t*t_0"
   mv HR$1_state.txt  HR$1_state.old
   sed "s/0.0/c_t*t_0/"<HR$1_state.old >HR$1_state.txt
fi






rm -f HR$1_table.txt

#Do the methods of interest

for METHOD in $METHODS; do

case $METHOD in
    Euler)
    # What is the minimum step size for Euler?
    mtt -q HR$n numpar m
    mtt -q HR$n sm m
octave -q <<EOF >HR$1.tmp1
    HR$1_numpar;
    A=HR$1_sm;
    Max_Eig=max(eig(-A))
    STEPFACTOR=ceil( Max_Eig*$DT/2 )
EOF
    MinSTEPFACTOR=`gawk '{if ($1=="STEPFACTOR") print $3}' HR$1.tmp1`
    STEPFACTOR=$MinSTEPFACTOR
	;;
    ImplicitS)
    # What is the empirical step size for sparse method?
    octave -q <<EOF >HR$1.tmp1
    if $n>100 
      SparseSTEPFACTOR=10*$n
    else
      SparseSTEPFACTOR=5*$n
    endif
EOF
     SparseSTEPFACTOR=`gawk '{if ($1=="SparseSTEPFACTOR") print $3}' HR$1.tmp1`

		STEPFACTOR=$SparseSTEPFACTOR
	;;
    *)
		STEPFACTOR=1
	;;
esac


  echo "Doing HR$1 with DT=$DT using $METHOD (STEPFACTOR = $STEPFACTOR)"

  # Modify the simpar.txt files
  grep -v 'STEPFACTOR' HR_simpar.txt | grep -v 'METHOD' | grep -v 'DT' > HR$1_simpar.txt
  echo "STEPFACTOR = $STEPFACTOR; # Added automatically" >>HR$1_simpar.txt
  echo "METHOD = $METHOD;         # Added automatically" >>HR$1_simpar.txt
  echo "DT = $DT;                 # Added automatically" >>HR$1_simpar.txt
  mtt -q -c -o HR$1 odeso ps > junk 2>>junk #HR$1_$METHOD.tmp
  grep user junk |\
     gawk '{print System " &\t" METHOD " &\t"  DT " &\t"  STEPFACTOR " &\t" $2 "\\\\"}'\
      METHOD=$METHOD STEPFACTOR=$STEPFACTOR System=HR$1 DT=$DT >> HR$1_table.txt

  cp HR$1_odeso.ps  HR$1.$METHOD.$DT.ps
done

cat HR$1_table.txt



Added mtt/lib/examples/Simulation/BigHeatedRod/Run_All version [2d96bc44fd].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# Generates the tables of timings
# PJG 17/8/98

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


Run 2	0.25	'ImplicitS Implicit Euler'
Run 10	0.25	'ImplicitS Implicit Euler'
Run 20	0.25	'ImplicitS Implicit Euler'
Run 50	0.25	'ImplicitS Implicit Euler'
Run 100	0.25	'ImplicitS Implicit Euler'
Run 200 0.25	'ImplicitS Implicit'

cat Run*_table.txt | sort

Added mtt/lib/examples/Simulation/BigHeatedRod/Segment_abg.fig version [1d5850b4e4].

































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2835 2205 2925 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2880 2250 2880 2700
-6
6 8505 2250 8595 2790
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8550 2295 8550 2745
-6
6 5310 6255 5400 6795
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5355 6300 5355 6750
-6
6 5805 6255 5895 6795
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5850 6300 5850 6750
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1306 2476 2881 2476 2656 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3781 2476 5356 2476 5131 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5761 2476 8550 2475 8325 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 4276 5581 2701 5806 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 6301 5581 4726 5806 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 6525 5356 6526 5131 6751
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 6526 8550 6525 8325 6750
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 2701 6920 3815 6601 3815
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 2251 5581 676 5806 901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5356 676 5806 676
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 7425 9900 90 45 90 45 7425 9900 7425
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 1800 1575 1800 1575 4455 7650 4455
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 6975 7650 4545 1575 4545 1575 6975 7650 6975
4 1 -1 0 0 0 20 0.0000 4 240 810 3331 2566 RT:r_t\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5581 2566 0\001
4 1 -1 0 0 0 20 0.0000 4 210 555 5581 4591 RS:r\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5581 6616 1\001
4 1 -1 0 0 0 20 0.0000 4 240 840 7021 4141 CT:c_t\001
4 1 -1 0 0 0 20 0.0000 4 255 870 5581 586 SS:T_s\001
4 2 4 0 0 0 20 0.0000 4 255 1110 1261 2566 SS:[t_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1260 8685 2565 SS:[t_out]\001
4 2 4 0 0 0 20 0.0000 4 255 1155 1260 6615 SS:[e_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1305 8685 6615 SS:[e_out]\001
4 0 1 1 0 0 20 0.0000 4 210 1875 1845 4050 Thermal model\001
4 0 1 1 0 0 20 0.0000 4 210 2025 1800 5175 Electrical model\001
4 0 1 1 0 0 20 0.0000 4 255 2415 6075 585 Temperature sensor\001

Added mtt/lib/examples/Simulation/BigHeatedRod/Segment_lbl.txt version [ffb638c19b].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Segment: Segment of HeatedRod
%DESCRIPTION Part of the HeatedRod example.
%% Label file for system Segment (Segment_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/08/10 12:29:48  peterg
% %% Added missing ports.
% %%
% %% Revision 1.1  1997/09/11 16:17:14  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Component type CT
	c_t		lin	effort,c_t

% Component type RS
	r		lin	flow,r

% Component type RT
	r_t		lin	flow,r_t

% Component type SS
	T_s		SS		external,0
	[t_in]		SS		external,internal
	[t_out]		SS		internal,external
	[e_in]		SS		external,internal
	[e_out]		SS		external,internal

Added mtt/lib/examples/Simulation/BigHeatedRod/examples.m version [ccb8cc8f8c].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

mttdt = 1;
mttx=(zeros(200,1));
mttu=(zeros(200,1));
BigHeatedRod_numpar;
alpha = BigHeatedRod_smx(mttx,mttu,mttdt);
show_matrix (alpha);
psfig("sparsity.ps");


[N,junk] = size(alpha);
A =  eye(N) - alpha;
plot(log10(abs(eig(A))))
grid;
xlabel("i");
ylabel("e_i");
psfig("eig.ps");

Added mtt/lib/examples/Simulation/BigHeatedRod/time_svdlu.m version [d2d86013f2].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [N,Ts,Tl]=time_svdlu;

  N=[100:100:700];

  Ts=[]; Tl=[];
  for n=N
    n
    M=rand(n,n);
    ts=time; svd(M); ts=time-ts
    tl=time; lu(M); tl=time-tl
    Ts=[Ts,ts];
    Tl=[Tl,tl];
  endfor;

endfunction;
  

Added mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_abg.fig version [ed25703b7d].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 900 3150 2250 3150 2025 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3150 4950 3150 4725 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 7425 3150 7200 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 5175 8550 900 45 900 45 5175 8550 5175
4 1 -1 0 0 10 20 0.0000 4 210 570 495 3240 Se:u\001
4 1 -1 0 0 10 20 0.0000 4 210 1095 2925 3240 RC:slow\001
4 1 -1 0 0 10 20 0.0000 4 210 1005 5535 3240 RC:fast\001
4 1 -1 0 0 10 20 0.0000 4 270 600 7830 3240 De:y\001

Added mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_desc.tex version [a6bf3f22eb].









































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ImplicitRC (ImplicitRC_desc.tex)
% Generated by MTT on Wednesday June 24 09:50:17 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:06:50  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This report describes the \emph{implicit} integration methods
available in MTT. They are introduced to provide  simulation
of systems within the following context:
\begin{enumerate}
\item The system may be stiff with a mixture of slow and fast
  (possibly due to approximating algebraic loops) subsystems.
\item The fast parts of the response are of no interest
\item A fixed sample interval is required -- possibly for real-time
  simulation or control
\item The system is nonlinear.
\item The solution of nonlinear algebraic equations is to be avaided.
\end{enumerate}

The following sections consider the linear and nonlinear versions
respectively. The ideas are based on a standard textbook
\footnote{Press et al: \emph{Numerical Recipes in C}, 2nd edition,
  1992. Cambridge, Section 16.6}.
 

\subsection{Implicit integration - the linear case}
\label{sec:linear}

Consider the \emph{linear} system:
\begin{equation}
  \label{eq:sys}
    \dot x = A x + B u
\end{equation}

For the purposes of simulation, it can be discretised (with sample
interval $\Delta t$) in at least two
ways:
\begin{enumerate}
\item $ \dot x \approx \frac{x_{i+1} - x_{i}}{\Delta t}$
\item $ \dot x \approx \frac{x_{i} - x_{i-1}}{\Delta t}$
\end{enumerate}
The former is gives rise to the \emph{forward} Euler or \emph{explicit}
integration scheme:
\begin{equation}
   x_{i+1} =  x_{i} + \Delta t \left [ A x_{i} + B_{i} u \right ]
\end{equation}
and the latter gives rise to the \emph{backward} Euler or \emph{implicit}
integration scheme:
\begin{equation}
   x_{i} =  x_{i-1} + \Delta t \left [ A x_{i} + B_{i} u \right ]
\end{equation}
which must be rewritten as:
\begin{equation}
   x_{i} =   \left [ I -  \Delta t A \right ]^{-1} x_{i-1} + \Delta t  B_{i} u
\end{equation}
for the purposes of implementation.

The explicit method gives simple implementation whereas the implicit
method requires matrix inversion. However, the explicit method is only
stable if:
\begin{equation}
  \Delta t < \frac{2}{| \lambda |}
\end{equation}
where $\lambda$ is the \emph{largest} eigenvalue of $A$. If this
largest eigenvalue is real so $\lambda = \frac{1}{\tau}$ where $\tau$
is the \emph{smallest} system time constant:
\begin{equation}
  \Delta t < 2 \tau
\end{equation}

If the system is stiff, that is it contains at least one small time
constant relative to the dominant time constants, Euler integration is
not feasible due to the very small sample interval $\Delta t$
required.

In contrast, the implicit method is stable.


\subsubsection{Example}
   The acausal bond graph of system \textbf{ImplicitRC} is
   displayed in Figure \Ref{fig:ImplicitRC_abg.ps} and its label
   file is listed in Section \Ref{sec:ImplicitRC_lbl}
   The subsystems are listed in Section \Ref{sec:ImplicitRC_sub}.

The system represents two simple RC circuits in series with
differential equations as given in Section \Ref{sec:ImplicitRC_ode-noargs.tex} and
transfer function  as given in Section \Ref{sec:ImplicitRC_tf-noargs.tex}.

For the purposes of this example the two time constants are $1$ and
$\epsilon=10^{-3}$ -- this is a stiff system. All of the simulations
use a sample interval of $\Delta t = 0.1$ ang the input is a unit
step.  Section \Ref{sec:ImplicitRC_sro-noargs.ps} shows the exact (computed from
the matrix exponential) solution, and  Section {sec:ImplicitRC_odeso-cc.ps}
shows the solution by implicit integration.

The explicit solution is not shown, but was found to be unstable for
$\Delta t > 0.002$ as predicted.

\subsection{Implicit integration - the nonlinear case}}
\label{sec:nonlinear}

Consider the \emph{nonlinear} system:
\begin{equation}
  \label{eq:sys}
    \dot x = f(x,u)
\end{equation}
and suppose it can be linearised about any state and input to give:
\begin{equation}
  A(x,u) = \frac{\partial f(x,u)}{\partial x}
\end{equation}

The corresponding \emph{implicit} scheme is:
\begin{equation}
   x_{i} =  x_{i-1} + \Delta t f(x_{i},u_{i})
\end{equation}
This is not easy to solve in general due to the set of non-linear
equations that need to be solved. To avoid this, consider a further
approximation:
\begin{equation}
  f(x_{i},u_{i}) \approx f(x_{i-1},u_{i}) + A(x_{i-1},u_i) ( x_{i} -  x_{i-1} )
\end{equation}
This then gives the \emph{semi-implicit} scheme
\begin{equation}
  x_{i} =  x_{i-1} + \Delta t \left [  f(x_{i-1},u_{i}) + A(x_{i-1},u_i) (
    x_{i} -  x_{i-1} ) \right ]
\end{equation}
which can be rewritten as:
\begin{equation}\label{eq:implicit}
   x_{i} =  \left [ I -  \Delta t A(x_{i-1},u_i) \right ]^{-1} 
    \Delta t \left [  f(x_{i-1},u_{i}) - A(x_{i-1},u_i) x_{i-1}  \right ]
\end{equation}


Because of the approximations invoved, Equation \ref{eq:implicit} is
not guarenteed to be stable. Nevertheless, it should do a much better
job than the corresponding \emph{explicit} method for reasonably
smooth systems.
This method is chosen by setting 
\begin{verbatim}
METHOD='Implicit'
\end{verbatim}
in the MTT simpar.txt file.

A further approximation arises by setting  $A(x_{i-1},u_i) =
A(x_{0},u_0)$ ie computing it one only at the beginning of the
simulation.
This method is chosen by setting 
\begin{verbatim}
METHOD='ImplicitL'
\end{verbatim}
in the MTT simpar.txt file.

Both methods make use of the \textbf{smx} ``state-matrix with state $x$''
representation of MTT which is generated symbolically from the system
bond graph.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_lbl.txt version [e8ed754f2f].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY ImplicitRC
%DESCRIPTION <Detailed description here>
%% Label file for system ImplicitRC (ImplicitRC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RC
	fast		lin	epsilon;1
	slow		lin	1;1

% Component type SS
	u		SS	external
	y		SS	external





Added mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_numpar.txt version [f5c254b34d].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (ImplicitRC_numpar.txt)
# Generated by MTT at Wednesday June 24 09:21:23 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:06:50  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
epsilon = 	1e-3; # ImplicitRC
## Removed by MTT on Sun Aug 17 13:59:26 BST 2003: ## Removed by MTT on Sun Aug 17 13:59:26 BST 2003: c =		1.0;
## Removed by MTT on Sun Aug 17 13:59:26 BST 2003: r =		1.0;

Added mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_rep.txt version [13bcda6c54].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system ImplicitRC (ImplicitRC_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2003/08/17 17:03:02  gawthrop
% %% Updated for new MTT
% %%
% %% Revision 1.1  2000/12/28 18:06:50  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt ImplicitRC abg tex
mtt ImplicitRC struc tex
mtt ImplicitRC ode tex
mtt ImplicitRC sm tex
mtt ImplicitRC sm m
mtt ImplicitRC tf tex

mtt ImplicitRC sro ps

mtt ImplicitRC numpar tex

mtt ImplicitRC simpar tex
mtt ImplicitRC odeso ps

Added mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_simpar.txt version [8d36b2a6d0].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system ImplicitRC (ImplicitRC_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/08/12 13:29:02  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=10.0
DT=0.1
STEPFACTOR=1

Added mtt/lib/examples/Simulation/ImplicitRC/examples.sh version [4fe342f5cf].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

mv ImplicitRC_simpar.txt SAVE
Delta="0.01 0.2 1.0"
for delta in $Delta; do
    echo Doing with sample interval = $delta

    cp SAVE ImplicitRC_simpar.txt 
cat <<EOF >>ImplicitRC_simpar.txt 
DT=$delta
EOF
    mtt -q ImplicitRC odeso dat
    cp ImplicitRC_odeso.dat ImplicitRC_odeso.$delta
done

gnuplot <<EOF 
set term postscript
set output "ImplicitRC.ps"
set grid
plot "ImplicitRC_odeso.0.01" with lines, \
     "ImplicitRC_odeso.0.2" with linespoints, \
     "ImplicitRC_odeso.1.0" with linespoints
EOF
mv SAVE ImplicitRC_simpar.txt 

ghostview ImplicitRC.ps

mv ImplicitRC.ps ../../Figs

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Fuel_abg.fig version [91a602d65e].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6303 2703 6303 3844 6528 3619
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 1128 6301 2269 6526 2044
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 2475 7425 2475 7200 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 2250 6525 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 2250 6525 2700
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12377 4725 12377 225 450 225 450 4725 12377 4725
4 1 -1 0 0 22 20 0.0000 4 210 765 6300 990 Se:T3\001
4 0 -1 0 0 22 20 0.0000 4 210 1035 7605 2565 Df:Heat\001
4 1 -1 0 0 22 20 0.0000 4 210 390 6255 2565 PS\001
4 0 4 0 0 2 12 0.0000 4 180 630 6660 2385 [power]\001
4 1 4 100 0 18 18 0.0000 4 270 1065 6390 4185 SS:[out]\001

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Fuel_lbl.txt version [ea89d593a7].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Fuel (Fuel_lbl.txt)
%SUMMARY Fuel
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	Heat
%ALIAS	$2	T3

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Df
 	Heat	SS		external

% Component type SS
	[out]	SS		external,external

% Component type Se
	T3	SS		external

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/In_abg.fig version [7eb82b8438].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 2253 3198 2253 3018 2433
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3196 2026 3196 2476
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5400 5625 5400 1530 675 1530 675 5625 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3195 4725 3195 5175
4 0 4 0 0 0 20 0.0000 4 255 1440 3332 5042 SS:[Hy_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1425 3377 2342 SS:[Th_out]\001
4 2 -1 0 0 0 20 0.0000 4 255 1095 2026 2341 SS:Th_in\001
4 2 -1 0 0 0 20 0.0000 4 255 1110 2071 5041 SS:Hy_in\001

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/In_desc.tex version [0c97485c1c].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/In_lbl.txt version [b98a7bad58].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY In: Inflow conditions
%DESCRIPTION <Detailed description here>
%ALIAS	in|out Th_out,Hy_out
%% Label file for system In (In_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/04 09:41:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hy_out]	SS	external,external
	[Th_out]	SS	external,external
	Hy_in		SS	p_1,internal
	Th_in		SS	t_1,internal

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Load_abg.fig version [f6adaf70fd].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 900 2700 2250 2925 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 2700 4050 2925 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2475 5400 2475 5175 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6795 5175 6795 225 1350 225 1350 5175 6795 5175
4 1 4 0 0 22 20 0.0000 4 270 900 2745 720 SS:[in]\001
4 1 -1 0 0 22 20 0.0000 4 210 2325 2880 2565 PS:PowerSensor\001
4 1 4 0 0 22 20 0.0000 4 270 420 2385 2250 [in]\001
4 1 4 0 0 22 20 0.0000 4 270 615 2385 2835 [out]\001
4 1 4 0 0 22 20 0.0000 4 270 1035 3735 2250 [power]\001
4 1 -1 0 0 22 20 0.0000 4 210 1095 6030 2565 Df:Work\001
4 1 -1 0 0 22 20 0.0000 4 270 630 2655 4410 R:r_l\001

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Load_lbl.txt version [cd55430fc2].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Load (Load_lbl.txt)
%SUMMARY Load
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	r_l

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


	PowerSensor			

% Component type Df
	Work	SS		external

% Component type R
	r_l	lin		flow,r_l

% Component type SS
	[in]	SS		external,external

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Out_abg.fig version [34cc41cc19].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5400 5625 5400 1530 675 1530 675 5625 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2205 2250 3150 2250 2970 2430
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 2250 2250 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 1980 2250 2250
4 0 -1 0 0 0 20 0.0000000 4 240 1290 3465 2340 SS:Th_out\001
4 0 -1 0 0 0 20 0.0000000 4 270 1320 3375 5040 SS:Hy_out\001
4 2 4 0 0 0 20 0.0000000 4 270 1380 2160 5040 SS:[Hy_in]\001
4 2 4 0 0 0 20 0.0000000 4 240 1350 2115 2340 SS:[Th_in]\001

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Out_desc.tex version [3dd57dc573].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Out_lbl.txt version [19b6550ba8].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Out: Outflow conditions
%DESCRIPTION <Detailed description here>
%ALIAS	in  Th_in,Hy_in
%% Label file for system Out (Out_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hy_in]		SS	external,external
	[Th_in]		SS	external,external
	Hy_out		SS	p_1,internal
	Th_out		SS	t_1,internal

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Shaft_abg.fig version [598a000ebe].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1620 2700 2970 2700 2745 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2700 4725 2700 4500 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2925 3150 4275 3375 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 3150 1125 3375 1350
2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5
	 6075 4950 6075 450 450 450 450 4950 6075 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2475 4330 1520 4330 1839
4 1 0 100 0 18 18 0.0000 4 195 150 3150 2790 1\001
4 1 0 100 0 18 18 0.0000 4 270 540 3150 990 I:j_s\001
4 1 4 100 0 18 18 0.0000 4 270 870 1170 2790 SS:[in]\001
4 1 4 100 0 18 18 0.0000 4 270 1065 5310 2790 SS:[out]\001
4 1 4 100 0 18 18 0.0000 4 270 1215 3195 4680 SS:[load]\001
4 1 0 100 0 18 18 0.0000 4 270 1245 4455 1395 Df:speed\001

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Shaft_lbl.txt version [93c7018fae].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system Shaft (Shaft_lbl.txt)
%SUMMARY Shaft
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	load	load
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	j_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	speed	SS		external

% Component type I
	j_s	lin		flow,j_s

% Component type SS
	[in]	SS		external,external
	[load]	SS		external,external
	[out]	SS		external,external

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_abg.fig version [9abd037150].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6078 1803 6078 2944 6303 2719
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4230 3375 5584 3375 5359 3600
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 8104 3375 7879 3600
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2704 3375 2479 3600
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9450 3375 10579 3375 10354 3600
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4
	 8550 3870 8550 5850 6975 5850 7200 6075
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4
	 5175 5850 3375 5850 3375 3825 3600 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 6284 6075 7425 6300 7200
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12152 8550 12152 675 225 675 225 8550 12152 8550
4 1 4 0 0 2 12 0.0000 4 180 540 8510 3740 [Shaft]\001
4 1 4 0 0 2 12 0.0000 4 180 540 3379 3739 [Shaft]\001
4 1 1 1 0 2 30 0.0000 4 300 210 2162 3017 1\001
4 1 1 1 0 2 30 0.0000 4 300 210 4817 3017 2\001
4 1 1 1 0 2 30 0.0000 4 300 210 7292 3017 3\001
4 1 1 1 0 2 30 0.0000 4 300 210 9947 3017 4\001
4 1 4 0 0 2 12 0.0000 4 180 540 6078 3198 [Heat]\001
4 1 -1 0 0 22 20 0.0000 4 210 570 1217 3467 In:in\001
4 1 -1 0 0 2 20 0.0000 4 195 1050 6167 3467 Comb:c1\001
4 0 -1 0 0 22 20 0.0000 4 210 1005 10758 3468 Out:out\001
4 1 -1 0 0 2 20 0.0000 4 255 1455 3469 3469 Pump:comp\001
4 1 -1 0 0 2 20 0.0000 4 255 1335 8780 3470 Pump:turb\001
4 1 4 0 0 2 12 0.0000 4 180 465 6075 6165 [load]\001
4 1 -1 0 0 22 20 0.0000 4 210 1500 6078 5943 Shaft:shaft\001
4 1 -1 0 0 22 20 0.0000 4 210 1380 6075 7740 Load:load\001
4 1 1 1 0 3 25 0.0000 4 270 1425 6030 8145 Work out\001
4 1 -1 0 0 22 20 0.0000 4 210 1185 6030 1665 Fuel:fuel\001
4 1 1 1 0 3 25 0.0000 4 270 1140 5985 1215 Heat in\001

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_desc.tex version [3351a658e2].




























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system SimpleGasTurbine (SimpleGasTurbine_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/05/18 15:45:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{SimpleGasTurbine} is
   displayed in Figure \Ref{SimpleGasTurbine_abg} and its label
   file is listed in Section \Ref{sec:SimpleGasTurbine_lbl}.
   The subsystems are listed in Section \Ref{sec:SimpleGasTurbine_sub}.
   
   \textbf{SimpleGasTurbine} can be regarded as an single-spool gas
   turbine (producing shaft power) with an ideal-gas working fluid. It
   corresponds to the simple Joule Cycle as described in Chapter 12 of
   Rogers and Mayhew and in Chapter 2 of Cohen, Rogers and
   Saravanamutto. However, unlike those examples, the system is
   written with dynamics in mind.
   
   The system is described using an energy Bond Graph- this ensures
   that the first law is observed. In particular transformers are used
   to explicitly convert between energy covariables. Although this is
   a simple model, I believe that it provides the basis for building
   complex thermodynamic systems involving gas power cycles.


There are five main components:
\begin{enumerate}
\item p1 -- a \textbf{Pump} component representing the compressor
  stage. This converts shaft work to energy flow in the working fluid.
\item c1 -- a \textbf{Comb} component representing the combustion
  chamber. This converts the heat obtained by burning fuel to energy
  flow in the working fluid.
\item t1 -- a \textbf{Turb} component representing the turbine
  component. This converts the energy flow in the working fluid to
  shaft work
\item j\_s -- an \textbf{I} component representing the combined inertia
  of the shaft and compressor and turbine rotors.
\item a \textbf{Load} component to absorb the shaft power.
\end{enumerate}
The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

Both \textbf{Pump} and \textbf{Turb} are implemented with the
\emph{polytropic} constitutive relationship with index $n$. When
$n=\gamma=\frac{c_p}{c_v}$ this corresponds to isentropic compression
and expansion and thus the \textbf{SimpleGasTurbine} achieves its
cycle efficiency. However, other values of $n$ can be used to account
for isentropic efficiency of less than unity.

To obtain a very simple dynamic model (and to avoid the need for an
accurate combustion chamber model) there are no dynamics associated
with the combustion chamber, but rahter it is assumed that the
corresponding temperature is imposed on the component (that is $T_3$
is the system input) the corresponding heat flow is then an output.

Both heat input and work output are measured using the \textbf{PS}
(power sensor) component, that for work output is embedded in the
\textbf{Load} component. These can be monitored to give the efficiency
of the \textbf{SimpleGasTurbine}.

A symbolic steady-state for the model was computed -- see Section
\ref{sec:SimpleGasTurbine_ss.tex}. In particular, the load
resistance was chosen to absorb all the generated work at the steady
state and the shaft inertia was chosen to give a unit time constant
for the linearised system. The mass flow and shaft speeds were taken
as unity.

For the purposed of simulation, the numerical values given in Examples
12.1 of Chapter 12 of Rogers and Mayhew, except that the isentropic
efficiencies are 100\% ($n=\gamma$) -- see Section
\ref{sec:SimpleGasTurbine_numpar.tex}.

Simulations were performed starting at the steady state and increasing
the combustion chamber temperature by 10\% at $t=1$ and reducing by
10\% at $t=5$. Graphs of the various outputs are plotted:
\begin{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-comp-1-T,SimpleGasTurbine-c1-1-T,SimpleGasTurbine-turb-1-T.ps}
  -- the temperatures at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-fuel-1-Heat-1-y,SimpleGasTurbine-load-1-Work-1-y.ps}
  -- the heat input and work output
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-shaft-1-speed-1-y.ps} -- the shaft speed and
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-c1-1-P.ps}
  -- the pressure at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\end{itemize}

This model can be modified extended in various ways to yield related
dynamic systems. For example:
\begin{itemize}
\item an air cooler is obtained by changing the direction of heat and
  work flows
\item additional \textbf{Turb} and \textbf{Comb} components add reheat
  to the cycle
\item an isentropic nozzle can be added and the work output removed
  to give a jet engine.
\end{itemize}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_input.txt version [74f8083ef6].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (SimpleGasTurbine_input.txt)
# Generated by MTT at Tue Mar 31 12:38:39 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:08:28  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

t_3 = 1000;

# Set the inputs
## Removed by MTT on Mon Nov 27 15:18:54 GMT 2000: u(1) =	 t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); # SimpleGasTurbine (T3)
## Removed by MTT on Wed Jun 11 15:42:11 BST 2003: simplegasturbine_fuel_1_t3_1_u	= t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); 

simplegasturbine__fuel__t3__u	= t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); 

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_lbl.txt version [ae2470155f].




























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY SimpleGasTurbine: single-spool gas turbine producing shaft power
#DESCRIPTION SimpleGasTurbine can be regarded as an single-spool gas
#DESCRIPTION turbine (producing shaft power) with an ideal-gas working fluid. It
#DESCRIPTION corresponds to the simple Joule Cycle as described in Chapter 12 of
#DESCRIPTION Rogers and Mayhew and in Chapter 2 of Cohen, Rogers and
#DESCRIPTION Saravanamutto. However, unlike those examples, the system is
#DESCRIPTION written with dynamics in mind.

## Explicitly copy appropriate components
#ALIAS	Pump	CompressibleFlow/Pump
#ALIAS	Comb	CompressibleFlow/Comb

#PAR t_2
#PAR t_3
#PAR t_4
#PAR p_2
#PAR p_3
#PAR p_4
#PAR mdot
#PAR gamma_0
#PAR q_0
#PAR w_0
#PAR omega_0
#PAR r_p
#PAR c_p
#PAR mom_0

#NOTPAR 	density
#NOTPAR	ideal_gas
#NOTPAR	q_0

## Label file for system SimpleGasTurbine (SimpleGasTurbine_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.5  2000/12/28 18:08:28  peterg
# ## To RCS
# ##
# ## Revision 1.4  1998/07/30 15:27:42  peterg
# ## Use #VAR inplace of dummy component.
# ##
# ## Revision 1.3  1998/07/03 14:54:45  peterg
# ## k_p --> k
# ## k_t --> k
# ##
# ## Revision 1.2  1998/07/03 14:53:38  peterg
# ## Renames tank to comb to be consistent.
# ##
# ## Revision 1.1  1998/05/18 15:46:02  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank

# Component type Fuel
	fuel

# Component type In
	in

# Component type Pump
	comp		none		c_v;density,ideal_gas,r;alpha;effort,k

# Component type Comb
	c1		none		m_c;v_c;r

# Component type Pump
	turb		none		c_v;density,ideal_gas,r;alpha;effort,k

# Component type Out
	out

# Component type Shaft
        shaft		none		j_s

# Component type Load
	load		none		r_l







Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_numpar.txt version [9ec8ae8fc7].




























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (SimpleGasTurbine_numpar.txt)
# Generated by MTT at Tue Mar 31 12:15:00 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:08:28  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_p = 	1005.0;
c_v = 	718.0; 
gamma_0 =  c_p/c_v;
alpha = (gamma_0-1)/gamma_0;
k = 	1.0;
p_1 = 	1e5; # 1 bar
p_4 = 	p_1; 
r = 	c_p-c_v;
t_1 = 	288.0; # In
v_c = 	1.0;

%Set the CC pressure and temperature
t_3 = 1000.0;
r_p = 6.0;
p_3 = r_p*p_1;

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c = (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 = p_1;
p_2 = p_3;

%Compute ss temperatures (isentropic)
t_2 = t_1*pow((p_2/p_1),alpha);
t_4 = t_3*pow((p_4/p_3),alpha);

%Find the steady-state work output
w_0 = c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Unit mass flow
mdot = 1;

%Corresponding shaft speed
omega_0 = mdot/k;

%Compute the corresponding load resistance (to absorb that work)
r_l = w_0/pow((omega_0),2);

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s = r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 =  omega_0*j_s;

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_rep.txt version [906aa92cc8].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system SimpleGasTurbine (SimpleGasTurbine_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2003/06/11 16:10:37  gawthrop
% %% Updated examples for latest MTT.
% %%
% %% Revision 1.2  2000/12/28 18:08:28  peterg
% %% To RCS
% %%
% %% Revision 1.1  2000/11/27 18:16:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss SimpleGasTurbine abg tex
mtt -o -ss SimpleGasTurbine struc tex
mtt -o -ss SimpleGasTurbine sympar tex
mtt -o -ss SimpleGasTurbine ode tex

mtt -o -ss SimpleGasTurbine sspar r
mtt -o -ss SimpleGasTurbine ss tex
mtt -o -ss SimpleGasTurbine sm tex

mtt -o -ss SimpleGasTurbine numpar tex
mtt -o -ss SimpleGasTurbine input tex
mtt -o -ss SimpleGasTurbine state tex
mtt -o -ss SimpleGasTurbine simpar tex
mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine__comp__T,SimpleGasTurbine__c1__T,SimpleGasTurbine__turb__T'

mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine_fuel_1_Heat_1_y,SimpleGasTurbine_load_1_Work_1_y'

mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine_shaft_1_speed_1_y'

mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine_c1_1_P'





Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_simp.r version [81a3a4cecb].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
%% Reduce commands to simplify output for system SimpleGasTurbine (SimpleGasTurbine_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LET c_v = c_p - r;
END;

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_sspar.r version [36ca0ccda1].




















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (SimpleGasTurbine_sspar.r)
% Generated by MTT at Thu Mar 26 16:28:59 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 18:08:28  peterg
% % To RCS
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c := (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 := p_1;
p_2 := p_3;

%Compute ss temperatures (isentropic)
t_2 := t_1*pow((p_2/p_1),alpha);
t_4 := t_3*pow((p_4/p_3),alpha);

%Find the steady-state work output
w_0 := c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Compute the corresponding load resistance (to absorb that work)
r_l := w_0/pow((omega_0),2);

%Unit mass flow
mdot := 1;

%Corresponding shaft speed
omega_0 := mdot/k;

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s := r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 :=  omega_0*j_s;

% Steady-state states
MTTX1 := 	mom_0;

% Steady-state inputs - combustion temperature
MTTU1 := 	t_3; % SimpleGasTurbine (T3)

;;END;

Added mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_state.txt version [c5243379dd].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# State initialisation file (SimpleGasTurbine_state.txt)
# Generated by MTT at Tue Mar 31 12:37:17 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:08:28  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Set the states
## Removed by MTT on Mon Nov 27 15:20:21 GMT 2000: x(1) =	 j_s/k ; # SimpleGasTurbine (j_s)

## Removed by MTT on Wed Jun 11 15:41:26 BST 2003: simplegasturbine_shaft_1_j_s	= j_s/k ;
simplegasturbine__shaft__j_s	= j_s/k;

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPipe/TestPipe_abg.fig version [546701647b].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 1351 4051 1351 3826 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 1126 4051 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2702 4052 2702 3827 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 2702 6976 2702 6751 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 1351 6976 1351 6751 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 3375 8550 405 450 405 450 3375 8550 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 2475 4050 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2475 4950 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 1125 4950 1575
4 2 4 0 0 0 20 0.0000000 4 240 930 4096 991 [Th_in]\001
4 2 -1 0 0 22 20 0.0000000 4 285 1065 1936 1441 SS:Th_in\001
4 2 -1 0 0 22 20 0.0000000 4 285 1080 1937 2792 SS:Hy_in\001
4 2 4 0 0 0 20 0.0000000 4 270 960 4097 2342 [Hy_in]\001
4 0 -1 0 0 22 20 0.0000000 4 285 1215 7111 1441 SS:Th_out\001
4 0 4 0 0 0 20 0.0000000 4 240 1080 4951 991 [Th_out]\001
4 0 4 0 0 0 20 0.0000000 4 270 1110 4951 2342 [Hy_out]\001
4 0 -1 0 0 22 20 0.0000000 4 285 1230 7111 2792 SS:Hy_out\001
4 1 -1 0 0 22 20 0.0000000 4 285 1110 4545 1980 Pipe:pipe\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPipe/TestPipe_lbl.txt version [151ff03f63].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TestPipe
%DESCRIPTION <Detailed description here>
%% Label file for system TestPipe (TestPipe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/20 08:02:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS Pipe IncompressibleFlow/Pipe

% Component type Pipe
	pipe		lin		rho;c_p;lin,r

% Component type SS
	Hy_in		SS	external,external
	Hy_out		SS	external,external
	Th_in		SS	external,external
	Th_out		SS	external,external

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPipe/TestPipe_rep.txt version [864bebdd7e].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TestPipe (TestPipe_rep.txt)
# Generated by MTT on" Fri Nov 20 08:16:40 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt TestPipe abg tex			# The system description
mtt TestPipe cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
mtt TestPipe struc tex	        # The system structure
mtt TestPipe dae tex	        # The system dae
# mtt TestPipe ode tex	        # The system ode 
# mtt TestPipe sspar tex		# Steady-state parameters
# mtt TestPipe ss tex 		# Steady state
# mtt TestPipe dm tex			# Descriptor matrices (of linearised system)
# mtt TestPipe sm tex			# State matrices (of linearised system)
# mtt TestPipe tf tex			# Transfer function (of linearised system)
# mtt TestPipe lmfr ps		# log modulus of frequency response (of linearised system)
# mtt TestPipe simpar tex		# Simulation parameters
# mtt TestPipe numpar tex		# Numerical simulation parameters
# mtt TestPipe input tex		# Simulation input
# mtt TestPipe odeso ps		# Simulation output

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPump/TestPump_abg.fig version [1e77e038d9].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 1351 4051 1351 3826 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2702 4052 2702 3827 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 2702 6976 2702 6751 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 1351 6976 1351 6751 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 3375 8550 405 450 405 450 3375 8550 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4500 4500 2475 4725 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4275 4500 4725 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 2475 4050 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2476 4950 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 1125 4950 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1125 4050 1575
4 2 4 0 0 0 20 0.0000 4 255 870 4096 991 [Th_in]\001
4 2 -1 0 0 22 20 0.0000 4 270 1200 1936 1441 SS:Th_in\001
4 2 -1 0 0 22 20 0.0000 4 270 1245 1937 2792 SS:Hy_in\001
4 0 -1 0 0 22 20 0.0000 4 270 1395 7111 1441 SS:Th_out\001
4 0 4 0 0 0 20 0.0000 4 255 1020 4951 991 [Th_out]\001
4 0 -1 0 0 22 20 0.0000 4 270 1440 7111 2792 SS:Hy_out\001
4 2 4 0 0 0 20 0.0000 4 255 885 3735 2565 [Hy_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1035 5355 2565 [Hy_out]\001
4 1 4 0 0 0 20 0.0000 4 240 810 4545 2340 [Shaft]\001
4 1 -1 0 0 22 20 0.0000 4 210 1200 4500 4815 SS:Shaft\001
4 1 -1 0 0 22 20 0.0000 4 270 1740 4545 1980 lPump:pump\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPump/TestPump_lbl.txt version [0beeb5c1ed].












































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TestPump: test of incompressible-flow pump component
%DESCRIPTION
%% Label file for system TestPump (TestPump_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.5  1998/11/20 13:00:27  peterg
% %% Replaces Pump by lPump in ALIAS
% %%
% %% Revision 1.4  1998/11/20 08:31:24  peterg
% %% Fixed alias error
% %%
% %% Revision 1.3  1998/11/20 08:28:41  peterg
% %% Tidied
% %%
% %% Revision 1.2  1998/11/20 08:09:57  peterg
% %% Added alias for Pump
% %%
% %% Revision 1.1  1998/11/20 08:06:28  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS lPump IncompressibleFlow/lPump


% Component type lPump
	pump		lin;lin		rho;c_p;flow,r_p;k_p;flow,r_l

% Component type SS
	Hy_in		SS	external,external
	Hy_out		SS	external,external
	Shaft		SS	external,external
	Th_in		SS	external,external
	Th_out		SS	external,external

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPump/TestPump_rep.txt version [a84c161cd8].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TestPump (TestPump_rep.txt)
# Generated by MTT on" Fri Nov 20 08:19:56 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt TestPump abg tex			# The system description
mtt TestPump cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
mtt TestPump struc tex	        # The system structure
#mtt TestPump dae tex	        # The system dae
mtt TestPump ode tex	        # The system ode 
# mtt TestPump sspar tex		# Steady-state parameters
# mtt TestPump ss tex 		# Steady state
# mtt TestPump dm tex			# Descriptor matrices (of linearised system)
# mtt TestPump sm tex			# State matrices (of linearised system)
# mtt TestPump tf tex			# Transfer function (of linearised system)
# mtt TestPump lmfr ps		# log modulus of frequency response (of linearised system)
# mtt TestPump simpar tex		# Simulation parameters
# mtt TestPump numpar tex		# Numerical simulation parameters
# mtt TestPump input tex		# Simulation input
# mtt TestPump odeso ps		# Simulation output

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestTank/TestTank_abg.fig version [39fee160b3].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 1351 4051 1351 3826 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2702 4052 2702 3827 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 2702 6976 2702 6751 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 1351 6976 1351 6751 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 3375 8550 405 450 405 450 3375 8550 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2025 1125 2025 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 1126 6975 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 2476 6975 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2025 2476 2025 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4500 4502 2475 4727 2700
4 2 4 0 0 0 20 0.0000000 4 240 930 4096 991 [Th_in]\001
4 2 -1 0 0 22 20 0.0000000 4 285 1065 1936 1441 SS:Th_in\001
4 2 -1 0 0 22 20 0.0000000 4 285 1080 1937 2792 SS:Hy_in\001
4 0 -1 0 0 22 20 0.0000000 4 285 1215 7111 1441 SS:Th_out\001
4 0 4 0 0 0 20 0.0000000 4 240 1080 4951 991 [Th_out]\001
4 0 -1 0 0 22 20 0.0000000 4 285 1230 7111 2792 SS:Hy_out\001
4 1 -1 0 0 22 20 0.0000000 4 225 1140 4545 1980 Tank:tank\001
4 1 4 0 0 0 20 0.0000000 4 240 1170 4590 2295 [Heat_in]\001
4 2 4 0 0 0 20 0.0000000 4 270 960 3915 2565 [Hy_in]\001
4 0 4 0 0 0 20 0.0000000 4 270 1110 5130 2565 [Hy_out]\001
4 1 -1 0 0 0 20 0.0000000 4 240 1590 4500 4860 SS:[Heat_in]\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestTank/TestTank_lbl.txt version [f62d6e747b].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY TestTank: Equations for incompressible-flow Tank component
%DESCRIPTION
%% Label file for system TestTank (TestTank_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/11/20 08:36:30  peterg
% %% Corrected alias
% %%
% %% Revision 1.2  1998/11/20 08:09:20  peterg
% %% Added alias for Tank
% %%
% %% Revision 1.1  1998/11/20 08:07:20  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS Tank IncompressibleFlow/Tank

% Component type SS
	Heat_in		SS	external,external
	Hy_in		SS	external,external
	Hy_out		SS	external,external
	Th_in		SS	external,external
	Th_out		SS	external,external

% Component type Tank
	tank		none		rho;c_p;c

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestTank/TestTank_rep.txt version [92aadf89bd].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system TestTank (TestTank_rep.txt)
# Generated by MTT on" Fri Nov 20 08:11:01 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt TestTank abg tex			# The system description
mtt TestTank cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
mtt TestTank struc tex	        # The system structure
# mtt TestTank dae tex	        # The system dae
mtt TestTank ode tex	        # The system ode 
# mtt TestTank sspar tex		# Steady-state parameters
# mtt TestTank ss tex 		# Steady state
# mtt TestTank dm tex			# Descriptor matrices (of linearised system)
# mtt TestTank sm tex			# State matrices (of linearised system)
# mtt TestTank tf tex			# Transfer function (of linearised system)
# mtt TestTank lmfr ps		# log modulus of frequency response (of linearised system)
# mtt TestTank simpar tex		# Simulation parameters
# mtt TestTank numpar tex		# Numerical simulation parameters
# mtt TestTank input tex		# Simulation input
# mtt TestTank odeso ps		# Simulation output

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/In_abg.fig version [991e0796f9].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 2253 3198 2253 3018 2433
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3196 2026 3196 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3195 4725 3195 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 4950 4547 4950 4367 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 2250 4547 2250 4367 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 5670 7200 1530 675 1530 675 5670 7200 5670
4 2 -1 0 0 0 20 0.0000 4 255 1095 2026 2341 SS:Th_in\001
4 2 -1 0 0 0 20 0.0000 4 255 1110 2071 5041 SS:Hy_in\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3376 5041 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3376 2341 0\001
4 0 4 0 0 0 20 0.0000 4 255 2235 4727 5042 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 4772 2342 SS:[Thermal_out]\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/In_desc.tex version [0c97485c1c].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/In_lbl.txt version [3db8aa0e33].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY In: Inflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system In (In_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	out Thermal_out,Hydraulic_out
%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out



% Component type SS
	Hy_in			SS	p_0,external
	Th_in			SS	t_0,external
	[Hydraulic_out]		SS	external,external
	[Thermal_out]		SS	external,external

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_abg.fig version [1fdbc1249e].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6302 1127 6302 2252 6527 2027
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6077 1127 6527 1127
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9495 2700 10534 2703 10309 2928
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6075 5175 3600 5175 3600 3150 3849 3399
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6076 5401 6526 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 4950 6300 4050 6525 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 8775 3150 8775 5175 6525 5175 6750 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 6299 6301 5399 6526 5624
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3060 2700 2835 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4497 2698 5715 2700 5490 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6930 2700 8145 2700 7920 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 7200 11925 225 900 225 900 7200 11925 7200
4 1 4 0 0 2 16 0.0000 4 210 750 3602 3062 [Shaft]\001
4 1 4 0 0 2 16 0.0000 4 225 1005 6302 2477 [Heat_in]\001
4 1 4 0 0 2 16 0.0000 4 210 750 8733 3063 [Shaft]\001
4 1 -1 0 0 2 20 0.0000 4 255 1185 3737 2792 lPump:p1\001
4 1 -1 0 0 22 20 0.0000 4 210 1110 6257 1037 SS:Heat\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6301 5266 1\001
4 1 -1 0 0 22 20 0.0000 4 210 1170 6391 6751 SS:Work\001
4 1 -1 0 0 22 20 0.0000 4 270 555 6300 3915 I:j_s\001
4 1 -1 0 0 2 20 0.0000 4 195 1065 6302 2792 Tank:C1\001
4 1 -1 0 0 2 20 0.0000 4 255 1140 8868 2793 lPump:t1\001
4 1 -1 0 0 22 20 0.0000 4 210 570 1620 2790 In:in\001
4 1 -1 0 0 22 20 0.0000 4 210 1005 11116 2791 Out:out\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_desc.tex version [4d57456af9].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system LiquidTurbine (LiquidTurbine_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{LiquidTurbine} is
   displayed in Figure \Ref{LiquidTurbine_abg} and its label
   file is listed in Section \Ref{sec:LiquidTurbine_lbl}.
   The subsystems are listed in Section \Ref{sec:LiquidTurbine_sub}.

\textbf{LiquidTurbine} can be regarded as a single-spool gas turbine
with an incompressible working fluid. Of course, such a device cannot
convert heat to work; however, it provides a useful first step towards
modelling a gas turbine.

There are three main components:
\begin{enumerate}
\item p1 -- a leaky pump \textbf{lPump} component. This is analogous
  to the gas turbine compressor.
\item c1 -- a tank \textbf{Tank} component. This is analogous
  to the gas turbine combustion chamber.
\item t1 -- a leaky turbine \textbf{lTurb} component. This is analogous
  to the gas turbine turbine.
\end{enumerate}
The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_lbl.txt version [e86e85fc85].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY LiquidTurbine
%DESCRIPTION <Detailed description here>
%% Label file for system LiquidTurbine (LiquidTurbine_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ALIAS	lPump	IncompressibleFlow/lPump
%ALIAS	Tank	IncompressibleFlow/Tank

%VAR p_0
%VAR q_0
%VAR t_0


%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Component type I
	j_s		lin		flow,j_s

% Component type Pump
	p1		lin;lin		rho;c_p;flow,r_p;k_p;flow,r_pl

% Component type SS
	Heat		SS	external,external
	Work		SS	external,external

% Component type Turb
	t1		lin;lin		rho;c_p;flow,r_t;k_t;flow,r_tl

% Component type Tank
	C1		none		rho;c_p;c_t

% Component type In
	in

% Component type Out
	out

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_numpar.txt version [e0fc2ac7f4].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (LiquidTurbine_numpar.txt)
# Generated by MTT at Mon Mar  9 09:16:28 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:11:16  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_p = 	1.0; # LiquidTurbine
c_t = 	1.0; # LiquidTurbine
j_s = 	1.0; # LiquidTurbine
k_p = 	1.0; # LiquidTurbine
k_t = 	1.0; # LiquidTurbine
p_0 = 	1e5; # In,Out
q_0 = 	1e5; # Heat in 
r_p = 	1.0; # LiquidTurbine
r_pl = 	100.0; # LiquidTurbine
r_t = 	1.0; # LiquidTurbine
r_tl = 	100.0; # LiquidTurbine
rho = 	1.0; # LiquidTurbine
t_0 = 	300.0; # In,Out

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_rep.txt version [4a1d6d995c].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system LiquidTurbine (LiquidTurbine_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/21 23:50:25  peterg
% %% Use compiled version
% %%
% %% Revision 1.1  1999/02/21 02:13:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss LiquidTurbine abg tex
mtt -o -ss LiquidTurbine struc tex
mtt -o -ss LiquidTurbine sympar tex
mtt -o -ss LiquidTurbine ss tex
mtt -o -ss LiquidTurbine ode tex


mtt -o -ss LiquidTurbine numpar txt
mtt -o -ss LiquidTurbine input txt

mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__Heat'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__Work'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__in__Hy_in'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__out__Hy_out'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__out__Th_out'

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_sspar.r version [d37fe0362d].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (LiquidTurbine_sspar.r)
% Generated by MTT at Fri Nov 20 11:42:16 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 18:11:16  peterg
% % To RCS
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	1; % LiquidTurbine (j_s)
MTTX2 := 	p_0*c_t/rho; % LiquidTurbine_C1 (tank) - pressure = p0
MTTX3 := 	t_0*p_0*c_t*c_p; % LiquidTurbine_C1 (tank) - temp = t0
% Steady-state inputs
MTTU1 := 	q_0; % LiquidTurbine (Heat)
MTTU2 := 	0; % LiquidTurbine (Work)
;;END;

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/Out_abg.fig version [50c38b16c3].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2205 2250 3150 2250 2970 2430
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2205 2025 2205 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4950 4545 4950 4365 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3555 2250 4500 2250 4320 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 5850 6075 1530 45 1530 45 5850 6075 5850
4 2 4 0 0 0 20 0.0000 4 255 2085 2160 5040 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2115 2340 SS:[Thermal_in]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 5040 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 2340 0\001
4 0 -1 0 0 0 20 0.0000 4 255 1245 4590 2340 SS:Th_out\001
4 0 -1 0 0 0 20 0.0000 4 255 1260 4635 5040 SS:Hy_out\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/Out_desc.tex version [3dd57dc573].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/Out_lbl.txt version [36c671bdc9].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Out: Outflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system Out (Out_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in


% Component type SS
	Hy_out		SS	p_0,external
	Th_out		SS	t_0,external
	[Hydraulic_in]	SS	external,external
	[Thermal_in]	SS	external,external

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/In_abg.fig version [695cb8cbc2].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 2253 3198 2253 3018 2433
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3196 2026 3196 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 4950 4547 4950 4367 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 2250 4547 2250 4367 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 5670 7200 1530 675 1530 675 5670 7200 5670
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
4 2 -1 0 0 0 20 0.0000 4 285 1140 2026 2341 SS:Th_in\001
4 2 -1 0 0 0 20 0.0000 4 285 1125 2071 5041 SS:Hy_in\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3376 5041 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3376 2341 0\001
4 0 4 0 0 0 20 0.0000 4 285 2295 4727 5042 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 285 2175 4772 2342 SS:[Thermal_out]\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/In_desc.tex version [0c97485c1c].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/In_lbl.txt version [7b70ce34dc].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY In: Inflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system In (In_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	out Thermal_out,Hydraulic_out
%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out



% Component type SS
	Hy_in			SS	internal,external
	Th_in			SS	external,internal
	[Hydraulic_out]		SS	external,external
	[Thermal_out]		SS	external,external

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/Out_abg.fig version [168ef8465c].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2205 2250 3150 2250 2970 2430
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2205 2025 2205 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4950 4545 4950 4365 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3555 2250 4500 2250 4320 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 5850 6075 1530 45 1530 45 5850 6075 5850
4 2 4 0 0 0 20 0.0000 4 285 2145 2160 5040 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 285 2025 2115 2340 SS:[Thermal_in]\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3375 5040 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3375 2340 0\001
4 0 -1 0 0 0 20 0.0000 4 285 1290 4590 2340 SS:Th_out\001
4 0 -1 0 0 0 20 0.0000 4 285 1275 4635 5040 SS:Hy_out\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/Out_desc.tex version [3dd57dc573].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/Out_lbl.txt version [6454b3a5a6].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Out: Outflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system Out (Out_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in


% Component type SS
	Hy_out		SS        p_0,internal
	Th_out		SS        t_0,internal
	[Hydraulic_in]	SS	external,external
	[Thermal_in]	SS	external,external

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_abg.fig version [5d0413d6f9].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 6210 4140 6390 4365
4 1 0 100 0 18 18 0.0000 4 195 150 6300 4365 0\001
-6
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9495 2700 10534 2703 10309 2928
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3060 2700 2835 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4497 2698 5715 2700 5490 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6930 2700 8145 2700 7920 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 7200 11925 225 900 225 900 7200 11925 7200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 4050 6300 2925 6525 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 4275 7650 4275 7425 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 4275 6075 4275 5850 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 4275 3600 4275 3375 4500
4 1 4 0 0 2 16 0.0000 4 240 1020 6302 2477 [Heat_in]\001
4 1 -1 0 0 2 20 0.0000 4 210 1245 6302 2792 TankC:t1\001
4 1 -1 0 0 2 20 0.0000 4 285 945 8868 2793 Pipe:p2\001
4 1 -1 0 0 22 20 0.0000 4 225 600 1620 2790 In:in\001
4 1 -1 0 0 22 20 0.0000 4 225 1080 11116 2791 Out:out\001
4 1 -1 0 0 2 20 0.0000 4 285 945 3737 2792 Pipe:p1\001
4 1 0 100 0 18 18 0.0000 4 210 1305 4275 4365 RS:heater\001
4 1 0 100 0 18 18 0.0000 4 270 1020 1935 4365 Se:V_in\001
4 1 0 100 0 18 18 0.0000 4 270 1215 8280 4365 De:T_out\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_desc.tex version [51759f48f8].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system ShowerHeater (ShowerHeater_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ShowerHeater} is
   displayed in Figure \Ref{ShowerHeater_abg} and its label
   file is listed in Section \Ref{sec:ShowerHeater_lbl}.
   The subsystems are listed in Section \Ref{sec:ShowerHeater_sub}.

\textbf{ShowerHeater} is a very elementary model of an electric heater suitable for
a shower. It illustates the use of bond graph components which are
internally pseudo, but externally true bond graphs
(temperature/entropy flow).

There are three main components:
\begin{enumerate}
\item p1 and p2 -- a \textbf{Pipe} component (see Section
  \Ref{sec:Pipe}). It is assumed that the pipes have zero flow
  resistance and thus do not generate heat via flow resistance.
\item t1 -- a tank \textbf{Tank} component. 
\item Heater -- a resistive heater modelled by the thermodynamic
  \textbf{R} component \textbf{RS}.
\end{enumerate}
Other components could be added to represent thermal conduction and
thermal capacities.

The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

The three inputs are
\begin{description}
\item[$u_1$] The flow rate
\item[$u_2$] The inlet temperature
\item[$u_3$] The voltage across the heating element.
\end{description}
The single output is
\begin{description}
\item[$y_1$] The outflow temperature
\end{description}
and the state is 
\begin{description}
\item[$x_1$] The heat contained in the tank.
\end{description}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_input.txt version [6978dbd547].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Input specification (ShowerHeater_input.txt)
# Generated by MTT at Tue Dec 14 10:03:59 EST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:11:47  peterg
## To RCS
##
###############################################################

# Set the inputs
showerheater__in__hy_in	= 1e-4*(t>30); # Inflow
showerheater__in__th_in	=  280; # In temperature
showerheater__v_in__u	= 240*((t<60)&&(t>1)); # Input voltage

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_lbl.txt version [ba8dee801c].















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY ShowerHeater
#DESCRIPTION <Detailed description here>
## Label file for system ShowerHeater (ShowerHeater_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  2000/12/28 18:11:47  peterg
# ## To RCS
# ##
# ###############################################################

#NOTPAR t_0

#ALIAS	Pipe	IncompressibleFlow/Pipe

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank


# Component type Pipe
	p1		lin	        rho;c_p;flow,0
	p2		lin	        rho;c_p;flow,0


# Component type TankC
	t1		TankC		rho;c_p;v

# Component type In
	in

# Component type Out
	out

# Component type RS
        heater	        lin		flow,r_h

# Component type Se
        V_in             SS              external

# Component type De
        T_out            SS              external

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_numpar.txt version [efdd8b1ce9].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (ShowerHeater_numpar.txt)
# Generated by MTT at Tue Dec 14 09:52:42 EST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:11:47  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_p = 	4.184*1e3;		# Specific heat
p_0 = 	0.0;			# Ambient pressure
r_h = 	10.0;			# Heater resistance
rho = 	1e3;			# Density
v = 	1e-3;			# Volume (1 lit)
t_0	= 1.0; # Added by MTT on Wed Aug 06 19:05:01 BST 2003

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_rep.txt version [4288f558fa].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system ShowerHeater (ShowerHeater_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:11:47  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:13:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt  ShowerHeater abg tex
mtt  ShowerHeater struc tex
mtt  ShowerHeater sympar tex
mtt  ShowerHeater ode tex


mtt  ShowerHeater numpar txt
mtt  ShowerHeater input txt

mtt  ShowerHeater odeso ps 

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_simpar.txt version [3b623625a5].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ShowerHeater (ShowerHeater_simpar.txt)
# Generated by MTT on Tue Dec 14 10:05:57 EST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 100.0;		# Last time in simulation
DT          = 0.5;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_simpar.txt_old version [3b623625a5].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ShowerHeater (ShowerHeater_simpar.txt)
# Generated by MTT on Tue Dec 14 10:05:57 EST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 100.0;		# Last time in simulation
DT          = 0.5;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_sspar.r version [c5e3a0b620].





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (ShowerHeater_sspar.r)
% Generated by MTT at Fri Nov 20 11:42:16 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	1; % ShowerHeater (j_s)
MTTX2 := 	p_0*c/rho; % ShowerHeater_C1 (tank) - pressure = p0
MTTX3 := 	t_0*p_0*c*c_p; % ShowerHeater_C1 (tank) - temp = t0
% Steady-state inputs
MTTU1 := 	q_0; % ShowerHeater (Heat)
MTTU2 := 	0; % ShowerHeater (Work)
;;END;

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_state.txt version [154b053b6b].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (ShowerHeater_state.txt)
# Generated by MTT at Tue Dec 14 10:06:08 EST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:11:47  peterg
## To RCS
##
###############################################################

# Set the states
## Removed by MTT on Wed Aug  6 19:07:29 BST 2003: mttx(1) 	
showerheater__t1__tank	= 280*rho*v*c_p; # Initial heat in tank

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_TankC_abg.fig version [61a9baa3f5].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2430 2070 3600 3105
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2445 2477 3570 2477 3345 2702
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2297 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 2387 1\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 3062 1\001
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2927 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2850 2657 .\001
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 2477 6990 2477 6765 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 5627 6990 5627 6765 5852
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 2478 8565 2478 8340 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9241 2479 10366 2479 10141 2704
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 5626 10365 5626 10140 5851
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8609 6571 5864 6571 5864 1801 8609 1801 8609 6571
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6989 2701 7439 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7214 2702 7214 3827 7439 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 5850 4050 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 1127 3825 2252 4050 2027
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 2475 5190 2475 4965 2700
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12825 7155 12825 225 225 225 225 7155 12825 7155
4 0 4 0 0 0 20 0.0000 4 285 2295 10546 5719 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 285 2175 10501 2569 SS:[Thermal_out]\001
4 2 4 0 0 0 20 0.0000 4 285 2145 4019 5716 SS:[Hydraulic_in]\001
4 1 -1 0 0 22 20 0.0000 4 225 390 5550 2567 ES\001
4 1 1 1 0 3 20 0.0000 4 210 150 4606 5538 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 4471 5808 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 4471 5448 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 4471 6078 V\001
4 1 4 0 0 0 20 0.0000 4 270 300 5280 2252 [s]\001
4 1 4 0 0 0 20 0.0000 4 270 315 5820 2252 [e]\001
4 1 1 1 0 3 20 0.0000 4 210 150 6406 2388 1\001
4 1 1 1 0 3 20 0.0000 4 210 660 6584 2206 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 6899 2386 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 6497 2659 .\001
4 1 1 1 0 3 20 0.0000 4 210 195 6497 2929 E\001
4 1 -1 0 0 22 20 0.0000 4 225 915 7214 4186 C:tank\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7215 5762 0\001
4 1 -1 0 0 22 20 0.0000 4 225 390 8925 2568 ES\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 5811 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 5451 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 9648 6081 V\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 5541 2\001
4 1 1 1 0 3 20 0.0000 4 210 195 7846 2930 E\001
4 1 4 0 0 0 20 0.0000 4 270 315 8655 2208 [e]\001
4 1 4 0 0 0 20 0.0000 4 270 300 9150 2208 [s]\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2301 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 2391 2\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2931 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 2661 .\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 3066 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 7846 2660 .\001
4 1 1 1 0 3 20 0.0000 4 210 660 7936 2209 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 8251 2389 0\001
4 1 1 1 0 3 20 0.0000 4 210 150 7758 2391 2\001
4 1 1 1 0 3 20 0.0000 4 285 2550 7259 6346 Pseudo Bond Graph\001
4 1 4 0 0 0 20 0.0000 4 285 1530 3870 945 SS:[Heat_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7245 2565 0\001
4 1 -1 0 0 22 20 0.0000 4 210 165 3825 2565 0\001
4 2 4 0 0 0 20 0.0000 4 285 2025 2385 2565 SS:[Thermal_in]\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_abg.fig version [61a9baa3f5].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2430 2070 3600 3105
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2445 2477 3570 2477 3345 2702
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2297 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 2387 1\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 3062 1\001
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2927 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2850 2657 .\001
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 2477 6990 2477 6765 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 5627 6990 5627 6765 5852
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 2478 8565 2478 8340 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9241 2479 10366 2479 10141 2704
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 5626 10365 5626 10140 5851
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8609 6571 5864 6571 5864 1801 8609 1801 8609 6571
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6989 2701 7439 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7214 2702 7214 3827 7439 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 5850 4050 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 1127 3825 2252 4050 2027
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 2475 5190 2475 4965 2700
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12825 7155 12825 225 225 225 225 7155 12825 7155
4 0 4 0 0 0 20 0.0000 4 285 2295 10546 5719 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 285 2175 10501 2569 SS:[Thermal_out]\001
4 2 4 0 0 0 20 0.0000 4 285 2145 4019 5716 SS:[Hydraulic_in]\001
4 1 -1 0 0 22 20 0.0000 4 225 390 5550 2567 ES\001
4 1 1 1 0 3 20 0.0000 4 210 150 4606 5538 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 4471 5808 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 4471 5448 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 4471 6078 V\001
4 1 4 0 0 0 20 0.0000 4 270 300 5280 2252 [s]\001
4 1 4 0 0 0 20 0.0000 4 270 315 5820 2252 [e]\001
4 1 1 1 0 3 20 0.0000 4 210 150 6406 2388 1\001
4 1 1 1 0 3 20 0.0000 4 210 660 6584 2206 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 6899 2386 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 6497 2659 .\001
4 1 1 1 0 3 20 0.0000 4 210 195 6497 2929 E\001
4 1 -1 0 0 22 20 0.0000 4 225 915 7214 4186 C:tank\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7215 5762 0\001
4 1 -1 0 0 22 20 0.0000 4 225 390 8925 2568 ES\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 5811 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 5451 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 9648 6081 V\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 5541 2\001
4 1 1 1 0 3 20 0.0000 4 210 195 7846 2930 E\001
4 1 4 0 0 0 20 0.0000 4 270 315 8655 2208 [e]\001
4 1 4 0 0 0 20 0.0000 4 270 300 9150 2208 [s]\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2301 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 2391 2\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2931 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 2661 .\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 3066 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 7846 2660 .\001
4 1 1 1 0 3 20 0.0000 4 210 660 7936 2209 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 8251 2389 0\001
4 1 1 1 0 3 20 0.0000 4 210 150 7758 2391 2\001
4 1 1 1 0 3 20 0.0000 4 285 2550 7259 6346 Pseudo Bond Graph\001
4 1 4 0 0 0 20 0.0000 4 285 1530 3870 945 SS:[Heat_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7245 2565 0\001
4 1 -1 0 0 22 20 0.0000 4 210 165 3825 2565 0\001
4 2 4 0 0 0 20 0.0000 4 285 2025 2385 2565 SS:[Thermal_in]\001

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_cr.r version [dab3fcf1b4].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Constitutive relation file for TankC (TankC_cr.r)
% Generated by MTT at Thu Mar  5 10:30:23 GMT 1998

OPERATOR TankC;

%Pressure
% -- not relevant here

%Temperature
FOR ALL COMP,rho,c_p,volume,Energy
LET TankC(COMP,rho,c_p,volume,effort,1,
	Energy,state,1
	) = Energy/(volume*rho*c_p);

END;

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_desc.tex version [944934a0ef].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system TankC (TankC_desc.tex)
% Generated by MTT on Tue Jan 13 18:03:04 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TankC} is
   displayed in Figure \Ref{TankC_abg} and its label
   file is listed in Section \Ref{sec:TankC_lbl}.
   The subsystems are listed in Section \Ref{sec:TankC_sub}.

Added mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_lbl.txt version [649a90bba0].



























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Label file for system TankC (TankC_lbl.txt)
%SUMMARY TankC: TankC of hot incompressible liquid - fixed volume
%DESCRIPTION rho - density; c_p - specific heat; v - volume
%DESCRIPTION Typical lable: tank  TankC  rho;c_p;v

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/11/20 13:20:27  peterg
% %% Aliased ports
% %%
% %% Revision 1.2  1998/11/20 09:46:34  peterg
% %% Modernised lbl syntax
% %%
% %% Revision 1.1  1998/11/20 08:57:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Heat	Heat_in

% Argument aliases
%ALIAS	$1	rho
%ALIAS	$2	c_p
%ALIAS	$3	v

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	tank		TankC	       rho,c_p,v

% Component type SS
	[Heat_in]	SS	external,external
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external



Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_abg.fig version [ebaa782f1c].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3150 5850 3150 5625 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4275 5850 4275 5625 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 2925 3150 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 4050 1800 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1777 4275 3127 4275 2902 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 4095 4500 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 8325 3150 8100 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 2925 6975 3375
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2925 2025 4725 2025 4725 5400 2925 5400 2925 2025
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 5850 9450 1575 450 1575 450 5850 9450 5850
4 0 -1 0 0 0 20 0.0000000 4 240 870 6030 3240 RT:r_2\001
4 2 4 0 0 0 20 0.0000000 4 240 690 2835 3060 [t_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 840 4770 3015 [t_out]\001
4 2 4 0 0 0 20 0.0000000 4 240 735 2880 4185 [e_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 885 4770 4185 [e_out]\001
4 2 -1 0 0 0 20 0.0000000 4 240 900 1620 3240 SS:T_1\001
4 0 -1 0 0 0 20 0.0000000 4 240 900 8460 3240 SS:T_2\001
4 2 -1 0 0 0 20 0.0000000 4 240 780 1665 4365 SS:I_r\001
4 0 -1 0 0 0 20 0.0000000 4 240 930 5985 4365 SS:V_0\001
4 1 -1 0 0 0 20 0.0000000 4 270 1575 3780 3825 Segment:s*20\001

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_desc.tex version [4a2a8618be].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system HeatedRod (HeatedRod_desc.tex)
% Generated by MTT on Thu Sep 4 18:05:09 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 16:16:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{table}[htbp]
  \begin{center}
    \leavevmode
    \begin{tabular}{l l l}
      \hline
      Parameter & Symbol & Value  \\
      \hline
      Length & $L_r$ & 1m \\
      Diameter & $D_r$ & 1mm \\
      Resistivity & $\rho$ & $1.68\times10^{-9} \Omega$m \\
      Thermal conductivity & $\sigma$ & 390 W$\text{m}^{-1}$\\
      Thermal capacity & $\kappa$ & 380 J$\text{m}^{-3}$\\
      \hline
    \end{tabular}
    \caption{Heated rod parameters}
    \label{tab:rod}
  \end{center}
\end{table}

 System \textbf{HeatedRod} is a model of a well-insulated rod of copper with an
 electric current passing through it which warms it up. The two ends of
 the rod are fixed at ambient temperature; this is where all the heat
 loss occurs. 
 
 This example introduces the idea of the {\bf FP}, \textbf{RT} and
 \textbf{CT} components in the context of thermal conduction.
 
 The model is similar to that described in chapter 8 of \citeN{Cel91}.
 However, instead of representing the thermal resistance by {\bf RS}
 components and reinserting the entropy flow, the {\bf RT} component
 uses two {\bf FP} components to convert from true to pseudo bonds and
 back again. Similary, the thermal capacity is modelled by the {\bf
   CT} component.
 
 This distributed system (which strictly speaking has a partial
 differential equation model) is approximated by an ordinary
 diffferential equation model by modelling the system by a number of
 discrete segments of length $\Delta x$. Each segment model consists
 of two conceptual parts.
 \begin{itemize}
 \item An ideal lump of copper with no thermal resistance but with the
   normal attributes of electrical resistance (modelled by the
   \textbf{RS} component and thermal capacity (modelled by the
   \textbf{CF} component).
 \item A thin lump wtih thermal resistance but no thermal capacity or
   electrical resistance (modeled by the \textbf{RT} component).
 \end{itemize}
At this level of the hierarchy, all bonds are true energy bonds and
thus energy conservation is assured. Note that the \textbf{RS}
component correctely transforms electrical to thermal energy.

The system was simulated with a total of nine lumps whilst passing a
current of 1A though the rod for a total of 10s. The initial
temperature and the end temperatures were all set at 300K.

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_input.txt version [dbd86998eb].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (HeatedRod_input.txt)
# Generated by MTT at Thu Sep  4 16:11:06 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:12:41  peterg
# %% To RCS
# %%
# %% Revision 1.1  1998/08/15 13:40:20  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Thu Jun 12 14:33:52 BST 2003: u() =	10.0*(t<5.0); # I_r 
heatedrod__i_r	= 10.0*(t<5.0); # I_r 

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_lbl.txt version [d5b6ca5013].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY HeatedRod: Thermal/Electrical model of Electric rod
%DESCRIPTION Introduces the idea of the ES component which
%DESCRIPTION transforms a relative-temperature/enthalpy pseudo bond 
%DESCRIPTION (at the [e]port) into an absolute-temperature/enntropy 
%DESCRIPTION energy bond (at the [s] port) and vice versa.

%VAR rod_length
%VAR rod_radius
%VAR electrical_resistivity
%VAR thermal_resistivity
%VAR thermal_capacity
%VAR segments
%VAR area
%VAR delta_x
%VAR volume
%VAR density
%VAR mass

%% Label file for system HeatedRod (HeatedRod_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 16:16:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RT
	r_2		lin	flow,r_2

% Component type SS
	I_r	SS	internal,external
	T_1	SS	t_0,internal
	T_2	SS	t_0,internal
	V_0	SS	internal,internal

% Component type Segment
	s

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_numpar.txt version [a9f0752d97].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (HeatedRod_numpar.txt)
# Generated by MTT at Thu Sep  4 16:11:04 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/08/15 13:40:33  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Constants for copper
density = 8.96;
rod_length = 1.0;
rod_radius = 1e-3;
electrical_resistivity = 16.8*0.000000001;
thermal_resistivity = 1/390.0;
thermal_capacity = 380.0;


segments = 20;
area = pi*rod_radius*rod_radius;
delta_x = rod_length/segments;
volume = area*delta_x;
mass = volume*density;

# Parameters
c_t = 	thermal_capacity*mass;
r = 	electrical_resistivity*delta_x/area;
r_t = 	thermal_resistivity*delta_x/area;
r_2 = 	r_t;
t_0 = 	300; # Ambient




Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_rep.txt version [d8fe1963e7].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system HeatedRod (HeatedRod_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/21 23:53:04  peterg
% %% Compiled version
% %%
% %% Revision 1.1  1999/02/21 02:14:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss HeatedRod abg tex
mtt -o -ss HeatedRod struc tex
mtt -o -ss HeatedRod ode tex
mtt -o -ss HeatedRod ss tex
mtt -o -ss HeatedRod sm tex
mtt -o -ss HeatedRod lmfr ps

mtt -o -ss HeatedRod numpar txt
mtt -o -ss HeatedRod input txt
mtt -o -ss HeatedRod odeso ps

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_simpar.txt version [b039d6f9cd].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system HR (HR_simpar.txt)
# Generated by MTT on Wednesday July 29 13:59:50 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/08/15 13:40:47  peterg
## Initial revision
##
###############################################################


LAST        = 10;       # Last time in simulation
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps

STEPFACTOR = 1; # Added automatically
DT = 0.1;                 # Added automatically

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_sspar.r version [a711759aa0].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (HeatedRod_sspar.r)
% Generated by MTT at Thu Jun 25 09:32:38 BST 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX2 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX3 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX4 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX5 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX6 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX7 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX8 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX9 := 	t_0*c_t; % HeatedRod_s_c_t (c)

% Steady-state inputs
MTTU1 := 	1.0; % HeatedRod (I_r)

;;END;

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_state.txt version [d44ad0a9b8].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (HeatedRod_state.txt)
# Generated by MTT at Sat Aug 15 15:34:41 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:12:41  peterg
## To RCS
##
###############################################################

# Set the states
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(1) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(2) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(3) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(4) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(5) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(6) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(7) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(8) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(9) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(10) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(11) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(12) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(13) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(14) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(15) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(16) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(17) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(18) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(19) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(20) 	=
## c_t*t_0; 	# c (HeatedRod_s_c_t)

heatedrod__s__10__c_t__c	= c_t*t_0;
heatedrod__s__11__c_t__c	= c_t*t_0;
heatedrod__s__12__c_t__c	= c_t*t_0;
heatedrod__s__13__c_t__c	= c_t*t_0;
heatedrod__s__14__c_t__c	= c_t*t_0;
heatedrod__s__15__c_t__c	= c_t*t_0;
heatedrod__s__16__c_t__c	= c_t*t_0;
heatedrod__s__17__c_t__c	= c_t*t_0;
heatedrod__s__18__c_t__c	= c_t*t_0;
heatedrod__s__19__c_t__c	= c_t*t_0;
heatedrod__s__20__c_t__c	= c_t*t_0;
heatedrod__s__2__c_t__c	= c_t*t_0;
heatedrod__s__3__c_t__c	= c_t*t_0;
heatedrod__s__4__c_t__c	= c_t*t_0;
heatedrod__s__5__c_t__c	= c_t*t_0;
heatedrod__s__6__c_t__c	= c_t*t_0;
heatedrod__s__7__c_t__c	= c_t*t_0;
heatedrod__s__8__c_t__c	= c_t*t_0;
heatedrod__s__9__c_t__c	= c_t*t_0;
heatedrod__s__c_t__c	= c_t*t_0;

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/Segment_abg.fig version [b5d0a0a3ff].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1306 2476 2881 2476 2656 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3781 2476 5356 2476 5131 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5761 2476 8550 2475 8325 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 4276 5581 2701 5806 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 6301 5581 4726 5806 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 6525 5356 6526 5131 6751
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 6526 8550 6525 8325 6750
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 2701 6920 3815 6601 3815
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 2251 5581 676 5806 901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5356 676 5806 676
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 7425 9900 90 45 90 45 7425 9900 7425
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 1800 1575 1800 1575 4455 7650 4455
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 6975 7650 4545 1575 4545 1575 6975 7650 6975
4 1 -1 0 0 0 20 0.0000000 4 240 810 3331 2566 RT:r_t\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5581 2566 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 555 5581 4591 RS:r\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5581 6616 1\001
4 1 -1 0 0 0 20 0.0000000 4 240 840 7021 4141 CT:c_t\001
4 1 -1 0 0 0 20 0.0000000 4 240 870 5581 586 SS:T_s\001
4 2 4 0 0 0 20 0.0000000 4 240 1020 1261 2566 SS:[t_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 1020 8685 2565 SS:[t_out]\001
4 2 4 0 0 0 20 0.0000000 4 240 1065 1260 6615 SS:[e_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 1065 8685 6615 SS:[e_out]\001
4 0 1 1 0 0 20 0.0000000 4 240 1875 1845 4050 Thermal model\001
4 0 1 1 0 0 20 0.0000000 4 240 2025 1800 5175 Electrical model\001
4 0 1 1 0 0 20 0.0000000 4 270 2415 6075 585 Temperature sensor\001

Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/Segment_desc.tex version [6387facfb7].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Segment (Segment_desc.tex)
% Generated by MTT on Thu Sep 4 18:05:43 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



   The acausal bond graph of system \textbf{Segment} is
   displayed in Figure \ref{Segment_abg} and its label
   file is listed in Section \ref{sec:Segment_lbl}.
   The subsystems are listed in Section \ref{sec:Segment_sub}.



Added mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/Segment_lbl.txt version [1cb8b4681d].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%SUMMARY Segment: Segment of HeatedRod
%DESCRIPTION Part of the HeatedRod example.
%% Label file for system Segment (Segment_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/08/10 12:29:48  peterg
% %% Added missing ports.
% %%
% %% Revision 1.1  1997/09/11 16:17:14  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CT
	c_t		lin	effort,c_t

% Component type RS
	r		lin	flow,r

% Component type RT
	r_t		lin	flow,r_t

% Component type SS
	T_s		SS		external,0
	[t_in]		SS		external,external
	[t_out]		SS		external,external
	[e_in]		SS		external,external
	[e_out]		SS		external,external

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_abg.fig version [3bd0451b28].





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3827 3152 5402 3152 5177 3377
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3152 8552 3152 8327 3377
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8552 2927 8552 3377
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 902 3150 2477 3150 2252 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2925 2475 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 2925 3825 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 1125 3152 2700 2927 2475
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 5175 -450 5175 -450 450 9900 450 9900 5175
4 1 -1 0 0 0 20 0.0000 4 285 1440 6212 3242 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000 4 210 1050 8687 3242 Sf:Work\001
4 1 1 1 0 3 20 0.0000 4 210 735 4456 3466 dS/dT\001
4 1 1 1 0 3 20 0.0000 4 195 180 4501 2926 T\001
4 1 1 1 0 3 20 0.0000 4 195 180 7921 2926 P\001
4 1 1 1 0 3 20 0.0000 4 210 765 7786 3466 dV/dT\001
4 1 1 1 0 3 30 0.0000 4 405 2325 5085 4635 Carnot cycle\001
4 2 -1 0 0 0 20 0.0000 4 210 975 810 3240 Se:Heat\001
4 1 -1 0 0 0 20 0.0000 4 195 1005 3150 3240 FMRT:r\001
4 1 4 100 0 18 14 0.0000 4 195 600 3150 2925 [mod]\001
4 1 -1 0 0 0 20 0.0000 4 210 1170 3150 990 Sf:switch\001

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_desc.tex version [2f3b6bc5ff].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system CarnotCycle (CarnotCycle_desc.tex)
% Generated by MTT on Tue Dec 9 12:13:57 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CarnotCycle} is
   displayed in Figure \Ref{CarnotCycle_abg} and its label
   file is listed in Section \Ref{sec:CarnotCycle_lbl}.
   The subsystems are listed in Section \Ref{sec:CarnotCycle_sub}.

The Carnot cycle is a simple closed thermodynamic cycle with four parts:
\begin{enumerate}
\item Isentropic compression
\item Heat injection at constant temperature
\item Isentropic expansion
\item Heat extraction at constant temperature
\end{enumerate}

The subsystem \textbf{Cycle} (Section \Ref{sec:Cycle}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

In contast to the Otto cycle (see Table
\Ref{tab:cycles} where each table entry gives the causality on the
heat and work ports respectively). The ideal Carnot cycle has
derivative causality on the {\bf [Heat]} port for two parts of the
cycle.

To avoid this causlity change, the Carnot cycle is approximated by
applying the heat from a temperature source via a thermal resistance
{\bf RT} component. During the {\em heat injection\/} and {\em heat
extraction\/} parts of the cycle, the resistance parameter $r\approx
0$, but during the {\em isentropic compression\/} and {\em isentropic
expansion\/} parts of the cycle, the resistance parameter $r\approx
\inf$.

The simulation parameters appear in Section
\Ref{sec:CarnotCycle_numpar.txt}. The results are plotted against time
as follows:
\begin{itemize}
\item Volume (Figure \Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-V})
\item Pressure (Figure
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-P})
\item Entropy (Figure \Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-S})
\item Temperature (Figure
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-T})
\end{itemize}

These values are replotted as the standard PV and TS diagrams in
Figures
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-V:CarnotCycle-cycle-P}
and
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-S:CarnotCycle-cycle-T}
respectively.

The PV diagram shows the long and thin form typical of the Carnot
cycle -- this implies a poor work ratio. The TS diagram is not
informative; it is not the expected rectangle because both T and S
change in a stepwise manner.




Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_input.txt version [3f74ca255c].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Input file (CarnotCycle_input.txt)
# Generated by MTT at Mon Dec  8 20:05:30 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:14:40  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


alpha = 0.553;

# Set the inputs
if ((t>=0.0)&&(t<1.0))		#Cooling
  carnotcycle__heat__u= 300.0;	# Source temperature
  carnotcycle__switch__u    = 1e10; # Large conductance - isothermal
  carnotcycle__work__u = -alpha;	# Volume rate-of-change
endif;

if ((t>=1.0)&&(t<2.0))		#Compression
  carnotcycle__heat__u = 300.0;	# Source temperature 
  carnotcycle__switch__u    = 0; # Small conductance -- isentropic
  carnotcycle__work__u = -(0.8-alpha); # Volume rate-of-change
endif;

if ((t>=2.0)&&(t<3.0))		#Heating
  TopTemp = x(1)/(m_g*c_v);
  carnotcycle__heat__u = TopTemp;	# Source temperature
  carnotcycle__switch__u    = 1e10; # Large conductance - isothermal
  carnotcycle__work__u = (0.8-alpha); # Volume rate-of-change
endif;

if (t>=3.0)			#Cooling
  carnotcycle__heat__u = 300.0;	# Source temperature
  carnotcycle__switch__u    = 0; # Small conductance -- isentropic
  carnotcycle__work__u = alpha;	# Volume rate-of-change
endif;

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_lbl.txt version [530e8f67dd].

























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY CarnotCycle: a simple closed thermodynamic cycle
#DESCRIPTION The Carnot cycle is a simple closed thermodynamic cycle
#DESCRIPTION with four parts:
#DESCRIPTION o Isentropic compression
#DESCRIPTION o Heat injection at constant temperature
#DESCRIPTION o Isentropic expansion
#DESCRIPTION o Heat extraction at constant temperature

#PAR P_0
#PAR T_0
#PAR V_0
#PAR alpha
#PAR TopTemp


#NOTPAR ideal_gas

## Label file for system CarnotCycle (CarnotCycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.3  2003/08/13 17:03:00  gawthrop
# ## Updated for new MTT
# ## Use FMR in place of R
# ## Fixed bug in sspar
# ##
# ## Revision 1.2  1998/08/10 16:40:07  peterg
# ## Added VARs and parametrs
# ##
# ## Revision 1.1  1998/07/21 15:18:18  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g

# Component type RT
	r		lin	flow,1

# Component type Se
	Heat	SS	external

# Component type Sf
	Work    SS	external
	switch  SS	external

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_numpar.txt version [229858da3a].



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (CarnotCycle_numpar.txt)
# Generated by MTT at Mon Dec  8 20:02:31 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.3  2003/08/13 17:03:10  gawthrop
# %% Updated for new MTT
# %% Use FMR in place of R
# %% Fixed bug in sspar
# %%
# %% Revision 1.2  2000/12/28 18:14:40  peterg
# %% To RCS
# %%
# %% Revision 1.1  1998/03/04 11:49:01  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0;			# Parameter c_v for CU
gamma_g = 1.4;			# Parameter gamma for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

## Use in input.txt
alpha	= 1.0; # Added by MTT on Thu Aug 14 11:42:15 BST 2003
toptemp	= 1.0; # Added by MTT on Thu Aug 14 11:42:15 BST 2003

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_params.r version [20ff45d443].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
%% Parameter file for system CarnotCycle (CarnotCycle_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_rep.txt version [84cd324287].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system CarnotCycle (CarnotCycle_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:14:40  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:15:05  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -ss -o CarnotCycle abg tex
mtt -ss -o CarnotCycle struc tex
mtt -ss -o CarnotCycle ode tex
mtt -ss -o CarnotCycle ss tex

mtt -ss -o CarnotCycle numpar txt
mtt -ss -o CarnotCycle input txt

mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__V'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__P'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__S'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__T'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__V:CarnotCycle__cycle__P'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__S:CarnotCycle__cycle__T'

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_simp.r version [8c64ed9a32].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce comands to simplify output for system CarnotCycle (CarnotCycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_simpar.txt version [4178b56134].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system OttoCycle (OttoCycle_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=4.0
DT=0.01
STEPFACTOR=10

Added mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_sspar.r version [5c712e6db1].

















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (CarnotCycle_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  2000/12/28 18:14:40  peterg
% % To RCS
% %
% % Revision 1.1  1998/03/04 11:49:14  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Set a pressure of 1 bar
%P_0 := 10^5;

% Unit initial volume
%V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
%T_0 := 300;

% Deduce the mass of gas
m_g :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % CarnotCycle_cycle_gas (c)
MTTX2 := 	V_0;         % CarnotCycle_cycle_gas (c)
MTTX3 := 	S_0;         % CarnotCycle_cycle_volume (3)
MTTX4 := 	V_0;         % CarnotCycle_cycle_entropy (3)

% Steady-state inputs
MTTU1 := 	T_0; % CarnotCycle (Heat)
MTTU2 := 	0; % CarnotCycle (Work)
MTTU3 := 	0; % Switch (conduction)
;;END;

Added mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_abg.fig version [8f0ef21ff3].




























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
4 1 -1 0 0 0 20 0.0000 4 285 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000 4 210 1050 6886 3241 Sf:Work\001
4 2 -1 0 0 0 20 0.0000 4 210 945 1936 3241 Sf:Heat\001
4 1 1 1 0 3 20 0.0000 4 210 735 2655 3465 dS/dT\001
4 1 1 1 0 3 20 0.0000 4 195 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000 4 195 180 6120 2925 P\001
4 1 1 1 0 3 20 0.0000 4 210 765 5985 3465 dV/dT\001
4 1 1 1 0 3 30 0.0000 4 405 1815 4365 4770 Otto cycle\001

Added mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_desc.tex version [0e04e9a7ae].


































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system OttoCycle (OttoCycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{OttoCycle} is
   displayed in Figure \Ref{OttoCycle_abg} and its label
   file is listed in Section \Ref{sec:OttoCycle_lbl}.
   The subsystems are listed in Section \Ref{sec:OttoCycle_sub}.


The Otto cycle is a simple closed thermodynamic cycle with four parts:
\begin{enumerate}
\item Isentropic compression
\item Heating at constant volume
\item Isentropic expansion
\item Cooling at constant volume
\end{enumerate}

The subsystem \textbf{Cycle} (Section \Ref{sec:Cycle}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

In Bond Graph terms, each of the four parts of the Otto cycle
correspond to integral causality as in each case a \emph{flow} is
constrained. This is in contrast to other cycles listed in Table
\Ref{tab:cycles} where each table entry gives the causality on the
heat and work ports respectively. This is possibly why the Otto cycle
is conceptually and practically simple.

The simulation parameters appear in Section
\Ref{sec:OttoCycle_numpar.txt}. The results are plotted against time
as follows:
\begin{itemize}
\item Volume (Figure \Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-V})
\item Pressure (Figure
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-P})
\item Entropy (Figure \Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-S})
\item Temperature (Figure
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-T})
\end{itemize}

These values are replotted as the standard PV and TS diagrams in
Figures
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-V:OttoCycle-cycle-P}
and
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-S:OttoCycle-cycle-T}
respectively.





Added mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_input.txt version [a1dff1c564].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (OttoCycle_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.3  2000/12/28 18:42:16  peterg
# %% New input definition.
# %% NB Needs to handle mutiports properly and state.txt modified accordingly
# %%
# %% Revision 1.2  2000/12/28 18:15:52  peterg
# %% To RCS
# %%
# %% Revision 1.1  1998/08/10 14:42:13  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs

if ((t>=0.0)&&(t<1.0))		#Compression
  OttoCycle__Heat__u = 0.0;	# Entropy flow
  OttoCycle__Work__u = -0.8;	# Volume rate-of-change
endif;

if ((t>=1.0)&&(t<2.0))		#Heating
  OttoCycle__Heat__u = 1000;	# Entropy flow
  OttoCycle__Work__u = 0.0;	# Volume rate-of-change
endif;

if ((t>=2.0)&&(t<3.0))		#Expansion
  OttoCycle__Heat__u = 0.0;	# Entropy flow
  OttoCycle__Work__u = 0.8;	# Volume rate-of-change
endif;

if (t>=3.0)			#Cooling
  OttoCycle__Heat__u = -1000;	# Entropy flow
  OttoCycle__Work__u = 0.0;	# Volume rate-of-change
endif;




Added mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_lbl.txt version [241819f0d8].


















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY OttoCycle: a simple closed thermodynamic cycle
#DESCRIPTION The Otto cycle is a simple closed thermodynamic cycle
#DESCRIPTION with four parts:
#DESCRIPTION o Isentropic compression
#DESCRIPTION o Heating at constant volume
#DESCRIPTION o Isentropic expansion
#DESCRIPTION o Cooling at constant volume
  
#PAR P_0
#PAR T_0
#PAR V_0
#NOTPAR ideal_gas


## Label file for system OttoCycle (OttoCycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.4  2000/12/28 18:42:17  peterg
# ## New input definition.
# ## NB Needs to handle mutiports properly and state.txt modified accordingly
# ##
# ## Revision 1.3  1998/08/10 16:05:52  peterg
# ## Added VARs and parameters
# ##
# ## Revision 1.2  1998/07/21 15:15:27  peterg
# ## Documentation + new format
# ##
# ## Revision 1.1  1998/07/21 15:12:21  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type Sf
	Heat	SS	external
	Work	SS	external

Added mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_numpar.txt version [b464fa9930].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (OttoCycle_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an appropriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;			

# Parameters
c_v = 	718.0;			# Parameter c_v for CU
gamma_g = 1.4;			# Parameter gamma for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v);# Parameter m for CU

Added mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_rep.txt version [c1e59d4735].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system OttoCycle (OttoCycle_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:15:52  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:16:17  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss OttoCycle abg tex
mtt -o -ss OttoCycle struc tex
mtt -o -ss OttoCycle ode tex
mtt -o -ss OttoCycle ss tex

mtt -o -ss OttoCycle numpar txt
mtt -o -ss OttoCycle input txt

mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__V'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__P'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__S'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__T'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__V:OttoCycle__cycle__P'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__S:OttoCycle__cycle__T'




Added mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_sspar.r version [28a921ee9f].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (OttoCycle_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 18:15:52  peterg
% % To RCS
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
%%P_0 := 10^5;

% Unit initial volume
%%V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
%%T_0 := 300;

% Deduce the mass of gas
m_g :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % OttoCycle_cycle_gas (c)
MTTX2 := 	V_0;         % OttoCycle_cycle_gas (c)
MTTX3 := 	S_0;         % OttoCycle_cycle_entropy (3)
MTTX4 := 	V_0;         % OttoCycle_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % OttoCycle (Heat)
MTTU2 := 	0; % OttoCycle (Work)
;;END;

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_abg.fig version [5d72c6d9ef].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 3360 4365 4770 Isentropic process\001
4 1 1 1 0 3 20 0.0000000 4 210 480 2700 3555 S=0\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2565 3330 .\001
4 1 1 1 0 3 20 0.0000000 4 210 195 6120 3555 V\001
4 1 1 1 0 3 30 0.0000000 4 60 105 6165 3285 .\001

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_desc.tex version [ff2532462b].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Isentropic (Isentropic_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_input.txt version [3384727177].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isentropic_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:16:47  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 10:14:17 BST 2003:   u(1) = -0.8;     # Volume rate-of-change
isentropic__work	= -0.8;     # Volume rate-of-change

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_lbl.txt version [fe7dd91d36].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Isentropic: Isentropic thermodynamic process - ideal gas
#DESCRIPTION A dynamic simulation of an isentropic process using
#DESCRIPTION the Cycle component and the two-prt CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas



## Label file for system Isentropic (Isentropic_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:16:47  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:27:44  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat	SS	internal,0
	Work	SS	internal,external

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_numpar.txt version [561c815b07].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isentropic_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_rep.txt version [330cdb1720].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Isentropic (Isentropic_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:16:47  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:18:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss Isentropic abg tex
mtt -o -ss Isentropic struc tex
mtt -o -ss Isentropic ode tex
mtt -o -ss Isentropic ss tex

mtt -o -ss Isentropic numpar txt
mtt -o -ss Isentropic input txt

mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__V'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__P'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__S'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__T'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__V:Isentropic__cycle__P'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__S:Isentropic__cycle__T'

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_simpar.txt version [ac622df4b8].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isentropic (Isentropic_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_simpar.txt_old version [ac622df4b8].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isentropic (Isentropic_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_sspar.r version [b36b93a55f].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (Isentropic_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % Isentropic_cycle_gas (c)
MTTX2 := 	V_0;         % Isentropic_cycle_gas (c)
MTTX3 := 	S_0;         % Isentropic_cycle_entropy (3)
MTTX4 := 	V_0;         % Isentropic_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isentropic (Heat)
MTTU2 := 	0; % Isentropic (Work)
;;END;

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_abg.fig version [21bfb6f246].


























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1800 6750 1800 6525 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2025 5175 3375 5400 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 5175 5400 4950
2 2 0 3 1 7 1 0 -1 0.000 1 0 -1 0 0 5
	 6075 900 9000 900 9000 2700 6075 2700 6075 900
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8325 900 8550 900 8550 2700 8325 2700 8325 900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3825 10125 5175 10350 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 1800 9900 1800 9675 2025
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8550 1665 9585 1665 9585 1935 8550 1935 8550 1665
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 4725 1440 5805 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 9675 1440 10755 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 7785 3465 8415 2835
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 1800 4950 1800 4725 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1755 1800 3105 1800 2880 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 2025 3375 5175 3600 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 5175 3600 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10350 1800 11700 1800 11475 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 1800 13500 1800 13275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11700 5175 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11925 2025 11925 5175 12150 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 2025 10125 3375 10350 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2025 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 10350 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 5175 10350 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 5400 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 1575 7875 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 1575 1755 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12150 1575 12150 2025
4 1 -1 0 0 0 20 0.0000 4 255 915 7290 1890 CU:gas\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5175 1890 1\001
4 1 -1 0 0 0 20 0.0000 4 270 1695 5175 3690 INTF:entropy\001
4 1 -1 0 0 0 20 0.0000 4 195 150 10125 1890 1\001
4 1 1 1 0 3 20 0.0000 4 270 1140 7200 1440 Ideal gas\001
4 1 1 1 0 3 20 0.0000 4 195 945 4635 1305 Heat in\001
4 1 1 1 0 3 20 0.0000 4 210 1170 10170 1305 Work out\001
4 1 1 1 0 3 20 0.0000 4 270 1980 5130 5895 Entropy change\001
4 1 1 1 0 3 20 0.0000 4 270 1485 7110 3690 Ideal piston\001
4 1 -1 0 0 0 20 0.0000 4 210 1680 10125 3690 INTF:volume\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3375 1890 0\001
4 2 4 0 0 0 20 0.0000 4 255 1215 1575 1890 SS:[Heat]\001
4 1 -1 0 0 0 20 0.0000 4 210 600 3375 5490 SS:T\001
4 1 1 1 0 3 20 0.0000 4 255 1620 3240 5895 Temperature\001
4 1 -1 0 0 0 20 0.0000 4 210 585 5130 5490 SS:S\001
4 1 -1 0 0 0 20 0.0000 4 210 645 10125 5490 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 210 585 11880 5490 SS:P\001
4 0 4 0 0 0 20 0.0000 4 255 1320 13680 1890 SS:[Work]\001
4 1 1 1 0 3 20 0.0000 4 270 1950 10080 5850 Volume change\001
4 1 1 1 0 3 20 0.0000 4 195 1095 11925 5850 Pressure\001
4 1 -1 0 0 0 20 0.0000 4 195 150 11925 1890 0\001

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_desc.tex version [9decb9a7b6].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Cycle (Cycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/06/30 12:46:49  peterg
% %% Changed CT2 to CU
% %%
% %% Revision 1.1  1998/06/30 12:46:24  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cycle} is
   displayed in Figure \Ref{Cycle_abg} and its label
   file is listed in Section \Ref{sec:Cycle_lbl}.
   The subsystems are listed in Section \Ref{sec:Cycle_sub}.

The system has two heat engine ports: 
\begin{enumerate}
\item \textbf{[Heat]} and
\item \textbf{[Work]}
\end{enumerate}
By convention, energy flows in to the \textbf{[Heat]} port and out of
the \textbf{[Work]} port. Both ports are true energy ports.


The subsystem \textbf{CU} (Section \Ref{sec:CU}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

Four \textbf{SS} components are set up as sensors to measure the
important quantities pertaining to the cycle:
\begin{enumerate}
\item \textbf{S} to measure the integrated entropy flow
\item \textbf{T} to measure the (absolute) temperature
\item \textbf{V} to measure the integrated volume change
\item \textbf{P} to measure the pressure
\end{enumerate}

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|l|l|l|}
         \hline
         Cycle & Compression & Heating & Expansion & Cooling \\
         \hline
         Otto & II & II & II & II \\
         Carnot & II & DI & II & DI \\
         Diesel & II & ID & II & II \\
         Joule & II & ID & II & ID \\
         \hline
       \end{tabular}
       \caption{Cycles and their causality}
       \label{tab:cycles}
     \end{center}
   \end{table}
   
   A number of cycles can be built depending on the causality of the
   two ports \textbf{[Heat]} and \textbf{[Work]} of \textbf{Cycle}
   Some possible cycles listed in Tables \Ref{tab:cycles} where each
   table entry gives the causality on the heat and work ports
   respectively.

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_lbl.txt version [d82e73d04d].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Cycle: Closed cycle with ideal gas
#DESCRIPTION Uses the CU two-port thermal capacitor.

#ALIAS in	Heat
#ALIAS out	Work

#ALIAS $1	ideal_gas
#ALIAS $2	c_v
#ALIAS $3	gamma_g
#ALIAS $4	m_g

## Label file for system Cycle (Cycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1998/07/21 14:21:04  peterg
# ## New style file
# ##
# ## Revision 1.1  1997/12/08 20:24:43  peterg
# ## Initial revision
# ##
# ## Revision 1.1  1997/12/07 20:38:05  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank




# Component type CU
	gas	CU	ideal_gas,c_v,gamma_g,m_g

# Component type INTF
	entropy
	volume

# Component type SS
	S	SS	external,0
	T	SS	external,0
	V	SS	external,0
	P	SS	external,0
	[Heat]	SS	external,external
	[Work]	SS	external,external



Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_simp.r version [b8f003f5e9].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce commands to simplify output for system Cycle (Cycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_abg.fig version [476d13332f].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5175 2925 5175 3375
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 3015 4365 4770 Isobaric process\001
4 1 1 1 0 3 20 0.0000000 4 210 480 2700 3555 S=0\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2565 3330 .\001
4 1 1 1 0 3 20 0.0000000 4 210 195 6120 3555 V\001
4 1 1 1 0 3 30 0.0000000 4 60 105 6165 3285 .\001

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_desc.tex version [b3e2d1ccc2].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Isobaric (Isobaric_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_input.txt version [bfb9bb0e91].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isobaric_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:17:13  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 11:41:46 BST 2003:   u(1) = 1000;     #Entropy flow 
isobaric__heat	= 1000;     #Entropy flow 

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_lbl.txt version [eac4d49411].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Isobaric: Isobaric thermodynamic process - ideal gas 
#DESCRIPTION A dynamic simulation of an isobaric (constant pressure)
#DESCRIPTION  process using the Cycle component and the two-port CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas 

## Label file for system Isobaric (Isobaric_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:17:13  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:32:49  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat	SS	internal,external
	Work	SS	P_0,internal

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_numpar.txt version [fbce8cfc6e].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isobaric_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma_g for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_rep.txt version [3ca4977ae4].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Isobaric (Isobaric_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:17:13  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:19:31  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt  -ss Isobaric abg tex
mtt  -ss Isobaric struc tex
mtt  -ss Isobaric ode tex
mtt  -ss Isobaric ss tex

mtt  -ss Isobaric numpar txt
mtt  -ss Isobaric input txt

mtt  -ss Isobaric odeso ps 'Isobaric__cycle__V'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__P'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__S'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__T'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__V:Isobaric__cycle__P'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__S:Isobaric__cycle__T'




Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_simpar.txt version [545a74e285].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isobaric (Isobaric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_simpar.txt_old version [545a74e285].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isobaric (Isobaric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_sspar.r version [c0e371332c].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (Isobaric_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % Isobaric_cycle_gas (c)
%MTTX2 := 	V_0;         % Isobaric_cycle_gas (c)
MTTX2 := 	S_0;         % Isobaric_cycle_entropy (3)
MTTX3 := 	V_0;         % Isobaric_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isobaric (Heat)
;;END;

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_abg.fig version [8fdef28898].


















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1800 6750 1800 6525 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2025 5175 3375 5400 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 5175 5400 4950
2 2 0 3 1 7 1 0 -1 0.000 1 0 -1 0 0 5
	 6075 900 9000 900 9000 2700 6075 2700 6075 900
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8325 900 8550 900 8550 2700 8325 2700 8325 900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3825 10125 5175 10350 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 1800 9900 1800 9675 2025
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8550 1665 9585 1665 9585 1935 8550 1935 8550 1665
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 4725 1440 5805 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 9675 1440 10755 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 7785 3465 8415 2835
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 1800 4950 1800 4725 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1755 1800 3105 1800 2880 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 2025 3375 5175 3600 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 5175 3600 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10350 1800 11700 1800 11475 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 1800 13500 1800 13275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11700 5175 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11925 2025 11925 5175 12150 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 2025 10125 3375 10350 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2025 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 10350 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 5175 10350 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 5400 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6750 2025 6750 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 9900 1575
4 1 -1 0 0 0 20 0.0000 4 255 855 7290 1890 CU:gas\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 1890 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1590 5175 3690 INTF:entropy\001
4 1 -1 0 0 0 20 0.0000 4 195 135 10125 1890 1\001
4 1 1 1 0 3 20 0.0000 4 270 1035 7200 1440 Ideal gas\001
4 1 1 1 0 3 20 0.0000 4 210 885 4635 1305 Heat in\001
4 1 1 1 0 3 20 0.0000 4 210 1080 10170 1305 Work out\001
4 1 1 1 0 3 20 0.0000 4 270 1800 5130 5895 Entropy change\001
4 1 1 1 0 3 20 0.0000 4 270 1365 7110 3690 Ideal piston\001
4 1 -1 0 0 0 20 0.0000 4 195 1560 10125 3690 INTF:volume\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 1890 0\001
4 2 4 0 0 0 20 0.0000 4 240 1140 1575 1890 SS:[Heat]\001
4 1 -1 0 0 0 20 0.0000 4 195 585 3375 5490 SS:T\001
4 1 1 1 0 3 20 0.0000 4 255 1485 3240 5895 Temperature\001
4 1 -1 0 0 0 20 0.0000 4 195 570 5130 5490 SS:S\001
4 1 -1 0 0 0 20 0.0000 4 195 615 10125 5490 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 195 570 11880 5490 SS:P\001
4 0 4 0 0 0 20 0.0000 4 240 1230 13680 1890 SS:[Work]\001
4 1 1 1 0 3 20 0.0000 4 270 1815 10080 5850 Volume change\001
4 1 1 1 0 3 20 0.0000 4 195 975 11925 5850 Pressure\001
4 1 -1 0 0 0 20 0.0000 4 195 135 11925 1890 0\001

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_desc.tex version [9decb9a7b6].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Cycle (Cycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/06/30 12:46:49  peterg
% %% Changed CT2 to CU
% %%
% %% Revision 1.1  1998/06/30 12:46:24  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cycle} is
   displayed in Figure \Ref{Cycle_abg} and its label
   file is listed in Section \Ref{sec:Cycle_lbl}.
   The subsystems are listed in Section \Ref{sec:Cycle_sub}.

The system has two heat engine ports: 
\begin{enumerate}
\item \textbf{[Heat]} and
\item \textbf{[Work]}
\end{enumerate}
By convention, energy flows in to the \textbf{[Heat]} port and out of
the \textbf{[Work]} port. Both ports are true energy ports.


The subsystem \textbf{CU} (Section \Ref{sec:CU}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

Four \textbf{SS} components are set up as sensors to measure the
important quantities pertaining to the cycle:
\begin{enumerate}
\item \textbf{S} to measure the integrated entropy flow
\item \textbf{T} to measure the (absolute) temperature
\item \textbf{V} to measure the integrated volume change
\item \textbf{P} to measure the pressure
\end{enumerate}

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|l|l|l|}
         \hline
         Cycle & Compression & Heating & Expansion & Cooling \\
         \hline
         Otto & II & II & II & II \\
         Carnot & II & DI & II & DI \\
         Diesel & II & ID & II & II \\
         Joule & II & ID & II & ID \\
         \hline
       \end{tabular}
       \caption{Cycles and their causality}
       \label{tab:cycles}
     \end{center}
   \end{table}
   
   A number of cycles can be built depending on the causality of the
   two ports \textbf{[Heat]} and \textbf{[Work]} of \textbf{Cycle}
   Some possible cycles listed in Tables \Ref{tab:cycles} where each
   table entry gives the causality on the heat and work ports
   respectively.

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_lbl.txt version [d82e73d04d].























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Cycle: Closed cycle with ideal gas
#DESCRIPTION Uses the CU two-port thermal capacitor.

#ALIAS in	Heat
#ALIAS out	Work

#ALIAS $1	ideal_gas
#ALIAS $2	c_v
#ALIAS $3	gamma_g
#ALIAS $4	m_g

## Label file for system Cycle (Cycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1998/07/21 14:21:04  peterg
# ## New style file
# ##
# ## Revision 1.1  1997/12/08 20:24:43  peterg
# ## Initial revision
# ##
# ## Revision 1.1  1997/12/07 20:38:05  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank




# Component type CU
	gas	CU	ideal_gas,c_v,gamma_g,m_g

# Component type INTF
	entropy
	volume

# Component type SS
	S	SS	external,0
	T	SS	external,0
	V	SS	external,0
	P	SS	external,0
	[Heat]	SS	external,external
	[Work]	SS	external,external



Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_simp.r version [b8f003f5e9].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
%% Reduce commands to simplify output for system Cycle (Cycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_abg.fig version [a9b0aef23c].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2925 3600 3375
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 3510 4365 4770 Isothermal process\001
4 1 1 1 0 3 20 0.0000000 4 210 195 6120 3555 V\001
4 1 1 1 0 3 30 0.0000000 4 60 105 6165 3285 .\001
4 1 1 1 0 3 20 0.0000000 4 210 165 2700 3555 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2700 3285 .\001
4 1 1 1 0 3 20 0.0000000 4 210 1005 2700 2925 T=const\001

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_desc.tex version [ccb4c49b18].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Isothermal (Isothermal_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_input.txt version [65539a7718].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isothermal_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:17:37  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 10:47:34 BST 2003:   u(1) = -0.8;     # Volume rate-of-change
isothermal__work	= -0.8;     # Volume rate-of-change

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_lbl.txt version [ca0038f1d8].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Isothermal: Isothermal thermodynamic process - ideal gas
#DESCRIPTION A dynamic simulation of an isothermal process using
#DESCRIPTION the Cycle component and the two-port CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas 

## Label file for system Isothermal (Isothermal_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:17:37  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:30:29  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat		SS	T_0,internal
	Work		SS	internal,external

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_numpar.txt version [7bdc15640d].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isothermal_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma_g for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_rep.txt version [2eeec12cdd].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Isothermal (Isothermal_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:17:37  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -ss Isothermal abg tex
mtt -ss Isothermal struc tex
mtt -ss Isothermal ode tex
mtt -ss Isothermal ss tex

mtt -ss Isothermal numpar txt
mtt -ss Isothermal input txt

mtt -ss Isothermal odeso ps 'Isothermal__cycle__V'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__P'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__S'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__T'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__V:Isothermal__cycle__P'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__S:Isothermal__cycle__T'




Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_simpar.txt version [ba2a940038].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isothermal (Isothermal_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_simpar.txt_old version [ba2a940038].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isothermal (Isothermal_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_sspar.r version [14b711f7a3].






































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (Isothermal_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	V_0;         % Isothermal_cycle_gas (c)
MTTX2 := 	S_0;         % Isothermal_cycle_entropy (3)
MTTX3 := 	V_0;         % Isothermal_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isothermal (Work)
;;END;

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_abg.fig version [4deb859011].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 4020 4365 4770 Isovolumetric process\001
4 1 1 1 0 3 20 0.0000000 4 210 510 6120 3555 V=0\001
4 1 1 1 0 3 30 0.0000000 4 60 105 5940 3285 .\001
4 1 1 1 0 3 20 0.0000000 4 210 165 2700 3555 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2700 3285 .\001

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_desc.tex version [6670b4774d].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Verbal description for system Isovolumetric (Isovolumetric_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_input.txt version [b9136199c8].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isovolumetric_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:17:57  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 11:04:07 BST 2003:   u(1) = 1000;     #Entropy flow 
isovolumetric__heat	 = 1000;     #Entropy flow 

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_lbl.txt version [d8583137d5].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#SUMMARY Isovolumetric: Isovolumetric thermodynamic process - ideal gas 
#DESCRIPTION A dynamic simulation of an Isovolumetric (constant volume)
#DESCRIPTION  process using the Cycle component and the two-port CU component.
#DESCRIPTION 
#DESCRIPTION the Cycle component and the two-port CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas 

## Label file for system Isovolumetric (Isovolumetric_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:17:57  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:37:03  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat	SS	internal,external
	Work	SS	internal,0

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_numpar.txt version [df377cc85f].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Numerical parameter file (Isovolumetric_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma_g for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_rep.txt version [6651c44452].


































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Outline report file for system Isovolumetric (Isovolumetric_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:17:57  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:21:03  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss Isovolumetric abg tex
mtt -o -ss Isovolumetric struc tex
mtt -o -ss Isovolumetric ode tex
mtt -o -ss Isovolumetric ss tex

mtt -o -ss Isovolumetric numpar txt
mtt -o -ss Isovolumetric input txt

mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__V'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__P'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__S'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__T'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__V:Isovolumetric__cycle__P'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__S:Isovolumetric__cycle__T'




Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_simpar.txt version [669617cdc7].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isovolumetric (Isovolumetric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_simpar.txt_old version [669617cdc7].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
%% Simulation parameters for system Isovolumetric (Isovolumetric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Added mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_sspar.r version [cfb7ef7827].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
% Steady-state parameter file (Isovolumetric_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % Isovolumetric_cycle_gas (c)
MTTX2 := 	V_0;         % Isovolumetric_cycle_gas (c)
MTTX3 := 	S_0;         % Isovolumetric_cycle_entropy (3)
MTTX4 := 	V_0;         % Isovolumetric_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isovolumetric (Heat)
MTTU2 := 	0; % Isovolumetric (Work)
;;END;

Added mtt/lib/examples/debian/README.Debian version [dac8a18a37].







1
2
3
4
5
6
+
+
+
+
+
+
mtt-examples for Debian
-----------------------

Library of examples for MTT (Model Transformation Tools).

 -- Geraint Paul Bevan <geraint@users.sourceforge.net>, Wed, 18 Feb 2004 22:47:08 +0000

Added mtt/lib/examples/debian/changelog version [43ade6029e].







1
2
3
4
5
6
+
+
+
+
+
+
mtt-examples (5.0-1) unstable; urgency=low

  * Initial Release.

 -- Geraint Paul Bevan <geraint@users.sourceforge.net>  Wed, 18 Feb 2004 22:47:08 +0000

Added mtt/lib/examples/debian/compat version [0c3ec9639d].


1
+
4

Added mtt/lib/examples/debian/conffiles.ex version [d832dbb182].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
#
# If you want to use this conffile, remove all comments and put files that
# you want dpkg to process here using their absolute pathnames.
# See the policy manual
#
# for example:
# /etc/mtt-examples/mtt-examples.conf

Added mtt/lib/examples/debian/control version [59260d425c].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Source: mtt-examples
Section: contrib/math
Priority: optional
Maintainer: Geraint Paul Bevan <geraint@users.sourceforge.net>
Build-Depends: debhelper (>= 4.0.0)
Standards-Version: 3.6.0

Package: mtt-examples
Architecture: all
Depends: mtt
Description: Library of examples for Model Transformation Tools
 A library of examples containing models of systems which span a range of physical domains (including chemical, electrical, hydraulic, mechanical and thermal) and which demonstrate several uses of bond graph modelling with MTT, such as analysis, control and simulation.
 .
 The MTT homepage is located at http://mtt.sourceforge.net. An on-line manual is available at http://mtt.sourceforge.net/doc.
 .

Added mtt/lib/examples/debian/copyright version [1acaedb686].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This package was debianized by Geraint Paul Bevan <geraint@users.sourceforge.net> on
Wed, 18 Feb 2004 22:47:08 +0000.

It was downloaded from http://sourceforge.net/projects/mtt

Upstream Author(s): Peter Gawthrop <mtt@gawthrop.net>

Copyright:

mtt-examples is copyright (c) 1989-2004 by Peter J. Gawthrop.

You are free to distribute this software under the terms of the
GNU General Public License (GPL).

On Debian systems, the complete text of the GNU General Public License
can be found in /usr/share/common-licenses/GPL.

Added mtt/lib/examples/debian/cron.d.ex version [2c98fb387d].





1
2
3
4
+
+
+
+
#
# Regular cron jobs for the mtt-examples package
#
0 4	* * *	root	mtt-examples_maintenance

Added mtt/lib/examples/debian/dirs version [b541042ac0].



1
2
+
+
usr/bin

Added mtt/lib/examples/debian/docs version [a7ffc6f8bf].

Added mtt/lib/examples/debian/emacsen-install.ex version [f82ffb9b9c].














































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh -e
# /usr/lib/emacsen-common/packages/install/mtt-examples

# Written by Jim Van Zandt <jrv@vanzandt.mv.com>, borrowing heavily
# from the install scripts for gettext by Santiago Vila
# <sanvila@ctv.es> and octave by Dirk Eddelbuettel <edd@debian.org>.

FLAVOR=$1
PACKAGE=mtt-examples

if [ ${FLAVOR} = emacs ]; then exit 0; fi

echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}

#FLAVORTEST=`echo $FLAVOR | cut -c-6`
#if [ ${FLAVORTEST} = xemacs ] ; then
#    SITEFLAG="-no-site-file"
#else
#    SITEFLAG="--no-site-file"
#fi
FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}

# Install-info-altdir does not actually exist. 
# Maybe somebody will write it.
if test -x /usr/sbin/install-info-altdir; then
    echo install/${PACKAGE}: install Info links for ${FLAVOR}
    install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/info/${PACKAGE}.info.gz
fi

install -m 755 -d ${ELCDIR}
cd ${ELDIR}
FILES=`echo *.el`
cp ${FILES} ${ELCDIR}
cd ${ELCDIR}

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF
${FLAVOR} ${FLAGS} ${FILES}
rm -f *.el path.el

exit 0

Added mtt/lib/examples/debian/emacsen-remove.ex version [336be314aa].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh -e
# /usr/lib/emacsen-common/packages/remove/mtt-examples

FLAVOR=$1
PACKAGE=mtt-examples

if [ ${FLAVOR} != emacs ]; then
    if test -x /usr/sbin/install-info-altdir; then
        echo remove/${PACKAGE}: removing Info links for ${FLAVOR}
        install-info-altdir --quiet --remove --dirname=${FLAVOR} /usr/info/mtt-examples.info.gz
    fi

    echo remove/${PACKAGE}: purging byte-compiled files for ${FLAVOR}
    rm -rf /usr/share/${FLAVOR}/site-lisp/${PACKAGE}
fi

Added mtt/lib/examples/debian/emacsen-startup.ex version [0d279cfd52].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
;; -*-emacs-lisp-*-
;;
;; Emacs startup file for the Debian mtt-examples package
;;
;; Originally contributed by Nils Naumann <naumann@unileoben.ac.at>
;; Modified by Dirk Eddelbuettel <edd@debian.org>
;; Adapted for dh-make by Jim Van Zandt <jrv@vanzandt.mv.com>

;; The mtt-examples package follows the Debian/GNU Linux 'emacsen' policy and
;; byte-compiles its elisp files for each 'emacs flavor' (emacs19,
;; xemacs19, emacs20, xemacs20...).  The compiled code is then
;; installed in a subdirectory of the respective site-lisp directory.
;; We have to add this to the load-path:
(let ((package-dir (concat "/usr/share/"
                           (symbol-name flavor)
                           "/site-lisp/mtt-examples")))
  (when (file-directory-p package-dir)
        (setq load-path (cons package-dir load-path))))

Added mtt/lib/examples/debian/init.d.ex version [958a43e196].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian 
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mtt-examples
NAME=mtt-examples
DESC=mtt-examples

test -x $DAEMON || exit 0

# Include mtt-examples defaults if available
if [ -f /etc/default/mtt-examples ] ; then
	. /etc/default/mtt-examples
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo "$NAME."
	;;
  #reload)
	#
	#	If the daemon can reload its config files on the fly
	#	for example by sending it SIGHUP, do it here.
	#
	#	If the daemon responds to changes in its config file
	#	directly anyway, make this a do-nothing entry.
	#
	# echo "Reloading $DESC configuration files."
	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
	#	/var/run/$NAME.pid --exec $DAEMON
  #;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0

Added mtt/lib/examples/debian/manpage.1.ex version [2f4204b36f].





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MTT-EXAMPLES SECTION "February 18, 2004"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mtt-examples \- program to do something
.SH SYNOPSIS
.B mtt-examples
.RI [ options ] " files" ...
.br
.B bar
.RI [ options ] " files" ...
.SH DESCRIPTION
This manual page documents briefly the
.B mtt-examples
and
.B bar
commands.
This manual page was written for the Debian distribution
because the original program does not have a manual page.
Instead, it has documentation in the GNU Info format; see below.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
.\" respectively.
\fBmtt-examples\fP is a program that...
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH SEE ALSO
.BR bar (1),
.BR baz (1).
.br
The programs are documented fully by
.IR "The Rise and Fall of a Fooish Bar" ,
available via the Info system.
.SH AUTHOR
This manual page was written by Geraint Paul Bevan <geraint@users.sourceforge.net>,
for the Debian project (but may be used by others).

Added mtt/lib/examples/debian/manpage.sgml.ex version [97d6404147].





























































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Process this file with docbook-to-man to generate an nroff manual
     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
     less'.  A typical entry in a Makefile or Makefile.am is:

manpage.1: manpage.sgml
	docbook-to-man $< > $@

    
	The docbook-to-man binary is found in the docbook-to-man package.
	Please remember that if you create the nroff version in one of the
	debian/rules file targets (such as build), you will need to include
	docbook-to-man in your Build-Depends control field.

  -->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
  <!ENTITY dhsurname   "<surname>SURNAME</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>February 18, 2004</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>SECTION</manvolnum>">
  <!ENTITY dhemail     "<email>geraint@users.sourceforge.net</email>">
  <!ENTITY dhusername  "Geraint Paul Bevan">
  <!ENTITY dhucpackage "<refentrytitle>MTT-EXAMPLES</refentrytitle>">
  <!ENTITY dhpackage   "mtt-examples">

  <!ENTITY debian      "<productname>Debian</productname>">
  <!ENTITY gnu         "<acronym>GNU</acronym>">
  <!ENTITY gpl         "&gnu; <acronym>GPL</acronym>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2003</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>&dhpackage;</refname>

    <refpurpose>program to do something</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&dhpackage;</command>

      <arg><option>-e <replaceable>this</replaceable></option></arg>

      <arg><option>--example <replaceable>that</replaceable></option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>This manual page documents briefly the
      <command>&dhpackage;</command> and <command>bar</command>
      commands.</para>

    <para>This manual page was written for the &debian; distribution
      because the original program does not have a manual page.
      Instead, it has documentation in the &gnu;
      <application>Info</application> format; see below.</para>

    <para><command>&dhpackage;</command> is a program that...</para>

  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <para>These programs follow the usual &gnu; command line syntax,
      with long options starting with two dashes (`-').  A summary of
      options is included below.  For a complete description, see the
      <application>Info</application> files.</para>

    <variablelist>
      <varlistentry>
        <term><option>-h</option>
          <option>--help</option>
        </term>
        <listitem>
          <para>Show summary of options.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-v</option>
          <option>--version</option>
        </term>
        <listitem>
          <para>Show version of program.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>bar (1), baz (1).</para>

    <para>The programs are documented fully by <citetitle>The Rise and
      Fall of a Fooish Bar</citetitle> available via the
      <application>Info</application> system.</para>
  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (but may be used by others).  Permission is
      granted to copy, distribute and/or modify this document under
      the terms of the &gnu; General Public License, Version 2 any 
	  later version published by the Free Software Foundation.
    </para>
	<para>
	  On Debian systems, the complete text of the GNU General Public
	  License can be found in /usr/share/common-licenses/GPL.
	</para>

  </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->


Added mtt/lib/examples/debian/manpage.xml.ex version [3091db28f9].





















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [

<!--

Process this file with an XSLT processor: `xsltproc \
-''-nonet /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/\
manpages/docbook.xsl manpage.dbk'.  A manual page
<package>.<section> will be generated.  You may view the
manual page with: nroff -man <package>.<section> | less'.  A
typical entry in a Makefile or Makefile.am is:

DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/\
manpages/docbook.xsl
XP=xsltproc -''-nonet

manpage.1: manpage.dbk
        $(XP) $(DB2MAN) $<
    
The xsltproc binary is found in the xsltproc package.  The
XSL files are in docbook-xsl.  Please remember that if you
create the nroff version in one of the debian/rules file
targets (such as build), you will need to include xsltproc
and docbook-xsl in your Build-Depends control field.

-->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
  <!ENTITY dhsurname   "<surname>SURNAME</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>February 18, 2004</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>SECTION</manvolnum>">
  <!ENTITY dhemail     "<email>geraint@users.sourceforge.net</email>">
  <!ENTITY dhusername  "Geraint Paul Bevan">
  <!ENTITY dhucpackage "<refentrytitle>MTT-EXAMPLES</refentrytitle>">
  <!ENTITY dhpackage   "mtt-examples">

  <!ENTITY debian      "<productname>Debian</productname>">
  <!ENTITY gnu         "<acronym>GNU</acronym>">
  <!ENTITY gpl         "&gnu; <acronym>GPL</acronym>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2003</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>&dhpackage;</refname>

    <refpurpose>program to do something</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&dhpackage;</command>

      <arg><option>-e <replaceable>this</replaceable></option></arg>

      <arg><option>--example <replaceable>that</replaceable></option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>This manual page documents briefly the
      <command>&dhpackage;</command> and <command>bar</command>
      commands.</para>

    <para>This manual page was written for the &debian; distribution
      because the original program does not have a manual page.
      Instead, it has documentation in the &gnu;
      <application>Info</application> format; see below.</para>

    <para><command>&dhpackage;</command> is a program that...</para>

  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <para>These programs follow the usual &gnu; command line syntax,
      with long options starting with two dashes (`-').  A summary of
      options is included below.  For a complete description, see the
      <application>Info</application> files.</para>

    <variablelist>
      <varlistentry>
        <term><option>-h</option>
          <option>--help</option>
        </term>
        <listitem>
          <para>Show summary of options.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-v</option>
          <option>--version</option>
        </term>
        <listitem>
          <para>Show version of program.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>bar (1), baz (1).</para>

    <para>The programs are documented fully by <citetitle>The Rise and
      Fall of a Fooish Bar</citetitle> available via the
      <application>Info</application> system.</para>
  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (but may be used by others).  Permission is
      granted to copy, distribute and/or modify this document under
      the terms of the &gnu; General Public License, Version 2 any 
	  later version published by the Free Software Foundation.
    </para>
	<para>
	  On Debian systems, the complete text of the GNU General Public
	  License can be found in /usr/share/common-licenses/GPL.
	</para>

  </refsect1>
</refentry>

Added mtt/lib/examples/debian/menu.ex version [50c60cd5ce].



1
2
+
+
?package(mtt-examples):needs=X11|text|vc|wm section=Apps/see-menu-manual\
  title="mtt-examples" command="/usr/bin/mtt-examples"

Added mtt/lib/examples/debian/mtt-examples-default.ex version [05a379d706].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
# Defaults for mtt-examples initscript
# sourced by /etc/init.d/mtt-examples
# installed at /etc/default/mtt-examples by the maintainer scripts

#
# This is a POSIX shell fragment
#

# Additional options that are passed to the Daemon.
DAEMON_OPTS=""

Added mtt/lib/examples/debian/mtt-examples.doc-base.EX version [45f81688d7].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Document: mtt-examples
Title: Debian mtt-examples Manual
Author: <insert document author here>
Abstract: This manual describes what mtt-examples is
 and how it can be used to
 manage online manuals on Debian systems.
Section: unknown

Format: debiandoc-sgml
Files: /usr/share/doc/mtt-examples/mtt-examples.sgml.gz

Format: postscript
Files: /usr/share/doc/mtt-examples/mtt-examples.ps.gz

Format: text
Files: /usr/share/doc/mtt-examples/mtt-examples.text.gz

Format: HTML
Index: /usr/share/doc/mtt-examples/html/index.html
Files: /usr/share/doc/mtt-examples/html/*.html

  

Added mtt/lib/examples/debian/postinst.ex version [fc24fc87dc].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# postinst script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#

case "$1" in
    configure)

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/lib/examples/debian/postrm.ex version [71b1621095].







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# postrm script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
       purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)


        ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

Added mtt/lib/examples/debian/preinst.ex version [fa7af07255].













































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# preinst script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
#
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    install|upgrade)
#        if [ "$1" = "upgrade" ]
#        then
#            start-stop-daemon --stop --quiet --oknodo  \
#                --pidfile /var/run/mtt-examples.pid  \
#                --exec /usr/sbin/mtt-examples 2>/dev/null || true
#        fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/lib/examples/debian/prerm.ex version [2e6b5a3d99].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
# prerm script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    remove|upgrade|deconfigure)
#       install-info --quiet --remove /usr/info/mtt-examples.info.gz
        ;;
    failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Added mtt/lib/examples/debian/rules version [6acbd63d43].



































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1




CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.

	touch configure-stamp


build: build-stamp

build-stamp: configure-stamp 
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)
	#/usr/bin/docbook-to-man debian/mtt-examples.sgml > mtt-examples.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) clean

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Add here commands to install the package into debian/mtt-examples.
	$(MAKE) install DESTDIR=$(CURDIR)/debian/mtt-examples


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
#	dh_installdocs
	dh_installexamples
#	dh_install
#	dh_installmenu
#	dh_installdebconf	
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_python
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

Added mtt/lib/examples/debian/watch.ex version [366a56825c].







1
2
3
4
5
6
+
+
+
+
+
+
# Example watch control file for uscan
# Rename this file to "watch" and then you can run the "uscan" command
# to check for upstream updates and more.
# Site		Directory		Pattern			Version	Script
version=2
sunsite.unc.edu	/pub/Linux/Incoming	mtt-examples-(.*)\.tar\.gz	debian	uupdate

Added mtt/lib/latex/bg.sty version [d6c82b5f87].




































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Bond Graph commands
\newcommand{\B}[1]{\text{\sffamily\textbf{#1}}}
\newcommand{\AmpE}{\B{AE }}
\newcommand{\AF}{\B{AF }}
\newcommand{\C}{\B{C }}
\newcommand{\CSW}{\B{CSW }}
\newcommand{\De}{\B{De }}
\newcommand{\Df}{\B{Df }}
\newcommand{\I}{\B{I }}
\newcommand{\INTF}{\B{INTF }}
\newcommand{\ISW}{\B{ISW }}
\newcommand{\R}{\B{R }}
\newcommand{\Se}{\B{Se }}
\newcommand{\Sf}{\B{Sf }}
\newcommand{\Ss}{\B{SS }}
\newcommand{\one}{\B{1 }}
\newcommand{\zero}{\B{0 }}
\newcommand{\TF}{\B{TF }}
\newcommand{\GY}{\B{GY }}

%% Bond Graph components with label
\newcommand{\BB}[2]{$\B{#1}$:$\mathbf{#2}$} %Generic

\newcommand{\BC}[1]{\BB{C}{#1}}
\newcommand{\BI}[1]{\BB{I}{#1}}
\newcommand{\BR}[1]{\BB{R}{#1}}

\newcommand{\BSS}[1]{\BB{SS}{#1}}
\newcommand{\BSe}[1]{\BB{Se}{#1}}
\newcommand{\BSf}[1]{\BB{Sf}{#1}}
\newcommand{\BDe}[1]{\BB{De}{#1}}
\newcommand{\BDf}[1]{\BB{Df}{#1}}

\newcommand{\BTF}[1]{\BB{TF}{#1}}
\newcommand{\BGY}[1]{\BB{TF}{#1}}

Added mtt/lib/octave/.octaverc version [04e2bb682d].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Startup file for Octave for use with MTT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

implicit_str_to_num_ok = 1;
empty_list_elements_ok = 1;
warn_string_concat = 0;

## Turn off irrelevant warnings
warning off Octave:possible-matlab-short-circuit-operator
warning off Octave:deprecated-syntax

## No more core dumps
crash_dumps_octave_core(0)
sigterm_dumps_octave_core(0)
sighup_dumps_octave_core(0)

Added mtt/lib/octave/README version [b32763b888].


1
+
This contains some octave specific helps to MTT

Added mtt/lib/octave/mkoctfile version [e7f6db0ac4].











































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh
#
# mkoctfile -- create a .oct file suitable for dynamic linking by
# Octave.
echo mkoctfile with optimisation level 0
# Exit immediately on any error.

set -e

# Default values for these variables are filled in when Octave is
# compiled. 

: ${CPPFLAGS=""}
: ${INCFLAGS="-I/usr/include -I/usr/include/octave-2.0.16"}
: ${F77="g77"}
: ${FFLAGS="-O0"}
: ${FPICFLAG="-fPIC"}
: ${CC="gcc"}
: ${CFLAGS="-DHAVE_CONFIG_H -mieee-fp -O0"}
: ${CPICFLAG="-fPIC"}
: ${CXX="c++"}
: ${CXXFLAGS="-O0"}
: ${CXXPICFLAG="-fPIC"}
: ${XTRA_CFLAGS="-mieee-fp -fno-rtti -fno-exceptions -fno-implicit-templates"}
: ${XTRA_CXXFLAGS="-mieee-fp -fno-rtti -fno-exceptions -fno-implicit-templates"}

: ${SH_LD="c++"}
: ${SH_LDFLAGS="-shared"}

: ${ALL_FFLAGS="$FFLAGS"}

: ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"}

: ${ALL_CXXFLAGS="$INCFLAGS $XTRA_CXXFLAGS $CXXFLAGS"}

# Local variables.

usage_msg="usage: mkoctfile [options] file ..."

cfiles=
ccfiles=
f77files=
objfiles=
octfiles=
octfile=
incflags=
defs=
ldflags=
dbg=:
strip=false

if [ $# -eq 0 ]; then
  echo $usage_msg
  exit 1;
fi

while [ $# -gt 0 ]; do
  file=
  case "$1" in
    *.c)
      file=$1
      cfiles="$cfiles $file"
    ;;
    *.cc | *.C | *.cpp)
      file=$1
      ccfiles="$ccfiles $file"
    ;;
    *.f | *.F)
      file=$1
      f77files="$f77files $file"
    ;;
    *.o)
      file=$1
      objfiles="$objfiles $file"
    ;;
    -d | --debug | -v | --verbose)
      dbg=echo
    ;;
    -h | -\? | --help)
      echo $usage_msg
      cat << EOF

Options:

  -h, -?, --help          Print this message.
  -IDIR                   Add -IDIR to compile commands.
  -DDEF                   Add -DDEF to compile commands.
  -lLIB                   Add library LIB to link command.
  -LDIR                   Add -LDIR to link command.
  -o FILE, --output FILE  Output file name.  Default extension is .oct.
  -s, --strip             Strip output file.
  -v, --verbose           Echo commands as they are executed.

  FILE                    Compile or link FILE.  Recognized file types are:

			    .c    C source
			    .cc   C++ source
			    .C    C++ source
			    .cpp  C++ source
			    .f    Fortran source
			    .F    Fortran source
			    .o    object file

EOF
      exit 0
    ;;
    -I*)
      incflags="$incflags $1"
    ;;
    -D*)
      defs="$defs $1"
    ;;
    -[lL]*)
      ldflags="$ldflags $1"
    ;;
    -o | --output)
      shift
      if [ $# -gt 0 ]; then
        octfile=`echo $1 | sed 's,\.[^.]*$,,'`.oct
      else
        echo "mkoctfile: output file name missing"
      fi
    ;;
    -s | --strip)
      strip=true
    ;;
    *)
      echo "mkoctfile: unrecognized argument $1"
      exit 1
    ;;
  esac
  if [ -n "$file" ]; then
    if [ -z "$octfile" ]; then
      octfile=`echo $file | sed 's,\.[^.]*$,,'`.oct
    fi
  fi
  shift
done

# Compile Fortran, C, and C++ files.  Add the name of each object file
# that is produced to the overall list of object files.

if [ -n "$f77files" ]; then
  for f in $f77files; do
    case $f in
      *.f)
        b=`echo $f | sed 's,\.f$,,'`
      ;;
      *.F)
        b=`echo $f | sed 's,\.F$,,'`
      ;;
    esac
    o=$b.o
    objfiles="$objfiles $o"
    $dbg $F77 -c $FPICFLAG $ALL_FFLAGS $f -o $o
    eval $F77 -c $FPICFLAG $ALL_FFLAGS $f -o $o
  done
fi

if [ -n "$cfiles" ]; then
  for f in $cfiles; do
    b=`echo $f | sed 's,\.c$,,'`
    o=$b.o
    objfiles="$objfiles $o"
    $dbg $CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $incflags $defs $f -o $o
    eval $CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $incflags $defs $f -o $o
  done
fi

if [ -n "$ccfiles" ]; then
  for f in $ccfiles; do
    case $f in
      *.cc)
        b=`echo $f | sed 's,\.cc$,,'`
      ;;
      *.C)
        b=`echo $f | sed 's,\.C$,,'`
      ;;
      *.cpp)
        b=`echo $f | sed 's,\.cpp$,,'`
      ;;
    esac
    o=$b.o
    objfiles="$objfiles $o"
    $dbg $CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $incflags $defs $f -o $o
    eval $CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $incflags $defs $f -o $o
  done
fi

# Link all the object files.

$dbg $SH_LD $SH_LDFLAGS -o $octfile $objfiles $ldflags
eval $SH_LD $SH_LDFLAGS -o $octfile $objfiles $ldflags

# Maybe strip it.

if $strip; then
  $dbg strip $octfile
  eval strip $octfile
fi

exit 0

Added mtt/lib/reduce/fix_c.r version [4c2ca104c3].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Fixes for c-code generation

%% Set PI explicitly here to avoid later conflict with cc headers
%% if PI is not already a number (i.e. on rounded has not been set)
IF NOT NUMBERP (pi) THEN LET PI = 3.14159$

ON ROUNDED$ % No integer output

%% Changes x^y to pow(x,y)
 OPERATOR pow$
 FOR ALL x,y LET x^y = pow(x,y)$ % Use the pow function
 FOR ALL x,y LET x**y = pow(x,y)$ % Use the pow function
 
 %% Derivatives
 FOR ALL f,g,x LET df(pow(f,g),x)=
 	   pow(f,g-1) * (df(f,x)*g + df(g,x)*f*log(f))$

 %% Special cases
 FOR ALL x LET pow(x,0) = 1$
 FOR ALL x LET pow(x,1) = x$

OPERATOR fabs$
FOR ALL x let abs(x) = fabs(x)$


END$

Added mtt/lib/reduce/reserved_words.make version [58b98880d4].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

reduce_reserved_word_manual_page=${1:-"/usr/local/reduce/doc/manual/appenda.tex"}
output="reserved_words.txt"

cat $reduce_reserved_word_manual_page                   |\
    tr "\n" " "                                         |\
    sed 's/\\\_/_/g'                                    |\
    sed 's/\\tt\ \([A-Za-z0-9_]*\)/\"\1\"/g'            |\
    tr " " "\n"                                         |\
    sed 's/\{//g'                                       |\
    sed 's/\}//g'                                       |\
    gawk -F\" '(NF==3) { printf "%s\n",$2 }'            |\
    sort -u						\
> $output

Added mtt/lib/reduce/reserved_words.txt version [727a3fd398].
























































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
ABS
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ADJPREC
ALGEBRAIC
ALGINT
ALLBRANCH
ALLFAC
AND
ANTISYMMETRIC
APPEND
ARGLENGTH
ARRAY
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
BEGIN
BFSPACE
BYE
CARD_NO
CEILING
CLEAR
CLEARRULES
COEFF
COEFFN
COFACTOR
COMBINEEXPT
COMBINELOGS
COMMENT
COMP
COMPLEX
CONJ
CONS
CONT
COS
COSH
COT
COTH
CRAMER
CREF
CSC
CSCH
DECOMPOSE
DEFINE
DEFN
DEG
DEMO
DEN
DEPEND
DET
DF
DIFFERENCE
DILOG
DISPLAY
DIV
DO
E
ECHO
ED
EDITDEF
EI
END
EPS
EQ
EQUAL
ERF
ERRCONT
EVALLHSEQP
EVAL_MODE
EVEN
EVENP
EXP
EXPANDLOGS
EXPR
EXPT
EZGCD
FACTOR
FACTORIAL
FACTORIZE
FEXPR
FIRST
FIX
FIXP
FLOOR
FOR
FORALL
FOREACH
FORT
FORT_WIDTH
FREEOF
FULLROOTS
G
GCD
GEQ
GO
GOTO
GREATERP
HIGH_POW
HYPOT
I
IF
IFACTOR
IMPART
IN
INDEX
INFINITY
INFIX
INPUT
INT
INTEGER
INTERPOL
INTSTR
K
KORDER
LAMBDA
LCM
LCOF
LENGTH
LEQ
LESSP
LET
LHS
LINEAR
LINELENGTH
LISP
LIST
LISTARGP
LISTARGS
LN
LOAD
LOAD_PACKAGE
LOG
LOG10
LOGB
LOW_POW
LTERM
MACRO
MAINVAR
MASS
MAT
MATCH
MATEIGEN
MATRIX
MAX
MCD
MEMBER
MEMQ
MIN
MINUS
MKID
MODULAR
MSG
MSHELL
MULTIPLICITIES
NAT
NEQ
NERO
NEXTPRIME
NIL
NODEPEND
NONCOM
NONZERO
NOSPLIT
NOSPUR
NULLSPACE
NUM
NUMBERP
ODD
OFF
ON
OPERATOR
OR
ORDER
ORDP
OUT
OUTPUT
PART
PAUSE
PERIOD
PF
PI
PLUS
PRECEDENCE
PRECISE
PRECISION
PRET
PRI
PRIMEP
PRINT_PRECISION
PROCEDURE
PRODUCT
QUIT
QUOTIENT
RANDOM
RANDOM_NEW_SEED
RANK
RAT
RATARG
RATIONAL
RATIONALIZE
RATPRI
REAL
REDERR
REDUCT
REMAINDER
REMFAC
REMIND
REPART
REPEAT
REST
RESULTANT
RETRY
RETURN
REVERSE
REVPRI
RHS
RLISP88
ROOT_MULTIPLICITY
ROUND
ROUNDALL
ROUNDBF
ROUNDED
SAVEAS
SAVESTRUCTR
SCALAR
SEC
SECH
SECOND
SET
SETMOD
SETQ
SHARE
SHOWRULES
SHOWTIME
SHUT
SIGN
SIN
SINH
SMACRO
SOLVE
SOLVESINGULAR
SPUR
SQRT
STRUCTR
SUB
SUM
SYMBOLIC
SYMMETRIC
T
TAN
TANH
THIRD
TIME
TIMES
TP
TRA
TRACE
TRFAC
TRIGFORM
TRINT
UNTIL
VARNAME
VECDIM
VECTOR
WEIGHT
WHEN
WHERE
WHILE
WRITE
WS
WTLEVEL

Added mtt/lib/rep/cxxsim.cc version [e39d33615e].

































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*  cxxsim:  creates a C++ simulation from MTT elementary system equations
 *  Copyright (C) 2000,2002  Geraint Paul Bevan
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <string>

namespace cxxsim {

  class cr {
    
  public:

    cr		(std::string system_name);
    
    void read	(std::ifstream &file);
    void write	(std::ofstream &file);
   
    friend std::ifstream &operator>> (std::ifstream &file, cr &c);
    friend std::ofstream &operator<< (std::ofstream &file, cr &c);
    
  private:

    std::string			name;

    std::list<std::string>	L;
  };

  class equations {

  public:

    equations	(std::string system_name);    

    void read	(std::ifstream &file);
    void write	(std::ofstream &file);
   
    friend std::ifstream &operator>> (std::ifstream &file, equations &e);
    friend std::ofstream &operator<< (std::ofstream &file, equations &e);

  private:
    
    void descend	(std::string s);
    void parse		(void);

    std::string				name; // system name

    // list of statements collected by reader
    std::list<std::string>		statements;

    std::list<std::string>		leqn; // final expressions
    std::list<std::string>		lvar; // intermediate expressions
    std::list<std::string>		loop; // algebraic loops

    // table of final and intermediate expressions
    std::map<std::string, std::string>	meqn; // lhs, rhs mapping
    std::map<std::string, std::string>	mvar;

    // tag is symbol denoting an intermediate variable
    std::string				tag; // denotes intermediates

    // token delimiters (not ([{.`'" or alphanumeric)
    std::string				delim;
  };

  class parameter {

  public:

    parameter	(std::string system_name);

    void read	(std::ifstream &file);
    void write	(std::ofstream &file);

    friend std::ifstream &operator>> (std::ifstream &file, parameter &p);
    friend std::ofstream &operator<< (std::ofstream &file, parameter &p);

  private:

    std::string		name;

    struct record {
      std::string	variable;
      std::string	component;
    };
    
    typedef struct record record_t;
    std::list<record_t>			L;
  };

  class structure {
    
  public:

    structure		(std::string system_name);

    void read		(std::ifstream &file);
    void write		(std::ofstream &file);

    friend std::ifstream &operator>> (std::ifstream &file, structure &s);
    friend std::ofstream &operator<< (std::ofstream &file, structure &s);

  private:

    void write_declare	(std::ofstream &file);
    void write_input	(std::ofstream &file);
    void write_logic	(std::ofstream &file);
    void write_state	(std::ofstream &file);

    std::string		name;

    struct record {
      std::string	vec;	// vector: u, x, y, yz
      unsigned int	num;	// position of element in vector
      std::string	cmp;	// component
      std::string	fnm;	// full name
      unsigned int	rpt;	// number of repetitions
      std::string	cty;	// causality
    };

    typedef struct record record_t;
    std::list<record_t>			Lu;
    std::list<record_t>			Lx;
    std::list<record_t>			Ly;
    std::list<record_t>			Lyz;
    std::list<record_t>::iterator	i;    
  };

  cr::cr (std::string system_name){
    name = system_name;
  }

  void
  cr::read (std::ifstream &file){
    std::string r;
    while (file >> r){
      L.push_back(r);
    }
  }

  void
  cr::write (std::ofstream &file){
    file << "enum causality { effort, flow, state };" << std::endl
	 << "typedef enum causality causality_t;" << std::endl;
    std::list<std::string>::iterator i;
    for (i = L.begin(); i != L.end(); i++){
      if ((*i != "SS") && (*i != "ISW")){
	file << "#include <" << *i << ".hh>" << std::endl;
      }
    }
    file << std::endl;
  }

  std::ifstream &operator>> (std::ifstream &file, cr &c){
    c.read(file);
    return file;
  }
  
  std::ofstream &operator<< (std::ofstream &file, cr &c){
    c.write(file);
    return file;
  }

  equations::equations (std::string system_name){
    name = system_name;
    tag = system_name;
    delim = "~!@#$%^&*)-+=]}\\|;:,<>/?";
  };

  void
  equations::read (std::ifstream &file){
    
    char				c;
    std::string				s;
    std::string				t;

    unsigned int			i;

    //    file.unsetf(std::ios::skipws);
    file.setf(std::ios::skipws);

    // read lines from file (no max length, unlike std::getline)
    while (file >> c){
      s = "";
      while (c != ';' && file){
	if (c == '%'){
	  file.unsetf(std::ios::skipws);
	  while ((c != '\n') && file){
	    file >> c;			     // eat comment
	  }
	  file.setf(std::ios::skipws);
	} else {
	  if ((c != ' ') && (c != '\t')){    // strip whitespace
	    s += c;
	  }
	  file >> c;
	}
      }
      
      // fix vector references
      t = "MTTu(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 5, "mttu[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      t = "MTTx(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 5, "mttx[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      t = "MTTdX(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 6, "mttdx[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      t = "MTTy(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 5, "mtty[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      
      // strip newlines
      while ((i = s.find('\n')) < s.length()){
	s.replace(i, 1, "");
      }

      if ((s != "") && (s != "END")){
	// add statement to list
	statements.push_back(s);
      }
    }

    // finished reading, time to comprehend ...
    this->parse();
  }
  
  void
  equations::write (std::ofstream &file){

    std::list<std::string>::iterator	eqn;

    file << "void"					<< std::endl
	 << this->name << "_ode(const double t,"	<< std::endl
	 << "\tdouble *mttu,"				<< std::endl
	 << "\tdouble *mttx,"				<< std::endl
	 << "\tdouble *mttdx,"				<< std::endl
	 << "\tdouble *mtty)"				<< std::endl
	 << "{"						<< std::endl;
    for (eqn = leqn.begin(); eqn != leqn.end(); eqn++){
      file << *eqn << " = " << meqn[*eqn] << ";" << std::endl;
    }
    file << "} // " << this->name << "_ode"		<< std::endl;
  };

  void
  equations::descend (std::string s){

    char		c;
    unsigned int	i;
    bool		cont;

    std::list<std::string>::iterator	var;

    loop.push_back(s);

    // find algebraic loops
    for (var = loop.begin(); var != loop.end(); var++){
      if ((i = mvar[s].find(*var)) < mvar[s].length()){
	c = mvar[s].c_str()[i + var->length()];
	if (delim.find(c) < delim.length()){
	  std::cerr << std::endl
		    << "warning: algebraic loop" << std::endl
		    << '\t' << s << " = " << mvar[s].substr(0, 60);
	  if (mvar[s].length() > 60){
	    std::cerr << " ...";
	  }
	  std::cerr << std::endl << std::endl;
	  mvar[s] = s + "____loop";
	}
      }
    }

    // substitutes intermediate variables for their expansion
    do {
      cont = false;
      for (var = lvar.begin(); var != lvar.end(); var++){
	// check for token match
	while ((i = mvar[s].find(*var)) < mvar[s].length()){
	  // ensure exact match
	  c = mvar[s].c_str()[i + var->length()];
	  if (delim.find(c) < delim.length()){
	    // expand expression recursively
	    this->descend(*var);
	    // check match again, map may have changed
	    if ((i = mvar[s].find(*var)) < mvar[s].length()){
	      c = mvar[s].c_str()[i + var->length()];
	      if (delim.find(c) < delim.length()){
	    	// substitute expression
		mvar[s].replace(i, var->length(), mvar[*var]);
		// continue
		cont = true;
	      }
	    }	    
	  }
	}
      }
    } while (cont);
    loop.pop_back();
  }
  
  void
  equations::parse (void){
    
    char		c;
    unsigned int	i;

    std::string		lhs;
    std::string		rhs;
    
    std::list<std::string>::iterator	s;

    std::list<std::string>::iterator	eqn;
    std::list<std::string>::iterator	var;

    for (s = statements.begin(); s != statements.end(); s++){
      // parse statement
      if ((i = s->find(":=")) < s->length()){
	lhs = s->substr(0, i);
	rhs = s->substr(i+2, s->length());
	
	// separate intermediate and final variables
	if (s->substr(0, tag.length()) == tag){
	  // add to table of intermediate variables
	  lvar.push_back(lhs);
	  mvar[lhs] = "(" + rhs + ")";
	} else {
	  // add to table of final variables
	  leqn.push_back(lhs);
	  meqn[lhs] = rhs + ";";
	}
      } else {
	std::cerr << std::endl
		  << "warning: non-assignment -- ignoring"
		  << std::endl
		  << '\t' << *s << std::endl
		  << std::endl;
      }
    }
      
    // expand rhs of intermediate variables
    for (var = lvar.begin(); var != lvar.end(); var++){
      loop.clear();
      descend(*var);
    }
    
    // substitute expanded expressions into final equations
    for (eqn = leqn.begin(); eqn != leqn.end(); eqn++){
      for (var = lvar.begin(); var != lvar.end(); var++){
	while ((i = meqn[*eqn].find(*var)) < meqn[*eqn].length()){
	  c = meqn[*eqn].c_str()[i + var->length()];
	  if (delim.find(c) < delim.length()){
	    meqn[*eqn].replace(i, var->length(), mvar[*var]);
	  }
	}
      }
    }
  }

    std::ifstream &operator>> (std::ifstream &file, equations &e){
    e.read(file);
    return file;
  }
  
  std::ofstream &operator<< (std::ofstream &file, equations &e){
    e.write(file);
    return file;
  }

  parameter::parameter (std::string system_name){
    name = system_name;
  };

  void
  parameter::read (std::ifstream &file){
    record_t r;
    while (file >> r.variable >> r.component){
      if (r.variable.find("#") == 0){
	file.unsetf(std::ios::skipws);
	char c = '\0';
	while (c != '\n'){
	  file >> c;
	}
	file.setf(std::ios::skipws);
      } else {
	L.push_back(r);
      }
    }
  }

  void
  parameter::write (std::ofstream &file){
    std::list<record_t>::iterator i;
    std::string type;
    std::string value;
    for (i = L.begin(); i != L.end(); i++){
      if (i->variable.substr(0, 6) == "bool__"){
	type = "bool";
	value = "false";
      } else if (i->variable.substr(0, 6) == "char__"){
	type = "char";
	value = "\0";
      } else if (i->variable.substr(0, 8) == "double__"){
	type = "double";
	value = "1.0";
      } else if (i->variable.substr(0, 7) == "float__"){
	type = "float";
	value = "1.0";
      } else if (i->variable.substr(0, 5) == "int__"){
	type = "int";
	value = "1";
      } else if (i->variable.substr(0, 7) == "string__"){
	type = "std::string";
	value = "hello world!";
      } else {
	type = "double";
	value = "1.0";
      }
      file << "static " << type << "\t" << i->variable << " = " << value
	   << ";\t// " << i->component << std::endl;
    }
    file << std::endl;
  }

  std::ifstream &operator>> (std::ifstream &file, parameter &p){
    p.read(file);
    return file;
  }

  std::ofstream &operator<< (std::ofstream &file, parameter &p){
    p.write(file);
    return file;
  }

  structure::structure (std::string system_name){
    name = system_name;
  };
  
  void
  structure::read (std::ifstream &file){
    std::list<record_t> *p;
    record_t r;
    if (! file){
      std::cerr << "warning: no structure data found (empty file)" << std::endl;
    }
    while (file >> r.vec >> r.num >> r.cmp >> r.fnm >> r.rpt >> r.cty){
      if (r.vec == "input"){
	p = &(this->Lu);
      } else if (r.vec == "state"){
	p = &(this->Lx);
      } else if (r.vec == "output"){
	p = &(this->Ly);
      } else {
	p = &(this->Lyz);
      }
      p->push_back(r);
    }
  };

  void
  structure::write (std::ofstream &file){
    this->write_declare(file);
    file << std::endl;
    this->write_input(file);
    file << std::endl;
    this->write_logic(file);
    file << std::endl;
    this->write_state(file);
    file << std::endl;
  }

  void
  structure::write_declare (std::ofstream &file){
    file << "const int mttNu\t= " << this->Lu.size() + 1 << ";"	<< std::endl
	 << "const int mttNx\t= " << this->Lx.size() + 1 << ";"	<< std::endl
	 << "const int mttNy\t= " << this->Ly.size() + 1 << ";"	<< std::endl
	 << "static double mttu[mttNu];"			<< std::endl
	 << "static double mttx[mttNx];"			<< std::endl
	 << "static double mtty[mttNy];"			<< std::endl
	 << "static double mttdx[mttNx];"			<< std::endl
	 << std::endl;
  }

  void
  structure::write_input (std::ofstream &file){
    file << "void"					<< std::endl
	 << this->name << "_input(const double t,"	<< std::endl
	 << "\tdouble *mttu,"				<< std::endl
	 << "\tdouble *mttx,"				<< std::endl
	 << "\tdouble *mtty)"				<< std::endl
	 << "{"						<< std::endl;
    for (i = Lu.begin(); i != Lu.end(); i++){
      file << "\tmttu["	<< i->num << "]\t= 1.0;"
	   << "\t// "	<< i->cmp
	   << "\t("	<< i->fnm << ")"		<< std::endl;
    }
    file << "} // " << this->name << "_input"		<< std::endl;
  }

  void
  structure::write_logic (std::ofstream &file){
    file << "void"					<< std::endl
	 << this->name << "_logic(const double t,"	<< std::endl
	 << "\tdouble *mttu,"				<< std::endl
	 << "\tdouble *mttx,"				<< std::endl
	 << "\tdouble *mttdx,"				<< std::endl
	 << "\tdouble *mtty)"				<< std::endl
	 << "{"						<< std::endl;
    for (i = Lx.begin(); i != Lx.end(); i++){
      if (i->cmp == "MTT_SWITCH"){
	file << "int " << i->fnm << " = 1;"		<< std::endl
	     << "if ((" << i->fnm << " == 0)"
	     << " || ((" << i->fnm << " < 0)"
	     << " && (mttx[" << i->num << "] < 0.0))){"	<< std::endl
	     << "\tmttx[" << i->num << "]\t = 0.0;"	<< std::endl
	     << "\tmttdx[" << i->num << "]\t = 0.0;"	<< std::endl
	     << "}"					<< std::endl;
      }
    }
    file << "} // " << this->name << "_logic"		<< std::endl;
  }

  void
  structure::write_state (std::ofstream &file){
    file << "void"					<< std::endl
	 << this->name << "_state(double *mttx)"	<< std::endl
	 << "{"						<< std::endl;
    for (i = Lx.begin(); i != Lx.end(); i++){
      file << "\tmttx["	<< i->num << "]\t= 0.0;"
	   << "\t// "	<< i->cmp
	   << "\t("	<< i->fnm << ")"		<< std::endl;
    }    
    file << "} // " << this->name << "_state"		<< std::endl;      
  }

  std::ifstream &operator>> (std::ifstream &file, structure &s){
    s.read(file);
    return file;
  }

  std::ofstream &operator<< (std::ofstream &file, structure &s){
    s.write(file);
    return file;
  }

};

void
usage(const char *program){
  std::cerr << std::endl
	    << "usage: " << program << " system" << std::endl
	    << std::endl;
}

int main(int argc, char *argv[])
{
  // check usage
  if (argc != 2){
    usage(argv[0]);
    return 1;
  }
  std::string system_name = argv[1];
  
  // open files for reading and writing
  std::string cr_filename		= system_name + "_cr.txt";
  std::string parameter_filename	= system_name + "_sympar.txt";
  std::string structure_filename	= system_name + "_struc.txt";
  std::string equations_filename	= system_name + "_ese.r";
  std::string cxxsim_filename		= system_name + "_cxxsim.cc";

  std::ifstream cr_file	      (cr_filename.c_str());
  std::ifstream parameter_file(parameter_filename.c_str());
  std::ifstream structure_file(structure_filename.c_str());
  std::ifstream equations_file(equations_filename.c_str());
  std::ofstream cxxsim_file(cxxsim_filename.c_str());

  // announce transformation
  std::clog << "Creating " << cxxsim_filename << std::endl;
  
  // do transformations (abracadabra!)
  cxxsim::cr	    system_cr	    (system_name);
  cxxsim::parameter system_parameter(system_name);
  cxxsim::structure system_structure(system_name);
  cxxsim::equations system_equations(system_name);

  cr_file	 >> system_cr;
  parameter_file >> system_parameter;
  structure_file >> system_structure;
  equations_file >> system_equations;
  
  
  cxxsim_file << system_cr
	      << system_parameter
	      << system_structure 
	      << system_equations
	      << std::endl;

  cxxsim_file << std::endl
	      << "int"								<< std::endl
	      << "main(void){"							<< std::endl
	      << std::endl
	      << "  double mttdt = 0.1; // integration time step"		<< std::endl
	      << "  double mttt;"						<< std::endl
	      << "  int i;"							<< std::endl
	      << std::endl
	      << "  for (mttt = 0.0; mttt <= 10.0; mttt += mttdt){"		<< std::endl
	      << std::endl
	      << "    // get inputs and rates"					<< std::endl
	      << "    " << system_name << "_input(mttt,mttu,mttx,mtty);"	<< std::endl
	      << "    " << system_name << "_ode(mttt,mttu,mttx,mttdx,mtty);"	<< std::endl
	      << std::endl
	      << "    // integrate states (euler)"				<< std::endl
	      << "    for (i = 1; i <= mttNx; i++){"				<< std::endl
	      << "      mttx[i] += mttdx[i] * mttdt;"				<< std::endl
	      << "    }"							<< std::endl
	      << std::endl
	      << "    // overwrite switch states"				<< std::endl
	      << "    " << system_name << "_logic(mttt,mttu,mttx,mttdx,mtty);"	<< std::endl
	      << std::endl
	      << "    // write: time outputs time states"			<< std::endl
	      << "    std::cout << mttt << '\\t';"				<< std::endl
	      << "    for (i = 1; i <= mttNy; i++){"				<< std::endl
	      << "      std::cout << mtty[i] << ' ';"				<< std::endl 
	      << "    }"							<< std::endl
	      << "    std::cout << '\\t' << mttt;"				<< std::endl
	      << "    for (i = 1; i <= mttNx; i++){"				<< std::endl
	      << "      std::cout << ' ' << mttx[i];"				<< std::endl 
	      << "    }"							<< std::endl
	      << "    std::cout << std::endl;"					<< std::endl
	      << "  }"								<< std::endl
	      << "  return 0;"							<< std::endl
	      << "}"								<< std::endl;

  // close files
  cr_file.close();
  parameter_file.close();
  structure_file.close();
  equations_file.close();
  cxxsim_file.close();

  return 0;
}

Added mtt/lib/rep/cxxsim_rep.make version [40e5a5430e].
































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-makefile-*-

# usage: mtt <sys> cxxsim view

# example:
# mtt copy MotorGenerator && cd MotorGenerator && mtt MotorGenerator cxxsim view

# cxxsim creates a very simple C++ simulation without using Reduce
# it doesn't use MTT's normal .txt files so the resultant .cc must be edited 
# manually to alter parameter, input and logic values

# a more intelligent version would just do ese_r2cc to create <sys>_ese.cc
# this could then be embedded into MTT's normal code like <sys>_ode.cc
# maybe another day ...

CC=g++

INCLUDE=-I. -I${MTT_LIB}/cr/hh
OPTIMISE=-O3
WARNINGS=-Wall -ansi -pedantic

ifeq ("","$(MTT_ARG)")
TARGET=$(MTT_SYS)_cxxsim.$(MTT_LANG)
else
TARGET=$(MTT_SYS)_cxxsim-$(MTT_ARG).$(MTT_LANG)
endif

all: $(TARGET)

# rule copied from gnuplot_rep.make
# need it here to prevent MTT using the default route (via dae)
$(MTT_SYS)_cxxsim.gnuplot: $(MTT_SYS)_gnuplot.wish $(MTT_SYS)_odes.dat2
	sh $(MTT_SYS)_gnuplot.wish		|\
		tee gnuplot_in.log		|\
		 gnuplot -geometry 400x300	\
		 > gnuplot_out.log 2> gnuplot_err.log &

$(MTT_SYS)_cxxsim.view: $(MTT_SYS)_cxxsim-odes.ps $(MTT_SYS)_cxxsim-odeso.ps
	${PSVIEW} $(MTT_SYS)_cxxsim-odes.ps
	${PSVIEW} $(MTT_SYS)_cxxsim-odeso.ps

$(MTT_SYS)_cxxsim.ps: $(MTT_SYS)_cxxsim-odeso.ps
	cp $< $@

$(MTT_SYS)_cxxsim-ode%.ps: $(MTT_SYS)_ode%.fig
	fig2dev -Leps $(MTT_SYS)_ode$*.fig $@

$(MTT_SYS)_ode%.fig: $(MTT_SYS)_ode%.gdat
	gdat2fig $(MTT_SYS)_ode$*

$(MTT_SYS)_ode%.gdat: $(MTT_SYS)_ode%.dat
	dat2gdat $(MTT_SYS) ode$*

$(MTT_SYS)_ode%.dat: $(MTT_SYS)_def.r $(MTT_SYS)_odes.dat2
	dat22dat $(MTT_SYS) ode $*

$(MTT_SYS)_odes.dat2: $(MTT_SYS)_cxxsim.exe
	./$< > $@

$(MTT_SYS)_cxxsim.exe: $(MTT_SYS)_cxxsim.cc
	echo Creating $(MTT_SYS)_cxxsim.exe
	$(CC) -o $@ $^ $(OPTIMISE) $(WARNINGS) $(INCLUDE)

$(MTT_SYS)_cxxsim.cc: $(MTT_SYS)_cr.txt $(MTT_SYS)_ese.r $(MTT_SYS)_struc.txt $(MTT_SYS)_sympar.txt cxxsim
	./cxxsim $(MTT_SYS)
	cp $@ ..

cxxsim: ${MTT_LIB}/rep/cxxsim.cc
	echo creating $@
	echo Compiling $^
	$(CC) -o $@ $^ $(OPTIMISE) $(WARNINGS) $(INCLUDE)

# list of constitutive relationships
$(MTT_SYS)_cr.txt:
	mtt -q $(MTT_OPTS) $(MTT_SYS) cr txt

# array sizes
$(MTT_SYS)_def.r:
	mtt -q $(MTT_OPTS) $(MTT_SYS) def r

# elementary system equations
$(MTT_SYS)_ese.r:
	mtt -q $(MTT_OPTS) $(MTT_SYS) ese r

# system structure
$(MTT_SYS)_struc.txt:
	mtt -q $(MTT_OPTS) $(MTT_SYS) struc txt

# list of symbolic parameters
$(MTT_SYS)_sympar.txt:
	mtt -q $(MTT_OPTS) $(MTT_SYS) sympar txt

# gnuplot script
$(MTT_SYS)_gnuplot.wish:
	mtt -q $(MTT_OPTS) $(MTT_SYS) gnuplot wish

Added mtt/lib/rep/gnuplot_rep.make version [d922043d89].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-makefile-*-
# create a gnuplot input file

MTTFLAGS	= $(MTT_OPTS)

all: $(MTT_SYS)_gnuplot.$(MTT_LANG)

$(MTT_SYS)_gnuplot.view: $(MTT_SYS)_gnuplot.wish
	mtt $(MTT_OPTS) $(MTT_SYS) odes dat2
	sh $(MTT_SYS)_gnuplot.wish				|\
		tee gnuplot_in.log				|\
		 gnuplot -name $(MTT_SYS) -geometry 400x300	\
		 > gnuplot_out.log 2> gnuplot_err.log &

$(MTT_SYS)_gnuplot.wish: $(MTT_SYS)_struc.txt
	$(MTTPATH)/trans/struc2gnuplot_txt2wish $(MTT_SYS)

$(MTT_SYS)_struc.txt:
	mtt $(MTTFLAGS) $(MTT_SYS) struc txt


Added mtt/lib/rep/ident_rep.make version [e8f9bdae3f].


















































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-makefile-*-

#SUMMARY 	Identification
#DESCRIPTION 	Partially know system identification using
#DESCRIPTION    using bond graphs

# Makefile for representation ident
# File ident_rep.make

#Copyright (C) 2000,2001,2002 by Peter J. Gawthrop

## Model targets
model_reps =  ${MTT_SYS}_sympar.m ${MTT_SYS}_simpar.m ${MTT_SYS}_state.m 
model_reps += ${MTT_SYS}_numpar.m ${MTT_SYS}_input.m ${MTT_SYS}_ode2odes.m  
model_reps += ${MTT_SYS}_def.m 

## Prepend s to get the sensitivity targets
sensitivity_reps = ${model_reps:%=s%}

## Model prerequisites
model_pre =  ${MTT_SYS}_abg.fig ${MTT_SYS}_lbl.txt 
model_pre += ${MTT_SYS}_rdae.r ${MTT_SYS}_numpar.txt

## Prepend s to get the sensitivity targets
sensitivity_pre = ${model_pre:%=s%}


## Simulation targets
sims = ${MTT_SYS}_sim.m s${MTT_SYS}_ssim.m

## m-files needed for ident
ident_m = ${MTT_SYS}_ident.m ${MTT_SYS}_ident_numpar.m 

## The input data
ident_data = ${MTT_SYS}_ident_data.dat

## Targets for the ident simulation
ident_reps = ${ident_m} ${sims} ${model_reps} ${sensitivity_reps}

## ps output files etc
psfile = ${MTT_SYS}_ident.ps
psfiles = ${MTT_SYS}_ident.ps ${MTT_SYS}_ident.comparison.ps ${MTT_SYS}_ident_pars.ps
figfiles = ${psfiles:%.ps=%.fig}
gdatfiles = ${psfiles:%.ps=%.gdat}
datfiles = ${psfiles:%.ps=%.dat2}

## LaTeX files etc
latexfiles = ${MTT_SYS}_ident_par.tex

all: ${MTT_SYS}_ident.${MTT_LANG}

echo:
	echo "sims: ${sims}"
	echo "model_reps: ${model_reps}"
	echo "sensitivity_reps: ${sensitivity_reps}"
	echo "ident_reps: ${ident_reps}"

${MTT_SYS}_ident.view: ${psfiles}
	ident_rep.sh ${MTT_SYS} view

${psfiles}: ${figfiles}
	ident_rep.sh ${MTT_SYS} ps
	touch ${psfiles}

${figfiles}: ${gdatfiles}
	ident_rep.sh ${MTT_SYS} fig
	touch ${figfiles}

${gdatfiles}: ${datfiles}
	ident_rep.sh ${MTT_SYS} gdat
	touch ${gdatfiles}

${datfiles} ${latexfiles}: ${ident_reps} ${ident_data} 
	ident_rep.sh ${MTT_SYS} dat2
	touch ${datfiles}

${MTT_SYS}_ident.m: 
	ident_rep.sh ${MTT_SYS} m

${MTT_SYS}_ident_numpar.m:
	ident_rep.sh ${MTT_SYS} numpar.m

## System model reps
## Generic txt files 
${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* txt

## Specific m files
${MTT_SYS}_ode2odes.m: ${model_pre}
	mtt -q -stdin ${MTT_OPTS} ${MTT_SYS} ode2odes m

${MTT_SYS}_sim.m: ${MTT_SYS}_ode2odes.m
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} sim m

## Numpar files
${MTT_SYS}_numpar.m:
	mtt ${MTT_SYS} numpar m

## Sympar files
${MTT_SYS}_sympar.m:
	mtt ${MTT_SYS} sympar m

## Generic txt to m
${MTT_SYS}_%.m: ${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* m

## r files
${MTT_SYS}_def.r: ${MTT_SYS}_abg.fig
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} def r

${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} rdae r

## Sensitivity model reps
## Generic txt files 
s${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} $* txt

## Specific m files
## Numpar files
s${MTT_SYS}_numpar.m:
	mtt -s s${MTT_SYS} numpar m

## Sympar files
s${MTT_SYS}_sympar.m:
	mtt -s s${MTT_SYS} sympar m

s${MTT_SYS}_ode2odes.m: ${sensitivity_pre}
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ode2odes m

s${MTT_SYS}_ssim.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ssim m

s${MTT_SYS}_def.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} def m


## Generic txt to m
s${MTT_SYS}_%.m: s${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* m

## r files
s${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} rdae r

Added mtt/lib/rep/ident_rep.sh version [13f8601111].






































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

## ident_rep.sh
## DIY representation "ident" for mtt
# Copyright (C) 2002 by Peter J. Gawthrop

ps=ps

sys=$1
rep=ident
lang=$2
mtt_parameters=$3
rep_parameters=$4

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_ident.dat2
dat2s_file=${sys}_idents.dat2
ident_numpar_file=${sys}_ident_numpar.m
option_file=${sys}_ident_mtt_options.txt

## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

check_new_options() {
    if [ -f "${option_file}" ]; then
	old_options=`cat ${option_file}`
        if [ "${mtt_options}" != "${old_options}" ]; then
	   echo ${mtt_options} > ${option_file}
	fi
    else
	echo ${mtt_options} > ${option_file}
    fi
}

## Make the _ident.m file
make_ident() {
filename=${sys}_${rep}.m
date=`date`
echo Creating ${filename}

cat > ${filename} <<EOF    
function [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)

  ## usage:  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)
  ##
  ## last      last time in run
  ## ppp_names Column vector of names of ppp params
  ## par_names Column vector of names of estimated params
  ## extras    Structure containing additional info
  ##
  ## Created by MTT on ${date}
 
  ## Sensitivity system name
  system_name = "s${sys}"

  ##Sanity check
  if nargin<3
    printf("Usage: [y,u,t] = ${sys}_ident(y,u,t,par_names,Q,extras);");
    return
  endif

  if nargin<6
    ## Set up optional parameters
    extras.criterion = 1e-3;
    extras.emulate_timing = 0;
    extras.max_iterations = 10;
    extras.simulate = 2;
    extras.v =  1e-2;
    extras.verbose = 1;
    extras.visual = 1;
  endif
  
  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  sympar  = ${sys}_sympar;
  simpar  = ${sys}_simpar;
  sympars  = s${sys}_sympar;
  simpars  = s${sys}_simpar;

  ## Parameter indices
  i_par = ppp_indices (par_names,sympar,sympars);

  ## Initial model state
  x_0 = zeros(2*n_x,1);

  ## Initial model parameters
  par_0 = s${sys}_numpar;

  ## Reset simulation parameters
  [n_data,m_data] = size(y);
  dt = t(2)-t(1);
  simpars.last = (n_data-1)*dt;
  simpars.dt = dt;

  ## Identification
  [epar,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpars,u,y,i_par,Q,extras);
  
  ## Do some plots
  figure(1);
  grid;
  title("Comparison of data");
  xlabel("t");
  ylabel("y");
  [N,M] = size(Y);
  y_est = Y(:,M-n_y+1:M);
  plot(t,y_est,"1;Estimated;", t,y,"3;Actual;");
  figfig("${sys}_ident_comparison");

  figure(2);
  [n_par,m_par] = size(Par);
  grid;
  title("Parameter estimates");
  xlabel("Iteration");
  ylabel("Estimates");
  plot(0:m_par-1, Par, 0:m_par-1, Par,"x");
  figfig("${sys}_ident_pars");

  ## Create a table of the parameters
  [n_par,m_par] = size(i_par);
  fid = fopen("${sys}_ident_par.tex", "w");
  fprintf(fid,"\\\\begin{table}[htbp]\\n");
  fprintf(fid," \\\\centering\\n");
  fprintf(fid," \\\\begin{tabular}{|l|l|}\\n");
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"  Name & Value \\\\\\\\ \\n");
  fprintf(fid,"  \\\\hline\\n");
  for i = 1:n_par
    fprintf(fid,"$%s$ & %4.2f \\\\\\\\ \\n", par_names(i,:), epar(i_par(i,1)));
  endfor
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"\\\\end{tabular}\\n");
  fprintf(fid,"\\\\caption{Estimated Parameters}\\n");
  fprintf(fid,"\\\\end{table}\\n");
  fclose(fid);

  ## Save the data for later use.
   par_values = epar(i_par(:,1));
   save ${sys}_ident_est_data.dat y_est Y par_names par_values
endfunction
EOF
}

make_ident_numpar() {
echo Creating ${ident_numpar_file}
cat > ${sys}_ident_numpar.m <<EOF
function [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;

  ## usage: [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  ## Edit for your own requirements
  ## Created by MTT on ${date}

    
  ## This section sets up the data source
  ## simulate = 0  Real data (you supply ${sys}_ident_data.dat)
  ## simulate = 1  Real data input, simulated output
  ## simulate = 2  Unit step input, simulated output
  simulate = 2;
  

  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  simpars = s${sys}_simpar;

  ## Access or create data
  if (simulate<2)		# Get the real data
    if (exist("${sys}_ident_data.dat")==2)
      printf("Loading ${sys}_ident_data.dat\n");
      load ${sys}_ident_data.dat
    else
      printf("Please create a loadable file ${sys}_ident_data.dat containing y,u and t\n");
      return
    endif
  else 
    switch simulate
      case 2			# Step simulation
	t = [0:simpars.dt:simpars.last]';
	u = ones(size(t));
      otherwise
	error(sprintf("simulate = %i not implemented", simulate));
    endswitch
  endif
  
  if (simulate>0)
    par = ${sys}_numpar();
    x_0 = ${sys}_state(par);
    dt = t(2)-t(1);
    simpars.dt = dt;
    simpars.last = t(length(t));
    y =  ${sys}_sim(zeros(n_x,1), par, simpars, u);
  endif

  ## Default parameter names - Put in your own here
  sympar = ${sys}_sympar;	# Symbolic params as structure
  par_names = struct_elements (sympar);	# Symbolic params as strings
  [n,m] = size(par_names);	# Size the string list

  ## Sort by index
  for [i,name] = sympar
    par_names(i,:) = sprintf("%s%s",name, blanks(m-length(name)));
  endfor
  
  ## Output weighting vector
  Q = ones(n_y,1);
  
  ## Extra parameters
  extras.criterion = 1e-5;
  extras.emulate_timing = 0;
  extras.max_iterations = 10;
  extras.simulate = simulate;
  extras.v =  1e-2;
  extras.verbose = 1;
  extras.visual = 1;
  extras.domain = "time";

endfunction
EOF
}

make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras);
  [N,M] = size(Y);
  y_est = Y(:,M);
  data = [t,y_est,u];
  save -ascii ${dat2_file} data
EOF

## Tidy up the latex stuff - convert foo_123 to foo_{123}
cat ${sys}_ident_par.tex > mtt_junk
sed  -e "s/_\([a-z0-9,]*\)/_{\1}/g" < mtt_junk >${sys}_ident_par.tex
rm mtt_junk
}

case ${lang} in
    numpar.m)
        ## Make the numpar stuff
        make_ident_numpar;
	;;
    m)
        ## Make the code
        make_ident;
	;;
    dat2)
        ## The dat2 language (output data) & fig file
	make_dat2; 
	;;
    gdat)
        cp ${dat2_file} ${dat2s_file} 
	dat22dat ${sys} ${rep} 
        dat2gdat ${sys} ${rep}
	;;
    fig)
        gdat2fig ${sys}_${rep}
	;;
    ps)
        figs=`ls ${sys}_ident*.fig | sed -e 's/\.fig//'`
	for fig in ${figs}; do
            fig2dev -Leps ${fig}.fig > ${fig}.ps
	done
	texs=`ls ${sys}_ident*.tex | sed -e 's/\.tex//'`
	for tex in ${texs}; do
          makedoc "" "${sys}" "ident_par" "tex" "" "" "$ps"
          doc2$ps ${sys}_ident_par "$documenttype"
	done
	;;
    view)
	pss=`ls ${sys}_ident*.ps` 
        echo Viewing ${pss}
        for ps in ${pss}; do
          ${PSVIEW} ${ps}&
	done
	;;
    *)
	echo Language ${lang} not supported by ${rep} representation
        exit 3
esac


Added mtt/lib/rep/ippp_rep.make version [7bb6eededb].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-makefile-*-
# Makefile for representation ippp - ppp system identification
# File ippp_rep.make

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.5  2002/12/12 17:18:42  geraint
  ## Fixed [ 647664 ] Namespace clash: LANG
  ## Prepended MTT_ to SYS, OPTS and LANG environment variables.
  ##
  ## Revision 1.4  2001/04/23 15:06:21  gawthrop
  ## Removed stdin bug workaround
  ##
  ## Revision 1.3  2001/04/11 07:52:45  gawthrop
  ## Temporary fix to avoid incorrect _input.cc with stdin
  ##
  ## Revision 1.2  2001/04/05 11:49:07  gawthrop
  ## Fixed a number of bugs to as to work with reports.
  ##
  ## Revision 1.1  2001/04/04 10:05:38  gawthrop
  ## Reresentation for system identification for ppp
  ##
  ###############################################################

#Copyright (C) 2000 by Peter J. Gawthrop

all: $(MTT_SYS)_ippp.$(MTT_LANG)

$(MTT_SYS)_ippp.view:  $(MTT_SYS)_ippp.pdf
	acroread *.pdf

$(MTT_SYS)_ippp.ps: $(MTT_SYS)_parameters.ps $(MTT_SYS)_error.ps $(MTT_SYS)_outputs.ps $(MTT_SYS)_ippp.pdf
	cp $(MTT_SYS)_parameters.ps $(MTT_SYS)_ippp.ps

$(MTT_SYS)_ippp.pdf: $(MTT_SYS)_parameters.pdf $(MTT_SYS)_error.pdf $(MTT_SYS)_outputs.pdf
	cp $(MTT_SYS)_parameters.pdf $(MTT_SYS)_ippp.pdf

$(MTT_SYS)_parameters.ps: s$(MTT_SYS)_ode2odes.m s$(MTT_SYS)_ssim.m $(MTT_SYS)_ippp.m s$(MTT_SYS)_sympar.m s$(MTT_SYS)_simpar.m
	octave $(MTT_SYS)_ippp.m

$(MTT_SYS)_error.ps: $(MTT_SYS)_parameters.ps
	touch $(MTT_SYS)_error.ps

$(MTT_SYS)_outputs.ps: $(MTT_SYS)_parameters.ps
	touch $(MTT_SYS)_outputs.ps

$(MTT_SYS)_parameters.pdf: s$(MTT_SYS)_ode2odes.m s$(MTT_SYS)_ssim.m $(MTT_SYS)_ippp.m s$(MTT_SYS)_sympar.m s$(MTT_SYS)_simpar.m
	octave $(MTT_SYS)_ippp.m

$(MTT_SYS)_error.pdf: $(MTT_SYS)_parameters.pdf
	touch $(MTT_SYS)_error.pdf

$(MTT_SYS)_outputs.pdf: $(MTT_SYS)_parameters.pdf
	touch $(MTT_SYS)_outputs.pdf

s$(MTT_SYS)_ode2odes.m: 
	echo Starting creation of s$(MTT_SYS)_ode2odes.m with options $(MTT_OPTS)
	mtt -q $(MTT_OPTS) -stdin -s s$(MTT_SYS) ode2odes m

s$(MTT_SYS)_ssim.m: s$(MTT_SYS)_def.m
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) ssim m

s$(MTT_SYS)_sympar.m:
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) sympar m

s$(MTT_SYS)_simpar.m:
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) simpar m

s$(MTT_SYS)_def.m:
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) def m

Added mtt/lib/rep/mtt_rep_diy version [8134d7ef8f].











































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

rep_name="diy"

help_message="
	A representation you can create all by yourself!

	The purpose of this representation is to help in the creation of a new DIY rep structure.
	Eventually it should form a template for creating new representations.
"

non_standard_options="
	--crash:	make the computer crash, wiping the hard drive in the process
	--recover:	attempt to recover data after crash (by crying very loudly for 10 minutes)
"

texi_message="
This message should be really, really helpful.
@node Stuff, More Stuff, Top, Top
Stuff!
@node More Stuff, Top, Top, Top
More Stuff
"

# function definitions for non-standard options (should have same name)
crash () {
    touch .crash
    echo "IDIOT!"
    exit 99
}
recover () {
    if [ -f .crash ]; then
	cat <<EOF
A long time ago
in galaxy far away
data can't be found
EOF
    else
	echo "Recovery worked - your data is safe!"
    fi
}
hello () {
    echo "Hello ${USER}!"
}

languages="ada c c++ fortran m pascal ps" # this is used for documentation only
process_language () {
    Language=$1
    case ${Language} in
	'c')
	    echo "C is a good language"
	    ;;
	'c')
	    echo "C++ is a great language"
	    ;;
	*)
	    exit ${ELanguageUnknown}
	    ;;
    esac
}

#####################################################################
###  It should not be necessary to edit anything below this line  ###
#####################################################################

# Error codes
ELanguageUnknown="-2"		# MTT will continue from here
ENoLanguageSpecified="-10"

help () {
    cat <<EOF

$0: help

	MTT representation ${rep_name}
${help_message}
EOF
}

usage () {
    cat <<EOF

$0: usage

	mtt [mtt_options] ${rep_name} [options] lang

	standard options:

	--help:		print useful help message
	--usage:	print this useful message
	--texi:		print very useful message

	additional options:
${non_standard_options}
EOF
}

texi () {
    cat <<EOF
@settitle MTT: ${rep_name} representation
${texi_message}
EOF
}

error () {
    cat <<EOF
*** Error: MTT (${rep_name}): $1 : exiting ($2)
EOF
    exit $2
}

warn () {
    cat <<EOF
*** Warning: MTT (${rep_name}): $1 : continuing
EOF
}

process_arguments () {
    if [ $# -eq 0 ]; then
	help
	usage
    else
	while [ -n "`echo $1 | grep '^--'`" ]; do
	    option=`echo $1 | sed 's/\-\-\(.*\)/\1/'`
	    ${option} 2> /dev/null || warn "option --${option} unknown"
	    shift
	done   
	export Language="$*"
    fi
}

process_arguments $*
if [ ! "${Language}" ]; then
    error "no language specified" ${NoLanguageSpecified}
fi

process_language ${Language}
	

Added mtt/lib/rep/nppp_rep.make version [53790be183].











































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-makefile-*-

#SUMMARY 	Nonlinear pole-placement predictive control (nPPP)
#DESCRIPTION 	

# Makefile for representation nppp
# File nppp_rep.make

#Copyright (C) 2000,2001,2002 by Peter J. Gawthrop

## Model targets
model_reps =  ${MTT_SYS}_sympar.m ${MTT_SYS}_simpar.m ${MTT_SYS}_state.m 
model_reps += ${MTT_SYS}_numpar.m ${MTT_SYS}_input.m ${MTT_SYS}_ode2odes.m  
model_reps += ${MTT_SYS}_def.m

## Prepend s to get the sensitivity targets
sensitivity_reps = ${model_reps:%=s%}

## Simulation targets
sims = ${MTT_SYS}_sim.m s${MTT_SYS}_ssim.m

## m-files needed for nppp
nppp_m = ${MTT_SYS}_nppp.m ${MTT_SYS}_nppp_numpar.m 

## Targets for the nppp simulation
nppp_reps = ${nppp_m} ${sims} ${model_reps} ${sensitivity_reps}

## ps output files
psfiles = ${MTT_SYS}_nppp.ps ${MTT_SYS}_nppp.basis.ps ${MTT_SYS}_nppp.par.ps ${MTT_SYS}_nppp.U.ps
figfiles = ${psfiles:%.ps=%.fig}

all: ${MTT_SYS}_nppp.${MTT_LANG}

echo:
	echo "sims: ${sims}"
	echo "model_reps: ${model_reps}"
	echo "sensitivity_reps: ${sensitivity_reps}"
	echo "nppp_reps: ${nppp_reps}"

${MTT_SYS}_nppp.view: ${MTT_SYS}_nppp.ps
	nppp_rep.sh ${MTT_SYS} view

${psfiles}: ${MTT_SYS}_nppp.fig
	nppp_rep.sh ${MTT_SYS} ps

${MTT_SYS}_nppp.gdat: ${MTT_SYS}_nppp.dat2
	nppp_rep.sh ${MTT_SYS} gdat

${MTT_SYS}_nppp.fig ${MTT_SYS}_nppp.dat2: ${nppp_reps}
	nppp_rep.sh ${MTT_SYS} dat2

${MTT_SYS}_nppp.m: 
	nppp_rep.sh ${MTT_SYS} m

${MTT_SYS}_nppp_numpar.m:
	nppp_rep.sh ${MTT_SYS} numpar.m

## System model reps
## Generic txt files 
${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* txt

## Specific m files
${MTT_SYS}_ode2odes.m: ${MTT_SYS}_rdae.r
	mtt -q -stdin ${MTT_OPTS} ${MTT_SYS} ode2odes m

${MTT_SYS}_sim.m: ${MTT_SYS}_ode2odes.m
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} sim m

## Generic txt to m
${MTT_SYS}_%.m: ${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* m

## r files
${MTT_SYS}_def.r: ${MTT_SYS}_abg.fig
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} def r

${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} rdae r

## Sensitivity model reps
## Generic txt files 
s${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* txt

## Specific m files
s${MTT_SYS}_ode2odes.m: s${MTT_SYS}_rdae.r
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ode2odes m

s${MTT_SYS}_ssim.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ssim m

s${MTT_SYS}_def.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} def m


## Generic txt to m
s${MTT_SYS}_%.m: s${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* m


## r files
s${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} rdae r


Added mtt/lib/rep/nppp_rep.sh version [08291d0b19].












































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

## nppp_rep.sh
## DIY representation "nppp" for mtt
# Copyright (C) 2002 by Peter J. Gawthrop

sys=$1
rep=nppp
lang=$2
mtt_parameters=$3
rep_parameters=$4

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_nppp.dat2
dat2s_file=${sys}_nppps.dat2
nppp_numpar_file=${sys}_nppp_numpar.m
option_file=${sys}_nppp_mtt_options.txt

## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

check_new_options() {
    if [ -f "${option_file}" ]; then
	old_options=`cat ${option_file}`
        if [ "${mtt_options}" != "${old_options}" ]; then
	   echo ${mtt_options} > ${option_file}
	fi
    else
	echo ${mtt_options} > ${option_file}
    fi
}

## Make the _nppp.m file
make_nppp() {
filename=${sys}_${rep}.m
echo Creating ${filename}

cat > ${filename} <<EOF    
function [y,u,t] = ${sys}_nppp (last, ppp_names, par_names, A_u, A_w, w, Q, extras)

  ## usage:  [y,u,t] = ${sys}_nppp (last, ppp_names, par_names, A_u, A_w, w, Q, extras)
  ##
  ## last      last time in run
  ## ppp_names Column vector of names of ppp params
  ## par_names Column vector of names of estimated params
  ## extras    Structure containing additional info

  ##Sanity check
  if nargin<2
    printf("Usage: [y,u,t] = ${sys}_nppp(N, ppp_names[, par_names, extras])\n");
    return
  endif

  if nargin<4
    ## Set up optional parameters
    extras.criterion = 1e-3;
    extras.emulate_timing = 0;
    extras.max_iterations = 15;
    extras.simulate = 1;
    extras.v =  1e-6;
    extras.verbose = 0;
    extras.visual = 1;
  endif
  
  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  sympar  = ${sys}_sympar;
  simpar  = ${sys}_simpar;
  sympars  = s${sys}_sympar;
  simpars  = s${sys}_simpar;
  t_ol = simpar.last;
    
  ## Number of intervals needed
  N = ceil(last/t_ol);

  ## Setpoints
  if extras.verbose
    printf("Open-loop interval %3.2f \n", simpar.last);
    printf(" -- using info in ${sys}_simpar.txt\n");
    printf("PPP optimisation from %3.2f to %3.2f\n", simpars.first, simpars.last);
    printf(" -- using info in s${sys}_simpar.txt\n");
  endif
  
  t_horizon = [simpars.first+simpars.dt:simpars.dt:simpars.last]';
  w_s = ones(length(t_horizon)-1,1)*w';

  ## Setup the indices of the adjustable stuff
  if nargin<2
    i_ppp = []
  else
    i_ppp = ppp_indices (ppp_names,sympar,sympars); # Parameters
  endif

  n_ppp = length(i_ppp(:,1));

  if nargin<3
    i_par = []
  else
    i_par = ppp_indices (par_names,sympar,sympars); # Parameters
  endif
  
    ## Do some simulations to check things out
    ## System itself
    par = ${sys}_numpar;
    x_0_ol = ${sys}_state(par);
    [y_ol,x_ol, t_ol] =  ${sys}_sim(x_0_ol, par, simpar, ones(1,n_u));
    simpar_OL = simpar;
    simpar_OL.last = simpars.last;
    [y_OL,x_OL, t_OL] =  ${sys}_sim(x_0_ol, par, simpar_OL, ones(1,n_u));

    pars = s${sys}_numpar;
    x_0_ppp = s${sys}_state(pars);
    [y_ppp,y_par,x_ppp, t_ppp] =  s${sys}_ssim(x_0_ppp, pars, simpars, ones(1,n_u));

    simpar_PPP = simpars;
    simpar_PPP.first = simpar.first;
    [y_PPP,y_par,x_PPP, t_PPP] =  s${sys}_ssim(x_0_ppp, pars, simpar_PPP, ones(1,n_u));

    ## Basis functions
    Us = ppp_ustar(A_u,1,t_OL',0,0)';


  if extras.visual		#Show some graphs
    figure(2); 	
    grid; title("Outputs of ${sys}_sim and s${sys}_ssim");
    plot(t_ol,y_ol, '*', t_ppp, y_ppp, '+', t_OL, y_OL, t_PPP, y_PPP);


    figure(3); 	
    grid; title("Basis functions");
    plot(t_OL, Us);

  endif



  ## Do it
  [y,u,t,P,U,t_open,t_ppp,t_est,its_ppp,its_est] \
      = ppp_nlin_run ("${sys}",i_ppp,i_par,A_u,w_s,N,Q,extras);

  ## Compute values at ends of ol intervals
  T_open = cumsum(t_open);
  T_open = T_open(1:length(T_open)-1); # Last point not in t
  j=[];
  for i = 1:length(T_open)
    j = [j; find(T_open(i)*ones(size(t))==t)];
  endfor
  y_open = y(j,:);
  u_open = u(j,:);

  ## Plots

    gset nokey
    gset nogrid
    #eval(sprintf("gset xtics %g", simpar.last));
    #gset noytics
    gset format x "%.1f"
    gset format y "%.2f"
    gset term fig monochrome portrait fontsize 20 size 20 20 metric \
	     thickness 4
    gset output "${sys}_nppp.fig"

    title("");
    xlabel("Time (s)");
    ylabel("u");
    subplot(2,1,2); plot(t,u,'-',  T_open, u_open,"+");
    #subplot(2,1,2); plot(t,u);   
    ylabel("y");
    subplot(2,1,1); plot(t,y,'-',  T_open, y_open,"+"); 
    #subplot(2,1,1); plot(t,y); 
    oneplot;
    gset term fig monochrome portrait fontsize 20 size 20 10 metric \
	     thickness 4
    gset output "${sys}_nppp.basis.fig"
    title("");
    xlabel("Time (s)");
    ylabel("Basis functions");
    plot(t_OL, Us);


    ## Create plot against time
    TTT = [ [0;T_open] [T_open; last] ]';
    TT = TTT(:);

    [n,m] = size(P);
    if m>0
      P = P(1:n-1,:);  # Loose last point
      PP = [];
      for j=1:m
        pp = [P(:,j) P(:,j)]';
        PP = [PP pp(:)];
      endfor

      oneplot;
      gset output "${sys}_nppp.par.fig"
      title("");
      xlabel("Time (s)");
      ylabel("Parameters");
      plot(TT,PP);
    endif

    [n,m] = size(U);
    if m>0    oneplot;
      gset output "${sys}_nppp.U.fig"
      title("");
      xlabel("Time (s)");
      ylabel("U");
      [n,m] = size(U);
      U = U(1:n-1,:);  # Loose last point
      UU = [];
      for j=1:m
        uu = [U(:,j) U(:,j)]';
        UU = [UU uu(:)];
      endfor
      plot(TT,UU);
    endif

endfunction

EOF
}

make_nppp_numpar() {
echo Creating ${nppp_numpar_file}
cat > ${sys}_nppp_numpar.m <<EOF
function [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar 

## usage:  [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar ()
##
## 

  ## Last time of run
  last = 10;

  ## Specify basis functions
  A_w = zeros(1,1);
  n_ppp = ${nu};
  A_u = ppp_aug(A_w,laguerre_matrix(n_ppp-1,2.0));

 
  ## Names of ppp parameters
  ppp_names = "";
  for i=1:n_ppp
    name = sprintf("ppp_%i", i);
    ppp_names = [ppp_names; name];
  endfor

  ## Estimated parameters
  par_names = [];

  ## Weights
  Q = ones(${ny},1);

  ## Setpoint
  w = zeros(${ny},1); w(1) = 1;

  ## Set up optional parameters
  extras.criterion = 1e-3;
  extras.emulate_timing = 0;
  extras.max_iterations = 15;
  extras.simulate = 1;
  extras.v =  1e-6;
  extras.verbose = 0;
  extras.visual = 0;

endfunction
EOF
}

make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar;
  [y,u,t] = ${sys}_nppp(last, ppp_names, par_names, A_u, A_w, w, Q, extras);
  data = [t,y,u];
  save -ascii ${dat2_file} data
EOF
}

case ${lang} in
    numpar.m)
        ## Make the numpar stuff
        make_nppp_numpar;
	;;
    m)
        ## Make the code
        make_nppp;
	;;
    dat2|fig|basis.fig|par.fig|U.fig)
        ## The dat2 language (output data) & fig file
        rm ${sys}_nppp*.fig
	make_dat2; 
	;;
    gdat)
        cp ${dat2_file} ${dat2s_file} 
	dat22dat ${sys} ${rep} 
        dat2gdat ${sys} ${rep}
	;;
    ps|basis.ps|par.ps|U.ps)
        figs=`ls ${sys}_nppp*.fig | sed -e 's/\.fig//'`
        echo $figs
	for fig in ${figs}; do
            fig2dev -Leps ${fig}.fig > ${fig}.ps
	done
	;;
    view)
	pss=`ls ${sys}_nppp*.ps` 
        echo Viewing ${pss}
        for ps in ${pss}; do
          gv ${ps}&
	done
	;;
    *)
	echo Language ${lang} not supported by ${rep} representation
        exit 3
esac


Added mtt/lib/rep/odeso_rep.make version [069699a344].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
# -*-makefile-*-

all: ${MTT_SYS}_odeso.${MTT_LANG}

${MTT_SYS}_odeso.gnuplot:
	@mtt -q ${MTT_OPTS} ${MTT_SYS} gnuplot view

ifneq ("${MTT_LANG}","gnuplot")
${MTT_SYS}_odeso.${MTT_LANG}:
	@touch odeso_rep.make.ignore
	@mtt -q ${MTT_OPTS} ${MTT_SYS} odeso ${MTT_LANG}
	@rm odeso_rep.make.ignore
endif

Added mtt/lib/rep/sfun_rep.make version [a81b02cdc5].





1
2
3
4
+
+
+
+
# -*-makefile-*-

all:
	${MTT_REP}/sfun_rep.sh "$(MTT_OPTS)" "$(MTT_SYS)" "$(MTT_LANG)"

Added mtt/lib/rep/sfun_rep.sh version [4e120748b1].








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

set -e

#
# function definitions
#


set_debug ()
{
    debug=$1
    if ( $debug ); then
	set -x
	make_debug='--debug=a'
    else
	set +x
	make_debug=''
    fi
}

exit_error ()
{
    message="$1"
    case $message in
	"Invalid Input"		) errno =  2 ;;
	"Unknown Template"	) errno =  3 ;;
	*			) errno = -1 ;;
    esac
    echo "#Error: " $message
    exit errno;
}       

check_for_valid_input ()
{
    return 0;
}

#
# file templates
#

# template_README      	compilation instructions
# template_mdk		simulink sub-system model

# template_mex_ae_c
# template_sfun_c
# template_sfun_debug_h
# template_sfun_input_c
# template_sfun_interface_c

write_template ()
{
    filename="$1"

    case $filename in

	README)

	    cat <<EOF
To build a Simulink funtion of the <mtt_model_name> model without using MTT:

mex <mtt_model_name>_sfun.c

The input block can be created with:

mex <mtt_model_name>_sfun_input.c

If numerical solution of algebraic equations is also required:

mex <mtt_model_name>_sfun_ae.c

The interface block can be created with

mex <mtt_model_name>_sfun_interface.c

EOF
	    ;;

	mdl)

	    cat <<EOF
Model {
  Name			  "<mtt_model_name>"
  Version		  4.00
  SampleTimeColors	  off
  LibraryLinkDisplay	  "all"
  WideLines		  off
  ShowLineDimensions	  on
  ShowPortDataTypes	  off
  ShowStorageClass	  off
  ExecutionOrder	  off
  RecordCoverage	  off
  CovPath		  "/"
  CovSaveName		  "covdata"
  CovMetricSettings	  "dw"
  CovNameIncrementing	  off
  CovHtmlReporting	  on
  BlockNameDataTip	  off
  BlockParametersDataTip  off
  BlockDescriptionStringDataTip	off
  ToolBar		  on
  StatusBar		  on
  BrowserShowLibraryLinks off
  BrowserLookUnderMasks	  off
  Created		  "Mon May 20 13:21:21 2002"
  Creator		  "geraint"
  UpdateHistory		  "UpdateHistoryNever"
  ModifiedByFormat	  "%<Auto>"
  LastModifiedBy	  "geraint"
  ModifiedDateFormat	  "%<Auto>"
  LastModifiedDate	  "Thu May 23 16:35:42 2002"
  ModelVersionFormat	  "1.%<AutoIncrement:13>"
  ConfigurationManager	  "None"
  SimParamPage		  "Solver"
  StartTime		  "0.0"
  StopTime		  "10.0"
  SolverMode		  "Auto"
  Solver		  "ode45"
  RelTol		  "1e-3"
  AbsTol		  "auto"
  Refine		  "1"
  MaxStep		  "auto"
  MinStep		  "auto"
  MaxNumMinSteps	  "-1"
  InitialStep		  "auto"
  FixedStep		  "auto"
  MaxOrder		  5
  OutputOption		  "RefineOutputTimes"
  OutputTimes		  "[]"
  LoadExternalInput	  off
  ExternalInput		  "[t, u]"
  SaveTime		  on
  TimeSaveName		  "tout"
  SaveState		  off
  StateSaveName		  "xout"
  SaveOutput		  on
  OutputSaveName	  "yout"
  LoadInitialState	  off
  InitialState		  "xInitial"
  SaveFinalState	  off
  FinalStateName	  "xFinal"
  SaveFormat		  "Array"
  LimitDataPoints	  on
  MaxDataPoints		  "1000"
  Decimation		  "1"
  AlgebraicLoopMsg	  "warning"
  MinStepSizeMsg	  "warning"
  UnconnectedInputMsg	  "warning"
  UnconnectedOutputMsg	  "warning"
  UnconnectedLineMsg	  "warning"
  InheritedTsInSrcMsg	  "warning"
  SingleTaskRateTransMsg  "none"
  MultiTaskRateTransMsg	  "error"
  IntegerOverflowMsg	  "warning"
  CheckForMatrixSingularity "none"
  UnnecessaryDatatypeConvMsg "none"
  Int32ToFloatConvMsg	  "warning"
  InvalidFcnCallConnMsg	  "error"
  SignalLabelMismatchMsg  "none"
  LinearizationMsg	  "none"
  VectorMatrixConversionMsg "none"
  SfunCompatibilityCheckMsg "none"
  BlockPriorityViolationMsg "warning"
  ArrayBoundsChecking	  "none"
  ConsistencyChecking	  "none"
  ZeroCross		  on
  Profile		  off
  SimulationMode	  "normal"
  RTWSystemTargetFile	  "grt.tlc"
  RTWInlineParameters	  off
  RTWRetainRTWFile	  off
  RTWTemplateMakefile	  "grt_default_tmf"
  RTWMakeCommand	  "make_rtw"
  RTWGenerateCodeOnly	  off
  TLCProfiler		  off
  TLCDebug		  off
  TLCCoverage		  off
  AccelSystemTargetFile	  "accel.tlc"
  AccelTemplateMakefile	  "accel_default_tmf"
  AccelMakeCommand	  "make_rtw"
  TryForcingSFcnDF	  off
  ExtModeMexFile	  "ext_comm"
  ExtModeBatchMode	  off
  ExtModeTrigType	  "manual"
  ExtModeTrigMode	  "normal"
  ExtModeTrigPort	  "1"
  ExtModeTrigElement	  "any"
  ExtModeTrigDuration	  1000
  ExtModeTrigHoldOff	  0
  ExtModeTrigDelay	  0
  ExtModeTrigDirection	  "rising"
  ExtModeTrigLevel	  0
  ExtModeArchiveMode	  "off"
  ExtModeAutoIncOneShot	  off
  ExtModeIncDirWhenArm	  off
  ExtModeAddSuffixToVar	  off
  ExtModeWriteAllDataToWs off
  ExtModeArmWhenConnect	  on
  ExtModeSkipDownloadWhenConnect off
  ExtModeLogAll		  on
  ExtModeAutoUpdateStatusClock off
  OptimizeBlockIOStorage  on
  BufferReuse		  on
  ParameterPooling	  on
  BlockReductionOpt	  on
  RTWExpressionDepthLimit 5
  BooleanDataType	  off
  BlockDefaults {
    Orientation		    "right"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    NamePlacement	    "normal"
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
    ShowName		    on
  }
  AnnotationDefaults {
    HorizontalAlignment	    "center"
    VerticalAlignment	    "middle"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  LineDefaults {
    FontName		    "Helvetica"
    FontSize		    9
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  System {
    Name		    "<mtt_model_name>"
    Location		    [51, 441, 346, 574]
    Open		    on
    ModelBrowserVisibility  off
    ModelBrowserWidth	    200
    ScreenColor		    "white"
    PaperOrientation	    "landscape"
    PaperPositionMode	    "auto"
    PaperType		    "usletter"
    PaperUnits		    "inches"
    ZoomFactor		    "100"
    ReportName		    "simulink-default.rpt"
    Block {
      BlockType		      Inport
      Name		      "In1"
      Position		      [25, 43, 55, 57]
      Port		      "1"
      LatchInput	      off
      DataType		      "double"
      SignalType	      "real"
      Interpolate	      on
    }
    Block {
      BlockType		      SubSystem
      Name		      "MTT Model\n<mtt_model_name>"
      Ports		      [1, 1]
      Position		      [100, 20, 140, 80]
      ForegroundColor	      "blue"
      BackgroundColor	      "lightBlue"
      ShowPortLabels	      on
      TreatAsAtomicUnit	      off
      RTWSystemCode	      "Auto"
      RTWFcnNameOpts	      "Auto"
      RTWFileNameOpts	      "Auto"
      System {
	Name			"MTT Model\n<mtt_model_name>"
	Location		[45, 448, 1008, 720]
	Open			off
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"white"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"usletter"
	PaperUnits		"inches"
	ZoomFactor		"100"
	Block {
	  BlockType		  Inport
	  Name			  "In1"
	  Position		  [590, 203, 620, 217]
	  Port			  "1"
	  LatchInput		  off
	  DataType		  "double"
	  SignalType		  "real"
	  Interpolate		  on
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Model Inputs"
	  Ports			  [1, 1]
	  Position		  [390, 59, 565, 91]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_input"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT  Model Inputs: MTTU"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Plant Model"
	  Ports			  [1, 2]
	  Position		  [65, 61, 250, 199]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT Model States: MTTX"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	  Port {
	    PortNumber		    2
	    Name		    "MTT Model Outputs: MTTY"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "S-Function"
	  Ports			  [4, 2]
	  Position		  [710, 47, 840, 238]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_interface"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	}
	Block {
	  BlockType		  Outport
	  Name			  "Out1"
	  Position		  [905, 183, 935, 197]
	  Port			  "1"
	  OutputWhenDisabled	  "held"
	  InitialOutput		  "[]"
	}
	Line {
	  Name			  "MTT Model States: MTTX"
	  Labels		  [2, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  1
	  Points		  [0, 0; 105, 0]
	  Branch {
	    Points		    [0, -20]
	    DstBlock		    "MTT Model Inputs"
	    DstPort		    1
	  }
	  Branch {
	    Points		    [0, 25]
	    DstBlock		    "S-Function"
	    DstPort		    2
	  }
	}
	Line {
	  Name			  "MTT Model Outputs: MTTY"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  2
	  DstBlock		  "S-Function"
	  DstPort		  3
	}
	Line {
	  Name			  "MTT  Model Inputs: MTTU"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Model Inputs"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  1
	  Points		  [30, 0; 0, -70; -850, 0; 0, 105]
	  DstBlock		  "MTT Plant Model"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "In1"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  4
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  2
	  DstBlock		  "Out1"
	  DstPort		  1
	}
      }
    }
    Block {
      BlockType		      Outport
      Name		      "Out1"
      Position		      [185, 43, 215, 57]
      Port		      "1"
      OutputWhenDisabled      "held"
      InitialOutput	      "[]"
    }
    Line {
      SrcBlock		      "MTT Model\n<mtt_model_name>"
      SrcPort		      1
      DstBlock		      "Out1"
      DstPort		      1
    }
    Line {
      SrcBlock		      "In1"
      SrcPort		      1
      DstBlock		      "MTT Model\n<mtt_model_name>"
      DstPort		      1
    }
  }
}

EOF
	    ;;

	mex_ae.c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_ae.c:
 * Matlab mex algebraic equations for <mtt_model_name>
 */

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <mex.h>
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

/* utility procedures */

double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

/* system equations */

static double *
<mtt_model_name>_ae (double *mttyz,
		     const double *mttx,
		     const double *mttu,
		     const double mttt,
		     const double *mttpar)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

/* generic mex function */

#ifdef __cplusplus
extern "C" {
#endif

void
mexFunction (int nlhs, mxArray *plhs[],
	     int nrhs, const mxArray *prhs[])
{
  double *mttyz;		/* residuals */

  double *mttx;			/* states */
  double *mttu;			/* known + unknown inputs */
  double mttt;			/* time */
  double *mttpar;		/* parameters */

  unsigned int i;
  double *p;

  PRINT_ENTER;

  mttyz		= array_of_double (MTTNYZ);

  mttx		= array_of_double (MTTNX);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttpar	= array_of_double (MTTNPAR);

  /* get trial values */
  p = mxGetPr (prhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* get states */
  p = mxGetPr (prhs[1]);
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = p[i];
  }

  /* get known inputs */
  p = mxGetPr (prhs[2]);
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = p[i];
  }

  /* get time */
  p = mxGetPr (prhs[3]);
  mttt = *p;

  /* get parameters */
  p = mxGetPr (prhs[4]);
  for (i = 0; i < MTTNPAR; i++) {
    mttpar[i] = p[i];
  }
  
  /* evaluate residuals */
  <mtt_model_name>_ae (mttyz, mttx, mttu, mttt, mttpar);
  
  /* return residuals */
  plhs[0] = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  p = mxGetPr (plhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = mttyz[i];
  }

  /* release memory */
  free (mttx);
  free (mttu);
  free (mttpar);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef __cplusplus
}
#endif

EOF
	    ;;

	sfun_c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun.c:
 * Matlab S-function simulation of <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttdx;		/* pointer to rates */
static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double *mttyz;		/* pointer to residuals */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_ae (void)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_ode (void)
{
#include "<mtt_model_name>_ode.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_odeo (void)
{
#include "<mtt_model_name>_odeo.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_state (void)
{
#include "<mtt_model_name>_state.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttdx		= array_of_double (MTTNX);
  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);
  mttyz		= array_of_double (MTTNYZ);

  PRINT_LEAVE;
}

static void
update_states_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = ssGetContStates (S)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_solver (void)
{
  mxArray *MTT_MATLAB_P;
  mxArray *MTT_MATLAB_T;
  mxArray *MTT_MATLAB_U;
  mxArray *MTT_MATLAB_Ui;
  mxArray *MTT_MATLAB_X;

  double *p;

  PRINT_ENTER;

  /* starting value for solver - start with zero */
  MTT_MATLAB_Ui = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  mxSetName (MTT_MATLAB_Ui, "MTT_Ui");
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = 0.0;
  }
  mexPutArray (MTT_MATLAB_Ui, "base");

  /* put states into matlab workspace */
  MTT_MATLAB_X = mxCreateDoubleMatrix (MTTNX, 1, mxREAL);
  mxSetName (MTT_MATLAB_X, "MTT_X");
  p = mxGetPr (MTT_MATLAB_X);
  for (i = 0; i < MTTNX; i++) {
    p[i] = mttx[i];
  }
  mexPutArray (MTT_MATLAB_X, "base");

  /* put known inputs into matlab workspace */
  MTT_MATLAB_U = mxCreateDoubleMatrix (MTTNU, 1, mxREAL);
  mxSetName (MTT_MATLAB_U, "MTT_U");
  p = mxGetPr (MTT_MATLAB_U);
  for (i = 0; i < MTTNU; i++) {
    p[i] = mttu[i];
  }
  mexPutArray (MTT_MATLAB_U, "base");

  /* put time into matlab workspace */
  MTT_MATLAB_T = mxCreateDoubleMatrix (1, 1, mxREAL);
  mxSetName (MTT_MATLAB_T, "MTT_T");
  *mxGetPr (MTT_MATLAB_T) = mttt;
  mexPutArray (MTT_MATLAB_T, "base");

  /* put parameters into matlab workspace */
  MTT_MATLAB_P = mxCreateDoubleMatrix (MTTNPAR, 1, mxREAL);
  mxSetName (MTT_MATLAB_P, "MTT_P");
  p = mxGetPr (MTT_MATLAB_P);
  for (i = 0; i < MTTNPAR; i++) {
    p[i] = mttpar[i];
  }
  mexPutArray (MTT_MATLAB_P, "base");

  /* call fsolve */
  mexEvalString ("MTT_Ui = fsolve (@<mtt_model_name>_sfun_ae, MTT_Ui, optimset('display','off'), MTT_X, MTT_U, MTT_T, MTT_P);");

  /* retrieve result */
  MTT_MATLAB_Ui = mexGetArray ("MTT_Ui", "base");
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* free memory */
  mxDestroyArray (MTT_MATLAB_P);
  mxDestroyArray (MTT_MATLAB_T);
  mxDestroyArray (MTT_MATLAB_U);
  mxDestroyArray (MTT_MATLAB_Ui);
  mxDestroyArray (MTT_MATLAB_X);

  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, MTTNX);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortDirectFeedThrough(S, 0, 1);

  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNX);
  ssSetOutputPortWidth(S, 1, MTTNY);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);

  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;

  <mtt_model_name>_numpar ();
  <mtt_model_name>_state ();

  for (i = 0; i < MTTNX; i++) {
    ssGetContStates (S)[i] = mttx[i];
  }

  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  }
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_odeo ();

  for (i = 0; i < MTTNX; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttx[i];
  }

  for (i = 0; i < MTTNY; i++) {
      ssGetOutputPortRealSignal (S, 1)[i] = mtty[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
    
  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  } 
  update_simtime_from_simulink (S);

  <mtt_model_name>_ode ();

  for (i = 0; i < MTTNX; i++) {
    ssGetdX (S)[i] = mttdx[i];
  }

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;
  UNUSED_ARG(S);

  free (mttdx);
  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

EOF
	    ;;

	sfun_debug.h)

	    cat <<EOF

#ifndef HAVE_SFUN_DEBUG_H
#define HAVE_SFUN_DEBUG_H


#if defined DEBUG && defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered '%s'\n", __FUNCTION__);
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving '%s'\n", __FUNCTION__);

#elif defined DEBUG && ! defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered a function\n");
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving a function\n");

#elif ! defined DEBUG

#define PRINT_ENTER
#define PRINT_LEAVE

#else

#error "Momentary lapse of logic : unreachable statement reached"

#endif


#endif /* HAVE_SFUN_DEBUG_H */

EOF
	    ;;

	sfun_input.c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_input.c:
 * Matlab S-function inputs for <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun_input
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_input (void)
{
#include "<mtt_model_name>_input.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNX);
  ssSetInputPortDirectFeedThrough(S, 0, 1);
    
  if (!ssSetNumOutputPorts(S, 1)) return;
  ssSetOutputPortWidth(S, 0, MTTNU);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_input ();

  for (i = 0; i < MTTNU; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

EOF
	    ;;

	sfun_interface.c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_interface.c:
 * Matlab S-function to process inputs and outputs of <mtt_model_name>
 */


#define S_FUNCTION_NAME <mtt_model_name>_sfun_interface
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static double *controller_inputs;
static double *controller_outputs;

static unsigned int i;		/* loop counter */

/* Start EDIT */
/* Edit this block to define the number of controller inputs, outputs and parameters */
const int NumberOfControllerInputs	= 1; /* inputs TO controller */
const int NumberOfControllerOutputs	= 1; /* outputs FROM controller */
/* End EDIT */

static void
<mtt_model_name>_process_inputs (void)
{
  /* insert <mtt_model_name>_struc.c */

  /* Start EDIT */
  /* Edit this block to process the model inputs and outputs */
  
  /* Remove the following line */
  fprintf (stderr, "*** Error: <mtt_model_name>_sfun_interface.c has not been customised!\n"); return;

  /* simple example follows */

  /* Get total of all outputs and input to controller */
  controller_inputs[0] = 0.0;
  for (i = 0; i < MTTNY; i++) {
    controller_inputs[0] += mtty[i];
  }

  /* overwrite first model input with output from controller */
  mttu[0] = controller_outputs[0];

  /* End EDIT */
}


/******************************************************************************
 *                DO NOT EDIT ANYTHING BELOW THIS LINE                        *
 ******************************************************************************/

/* system equations */

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  controller_inputs	= array_of_double (NumberOfControllerInputs);
  controller_outputs	= array_of_double (NumberOfControllerOutputs);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 1)[i];
  }
  for (i = 0; i < MTTNY; i++) {
    mtty[i] = *ssGetInputPortRealSignalPtrs (S, 2)[i];
  }
  for (i = 0; i < NumberOfControllerOutputs; i++) {
    controller_outputs[i] = *ssGetInputPortRealSignalPtrs (S, 3)[i];
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 4)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortWidth(S, 1, MTTNX);
  ssSetInputPortWidth(S, 2, MTTNY);
  ssSetInputPortWidth(S, 3, NumberOfControllerOutputs);	/* inputs from controller */
  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetInputPortDirectFeedThrough(S, 1, 1);
  ssSetInputPortDirectFeedThrough(S, 2, 1);
  ssSetInputPortDirectFeedThrough(S, 3, 1);
    
  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNU); /* altered inputs */
  ssSetOutputPortWidth(S, 1, NumberOfControllerInputs); /* outputs to controller */
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  <mtt_model_name>_process_inputs ();

  UNUSED_ARG(tid); /* not used in single tasking mode */

  for (i = 0; i < MTTNU; i++) {
    ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }
  
  for (i = 0; i < NumberOfControllerInputs; i++) {
    ssGetOutputPortRealSignal (S, 1)[i] = controller_inputs[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  free (controller_inputs);
  free (controller_outputs);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

EOF
	    ;;

	*)
	    exit_error "Unknown Template";
	    ;;

    esac
}	    







### main program

set_debug false
check_for_valid_input "$*"

MTT_OPTS="$1" MTT_SYS="$2" MTT_LANG="$3" make $make_debug -f ${MTT_REP}/sfun_rep/Makefile ${2}_sfun.${3}
exit 0

Added mtt/lib/rep/sfun_rep/Makefile version [b56d0c54fd].










































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/make -f

all: $(MTT_SYS)_sfun.mexglx

$(MTT_SYS)_sfun.mexglx: $(MTT_SYS)_sfun.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h $(MTT_SYS)_numpar.c $(MTT_SYS)_ode.c $(MTT_SYS)_odeo.c $(MTT_SYS)_state.c $(MTT_SYS)_sfun_ae.mexglx $(MTT_SYS)_sfun_input.mexglx $(MTT_SYS)_sfun_interface.mexglx $(MTT_SYS).mdl
	echo Creating $@
	mex $(MTT_SYS)_sfun.c
	cp *_sfun*mexglx $(MTT_SYS).mdl ..

$(MTT_SYS)_sfun.c:: ${MTT_REP}/sfun_rep/sfun.c.tmpl $(MTT_SYS)_def.r
	echo Creating $@
	cat $< | sed 's/<mtt_model_name>/$(MTT_SYS)/g' |\
	sed s/\<have_algebraic_equations\>/`mtt_getsize $(MTT_SYS) yz`/ > $@

$(MTT_SYS)_sfun_ae.mexglx: $(MTT_SYS)_sfun_ae.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h $(MTT_SYS)_ae.c
	echo Creating $@
	mex $(MTT_SYS)_sfun_ae.c

$(MTT_SYS)_sfun_ae.c:: ${MTT_REP}/sfun_rep/mex_ae.c.tmpl $(MTT_SYS)_def.r
	echo Creating $@
	cat $< | sed 's/<mtt_model_name>/$(MTT_SYS)/g' |\
	sed s/\<have_algebraic_equations\>/`mtt_getsize $(MTT_SYS) yz`/ > $@

$(MTT_SYS)_sfun_input.mexglx: $(MTT_SYS)_sfun_input.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h $(MTT_SYS)_input.c $(MTT_SYS)_numpar.c
	echo Creating $@
	mex $(MTT_SYS)_sfun_input.c

$(MTT_SYS)_sfun_input.c:: ${MTT_REP}/sfun_rep/sfun_input.c.tmpl
	echo Creating $@
	cat $^ | sed 's/<mtt_model_name>/$(MTT_SYS)/g' > $@

$(MTT_SYS)_sfun_interface.mexglx: $(MTT_SYS)_sfun_interface.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_numpar.c
	echo Creating $@
	mex $(MTT_SYS)_sfun_interface.c

$(MTT_SYS)_sfun_interface.c: ${MTT_REP}/sfun_rep/sfun_interface.c.tmpl $(MTT_SYS)_struc.c
	echo Creating $@
	cat ${MTT_REP}/sfun_rep/sfun_interface.c.tmpl	|\
	 sed 's/<mtt_model_name>/$(MTT_SYS)/g'		|\
	 ${MTT_REP}/sfun_rep/insert_file.sh > $@

$(MTT_SYS)_sfun.zip: $(MTT_SYS)_sfun.c sfun_debug.h useful-functions.hh $(MTT_SYS)_sfun_ae.c $(MTT_SYS)_sfun_input.c $(MTT_SYS)_sfun_interface.c \
	 $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h\
	 $(MTT_SYS)_ae.c $(MTT_SYS)_input.c $(MTT_SYS)_numpar.c $(MTT_SYS)_ode.c $(MTT_SYS)_odeo.c $(MTT_SYS)_state.c \
	 $(MTT_SYS).mdl README
	echo Creating $@
	zip $@ $^

$(MTT_SYS).mdl: ${MTT_REP}/sfun_rep/mdl.tmpl
	echo Creating $@
	cat $^ | sed 's/<mtt_model_name>/$(MTT_SYS)/g' > $@

README:: ${MTT_REP}/sfun_rep/README.tmpl README.CVS
	echo Creating $@
	date > $@
	cat $^ | sed 's/<mtt_model_name>/$(MTT_SYS)/g' >> $@
	rm -f README.CVS

README.CVS:
	echo Getting CVS status
	(cvs status ../$(MTT_SYS)_abg.fig || echo -e "\n$(MTT_SYS)_abg.fig is not under CVS\n") > $@ 2>1

$(MTT_SYS)_ae.c: $(MTT_SYS)_ae.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) ae c cat 

$(MTT_SYS)_input.c: $(MTT_SYS)_input.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) input c cat 

$(MTT_SYS)_numpar.c: $(MTT_SYS)_numpar.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) numpar c cat

$(MTT_SYS)_ode.c: $(MTT_SYS)_ode.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) ode c cat

$(MTT_SYS)_odeo.c: $(MTT_SYS)_odeo.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) odeo c cat

$(MTT_SYS)_state.c: $(MTT_SYS)_state.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) state c cat

$(MTT_SYS)_struc.c: $(MTT_SYS)_struc.txt
	echo Creating $@
	gawk '\
($$1 == "input")  { printf "         double *%s\t= &(mttu[%d]);\t/* input and output */\n", $$4, $$2-1 }\
($$1 == "state")  { printf "   const double *_%s\t= &(mttx[%d]);\t/* input */\n", $$4, $$2-1 }\
($$1 == "output") { printf "   const double *_%s\t= &(mtty[%d]);\t/* input */\n", $$4, $$2-1 }\
($$1 != "input" && $$1 != "state" && $$1 != "output") { }\
	' $^ > $@

sfun_debug.h:: ${MTT_REP}/sfun_rep/sfun_debug.h
	echo Copying $@
	cp $^ $@

useful-functions.hh:: ${MTT_CC}/include/useful-functions.hh
	echo Copying $@
	cp $^ $@

%::
	mtt -cc -q $(MTT_OPTS) `echo $* | sed 's/\(.*\)_\(.*\)\.\(.*\)/\1 \2 \3/'`

Added mtt/lib/rep/sfun_rep/README.tmpl version [b5c86b874f].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

To build a Simulink funtion of the <mtt_model_name> model without using MTT:

mex -I. <mtt_model_name>_sfun.c

The input block can be created with:

mex -I. <mtt_model_name>_sfun_input.c

If numerical solution of algebraic equations is also required:

mex -I. <mtt_model_name>_sfun_ae.c

The interface block can be created with

mex -I. <mtt_model_name>_sfun_interface.c

Added mtt/lib/rep/sfun_rep/insert_file.sh version [25cb36fec8].





1
2
3
4
+
+
+
+
#! /usr/bin/gawk -f
# script to replace the line: "/* insert filename */" with the contents of file "filename"
($1 != "/*" || $2 != "insert" || $4 != "*/") { print }
($1 == "/*" && $2 == "insert" && $4 == "*/") { cmd = "cat " $3 ; system(cmd) }

Added mtt/lib/rep/sfun_rep/mdl.tmpl version [97145b618f].






























































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Model {
  Name			  "mdl"
  Version		  4.00
  SampleTimeColors	  off
  LibraryLinkDisplay	  "all"
  WideLines		  off
  ShowLineDimensions	  on
  ShowPortDataTypes	  off
  ShowStorageClass	  off
  ExecutionOrder	  off
  RecordCoverage	  off
  CovPath		  "/"
  CovSaveName		  "covdata"
  CovMetricSettings	  "dw"
  CovNameIncrementing	  off
  CovHtmlReporting	  on
  BlockNameDataTip	  off
  BlockParametersDataTip  off
  BlockDescriptionStringDataTip	off
  ToolBar		  on
  StatusBar		  on
  BrowserShowLibraryLinks off
  BrowserLookUnderMasks	  off
  Created		  "Mon May 20 13:21:21 2002"
  Creator		  "geraint"
  UpdateHistory		  "UpdateHistoryNever"
  ModifiedByFormat	  "%<Auto>"
  LastModifiedBy	  "geraint"
  ModifiedDateFormat	  "%<Auto>"
  LastModifiedDate	  "Tue Jun 18 18:49:28 2002"
  ModelVersionFormat	  "1.%<AutoIncrement:14>"
  ConfigurationManager	  "None"
  SimParamPage		  "Solver"
  StartTime		  "0.0"
  StopTime		  "10.0"
  SolverMode		  "Auto"
  Solver		  "ode45"
  RelTol		  "1e-3"
  AbsTol		  "auto"
  Refine		  "1"
  MaxStep		  "auto"
  MinStep		  "auto"
  MaxNumMinSteps	  "-1"
  InitialStep		  "auto"
  FixedStep		  "auto"
  MaxOrder		  5
  OutputOption		  "RefineOutputTimes"
  OutputTimes		  "[]"
  LoadExternalInput	  off
  ExternalInput		  "[t, u]"
  SaveTime		  on
  TimeSaveName		  "tout"
  SaveState		  off
  StateSaveName		  "xout"
  SaveOutput		  on
  OutputSaveName	  "yout"
  LoadInitialState	  off
  InitialState		  "xInitial"
  SaveFinalState	  off
  FinalStateName	  "xFinal"
  SaveFormat		  "Array"
  LimitDataPoints	  on
  MaxDataPoints		  "1000"
  Decimation		  "1"
  AlgebraicLoopMsg	  "warning"
  MinStepSizeMsg	  "warning"
  UnconnectedInputMsg	  "warning"
  UnconnectedOutputMsg	  "warning"
  UnconnectedLineMsg	  "warning"
  InheritedTsInSrcMsg	  "warning"
  SingleTaskRateTransMsg  "none"
  MultiTaskRateTransMsg	  "error"
  IntegerOverflowMsg	  "warning"
  CheckForMatrixSingularity "none"
  UnnecessaryDatatypeConvMsg "none"
  Int32ToFloatConvMsg	  "warning"
  InvalidFcnCallConnMsg	  "error"
  SignalLabelMismatchMsg  "none"
  LinearizationMsg	  "none"
  VectorMatrixConversionMsg "none"
  SfunCompatibilityCheckMsg "none"
  BlockPriorityViolationMsg "warning"
  ArrayBoundsChecking	  "none"
  ConsistencyChecking	  "none"
  ZeroCross		  on
  Profile		  off
  SimulationMode	  "normal"
  RTWSystemTargetFile	  "grt.tlc"
  RTWInlineParameters	  off
  RTWRetainRTWFile	  off
  RTWTemplateMakefile	  "grt_default_tmf"
  RTWMakeCommand	  "make_rtw"
  RTWGenerateCodeOnly	  off
  TLCProfiler		  off
  TLCDebug		  off
  TLCCoverage		  off
  AccelSystemTargetFile	  "accel.tlc"
  AccelTemplateMakefile	  "accel_default_tmf"
  AccelMakeCommand	  "make_rtw"
  TryForcingSFcnDF	  off
  ExtModeMexFile	  "ext_comm"
  ExtModeBatchMode	  off
  ExtModeTrigType	  "manual"
  ExtModeTrigMode	  "normal"
  ExtModeTrigPort	  "1"
  ExtModeTrigElement	  "any"
  ExtModeTrigDuration	  1000
  ExtModeTrigHoldOff	  0
  ExtModeTrigDelay	  0
  ExtModeTrigDirection	  "rising"
  ExtModeTrigLevel	  0
  ExtModeArchiveMode	  "off"
  ExtModeAutoIncOneShot	  off
  ExtModeIncDirWhenArm	  off
  ExtModeAddSuffixToVar	  off
  ExtModeWriteAllDataToWs off
  ExtModeArmWhenConnect	  on
  ExtModeSkipDownloadWhenConnect off
  ExtModeLogAll		  on
  ExtModeAutoUpdateStatusClock off
  OptimizeBlockIOStorage  on
  BufferReuse		  on
  ParameterPooling	  on
  BlockReductionOpt	  on
  RTWExpressionDepthLimit 5
  BooleanDataType	  off
  BlockDefaults {
    Orientation		    "right"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    NamePlacement	    "normal"
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
    ShowName		    on
  }
  AnnotationDefaults {
    HorizontalAlignment	    "center"
    VerticalAlignment	    "middle"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  LineDefaults {
    FontName		    "Helvetica"
    FontSize		    9
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  System {
    Name		    "mdl"
    Location		    [61, 487, 356, 620]
    Open		    on
    ModelBrowserVisibility  off
    ModelBrowserWidth	    200
    ScreenColor		    "white"
    PaperOrientation	    "landscape"
    PaperPositionMode	    "auto"
    PaperType		    "usletter"
    PaperUnits		    "inches"
    ZoomFactor		    "100"
    ReportName		    "simulink-default.rpt"
    Block {
      BlockType		      Inport
      Name		      "In1"
      Position		      [25, 43, 55, 57]
      Port		      "1"
      LatchInput	      off
      DataType		      "double"
      SignalType	      "real"
      Interpolate	      on
    }
    Block {
      BlockType		      SubSystem
      Name		      "MTT Model\n<mtt_model_name>"
      Ports		      [1, 1]
      Position		      [100, 20, 140, 80]
      ForegroundColor	      "blue"
      BackgroundColor	      "lightBlue"
      ShowPortLabels	      on
      TreatAsAtomicUnit	      off
      RTWSystemCode	      "Auto"
      RTWFcnNameOpts	      "Auto"
      RTWFileNameOpts	      "Auto"
      System {
	Name			"MTT Model\n<mtt_model_name>"
	Location		[55, 494, 1018, 766]
	Open			off
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"white"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"usletter"
	PaperUnits		"inches"
	ZoomFactor		"100"
	Block {
	  BlockType		  Inport
	  Name			  "In1"
	  Position		  [590, 203, 620, 217]
	  Port			  "1"
	  LatchInput		  off
	  DataType		  "double"
	  SignalType		  "real"
	  Interpolate		  on
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Model Inputs"
	  Ports			  [1, 1]
	  Position		  [390, 59, 565, 91]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_input"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT  Model Inputs: MTTU"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Plant Model"
	  Ports			  [1, 2]
	  Position		  [65, 61, 250, 199]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT Model States: MTTX"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	  Port {
	    PortNumber		    2
	    Name		    "MTT Model Outputs: MTTY"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  Memory
	  Name			  "Memory"
	  Position		  [870, 80, 900, 110]
	  X0			  "0"
	  InheritSampleTime	  off
	  RTWStateStorageClass	  "Auto"
	}
	Block {
	  BlockType		  Memory
	  Name			  "Memory1"
	  Position		  [860, 175, 890, 205]
	  X0			  "0"
	  InheritSampleTime	  off
	  RTWStateStorageClass	  "Auto"
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "S-Function"
	  Ports			  [4, 2]
	  Position		  [710, 47, 840, 238]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_interface"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	}
	Block {
	  BlockType		  Outport
	  Name			  "Out1"
	  Position		  [905, 183, 935, 197]
	  Port			  "1"
	  OutputWhenDisabled	  "held"
	  InitialOutput		  "[]"
	}
	Line {
	  Name			  "MTT Model States: MTTX"
	  Labels		  [2, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  1
	  Points		  [0, 0; 105, 0]
	  Branch {
	    Points		    [0, -20]
	    DstBlock		    "MTT Model Inputs"
	    DstPort		    1
	  }
	  Branch {
	    Points		    [0, 25]
	    DstBlock		    "S-Function"
	    DstPort		    2
	  }
	}
	Line {
	  Name			  "MTT Model Outputs: MTTY"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  2
	  DstBlock		  "S-Function"
	  DstPort		  3
	}
	Line {
	  Name			  "MTT  Model Inputs: MTTU"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Model Inputs"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "In1"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  4
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  1
	  DstBlock		  "Memory"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Memory"
	  SrcPort		  1
	  Points		  [0, -55; -855, 0]
	  DstBlock		  "MTT Plant Model"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Memory1"
	  SrcPort		  1
	  DstBlock		  "Out1"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  2
	  DstBlock		  "Memory1"
	  DstPort		  1
	}
      }
    }
    Block {
      BlockType		      Outport
      Name		      "Out1"
      Position		      [185, 43, 215, 57]
      Port		      "1"
      OutputWhenDisabled      "held"
      InitialOutput	      "[]"
    }
    Line {
      SrcBlock		      "MTT Model\n<mtt_model_name>"
      SrcPort		      1
      DstBlock		      "Out1"
      DstPort		      1
    }
    Line {
      SrcBlock		      "In1"
      SrcPort		      1
      DstBlock		      "MTT Model\n<mtt_model_name>"
      DstPort		      1
    }
  }
}

Added mtt/lib/rep/sfun_rep/mex_ae.c.tmpl version [ca0d3e6d3b].



























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_ae.c:
 * Matlab mex algebraic equations for <mtt_model_name>
 */

#if <have_algebraic_equations> /* have_algebraic_equations */

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <mex.h>
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"
#include "<mtt_model_name>_cr.h"

/* utility procedures */

double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

/* system equations */

static void
<mtt_model_name>_ae (double *mttyz,
		     const double *mttx,
		     const double *mttu,
		     const double mttt,
		     const double *mttpar)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

/* generic mex function */

#ifdef __cplusplus
extern "C" {
#endif

void
mexFunction (int nlhs, mxArray *plhs[],
	     int nrhs, const mxArray *prhs[])
{
  double *mttyz;		/* residuals */

  double *mttx;			/* states */
  double *mttu;			/* known + unknown inputs */
  double mttt;			/* time */
  double *mttpar;		/* parameters */

  unsigned int i;
  double *p;

  PRINT_ENTER;

  mttyz		= array_of_double (MTTNYZ);

  mttx		= array_of_double (MTTNX);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttpar	= array_of_double (MTTNPAR);

  /* get trial values */
  p = mxGetPr (prhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* get states */
  p = mxGetPr (prhs[1]);
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = p[i];
  }

  /* get known inputs */
  p = mxGetPr (prhs[2]);
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = p[i];
  }

  /* get time */
  p = mxGetPr (prhs[3]);
  mttt = *p;

  /* get parameters */
  p = mxGetPr (prhs[4]);
  for (i = 0; i < MTTNPAR; i++) {
    mttpar[i] = p[i];
  }
  
  /* evaluate residuals */
  <mtt_model_name>_ae (mttyz, mttx, mttu, mttt, mttpar);
  
  /* return residuals */
  plhs[0] = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  p = mxGetPr (plhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = mttyz[i];
  }

  /* release memory */
  free (mttx);
  free (mttu);
  free (mttpar);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef __cplusplus
}
#endif

#endif /* have_algebraic_equations */

Added mtt/lib/rep/sfun_rep/sfun.c.tmpl version [f43285b0f1].



































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun.c:
 * Matlab S-function simulation of <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"
#include "<mtt_model_name>_cr.h"

static double *mttdx;		/* pointer to rates */
static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double *mttyz;		/* pointer to residuals */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_ae (void)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_ode (void)
{
#include "<mtt_model_name>_ode.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_odeo (void)
{
#include "<mtt_model_name>_odeo.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_state (void)
{
#include "<mtt_model_name>_state.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttdx		= array_of_double (MTTNX);
  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);
  mttyz		= array_of_double (MTTNYZ);

  PRINT_LEAVE;
}

static void
update_states_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = ssGetContStates (S)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_solver (void)
{
#if <have_algebraic_equations> /* have_algebraic_equations */
  mxArray *MTT_MATLAB_P;
  mxArray *MTT_MATLAB_T;
  mxArray *MTT_MATLAB_U;
  mxArray *MTT_MATLAB_Ui;
  mxArray *MTT_MATLAB_X;

  double *p;

  PRINT_ENTER;

  /* starting value for solver - start with zero */
  MTT_MATLAB_Ui = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = 0.0;
  }
  mexPutVariable ("base", "MTT_Ui", MTT_MATLAB_Ui);

  /* put states into matlab workspace */
  MTT_MATLAB_X = mxCreateDoubleMatrix (MTTNX, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_X);
  for (i = 0; i < MTTNX; i++) {
    p[i] = mttx[i];
  }
  mexPutVariable ("base", "MTT_X", MTT_MATLAB_X);

  /* put known inputs into matlab workspace */
  MTT_MATLAB_U = mxCreateDoubleMatrix (MTTNU, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_U);
  for (i = 0; i < MTTNU; i++) {
    p[i] = mttu[i];
  }
  mexPutVariable ("base", "MTT_U", MTT_MATLAB_U);

  /* put time into matlab workspace */
  MTT_MATLAB_T = mxCreateDoubleMatrix (1, 1, mxREAL);
  *mxGetPr (MTT_MATLAB_T) = mttt;
  mexPutVariable ("base", "MTT_T", MTT_MATLAB_T);

  /* put parameters into matlab workspace */
  MTT_MATLAB_P = mxCreateDoubleMatrix (MTTNPAR, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_P);
  for (i = 0; i < MTTNPAR; i++) {
    p[i] = mttpar[i];
  }
  mexPutVariable ("base", "MTT_P", MTT_MATLAB_P);

  /* call solver */
  mexEvalString ("MTT_Ui = lsqnonlin (@<mtt_model_name>_sfun_ae, MTT_Ui, [], [], optimset('display','off','diagnostics','off','TolX',1e-2,'TolFun',1e-2), MTT_X, MTT_U, MTT_T, MTT_P);");

  /* retrieve result */
  MTT_MATLAB_Ui = mexGetVariable ("base", "MTT_Ui");
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* free memory */
  mxDestroyArray (MTT_MATLAB_P);
  mxDestroyArray (MTT_MATLAB_T);
  mxDestroyArray (MTT_MATLAB_U);
  mxDestroyArray (MTT_MATLAB_Ui);
  mxDestroyArray (MTT_MATLAB_X);

  PRINT_LEAVE;
#endif /* have_algebraic_equations */
  ;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, MTTNX);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortDirectFeedThrough(S, 0, 1);

  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNX);
  ssSetOutputPortWidth(S, 1, MTTNY);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);

  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;

  <mtt_model_name>_numpar ();
  <mtt_model_name>_state ();

  for (i = 0; i < MTTNX; i++) {
    ssGetContStates (S)[i] = mttx[i];
  }

  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  }
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_odeo ();

  for (i = 0; i < MTTNX; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttx[i];
  }

  for (i = 0; i < MTTNY; i++) {
      ssGetOutputPortRealSignal (S, 1)[i] = mtty[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
    
  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  } 
  update_simtime_from_simulink (S);

  <mtt_model_name>_ode ();

  for (i = 0; i < MTTNX; i++) {
    ssGetdX (S)[i] = mttdx[i];
  }

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;
  UNUSED_ARG(S);

  free (mttdx);
  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

Added mtt/lib/rep/sfun_rep/sfun_debug.h version [484e8ce3d6].































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

#ifndef HAVE_SFUN_DEBUG_H
#define HAVE_SFUN_DEBUG_H


#if defined DEBUG && defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered '%s'\n", __FUNCTION__);
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving '%s'\n", __FUNCTION__);

#elif defined DEBUG && ! defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered a function\n");
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving a function\n");

#elif ! defined DEBUG

#define PRINT_ENTER
#define PRINT_LEAVE

#else

#error "Momentary lapse of logic : unreachable statement reached"

#endif


#endif /* HAVE_SFUN_DEBUG_H */

Added mtt/lib/rep/sfun_rep/sfun_input.c.tmpl version [37d9259f60].


























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_input.c:
 * Matlab S-function inputs for <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun_input
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"
#include "<mtt_model_name>_cr.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_input (void)
{
#include "<mtt_model_name>_input.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNX);
  ssSetInputPortDirectFeedThrough(S, 0, 1);
    
  if (!ssSetNumOutputPorts(S, 1)) return;
  ssSetOutputPortWidth(S, 0, MTTNU);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_input ();

  for (i = 0; i < MTTNU; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

Added mtt/lib/rep/sfun_rep/sfun_interface.c.tmpl version [8f8ea00a46].




















































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_interface.c:
 * Matlab S-function to process inputs and outputs of <mtt_model_name>
 */


#define S_FUNCTION_NAME <mtt_model_name>_sfun_interface
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static double *MTT_outputs;
static double *MTT_inputs;

static unsigned int i;		/* loop counter */

/* Start EDIT */
/* Edit this block to define the number of simulink inputs, outputs and parameters */
#define NumberOfSimulinkInputs	MTTNY /* MTT outputs */
#define NumberOfSimulinkOutputs	MTTNU /* MTT inputs */
/* End EDIT */

static void
<mtt_model_name>_process_inputs (SimStruct *S)
{
  /* insert <mtt_model_name>_struc.c */

  /* Start EDIT */
  /* Edit this block to process the model inputs and outputs */
  
  /* Error messages can be set using the following line */
  /*  ssSetErrorStatus (S, "<mtt_model_name>_some error message!\n"); */

  /* Default is to expose all MTT inputs, outputs and states */

  /* Get all the MTT model outputs and pass them to simulink */
  for (i = 0; i < NumberOfSimulinkInputs; i++) {
    MTT_outputs[i] = mtty[i];
  }

  /* Get all inputs from Simulink and pass them to the MTT model */
  /* Any inputs not over-written here will be read from <mtt_model_name>_input.c  */
  for (i = 0; i < NumberOfSimulinkOutputs; i++) {
    mttu[i] = MTT_inputs[i];
  }

  /* End EDIT */
}


/******************************************************************************
 *                DO NOT EDIT ANYTHING BELOW THIS LINE                        *
 ******************************************************************************/

/* system equations */

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
check_finite(SimStruct *S, double *array, unsigned int index)
{
  const char *array_name;
  char warning[128];
  if ((array[index] <= 0.0) || (array[index] >= 0.0)) {
    ; /* no problem */
  } else {
    if (array == mttpar) {
      array_name = "mttpar";
    } else if (array == mttu) {
      array_name = "mttu";
    } else if (array == mttx) {
      array_name = "mttx";
    } else if (array == mtty) {
      array_name = "mtty";
    } else if (array == MTT_outputs) {
      array_name = "MTT_outputs";
    } else if (array == MTT_inputs) {
      array_name = "MTT_inputs";
    } else {
      array_name = "unknown_array";
    }
    sprintf(warning, "(time %f) Non-finite array element: %s[%d]\n", mttt, array_name, index);
    ssWarning(S, warning);
  }
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  MTT_outputs	= array_of_double (NumberOfSimulinkInputs);
  MTT_inputs	= array_of_double (NumberOfSimulinkOutputs);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
    check_finite(S, mttu, i);
  }
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 1)[i];
    check_finite(S, mttx, i);
  }
  for (i = 0; i < MTTNY; i++) {
    mtty[i] = *ssGetInputPortRealSignalPtrs (S, 2)[i];
    check_finite(S, mtty, i);
  }
  for (i = 0; i < NumberOfSimulinkOutputs; i++) {
    MTT_inputs[i] = *ssGetInputPortRealSignalPtrs (S, 3)[i];
    check_finite(S, MTT_inputs, i);
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 4)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortWidth(S, 1, MTTNX);
  ssSetInputPortWidth(S, 2, MTTNY);
  ssSetInputPortWidth(S, 3, NumberOfSimulinkOutputs);	/* inputs from simulink */
  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetInputPortDirectFeedThrough(S, 1, 1);
  ssSetInputPortDirectFeedThrough(S, 2, 1);
  ssSetInputPortDirectFeedThrough(S, 3, 1);
    
  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNU); /* altered inputs */
  ssSetOutputPortWidth(S, 1, NumberOfSimulinkInputs); /* outputs to simulink */
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  <mtt_model_name>_process_inputs (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  for (i = 0; i < MTTNU; i++) {
    check_finite(S, mttu, i);
    ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }
  
  for (i = 0; i < NumberOfSimulinkInputs; i++) {
    check_finite(S, MTT_outputs, i);
    ssGetOutputPortRealSignal (S, 1)[i] = MTT_outputs[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  free (MTT_outputs);
  free (MTT_inputs);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

Added mtt/lib/xfig/Basic/0.fig version [fc409194ef].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 0\001

Added mtt/lib/xfig/Basic/1.fig version [fa271395bb].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 1\001

Added mtt/lib/xfig/Basic/AE.fig version [63cbbf46d6].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AE:ae_1\001

Added mtt/lib/xfig/Basic/AEf.fig version [cd581c11ab].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AEf:aef_1\001

Added mtt/lib/xfig/Basic/AF.fig version [d3d62f06c4].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AF:af_1\001

Added mtt/lib/xfig/Basic/AFe.fig version [e76fcd7f46].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AFe:afe_1\001

Added mtt/lib/xfig/Basic/C.fig version [7ff23716fc].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 C:c_1\001

Added mtt/lib/xfig/Basic/De.fig version [453a3f3f0b].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 De:de_1\001

Added mtt/lib/xfig/Basic/DescriptiveText.fig version [174032c291].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 1 101 0 3 20 0.0000 4 255 2025 1395 630 Descriptive text.\001

Added mtt/lib/xfig/Basic/Df.fig version [371772784b].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Df:df_1\001

Added mtt/lib/xfig/Basic/EMTF.fig version [3d87d41331].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 EMTF:emtf_1\001

Added mtt/lib/xfig/Basic/GY.fig version [a49e410bdc].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 GY:gy_1\001

Added mtt/lib/xfig/Basic/I.fig version [2989eccd82].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 I:i_1\001

Added mtt/lib/xfig/Basic/INTF.fig version [ecff474a22].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 INTF:intf_1\001

Added mtt/lib/xfig/Basic/InPort.fig version [fd70624acc].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 2 4 100 0 18 18 0.0000 4 270 870 1890 855 SS:[in]\001

Added mtt/lib/xfig/Basic/MAKE_COMPONENT version [e7c52bd3fa].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
## Makes a new component

if [ -z "$2" ]; then
  label=$1
else
  label=$2    
fi

case $1 in
    0)
	echo Making new component $1 with no label
        sed "s/TEXT/$1/" <template.txt >$1.fig
	;;
    1)
	echo Making new component $1 with no label
        sed "s/TEXT/$1/" <template.txt >$1.fig
	;;
    *)
  echo Making new component $1 with label $label
  sed "s/TEXT/$1:$label/" <template.txt >$1.fig
esac

Added mtt/lib/xfig/Basic/MAKE_COMPONENTS version [e2b32f5799].





























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
## Makes all components

./MAKE_COMPONENT R r_1
./MAKE_COMPONENT C c_1
./MAKE_COMPONENT I i_1

./MAKE_COMPONENT 0
./MAKE_COMPONENT 1

./MAKE_COMPONENT SS ss_1
./MAKE_COMPONENT Se se_1
./MAKE_COMPONENT Sf sf_1
./MAKE_COMPONENT De de_1
./MAKE_COMPONENT Df df_1

./MAKE_COMPONENT TF tf_1
./MAKE_COMPONENT GY gy_1
./MAKE_COMPONENT AE ae_1
./MAKE_COMPONENT AEf aef_1
./MAKE_COMPONENT AF af_1
./MAKE_COMPONENT AFe afe_1


./MAKE_COMPONENT EMTF emtf_1
./MAKE_COMPONENT INTF intf_1

./MAKE_COMPONENT Subsystem sub_1

Added mtt/lib/xfig/Basic/OutPort.fig version [9c5dd9c690].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 0 4 100 0 18 18 0.0000 4 270 1065 1890 855 SS:[out]\001

Added mtt/lib/xfig/Basic/Port.fig version [6321cfa21c].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 4 100 0 18 18 0.0000 4 300 1620 1890 855 SS:[port_1]\001

Added mtt/lib/xfig/Basic/PortLabel.fig version [cb5b36e605].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 4 100 0 18 14 0.0000 4 210 825 855 630 [port_1]\001

Added mtt/lib/xfig/Basic/PortLabel.txt version [cb5b36e605].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 4 100 0 18 14 0.0000 4 210 825 855 630 [port_1]\001

Added mtt/lib/xfig/Basic/R.fig version [654cc51222].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 R:r_1\001

Added mtt/lib/xfig/Basic/SS.fig version [9f614e5774].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 SS:ss_1\001

Added mtt/lib/xfig/Basic/Se.fig version [6de4ea567d].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Se:se_1\001

Added mtt/lib/xfig/Basic/Sf.fig version [6e96816a11].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Sf:sf_1\001

Added mtt/lib/xfig/Basic/Subsystem.fig version [37c513eb5f].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Subsystem:sub_1\001

Added mtt/lib/xfig/Basic/TF.fig version [86e02d055f].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 TF:tf_1\001

Added mtt/lib/xfig/Basic/blue-box.fig version [de5f3c52ac].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 1 2 1 7 101 0 -1 6.000 0 0 7 0 0 5
	 3825 2700 450 2700 450 450 3825 450 3825 2700

Added mtt/lib/xfig/Basic/bond.fig version [320851a75c].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 900 675 2250 675 2025 900

Added mtt/lib/xfig/Basic/gold-box.fig version [68e5946bc3].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 3825 2700 450 2700 450 450 3825 450 3825 2700

Added mtt/lib/xfig/Basic/halfstroke.fig version [1fdeb37f4d].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1350 1125 1350 1350

Added mtt/lib/xfig/Basic/stroke.fig version [4fd3498223].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 675 675 675 1125

Added mtt/lib/xfig/Basic/template.txt version [b2d9218f91].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 TEXT\001

Added mtt/lib/xfig/Thermal/CT.fig version [fc7936d9f9].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 CT:ct_1\001

Added mtt/lib/xfig/Thermal/MAKE_COMPONENT version [9f63b6b6f6].

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
## Makes a new component

if [ -z "$2" ]; then
  label=$1
else
  label=$2    
fi

if [ "$1" = "0" ]||[ "$1" = "1" ]; then
  echo Making new component $1 with no label
  sed "s/TEXT/$1/" <template.txt >$1.fig
else
  echo Making new component $1 with label $label
  sed "s/TEXT/$1:$label/" <template.txt >$1.fig
fi

Added mtt/lib/xfig/Thermal/MAKE_COMPONENTS version [ab85a0e8eb].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
#!/bin/sh
## Makes all components

./MAKE_COMPONENT RS rs_1
./MAKE_COMPONENT RT rt_1
./MAKE_COMPONENT CT ct_1

Added mtt/lib/xfig/Thermal/RS.fig version [d967438bbf].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 RS:rs_1\001

Added mtt/lib/xfig/Thermal/RT.fig version [434299c19a].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 RT:rt_1\001

Added mtt/lib/xfig/Thermal/template.txt version [b2d9218f91].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 TEXT\001

Added mtt/lib/xfig/libs.txt version [021119315b].





1
2
3
4
+
+
+
+
/home/peterg/mtt_new/mtt/lib/xfig/Basic  Basic
/home/peterg/mtt_new/mtt/lib/comp/compound/Electrical Electrical
/home/peterg/mtt_new/mtt/lib/comp/compound/Thermal Thermal

Deleted mttroot/CVSROOT/checkoutlist version [db1d2d9b69].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
#	[<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'
syncmail

Deleted mttroot/CVSROOT/commitinfo version [85654ac9a8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list 
# of files to check.  A non-zero exit of the filter program will 
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Deleted mttroot/CVSROOT/config version [28e7a42550].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no

# Set `PreservePermissions' to `yes' to save file status information
# in the repository.
#PreservePermissions=no

# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no

Deleted mttroot/CVSROOT/cvswrappers version [9d41597c29].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
#  wildcard	[option value][option value]...
#
#  where option is one of
#  -f		from cvs filter		value: path to filter
#  -t		to cvs filter		value: path to filter
#  -m		update methodology	value: MERGE or COPY
#  -k		expansion mode		value: b, o, kkv, &c
#
#  and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'

Deleted mttroot/CVSROOT/editinfo version [dfa5fb459c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "editinfo" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Deleted mttroot/CVSROOT/loginfo version [f5255d5add].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "loginfo" file controls where "cvs commit" log information
# is sent.  The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT.  If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter.  The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators.  The format
# characters are:
#
#   s = file name
#   V = old version number (pre-checkin)
#   v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog

# Lines to mail changes
CVSROOT $CVSROOT/CVSROOT/syncmail %{sVv} mtt@gawthrop.net
DEFAULT $CVSROOT/CVSROOT/syncmail %{sVv} mtt-cvs@lists.sourceforge.net

Deleted mttroot/CVSROOT/modules version [84b74e5335].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Three different line formats are valid:
#	key	-a    aliases...
#	key [options] directory
#	key [options] directory files...
#
# Where "options" are composed of:
#	-i prog		Run "prog" on "cvs commit" from top-level of module.
#	-o prog		Run "prog" on "cvs checkout" of module.
#	-e prog		Run "prog" on "cvs export" of module.
#	-t prog		Run "prog" on "cvs rtag" of module.
#	-u prog		Run "prog" on "cvs update" of module.
#	-d dir		Place module in directory "dir" instead of module name.
#	-l		Top-level directory only -- do not recurse.
#
# NOTE:  If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias.  An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module.  This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.

Deleted mttroot/CVSROOT/notify version [2a5259e3c5].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent.  The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT.  If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"

Deleted mttroot/CVSROOT/rcsinfo version [c276b88ba1].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT.  For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Deleted mttroot/CVSROOT/syncmail version [2c972f2c68].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459











































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/python

# Copyright (c) 2002, 2003, Barry Warsaw, Fred Drake, and contributors
# All rights reserved.
# See the accompanying LICENSE file for details.

# Compatibility: Python 2.2.3, tied to the version of Python on SourceForge's
# authenticated CVS server.

"""Complicated notification for CVS checkins.

This script is used to provide email notifications of changes to the CVS
repository.  These email changes will include context diffs of the changes.
Really big diffs will be trimmed.

This script is run from a CVS loginfo file (see $CVSROOT/CVSROOT/loginfo).  To
set this up, create a loginfo entry that looks something like this:

    mymodule /path/to/this/script %%s some-email-addr@your.domain

In this example, whenever a checkin that matches `mymodule' is made, this
script is invoked, which will generate the diff containing email, and send it
to some-email-addr@your.domain.

    Note: This module used to also do repository synchronizations via
    rsync-over-ssh, but since the repository has been moved to SourceForge,
    this is no longer necessary.  The syncing functionality has been ripped
    out in the 3.0, which simplifies it considerably.  Access the 2.x versions
    to refer to this functionality.  Because of this, the script is misnamed.

It no longer makes sense to run this script from the command line.  Doing so
will only print out this usage information.

Usage:

    %(PROGRAM)s [options] <%%S> email-addr [email-addr ...]

Where options are:

    --cvsroot=<path>
        Use <path> as the environment variable CVSROOT.  Otherwise this
        variable must exist in the environment.

    --context=#
    -C #
        Include # lines of context around lines that differ (default: 2).

    -c
        Produce a context diff (default).

    -m hostname
    --mailhost hostname
        The hostname of an available SMTP server.  The default is
        'localhost'.

    -u
        Produce a unified diff (smaller).

    -S TEXT
    --subject-prefix=TEXT
        Prepend TEXT to the email subject line.

    -R ADDR
    --reply-to=ADDR
      Add a "Reply-To: ADDR" header to the email message.

    --quiet / -q
        Don't print as much status to stdout.

    --fromhost=hostname
    -f hostname
        The hostname that email messages appear to be coming from.  The From:
        header of the outgoing message will look like user@hostname.  By
        default, hostname is the machine's fully qualified domain name.

    --help / -h
        Print this text.

The rest of the command line arguments are:

    <%%S>
        CVS %%s loginfo expansion.  When invoked by CVS, this will be a single
        string containing the directory the checkin is being made in, relative
        to $CVSROOT, followed by the list of files that are changing.  If the
        %%s in the loginfo file is %%{sVv}, context diffs for each of the
        modified files are included in any email messages that are generated.

    email-addrs
        At least one email address.
"""
__version__ = '1.2'

import os
import sys
import re
import time
import string
import getopt
import smtplib
import pwd
import socket

try:
    from socket import getfqdn
except ImportError:
    def getfqdn():
        # Python 1.5.2 :(
        hostname = socket.gethostname()
        byaddr = socket.gethostbyaddr(socket.gethostbyname(hostname))
        aliases = byaddr[1]
        aliases.insert(0, byaddr[0])
        aliases.insert(0, hostname)
        for fqdn in aliases:
            if '.' in fqdn:
                break
        else:
            fqdn = 'localhost.localdomain'
        return fqdn


from cStringIO import StringIO

# Which SMTP server to do we connect to?
MAILHOST = 'localhost'
MAILPORT = 25

# Diff trimming stuff
DIFF_HEAD_LINES = 20
DIFF_TAIL_LINES = 20
DIFF_TRUNCATE_IF_LARGER = 1000

COMMASPACE = ', '

PROGRAM = sys.argv[0]

BINARY_EXPLANATION_LINES = [
    "(This appears to be a binary file; contents omitted.)\n"
    ]

NOVERSION = "Couldn't generate diff; no version number found for file: %s"
BACKSLASH = "Couldn't generate diff: backslash in filespec's filename: %s"



def usage(code, msg=''):
    print __doc__ % globals()
    if msg:
        print msg
    sys.exit(code)



def calculate_diff(entry, contextlines):
    file = entry.name
    oldrev = entry.revision
    newrev = entry.new_revision

    # Make sure we can find a CVS version number
    if oldrev is None and newrev is None:
        return NOVERSION % file

    if string.find(file, "'") <> -1:
        # Those crazy users put single-quotes in their file names!  Now we
        # have to escape everything that is meaningful inside double-quotes.
        filestr = string.replace(file, '\\', '\\\\')
        filestr = string.replace(filestr, '`', '\`')
        filestr = string.replace(filestr, '"', '\"')
        filestr = string.replace(filestr, '$', '\$')
        # and quote it with double-quotes.
        filestr = '"' + filestr + '"'
    else:
        # quote it with single-quotes.
        filestr = "'" + file + "'"
    if oldrev is None:
        # File is being added.
        try:
            if os.path.exists(file):
                fp = open(file)
            else:
                update_cmd = "cvs -fn update -r %s -p %s" % (newrev, filestr)
                fp = os.popen(update_cmd)
            lines = fp.readlines()
            fp.close()
            # Is this a binary file?  Let's look at the first few
            # lines to figure it out:
            for line in lines[:5]:
                for c in string.rstrip(line):
                    if c in string.whitespace:
                        continue
                    if c < ' ' or c > chr(127):
                        lines = BINARY_EXPLANATION_LINES[:]
                        break
            lines.insert(0, '--- NEW FILE: %s ---\n' % file)
        except IOError, e:
            lines = ['***** Error reading new file: ',
                     str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()]
    elif newrev is None:
        lines = ['--- %s DELETED ---\n' % file]
    else:
        # File has been changed.
        # This /has/ to happen in the background, otherwise we'll run into CVS
        # lock contention.  What a crock.
        if contextlines > 0:
            difftype = "-C " + str(contextlines)
        else:
            difftype = "-u"
        diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s %s" \
                  % (difftype, oldrev, newrev, filestr)
        fp = os.popen(diffcmd)
        lines = fp.readlines()
        # ignore the error code, it always seems to be 1 :(
        fp.close()
    if len(lines) > DIFF_TRUNCATE_IF_LARGER:
        removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES
        del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES]
        lines.insert(DIFF_HEAD_LINES,
                     '[...%d lines suppressed...]\n' % removedlines)
    return string.join(lines, '')



rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]')

def quotename(name):
    if name and rfc822_specials_re.search(name):
        return '"%s"' % string.replace(name, '"', '\\"')
    else:
        return name



def blast_mail(subject, people, entries, contextlines, fromhost, replyto):
    # cannot wait for child process or that will cause parent to retain cvs
    # lock for too long.  Urg!
    if not os.fork():
        # in the child
        # give up the lock you cvs thang!
        time.sleep(2)
        # Create the smtp connection to the localhost
        conn = smtplib.SMTP()
        conn.connect(MAILHOST, MAILPORT)
        user = pwd.getpwuid(os.getuid())[0]
        name = string.split(pwd.getpwuid(os.getuid())[4], ',')[0]
        domain = fromhost or getfqdn()
        address = '%s@%s' % (user, domain)
        s = StringIO()
        sys.stdout = s
        datestamp = time.strftime('%a, %d %b %Y %H:%M:%S +0000',
                                  time.gmtime(time.time()))
        try:
            vars = {'address' : address,
                    'name'    : quotename(name),
                    'people'  : string.join(people, COMMASPACE),
                    'subject' : subject,
                    'version' : __version__,
                    'date'    : datestamp,
                    }
            print '''\
From: %(name)s <%(address)s>
To: %(people)s''' % vars
            if replyto:
                print 'Reply-To: %s' % replyto
            print '''\
Subject: %(subject)s
Date: %(date)s
X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail>
''' % vars
            s.write(sys.stdin.read())
            # append the diffs if available
            print
            for entry in entries:
                print calculate_diff(entry, contextlines)
        finally:
            sys.stdout = sys.__stdout__
        resp = conn.sendmail(address, people, s.getvalue())
        conn.close()
        os._exit(0)



class CVSEntry:
    def __init__(self, name, revision, timestamp, conflict, options, tagdate):
        self.name = name
        self.revision = revision
        self.timestamp = timestamp
        self.conflict = conflict
        self.options = options
        self.tagdate = tagdate

def get_entry(prefix, mapping, line, filename):
    line = string.strip(line)
    parts = string.split(line, "/")
    _, name, revision, timestamp, options, tagdate = parts
    key = namekey(prefix, name)
    try:
        entry = mapping[key]
    except KeyError:
        if revision == "0":
            revision = None
        if string.find(timestamp, "+") != -1:
            timestamp, conflict = tuple(string.split(timestamp, "+"))
        else:
            conflict = None
        entry = CVSEntry(key, revision, timestamp, conflict,
                         options, tagdate)
        mapping[key] = entry
    return entry

def namekey(prefix, name):
    if prefix:
        return os.path.join(prefix, name)
    else:
        return name

def load_change_info(prefix=None):
    if prefix is not None:
        entries_fn = os.path.join(prefix, "CVS", "Entries")
    else:
        entries_fn = os.path.join("CVS", "Entries")
    entries_log_fn = entries_fn + ".Log"
    mapping = {}
    f = open(entries_fn)
    while 1:
        line = f.readline()
        if not line:
            break
##        if string.strip(line) == "D":
##            continue
        # we could recurse down subdirs, except the Entries.Log files
        # we need haven't been written to the subdirs yet, so it
        # doesn't do us any good
##        if line[0] == "D":
##            name = string.split(line, "/")[1]
##            dirname = namekey(prefix, name)
##            if os.path.isdir(dirname):
##                m = load_change_info(dirname)
##                mapping.update(m)
        if line[0] == "/":
            # normal file
            get_entry(prefix, mapping, line, entries_fn)
        # else: bogus Entries line
    f.close()
    if os.path.isfile(entries_log_fn):
        f = open(entries_log_fn)
        while 1:
            line = f.readline()
            if not line:
                break
            if line[1:2] != ' ':
                # really old version of CVS
                break
            entry = get_entry(prefix, mapping, line[2:], entries_log_fn)
            parts = string.split(line, "/")[1:]
            if line[0] == "A":
                # adding a file
                entry.new_revision = parts[1]
            elif line[0] == "R":
                # removing a file
                entry.new_revision = None
        f.close()
    for entry in mapping.values():
        if not hasattr(entry, "new_revision"):
            print 'confused about file', entry.name, '-- ignoring'
            del mapping[entry.name]
    return mapping

def load_branch_name():
    tag_fn = os.path.join("CVS", "Tag")
    if os.path.isfile(tag_fn):
        f = open(tag_fn)
        line = string.strip(f.readline())
        f.close()
        if line[:1] == "T":
            return line[1:]
    return None

# scan args for options
def main():
    # XXX Should really move all the options to an object, just to
    # avoid threading so many positional args through everything.
    try:
        opts, args = getopt.getopt(
            sys.argv[1:], 'hC:cuS:R:qf:m:',
            ['fromhost=', 'context=', 'cvsroot=', 'mailhost=',
             'subject-prefix=', 'reply-to=',
             'help', 'quiet'])
    except getopt.error, msg:
        usage(1, msg)

    # parse the options
    contextlines = 2
    verbose = 1
    subject_prefix = ""
    replyto = None
    fromhost = None
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage(0)
        elif opt == '--cvsroot':
            os.environ['CVSROOT'] = arg
        elif opt in ('-C', '--context'):
            contextlines = int(arg)
        elif opt == '-c':
            if contextlines <= 0:
                contextlines = 2
        elif opt == '-u':
            contextlines = 0
        elif opt in ('-S', '--subject-prefix'):
            subject_prefix = arg
        elif opt in ('-R', '--reply-to'):
            replyto = arg
        elif opt in ('-q', '--quiet'):
            verbose = 0
        elif opt in ('-f', '--fromhost'):
            fromhost = arg
        elif opt in ('-m', '--mailhost'):
            global MAILHOST
            MAILHOST = arg

    # What follows is the specification containing the files that were
    # modified.  The argument actually must be split, with the first component
    # containing the directory the checkin is being made in, relative to
    # $CVSROOT, followed by the list of files that are changing.
    if not args:
        usage(1, 'No CVS module specified')
    changes = load_change_info()
    branch = load_branch_name()
    subject = subject_prefix + args[0]
    specs = string.split(args[0])
    del args[0]

    # The remaining args should be the email addresses
    if not args:
        usage(1, 'No recipients specified')

    # Now do the mail command
    people = args

    if specs[-3:] == ['-', 'Imported', 'sources']:
        print 'Not sending email for imported sources.'
        return

    if verbose:
##        print 'Python version', sys.version
##        os.system("type python1.6; type python2;"
##                  " type python2.0; type python2.1; type python2.2;"
##                  " type rcsdiff; type rlog")
        print 'Mailing %s...' % string.join(people, COMMASPACE)
        print 'Generating notification message...'
    blast_mail(subject, people, changes.values(),
               contextlines, fromhost, replyto)
    if verbose:
        print 'Generating notification message... done.'



if __name__ == '__main__':
    main()
    sys.exit(0)

Deleted mttroot/CVSROOT/taginfo version [364dad5373].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4->  file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

Deleted mttroot/CVSROOT/verifymsg version [cbc796537d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# The "verifymsg" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.

Deleted mttroot/gino/AUTHORS version [8194ff1aef].

1

-
Peter J. Gawthrop (peter@gawthrop.net)

Deleted mttroot/gino/COPYING version [b34d81c876].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339



















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
                    GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                          675 Mass Ave, Cambridge, MA 02139, USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 19yy  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) 19yy name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

Deleted mttroot/gino/INSTALL version [45c34bc6d3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
=======================================================================
Prerequisites

Octave and ginsh must be installed before installing gino


=======================================================================
Simple system installation

$ tar xzf gino-<ver>.tar.gz
$ cd gino-<ver>
$ make clean
$ make 

As superuser
# make install

Deleted mttroot/gino/Makefile version [9715ccae4b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Makefile for gino library

all: g_funs

g_funs:
	./create_gino.sh

clean:
	rm -rf g_funs

install: g_funs
	cp -rf ../gino /usr/share/octave/site/m



Deleted mttroot/gino/README version [8fb7e2da1f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Gino is a symbolic toolbox for octave (www.octave.org) using ginsh -
the shell interface to ginac (www.ginac.de).

ginsh.m provides a low-level octave interface to ginsh. All of the
ginsh functions are implemented by octave functions of the form
g_fun(arglist).

All in and out arguments of the toolbox functions are octave strings
containing valid ginsh expressions. Where appropriate, these can be
turned into matlab scalars, matrices and lists using octave's eval
function. Spurious output is avoided by setting
default_eval_print_flag=0.

This provides a clear division between symbolic expressions (always
contained in strings) and octave expressions. It also allows the
powerful octave string machinery to be used to manipulate symbolic
expressions.

gino_examples.m contains some introductory examples.

P.J.Gawthrop. 19th December 2002.


Deleted mttroot/gino/create_gino.sh version [df77946783].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
## Creates gino functions by querying ginsh
# Copyright (C) 2002 by Peter J. Gawthrop

prefix="g_"			# Prefix function names by this
subdir=${prefix}funs		# Where the generated functions live
ginsh="/usr/bin/ginsh"		# Location of ginsh

create_fun() {
    funname=${prefix}$1
    filename=${funname}.m

    ## Creates an octave function
    echo Creating ${subdir}/${filename}

    ## Find usage string

    usage=`echo "?$1" | ginsh | head -1`

    ## The octave function
    cat<<EOF > ${subdir}/${filename}
function res = ${funname} (arg1,arg2,arg3)

  ## usage:  res = ${prefix}${usage}

  ## Generated by create_gino.sh on `date`
  ## DO NOT EDIT ME

  if nargin<1
    arg1 = "";
  endif

  if nargin<2
    arg2 = "";
  endif

  if nargin<3
    arg3 = "";
  endif

  res = gino("$1", arg1, arg2, arg3);

endfunction
EOF
}

create_readme() {
    cat > ${subdir}/README <<EOF
These files were generated automatically by create_gino.sh
on `date`.

DO NOT EDIT THEM
EOF
}

## Find available ops
ops=`echo "??" | ginsh | gawk '{if(i++==1) {gsub(",",""); print $0}}'`

## Does ginsh exist?
if [ -x "${ginsh}" ]; then
    echo $ginsh exists - ok
else
    echo $ginsh does not exist, exiting
    exit
fi

## Create the corresponding octave funs.
mkdir -p ${subdir}
create_readme;
for op in ${ops}; do
    create_fun ${op}
done

Deleted mttroot/gino/g2o_pol.m version [7d7c3065b2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function o_pol = g2o_pol (g_pol, object)

  ## usage:  o_pol = g2o_pol (g_pol)
  ##
  ## Converts a ginsh polynomial to an octave polynomial
  ## Both o_pol and g_pol are strings
  ## o_pol can be an argument to eval

  if nargin<1
    error("usage:  o_pol = g2o_pol (g_pol)");
  endif
  
  if nargin<2
    object="s";
  endif
  
  g_pol = g_expand(g_pol);
  n = g_degree(g_pol, object);
  n = eval([n,";"]);
  o_pol = "";
  for i=n:-1:0
    pol_i = g_coeff(g_pol,object,int2str(i));
    o_pol = sprintf("%s %s", o_pol, pol_i);
  endfor
  o_pol = sprintf("[%s ];", o_pol);

endfunction

Deleted mttroot/gino/gino.m version [7b8fb38fbb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function res = gino (op,arg1,arg2,arg3)

  ## Gino is the octave interface to ginsh - the GiNaC shell interface.
  ## The simplest way to use gino is via the octave functions  go_fun.
  ## where "fun" is a ginsh function - type gino("??") for a list.
  ## usage:  res = gino (op,arg1,arg2,arg3)
  ## 
  ## Please set default_eval_print_flag = 0
  ##
  ## Part of the gino (ginsh-octave) toolbox
  ## Copyright (C) 2002 by Peter J. Gawthrop

  if nargin<1
    error("usage: gino(op,[arg1,arg2,arg3])p");
  elseif (nargin==1)||(length(arg1)==0)
    go_in = sprintf("%s", op);
  elseif (nargin==2)||(length(arg2)==0)
    go_in = sprintf("%s(%s)", op, arg1);
  elseif (nargin==3)||(length(arg3)==0)
    go_in = sprintf("%s(%s,%s)", op, arg1, arg2);
  elseif (nargin==4)
    go_in = sprintf("%s(%s,%s,%s)", op, arg1, arg2, arg3);
  else
    error("usage: gino(op,[arg1,arg2,arg3]");
  endif

  res = ginsh(go_in);

endfunction

Deleted mttroot/gino/gino_examples.m version [faa058f3c8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Simple example of creating an octave polynomial symbolically
P = g2o_pol("s^2*(s+a)*(s+b)^3") # Create symbolic polynomial in octave form
a = 1; b = 2;			# Give a and b numerical values
p = eval(P)			# Create numerical polynomial
roots(p)			# Use p in any appropriate octave
				# function

## More complicated example of symbolic linearisation

## ODE dx/dt = f(x,u); y = g(x,u)
f_1 = "x_2 - beta*tanh(u_1)";
f_2 = "-x_1 + x_2^2 + u_1";
g_1   = "x_1";
f = go_list(f_1,f_2)
g = go_list(g_1)

## Linearise via symbolic differentiation
[A,B,C,D] = go_lin(f,g)

## Find the transfer function

I = "[[1,0],[0,1]]";		# Unit matrix
## Create G as a string: C(sI-A)^-1B + D
G_str = sprintf("%s*((s*%s-%s)^(-1))*%s + %s", C,I,A,B,D)

## Find G itself
G = g_evalm(G_str);		

## Substitute steady-state values
G = g_subs(G, "{u_1,x_1,x_2}", "{0,0,0}")

## Extract the (only) matrix element
G = g_op(G,"0")

## Find numerator and denominator
a = g2o_pol(g_denom(G))
b = g2o_pol(g_numer(G))

## Evaluate numerically
beta = 0.5;
b = eval(b)
a = eval(a)

Deleted mttroot/gino/ginsh.m version [4824a91cb3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function go_out = ginsh (go_in)

  ## usage:  go_out = ginsh (go_in)
  ##         go_out, go_in strings containing valid ginsh code
  ## Interface to ginsh to provide symbolic manipulation within octave
  ## Part of the gino (ginsh-octave) toolbox

  ## Copyright (C) 2002 by Peter J. Gawthrop

  ##   This program is free software; you can redistribute it and/or modify
  ##    it under the terms of the GNU General Public License as published by
  ##    the Free Software Foundation; either version 2 of the License, or
  ##    (at your option) any later version.
  
  ##    This program is distributed in the hope that it will be useful,
  ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
  ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ##    GNU General Public License for more details.
  
  ##    You should have received a copy of the GNU General Public License
  ##    along with this program; if not, write to the Free Software
  ##    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
  command = sprintf("echo '%s;' | ginsh ", go_in); # sh command
  go_out = system(command);	# execute it
  
  if (length(go_out)>0)		# Strip trailing NL
    go_out = substr(go_out,1,length(go_out)-1);
  endif
endfunction

Deleted mttroot/gino/go_append.m version [7b74ee52c4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function new_list = go_append (list,element)

  ## usage:  new_list = go_append (list,element)
  ##
  ## Appends element to list to give new list
  ## This is missing from ginsh
  ## Copyright (C) 2002 by Peter J. Gawthrop

  new_list = deblank(list);	# Remove trailing blanks
  new_list = new_list(1:length(new_list)-1); # Zap final }
  if (g_nops(list)=="0")
    new_list = sprintf("%s%s}", new_list, element);
  else
    new_list = sprintf("%s,%s}", new_list, element);
  endif
  

endfunction

Deleted mttroot/gino/go_diff.m version [5fae555e6a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [dfdx_l, dfdx_m] = go_diff (f,x)

  ## usage:  [dfdx_l dfdx_m] = go_diff (f,x)
  ##
  ## dfdx_l is a list with ith element df/dx
  ## dfdx_m the corresponing matrix (in ginsh form)
  ## f may itself be a list
  ## The elements of x must be symbols

  N = eval(g_nops(f));
  M = eval(g_nops(x));

  dfdx = "{}";

  ## Find derivatives of f for each x_i and append to list
  for j = 1:M
    dfdx = go_append(dfdx, g_diff(f,g_op(x,int2str(j-1))));
  endfor

  ## Convert to matrix and transpose
  dfdx_m = g_transpose(go_lst_to_matrix(dfdx));

  ## And back to a list
  dfdx_l = go_matrix_to_lst(dfdx_m);

endfunction

Deleted mttroot/gino/go_gmatrix2mmatrix.m version [1074e04ce6].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
function M_m = go_gmatrix2mmatrix (M-g)

  ## usage:  M_m = go_gmatrix2mmatrix (M-g)
  ##
  ## Converts a ginsh format matrix to a matlab format matrix

  M_m = strrep(M_g,"],[","];[");

endfunction

Deleted mttroot/gino/go_lin.m version [eb13e9d447].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D] = go_lin (f,g)

  ## usage:  [A,B,C,D] = go_lin (f,g)
  ##
  ## 

  n_x = eval(g_nops(f));		# Number of states
  n_y = eval(g_nops(g));		# Number of outputs

  n_u = n_y;

  ## Create symbolic state list
  x = "{}";
  for i=1:n_x
    x = go_append(x,sprintf("x_%i", i));
  endfor


  ## Create symbolic input list
  u = "{}";
  for i=1:n_u
    u = go_append(u,sprintf("u_%i", i));
  endfor
		  
  [A_l,A] = go_diff(f,x);
  [B_l,B] = go_diff(f,u);
  [C_l,C] = go_diff(g,x);
  [D_l,D] = go_diff(g,u);

endfunction

Deleted mttroot/gino/go_list.m version [e679433787].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function list = go_list (exp0,exp1,exp2,exp3,exp4,exp5,exp6,exp7,exp8,exp9)

  ## usage:  list = go_list
  ## (exp0[,exp1,exp2,exp3,exp4,exp5,exp6,exp7,exp8,exp9])
  ## Creates a list containing the expressions in the argument list
  ## 

  ## Copyright (C) 2002 by Peter J. Gawthrop
  if nargin>10
    error("Only 10  expressions allowed in argument list");
  endif

  N = nargin;

  list=exp0;
  for i=1:N-1
    exp = eval(sprintf("exp%i;",i));
    list=sprintf("%s, %s", list, exp);
  endfor

  list = sprintf("{%s}", list);

endfunction

Deleted mttroot/gino/go_lst_to_matrix.m version [8142b99b12].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function M = go_lst_to_matrix (L)

  ## usage:  M = go_lst_to_matrix (L)
  ##
  ## Converts a list to a matrix
  ## Assumes list contains equal-length lists as elements
  ## Not in ginsh
  ## Copyright (C) 2002 by Peter J. Gawthrop

  n = eval(g_nops(L));
  m = eval(g_nops(g_op(L,"0")));

  M = "";
  for i = 1:n
    M = sprintf("%s[",M);
    m_i = g_op(L,int2str(i-1));
    if (eval(g_nops(m_i))!=m)
      error("All list elements must be lists of same length");
    endif
    
    for j = 1:m
      m_ij = g_op(m_i,int2str(j-1));
      if j>1 
	jsep = ", ";
      else
	jsep = "";
      endif
      M = sprintf("%s%s%s", M, jsep, m_ij);
    endfor
    if i<n 
      isep=", ";
    else
      isep="";
    endif
    
    M = sprintf("%s]%s", M, isep);
  endfor

  M = sprintf("[%s]",M);
  
endfunction

Deleted mttroot/gino/go_matrix_to_lst.m version [a29229a6df].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
function L = go_matrix_to_lst (M)

  ## usage:  L = go_matrix_to_lst (M)
  ##
  ## Converts matrix to list (in ginsh format)

  L = strrep(strrep(M,"[","{"), "]","}");

endfunction

Deleted mttroot/mtt/Makefile version [92a793815c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147



















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/make -f

# Destinations compliant with Filesystem Hierarchy Standard (FHS) 2.1
# DESTDIR prefix required by Debian build process
CONFDIR=$(DESTDIR)/etc
PROGDIR=$(DESTDIR)/usr/bin
INSTDIR=$(DESTDIR)/usr/share/mtt

# DOCPATH and INFOPATH required by doc/Makefile
DOCDIR=$(DESTDIR)/usr/share/doc/mtt
INFODIR=$(DESTDIR)/usr/share/info

# XFIG Libraries directory
XFIGDIR=$(DESTDIR)/usr/share/xfig/Libraries

configure: configure-stamp
configure-stamp:
	@touch configure-stamp

build: configure mtt.sh xmtt.sh build-stamp

build-cc:
	@cd cc ; make -s build

build-doc:
	@cd doc ; make -s all

build-stamp:
	@touch build-stamp

clean:
	@touch clean.sh
	@-chmod a+x clean.sh
	@./clean.sh
	@rm -f clean.sh

clean-cc:
	@touch clean-cc.sh
	@-chmod a+x clean-cc.sh
	@./clean-cc.sh
	@rm -f clean-cc.sh

clean-conf:
	@touch clean-conf.sh
	@-chmod a+x clean-conf.sh
	@./clean-conf.sh
	@rm -f clean-conf.sh

clean-doc:
	@touch clean-doc.sh
	@-chmod a+x clean-doc.sh
	@./clean-doc.sh
	@rm -f clean-doc.sh
	@cd doc ; make -s clean

clean-xfig:
	@touch clean-xfig.sh
	@-chmod a+x clean-xfig.sh
	@./clean-xfig.sh
	@rm -f clean-xfig.sh

distclean: clean clean-cc clean-conf clean-doc clean-xfig
	@-rm -f build-stamp configure-stamp config.log mtt.sh xmtt.sh

install: build clean.sh clean-conf.sh
	@install -d $(INSTDIR) $(CONFDIR) $(PROGDIR)
	@cp -a   bin cc doc lib $(INSTDIR)
	@cat bin/mttrc | grep -v 'MTT_LIB/xfig' |\
	sed 's|$$1|/usr/share/mtt|' > $(CONFDIR)/mtt.conf
	@install mtt.sh  $(PROGDIR)/mtt
	@install xmtt.sh $(PROGDIR)/xmtt

install-cc: build-cc clean-cc.sh
	@install -d $(INSTDIR)/bin/trans
	@install cc/parse_m2cc.exe $(INSTDIR)/bin/trans

install-doc: build-doc clean-doc.sh
	@install -d $(DOCDIR) $(INFODIR)
	@cd doc ; DOCPATH=$(DOCDIR) INFOPATH=$(INFODIR) make -s install-doc
	@cd doc ; install Makefile mtt.info* mtt.pdf mtt.ps.gz $(DOCDIR)
	@install doc/mtt.info* $(INFODIR)

install-xfig: clean-xfig.sh
	@install -d $(XFIGDIR)
	@cp -a   lib/xfig $(XFIGDIR)/MTT_Bond_Graph

.PHONY: FORCE

clean.sh: FORCE
	@echo '#! /bin/sh'						>>clean.sh
	@echo '# This file is auto-generated - do not edit'		>>clean.sh
	@echo 'rm -f  $(PROGDIR)/mtt $(PROGDIR)/xmtt'			>>clean.sh
	@echo 'rm -fr $(INSTDIR)'					>>clean.sh

clean-cc.sh: FORCE
	@echo '#! /bin/sh'						>>clean-cc.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-cc.sh
	@echo 'rm -f  $(INSTDIR)/bin/trans/parse_m2cc.exe'		>>clean-cc.sh

clean-conf.sh: FORCE
	@echo '#! /bin/sh'						>>clean-conf.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-conf.sh
	@echo 'rm -f  $(CONFDIR)/mtt.conf'				>>clean-conf.sh

clean-doc.sh: FORCE
	@echo '#! /bin/sh'						>>clean-doc.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-doc.sh
	@echo 'rm -fr $(DOCDIR)'					>>clean-doc.sh
	@echo 'rm -f  $(INFODIR)/mtt.info*'				>>clean-doc.sh

clean-xfig.sh: FORCE
	@echo '#! /bin/sh'						>>clean-xfig.sh
	@echo '# This file is auto-generated - do not edit'		>>clean-xfig.sh
	@echo 'rm -f  $(XFIGDIR)/MTT_Bond_Graph'			>>clean-xfig.sh

mtt.sh.tmp:
	@echo '#! /bin/sh'						> mtt.sh.tmp
	@echo '# This file is auto-generated - do not edit'		>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo 'mtt_config_file=$(CONFDIR)/mtt.conf'			>>mtt.sh.tmp
	@echo 'mtt_program_dir=$(PROGDIR)'				>>mtt.sh.tmp
	@echo 'mtt_install_dir=$(INSTDIR)'				>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo '# get site-specific settings'				>>mtt.sh.tmp
	@echo 'if [ -r $${mtt_config_file} ]; then'			>>mtt.sh.tmp
	@echo '   . $${mtt_config_file} $${mtt_install_dir} >/dev/null'	>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo 'elif [ -r $${mtt_install_dir}/bin/mttrc ]; then'		>>mtt.sh.tmp
	@echo '   . $${mtt_install_dir}/bin/mttrc $${mtt_install_dir}'	>>mtt.sh.tmp
	@echo 'fi'							>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo '# get user-specific settings'				>>mtt.sh.tmp
	@echo 'if [ -r $${HOME}/.mttrc ]; then'				>>mtt.sh.tmp
	@echo '   . $${HOME}/.mttrc'					>>mtt.sh.tmp
	@echo 'fi'							>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp
	@echo '# get directory-specific settings'			>>mtt.sh.tmp
	@echo 'if [ -r ./.mttrc ]; then'				>>mtt.sh.tmp
	@echo '   . ./.mttrc'						>>mtt.sh.tmp
	@echo 'fi'							>>mtt.sh.tmp
	@echo ''							>>mtt.sh.tmp

mtt.sh: mtt.sh.tmp
	@cat mtt.sh.tmp bin/mtt						> mtt.sh

xmtt.sh: mtt.sh.tmp
	@cat mtt.sh.tmp bin/xmtt					> xmtt.sh

Deleted mttroot/mtt/bin/capitalise_initial version [b5ca98d45c].

1
2
3
4
5
6






-
-
-
-
-
-
#! /bin/sh

phrase="$*"
initial=$(echo $phrase | sed 's/\(.\).*/\1/')
Initial=$(echo $initial | tr [a-z] [A-Z])
echo $phrase | sed s/$initial/$Initial/

Deleted mttroot/mtt/bin/check_integration version [a5d2ce5a34].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Check if obsolete method of specifiying integration method in use.
if [ -f "$1_simpar.txt" ]; then
  method_line=`grep -i METHOD  $1_simpar.txt`
  if [ -n "`echo $method_line | grep -i euler`" ]; then
     echo "$1_simpar.txt contains Euler method - please use mtt -i euler in future"
     mtt_switches="$mtt_switches -i euler";
  elif [ -n "`echo $method_line | grep -i implicit`" ]; then
     echo "$1_simpar.txt contains Implicit method - please use mtt -i implicit in future"
     mtt_switches="$mtt_switches -i implicit";
  fi
fi

echo Invoking mtt $mtt_switches $1 $2 $3 $4

mtt $mtt_switches $1 $2 $3 $4

Deleted mttroot/mtt/bin/mtt version [d8412334b4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt
# This is the main shell script for MTT

# P.J.Gawthrop Oct 1989, Dec 1989, 1990, 1991, Oct 1993, Dec 1993, Jan 1994, Dec 95, Nov 1996.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997,1998,1999
# Copyright (C) 2000 by Peter J. Gawthrop
# Copyright (C) 2001 by Peter J. Gawthrop


###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.419  2014/04/18 02:02:08  gawthrop
## Added sum.tex representation -- this was in a very old MTT and
## summerises the structure.
##
## Revision 1.418  2013/07/19 05:40:26  gawthrop
## Added -nas (No alphabetic sort) switch in help options
##
## Revision 1.417  2008/07/22 17:37:01  geraint
## Fixed case of MTT_EXAMPLES
##
## Revision 1.416  2006/09/27 13:03:20  geraint
## Fixed fr.view and enabled commands to directly build ??fr.m
##
## Revision 1.415  2006/02/09 23:58:24  geraint
## rtxi: builds but does not yet work.
##
## Revision 1.414  2005/11/18 17:23:19  geraint
## rtxi.
##
## Revision 1.413  2005/11/16 00:43:15  geraint
## rtxi
##
## Revision 1.412  2005/09/29 13:46:25  gawthrop
## Converts labg.fig -> ps/eps correctly (using fig2ps)
##
## Revision 1.411  2005/03/15 15:03:28  gawthrop
## Now works for Hierarchical systems
##
## Revision 1.410  2005/03/15 13:35:50  gawthrop
## Pretty abg figure in reports.
##
## Revision 1.409  2005/03/15 12:03:17  gawthrop
## New labg.fig rep - pretty LaTeX figures.
##
## Revision 1.408  2005/02/18 16:59:02  gawthrop
## Don't check files when using -s
##
## Revision 1.407  2005/02/17 18:36:38  geraint
## Removed a bash-ism: replaced [[ conditional ]] with [ conditional ]
##
## Revision 1.406  2005/01/06 15:36:06  geraint
## Tidied output of options.
##
## Revision 1.405  2005/01/06 12:47:53  geraint
## Fixed generation of sese.r with -make-sort option.
##
## Revision 1.404  2004/09/10 21:05:15  geraint
## Ensure that the system exists before proceeding.
## This should stop me from copying my home directory to MTT_work.
##
## Revision 1.403  2004/09/07 20:38:44  geraint
## Applies CRs before creating sese.make to avoid Circular dependencies.
##
## Revision 1.402  2004/09/03 08:35:27  geraint
## Copies Perl CRs to an mtt subdirectory (=> mtt:: workspace).
##
## Revision 1.401  2004/09/02 22:04:06  geraint
## Passes ${use_reduce} to mtt_make_sympar so that it can decide
## if to issue warnings about Reduce reserved words
##
## Revision 1.400  2004/08/31 01:29:48  geraint
## CRs are applied to sorted equation files during production.
##
## Revision 1.399  2004/08/29 16:09:49  geraint
## Added option -no-reduce
##
## Code sorting can now be used with Reduce (via sese.r) so that existing CRs
## work with sorted code (using -make-sort or -sort), or without by using
## -no-reduce; this option implies -make-sort.
##
## Revision 1.398  2004/08/29 14:39:23  geraint
## Added rule to create dae from sorted equations (sese) if sorting is requested.
##
## Revision 1.397  2004/08/29 13:17:30  geraint
## Added rules to use sae (sorted algebraic equations) instead
## of ae if sorted equations are being used.
##
## Converted temporary variable names to lowercase in sorted
## sympar.h to match code output from mtt_r2m.
##
## Revision 1.396  2004/08/29 02:59:30  geraint
## Added -make-sort option and rules to generate simulation using sesx and sesy.
##
## Revision 1.395  2004/08/28 23:48:06  geraint
## Removed dependency of ae.r on cse.r if -ae is not specified as an option.
## This prevents an implicit -A and thus removes a dependency on cse
## (and hence Reduce) for sorted systems.
##
## Revision 1.394  2004/08/28 22:14:12  geraint
## Removed -ibg option: now the default method.
##
## Revision 1.393  2004/08/26 16:20:17  geraint
## Creates postscript files of either dia or fig bond graphs.
##
## Revision 1.392  2004/08/26 12:50:12  geraint
## Replaced some implicit rules with explicit tests and patterns.
## Better than having make search through every possible implicit rule.
##
## Revision 1.391  2004/08/26 00:07:06  geraint
## Added rule to create cbg.dia.
##
## Revision 1.390  2004/08/13 09:49:13  geraint
## Only use one level of MTT_work to prevent MTT from repeatedly copying or creating the same files.
##
## Revision 1.389  2004/08/13 01:32:03  geraint
## Use ibg.m by default for both Xfig and Dia models.
##
## Revision 1.388  2004/08/11 08:18:07  geraint
## Ignores diy make files if the file ${rep}_rep.make.ignore exists, thus allowing user-defined makefiles to use the default MTT rules for languages which they do not override. See odes_rep.make and odeso_rep.make for an example of its use.
##
## Revision 1.387  2004/08/11 07:44:18  geraint
## Included cmp.m as a prerequisite for abg.m
##
## Revision 1.386  2004/08/05 00:02:57  geraint
## Uses lbl2cmp_txt2m.pl to generate _cmp.m.
##
## Revision 1.385  2004/08/02 20:25:47  geraint
## abg.m requires lbl.txt to allow units to be checked.
##
## Revision 1.384  2004/08/01 20:13:30  geraint
## ibg2abg transformation does not require lbl.txt (directly)
##
## Revision 1.383  2004/08/01 19:50:07  geraint
## Moved rules for ibg.m and abg.m so that -ibg can be used with dia models.
## Need to create cmp.m files before this combination will work.
##
## Revision 1.382  2003/09/23 20:53:49  geraint
## Updated version number (5.0).
##
## Revision 1.381  2003/08/10 18:56:55  gawthrop
## Explicitly generate eps files
##
## Revision 1.380  2003/08/06 14:44:51  gawthrop
## Don't include -q or -u in long file names via ${__ARGS}
##
## Revision 1.379  2003/08/06 10:33:42  gawthrop
## User now warned not to use -c which is unsupported.
##
## Revision 1.378  2003/08/04 09:15:09  gawthrop
## -ss switch reinstated
##
## Revision 1.377  2003/06/11 15:48:02  gawthrop
## Copies (aliased) subsystems first.
## Include switches in .ps file names.
##
## Revision 1.376  2003/05/09 09:46:35  gawthrop
## Fixed html output of figures
##
## Revision 1.375  2003/05/08 18:42:52  gawthrop
## Generate pdf from ps (using hyperref package for links etc)
##
## Revision 1.374  2003/04/17 20:57:27  geraint
## Added -sort option to allow direct generation of ode2odes.m using sese.m
## instead of ode/csex.
##
## "mtt -sort rc odeso view" works without Reduce installed!!!
##
## Revision 1.373  2003/04/17 20:07:32  geraint
## Added rule to create _sese.m
##
## Revision 1.372  2003/03/24 12:03:36  gawthrop
## Added -I switch to sese transformation
##
## Revision 1.371  2003/03/13 15:47:35  gawthrop
## Added sese rep.
##
## Revision 1.370  2003/02/11 20:04:08  geraint
## Reverted to line-by-line optimisation as default and added caution to
## description of -optg.
##
## Global optimisation has been observed to create assignments using
## uninitialised temporary variables.
##
## Revision 1.369  2003/02/06 20:28:40  geraint
## Added -ibg switch to aid testing during development of ibg2abg.m
##
## Revision 1.368  2002/12/12 17:18:41  geraint
## Fixed [ 647664 ] Namespace clash: LANG
## Prepended MTT_ to SYS, OPTS and LANG environment variables.
##
## Revision 1.367  2002/12/09 00:14:08  geraint
## Hierarchical dia and mixed dia/fig bond graphs now working.
##
## Revision 1.366  2002/12/06 21:56:21  geraint
## Cosmetic change: removed commented-out lines.
##
## Revision 1.365  2002/12/06 12:45:25  gawthrop
## Simplified rule for sub.sh: both fig and dia go via cmp.txt now.
##
## Revision 1.364  2002/12/03 23:28:44  geraint
## Added dependencies for bond graphs built with dia.
##
## Revision 1.363  2002/11/30 13:39:50  gawthrop
## Split abg2lbl_fig2txt into two parts:
##   abg2cmp_fig2txt
##   cmp2lbl_txt
## and incorporated into mtt
##
## Revision 1.362  2002/09/19 08:12:53  gawthrop
## Merged version after documentation update
##
## Revision 1.361  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.360.2.3  2002/09/16 07:59:26  geraint
## Changed default optimisation to global.
##
## Revision 1.360.2.2  2002/09/04 10:44:59  geraint
## Added option to specify number of tmp variables declared (-ntmpvar <N>).
##
## Revision 1.360.2.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.360  2002/08/20 15:51:16  gawthrop
## Update to work with ident DIY rep
##
## Revision 1.359  2002/08/07 14:27:14  geraint
## Changes to make "-i dassl" work again.
##
## Revision 1.358  2002/08/07 11:04:40  geraint
## Now updates timestamp on lbl.txt after processing in make. This eliminates the delay where MTT spends a long period of time uselessly recursing through the model on subsequent passes if the label file is older than the bondgraph.
##
## Revision 1.357  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.356  2002/06/17 13:14:50  geraint
## Fixed some rules to reduce number of implicit rule searches.
##
## Revision 1.355  2002/06/10 23:18:44  geraint
## Adjusted cr.h comment delimiters to be C compliant.
##
## Revision 1.354  2002/06/10 10:43:19  gawthrop
## ode2odes now prerequisite for sim.m and ssim.m
##
## Revision 1.353  2002/05/28 18:08:38  geraint
## Fixed [ 547294 ] CRs are not sought from MTT_CRS.
##
## Revision 1.352  2002/05/24 11:04:10  geraint
## Removed unnecessary message about *.log file not existing when -D option is used.
##
## Revision 1.351  2002/05/23 17:08:20  geraint
## `mtt sys sfun zip` now produces an input block and an interface block for MTT models.
## Models can be embedded within larger Simulink models by the 2 ports.
## The user must edit 2 code blocks in <sys>_sfun_interface.c before compiling with mex.
##
## Revision 1.350  2002/05/21 08:45:36  gawthrop
## DIY reps: no longer skips rep if file exists already.
## Avoids problems in rep.txt when options change
##
## Revision 1.349  2002/05/20 10:29:59  gawthrop
## -oct now forces an m target language to be oct
## (if the rep is an the list: "ae input logic numpar simpar state")
##
## Revision 1.348  2002/05/20 08:50:12  geraint
## Cleans _sfun_ae.mexglx.
##
## Revision 1.347  2002/05/20 07:12:05  gawthrop
## Trying to get oct files generated with -oct
##
## Revision 1.346  2002/05/17 11:15:38  gawthrop
## Messages about copying when using -dr now only appear in verbose (-v) mode.
##
## Revision 1.345  2002/05/15 14:22:25  geraint
## Code for Simulink S-function target written direct to sfun.cc instead of
## calling .mexglx files. This eliminates the sfun dependency on Octave
## ColumnVectors. sys_sfun.cc should build directly on a MS Windows machine
## (can't test this yet).
##
## added sfun.zip target to create source code to export.
##
## Revision 1.344  2002/05/11 01:14:17  geraint
## Fix for [ 553218 ] simpar.oct and simpar.m different.
## Translation added between ColumnVector in base .cc and Octave_map in .oct.
##
## Revision 1.343  2002/05/10 14:07:16  geraint
## Preserve .cc files.
##
## Revision 1.342  2002/05/10 13:24:58  geraint
## Added initial support for building Simulink S-functions.
## Rates do not update properly yet.
## Inertial switches do not work yet.
## Implicit integration not supported yet.
##
## build with: mtt -i euler MotorGenerator sfun mexglx.
##
## Revision 1.341  2002/05/09 15:40:22  gawthrop
## -dr touches copied files to redo timestamp
##
## Revision 1.340  2002/05/08 22:13:47  geraint
## Removed redundant path from mtt_*.cc targets in mexglx build line.
##
## Revision 1.339  2002/05/08 21:32:26  geraint
## Tidied up $1_ode2odes_*.* targets and renamed dummies as *.stamp.
##
## Revision 1.338  2002/05/08 16:03:32  geraint
## Added mex support for ode2odes: mtt sys ode2odes mexglx.
## This mex stuff seems to require octave2.1-headers.
##
## Revision 1.337  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.336  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.335  2002/05/01 17:30:55  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
## if necessary.
##
## Revision 1.334  2002/05/01 14:10:22  gawthrop
## Added -dr foo (reads from dir foo) option
##
## Revision 1.333  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.332  2002/04/26 23:19:00  geraint
## Fixed path to info files for "mtt info".
##
## Revision 1.331  2002/04/19 09:24:29  gawthrop
## 2 changes to ode2odes_out generation: only compiles the specified c
## file; outside the computation=c clause
##
## Revision 1.330  2002/04/17 10:03:12  geraint
## Marked .sg as a major representation.
##
## Revision 1.329  2002/04/16 14:58:00  gawthrop
## mtt copy does NOT now copy the CVS directory
## $directory --> ${directory}  (just to be tidy)
##
## Revision 1.328  2002/02/19 16:27:05  geraint
## Changes to make MTT work out of the box with Debian.
##
## Revision 1.327  2001/11/15 02:56:17  geraint
## Added DASSL as an option for solution of algebraic equations (-ae dassl).
## Requires octave-2.1.35.
##
## Revision 1.326  2001/10/26 01:01:47  geraint
## fixcc when rdae_is_dae (-cr).
##
## Revision 1.325  2001/10/11 03:15:55  geraint
## Fixed make dependencies for c++ simulation code
## - re-simulation no longer required for different output format.
##
## Revision 1.324  2001/10/05 23:39:43  geraint
## Made odes.dat2 .PRECIOUS to prevent deletion when simulation receives ^C.
##
## Revision 1.323  2001/08/08 02:14:59  geraint
## Rationalisation of solver code, beginning with algebraic solvers.
##
## Revision 1.322  2001/08/01 04:06:07  geraint
## Added -i dassl for -cc and -oct.
##
## Revision 1.321  2001/07/27 23:43:34  geraint
## Added -cc to usage options (required for use with xmtt).
##
## Revision 1.320  2001/07/27 23:38:38  geraint
## Changed comment below (# SUMMARY) - fixes xmtt.
##
## Revision 1.319  2001/07/27 23:29:10  geraint
## *** empty log message ***
##
## Revision 1.318  2001/07/24 04:17:30  gawthrop
## Removed all " from # SUMMARY lines - messes up xmtt
##
## Revision 1.317  2001/07/24 00:55:17  gawthrop
## Resolved clashes -- marked with ## >>>
##
## Revision 1.316  2001/07/22 19:24:03  geraint
## Multiple '-v' increases verbosity.
##
## Revision 1.315  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.314  2001/07/13 04:19:03  gawthrop
## Now loads _subs.r with _cr.r file when using -cr option
##
## Revision 1.313  2001/06/13 14:53:59  gawthrop
## MTT now gas the double-colon option in the abg.fig file
## eg R:r:a^2+3*b
##
## Revision 1.312  2001/06/11 19:43:49  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.311  2001/05/26 18:36:43  gawthrop
## Further modifications. Now works on rcPPP
##  -- next jobs:
##     add identification to ppp_nlin_sim
##     create real-time ppp_nlin_run
##
## Revision 1.310  2001/05/08 08:30:12  gawthrop
## Added line to reverse the x^y --> pow(x,y) in default  _simp file to
## prettyfy LaTeX
##
## Revision 1.309.2.3  2001/07/13 04:02:31  geraint
## Implemented numerical algebraic solution for _ode2odes.oct.
##
## Revision 1.309.2.2  2001/06/05 03:20:39  geraint
## added -ae option to select algebraic equation solution method.
##
## Revision 1.309.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.309  2001/04/28 03:15:03  geraint
## Fixed comment (interfered with "mtt help representations").
##
## Revision 1.308  2001/04/25 22:17:45  geraint
## Fixed icd.txt2 dependency.
##
## Revision 1.307  2001/04/15 21:15:41  geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.305  2001/04/11 09:44:26  gawthrop
## Fixed cc and c problems to do with pow(x,y) and integers
## mtt/lib/reduce/fix_c.r is included in rdae2dae and cse2smx_lang for
## -c, -cc and -oct options
##
## Revision 1.304  2001/04/11 07:35:22  gawthrop
## Now uses system_cr.h in place of system.h in .c rep -
##   compatible with older code
##
## Revision 1.303  2001/04/10 12:54:50  gawthrop
## Minor fixes for sensitivity versions
##
## Revision 1.302  2001/04/06 05:24:30  geraint
## -stdin for .cc reps.
##
## Revision 1.301  2001/04/05 03:46:12  geraint
## Added mtt_prepend.sh, -p preserves time attribute of base file
## - eliminates error in dependencies due to update of ese.r by modpar.r.
##
## Revision 1.300  2001/04/04 10:06:49  gawthrop
## New ssim (sensitiveity simulation) rep
##
## Revision 1.299  2001/04/03 14:49:42  gawthrop
## Revised to incorporate new ssim (sensitivity simulation)
## representation (m only just now).
##
## Revision 1.298  2001/04/02 17:36:20  gawthrop
## Resolved $sys name clash when using -s
##
## Revision 1.297  2001/03/29 19:20:45  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.296  2001/03/27 01:07:34  geraint
## Improved determination of Octave version for ode2odes.exe creation.
## Removed FORCE check_update of .txts.
##
## Revision 1.295  2001/03/23 11:21:29  gawthrop
## Show -pdf oprion in help list
##
## Revision 1.294  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.293.2.8  2001/03/19 01:35:31  geraint
## Reverted forced update check to main branch form, ready for merge.
##
## Revision 1.293.2.7  2001/03/17 09:51:06  geraint
## Implemented Runge-Kutta IV fixed-step method (-i rk4).
##
## Revision 1.293.2.6  2001/03/03 06:50:38  geraint
## Added summary lines for ode2odes.
##
## Revision 1.293.2.5  2001/03/03 00:27:14  geraint
## Fixed ar options to work with GNU ar. Allow mtt to create dependencies for mtt_%.cc when making mtt_%.oct.
##
## Revision 1.293.2.4  2001/03/02 00:45:21  geraint
## Separated Euler and Implicit methods in .cc code and dependencies.
##
## Revision 1.293.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.293.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.293.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.293  2001/02/06 04:39:08  geraint
## Added _standalone.exe representation.
##
## Revision 1.292  2001/02/05 17:27:40  gawthrop
## Make sure _def.r exists before creating _state.txt
##
## Revision 1.291  2000/12/27 14:50:40  peterg
## This is the first CVS version (4.9).
## Commented out code now deleted
##
## Revision 1.290  2000/12/05 09:59:37  peterg
## Generates $1_cr.h - allows inclusion of c functions for crs
##
## Revision 1.289  2000/12/05 09:01:52  peterg
## Changed == to =
##
## Revision 1.288  2000/12/01 17:59:01  peterg
## Added .PRECIOUS: %.cc to hang on to cc files - thanks Geraint
##
## Revision 1.287  2000/12/01 16:04:24  peterg
## More partitioning achieved -- now needs the connections to be properly
## sorted in cbg2ese_r
##
## Revision 1.286  2000/12/01 14:18:44  peterg
## -partition now partially works up to cse.m
##   but need to think about indexing, struc files etc for subsystems.
##
## Revision 1.285  2000/11/27 11:51:21  peterg
## Fixed a few pdf /fig bugs
##
## Revision 1.284  2000/11/27 10:33:35  peterg
## -pdf option now coerces ps-->pdf
##
## Revision 1.283  2000/11/24 15:11:50  peterg
## -pdf switch for simple displays
##
## Revision 1.282  2000/11/24 14:53:53  peterg
## Added lagrange rep : lde.r and lde.tex
##
## Revision 1.281  2000/11/16 13:51:15  peterg
## Added units stuff
##
## Revision 1.280  2000/11/10 14:45:16  peterg
## Finished up changes to incorporate Geraint's cc stuff
##
## Revision 1.279  2000/11/08 09:51:52  peterg
## Started incorporating Geraints CC/oct conversions
##
## Revision 1.278  2000/11/07 16:39:21  peterg
## *** empty log message ***
##
## Revision 1.277  2000/10/17 09:54:07  peterg
## logic rep sorted out
##
## Revision 1.276  2000/10/15 09:30:31  peterg
## *** empty log message ***
##
## Revision 1.275  2000/10/12 18:38:47  peterg
## New method of sympar generation implemented - uses mtt_make_sympar
## Check/update of numpar.txt is forced.
##
## Revision 1.274  2000/10/12 15:11:54  peterg
## Added the update function for numpar only
##
## Revision 1.273  2000/10/10 21:00:27  peterg
## More changes for new code gneration
##
## Revision 1.272  2000/10/06 16:20:00  peterg
## added ode_write rule
##
## Revision 1.271  2000/10/03 12:14:25  peterg
## Version 4.8
##
## Revision 1.270  2000/10/03 12:13:51  peterg
## Corrected MTT_LIB paths
##
## Revision 1.269  2000/09/30 14:12:03  peterg
## Fixed bug with no-parameter systems - changed mtt_txt2m and mtt_m2p
##
## Revision 1.268  2000/09/27 16:15:55  peterg
## Now sh (as opposed to bash) compatible -  fixed dat22dat again
##
## Revision 1.267  2000/09/21 10:08:30  peterg
## Version 4.7.1 - bug in odes.dat representation fixed in dat22dat
##
## Revision 1.266  2000/09/19 07:47:38  peterg
## fig2dev back to eps - ps produces a4 style output.
##
## Revision 1.265  2000/09/19 07:45:28  peterg
## Version 4.7
##
## Revision 1.264  2000/09/15 08:37:27  peterg
## Fixed bug using -sub in cbg view
##
## Revision 1.263  2000/09/15 07:33:35  peterg
## Replace fig2dev language eps by ps to avoid version problem.
##
## Revision 1.262  2000/09/14 17:16:33  peterg
## Fixes some outstanding bugs:
##   perpendicular strokes in cbg.fig
##   proper display of hierachical cbg file (-sub and -viewlevel)
##
## Revision 1.261  2000/09/14 12:43:46  peterg
## view of ps s files now uses -sub and -viewlevel options
##
## Revision 1.260  2000/09/14 09:59:08  peterg
## Added -viewlevel switch
##
## Revision 1.259  2000/09/11 08:21:27  peterg
## Introduced MML - but for _tf rep only.
##
## Revision 1.258  2000/09/11 08:17:28  peterg
## Extended _simp.r to incude default switches
##
## Revision 1.257  2000/09/02 15:53:53  peterg
## Now does partitioning up to dae.view
##
## Revision 1.256  2000/09/02 14:24:06  peterg
## -sub switch introduced - works up to dae.r
##
## Revision 1.255  2000/08/30 11:43:04  peterg
## Put in the -opt switch for code optimisation
##
## Revision 1.254  2000/08/29 09:59:47  peterg
## Version 4.5 -- includes code optimisation using the "Scope" package in reduce
##
## Revision 1.253  2000/08/24 08:53:35  peterg
## New makesubs to create a .subs.r file with output switches to simplify output.
##
## Revision 1.252  2000/08/09 10:31:17  peterg
## Use -d option to find if its a book-style report
##
## Revision 1.251  2000/08/04 10:54:33  peterg
## Rationalised call to gcc using -lp2c to access p2c lib.
##
## Revision 1.250  2000/08/01 19:29:27  peterg
## Explcit zero of input in the simulations
##
## Revision 1.249  2000/08/01 12:28:02  peterg
## VERSION 4.4
##    euler now works
##    stepfactor applies to both int. algorithms
##
## Revision 1.248  2000/07/20 07:46:07  peterg
## Version 4.3
##
## Revision 1.247  2000/07/13 07:21:12  peterg
## Interface to Octave Control Systems Toolbox (OCST) - mtt2sys.m
##
## Revision 1.246  2000/05/21 18:00:11  peterg
## Make manual if not already done.
## Released 4.2 version
## (Train Durham -- Glasgow).
##
## Revision 1.245  2000/05/19 17:50:10  peterg
## Changes to state rep - now has parameter
##
## Revision 1.244  2000/05/19 14:19:46  peterg
## Added library path for representations
##
## Revision 1.243  2000/05/19 11:36:36  peterg
## Added logic rep.
##
## Revision 1.242  2000/05/18 20:12:02  peterg
## Version 4.2
##
## Revision 1.241  2000/05/16 11:42:14  peterg
## Addded /usr/lib/libp2c.a  to gcc
##
## Revision 1.240  2000/05/10 09:38:58  peterg
## Added Make to list of copied files.
##
## Revision 1.239  2000/04/11 18:08:33  peterg
## Fixed cse.tex bug
##
## Revision 1.238  2000/04/10 10:06:41  peterg
## Sorted out implicit rules for p2oct conversion
##
## Revision 1.237  2000/04/07 19:10:24  peterg
## New smxa and smxax reps
##
## Revision 1.236  2000/04/06 10:55:36  peterg
## Removed debug lines
##
## Revision 1.235  2000/04/06 10:52:53  peterg
## Replace $PWD with `pwd` for sh compatibility
##
## Revision 1.234  2000/04/04 16:14:08  peterg
## Sorted mtt help
##
## Revision 1.233  2000/03/16 10:16:11  peterg
## Clean no longer zaps the abg.m files
##
## Revision 1.232  2000/03/16 09:43:35  peterg
## Put in $mtt_switches in mtt comand line when creating _state.txt and
## _input.txt
##
## Revision 1.231  2000/03/15 21:24:23  peterg
## Version 4.1:
##   Fixed problems with -abg mode
##   Old-style SS lbl no longer supported
##
## Revision 1.230  2000/03/15 20:31:06  peterg
## Replaced lbl2cr by abg2cr_m2txt
##
## Revision 1.229  2000/03/15 19:39:40  peterg
## Replaced sub creation cmp2sub_m2sh by abg2sub_m2sh
##
## Revision 1.228  2000/03/07 10:54:14  peterg
## Added  $1_lbl.txt to sympar.txt
##
## Revision 1.227  2000/02/16 15:05:46  peterg
## Replaced spurious 8spaces by tab
##
## Revision 1.226  2000/02/10 18:51:31  peterg
## Included OFF exp; in subs.r default
##
## Revision 1.225  2000/02/10 15:03:10  peterg
## Put subs.r file into the m-code generation -- allows the off exp;
## switch for simpler expresions.
##
## Revision 1.224  2000/02/08 10:27:04  peterg
## Removed obselete .h stuff
##
## Revision 1.223  2000/02/08 09:55:00  peterg
## Added .oct language for ode
## -- octave loadable builtin
##
## Revision 1.222  1999/12/23 10:03:42  peterg
## Added $1_sympars.txt to numpar.m target
##
## Revision 1.221  1999/12/22 05:15:51  peterg
## Set to version 4.0.
##
## Revision 1.220  1999/12/17 03:17:57  peterg
## reps_made is now $1_reps_made - stops clash between two reps per directory
##
## Revision 1.219  1999/12/14 00:36:50  peterg
## Changed $source to $stdin and added to mtt_m2p arg list
##
## Revision 1.218  1999/12/03 00:04:50  peterg
## Version to eric.
## -stdin switch added
##
## Revision 1.217  1999/11/16 22:15:55  peterg
## Changed compcopy to test for abg, not lbl file
##
## Revision 1.216  1999/11/16 05:53:21  peterg
## Added sensitivity (-s) switch
##
## Revision 1.215  1999/11/15 22:45:31  peterg
## Reorganised integration method using -i switch
## Introduced -r (reset) switch
##
## Revision 1.214  1999/11/14 21:27:11  peterg
## *** empty log message ***
##
## Revision 1.213  1999/09/02 23:24:40  peterg
## Now explicitly generates executable _ode2odes.out file
## Which takes command line arguments
##
## Revision 1.212  1999/08/18 06:20:32  peterg
## Put -u back again .....
##
## Revision 1.211  1999/08/17 04:10:38  peterg
## Removed the -u switch from cp - it doesnt work on non GNU cps
##
## Revision 1.210  1999/08/02 12:52:12  peterg
## Removed redundant .p copying.
##
## Revision 1.209  1999/07/27 03:50:13  peterg
## Fixed odeo.p bug.
## Fixed compound object bug in fig.
##
## Revision 1.208  1999/07/20 23:43:05  peterg
## V 3.8 ( to Eric)
##
## Revision 1.207  1999/04/02 07:17:37  peterg
## Upped version to 3.6 -- the new implicit solver with switches
##
## Revision 1.206  1999/04/02 06:28:54  peterg
## New implicit method - solves numerical prob with ISW
##
## Revision 1.205  1999/03/15 23:27:43  peterg
## Modified generation of odes.dat2 data
##
## Revision 1.204  1999/03/15 05:53:33  peterg
## Put in user-defined representations
##
## Revision 1.203  1999/03/08 03:51:12  peterg
## Version 3.5 for Linux Red Hat 5.2 (Newcastle)
##
## Revision 1.202  1999/02/17 01:59:20  peterg
## Now handles html copy correctely (ie mv directory to ..)
## Fixed path probs with html
##
## Revision 1.201  1999/02/16 03:50:09  peterg
## Removed explicit _smx targets
##
## Revision 1.200  1998/12/03 17:11:03  peterg
## Added -dc (derivative causality) switch.
##
## Revision 1.199  1998/12/03 16:53:50  peterg
## Now completes causality using component, not bond, status.
##
## Revision 1.198  1998/11/20 16:12:30  peterg
## Now copies aliased systems BEFORE generating rgb etc.
##
## Revision 1.197  1998/11/20 09:00:45  peterg
## Number of changes to underlying tools
##
## Revision 1.196  1998/11/10 11:55:40  peterg
## Added $info_switch to abg2cbg invocation
##
## Revision 1.195  1998/10/28 13:58:57  peterg
## Added $1_sympars.txt prerequisite to _tf.m target
##
## Revision 1.194  1998/10/20 09:00:43  peterg
## Added a few summary lines - to help with xmtt
##
## Revision 1.193  1998/10/01 16:11:42  peterg
## Implicit integration now handles switches
##
## Revision 1.192  1998/09/29 20:09:46  peterg
## Fixed nyfr and nifr plotting bug
##
## Revision 1.191  1998/09/02 12:05:39  peterg
## Added INPUT to simpar
## Revision 1.190  1998/09/02 11:48:51  peterg
## VERSION 3.2 (Swansea)
## abg data structure now uses explicti port and subsystem lists so that
## processing is in predetermined order.
##
## Revision 1.189  1998/08/31 10:49:15  peterg
## Minor changes to -abg operation
##
## Revision 1.188  1998/08/27 08:33:21  peterg
## New reduce integration methods - euler/Implicit only
##
## Revision 1.187  1998/08/25 20:06:56  peterg
## New data structure for abg.m and cbg.m
##
## Revision 1.186  1998/08/18 10:49:05  peterg
## VERSION 3.1 release
##
## Revision 1.185  1998/08/18 09:21:14  peterg
## Removed "" from default simpar file.
##
## Revision 1.184  1998/08/18 09:08:26  peterg
## Now grabs components (specified in lbl file as alias) at the rbg stage
## - this makes sure that they are there when needed.
##
## Revision 1.183  1998/08/18 08:48:43  peterg
## Sorted out problem with ifeq ($REPTYPE,data) block - added else.
##
## Revision 1.182  1998/08/17 15:48:39  peterg
## Replaced SVD solver with LUD solver
##
## Revision 1.181  1998/08/15 13:45:28  peterg
## Added new integration methods in Pascal/c version
## Revised the various translations appropriately
##
## Revision 1.180  1998/08/12 14:15:13  peterg
## Implicit integration - c implemetation now included.
##
## Revision 1.179  1998/08/12 12:29:18  peterg
## Put back some of the args stuff -- needed for plots.
##
## Revision 1.178  1998/08/11 13:38:35  peterg
## Zapped the obsolete args stuff
##
## Revision 1.177  1998/07/30 17:32:44  peterg
## VERSION 3.0
##
## Revision 1.176  1998/07/27 20:25:15  peterg
## Sorted out new mtt_r2m
##
## Revision 1.175  1998/07/27 18:49:09  peterg
## Fixed the frequency stuff
##
## Revision 1.174  1998/07/27 07:10:10  peterg
## Removed dummy global stuff.
##
## Revision 1.173  1998/07/26 14:38:20  peterg
## *** empty log message ***
##
## Revision 1.172  1998/07/26 11:13:38  peterg
## Fixed name classes with globs - ide is that all @strong{MTT} variables
## start with @strong{MTT}
##
## Revision 1.171  1998/07/25 20:37:22  peterg
## Removes -s (switches) option -- they are now assumed to be present
## I still need to shift the old switch
##
## Revision 1.170  1998/07/25 19:16:22  peterg
## Sorted out sympar + switch variables - new sympars rep combines both
##
## Revision 1.169  1998/07/25 16:35:12  peterg
## Incorporated mtt_p2c (uses p2c)
##
## Revision 1.168  1998/07/25 09:44:25  peterg
## Uses Pascal as step on the way to c code -- MUCH nicer!
## State and input now use the simple default - no steady states
##
## Revision 1.167  1998/07/24 17:10:34  peterg
## *** empty log message ***
##
## Revision 1.166  1998/07/22 08:37:30  peterg
## Implicit integration now the default - for octave anyway.
##
## Revision 1.165  1998/07/19 16:00:22  peterg
## Added smx representation
##
## Revision 1.164  1998/07/17 19:45:58  peterg
## Component aliases implemented.
##
## Revision 1.163  1998/07/17 08:27:33  peterg
## Added find target
##
## Revision 1.162  1998/07/16 16:14:27  peterg
## Now stops if a transformation forces error.
##
## Revision 1.161  1998/07/08 11:21:32  peterg
## Added -I switch
##
## Revision 1.160  1998/07/04 11:38:51  peterg
## Version 3.0-- (Seascale)
##
## Revision 1.159  1998/07/04 11:37:43  peterg
## Aliases implemented for parameters + lots of associated goodies
## New-style lbl files - no more SS nonsense.
##
## Revision 1.158  1998/07/03 09:06:39  peterg
## Alias implemented for ports
##
## Revision 1.157  1998/07/01 10:22:11  peterg
## Moved tidy stuff to end of preamble -- needed to make muti-plot copy
## correctely
## Now copies ps file with arguments to WD
##
## Revision 1.156  1998/06/26 14:19:43  peterg
## Copy hidden files (eg .octaverc) in tidy mode
##
## Revision 1.155  1998/06/24 07:43:42  peterg
## Version 2.91 -- includes implicit integration (octave)
##
## Revision 1.154  1998/06/17 14:14:09  peterg
## Removed struc.txt prerequisite for simpar.txt - switch version
##
## Revision 1.153  1998/05/28 09:36:38  peterg
## --version and --versions switch
##
## Revision 1.152  1998/05/24 15:43:10  peterg
## Added symbolic solution of alg. equations (-A)
##
## Revision 1.151  1998/05/23 16:18:37  peterg
## ordinary differential equation.m files generated with the new ode2lang
## method.
##
## Revision 1.150  1998/05/19 19:47:37  peterg
## Updated the odesso representation to use simpar file.
##
## Revision 1.149  1998/05/14 15:16:13  peterg
## Sorted out Differential-Algebraic Equation simulation
## Added LSODE methode to ordinary differential equation simulation
##
## Revision 1.148  1998/05/12 14:42:07  peterg
## Added ese_tidy and new method for organising ese files -
## Each subsystem has an array of variables - effort, flow and state for
## each bond
##
## Revision 1.147  1998/04/15 18:41:47  peterg
## Fixed various probs with multiple systems in one directory
##
## Revision 1.146  1998/04/04 11:00:20  peterg
## Modified various parts to allow coercing directions at ports
##
## Revision 1.145  1998/04/03 11:17:44  peterg
## VERSION 2.9
##
## Revision 1.144  1998/03/27 13:32:25  peterg
## Removed sympar prerequisites from ss reps.
##
## Revision 1.143  1998/03/22 21:14:03  peterg
## Added obspar.r representation
## Help now case insensitive
##
## Revision 1.142  1998/03/20 15:09:26  peterg
## Changed order of prerequisites for _dae.r to put _rdae.r first.
##
## Revision 1.141  1998/03/11 10:45:19  peterg
## Added rclean - recursive clean
##
## Revision 1.140  1998/03/09 10:23:30  peterg
## PS view now runs as a background process.
##
## Revision 1.139  1998/03/07 16:04:23  peterg
## Added some more txt view reps: input, lbl, numpar, state
##
## Revision 1.138  1998/03/07 15:23:40  peterg
## Uses sort_sympar to uniquely produce the sympar list.
##
## Revision 1.137  1998/03/07 14:04:17  peterg
## dae creation split into 2 parts:
## 1. create a raw (ie without constitutive relationship) dae (rdae)
## 2. add the raw dae to the crs to get the dae.
## reduce has less work to do with this approach
##
## Revision 1.136  1998/03/04 16:34:19  peterg
## New local (_cr.r) and generic (.cr) CR structure.
## CR and lbl now have view mode.
## CRS in abg_tex.
##
## Revision 1.135  1998/02/25 22:09:48  peterg
## Added simpar representation.
##
## Revision 1.134  1998/02/25 15:28:34  peterg
## Added state.m rep.
##
## Revision 1.133  1998/02/24 22:35:33  peterg
## Added -p (preserve) switch to cp in tidy mode.
##
## Revision 1.132  1998/02/24 22:33:23  peterg
## new state reresentation included
##
## Revision 1.131  1998/02/23 16:21:21  peterg
## Just do model name in summary line of lbl file
##
## Revision 1.130  1998/02/19 13:40:24  peterg
## Removed prerequisit from sspar.r target.
##
## Revision 1.129  1998/02/12 08:18:42  peterg
## VERSION 2.8 (St. Annes)
##
## Revision 1.128  1998/02/12 07:48:04  peterg
## Tidy mode copies all files (containing .) to work dir -- this makes
## sure that files such a .c .constitutive relationship go across.
##
## Revision 1.127  1998/02/11 19:36:29  peterg
## Only displays one level of cbg file now.
##
## Revision 1.126  1998/02/11 19:26:03  peterg
## Added verbose (-v) mode.
##
## Revision 1.125  1998/02/11 11:36:28  peterg
## Updated version control mode - make it untidy.
## cp --> cp -u after tidy-mode .
##
## Revision 1.124  1998/02/10 13:03:36  peterg
## Now includes controller transfer function (ctf).
##
## Revision 1.123  1998/02/09 13:51:04  peterg
## Fixed directory string bug.
##
## Revision 1.122  1998/02/06 15:02:26  peterg
## New default sspar -- sets all states to zero.
##
## Revision 1.121  1998/02/06 14:36:51  peterg
## Report on copying back from MTT_work
##
## Revision 1.120  1998/02/05 16:06:53  peterg
## Removed debugging lines.
## Auto parts in books.
##
## Revision 1.119  1998/02/05 15:04:25  peterg
## Fixed problem with book in tidy mode.
##
## Revision 1.118  1998/02/05 12:00:11  peterg
## Tidy mode now default.
## It seems to work ok but not for book type documents.
##
## Revision 1.117  1998/02/04 16:50:50  peterg
## Introduced the tidy (-t and -T) options
##
## Revision 1.116  1998/02/04 11:00:04  peterg
## Added view of subsystems.
##
## Revision 1.115  1998/01/29 19:37:31  peterg
## Fixed spurious call to X server bug
##
## Revision 1.114  1998/01/23 13:38:07  peterg
## VERSION 2.7
##
## Revision 1.113  1998/01/23 13:27:13  peterg
## Added state-feedback control representations:
## smc,smo,ssk,ssl
##
## Revision 1.112  1998/01/21 09:24:46  peterg
## Removed 'touch $1_rep.txt' -- perhaps best to do this by hand if
## necessary. As it is, it cuased probs wene reediting the _rep.txt file.
##
## Revision 1.111  1998/01/16 14:56:59  peterg
## Argument now correctely recognised as a string beginning with -
## (rather than containing -)
##
# Revision 1.110  1998/01/06  13:59:30  peterg
# Added rename function.
#
# Revision 1.109  1998/01/06  09:20:02  peterg
# Made LATEX2HTML an environment variable.
#
# Revision 1.108  1997/12/19  08:48:55  peterg
# Lille modifications - bicausal algebraic loops supported
#
## Revision 1.107  1997/12/11 10:59:50  peterg
## This is version 2.6
##
# Revision 1.106  1997/12/11  10:59:07  peterg
# Added debug -D switch + echos directory when -d switch used.
#
# Revision 1.105  1997/12/11  09:04:47  peterg
# Reduced default rep.txt file to just abg.txt -- this is to document
# components which may not be causally complete
#
# Revision 1.104  1997/12/07  21:05:10  peterg
# Removed a debbugging echo
#
## Revision 1.103  1997/12/07 20:10:36  peterg
## Fixed bugs with reprots and distinguish between book, article and
## section reports.
##
## Revision 1.102  1997/12/07 12:14:43  peterg
## Hnadles book, article and section reports seperately
##
## Revision 1.101  1997/12/06 18:54:53  peterg
## Now tidies up after itself.
## Major modifications to do a rep on a directory -- creates a book with
## each example as a chapter.
##
## Revision 1.100  1997/12/06 12:14:39  peterg
## Put a conditional around the PS data rep to check for set arguments.
##
## Revision 1.99  1997/12/04 22:06:53  peterg
## Added view arguments for graph plotting
##
## Revision 1.98  1997/12/04 10:58:15  peterg
## Tidied up switches
##
## Revision 1.97  1997/12/04 10:44:33  peterg
## Changed $cc to $CC
##
## Revision 1.96  1997/12/04 10:40:26  peterg
## Added -p switch - print enviromment variables
##
## Revision 1.95  1997/12/04 10:05:02  peterg
## Compiler now symbolocic $cc
##
# Revision 1.94  1997/11/20  11:23:16  peterg
# Changed gcc to cc
#
## Revision 1.93  1997/09/18 16:57:28  peterg
## _sympar.txt now has a second column - the system type from whence the
## parameter (in the first column) came.
## Done on the train Glasgow-Warrington !
##
## Revision 1.92  1997/09/11 17:08:46  peterg
## Added spreadsheet version of odeso
##
## Revision 1.91  1997/09/11 08:21:08  peterg
## copy utility split into two:
## copy: copies examples (copies the entire directory)
## compcopy: (just used internally) copies components.
##
## Revision 1.90  1997/08/30 19:35:39  peterg
## Added date to mtt line
##
## Revision 1.89  1997/08/26 15:20:25  peterg
## Added explicit evaluation of report representations
## Version now 2.5++
##
## Revision 1.88  1997/08/25 07:51:47  peterg
## Version 2.5.
##
## Revision 1.87  1997/07/27 13:11:11  peterg
## Added path checking code -- mtt_check_vars
##
# Revision 1.86  1997/06/29  19:05:51  peterg
# Seascale changes -- mainly to new rep format.
#
## Revision 1.85  1997/06/27 12:14:49  peterg
## Upped version to 2.4++
##
# Revision 1.84  1997/06/13  14:08:23  peterg
# Changed default rep.txt
#
# Revision 1.83  1997/06/13  09:18:28  peterg
# Removed all params.m
#
# Revision 1.82  1997/06/13  08:59:03  peterg
# Set to version 2.4
#
## Revision 1.81  1997/05/22 10:11:04  peterg
## Fixed dat2gdat bug (with parameters)
##
## Revision 1.80  1997/05/22 07:38:27  peterg
## Added command line info to .doc files (makedoc)
##
## Revision 1.79  1997/05/19 16:44:12  peterg
## Many changes to get rep.html mode working properly.
##
# Revision 1.78  1997/05/19  13:17:50  peterg
# Explicit inclusion of mtt.sty in .doc files -- latex2html prefers this
#
# Revision 1.77  1997/05/19  11:29:37  peterg
# Added desc.tex and abg.tex descriptions.
#
# Revision 1.76  1997/05/15  09:43:46  peterg
# New version of _input.txt for -s option
#
# Revision 1.75  1997/05/15  09:15:54  peterg
# Included switch.c in dependancy list for _input.c (when -s switch set)
#
# Revision 1.74  1997/05/13  16:58:02  peterg
# Added -s switch to get mtt to search for (Bond Graph) switches
#
## Revision 1.73  1997/05/09 09:18:45  peterg
## Put ./ in front of a.out (again)
##
# Revision 1.72  1997/05/06  13:54:21  peterg
# Changed gcc arguments for the ode simulation -- all files now included
# in the _odes.c file
#
# Revision 1.71  1997/05/03  15:50:18  peterg
# c functions not included in gcc arg list -- they are now included in
# the main prog.
#
# Revision 1.70  1997/05/03  14:17:13  peterg
# Now copies c utilities (eg dsvdcmp.c) from $MTTPATH/trans/c.
#
# Revision 1.69  1997/05/03  13:58:35  peterg
# Implicit integration for sm representation added.
#
# Revision 1.68  1997/05/01  08:39:20  peterg
# params.c and params.m not used any more.
# _numpar.txt is the common base from which _numpar.c and numpar.m is
# generated.
#
# Revision 1.67  1997/04/23  07:26:49  peterg
# Added -o switch -- ode and dae are the same
# Added switches to default menu
#
# Revision 1.66  1997/04/16  09:46:01  peterg
# More informative copy message
#
# Revision 1.65  1997/04/15  15:16:12  peterg
# Added structure (_struc) files.
# Fixed prob with dvi2ps conversion -- removed .doc extension.
#
# Revision 1.64  1997/04/09  09:26:44  peterg
# Added crcopy feature to pull crs from library -- similar to copy
# feature.
#
# Revision 1.63  1997/03/22  17:09:11  peterg
# Fixed bug in recursive cr.txt generation.
# Fixed bug in recursive sympar.txt generation.
#
# Revision 1.62  1997/03/20  17:48:50  peterg
# Better _input.c file default.
#
# Revision 1.61  1997/03/20  16:53:01  peterg
# Generates c files using include statements.
#
# Revision 1.60  1997/03/20  10:25:41  peterg
# Generates a compehensive default params file.
#
# Revision 1.59  1997/03/19  10:14:04  peterg
# Now produces a stripped acausal bond graph.
#
# Revision 1.58  1997/03/18  17:58:12  peterg
# Generates label files containing all variables in fig file.
# Generates sympar file for all levels in system.
# Generates txt version of sympar file.
#
# Revision 1.57  1997/03/10  09:24:58  peterg
# a.out now deleted in the clean operation
#
# Revision 1.56  1997/03/05  08:24:09  peterg
# Delete a.out after it has run.
#
# Revision 1.55  1997/02/24  19:31:10  peterg
# Removed numpar.m requirement from .m files
#
## Revision 1.54  1997/02/09 20:33:13  peterg
## Replaced a.out with ./a.out
##
## Revision 1.53  1997/02/09 20:30:04  peterg
## Copied from tweedledum.
##
# Revision 1.54  1997/02/07  13:33:03  peterg
# Added ; to _input.c file - bug fix.
#
# Revision 1.53  1997/02/07  13:25:04  peterg
# Version 2.3
#
# Revision 1.52  1997/01/21  22:55:59  peterg
# Minor bug fixes
#
## Revision 1.51  1997/01/21 13:16:40  peterg
## Included transformations to language c for:
## ode
## params
## numpar
##
## Revision 1.50  1996/12/21 19:46:52  peterg
## Set to 2.2++
## Changed \* --> \\* in rbg_fig2m.awk
##
## Revision 1.49  1996/12/19 19:55:22  peterg
## Version 2.2 -- Linux.
##
## Revision 1.48  1996/12/07 21:33:52  peterg
## Changed _input file to give unit step on ALL inputs
##
## Revision 1.47  1996/12/07 20:50:16  peterg
## *** empty log message ***
##
## Revision 1.46  1996/12/05 10:48:51  peterg
## Put sympar in clean list.
## sympar now sucks in params.r file
##
## Revision 1.45  1996/12/05 10:41:39  peterg
## Saved many changes over past 2 weeks.
##
# Revision 1.44  1996/11/12  16:04:25  peterg
# Really VERSION 2.1
#
# Revision 1.43  1996/11/12  08:52:57  peterg
# Fixed bug in test arg to if - missing "".
#
# Revision 1.42  1996/11/11  17:23:03  peterg
# Added numpar.m requirement to all .m targets
#
## Revision 1.41  1996/11/11 17:18:32  peterg
## VERSION 2.1
##
## Revision 1.40  1996/11/09 21:17:38  peterg
## Fixed bug with copying at level 0.
##
## Revision 1.39  1996/11/09 20:22:54  peterg
## VERSION 2.0
##
## Revision 1.38  1996/11/09 20:17:34  peterg
## Fixed bug with null ARGS argument
## Put in new lib paths.
##
## Revision 1.37  1996/11/09 18:47:46  peterg
## Added new copy command (using find).
## More documaentation stuff.
##
# Revision 1.36  1996/11/03  21:19:02  peterg
# Recursice generation of Constitutive Relationship files.
#
## Revision 1.35  1996/11/02 10:19:19  peterg
## Constitutive Relationship generation from lbl file
##
## Revision 1.34  1996/11/01 13:34:35  peterg
## -q (quiet) switch added
##
## Revision 1.33  1996/11/01 12:34:45  peterg
## Added browser - mtt_help
##
## Revision 1.32  1996/10/31 20:48:41  peterg
## Revised html generation.
## Stopped deletion of rep.txt file.
##
# Revision 1.31  1996/10/20  19:23:54  peterg
# Automatic generation of sub-system abg.m files.
#
## Revision 1.30  1996/10/01 14:08:05  peterg
## Replaced $() by ``
## Replaced make with gmake
##
# Revision 1.29  1996/10/01  11:04:05  peter
# Changed name of html document.
#
## Revision 1.28  1996/09/13 18:44:11  peter
## Added params dependencies.
##
## Revision 1.27  1996/09/12 19:24:56  peter
## New numpar/params setup.
##
## Revision 1.26  1996/09/10 17:04:47  peter
## Added impulse response (ir) representation.
##
## Revision 1.25  1996/08/30 20:03:45  peter
## Removed dependencies from vc
##
## Revision 1.24  1996/08/30 18:37:17  peter
## inor changes.
##
## Revision 1.23  1996/08/30 11:10:37  peter
## More files in clean up.
##
## Revision 1.22  1996/08/30 10:07:51  peter
## Removed impicit creation of abg.fig file.
##
## Revision 1.21  1996/08/22 12:19:51  peter
## Added various document viewers.
##
## Revision 1.20  1996/08/20 08:24:53  peter
## Now with version control.
##
## Revision 1.19  1996/08/19 15:33:22  peter
## Included new state matric (sm) rep.
## Generate step response (sr) from sm.
##
## Revision 1.18  1996/08/19 13:30:54  peter
## New CLEAN target.
##
## Revision 1.17  1996/08/19 06:48:14  peter
## Explicit figure editing.
##
## Revision 1.16  1996/08/18 19:58:36  peter
## Report generation included.
##
## Revision 1.15  1996/08/18 12:01:01  peter
## Unified format of time responses.
##
## Revision 1.14  1996/08/16 14:52:24  peter
## Added two alternative view options - dview and pview.
##
## Revision 1.13  1996/08/16 08:24:31  peter
## Correctly chooses how to make a ps file using $REPTYPE.
##
## Revision 1.12  1996/08/15 16:47:47  peter
## DAE solution (experimental) included.
##
## Revision 1.11  1996/08/15 11:55:30  peter
## Checks for changed argument.
## Handles frequency response.
##
## Revision 1.10  1996/08/15 07:44:24  peter
## Now handles generic transformations using %.
##
## Revision 1.9  1996/08/14 09:16:08  peter
## Step response now goes through  m, dat and gdat conversions
##
## Revision 1.8  1996/08/12 20:19:52  peter
## Arguments now passed via $1_args.m file
##
## Revision 1.7  1996/08/11 19:49:27  peter
## Parameter passing (via $4) added.
##
## Revision 1.6  1996/08/11 10:40:56  peter
## Added new numpar stuff.
## Added step response.
##
## Revision 1.5  1996/08/10 14:13:47  peter
## Added impulse and frequency response stuff.
##
## Revision 1.4  1996/08/10 09:19:48  peter
## Put in help, info and warranty stuff.
##
## Revision 1.3  1996/08/09 15:13:13  peter
## Generic viewing of any representation via ps files implemented.
##
## Revision 1.2  1996/08/05 19:50:55  peter
## Put in fig.fig target.
##
## Revision 1.1  1996/08/04 17:29:42  peter
## Initial revision
##
###############################################################

set_oct() {
## Sets ${m} to oct if such a rep is supported
    m=m
    supported_reps="ae input logic numpar simpar state"
    for supported_rep in ${supported_reps}; do
	if [ "${rep}" = "${supported_rep}" ]; then
          m=oct	    
	fi
    done
}

#Check $MTTPATH has been set
mtt_check_var "$MTTPATH" "MTTPATH"

#Version
version='5.0'

# MTT recursion level is zero unless explicitly set
level=0

#Computation mode is octave by default
computation=octave

#By default, Reduce is used if available
if [ -n "$SYMBOLIC" ]; then
    use_reduce='yes'
else
    use_reduce='no'
fi

#By default, the dae and ode representations are different
dae_is_ode=0

#By default, the ode and cse reps are different
ode_is_cse=0

# By default, don't look for BG switches
switches=0

#By default, don't print the environment variables
print='';

# By default, make it tidy
tidy=tidy;

# Default not verbose
verbose=' -s'
verbosity=0

# Default integration method
integration_method=implicit;

# Default algebraic equation solver
algebraic_solver=noAlgebraicSolver;

# Default no info
info_switch=''

# Default use m, not oct files
m='m';

# Default use ps files
ps=ps
eps=eps
psview=$PSVIEW

# Default declare 500 temporary variables
num_tmp_var=500

# Default no equation sorting
do_sort=''
sort_method=''

#Initialise list of switches
mtt_switches='';

#Initialise read dirs
read_dirs=''

#Initialise view_level
viewlevel=0

#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-q )
                mtt_switches="$mtt_switches $1";
		quiet=quiet;;  
	-r )
                mtt_switches="$mtt_switches $1";
		reset=reset;;  

	-p )
                mtt_switches="$mtt_switches $1";
		print='-p';;
	-c )
	        echo "-c is obsolete. Please use -cc instead"
                fixcc='-fixcc'
                mtt_switches="$mtt_switches $1";
                matrix_smxa="-matrix";
		computation=c ;;
	-cc )
                fixcc='-fixcc'
                mtt_switches="$mtt_switches $1";
                matrix_smxa="-matrix";
		computation=cc ;;
	-cr )
                mtt_switches="$mtt_switches $1";
		rdae_is_dae=1 ;
                cr_first='-cr';;
	-o )
                mtt_switches="$mtt_switches $1";
		dae_is_ode=1 ;;
	-nocr )
                mtt_switches="$mtt_switches $1";
		rdae_is_dae=1 ;;
	-no-reduce )
                mtt_switches="$mtt_switches $1";
                use_reduce='no';
                do_sort='-sort';
                sort_method='make';
                rdae_is_dae=1 ;
                cr_first='-cr';
                Solve='';
                num_tmp_var=0 ;
                integration_method="euler" ;;
	-i )
                mtt_switches="$mtt_switches $1";
                shift;
                case $1 in
		    dassl)
			integration_method=dassl;
			mtt_switches="$mtt_switches dassl";
			;;
		    euler)
			integration_method=euler;
                        mtt_switches="$mtt_switches euler";
			;;
		    implicit)
			integration_method=implicit;
                        mtt_switches="$mtt_switches implicit";
			;;
		    rk4)
			integration_method=rk4;
			mtt_switches="$mtt_switches rk4";
			;;
		    *)
			echo $1 is an unknown integration method - use dassl, euler, rk4 or implicit;
                        exit;;
		esac;;
	-ae )
                mtt_switches="$mtt_switches $1";
		case $2 in
		    dassl)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=Dassl_Solver;
			shift;
			;;
		    fsolve | hybrd)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=Hybrd_Solver;
			shift;
			;;
		    hooke)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=HJ_Solver;
			shift;
			;;
		    reduce)
			mtt_switches="$mtt_switches $2";
			algebraic_solver=Reduce_Solver;			
			Solve='-A';
			shift;
			;;
		    *)
			echo $1 is an unknown solver - use hybrd, hooke or reduce;
			exit;;
	        esac;;
	-s )
                sensitivity_switch='-s';
                mtt_switches="$mtt_switches $1";
		sensitivity=sensitivity ;;
	-make-sort )
		mtt_switches="$mtt_switches $1";
		do_sort='-sort';
		sort_method="make";
		num_tmp_var=0 ;;
	-sort )
                mtt_switches="$mtt_switches $1";
		do_sort='-sort';
		sort_method="seqn";
		integration_method="sorted_euler";;
	-ss )
                mtt_switches="$mtt_switches $1";
		steadystate_computation=yes ;;
	-d )
		directory=$2; cd $directory; shift ;;
	-dc )
		mtt_switches="$mtt_switches $1";
		causality_switch='-derivative' ;;
	-S )
		directory=$2;  shift;;
	-D )
                mtt_switches="$mtt_switches $1";
		debug=debug ;;
	-v )
                mtt_switches="$mtt_switches $1";
		info_switch='-I';
                Verbose='verbose';
		verbosity=`expr $verbosity + 1`;
		if [ $verbosity -ge 1 ]; then verbose=' -w '; fi;
		if [ $verbosity -ge 2 ]; then set -x; fi;
		if [ $verbosity -ge 3 ]; then verbose_make=' -d '; fi;
		;;
	-I )
                mtt_switches="$mtt_switches $1";
		info_switch='-I' ;;
	-t )
		tidy=tidy ;;
	-trace )
                mtt_switches="$mtt_switches $1";
		trace='-n' ;;
	-T )
		tidy=tidy;
                verytidy=verytidy ;;
	-u )
		tidy=untidy ;
                mtt_switches="$mtt_switches $1";
                ;;
	-l )
                mtt_switches="$mtt_switches $1 $2";
		level=$2; shift ;;
	-A )
                mtt_switches="$mtt_switches $1";
                Solve='-A';;
	-abg )
                mtt_switches="$mtt_switches $1";
                start_at_abg='yes';;
	-stdin )
                mtt_switches="$mtt_switches $1";
                stdin=stdin;;
	-sub )  mtt_switches="$mtt_switches $1 $2";
                sub='-sub'; 
                subsystem="_"$2;
                shift;;
	-oct )
                fixcc='-fixcc'
                mtt_switches="$mtt_switches $1";
                using_oct=yes;
                ;;
	-opt | -optl )
		mtt_switches="$mtt_switches $1";
                optimise='-optimise_local';;
	-optg )
		mtt_switches="$mtt_switches $1";
                optimise='-optimise_global';;
        -ntmpvar )
		num_tmp_var=$2;
		mtt_switches="$mtt_switches $1 $2";
		shift;;
	-partition ) mtt_switches="$mtt_switches $1";
                     partition='-partition';
                ;;
	-pdf )   mtt_switches="$mtt_switches $1";
                 ## ps=pdf; 
                 ## eps=pdf;
                 ## pdf='-pdf';
                 psview=$PDFVIEW;
                ;;
	-dr )   mtt_switches="$mtt_switches $1"; shift
                mtt_switches="$mtt_switches $1"; read_dir=$1
	        if [ -d "${read_dir}" ]; then
		    read_dirs="${read_dirs} ${read_dir}"
		else
		    echo "${read_dir} does not exist - ignoring"
		fi
                ;;
	-nas )  no_alpha_sort="no_alpha_sort";
                mtt_switches="$mtt_switches $1";
                ;;
	-viewlevel )  mtt_switches="$mtt_switches $1 $2";
                      viewlevel=$2;
                      shift;;
        --version)                
                  echo 'MTT version' $version; exit;;
        --versions)                
                mtt_versions; exit;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

## Create switches string for adding to file names.
  MTT_SWITCHES=`echo ${mtt_switches} | sed 's/ //g' | sed 's/^-u-q//'`

#Print header if not in quiet (-q) mode.
if [ "$quiet" != "quiet" ]; then
  echo
  echo 'MTT (Model Transformation Tools) version' $version
  echo '($Date$)'
  echo 'This is free software with ABSOLUTELY NO WARRANTY.'
  echo 'Type `mtt warranty'\' 'for details.'
  echo
  # Print current directory if in -d mode
  if [ -n "$directory" ]; then
    echo Using directory $directory
    echo
  fi
fi

#Print what's going on if in verbose mode
if [ -n "$Verbose" ]; then
    echo  Starting  mtt  $mtt_switches  $1 $2 $3 $4 at level $level 
    echo  "        " current wd `pwd`
fi

#Check the principle paths
mtt_check_vars $print

# Exit if just printing paths
if [ "$print" != "" ]; then
  exit
fi

if [ -z "$1" ]; then
  if [ -z "$print" ]; then
      cat <<EOF
Usage:
	mtt help		-- mtt on-line help
	mtt find component	-- find location of a compound component
	mtt info		-- info-based manual
	mtt info topic
	mtt hinfo		-- hypertext manual
	mtt manual		-- pdf manual
	mtt warranty
	mtt clean		-- cleans up intermediate files
	mtt rclean		-- recursively cleans up intermediate files
	mtt Clean		-- cleans up all generated files
	mtt <system_name> clean
	mtt copy <system_name> <path_name>
	mtt rename <old_name> <new_name>
	mtt <system_name> <representation> vc 
	mtt <system_name> <representation> <language>
	mtt <system_name> <representation> <language> <parameters>

Options:
	-A		solve algebraic equations symbolically
	-abg		start at abg.m representation
	-ae <method>	algebraic equation solver: reduce|hybrd|dassl|hooke
	-cc		C++ code generation
	-cr		use cr before resolving equations
	-D		debug -- leave log files etc
	-d <dir>	use directory <dir>
	-dc		maximise derivative (not integral) causality
	-dr <dir>	use files contained in <dir>
	-I		prints more information
	-i <method>	integration method: implicit|euler|rk4|dassl
        -nas            no alphabetic sort (of components)
	-o		ode is same as dae
	-oct		use oct files in place of m files where appropriate
	-opt		optimise code generation (equivalent to -optl)
	-optl		locally optimise code generation (line-by-line)
	-ntmpvar <N>	declare <N> temporary variables (default=$num_tmp_var)
	-p		print environment variables
	-partition	partition hierachical system
	-pdf		generate pdf in place of ps
	-q		quiet mode -- suppress MTT banner
	-r		reset time stamp on representation
	-s		generate sensitivity BG (use mtt -s sSys rep lang)
	-ss		use steady-state info to initialise simulations
	-stdin		read input data from standard input for  simulations
	-sub <subsys>	operate on subsystem <subsys>
	-t		tidy mode (default)
	-trace		just indicate what mtt will do - but do not do it
	-u		untidy mode (leaves files in current dir)
	-v		verbose mode (multiple uses increment the verbosity)
	--version	print version and exit
	--versions	print version of mtt and components and exit
	-viewlevel <N>	view <N> levels of hierachy

Experimental options:
	-optg		globally optimise code generation (full vector)
	-make-sort	use sorted equations (sese, generated by make)
	-no-reduce	try not to use symbolic algebra
	-sort		use sorted equations (sese, generated by seqn)

Deprecated options:
	-c		c-code generation

EOF
    exit
  fi
fi


if [ "$1" = "info" ]  && [ "$3" = "" ]; then
  (cd $MTT_DOC ; make --silent mtt.info)
  echo "Invoking info in xterm"
  xterm -e info -f $MTT_DOC/mtt.info $2
  exit
fi

if [ "$1" = "help" ]; then
  mtt_help $2 $3
  exit
fi

if [ "$1" = "hinfo" ] && [$2 = ""]; then
   mtt_check_var "$HTMLVIEW" HTMLVIEW
  (cd $MTT_DOC/; make --silent mtt.html) 
   echo Invoking $HTMLVIEW
   (cd $MTT_DOC; $HTMLVIEW file://$MTT_DOC/mtt.html)&
   exit
fi

if [ "$1" = "manual" ] && [$2 = ""]; then
  mtt_check_var "$PDFVIEW" PDFVIEW
  (cd $MTT_DOC/; make --silent mtt.pdf) 
  echo Invoking $PDFVIEW 
  $PDFVIEW  $MTT_DOC/mtt.pdf &
  exit
fi

if [ $1 = "find" ]&& [$3 = ""]; then
    mtt_find $MTT_COMPONENTS $2
    find_status=$?
  if [ $find_status = "1" ]; then
    echo Component $2 not found - is MTT_COMPONENTS set correctly?
  fi
    exit $find_status
fi

if [ "$1" = "warranty" ] && [$2 = ""]; then
  cat << EOF
Copyright (C) 1989, 1990, 1991, 1992, 1993, 
              1994, 1995, 1996, 1997, 1998, 1999 Peter J. Gawthrop
This is free software with ABSOLUTELY NO WARRANTY.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

EOF
  exit
fi

# Start at abg representation
if [ -n "$start_at_abg" ]; then
  if [ -f "$1_abg.m" ]; then
    if [ "$quiet" != "quiet" ]; then
        echo Starting from $1_abg.m
    fi
  else
    echo $1_abg.m does not exist
    exit
  fi
fi

# Clean up 
if [ "$1" = "clean" ]; then
  echo Removing intermediate files in `pwd`
  rm -fr MTT_work
  exit
fi

# Recursively clean up
if [ "$1" = "rclean" ]; then
  echo 'Removing intermediate files recursively'
  dir2paths '.' | gawk '{print "mtt -q -d " $1 " clean " $2}' | sh
  exit
fi

# The big clean up
if [ "$1" = "Clean" ] && [ "$2" = "" ]; then
  echo 'Removing all generated files for all systems'
  rm -f *.log  mtt_info.txt warning.txt
  rm -f *_abg.ps *_args.*  *_cr.txt *_abg.tex
  rm -f *_sabg.fig *_sabg.ps *_head.fig *_bnd.fig 
  rm -f *_labg.fig *_lcbg.fig
  rm -f *_sympar.r *_sympar.c *_sympar.h *_sympar.txt? *_sympar.tex
  rm -f *_rbg.* *_cmp.* *_fig.fig *_*cbg.* *_ese.* *_def.* *_alias.*
  rm -f *_sub.* *_type.sh
  rm -f *_dae*.* *_cse.* *_ode.*
  rm -f *_obs.* *_rfe.* *_ss.*
  rm -f *_dm.* *_csm.*  *_tf.* *_sr*.* *_ir*.* *_*fr.*
  rm -f *_numpar.c *_input.m *_input.c *_switch.c *_switch.txt
  rm -f *_sm.* *_can.*
  rm -f *_struc.* *_sympar.txt *_sympar.c *_sympar.h *_sympar.m
  rm -f *_odes.c *_odes.dat *_odes.gdat *_odes.m *_odes.ps *_odes.sg
  rm -f *_odeso.dat *_odeso.gdat *_odeso.sdat *_odeso.m *_odeso.ps
  rm -f *_*.doc *_*.idx *_*.ind *_*.ilg *_*.dvi *_*.aux *_*.lof *_*.toc
  rm -f *_rep.tex
  rm -f  *_unique_raw_list *_raw_list
  rm -f mtt_error.txt mtt_info.txt *_ode2odes.out 
  rm -f *_*_write.r *_simpar.m *_simpar.p
  rm -f *_cseo.oct *_input.oct *_simpar.oct *_smxax.oct
  rm -f *_csex.oct *_numpar.oct *_smxa.oct *_state.oct 
  rm -f *_ode.oct *_odeo.oct
  rm -f *_cseo.mexglx *_input.mexglx *_simpar.mexglx *_smxax.mexglx
  rm -f *_csex.mexglx *_numpar.mexglx *_smxa.mexglx *_state.mexglx 
  rm -f *_ode.mexglx *_odeo.mexglx
  rm -f *_sfun.mexglx *_sfun_*.mexglx
  rm -f *_cseo.cc *_input.cc *_simpar.cc *_smxax.cc
  rm -f *_csex.cc *_numpar.cc *_smxa.cc *_state.cc 
  rm -f *_ode.cc *_odeo.cc
  rm -f *_logic.m *_logic.cc *_logic.oct
  rm -f *_state.m *_state.cc *_state.oct
  rm -f *_ode2odes.* *.dat2 MTT.core
  rm -f *_modpar.txt *_modpar.r
  rm -f *_ICD.txt *_ICD.c *_ICD.cc *_ICD.m
  rm -f *_ae.r *_ae.m *_ae.cc *_ae.oct
  rm -f *_sese.r *_sese.m
  rm -f *_sese.make *_sesx.* *_sesy.* _sae.*
  rm -fR *_rep MTT_work
  exit
fi

# Clean up named system
if [ "$2" = "Clean" ] && [ "$3" = "" ]; then
  echo 'Removing all generated files for system ' $1
  rm -f *.log  mtt_info.txt warning.txt
  rm -f $1_abg.ps $1_args.*  $1_cr.txt $1_abg.tex
  rm -f $1_sabg.fig $1_sabg.ps $1_head.fig $1_bnd.fig 
  rm -f $1_labg.fig $1_lcbg.fig
  rm -f $1_sympar.r $1_sympar.c $1_sympar.h $1_sympar.txt? $1_sympar.tex
  rm -f $1_rbg.* $1_cmp.* $1_fig.fig $1*_*cbg.* $1*_ese.* $1_def.* $1_alias.*
  rm -f $1_sub.* $1_type.sh
  rm -f $1_dae*.* $1_cse.* $1_ode.*  $1_obs.* $1_rfe.* $1_ss.*
  rm -f $1_dm.* $1_csm.* $1_tf.* $1_sr*.* $1_ir*.* $1_*fr.*
  rm -f  $1_numpar.m $1_numpar.c $1_input.m $1_input.c $1_switch.c $1_switch.txt
  rm -f $1_sm*.* $1_can.*
  rm -f $1_struc.* $1_sympar.txt $1_sympar.c $1_sympar.h $1_sympar.m
  rm -f $1_odes.c $1_odes.dat $1_odes.gdat $1_odes.sdat $1_odes.m $1_odes.ps $1_odes.sg
  rm -f $1_odeso.dat $1_odeso.gdat $1_odeso.m $1_odeso.ps
  rm -f $1_*.doc $1_*.idx $1_*.ind $1_*.ilg $1_*.dvi $1_*.aux $1_*.lof $1_*.toc
  rm -f $1_rep.tex
  rm -f $1_unique_raw_list $1_raw_list
  rm -f mtt_error.txt mtt_info.txt $1_ode2odes.out 
  rm -f $1_*_write.r $1_simpar.m $1_simpar.p
  rm -f $1_cseo.oct $1_input.oct $1_simpar.oct $1_smxax.oct
  rm -f $1_csex.oct $1_numpar.oct $1_smxa.oct $1_state.oct 
  rm -f $1_ode.oct $1_odeo.oct
  rm -f $1_cseo.mexglx $1_input.mexglx $1_simpar.mexglx $1_smxax.mexglx
  rm -f $1_csex.mexglx $1_numpar.mexglx $1_smxa.mexglx $1_state.mexglx 
  rm -f $1_ode.mexglx $1_odeo.mexglx
  rm -f $1_sfun.mexglx $1_sfun_*.mexglx
  rm -f $1_cseo.cc $1_input.cc $1_simpar.cc $1_smxax.cc
  rm -f $1_csex.cc $1_numpar.cc $1_smxa.cc $1_state.cc 
  rm -f $1_ode.cc $1_odeo.cc
  rm -f $1_logic.m $1_logic.cc $1_logic.oct 
  rm -f $1_state.m $1_state.cc $1_state.oct
  rm -f $1_ode2odes.* $1.dat2
  rm -f $1_modpar.txt $1_modpar.r
  rm -f $1_ICD.txt $1_ICD.c $1_ICD.cc $1_ICD.m
  rm -f $1_ae.r $1_ae.m $1_ae.cc $1_ae.oct
  rm -f $1_sese.r $1_sese.m
  rm -f $1_sese.make $1_sesx.* $1_sesy.* $1_sae.*
  rm -fR $1_rep MTT_work
  exit
fi

if [ "$2" = "rep" ]; then
     documenttype=article
      # See if we are making a book -- ie representation rep on a directory
     isMTT_work=`pwd | grep 'MTT_work'`
      if [ -n "$isMTT_work" ]; then
	dotdot='../'
      fi  

     #isdirectory=`file $dotdot$1 | gawk '{print $2}' | grep directory`
     if [ -d "$dotdot$1" ]; then
	documenttype=book
     fi
else
     documenttype=section
fi

case $2 in
    nyfr)
	NyquistStyle='True'
	;;
    nifr)
	NyquistStyle='True'
	;;
    *)
esac

#SUMMARY abg*	acausal bond graph (fig)
#SUMMARY abg*	acausal bond graph (dia)
#SUMMARY abg*	acausal bond graph (ps)
#SUMMARY abg*	acausal bond graph (view)
# Invoke explicit requests for modification
if [ "$2" = "abg" ] && [ "$3" = "fig" ]; then
  mtt_check_var "$FIG" FIG
  echo Editing $1_$2.$3
  ($FIG $1_$2.$3; cp $1_abg.fig $1_$1_abg.fig) &
  exit
fi

# Rename a system
if [ "$1" = "rename" ]; then
  mtt_rename_all $2 $3
  exit
fi

# Copy systems from the example library
if [ "$1" = "copy" ]; then
   #set up source and destination dirs
    source=$3
    if [ -z "$source" ]; then
      source=$MTT_EXAMPLES
    fi
    destination=$4
    if [ -z "${destination}" ]; then
      destination=$2
    fi      
# check that its not here already
  file_exists=`ls ${destination}/$2_abg.fig 2> /dev/null`
  if [ -n "$file_exists" ]; then
    if [ "$quiet" != "quiet" ]; then    
      echo System $2 exists already - no action taken
    fi
  else
    source=$3
    if [ -z "$source" ]; then
      source=$MTT_EXAMPLES
    fi
    destination=$4
    if [ -z "${destination}" ]; then
      destination=$2
    fi    
echo Copying system $2 from $source into directory ${destination}
    find $source -name "$2" -exec cp -fr {} . \;
    rm -rf ${destination}/CVS
  fi
  exit
fi

# Copy components from the library
if [ "$1" = "compcopy" ]; then

   #Pull out the base name (we may have a library as well)
   name=`basename $2`

   #set up source and destination dirs
    source=$3
    if [ -z "$source" ]; then
      source=$MTT_COMPONENTS
    fi
    destination=$4
    if [ -z "${destination}" ]; then
      destination='.'
    fi   

  # check that its not here already
  file_exists=`ls ${destination}/"$name"_abg.fig 2> /dev/null`
  if [ -n "$file_exists" ]; then
    if [ "$quiet" != "quiet" ]; then    
      echo Component $name exists already - no action taken
    fi
  else
    if [ $source = "." ]; then
      cp -u *_*.* ${destination}
    else
      comp_path=`mtt_find $source $2 path_only`
      n_found=`echo $comp_path | wc | gawk '{print $2}'`

      if [ "$n_found" = "1" ]; then
         echo Copying $2 from $comp_path to ${destination}
         cp $comp_path/*_*.* ${destination}
         exit 0
      elif [ "$n_found" = "0" ]; then
	if [ "$quiet" != "quiet" ]; then    
           echo Component $2 not found - is MTT_COMPONENTS set correctly?
        fi
         exit 1
      elif [ "$n_found" > "1" ]; then
         echo "Multiple versions of $2 found (see below) - use a more explicit alias"
         mtt -q find $2
         exit 2
      fi
    fi
  fi
  exit
fi

# Copy CRs from the library
if [ "$1" = "crcopy" ]; then
  # check that its not here already (or a _cr.r version)
  file_exists=`ls $2.cr $2_cr.r 2> /dev/null`
  if [ -n "$file_exists" ]; then
    if [ "$quiet" != "quiet" ]; then    
      echo $2.cr or $2_cr.r exists already - no action taken
    fi
  else
    path_name=$3
    if [ -z "$path_name" ]; then
	path_name=""
	for path in `echo $MTT_CRS | sed 's/:/ /g'`; do
	    path_name="$path_name $path/r"
	done
    fi
    echo Copying CR $2 to here from $3
    find $path_name -name "$2.cr" -exec cp {} . \;
  fi
  exit
fi


# Version control
VC=''

if [ "$3" = "vc" ]; then
  tidy=untidy;
  if [ -n "$4" ]; then
    log_message=$4
  else
    log_message="No Message"
  fi
  case $2 in
	abg )
		VC='ok'
		VCext='fig' ;;
	lbl )
		VC='ok'
		VCext='txt' ;;
	desc )
		VC='ok'
		VCext='tex' ;;
	simp )
		VC='ok'
		VCext='r' ;;
	rep )
		VC='ok'
		VCext='txt' ;;
	numpar )
		VC='ok'
		VCext='txt' ;;
	input )
		VC='ok'
		VCext='txt' ;;
	state )
		VC='ok'
		VCext='txt' ;;
	odes )
		VC='ok'
		VCext='h' ;;
	sspar )
		VC='ok'
		VCext='r' ;;
	*)
		echo Version control is not appropriate for representation $2
		exit  ;;
  esac
fi

# Classify the representation - needed for conversion route to postscript
PLOTTYPE='single';
case $2 in
	abg )
		REPTYPE='bg' ;;
	labg )
		REPTYPE='lbg' ;;
	sabg )
		REPTYPE='bg' ;;
	cbg )
		REPTYPE='bg' ;;
	input )
		REPTYPE='txt' ;;
	numpar )
		REPTYPE='txt' ;;
	state )
		REPTYPE='txt' ;;
	simpar )
		REPTYPE='txt' ;;
	obspar )
		REPTYPE='txt' ;;
	odes)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	odeso)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	sms)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	smso)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	odess)
		REPTYPE='data' ;;
	odesso)
		REPTYPE='data' ;;
	daes)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	daeso)
		REPTYPE='data'; PLOTTYPE='multiple' ;;
	ir)
		REPTYPE='data' ;;
	iro)
		REPTYPE='data' ;;
	sr)
		REPTYPE='data' ;;
	sro)
		REPTYPE='data' ;;
	fr)
		REPTYPE='data' ;;
	lmfr)
		REPTYPE='data' ;;
	lpfr)
		REPTYPE='data' ;;
	nyfr)
		REPTYPE='data' ;;
	nifr)
		REPTYPE='data' ;;
	*)
		REPTYPE='tex' ;;
esac


## Set up the main arguments
sys=$1
rep=$2
lang=$3

## Make ps pdf if -pdf set
if [ "$lang" = "ps" ]; then
  lang=$ps
fi


# Create some strings
Subsystem=$1$subsystem;

Subsystem_=$Subsystem"_"
Subsystem_ese=$Subsystem"_ese"
Subsystem_def=$Subsystem"_def"
Subsystem_rdae=$Subsystem"_rdae"
Subsystem_dae=$Subsystem"_dae"
Subsystem_subs=$Subsystem"_subs"
Subsystem_cr=$Subsystem"_cr"
Subsystem_cbg=$Subsystem"_cbg"


## Create the make target name
if [ -z "${using_oct}" ]; then
  target=${sys}_${rep}.${lang}    
else
  set_oct;
  if [ "${lang}" = "m" ]; then
    target=${sys}_${rep}.${m}
  else
    target=${sys}_${rep}.${lang}
  fi
fi 

##echo $target
##target=${sys}_${rep}.${lang}

## Arguments
ARGS=$4; _ARGS=-$4; __ARGS=`echo $_ARGS | tr ',' '-'`
__ARGS="${MTT_SWITCHES}${__ARGS}"
__ARGS=`echo ${__ARGS} | sed -e 's/-q//g' -e 's/-u//g'`

# Save up the argument list in a file; but only if argument has changed
#DIFF doesn't like empty files - so put a blank if empty
#if [ -z "$ARGS" ]; then
#  ARGS=' ';
#  _ARGS='';
#fi

#cat > $1_args.new <<EOF
#$ARGS
##EOF

#DIFF=`diff -bq $1_args.m $1_args.new 2>/dev/null`

#if [ -n "$DIFF" ]; then
#  mv $1_args.new $1_args.m
#fi

## If in MTT_work, then copy from -dr read dirs
this_dir=`basename $PWD`
if [ "${this_dir}" = "MTT_work" ]; then
  # Copy from read dirs to MTT_work
  for dir in ${read_dirs}; do
     if [ -n "$Verbose" ]; then
       echo Copying ${dir}/*
       cp --force ${dir}/* .
     else
       cp --force ${dir}/* . 2> /dev/null
     fi
    read_files=`echo ${dir}/*`
    for read_file in ${read_files}; do
     read_file_name=`basename ${read_file}`
     touch ${read_file_name}
    done
   done
fi

# Tidy mode - operate in the directory MTT-work
if [ "$tidy" = "tidy" ] && [ "$level" = "0" ]; then
    # make sure that a system exists in this directory
    if [ "${sys}_${rep}.${lang}" != "${sys}_abg.dia" ] && [ "${sys}_${rep}.${lang}" != "${sys}_abg.fig" ]; then
	nabgs=`ls ${sys}_abg.* 2>/dev/null | wc -l`
	if [ $nabgs -eq 0 ]&&[ -z "$sensitivity" ]; then
	    echo "MTT Error: System $sys does not exist"
	    exit -1;
	fi
    fi
   mkdir -p MTT_work
   valid_files=`ls | grep -v '^MTT'`
   ##cp -p -u  Makefile Make *.* .* MTT_work  2>/dev/null
   cp -p -u -R --force ${valid_files} MTT_work  2>/dev/null

   # Go to MTT_work
   cd MTT_work

   if [ -f ".octaverc" ]; then
     touch .octaverc
   else
     echo Copying .octaverc 
     cp $MTT_LIB/octave/.octaverc .
   fi

   if [ -f "useful-functions.hh" ]; then
     touch useful-functions.hh
   else
     echo Copying useful-functions.hh
     cp $MTT_CC/include/useful-functions.hh .
   fi

   if [ -z "$directory" ]; then
     Directory=''
   else
     Directory=$directory/MTT_work
   fi

     mtt -u -q  $mtt_switches -S "$Directory"  $1 $2 $3 $4
     mtt_status=$?

   # Exit on failure
   if [ "$mtt_status" != "0" ]; then
     echo Exiting MTT with error $mtt_status
     exit 1
   fi

  # Copy back from working directory
   if [ "$3" != "view" ] && [ "$3" != "hview" ] && [ -z "$reset" ]; then
      if [ "$3" = "html" ]; then
	  echo Moving $1_$2
          mv $1_$2 ..
      else
        if [ "$PLOTTYPE" = "multiple" -a -f $1_$2__ARGS.$ps ]; then
          echo Copying  $1_$2$__ARGS.$ps
          cp  $1_$2$__ARGS.$ps ..
        else
	    if [ -f $1$subsystem"_"$2.$lang ]; then
		echo Copying  $1$subsystem"_"$2.$lang
		cp  -p -u $1$subsystem"_"$2.$lang ..
	    fi
        fi
      fi
    fi

   # Remove the MTT_work directory if very tidy
   if [ "$verytidy" = "verytidy" ]; then
    echo Removing all working files
    rm -rf ../MTT_work
  fi
exit
fi 

# User defined representations
## Copy from library if not already here

## .make versions
if [ -f "$MTT_REP/$2_rep.make" ]; then
  if [ -f "$2_rep.make" ]; then
    echo Using $2_rep.make
  else
    echo Copying $2_rep.make from $MTT_REP
    cp $MTT_REP/$2_rep.make .
  fi
fi

if [ -f "$2_rep.make" ]; then
   if [ -n "$4" ]; then
      filename=$1_$2-$4.$3
   else
      filename=$1_$2.$3
   fi

   #if [ -f "$filename" ]; then
   #   echo $filename exists
   #else
   if [ ! -f "$2_rep.make.ignore" ]; then
       if [ -n "$Verbose" ]; then
	   echo make -s -f $2_rep.make "MTT_SYS=$1" "MTT_LANG=$3" "MTT_ARG=$4" "MTT_OPTS=$mtt_switches" 
       fi
       make -s -f $2_rep.make "MTT_SYS=$1" "MTT_LANG=$3" "MTT_ARG=$4" "MTT_OPTS=$mtt_switches"
       if [ -n "$4" ]; then
	   echo Copying  $1_$2$__ARGS.$ps
	   cp  $1_$2$__ARGS.$ps ..
       fi
   #fi
       exit
   fi
fi

## Check for pre version 4.0 integration method specification.
if [ $level = "0" ]; then
  if [ -f "$1_simpar.txt" ]; then
    method_line=`grep -i METHOD  $1_simpar.txt`
    if [ -n "`echo $method_line | grep -i euler`" ]; then
      echo Obsolete $1_simpar.txt contains: $method_line
      echo "    please use mtt -i euler in future"
      mtt_switches="$mtt_switches -i euler";
    elif [ -n "`echo $method_line | grep -i implicit`" ]; then
      echo Obsolete $1_simpar.txt contains: $method_line
      echo "    please use mtt -i implicit in future"
      mtt_switches="$mtt_switches -i implicit";
    fi
  fi
fi

if [ -n "$reset" ]; then
  if [ -f "$1_$2.$3" ]; then
    echo Resetting time stamp on $1_$2.$3
    touch $1_$2.$3
  else
    echo $1_$2.$3 does not exist - no action taken
  fi
  exit;    
fi


if [ -n "$sensitivity" ]; then
  sys_s=`echo $1 | cut -c 2-`
  sys_abg=${sys_s}_abg
fi

## Check octave version
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) define_octave_dev="";;			# stable 
    1) define_octave_dev="-DOCTAVE_DEV";;	# development
    *) define_octave_dev="-DOCTAVE_DEV";;
esac

################################
# This is the main mtt programme
################################

#echo Target is $target, Subsystem is $Subsystem, options are $mtt_switches
##<<<<<<< mtt
##$MAKE  -S ${trace} ${verbose}  -f  -  ${target} << EOF
##=======
##$MAKE -S $verbose $verbose_make -f  -  $target << EOF
##>>>>>>> 1.316
$MAKE -S ${trace} $verbose $verbose_make -f  -  $target << EOF

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files
$1_%.oct:  $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Creating $1_\$*.oct; $MKOCTFILE ${MTT_CXXINCS} -DCODEGENTARGET=OCTAVEDLD $1_\$*.cc

## pdf files from ps (new version)
$1_%.pdf:  $1_%.ps
	echo Creating $1_\$*.pdf; ps2pdf  $1_\$*.ps $1_\$*.pdf

## eps from ps (NB ps files are actually eps anyway)
$1_%.eps:  $1_%.ps
	echo Creating $1_\$*.eps; cp  $1_\$*.ps $1_\$*.eps

.PRECIOUS: mtt_%.oct
.PRECIOUS: $1_%.oct
mtt_%.oct: mtt_%.cc
	echo Compiling \$<
	${MKOCTFILE} ${MTT_CXXINCS} -DCODEGENTARGET=OCTAVEDLD $define_octave_dev \$<

## .mex files
$1_%.mexglx: $1_%.cc $1_def.h $1_sympar.h $1_cr.h mtt_kpathsea.cc mtt_matlab_octave.cc mtt_matlab_octave.hh
	echo Creating $1_\$*.mexglx
	${MTT_CXX} -shared -o $1_\$*.mexglx $1_\$*.cc \
	${MTT_MATLAB_FLAGS} -DCODEGENTARGET=MATLABMEX \
	${MTT_CXXINCS} ${MTT_CXXLIBS} ${MTT_CXXFLAGS} mtt_kpathsea.cc mtt_matlab_octave.cc

## .cc files
.PRECIOUS: %.cc # Don't let mtt delete them
.PRECIOUS: $1_%.cc # Don't let mtt delete them
$1_%.cc:  $1_%.m
	mtt_m2cc.sh  $1 \$* cc cat 

mtt_%.cc:: ${MTT_LIB}/cc/mtt_%.cc
	cp ${MTT_LIB}/cc/mtt_\$*.cc mtt_\$*.cc

mtt_%.hh:: ${MTT_LIB}/cc/mtt_%.hh
	cp ${MTT_LIB}/cc/mtt_\$*.hh mtt_\$*.hh

## .o files
.PRECIOUS: $1_%.o
$1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Compiling $1_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE

.PRECIOUS: mtt_%.o
mtt_%.o: mtt_%.cc
	echo Compiling mtt_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE $define_octave_dev

# Copy aliased subsystems
$1_aliased_subsystems_copied: 
	lbl2component $1 | sh || exit 1 # Grab specified components now
	touch $1_aliased_subsystems_copied

# Generates code to write reduce code
$1_ode_write.r: $1_def.m
	def2write_r  $1 $2 $computation

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")
$1_abg.fig: $sys_abg.fig
	abg2sensitivity_fig $sys_s
else # Either find the sensitivity model or fetch the model and create sensitivity model
$1_abg.fig:
	mtt -q -u $mtt_switches compcopy $1 || abg2sensitivity_fig $sys_s
endif
endif

ifneq ("$sensitivity","sensitivity")
ifneq ("$level","0")
# If level>0, try and get subsystem files; creating if necessary
ifneq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_abg.fig:
	mtt -q -u $mtt_switches compcopy $1
else
$1_abg.fig:
endif
endif
endif

# Create an arg file if it doesn't exist
$1_args.m:
	touch $1_args.m

#Create list of components
ifeq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_cmp.txt: $1_abg.dia
	abg2cmp_dia2txt $1
else
$1_cmp.txt: $1_abg.fig
	abg2cmp_fig2txt $1
endif

#Create skeleton files (with titles) if not already there
#SUMMARY lbl*	label file (txt)
#SUMMARY lbl	label file (txt)
#SUMMARY lbl*	label file (view)
#SUMMARY lbl	label file (view)
#SUMMARY lbl*	label file (tex)
#SUMMARY lbl	label file (tex)
$1_lbl.txt: $1_cmp.txt
	cmp2lbl_txt $1 $sensitivity
	touch $1_lbl.txt

$1_lbl.tex: $1_lbl.txt
	lbl_txt2tex $1

#SUMMARY alias  name aliases for each subsystem (txt)
$1_alias.txt: $1_lbl.txt
	lbl2alias_txt2txt $1

#SUMMARY modpar  name modulated parameters for each subsystem (txt)
$1_modpar.txt: $1_lbl.txt
	lbl2modpar_txt $1

#SUMMARY modpar  name modulated parameters for each subsystem (r)
$1_modpar.r: $1_modpar.txt $1_struc.txt
	modpar_txt2r $1

#SUMMARY alias  name aliases for each subsystem (m)
$1_alias.m: $1_alias.txt
	alias_txt2m $1

##SUMMARY icd	interface definition for system (c)
##SUMMARY icd	interface definition for system (cc)
##SUMMARY icd	interface definition for system (m)
##SUMMARY icd	interface definition for system (txt)

$1_ICD.c: $1_ICD.txt
	ICD_txt2lang.sh $1 c

$1_ICD.cc: $1_ICD.txt
	ICD_txt2lang.sh $1 cc

$1_ICD.m: $1_ICD.txt
	ICD_txt2lang.sh $1 m

$1_ICD.txt: $1_icd.txt2
	icd2ICD_txt22txt.sh $1

$1_icd.txt2: $1_ese.r
	touch $1_icd.txt2

#SUMMARY icd	interface definitions for each subsystem (m)
$1_icd.m: $1_icd.txt
	icd_txt2m.sh $1

#SUMMARY icd	interface definitions for each subsystem (txt)
$1_icd.txt: $1_lbl.txt
	lbl2icd_txt2txt.sh $1

#SUMMARY cr	constitutive relationship for each subsystem (txt)
$1_cr.txt: $1_abg.m $1_sub.sh
	abg2cr_m2txt $1

	if [ "$level" = "0" ]; then \
	  mv $1_cr.txt MTT_cr.txt; \
	else \
	  cat $1_cr.txt >> MTT_cr.txt; \
	fi

	sh $1_sub.sh "rm -f " '_cr.txt' # Remove the txt.cr files
	sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' cr txt' #Create new ones

	if [ "$level" = "0" ]; then \
	  sort -u MTT_cr.txt> $1_cr.txt; \
	fi

#SUMMARY cr	constitutive relationship for each subsystem (r)
$1_cr.r: $1_cr.txt
	cr_txt2r $1

#SUMMARY cr	constitutive relationship header (c)
$1_cr.h: 
	echo Creating $1_cr.h
	echo "/* CR headers for system $1 */" > $1_cr.h

# Cheat a bit and use the top level cr file for the subsystem as well
ifneq ($sub,)
$Subsystem_cr.r: $1_cr.r
	echo Creating $Subsystem_cr.r "(copying $1_cr.r)"
	cp $1_cr.r $Subsystem_cr.r
endif
#SUMMARY cr	constitutive relationship for each subsystem (tex)
#SUMMARY cr	constitutive relationship for each subsystem (view)
$1_cr.tex: $1_cr.r
	txt2tex $1 cr r

#SUMMARY sympar	symbolic parameters (txt)
#SUMMARY sympar*	symbolic parameters (view)
$1_sympar.txt: $1_type.sh $1_abg.m $1_aliased.txt
	mtt_make_sympar $1 ${use_reduce}

#SUMMARY sympar	symbolic parameters (r)
$1_sympar.r: $1_sympar.txt
	sympar_txt2r $1
$1_sympar.m: $1_sympar.txt
	sympar_txt2m $1
ifneq ($sort_method,make)
$1_sympar.h: $1_sympar.txt
	sympar_txt2h.sh $1 $num_tmp_var
else
$1_sympar.h: $1_sympar.txt $1_sese.make
	sympar_txt2h.sh $1 $num_tmp_var
	declaration="static double" \
	make -f $1_sese.make declare_tmpvars |\
	tr [A-Z] [a-z] >> \$@
endif

#SUMMARY sympar	symbolic parameters (c)
# txt to c sympar conversion
$1_sympar.c: $1_sympar.txt
	sympar_txt2c $1

#SUMMARY sympar	symbolic parameters (tex)
# txt to tex (LaTeX) sympar conversion
$1_sympar.tex: $1_sympar.txt
	sympar_txt2tex $1

#SUMMARY logic	Dynamic switch logic (tex)
#SUMMARY logic	Dynamic switch logic (view)
$1_logic.tex: $1_logic.txt
	txt2tex $1 logic txt


#SUMMARY switch	Dynamic switch information (txt)
$1_switch.txt: $1_struc.txt
	struc2switch_txt $1
#$1_switchopen.m: $1_switch.txt $1_sympars.txt $1_logic.txt
#	switch_txt2m $1

#SUMMARY sympars sympar + dynamic switch information (txt)
$1_sympars.txt: $1_sympar.txt $1_switch.txt
	   echo Creating $1_sympars.txt
	   cat $1_sympar.txt $1_switch.txt > $1_sympars.txt

#SUMMARY simp	simplification information (r)
$1_simp.r:
	echo Creating $1_simp.r
	( \
	echo "%% Reduce commands to simplify output for system $1 ($1_simp.r)"; \
	cat $MTTPATH/trans/m/rcs_header.txt; \
	    echo 'ON ALLFAC; %Multiplicative factors'; \
	    echo 'OFF DIV; %Polynomial division'; \
	    echo 'OFF FACTOR; %Factorise polynomials'; \
	    echo 'OFF LIST; %Each term on a new line'; \
	    echo 'FOR ALL x,y LET pow(x,y) = x^y; %Readable pow function'; \
	echo 'END;'; \
	)> $1_simp.r

#SUMMARY subs  algebraic substitution (r)
$Subsystem_subs.r: 
	mtt $mtt_switches -q -u $1 sympar txt; 
	makesubs $Subsystem;

#SUMMARY obspar  GPC observability function parameters (r)
$1_obspar.r:
	echo Creating $1_obspar.r
	( \
	echo "%% Reduce  GPC observability function parameters for system $1 ($1_obspar.r)"; \
	cat $MTTPATH/trans/m/rcs_header.txt; \
	echo 'MTTGPCNy := 5;'; \
	echo 'MTTGPCNu := 0;'; \
	echo 'Matrix MTTdU(5,1);'; \
	echo 'MTTdU(1,1) := MTTdU1;'; \
	echo 'MTTdU(2,1) := MTTdU2;'; \
	echo 'MTTdU(3,1) := MTTdU3;'; \
	echo 'MTTdU(4,1) := MTTdU4;'; \
	echo 'MTTdU(5,1) := MTTdU5;'; \
	echo 'Matrix MTTUU(1,5);'; \
	echo 'MTTUU(1,1) := MTTu1;'; \
	echo 'MTTUU(1,2) := MTTu11;'; \
	echo 'MTTUU(1,3) := MTTu12;'; \
	echo 'MTTUU(1,4) := MTTu13;'; \
	echo 'MTTUU(1,5) := MTTu14;'; \
	echo 'END;'; \
	)> $1_obspar.r

#SUMMARY simpar	simulation information (txt)
$1_simpar.txt:
	echo Creating $1_simpar.txt
	( \
	echo '# -*-octave-*- Put Emacs into octave-mode'; \
	echo "# Simulation parameters for system $1 ($1_simpar.txt)"; \
	echo "# Generated by MTT on" `date`.; \
	cat $MTTPATH/trans/rcs_header.sh; \
	echo ;\
	echo 'FIRST        = 0.0;       # First time in simulation output'; \
	echo 'DT          = 0.1;        # Print interval'; \
	echo 'LAST        = 10.0;       # Last time in simulation'; \
	echo 'STEPFACTOR  = 1;          # Integration steps per print interval'; \
	echo 'WMIN        = -1;         # Minimum frequency = 10^WMIN'; \
	echo 'WMAX        = 2;          # Maximum frequency = 10^WMAX'; \
	echo 'WSTEPS      = 100;        # Number of frequency steps'; \
	echo 'INPUT       = 1;          # Index of the input'; \
	)> $1_simpar.txt

#SUMMARY simpar	simulation information (m)
$1_simpar.m: $1_simpar.txt $1_def.r $1_sympar.txt
	mtt_txt2m $1 simpar


#SUMMARY numpar	numerical parameter declaration -- default (txt) 
$1_numpar.txt : $1_sympar.txt $1_def.r
ifeq ($target,$1_numpar.txt)
	mtt_update $1 numpar update
else
	mtt_update $1 numpar
endif

#SUMMARY state	numerical state declaration  -- default (txt)
ifeq ($steadystate_computation,yes)
$1_state.txt : $1_struc.txt $1_sympar.txt $1_def.r $1_ss.r
else
$1_state.txt : $1_struc.txt $1_sympar.txt $1_def.r
endif

ifeq ($target,$1_state.txt)
	mtt_update $1 state update
else
	mtt_update $1 state
endif

#SUMMARY input	numerical state declaration  -- default (txt)
$1_input.txt : $1_struc.txt $1_sympar.txt
ifeq ($target,$1_input.txt)
	mtt_update $1 input update
else
	mtt_update $1 input
endif

#SUMMARY logic	Dynamic switch logic (txt)
$1_logic.txt : $1_def.r $1_struc.txt $1_sympar.txt
ifeq ($target,$1_logic.txt)
	mtt_update $1 logic update
else
	mtt_update $1 logic
endif

# Dummy target
FORCE:

ifeq ($use_reduce,yes)
$1_ode2odes_common_%.stamp: $1_ae.% $1_input.% $1_logic.% $1_numpar.% $1_simpar.% $1_state.%
	touch \$@
$1_ode2odes_common.o: $1_ae.o $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o
	@echo "Creating $1_ode2odes_common.o"
	ar -cr \$@ \$^
else
$1_ode2odes_common_%.stamp: $1_sae.% $1_input.% $1_logic.% $1_numpar.% $1_simpar.% $1_state.%
	touch \$@
$1_ode2odes_common.o: $1_sae.o $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o
	@echo "Creating $1_ode2odes_common.o"
	ar -cr \$@ \$^
endif

ifeq ($use_reduce,yes)
$1_ode2odes_euler_%.stamp $1_ode2odes_rk4_%.stamp: $1_ode.% $1_odeo.%
	touch \$@
$1_ode2odes_euler.o $1_ode2odes_rk4.o: $1_ode.o $1_odeo.o mtt_euler.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
else
$1_ode2odes_euler_%.stamp $1_ode2odes_rk4_%.stamp: $1_sesx.% $1_sesy.%
	touch \$@
$1_ode2odes_euler.o $1_ode2odes_rk4.o: $1_sesx.o $1_sesy.o mtt_euler.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
endif

ifeq ($use_reduce,yes)
$1_ode2odes_implicit_%.stamp: $1_cseo.% $1_csex.% $1_smxa.% $1_smxax.%
	touch \$@
$1_ode2odes_implicit.o: $1_cseo.o $1_csex.o $1_smxa.o $1_smxax.o mtt_implicit.o
	@echo "Creating $1_ode2odes_implicit.o"
	ar -cr \$@ \$^
endif				# no alternative

ifeq ($use_reduce,yes)
$1_ode2odes_dassl_oct.stamp: $1_ode.oct $1_odeo.oct mtt_dassl.oct
	touch \$@
$1_ode2odes_dassl_o.stamp: $1_ode.o $1_odeo.o mtt_dassl.o
	touch \$@
$1_ode2odes_dassl_%.stamp: $1_ode.% $1_odeo.%
	touch \$@
$1_ode2odes_dassl.o: $1_ode.o $1_odeo.o mtt_dassl.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
else
$1_ode2odes_dassl_oct.stamp: $1_sesx.oct $1_sesy.oct mtt_dassl.oct
	touch \$@
$1_ode2odes_dassl_o.stamp: $1_sesx.o $1_sesy.o mtt_dassl.o
	touch \$@
$1_ode2odes_dassl_%.stamp: $1_sesx.% $1_sesy.%
	touch \$@
$1_ode2odes_dassl.o: $1_sesx.o $1_sesy.o mtt_dassl.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
endif

$1_ode2odes_${algebraic_solver}.cc:	mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.hh mtt_${algebraic_solver}.cc

$1_ode2odes_${algebraic_solver}.o:	mtt_Solver.o  mtt_AlgebraicSolver.o  mtt_${algebraic_solver}.o
	@echo "Creating $1_ode2odes_${algebraic_solver}.o"
	ar -cr \$@ \$^

#SUMMARY numpar	numerical parameter declaration (m) 
$1_numpar.m:  $1_numpar.txt $1_sympars.txt
	mtt_txt2m $1 numpar

#SUMMARY numpar	numerical parameter declaration (c) 
#SUMMARY numpar	numerical parameter declaration (view) 
$1_numpar.c:  $1_numpar.txt $1_sympar.c
	txt2c $1 numpar



#SUMMARY logic	logic input declaration (m) 
$1_logic.m:  $1_logic.txt $1_switch.txt
	mtt_txt2m $1 logic

#SUMMARY state	state declaration  -- default (txt)
#$1_state.txt: 
#	mtt $mtt_switches $1 struc txt; 
#	mtt $mtt_switches $1 ss r; 
#	struc2state_txt2txt $1

#SUMMARY state	state declaration (m) 
$1_state.m:  $1_state.txt $1_sympars.txt
	mtt_txt2m $1 state

#SUMMARY desc Verbal description of system (tex)
$1_desc.tex:
	makedesc $1


#SUMMARY params	symbolic parameter setting (r)
 $1_params.r: 
	echo Creating $1_params.r
	( \
	echo "%% Parameter file for system $1 ($1_params.r)"; \
	echo "%% This file provides symbolic parameters for simplification";\
	cat $MTTPATH/trans/m/rcs_header.txt; \
	echo 'END;'; \
	)> $1_params.r


#SUMMARY sspar	steady-state definition (r)
$1_sspar.r: 
	struc2sspar_txt2r $1

#SUMMARY sspar	steady-state parameters (tex)
#SUMMARY sspar	steady-state parameters (view)
$1_sspar.tex: $1_sspar.r
	txt2tex $1 sspar r

#SUMMARY rep*	report (txt)
#SUMMARY rep	report (tex)
#SUMMARY rep*	report (view)
#SUMMARY rep*	report (html)


ifeq ($documenttype,book)
$1_rep.txt:
	dir2rep $1 $dotdot;
else
$1_rep.txt:
	makerep_txt $1;
endif

#SUMMARY rbg	raw bond graph (m)
#Raw bond graph: fig file to mfile
$1_rbg.m: $1_abg.fig  $1_lbl.txt
	rbg_fig2m $1 $no_alpha_sort

$1_cmp.m: $1_lbl.txt $1_cmp.txt
	lbl2cmp_txt2m.pl --sys=$1 --$debug

$1_fig.fig: $1_rbg.m

#SUMMARY sabg	stripped acausal bond graph (fig)
#SUMMARY sabg	stripped acausal bond graph (ps)
#SUMMARY sabg	stripped acausal bond graph (view)
$1_sabg.fig: $1_rbg.m

#SUMMARY labg	latex-ready acausal bond graph (fig)
$1_labg.fig: $1_rbg.m
$1_labg.tex: $1_labg.fig
	fig2dev -L pstex_t -p $1_labg.eps $1_labg.fig $1_labg.tex
	fig2dev -L pstex $1_labg.fig $1_labg.eps
	cp -v $1_labg.eps ..

#Subsystem creation commands
#SUMMARY sub Executable subsystem list (sh)
ifeq ($start_at_abg,yes)
$1_sub.sh: $1_abg.m
	abg2sub_m2sh $1
else
$1_sub.sh: $1_cmp.txt $1_aliased_subsystems_copied
	cmp2sub_txt2sh $1
endif

#SUMMARY sub LaTeX subsystem list (tex)
#SUMMARY sub subsystem list (ps)
#SUMMARY sub subsystem list (view)
$1_sub.tex: $1_sub.sh
ifeq ($documenttype,section)
	sub_sh2tex $1
else
	sub_sh2tex -l $1
endif

#SUMMARY abg	acausal bond graph (m)
#Raw bond graph to acausal bond graph: mfile

ifneq ($start_at_abg,yes)
$1_abg.m: $1_ibg.m $1_cmp.m $1_lbl.txt $1_alias.m $1_sub.sh $1_icd.m
	@echo "Creating \$@"
	(sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' abg m null  || exit 1') || exit 1
	ibg2abg_m $info_switch $1
endif

ifeq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_ibg.m: $1_abg.dia $1_alias.m
	abg2ibg_dia2m $1
else
$1_ibg.m: $1_abg.fig $1_rbg.m
	@echo "Creating \$@"
	rbg2ibg_m $info_switch $1
endif

$1_connections.dat: $1_abg.m
	abg2connections_m2dat $1

#SUMMARY cbg*	causal bond graph (m)
#Acausal bond graph to causal bond graph: mfile
$1_cbg.m: $1_abg.m
	abg2cbg_m  $info_switch $causality_switch $1

$1_type.sh: $1_cbg.m
	touch $1_type.sh

#SUMMARY cbg*	causal bond graph (fig)
#SUMMARY cbg*	causal bond graph (dia)
#SUMMARY cbg*	causal bond graph (ps)
#SUMMARY cbg*	causal bond graph (view)
#Causal bond graph: mfile to fig conversion
$1_cbg.fig: $1_cbg.m  $1_fig.fig $1_type.sh
	sh $1_type.sh 'echo cbg_m2fig ' ' ' ' ' | sh

$1_cbg.dia: $1_cbg.m
	@sh $1_type.sh 'cbg_m2dia ' ' ' ' '

#SUMMARY ese	elementary system equations (r)
#SUMMARY def	definitions - system orders etc. (r)
#SUMMARY def	definitions - system orders etc. (m)
#SUMMARY def	definitions - system orders etc. (h)
#SUMMARY struc*	structure - list of inputs, outputs and states (txt)
#SUMMARY struc	structure - list of inputs, outputs and states (tex)
#SUMMARY struc*	structure - list of inputs, outputs and states (view)
#SUMMARY sum	structure summary - matrix of inputs, outputs and states (tex)
#SUMMARY sum*	structure summary - matrix of inputs, outputs and states (view)
#Elementary system equations + definitions
${sys}_ese.r: ${sys}_cbg.m
	   cbg2ese_m2r $partition $info_switch $Subsystem; #ese_tidy $1

ifeq ($sort_method,seqn)
${sys}_sese.m: ${sys}_def.r ${sys}_sese.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sese m
${sys}_sese.r: ${sys}_cbg.m ${sys}_struc.m
	echo Creating \$@
	cbg2sese_m2r $info_switch $Subsystem
endif

ifeq ($sort_method,make)
${sys}_sesx.m: ${sys}_def.r ${sys}_sesx.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sesx m
${sys}_sesy.m: ${sys}_def.r ${sys}_sesy.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sesy m
${sys}_sae.m: ${sys}_def.r ${sys}_sae.r ${sys}_sympar.txt
	echo Creating \$@
	mtt_r2m ${sys} sae m

${sys}_sese.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTdX MTTy > \$@
	echo 'END;' >> \$@
${sys}_sesx.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTdX > \$@
${sys}_sesy.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTy  > \$@
${sys}_sae.r: ${sys}_sese.make
	echo Creating \$@
	make -f \$< MTTyz > \$@

${sys}_sese.make: ${sys}_ese.txt
	echo Creating \$@
	ese_txt2make.pl --sys=${sys} --infile=${sys}_ese.txt --outfile=\$@ --$debug

${sys}_ese.txt: ${sys}_ese.r ${sys}_cr.txt perl_crs.stamp
	echo Creating \$@
	ese_r2txt.pl < \$< |\
	apply_crs ${sys} > \$@

perl_crs.stamp:
	echo Copying CRs from ${MTT_LIB}/cr/perl
	mkdir -p mtt
	cp ${MTT_LIB}/cr/perl/*.pm mtt/
	touch \$@
endif

$1_def.r: $1_ese.r
	touch $1_def.r
$1_struc.txt: $1_ese.r
	touch $1_struc.txt
$1_aliased.txt: $1_ese.r
	touch $1_aliased.txt
$1_struc.tex: $1_struc.txt
	struc_txt2tex $1
$1_sum.tex: $1_struc.txt
	struc2sum_txt2tex $1
$1_struc.m: $1_struc.txt 
	struc_txt2m $1
$1_def.m: $1_def.r
	def_r2m $1; matlab_tidy $1_def.m;
$1_def.h: $1_def.m $1_sympar.txt
	def_m2h.sh $1

#SUMMARY rdae	raw differential-algebraic equations (r)
#SUMMARY dae	differential-algebraic equations (r)
#SUMMARY dae*	differential-algebraic equations (m)
#SUMMARY dae	differential-algebraic equations (tex)
#SUMMARY dae*	differential-algebraic equations (view)
#SUMMARY dae	differential-algebraic equations (ps)
#Differential-algebraic equations

ifeq ($do_sort,)
${sys}_rdae.r: ${sys}_ese.r ${sys}_def.r $1_modpar.r ${Subsystem}_cr.r ${Subsystem}_subs.r
else
${sys}_rdae.r: ${sys}_sese.r ${sys}_def.r $1_modpar.r ${Subsystem}_cr.r ${Subsystem}_subs.r
endif
ifneq ($partition,)
	echo Doing subsystems
	mtt_make_subsystems  ${sys} rdae r
endif
	mtt_prepend.sh -p $1_modpar.r $1_ese.r # Add modulated parameters to start
	ese2rdae_r ${cr_first} ${fixcc} ${do_sort} ${Subsystem}
	tidy ${Subsystem}_rdae.r

${sys}_dae.r: ${Subsystem}_rdae.r ${Subsystem}_def.r ${Subsystem}_subs.r ${Subsystem}_cr.r
ifneq ($partition,)
	echo Doing subsystems
	mtt_make_subsystems  ${sys} dae r
endif
ifeq ($rdae_is_dae,1)
	echo Copying $1_rdae.r to $1_dae.r
	cp $1_rdae.r  $1_dae.r
else
	rdae2dae_r ${fixcc} ${Subsystem}; tidy ${Subsystem}_dae.r
endif

$1_dae.m: $1_def.r $1_dae.r  $1_sympars.txt
	dae_r2m $1; matlab_tidy $1_dae.m; matlab_tidy $1_daeo.m
$1_dae.c: $1_def.r $1_dae.r  $1_sympar.r
	dae_r2c $1; c_tidy $1_dae.c
$1_dae.tex: $1_dae.r $1_simp.r
	dae_r2tex $partition $1; latex_tidy $1_dae.tex

#SUMMARY ae	algebraic equations - unknown inputs (r)
#SUMMARY ae	algebraic equations - unknown inputs (m)
#SUMMARY ae	algebraic equations - unknown inputs (cc)

ifeq ($algebraic_solver,noAlgebraicSolver)
$1_ae.r:
else
$1_ae.r: $1_cse.r
endif
	touch \$@

$1_ae.m: $1_ae.r
	mtt_r2m $1 ae

#SUMMARY cse	constrained-state equations (r)
#SUMMARY cse*	constrained-state equations (m)
#SUMMARY cse*	constrained-state equations (oct)
#SUMMARY cse	constrained-state equations (tex)
#SUMMARY cse*	constrained-state equations (view)
#SUMMARY cse	constrained-state equations (ps)
#Constrained-state equations
${sys}_cse.r: ${Subsystem}_dae.r ${Subsystem}_dae.r ${Subsystem}_def.r ${Subsystem}_subs.r 
ifneq ($partition,)
	echo Doing subsystems
	mtt_make_subsystems  ${sys} cse r
endif
	dae2cse_r $fixcc $optimise $Solve ${Subsystem}; tidy ${Subsystem}_cse.r #$1_subs.r
$1_csex.r: $1_cse.r
	touch $1_csex.r
$1_cseo.r: $1_cse.r
	touch $1_cseo.r

#$1_cse.m: $1_def.r $1_cse.r $1_sympar.r  $1_subs.r 
#	cse_r2m $1; matlab_tidy $1_cse.m
${sys}_cse.m: ${Subsystem}_def.r ${Subsystem}_cse.r ${sys}_sympars.txt
ifneq ($partition,)
	echo Doing subsystems
	mtt_cp_subrep ${sys} sympars txt
	mtt_make_subsystems  ${sys} cse m
endif
	mtt_r2m ${Subsystem} cse;#  matlab_tidy $1_cse.m; matlab_tidy $1_cseo.m; 

${sys}_cseo.m: ${Subsystem}_def.r ${Subsystem}_cseo.r ${sys}_sympars.txt
ifneq ($partition,)
	echo Doing subsystems
	mtt_cp_subrep ${sys} sympars txt
	mtt_make_subsystems  ${sys} cseo m
endif
	mtt_r2m ${Subsystem} cseo

${sys}_csex.m: ${Subsystem}_def.r ${Subsystem}_csex.r ${sys}_sympars.txt
ifneq ($partition,)
	echo Doing subsystems
	mtt_cp_subrep ${sys} sympars txt
	mtt_make_subsystems  ${sys} csex m
endif
	mtt_r2m ${Subsystem} csex

$1_cse.tex: $1_cse.r  $1_sympar.r $1_simp.r
	cse_r2tex $1 $2; latex_tidy $1_cse.tex


#SUMMARY scse	sensitivity constrained-state equations (r)
#SUMMARY scse	sensitivity constrained-state equations (tex)
#SUMMARY scse	sensitivity constrained-state equations (ps)

$1_scse.r: $1_cse.r $1_def.r 
	cse2scse_r  $1 "$4"; tidy $1_scse.r

#$1_cse.m: $1_def.r $1_cse.r $1_sympar.r  $1_subs.r 
#	cse_r2m $1; matlab_tidy $1_cse.m
$1_scse.m: $1_def.m $1_scse.r $1_sympars.txt
	mtt_r2m $optimise  -parameters $1 scse;  
	matlab_tidy $1_scse.m; matlab_tidy $1_scseo.m; 

$1_scse.tex: $1_scse.r  $1_sympar.r $1_simp.r
	cse_r2tex $1 $2; latex_tidy $1_scse.tex


#SUMMARY ode	ordinary differential equations (r)
#SUMMARY ode*	ordinary differential equations (m)
#SUMMARY ode	ordinary differential equations (c)
#SUMMARY ode	ordinary differential equations (tex)
#SUMMARY ode*	ordinary differential equations (view)
#SUMMARY ode	ordinary differential equations (ps)
#SUMMARY ode	ordinary differential equations (oct)
#Ordinary differential equations

ifeq ($dae_is_ode,1)
$1_ode.r: $1_dae.r
	echo Copying $1_dae.r to $1_ode.r
	cp $1_dae.r  $1_ode.r
else
$1_ode.r: $1_cse.r $1_cseo.r $1_def.r $1_sympar.r $1_subs.r
	cse2ode_r $optimise $1; tidy $1_ode.r
endif

$1_odeo.r: $1_ode.r
	touch $1_odeo.r

$1_ode.m: $1_def.r $1_ode.r
	mtt_r2m $optimise -parameters $1 ode m; #  matlab_tidy $1_ode.m
$1_odeo.m: $1_def.r $1_odeo.r
	mtt_r2m $1 odeo m

$1_odea.m: $1_ode.m
	touch $1_odea.m

$1_ode.tex: $1_ode.r  $1_sympar.r $1_simp.r
	ode_r2tex $1; latex_tidy $1_ode.tex


$1_lde.r: $1_dae.r
	dae2lde_r $optimise $1; tidy $1_lde.r

$1_lde.tex: $1_lde.r  $1_sympar.r $1_simp.r
	lde_r2tex $1; latex_tidy $1_lde.tex

# The main simulation programme
ifeq ($integration_method,implicit)
$1_ode2odes.m : $1_def.r $1_sympars.txt \
                $1_smxa.m $1_smxax.m\
                $1_simpar.m $1_numpar.m $1_state.m $1_input.m \
                $1_csex.m $1_cseo.m  $1_logic.m
ifeq ($using_oct,yes)
	touch $1_ode2odes.m # Create a dummy which wont' be used
	mtt $mtt_switches -q -u $1 ode2odes oct
else
	make_ode2odes $1 m $integration_method $algebraic_solver $sort_method
endif
endif
ifneq ($integration_method,implicit)
ifeq ($sort_method,seqn)
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_sese.m $1_logic.m
else
ifeq ($use_reduce,no)
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_sesx.m $1_sesy.m $1_logic.m
else
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_ode.m $1_odeo.m  $1_logic.m
endif
endif
ifeq ($using_oct,yes)
	echo "*** Warning: Shouldn't be here! Creating dummy $1_ode2odes.m"
	touch $1_ode2odes.m # Create a dummy which wont' be used
	mtt $mtt_switches -q -u $1 ode2odes oct
else
	make_ode2odes $1 m $integration_method $algebraic_solver $sort_method
endif
endif

#SUMMARY ode2odes Simulation function (m)
#SUMMARY ode2odes Simulation function (cc)
#SUMMARY ode2odes Simulation function (oct)
#SUMMARY ode2odes_rtxi Simulation function (o)
#SUMMARY ode2odes Simulation function (exe)
$1_ode2odes.exe: $1_def.h $1_sympar.h\
		 $1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o mtt_kpathsea.o
	echo Creating $1_ode2odes.exe
	${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\
	$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o mtt_kpathsea.o\
	${MTT_LDFLAGS} ${MTT_CXXLIBS}

$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
	echo Creating $1_ode2odes.o
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DCODEGENTARGET=STANDALONE

$1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common_oct.stamp $1_ode2odes_${integration_method}_oct.stamp $1_ode2odes_${algebraic_solver}.o
	touch $1_ode2odes.m
	echo Creating $1_ode2odes.oct
	$MKOCTFILE ${MTT_CXXINCS} -DCODEGENTARGET=OCTAVEDLD $1_ode2odes.cc mtt_${algebraic_solver}.cc mtt_Solver.cc mtt_AlgebraicSolver.cc

$1_ode2odes.mexglx: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
	touch $1_ode2odes.m
	echo Creating $1_ode2odes.mexglx
	${MTT_CXX} -DCODEGENTARGET=MATLABMEX -o $1_ode2odes.mexglx $1_ode2odes.cc \
	$1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o \
	${MTT_MATLAB_FLAGS} ${MTT_CXXINCS} ${MTT_CXXLIBS} ${MTT_CXXFLAGS} \
	${MTT_LIB}/cc/mtt_kpathsea.cc ${MTT_LIB}/cc/mtt_matlab_octave.cc

$1_ode2odes.cc: $1_def.r $1_sympars.txt\
		$1_ode2odes_common_m.stamp $1_ode2odes_common_cc.stamp\
		$1_ode2odes_${integration_method}_m.stamp $1_ode2odes_${integration_method}_cc.stamp\
		mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.cc mtt_${algebraic_solver}.hh
	touch $1_ode2odes.m
	make_ode2odes $1 cc $integration_method $algebraic_solver $sort_method

#SUMMARY rtxi real time module (cc)
#SUMMARY rtxi real time module (so)
$1_ode2odes_rtxi.lo: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o \
		    $1_rtxi.cc $1_rtxi.h
	@echo "Creating \$@"
	${MTT_RTXI_CXXCOMPILE} ${MTT_RTXI_CXXFLAGS} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DCODEGENTARGET=RTXI -o \$@
	@echo compilation complete

$1_rtxi.so: $1_rtxi.cc $1_ode2odes_rtxi.lo $1_rtxi.h
	@echo Compiling module
	${MTT_RTXI_CXXCOMPILE} ${MTT_RTXI_CXXFLAGS} -c $1_rtxi.cc -o $1_rtxi.lo
	@echo Compilation complete
	${MTT_RTXI_CXXLINK} ${MTT_RTXI_LIBS} ${MTT_RTXI_LDFLAGS} ${MTT_CXXLIBS} -rpath ${MTT_RTXI_RPATH}$1 -o $1_rtxi.la $1_rtxi.lo $1_ode2odes_rtxi.lo
	@echo Module created

$1_rtxi.install: $1_rtxi.so
	@echo Installing module in ${MTT_RTXI_RPATH}$1)
	${MTT_RTXI_LIBTOOL} --mode=install cp $1_rtxi.la ${MTT_RTXI_RPATH}$1

$1_rtxi.cc: $1_struc.txt $1_sympar.txt
	echo Creating \$@
	sympar2rtxi_txt2cc $1

$1_rtxi.h: $1_sympar.txt
	echo Creating \$@
	sympar2rtxi_txt2h $1



#Conversion of m to p to c
#SUMMARY ode	ordinary differential equations (c)
#SUMMARY ode	ordinary differential equations (p)
#SUMMARY state	state declaration (c) 
#SUMMARY state	state declaration (p) 
$1_simpar.p : $1_def.r $1_simpar.m
	mtt_m2p $1_simpar.m
$1_numpar.p : $1_def.r $1_numpar.m
	mtt_m2p $1_numpar.m
$1_state.p : $1_def.r $1_state.m
	mtt_m2p $1_state.m

#SUMMARY input	numerical input declaration (m) 
ifeq ($stdin,stdin)
$1_input.m : $1_def.r
	make_stdin $1 m
$1_input.p : $1_def.r
	make_stdin $1 p
$1_input.cc:
	make_stdin $1 cc
else
$1_input.m:  $1_input.txt $1_sympars.txt
	mtt_txt2m $1 input
$1_input.p : $1_def.r $1_input.m
	mtt_m2p $1_input.m
endif

$1_ode.p : $1_def.r $1_ode.m
	mtt_m2p $1_ode.m
$1_odeo.p : $1_def.r $1_odeo.m
	mtt_m2p $1_odeo.m
$1_csex.p : $1_def.r $1_cse.m
	mtt_m2p $1_csex.m
$1_cseo.p : $1_def.r $1_cseo.m
	mtt_m2p $1_cseo.m
$1_smx.p : $1_def.r $1_smx.m
	mtt_m2p $1_smx.m
$1_smxa.p : $1_def.r $1_smxa.m
	mtt_m2p $1_smxa.m
$1_smxax.p : $1_def.r $1_smxax.m
	mtt_m2p $1_smxax.m
$1_logic.p : $1_def.r $1_logic.m
	mtt_m2p $1_logic.m

ifeq ($integration_method,implicit)
$1_ode2odes.p : $1_ode2odes.m $1_def.r $1_smxa.p $1_smxax.p\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_csex.p $1_cseo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif
ifneq ($integration_method,implicit)
$1_ode2odes.p : $1_ode2odes.m $1_def.r\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_ode.p $1_odeo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif

$1_ode2odes.c: $1_ode2odes.p 
	mtt_p2c $info_switch $1 ode2odes

##SUMMARY sim Octave simulation function (m)

#ifeq ($computation,octave)
#$1_sim.m: $1_def.r $1_sympar.txt $1_cse.m $1_cseo.m $1_smxa.m $1_smxax.m $1_numpar.m $1_state.m
	mtt_make_sim $1 $integration_method $computation 
#endif

#ifeq ($computation,c)
#$1_sim.m: $1_def.r $1_sympar.txt $1_ode2odes.out $1_numpar.m $1_state.m
#	mtt_make_sim $1 $integration_method $computation 
#endif

#SUMMARY ssim Octave sensitivity simulation function (m)
$1_ssim.m: $1_def.r $1_ode2odes.${m}
	make_ssim $1 m

#SUMMARY sim Octave simulation function (m)
$1_sim.m: $1_def.r $1_ode2odes.${m}
	make_sim $1 m

#SUMMARY obs	observer equations for CGPC (r)
#SUMMARY obs*	observer equations for CGPC (m)
#SUMMARY obs	observer equations for CGPC (tex)
#SUMMARY obs*	observer equations for CGPC (view)
#SUMMARY obs	observer equations for CGPC (ps)
#Observer functions for GPC
$1_obs.r: $1_ode.r $1_def.r $1_obspar.r $1_subs.r
	ode2obs_r $1; tidy $1_obs.r
$1_obs.m: $1_def.r $1_sympars.txt $1_obs.r $1_obspar.r $1_numpar.m
	mtt_r2m $optimise  -parameters $1 obs
$1_obs.tex: $1_obs.r  $1_sympar.r $1_simp.r
	obs_r2tex $1; latex_tidy $1_obs.tex


#SUMMARY rfe	robot-form equations (r)
#SUMMARY rfe	robot-form equations (tex)
#SUMMARY rfe*	robot-form equations (view)
#SUMMARY rfe	robot-form equations (ps)
#Robot-form equations
$1_rfe.r: $1_cse.r $1_csm.r $1_def.r $1_sympar.r
	cse2rfe_r $1; tidy $1_rfe.r
$1_rfe.tex: $1_rfe.r  $1_sympar.r  $1_simp.r
	rfe_r2tex $1; latex_tidy $1_rfe.tex

#SUMMARY ss	steady-state equations (r)
#SUMMARY ss*	steady-state equations (m)
#SUMMARY ss	steady-state equations (tex)
#SUMMARY ss*	steady-state equations (view)
#SUMMARY ss	steady-state equations (ps)
#Steady-states
$1_ss.r: $1_def.r $1_sspar.r $1_cr.r $1_ode.r
	sspar2ss_r $1; tidy $1_ss.r
$1_ss.m: $1_def.r  $1_ss.r  $1_numpar.m
	ss_r2m $1; matlab_tidy $1_ss.m
$1_ss.tex: $1_def.r $1_ss.r $1_simp.r
	ss_r2tex $1; latex_tidy $1_ss.tex 


#SUMMARY dm	descriptor matrices (r)
#SUMMARY dm*	descriptor matrices (m)
#SUMMARY dm	descriptor matrices (tex)
#SUMMARY dm*	descriptor matrices (view)
#SUMMARY dm	descriptor matrices (ps)
#Linearised system: descriptor matrices
$1_dm.r: $1_dae.r $1_def.r $1_cr.r  $1_ss.r $1_sympar.r
	dae2dm_r $1; tidy $1_dm.r
$1_dm.m: $1_def.r $1_dm.r $1_sympars.txt
		mtt_r2m $optimise -parameters $1 dm
$1_dm.tex: $1_dm.r $1_sympar.r $1_simp.r 
	dm_r2tex $1; latex_tidy $1_dm.tex



#SUMMARY csm	constrained-state matrices (r)
#SUMMARY csm	constrained-state matrices (m)
#SUMMARY csm	constrained-state matrices (tex)
#SUMMARY csm	constrained-state matrices (view)
#SUMMARY csm    constrained-state matrices (ps)
#Linearised system: constrained-state matrices
$1_csm.r: $1_cse.r $1_def.r $1_cr.r $1_sspar.r
	cse2csm_r $1 csm; tidy $1_csm.r
$1_csm.m: $1_def.r $1_csm.r $1_sympars.txt
		mtt_r2m $optimise  -parameters $1 csm;  matlab_tidy $1_csm.m
$1_csm.tex: $1_csm.r  $1_sympar.r $1_simp.r
	csm_r2tex $1 csm; latex_tidy $1_csm.tex
#SUMMARY scsm	sensitivity constrained-state matrices (r)
#SUMMARY scsm	sensitivity constrained-state matrices (m)
#SUMMARY scsm	sensitivity constrained-state matrices (tex)
#SUMMARY scsm	sensitivity constrained-state matrices (view)
#SUMMARY scsm	sensitivity constrained-state matrices (ps)
#Linearised system: sensitivity constrained-state matrices
$1_scsm.r: $1_scse.r $1_def.r $1_cr.r $1_sympar.r $1_sspar.r
	cse2csm_r $1 scsm; tidy $1_scsm.r
$1_scsm.m: $1_def.r $1_scsm.r $1_sympars.txt
		csm_r2m $1 scsm;  matlab_tidy $1_scsm.m
$1_scsm.tex: $1_scsm.r  $1_sympar.r $1_simp.r
	csm_r2tex $1 scsm; latex_tidy $1_scsm.tex

#SUMMARY sm	state matrices (r)
#SUMMARY sm*	state matrices (m)
#SUMMARY sm	state matrices (icad)
#SUMMARY sm	state matrices (tex)
#SUMMARY sm	state matrices (c)
#SUMMARY sm*	state matrices (view)
#SUMMARY sm	state matrices (ps)
#Linearised system: state matrices
$1_sm.r: $1_csm.r $1_def.r $1_cr.r $1_ss.r $1_sympar.r
	csm2sm_r $optimise $1 sm; tidy $1_sm.r
$1_sm.m: $1_def.r $1_sm.r $1_sympars.txt 
		mtt_r2m $optimise  -parameters $1 sm
$1_sm.icad:  $1_sm.m $1_numpar.m
		sm_m2icad $1
$1_sm.c: $1_def.r $1_sm.r $1_sympar.c
		sm_r2c $1
$1_sm.tex: $1_sm.r  $1_sympar.r $1_simp.r
	sm_r2tex $1 sm; latex_tidy $1_sm.tex

#SUMMARY ssm	sensitivity state matrices (r)
#SUMMARY ssm	sensitivity state matrices (icad)
#SUMMARY ssm	sensitivity state matrices (tex)
#SUMMARY ssm	sensitivity state matrices (c)
#SUMMARY ssm	sensitivity state matrices (ps)
#Linearised system: sensitivity state matrices
$1_ssm.r: $1_scsm.r $1_def.r $1_cr.r $1_ss.r $1_sympar.r
	csm2sm_r $optimise $1 ssm; tidy $1_ssm.r
$1_ssm.m: $1_def.r $1_ssm.r $1_sympars.txt 
		mtt_r2m $optimise -parameters $1 ssm
$1_ssm.tex: $1_ssm.r  $1_sympar.r $1_simp.r
	sm_r2tex $1 ssm; latex_tidy $1_ssm.tex

#SUMMARY smx	state matrices with variable state x (r)
#SUMMARY smx	state matrices with variable state x (m)
#SUMMARY smxx	Sparse computation of Ax (m)
#SUMMARY smxtx	Sparse computation of ATx (m)
$1_smx.r: $1_def.r $1_def.m $1_ode.r $1_subs.r
		ode2smx_lang $1 r; tidy $1_smx.r

$1_smx.m: $1_def.r $1_def.m $1_cse.r $1_sympars.txt $1_subs.r
		cse2smx_lang $fixcc $optimise -parameters $1 smx m

$1_smxa.m: $1_def.r $1_def.m $1_cse.r  $1_sympars.txt $1_subs.r
		cse2smx_lang $fixcc $optimise -parameters $matrix_smxa $1 smxa m

$1_smxax.m: $1_def.r $1_def.m $1_cse.r $1_sympars.txt $1_subs.r
		cse2smx_lang $fixcc $optimise -parameters $1 smxax m

#SUMMARY smc	controller form state matrices etc. - siso only (r)
#SUMMARY smc	controller form state matrices etc. - siso only (tex)
#SUMMARY smc*	controller form state matrices etc. - siso only (m)
#SUMMARY smc*	controller form state matrices etc. - siso only (view)
#SUMMARY smc	controller form state matrices etc. - siso only (ps)
#Linearised system: controller form state matrices etc.
$1_smc.r: $1_sm.r $1_def.r $1_tf.r 
	sm2smc_r $1; tidy $1_smc.r
$1_smc.tex: $1_smc.r  $1_simp.r
	smc_r2tex $1; latex_tidy $1_smc.tex
$1_smc.m: $1_def.r $1_smc.r $1_numpar.m
		smc_r2m $1;  matlab_tidy $1_smc.m

#SUMMARY smo	observer form state matrices etc. - siso only (r)
#SUMMARY smo	observer form state matrices etc. - siso only (tex)
#SUMMARY smo*	observer form state matrices etc. - siso only (m)
#SUMMARY smo*	observer form state matrices etc. - siso only (view)
#SUMMARY smo	observer form state matrices etc. - siso only (ps)
#Linearised system: observer form state matrices etc.
$1_smo.r: $1_sm.r $1_def.r $1_tf.r 
	sm2smo_r $1; tidy $1_smo.r
$1_smo.tex: $1_smo.r  $1_simp.r
	smo_r2tex $1; latex_tidy $1_smo.tex
$1_smo.m: $1_def.r $1_smo.r $1_numpar.m
		smo_r2m $1;  matlab_tidy $1_smo.m

#SUMMARY ssk	State-space controller gain - siso only (r)
#SUMMARY ssk	State-space controller gain - siso only (tex)
#SUMMARY ssk*	State-space controller gain - siso only (m)
#SUMMARY ssk*	State-space controller gain - siso only (view)
#SUMMARY ssk	State-space controller gain - siso only (ps)
#Linearised system: State-space controller gain
$1_ssk.r: $1_def.r $1_smc.r 
	smc2ssk_r $1; tidy $1_ssk.r
$1_ssk.tex: $1_ssk.r  $1_simp.r
	ssk_r2tex $1; latex_tidy $1_ssk.tex
$1_ssk.m: $1_def.r $1_ssk.r $1_numpar.m
		ssk_r2m $1;  matlab_tidy $1_ssk.m

#SUMMARY ssl	State-space observer gain - siso only (r)
#SUMMARY ssl	State-space observer gain - siso only (tex)
#SUMMARY ssl*	State-space observer gain - siso only (m)
#SUMMARY ssl*	State-space observer gain - siso only (view)
#SUMMARY ssl	State-space observer gain - siso only (ps)
#Linearised system: State-space observer gain
$1_ssl.r: $1_def.r $1_smo.r 
	smo2ssl_r $1; tidy $1_ssl.r
$1_ssl.tex: $1_ssl.r  $1_simp.r
	ssl_r2tex $1; latex_tidy $1_ssl.tex
$1_ssl.m: $1_def.r $1_ssl.r $1_numpar.m
		ssl_r2m $1;  matlab_tidy $1_ssl.m

#SUMMARY tf	transfer function (r)
#SUMMARY tf*	transfer function (m)
#SUMMARY tf	transfer function (tex)
#SUMMARY tf*	transfer function (view)
#SUMMARY tf	transfer function (ps)
#Linearised system: transfer function
$1_tf.r: $1_dm.r $1_sympar.r 
	dm2tf_r $1; tidy $1_tf.r
$1_tf.m: $1_def.r $1_sympars.txt $1_tf.r 
	tf_r2m $1; matlab_tidy $1_tf.m
$1_tf.tex: $1_def.r $1_tf.r $1_sympar.r $1_simp.r
	tf_r2tex $1; latex_tidy $1_tf.tex

#SUMMARY pkim	partialyy-known system identification matrix (r)
#SUMMARY pkim	partialyy-known system identification matrix (tex)
#SUMMARY pkim	partialyy-known system identification matrix (view)
#SUMMARY pkim	partialyy-known system identification matrix (ps)
$1_pkim.r: $1_tf.r $1_sympar.r 
	tf2pkim_r $1; tidy $1_pkim.r
$1_pkim.tex: $1_def.r $1_pkim.r $1_simp.r
	pkim_r2tex $1; latex_tidy $1_pkim.tex

#SUMMARY ctf    controller transfer function (r)
#SUMMARY ctf	controller transfer function (m)
#SUMMARY ctf	controller transfer function (tex)
#SUMMARY ctf	controller transfer function (view)
#SUMMARY ctf	controller transfer function (ps)
#Linearised system: transfer function
$1_ctf.r: $1_dm.r $1_ssk.r  $1_ssl.r   $1_sm.r  
	ssk2ctf_r $1; tidy $1_ctf.r
$1_ctf.m: $1_def.r $1_ctf.r 
	ctf_r2m $1; matlab_tidy $1_ctf.m
$1_ctf.tex: $1_def.r $1_ctf.r $1_sympar.r $1_simp.r
	ctf_r2tex $1; latex_tidy $1_ctf.tex

#SUMMARY ir	impulse response - state (m)
#SUMMARY ir	impulse response - state (dat)
#SUMMARY ir	impulse response - state (ps)
#SUMMARY ir	impulse response - state (view)

#SUMMARY iro	impulse response - output (m)
#SUMMARY iro	impulse response - output (dat)
#SUMMARY iro	impulse response - output (ps)
#SUMMARY iro	impulse response - output (view)

#SUMMARY sr	step response - state (m)
#SUMMARY sr	step response - state (dat)
#SUMMARY sr	step response - state (ps)
#SUMMARY sr	step response - state (view)

#SUMMARY sro*	step response - output (m)
#SUMMARY sro	step response - output (dat)
#SUMMARY sro	step response - output (ps)
#SUMMARY sro*	step response - output (view)

#SUMMARY odes	ode solution - state (m)
#SUMMARY odes*	ode solution - state (dat)
#SUMMARY odes*  ode solution - state & output for SciGraphica (sg)
#SUMMARY odes*	ode solution - state (ps)
#SUMMARY odes*	ode solution - state (view)

#SUMMARY sms	ode (in state matrix form) solution - state & output (c)

#SUMMARY odeso	ode solution - output (m)
#SUMMARY odeso*	ode solution - output (dat)
#SUMMARY odeso*	ode solution - output for spreadsheet (sdat) 
#SUMMARY odeso	ode solution - output (ps)
#SUMMARY odeso*	ode solution - output (view)

#SUMMARY daes   dae solution - state (m)
#SUMMARY daes	dae solution - state (dat)
#SUMMARY daes	dae solution - state (ps)
#SUMMARY daes	dae solution - state (view)

#SUMMARY daeso  dae solution - output (m)
#SUMMARY daeso	dae solution - output (dat)
#SUMMARY daeso	dae solution - output (ps)
#SUMMARY daeso	dae solution - output (view)

#Time responses
$1_ir.m: $1_sm.m $1_numpar.m $1_def.m $1_simpar.m
	sm2ir_m $1 '$ARGS'
$1_iro.m: $1_ir.m
	touch $1_iro.m
$1_ir.dat: $1_ir.m
	m2dat $1_ir
$1_iro.dat: $1_iro.m
	m2dat $1_iro
$1_sr.m: $1_sm.m $1_numpar.m $1_simpar.m $1_def.m
	sm2sr_m $1 
$1_sr.dat: $1_sr.m
	m2dat $1_sr
$1_sro.m: $1_sr.m
	touch $1_sro.m$
$1_sro.dat: $1_sro.m
	m2dat $1_sro
1_odes.c: $1_ode.c $1_def.r $1_sympar.r
	ode2odes_r2c $1 
$1_sms.c: $1_sm.c $1_def.r $1_sympar.r
	sm2sms_r2c $1

.PRECIOUS: $1_odes.dat2
ifeq ($computation,octave)
ifeq ($using_oct,yes)
$1_odes.dat2: $1_ode2odes.oct
	time octave_ode2odes $1
else
$1_odes.dat2: $1_ode2odes.m
	time octave_ode2odes $1
endif
endif

$1_ode2odes.out: $1_ode2odes.c $1_cr.h
	echo Creating $1_odes.out by compiling $1_ode2odes.c 
	$CC $1_ode2odes.c -lp2c -lm -o $1_ode2odes.out

ifeq ($computation,c)
$1_odes.dat2: $1_ode2odes.out
	echo Creating $1_odes.dat2 using c version
	    time ./$1_ode2odes.out>$1_odes.dat2
endif

ifeq ($computation,cc)
$1_sim.exe: $1_ese.r 
	mtt $mtt_switches -q $1 sim exe

$1_odes.dat2: $1_ode2odes.exe 
	echo Creating $1_odes.dat2 using cc version $ARGS
	    time ./$1_ode2odes.exe $ARGS >$1_odes.dat2
endif


#$1_odeso.m: $1_odes.m
#	touch $1_odeso.m
#$1_smso.m: $1_sms.m
#	touch $1_smso.m
#$1_daes.m: $1_dae.m $1_numpar.m  $1_def.m $1_input.m $1_simpar.m
#	dae2daes_m $1 '$ARGS'
#$1_daeso.m: $1_daes.m
#	touch $1_daeso.m


#Conversion of data files from dat to sdat format
$1_odeso.sdat: $1_odeso.dat $1_struc.txt
	odeso_dat2sdat $1

$1_odes.sdat: $1_odes.dat $1_struc.txt
	odes_dat2sdat $1

#Conversion of data to SciGraphica
$1_odes.sg: $1_struc.m $1_odes.dat2
	echo Creating $1_odes.sg
	dat22sg.sh $1

#SUMMARY odess	ode numerical steady-states - states (m)
#SUMMARY odess	ode numerical steady-states - states (dat)
#SUMMARY odess	ode numerical steady-states - states (ps)
#SUMMARY odess	ode numerical steady-states - states (view)

#SUMMARY odesso	ode numerical steady-states - outputs (m)
#SUMMARY odesso	ode numerical steady-states - outputs (dat)
#SUMMARY odesso	ode numerical steady-states - outputs (ps)
#SUMMARY odesso	ode numerical steady-states - outputs (view)

#Numerical steady states
$1_odess.dat2: $1_ode.m $1_odeo.m $1_numpar.m  $1_input.m $1_simpar.m
	ode2odess_m2dat2 $1 
#$1_odess.m: $1_ode.m $1_odeo.m $1_numpar.m  $1_input.m $1_simpar.m
#	ode2odess_m $1 
#$1_odesso.m: $1_odess.m
#	touch $1_odesso.m


#SUMMARY fr	frequency response (m)
#SUMMARY fr	frequency response (dat)
#SUMMARY fr	frequency response (ps)
#SUMMARY fr	frequency response (view)

#SUMMARY lmfr	loglog modulus frequency response (m)
#SUMMARY lmfr	loglog modulus frequency response (dat)
#SUMMARY lmfr	loglog modulus frequency response (ps)
#SUMMARY lmfr*	loglog modulus frequency response (view)

#SUMMARY lpfr	semilog phase frequency response (m)
#SUMMARY lpfr	semilog phase frequency response (dat)
#SUMMARY lpfr	semilog phase frequency response (ps)
#SUMMARY lpfr*	semilog phase frequency response (view)

#SUMMARY nyfr	Nyquist style frequency response (m)
#SUMMARY nyfr	Nyquist style frequency response (dat)
#SUMMARY nyfr	Nyquist style frequency response (ps)
#SUMMARY nyfr	Nyquist style frequency response (view)

#SUMMARY nifr	Nichols style frequency response (m)
#SUMMARY nifr	Nichols style frequency response (dat)
#SUMMARY nifr	Nichols style frequency response (ps)
#SUMMARY nifr	Nichols style frequency response (view)


#Frequency responses
$1_fr.m: $1_dm.m $1_numpar.m $1_def.m $1_simpar.m
	dm2fr_m $1 
$1_lmfr.m $1_lpfr.m $1_nyfr.m $1_nifr.m: $1_fr.m

$1_fr.dat: $1_fr.m
	m2dat $1_fr
$1_lmfr.dat: $1_lmfr.m
	m2dat $1_lmfr
$1_lpfr.dat: $1_lpfr.m
	m2dat $1_lpfr
$1_nyfr.dat: $1_nyfr.m
	m2dat $1_nyfr
$1_nifr.dat: $1_nifr.m
	m2dat $1_nifr


ifeq ($REPTYPE,txt)
#Generic conversion of txt files to tex files
$1_$2.tex: $1_$2.txt
	txt2tex $1 $2 txt
 endif

#Conversion of dat2 files  to dat format
$1_odeso.dat: $1_odes.dat2 $1_def.r
	echo Creating $1_odeso.dat
	dat22dat $1 ode so
$1_odes.dat: $1_odes.dat2 $1_def.r
	echo Creating $1_odes.dat
	dat22dat $1 ode s
$1_odesso.dat: $1_odess.dat2 $1_def.r
	echo Creating $1_odesso.dat
	dat22dat $1 odes so
$1_odess.dat: $1_odess.dat2 $1_def.r
	echo Creating $1_odess.dat
	dat22dat $1 odes s

#Generic conversion of data files from dat to (gplot) gdat format 
$1_$2.gdat: $1_$2.dat $1_struc.txt  $1_args.m
	dat2gdat $1 $2 "$ARGS" "$NyquistStyle"

## Conversion of gdat to fig files
ifeq ($REPTYPE,data)
$1_$2.fig: $1_$2.gdat
	gdat2fig $1_$2

ifneq ($ARGS,) ## Multiple plots
	echo Creating $1_$2$__ARGS.fig
	mv $1_$2.fig $1_$2$__ARGS.fig
	rm -f $1_$2.gdat
endif

## Conversion of gdat fig files to ps/pdf
ifeq ($ARGS,) # single plot
$1_$2.$ps : $1_$2.fig
	echo Creating $1_$2.$ps
	fig2dev -L$eps $1_$2.fig > $1_$2.$ps
else ## Multiple plots
$1_$2.$ps : $1_$2.fig
	mtt -q -r $1 $2 dat $4
	echo Creating $1_$2$__ARGS.$ps
	fig2dev -L$eps $1_$2$__ARGS.fig > $1_$2$__ARGS.$ps
endif

endif


#Generic conversion of Latex to latex document
mtt.sty:
	echo Copying mtt.sty to here
	cp $MTTPATH/trans/mtt.sty .
$1_$2.doc: $1_$2.tex
	makedoc "$mtt_switches" "$1" "$2" "$3" "$4" "$documenttype" "$ps"


#Create PostScript version of dia and fig files
ifeq ($REPTYPE,bg)
ifeq ("\$(wildcard $1_abg.dia)","$1_abg.dia")
$1_$2.$ps : $1_$2.dia
else
$1_$2.$ps : $1_$2.fig
endif
	echo Creating $1_$2.$ps
	bg2eps $1 $2 $ps $eps
endif

ifeq ($REPTYPE,lbg)
$1_$2.$ps : $1_$2.fig
	labg_fig2ps $1_$2
endif

ifeq ($REPTYPE,tex)
#Generic conversion of LaTeX doc to dvi or pdf
$1_$2.$ps: $1_$2.doc
	doc2$ps $1_$2 "$documenttype"
endif


ifeq ($REPTYPE,tex)
#Create html version of dvi file
$1_$2.html: $1_$2.doc
	echo Creating $1_$2/$1_$2.html
	$LATEX2HTML $1_$2.doc>latex2html.log 2>latex2html.log
endif

#Default view
ifeq ($REPTYPE,bg)
$1_$2.view : $Subsystem_$2.pview
endif

ifeq ($REPTYPE,data)
$1_$2.view: $1_$2.$ps
ifeq ($ARGS,) # single plot
	echo Creating view of $1_$2 - $ps file
	$psview $1_$2.$ps&
else
	echo Creating view of $1_$2$__ARGS - $ps file
	$psview $1_$2$__ARGS.$ps&
endif
endif

ifeq ($REPTYPE,tex)
$1_$2.view : $1_$2.pview
endif

ifeq ($REPTYPE,txt)
$1_$2.view : $1_$2.tview
endif

# Hypertext view
$1_$2.hview: $1_$2.html
	$HTMLVIEW $1_$2/$1_$2.html&

#View a ps file
$Subsystem_$2.pview: $1_$2.$ps
	echo Creating view of $Subsystem_$2 - $ps file
	mtt_multi $psview $Subsystem $2 $ps $viewlevel  | sh 

#View a gdat file
$1_$2.dview: $1_$2.gdat
	echo Creating view of $1_$2
	gdat2view $1_$2 '$ARGS'&

#View a tex file
$1_$2.tview: $1_$2.dvi
	echo Creating view of $1_$2
	$DVIVIEW $1_$2.dvi&

#Report generation
$1_rep.make: $1_rep.txt
	rep_txt2make $1 "$mtt_switches"

$1_reps_made:
	rep_txt2sh $1 "$mtt_switches";  touch $1_reps_made

$1_rep.tex: $1_rep.txt $1_reps_made
	rep_txt2tex $1 "$documenttype" "$directory" "$mtt_switches";

#SUMMARY abg Acausal bond graph report (tex)
$1_abg.tex: $1_sub.sh $1_labg.tex
	sh $1_sub.sh "mtt -q " " labg tex"
	abg2tex $pdf ${sensitivity_switch} $1

#SUMMARY tf Transfer function (mml)
$1_$2.mml: $1_$2.r
	mtt_r2mml $1 $2


# Version control system - uses RCS
RCS:
	echo Creating RCS
	mkdir RCS
$1_$2.vc: RCS 
	echo Version control on $1_$2.$VCext with message: $log_message
	ci -m"$log_message" -I $1_$2.$VCext </dev/tty  ; co -l $1_$2.$VCext 

EOF
# Remember the exit status of make
make_status=$?

# Tidy up.
# echo Removing log files and other garbage
  rm -f  *_unique_raw_list *_raw_list
  rm -f mtt_error.txt mtt_info.txt 
  rm -f  mtt_info.txt warning.txt
#  rm -f *_*.idx *_*.ind *_*.ilg  *_*.lof *_*.toc

# Remove logs if not debugging
if [ "$debug" != "debug" ]; then
  rm -f *.log
else
  echo Debugging - log files retained in LOGFILES  
  mkdir -p LOGFILES
  mv -f *.log LOGFILES 2> /dev/null
fi

#Print what's going on if in verbose mode
if [ -n "$Verbose" ]; then
    echo Finishing mtt  $mtt_switches  $1 $2 $3 $4 at level $level
fi

if [ "$make_status" != "0" ]; then
    echo Exiting MTT with error $make_status
    exit 1
fi

Deleted mttroot/mtt/bin/mtt_backup version [390999ad3b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Does a backup with date of selected files.


while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
    -d)
         format=date;
	 shift
	;;
    -v)
         format=version;
	 shift
	;;
    -h)
         echo "Usage: mtt_backup [-d|-v] [lib|doc]";
	 exit
	;;
    *)
         format=date;
esac
done

#Name of archive
if [ -z "$1" ]; then
    mtt="mtt"
    dirs='mtt mtt-lib mtt-cc mtt-doc'
else
    mtt="mtt-$1"
    dirs=$mtt
fi

## Create appropriate filename
case $format in
    date)
         filename=`date | gawk '{printf("%s_%s%s_%s.tgz\n", mtt, $2,$3,$6)}' mtt=$mtt`;
	 shift
	;;
    version)
         filename=`mtt --version | gawk '{printf("%s-%s.tar.gz\n", mtt, $NF)}' mtt=$mtt`;
	 shift
	;;

    *)

esac

echo Backup file $filename



#Check whether archive exists here
if [ -f "$filename" ]; then
    echo File $filename already exists - exiting
    exit    
fi

# Listing files to ignore
#echo Finding irrelevant files
#find $dirs -name '*.*' -print |\
#  grep 'dvi$\|ps$\|gif$\|log$\|dat$\|MTT_work\|core\|~$' >IGNORE
#wc IGNORE | gawk '{print "Ignoring", $1, "files"}'

#echo examples >> IGNORE

#Inform user
echo Backing up $dirs to $filename

#Tar the files
#tar --exclude-from IGNORE --create --gzip --file $filename $dir
tar --create --gzip --file $filename $dirs
#Size info
ls -l $filename
#

Deleted mttroot/mtt/bin/mtt_backups version [6f813c5536].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Does a backup with date of all mtt components
# $Log$
# Revision 1.2  2000/10/03 12:17:58  peterg
# Prints usage line
#

if [ -z "$1" ]; then
   echo "Usage: mtt_backups [-v|-d]"
   exit    
fi
mtt_backup $1
mtt_backup $1 cc
mtt_backup $1 lib
mtt_backup $1 doc

Deleted mttroot/mtt/bin/mtt_check_sese version [4337a95ac3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
## This script tests the sese generation by comparing the 
## dae files generated by the conventional approach
## Copyright (C) 2003 by Peter J. Gawthrop

sys=$1

## Correct dae file.
rm -vf ${sys}_ese.r MTT_work/${sys}_ese.r
mtt -q ${sys} dae r
mv -v ${sys}_dae.r ${sys}_dae.r_CORRECT

## sese file   
rm -vf ${sys}_sese.r MTT_work/${sys}_sese.r
mtt -q ${sys} sese r

## Create the dae file from the sese file 
cp -v ${sys}_sese.r ${sys}_ese.r
mtt -q ${sys} dae r

## And test
diff ${sys}_dae.r ${sys}_dae.r_CORRECT > mtt_diffs

## Result
if [ "$?" = "0" ]; then
    echo "****** dae files are the same ******"
else
    echo "****** dae files are different ******"
    cat mtt_diffs
fi

Deleted mttroot/mtt/bin/mtt_check_var version [afd404bde7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_check_var

# P.J.Gawthrop July 1997
# Copyright (c) P.J.Gawthrop 1997


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1997/12/04  10:41:15  peterg
# Added third argument to print env. variables.
#
## Revision 1.1  1997/07/27 13:11:37  peterg
## Initial revision
##
###############################################################

var=$1
name=$2
print=$3
software=$4

if [ -z "$1"  ]; then
 echo '*** MTT WARNING Environment variable' $name 'not set. *****'
 echo "Please check that software package $software has been correctely installed"
 echo
 exit
fi

if [ "$print" = "print" ]; then
 echo Environment variable $name set to $var
fi

Deleted mttroot/mtt/bin/mtt_check_vars version [aa8113cf2e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_check_vars

# P.J.Gawthrop July 1997
# Copyright (c) P.J.Gawthrop 1997


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8.2.1  2001/03/06 03:48:43  geraint
## Print additional environment variable for "mtt -p".
## MTT_LDFLAGS defaults to " " to avoid installation warning.
##
## Revision 1.8  2000/12/27 13:11:42  peterg
## *** empty log message ***
##
## Revision 1.7  2000/08/04 15:48:30  peterg
## Added PDF
##
## Revision 1.6  2000/05/22 12:37:24  peterg
## *** empty log message ***
##
## Revision 1.5  2000/05/22 12:34:07  peterg
## Added MTT_REP
##
## Revision 1.4  1998/07/30 17:30:41  peterg
## Added some more paths
##
## Revision 1.3  1998/01/23 13:33:47  peterg
## Removed OCTAVE_PATH
## Removed RMATRIX
##
# Revision 1.2  1997/12/04  10:41:49  peterg
# Added -p argument to print environment variables
#
## Revision 1.1  1997/07/27 13:12:03  peterg
## Initial revision
##
###############################################################

#Look for a command line argument
while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-p )
		print=print ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Octave
#mtt_check_var "$OCTAVE_PATH" "OCTAVE_PATH" "$print" "Octave"

# LaTeX
#mtt_check_var "$TEXFORMATS" "TEXFORMATS" "$print" "LaTeX"
#mtt_check_var "$TEXINPUTS" "TEXINPUTS" "$print" "LaTeX"
#mtt_check_var "$TEXFONTS" "TEXFONTS" "$print" "LaTeX"

# MTT variables
mtt_check_var "$MAKE" "MAKE" "$print" "MTT"
mtt_check_var "$MTTPATH" "MTTPATH" "$print" "MTT"
mtt_check_var "$MTT_CRS" "MTT_CRS" "$print" "MTT"
mtt_check_var "$MTT_COMPONENTS" "MTT_COMPONENTS" "$print" "MTT"
mtt_check_var "$MTT_EXAMPLES" "MTT_EXAMPLES" "$print" "MTT"
mtt_check_var "$MTT_LIB" "MTT_LIB" "$print" "MTT"
mtt_check_var "$MTT_REP" "MTT_REP" "$print" "MTT"
mtt_check_var "$MATRIX" "MATRIX" "$print" "MTT"
mtt_check_var "$SYMBOLIC" "SYMBOLIC" "$print" "MTT"
mtt_check_var "$FIG" "FIG" "$print" "MTT"
mtt_check_var "$PSVIEW" "PSVIEW" "$print" "MTT"
mtt_check_var "$PDFVIEW" "PDFVIEW" "$print" "MTT"
mtt_check_var "$HTMLVIEW" "HTMLVIEW" "$print" "MTT"
mtt_check_var "$DVIVIEW" "DVIVIEW" "$print" "MTT"
mtt_check_var "$CC" "CC" "$print" "MTT"
mtt_check_var "$LATEX2HTML" "LATEX2HTML" "$print" "MTT"
mtt_check_var "$MKOCTFILE" "MKOCTFILE" "$print" "MTT"
mtt_check_var "$MTT_CXX" "MTT_CXX" "$print" "MTT"
mtt_check_var "$MTT_CXXFLAGS" "MTT_CXXFLAGS" "$print" "MTT"
mtt_check_var "$MTT_CXXLIBS" "MTT_CXXLIBS" "$print" "MTT"
mtt_check_var "$MTT_CXXINCS" "MTT_CXXINCS" "$print" "MTT"
mtt_check_var "$MTT_LDFLAGS" "MTT_LDFLAGS" "$print" "MTT"


Deleted mttroot/mtt/bin/mtt_cvs2deb version [3cd53ec09b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190






























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

# Script to create a .deb package from the current cvs sources.

usage ()
{
    cat <<EOF

usage: $0 [options]

options:
	-dir /path/to/mttroot
		Build package from local directory /path/to/mttroot instead of sourceforge CVS.

        -email email@address
		email address of packager
	-keep
		Keep temporary directory after package creation

	-log changelog text
		Write changelog text to changelog file
		Note: this must be the last option given.

	-name name
		name of packager
	-version #.#
		Use version #.# instead of the date to label the .deb

EOF
}

error ()
{
    echo $0: error: ${1:-"unknown error"} - aborting.
    exit 1
}

# use -email and -name to change
DEBFULLNAME=${DEBFULLNAME:-"Geraint Paul Bevan"}
DEBEMAIL=${DEBEMAIL:-"geraint@users.sourceforge.net"}

# default switches
default_sources="sourceforge"
default_logtext="snapshot from ${default_sources}."
default_version=`date --iso-8601 | sed 's/\-/./g'`

sources=${default_sources}
logtext=${default_logtext}
version="5.0."${default_version}
keeptmp="remove"

# look for command line arguments
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-dir) # package directory instead of cvs sources
	    # should be the path to the mttroot directory
	    sources=$2
	    if [ ! "`basename ${sources}`" = "mttroot" ]; then
		error "directory ${sources} is not location of mttroot"
	    fi
	    if [ "${logtext}" = "${default_logtext}" ]; then
		logtext="snapshot from local sources (${sources})"
	    fi
	    echo "Using source directory: ${sources}"
	    shift ;;	
	-email) # email address of packager
	    DEBEMAIL=$2
	    echo "Using email address ${DEBEMAIL}"
	    shift ;;
	-h | -help | --help)
	    usage
	    exit 0 ;;	
	-keep) # keep temporary directory
	    echo "Keeping temporary files"
	    keeptmp="keep" ;;
	-log) # specify changelog text
	    shift
	    logtext="$*"
	    echo "Using changelog text: ${logtext}"
	    shift ;;
	-name) # name of packager
	    DEBFULLNAME=$2
	    echo "Using name ${DEBFULLNAME}"
	    shift ;;
	-version) # specify version
	    version=$2
	    echo "Using version number: ${version}"
	    shift ;;
	*)
	    usage
	    error "unknown option $1" ;;	    
    esac
    shift
done

topdir=`pwd`

## Main MTT
echo "Packaging mtt ..."

# create working directory
tmpdir=`mktemp -d mtt_cvs2deb.tmp.XXXXXXXXXX`
if [ ! -d ${tmpdir} ]; then
    error "cannot create temporary directory"
fi

# copy sources to working directory
cd ${tmpdir}
if [ "${sources}" = "${default_sources}" ]; then
    cvs -z3 -d:pserver:anonymous@mtt.cvs.sf.net:/cvsroot/mtt export -D now mttroot/mtt
else
    mkdir -p ./mttroot
    cp -a ${sources}/mtt ./mttroot/mtt
    for dir in $(find . -type d -name CVS); do
	rm -r $dir
    done
fi

# generate tarball of sources
cd mttroot
tar -cf mtt-${version}.tar mtt/
tar --file mtt-${version}.tar --delete mtt/lib/examples
gzip mtt-${version}.tar
cd mtt

# create .deb
echo "$0: information: a \"Could not find diffs\" error in the next few lines is probably harmless"
uupdate -u mtt-${version}.tar.gz
cd ../mtt-${version}/debian
dch -v ${version} ${logtext}
cd ..
dpkg-buildpackage -rfakeroot -k${DEBEMAIL} -m${DEBEMAIL}
cd ..

# clean up
cp mtt*.deb ${topdir}/
cd ${topdir}
if [ "${keeptmp}" = "remove" ]; then
    rm -r ${tmpdir}
else
    echo Keeping temporary directory: ${tmpdir}
fi


## Examples
echo "Packaging mtt-examples ..."

# create working directory
tmpdir=`mktemp -d mtt_cvs2deb.tmp.XXXXXXXXXX`
if [ ! -d ${tmpdir} ]; then
    error "cannot create temporary directory"
fi

# copy sources to working directory
cd ${tmpdir}
if [ "${sources}" = "${default_sources}" ]; then
    cvs -z3 -d:pserver:anonymous@mtt.cvs.sf.net:/cvsroot/mtt export -D now mttroot/mtt/lib/examples
else
    mkdir -p ./mttroot/mtt/lib/
    cp -a ${sources}/mtt/lib/examples ./mttroot/mtt/lib
    for dir in $(find . -type d -name CVS); do
	rm -r $dir
    done
fi

# generate tarball of sources
cd mttroot/mtt/lib
tar -cf mtt-examples-${version}.tar examples/
gzip mtt-examples-${version}.tar
cd examples

# create .deb
echo "$0: information: a \"Could not find diffs\" error in the next few lines is probably harmless"
uupdate -u mtt-examples-${version}.tar.gz
cd ../mtt-examples-${version}/debian
dch -v ${version} ${logtext}
cd ..
dpkg-buildpackage -rfakeroot -k${DEBEMAIL} -m${DEBEMAIL}
cd ..

# clean up
cp mtt-examples*.deb ${topdir}/
cd ${topdir}
if [ "${keeptmp}" = "remove" ]; then
    rm -r ${tmpdir}
else
    echo Keeping temporary directory: ${tmpdir}
fi

exit 0

Deleted mttroot/mtt/bin/mtt_deb2cd version [4cf587b080].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

# Script to create a CD-ready directory from .deb package
# output from script will be a directory which should be copied to / of CDROM
# user of CDROM should run "apt-cdrom add"

usage ()
{
    cat <<EOF

usage: $0 debfile

EOF
}

error ()
{
    echo $0: error: ${1:-"unknown error"} - aborting.
    exit 1
}

debfile="$1"

# should be root for some of these commands
if [ ! `whoami` = "root" ]; then
    export my_user=${USER}
    export my_group=`groups | gawk '{print $1}'`
    echo root password required
    exec su -p -c "$0 $*"
    error "root authorisation failed"
fi

if [ -z "${debfile}" ]; then
    usage
    error "No debfile given"
fi

topdir=`pwd`

# create working directory
tmpdir=`mktemp -d mtt_deb2cd.tmp.XXXXXXXXXX`
if [ ! -d ${tmpdir} ]; then
    error "cannot create temporary directory"
fi

cp ${debfile} ${tmpdir}/
cd ${tmpdir}
mkdir .disk
echo "MTT (${debfile}, `date`)" > .disk/info
tmpfile=`mktemp mtt_deb2cd.tmp.XXXXXXXXXX`
echo "Scanning .deb packages"
dpkg-scanpackages . ${tmpfile} | gzip > ./Packages.gz
rm ${tmpfile}
# create Redhat package
echo "Creating .rpm, please wait ..."
alien --to-rpm ${debfile}
chown -R ${my_user:-"root"}.${my_group:-"root"} .
cd ..

echo "Directory created (${tmpdir}) - copy this to iso9660 image as /"

exit 0

Deleted mttroot/mtt/bin/mtt_find version [a16165e9f1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124




























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_find
# mtt_find path name operation
# P.J.Gawthrop Nov 1996
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/10/03 18:29:57  peterg
## *** empty log message ***
##
## Revision 1.6  1998/07/17 19:47:35  peterg
## Minor changes
##
## Revision 1.5  1998/07/17 07:50:33  peterg
## Now handles library name
## Returns a status
##   0 if exactly one result
##   1 if no results
##   2 if two or more results
##   3 if utterly confused
##
## Revision 1.4  1998/07/16 20:40:24  peterg
## Cleaned up algorithms
##
## Revision 1.3  1998/07/16 09:15:34  peterg
## Now prints:
## 	dir
## 	name_lbl.txt
##         access time
##
## Revision 1.2  1997/09/04 09:15:19  peterg
## Includes summary line as well as description lines
##
## Revision 1.1  1996/11/10 10:48:45  peterg
## Initial revision
##
###############################################################

# Set up dummy file
rm -f mtt_junk
touch mtt_junk

# Interpret the arguments
path="$1"

if [ -n "$2" ]; then
    name=`basename $2`
    longname=$2
    Name="-name $name"
else
    name='*'
fi

# If this is non-empty just print the path
path_only=$3

# Find all dirs in path with same name as component
# AND the path contains the full (name+library) name
paths=`echo $path | tr ":" " "`
foundpath=`\
for thepath in $paths; do
    find $thepath -type d  $Name -print 
done |\
sort -u |\
grep "$longname"`

# If empty set foundpath to the simple components path
if [  -z "$foundpath"  ]; then
  foundpath="$MTT_LIB/comp/simple"
fi

# If non-null result, check that the name_ext file exists in dir name
# and print dirname and file name and last access time
if [ -n "$foundpath" ]; then
  if [ -n "$path_only" ]; then
    format='%h\n';
  else
    format='%h\t%f\t%Ac\n';
  fi
  for thepath in $foundpath ;  do
    if [ "$thepath" = "$MTT_COMPONENTS/simple" ]; then
        ext='cause.m'; # finds _cause.m
        simple='simple';
    else
        ext='lbl.txt'; # finds _lbl.txt
    fi    
     dirname=`basename $thepath`
     if [ -n "$simple" ]; then
      fullname="$name"_"$ext"
    else
      fullname="$dirname"_"$ext"
    fi
  find $thepath -maxdepth 1 -name $fullname  -printf $format;
 done |\
 tee mtt_junk
fi

# Check exit status and return 
hits=`wc mtt_junk | gawk '{print $1}'`
rm -f mtt_junk

if [ $hits = "1" ]; then
    exit 0
elif [ $hits = "0" ]; then
    exit 1
elif [ $hits > "1" ]; then
    exit 2
else
    exit 3
fi





Deleted mttroot/mtt/bin/mtt_help version [92a6751c3c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197





































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_help

# P.J.Gawthrop Nov 1996
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2000/10/03 18:29:26  peterg
## crs now works after a fashion
##
## Revision 1.13  2000/04/04 15:22:44  peterg
## Major changes: simple components now work
## Single components now work
##
## Revision 1.12  1998/07/21 08:47:59  peterg
## Default null $2 (regexp) to '^' - ie match any line
##
## Revision 1.11  1998/07/16 20:41:05  peterg
## Now uses new mtt_help
##
## Revision 1.10  1998/05/18 08:35:19  peterg
## Surround arguments to tr with ""
##
## Revision 1.9  1998/03/26 08:23:02  peterg
## Use mixed case Topic for *) part of case sttement
##
## Revision 1.8  1998/03/22 21:13:17  peterg
## Fixed bug in above
##
## Revision 1.7  1998/03/22 20:21:11  peterg
## $topic now converted to lower case.
##
## Revision 1.6  1997/09/04 09:35:04  peterg
## Changed $ext to give accurate match -- matches t ot m at end of
## filename
##
# Revision 1.5  1997/09/04  09:21:01  peterg
# Added context-dependent sort.
#
# Revision 1.4  1997/09/04  09:16:29  peterg
# Removed sort -u
#
## Revision 1.3  1996/11/09 21:10:20  peterg
## Tidied up searches by putting everyrhing into lib.
##
# Revision 1.2  1996/11/02  10:22:54  peterg
# Now browses crs.
#
## Revision 1.1  1996/11/01 12:34:54  peterg
## Initial revision
##
###############################################################

comment='#';
Topic=$1
topic=`echo $Topic | tr "[A-Z]" "[a-z]"`

if [ -n "$2" ]; then
    regexp=$2;
else
    regexp='^';
fi

if [ "$topic" = "" ]; then
    echo 'Usage: mtt help representations'
    echo '       mtt help simple'
    echo '       mtt help components'
    echo '       mtt help examples' 
    echo '       mtt help CRs'    
    echo '       mtt help representations <match_string>'
    echo '       mtt help components <match_string>'
    echo '       mtt help examples  <match_string>'
    echo '       mtt help CRs <match_string>'
    echo '       mtt help <component_or_example_or_CR_name>'
  exit
fi

ext='_[cl]*.*[mt]'
summary='[%#]SUMMARY'
description='[%#]DESCRIPTION'
alias='[%#]ALIAS'
lbl="_lbl.txt"

case $topic in
  components)
    key=$summary 
    find_path="$MTT_COMPONENTS"
    name=''
    sort='sort -u'
    blurb="components";;

  simple)
    key=$summary 
    find_path="$MTT_COMPONENTS/simple"
    name=''
    sort='sort -u'
    blurb="simple components";;

  crs) 
    key=$summary 
    find_path=$MTT_CRS/r
    name='*.cr'
    sort='sort -u'
    blurb="constitutive relationships";;

  examples) 
    key=$summary 
    find_path=$MTT_EXAMPLES
    name=''
    all='all'
    sort='sort -u'
    blurb="Examples";;

  representations)
    key=$summary 
    find_path=$MTTPATH
    name='mtt'
    all='all'
    sort='sort -u'
    blurb="Representations";;

  *)
    other=OTHER;
    key="$summary|$description|$alias" 
    find_path=$MTT_LIB
    name=$Topic
    all='all'
    sort='cat'
    blurb=$Topic;;     
esac

subtopic=$2
if [ "$subtopic" = "" ]; then
  subtopic='.'
fi;


case $topic in
    representations)
         echo $comment $blurb
         mtt2reps_txt

	;;
    crs)
	echo  $comment $blurb
        find $find_path -name "$name" -print |\
        gawk '{print "grep", key, $1}' key=$key | sh |\
        sed "s/$key //" | $sort
	;;
    *)
	
    fullnames=`mtt_find $find_path "$name" | gawk '{printf("%s/%s\n",$1,$2)}'`
    N=`echo $fullnames | wc -w`;
    if [ -z "$fullnames" ]; then
	echo $comment No $blurb found.
    else
    echo $comment $N $blurb found.
    for fullname in $fullnames; do
        name=`basename $fullname`
	if [ -n "$other" ]; then
	cat $fullname | egrep $key 
	else
        info=`cat $fullname | egrep $key | gawk '{for (i=2;i<=NF;i++) print $i}'`
	category=`echo $fullname |   sed "s!$find_path/!!" ` 
        category=`dirname $category`
	echo $category $name $info
	fi
    done
    fi
  esac
exit


  gawk '{print "cat " $1 "/" $2}'  | sh |\
  egrep $key  | egrep $regexp  |\
  sed "s/$summary[	]*//" |\
  sed "s/$description[	]*/  /" |\
  sed "s/$alias[	]*/  Alias: /" |\
  sed "s!$find_path/!!" |\
  $sort








Deleted mttroot/mtt/bin/mtt_pause version [9430af6a72].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#! /bin/sh

## mtt_pause: Just waits for an EOF
## P J Gawthrop April 2000
## Copyright (C) 2000 by Peter J. Gawthrop

echo $*

mtt $*
cat>/dev/null

Deleted mttroot/mtt/bin/mtt_rename version [f11f51dae2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_rename

# P.J.Gawthrop Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2002/04/22 08:05:26  gawthrop
## New regexp.
##
## Revision 1.5  2000/12/27 13:11:42  peterg
## *** empty log message ***
##
## Revision 1.4  1998/08/15 13:50:22  peterg
## Doesn't zap preexisting files
##
## Revision 1.3  1998/08/14 15:37:38  peterg
## rename now copies - no delete
##
## Revision 1.2  1998/01/06 13:57:39  peterg
## Now removes old version after copying
##
# Revision 1.1  1998/01/06  13:48:23  peterg
# Initial revision
#
###############################################################

old_name=$1
new_name=$2
extension=$3

left='[^a-zA-Z]'
right=$left
if [ -f "$new_name$extension" ]; then
   echo  "$new_name$extension already exists -- no action taken"
   exit
fi
if ls $old_name$extension > /dev/null 2>&1 
    then
	echo Renaming $old_name$extension to $new_name$extension
	sed \
         -e "s/\($left\)$old_name\($right\)/\1$new_name\2/g" \
         -e "s/^$old_name\($right\)/$new_name\1/g" \
        <$old_name$extension >$new_name$extension
fi



Deleted mttroot/mtt/bin/mtt_rename_all version [2428ae4c1a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_rename_all

# P.J.Gawthrop Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/03/17 11:50:18  peterg
## Added pic.fig -- schematic
##
## Revision 1.6  1998/07/22 15:20:06  peterg
## Added state.txt
##
## Revision 1.5  1998/04/13 09:15:36  peterg
## Added obspar
##
## Revision 1.4  1998/03/27 07:38:32  peterg
## simpar.r ---> simpar.txt
##
## Revision 1.3  1998/03/26 14:47:43  peterg
## Addes subs and cr
##
## Revision 1.2  1998/03/02 17:14:06  peterg
## Added simpar to list
##
## Revision 1.1  1998/01/06 13:57:59  peterg
## Initial revision
##
###############################################################

old_name=$1
new_name=$2

mtt_rename $old_name $new_name _abg.fig
mtt_rename $old_name $new_name _cr.r
mtt_rename $old_name $new_name _desc.tex
mtt_rename $old_name $new_name _input.txt
mtt_rename $old_name $new_name _lbl.txt
mtt_rename $old_name $new_name _logic.txt
mtt_rename $old_name $new_name _numpar.txt
mtt_rename $old_name $new_name _obspar.r
mtt_rename $old_name $new_name _odes.h
mtt_rename $old_name $new_name _rep.txt
mtt_rename $old_name $new_name _pic.fig
mtt_rename $old_name $new_name _simp.r
mtt_rename $old_name $new_name _simpar.txt
mtt_rename $old_name $new_name _sspar.r
mtt_rename $old_name $new_name _state.txt
mtt_rename $old_name $new_name _subs.r

Deleted mttroot/mtt/bin/mtt_version version [6c3f7fc85e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_version
# Prints out version of a GNU-style tool

# P.J.Gawthrop May 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1999/12/20 02:08:38  peterg
## Added second arg option
##
## Revision 1.2  1998/05/28 09:31:44  peterg
## Cosmetic changes
##
## Revision 1.1  1998/05/28 09:31:13  peterg
## Initial revision
##
###############################################################

if [ -z "$2" ]; then
    echo Trying $1 ...
    ver=`$1 --version | head -1`
     if [ -n "$ver" ]; then
        echo is OK and has version $ver.
    else
        echo Either $1 does not exist or is not the GNU version.
    fi
else
    echo $1: $2
fi








Deleted mttroot/mtt/bin/mtt_versions version [631ca6b658].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_versions

# P.J.Gawthrop May 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2005/02/17 22:15:35  geraint
## Added missing quotes to conditional expression.
##
## Revision 1.5  2005/02/17 18:36:38  geraint
## Removed a bash-ism: replaced [[ conditional ]] with [ conditional ]
##
## Revision 1.4  2003/08/06 22:39:40  geraint
## Fixed reporting of non-existent software, no longer says "is OK and has version .".
##
## Revision 1.3  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.2  2000/11/13 21:40:26  peterg
## Sorted out the non-gnu
##
## Revision 1.1  1998/05/28 09:24:41  peterg
## Initial revision
##
###############################################################

echo Versions of mtt and its components on `date`

## gnu standard --version
mtt_version mtt

echo Doing the GNU components
mtt_version gawk
mtt_version basename
mtt_version cat
mtt_version cp
mtt_version dirname
mtt_version gcc
mtt_version grep
mtt_version head
mtt_version make
mtt_version octave
mtt_version sed
mtt_version tail
mtt_version tr

## Non standards
echo Doing the non-GNU components

print_version ()
{
    program=${1:-"Error: unknown program"}
    shift;
    version=$*
    if [ "${version:-""}" ]; then
	echo is OK and has version $version.
    else
	echo $program does not exist.
    fi
}

echo Trying xfig ...
xfig -help 2> mtt_junk; version=`grep Xfig mtt_junk`
print_version xfig $version

echo Trying fig2dev ...
fig2dev -h > mtt_junk; version=`grep -i patchlevel mtt_junk`
print_version fig2dev $version

echo Trying reduce ...
reduce -w >mtt_junk 2>1 <<EOF
bye;
EOF
version=`grep  -i REDUCE mtt_junk`
print_version reduce $version


Deleted mttroot/mtt/bin/mtt_xargs.sh version [0e001e0d54].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
#! /bin/sh

cmd=$1
for arg in $2; do
	eval $cmd $arg
done

Deleted mttroot/mtt/bin/mttrc version [38af940af8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388




































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mttrc - sets up paths etc for mtt
# Usage: mttrc 

# Copyright (c) P.J.Gawthrop 1996,1977.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.45  2009/06/26 01:08:49  geraint
## Octave load path no longer accepts trailing // as recursive.
## Path is now calculated using find, which is much quicker than Octave's genpath()
##
## Revision 1.44  2006/04/25 23:24:29  geraint
## Reverted to simple g++ for MTT_CXX. Trying to force the version causes library problems.
##
## Revision 1.43  2006/02/09 23:49:40  geraint
## added rtxi build flags
##
## Revision 1.42  2005/11/16 00:43:15  geraint
## rtxi
##
## Revision 1.41  2004/02/17 17:53:34  geraint
## Fixed [ 898739 ] libhdf5 dependency breaks -cc reps.
## Now uses mkoctfile to determine include and library flags.
##
## Revision 1.40  2003/09/23 15:57:18  gawthrop
## And back to gv
##
## Revision 1.39  2003/09/22 17:38:56  gawthrop
## gv --> ghostview
##
## Revision 1.38  2003/07/13 21:53:24  geraint
## Updated to conform to latest Octave (tested with 2.1.49).
## - the pathsearch library was merged into liboctave last year
## - static_cast no longer seems to work between Matrix and ColumnVector
##
## Revision 1.37  2002/09/19 08:08:15  gawthrop
## Updated documentation documentation
##
## Revision 1.36  2002/08/28 15:48:00  geraint
## Updated mttrc to make standalone C++ compilation configuration clearer.
##
## Revision 1.35  2002/08/06 09:56:54  geraint
## Updated to work with changes in unstable version of Octave 2.1.36.
## Tested with 2.0.17 (ok) but will break earlier unstables (2.1.(<=35)).
##
## Revision 1.34  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.33  2002/05/08 11:39:36  gawthrop
## Added MTT_REP to PATH
##
## Revision 1.32  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.31  2002/05/02 20:12:45  geraint
## Added -Wl,--rpath to MTT_CXXLIBS. Sets the runtime linker path so that the
## sys-admin does not have to ldconfig the octave directory for -cc to work.
##
## Revision 1.30  2002/05/02 11:10:11  geraint
## s/loctave/loctinterp/
##
## Revision 1.29  2002/05/02 11:03:46  geraint
## Reinstated -liboctinterp and -lncurses; needed by xleftdiv.
##
## Revision 1.28  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.27  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.26  2002/04/26 16:16:33  geraint
## Removed unnecessary variables PLAT and GCCVERS.
##
## Revision 1.25  2002/04/02 09:16:39  geraint
## Tidied up library search paths, now assumes that system libraries are set up correctly.
## For Debian, this means installing the following: blas-dev, fftw-dev, lapack-dev, libncurses5-dev, libkpathsea-dev, libreadline-dev
## It may also be necessary to run /sbin/ldconfig on the relevant directories (especially Octave's).
##
## Revision 1.24  2001/10/15 14:28:35  gawthrop
## Now has . at start of components library path $MTT_COMPONENTS
##
## Revision 1.23  2001/07/24 22:32:49  gawthrop
## Use gv, not ghostview
##
## Revision 1.22  2001/04/12 03:08:00  geraint
## Improved sh->csh conversion, reduces environment namespace pollution.
## Still need to do proper if [ -z $MTT_BASE ] ... else ... fi conversion.
##
## Revision 1.21  2001/04/10 13:56:13  gawthrop
## Uses standard mkoctfile
##
## Revision 1.20  2001/04/10 13:08:19  gawthrop
## Smoother translation to .cs using sh2csh
##
## Revision 1.19  2001/03/30 15:13:49  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.18  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.17.2.4  2001/03/06 03:48:43  geraint
## Print additional environment variable for "mtt -p".
## MTT_LDFLAGS defaults to " " to avoid installation warning.
##
## Revision 1.17.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.17.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.17.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.17  2000/12/27 16:46:13  peterg
## Stripped the mtt- from paths
##
## Revision 1.16  2000/12/27 15:16:44  peterg
## If then else format
##
## Revision 1.15  2000/12/27 14:57:43  peterg
## Now takes the base path as an argument
##
## Revision 1.14  2000/12/27 13:11:43  peterg
## *** empty log message ***
##
## Revision 1.13  2000/10/03 12:12:14  peterg
## New path structure to account for three way split in mtt tree
##
## Revision 1.12  2000/09/18 12:17:07  peterg
## Now includes to control system toolbox in OCTAVE_PATH
## Don't use -path stuff - use :: instead.
##
## Revision 1.11  2000/05/21 17:55:15  peterg
## New rep path
##
## Revision 1.10  2000/05/16 11:41:23  peterg
## *** empty log message ***
##
## Revision 1.9  1999/03/11 04:02:19  peterg
## Revised so that sh2csh does its stuff.
##
## Revision 1.8  1998/07/17 19:48:46  peterg
## *** empty log message ***
##
## Revision 1.7  1998/03/24 09:11:49  peterg
## Compatible with .csh version
##
## Revision 1.6  1998/03/13 11:53:29  peterg
## reduce --> reduce 64
##
## Revision 1.5  1998/01/16 08:55:01  peterg
## MAKE=make
##
## Revision 1.4  1998/01/06 09:14:51  peterg
## Added latex2html to setup
##
# Revision 1.3  1998/01/06  09:11:26  peterg
# Removed matlab from the setup
#
# Revision 1.2  1997/12/04  10:49:16  peterg
# Put under RCS at last
# Added CC variable
#
###############################################################

## When using csh, replace $1 by the mtt base path, eg /usr/share/mtt/latest
export MTT_BASE=$1

if [ -z "$MTT_BASE" ]; then
  echo mttrc requires one argument: eg mttrc /usr/share/mtt/latest
else
  echo Setting paths with base $MTT_BASE
  # The following line sets up the make to use -- gmake is the standard 
  # but you may wish to use lsmake for parallelism
  export MAKE='make'
  
  # The following sets up the c compiler
  export CC='gcc'
  
  # Setup the paths
  export MTTPATH=$MTT_BASE/bin
  export MTT_LIB=$MTT_BASE/lib
  export MTT_DOC=$MTT_BASE/doc
  export MTT_CC=$MTT_BASE/cc
  
  export MTT_COMPONENTS=.:$MTT_LIB/comp
  export MTT_CRS=$MTT_LIB/cr
  export MTT_EXAMPLES=$MTT_LIB/examples
  export MTT_REP=$MTT_LIB/rep
  
  export PATH=$PATH\:$MTTPATH\:$MTTPATH/trans\:$MTT_CC\:$MTT_REP
  
  #Setup octave
##<<<<<<< mttrc
##  export MATRIX_PATH=$MTTPATH/trans/m/
##  export MATRIX_PATH=$MATRIX_PATH\:$MTT_LIB/comp/simple/
##  export MATRIX_PATH=$MATRIX_PATH\:$MTT_LIB/control/
##  export MATRIX_PATH=$MATRIX_PATH\:$MTT_LIB/octave/\:\:
  
##=======
  MATRIX="octave"
  #MATRIX_PATH1=$(echo "genpath('$MTTPATH/trans/m')"     |$MATRIX -q | awk '{print $3}') 
  #MATRIX_PATH2=$(echo "genpath('$MTT_LIB/comp/simple')" |$MATRIX -q | awk '{print $3}') 
  #MATRIX_PATH3=$(echo "genpath('$MTT_LIB/control')"     |$MATRIX -q | awk '{print $3}') 
  #MATRIX_PATH4=$(echo "genpath('$MTT_LIB/octave')"      |$MATRIX -q | awk '{print $3}') 
  #export MATRIX_PATH=$MATRIX_PATH1:$MATRIX_PATH2:$MATRIX_PATH3:$MATRIX_PATH4
  MATRIX_PATH1=$(find $MTTPATH/trans/m     -type d|grep -v CVS|awk '{printf ":%s", $0}')
  MATRIX_PATH2=$(find $MTT_LIB/comp/simple -type d|grep -v CVS|awk '{printf ":%s", $0}')
  MATRIX_PATH3=$(find $MTT_LIB/control     -type d|grep -v CVS|awk '{printf ":%s", $0}')
  MATRIX_PATH4=$(find $MTT_LIB/octave      -type d|grep -v CVS|awk '{printf ":%s", $0}')
  export MATRIX_PATH=$MATRIX_PATH1:$MATRIX_PATH2:$MATRIX_PATH3:$MATRIX_PATH4
##>>>>>>> 1.45
  export OCTAVE_PATH=.\:$MATRIX_PATH
##<<<<<<< mttrc
  export MATRIX="octave --path $OCTAVE_PATH"
##=======
##  export MATRIX="$MATRIX --path $OCTAVE_PATH"
##>>>>>>> 1.45
  
  # Setup the symbolic stuff
  ##export SYMBOLIC='reduce 64'
  export SYMBOLIC='reduce -w'
  
  
  # Setup xfig
  export FIG="xfig  \
  	-startfontsize 20 \
  	-metric \
  	-portrait \
  	-startgridmode 2 \
  	-pheight 21 \
  	-pwidth 30 \
  	-library_dir $MTT_LIB/xfig/\
  	"
  
  # Setup ps viewer
  export PSVIEW='evince'
  
  # Setup pdf viewer
  export PDFVIEW='acroread'
  
  # Setup html viewer
  export HTMLVIEW='firefox'
  
  # Setup dvi viewer
  export DVIVIEW='xdvi'
  
  # Setup latex2html
  export LATEX2HTML="latex2html -contents_in_navigation -index_in_navigation -address http://mtt.sourceforge.net"
  
  # Ascend stuff
  export ASCENDLIBRARY=$MTTPATH/ascend/lib
  
  # Oct file generation - use version with no optimisation.
  #export MKOCTFILE=$MTT_LIB/octave/mkoctfile # This for no optimisation
  export MKOCTFILE=mkoctfile

  #########################################################################################
  ##
  ## Configure environment for standalone compilation of files linked with Octave libraries
  ## (required for ode2odes.exe only)
  
  # location of Octave directories on local system (usually /usr, /usr/local or /opt)
      
  OCTAVEPREFIX="/usr"
  
  # include paths for Octave
  
  IOCTAVE="-I${OCTAVEPREFIX}/include/octave/ -I${OCTAVEPREFIX}/include/octave/octave"
      
  # include and library paths for Octave
      
  if [ -z `which ${MKOCTFILE}` ]; then
      # Octave development stuff not installed
      # C++ and .oct representations will not work
      OCTAVE_INC_FLAGS=" "
      OCTAVE_LIB_FLAGS=" "
  else
      OCTAVE_INC_FLAGS="`${MKOCTFILE} --print INCFLAGS`"
      OCTAVE_LIB_FLAGS="\
        `${MKOCTFILE} --print LFLAGS`              \
        `${MKOCTFILE} --print LIBOCTAVE`           \
        `${MKOCTFILE} --print LIBCRUFT`            \
        `${MKOCTFILE} --print LIBOCTINTERP`        \
        `${MKOCTFILE} --print BLAS_LIBS`           \
        `${MKOCTFILE} --print FFTW_LIBS`           \
        `${MKOCTFILE} --print LIBS`                \
        `${MKOCTFILE} --print FLIBS`               \
        `${MKOCTFILE} --print RLD_FLAG`"
  fi
      
  # C++ compiler options
      
  DEBUG="-g"
  OPTIM="-O3"
  FLAGS="-fno-rtti -fno-exceptions -fno-implicit-templates"
  
  # exported variables
      
  export MTT_CXX="g++"
  export MTT_CXXFLAGS="${DEBUG} ${OPTIM} ${FLAGS}"
  export MTT_CXXLIBS="${OCTAVE_LIB_FLAGS}"
  export MTT_CXXINCS="-I. -I${MTT_LIB}/cc ${OCTAVE_INC_FLAGS}"
  export MTT_LDFLAGS=" "
  
  ## End of Octave environment configuration
  ##
  #########################################################################################

  ############################################################  
  ##
  ## Configure environment for compilation of Matlab mex files
    
    MATLAB_ARCH="glnx86"
    MATLAB_ROOT="/usr/local/matlab6p1"
    MATLAB_FLAGS="-shared -fPIC -ansi -D_GNU_SOURCE -pthread"
    MATLAB_INCS="-I${MATLAB_ROOT}/extern/include"
    MATLAB_LIBS="-Wl,--rpath-link,${MATLAB_ROOT}/extern/lib/${MATLAB_ARCH},--rpath-link,${MATLAB_ROOT}/bin/${MATLAB_ARCH} -L${MATLAB_ROOT}/bin/${MATLAB_ARCH} -lmx -lmex -lm"

    # exported variables

    export MTT_MATLAB_FLAGS="${MATLAB_FLAGS} ${MATLAB_INCS} ${MATLAB_LIBS}"

  ## End of Matlab environment configuration
  ##
  #############################################################

  #######################################################
  ##
  ## Configure environment for compilation of RTXI module

##<<<<<<< mttrc
 ## RTXI_INCS="-I/usr/local/src/mtt/rtxi/rtxi_cvs_30Sep05/include -I/usr/include/qt3 -I/home/peterg/Development/rtxi/include"
#  MORE_RTXI_INCS="-I/usr/realtime/include -I/usr/src/linux/include"
##=======
  ROOT="/usr/local/rtxi-knoppix"

  RTXI_LIBTOOL="${ROOT}/usr/local/lib/rtxi/libtool"
  RTXI_CXX="g++-3.3"
  RTXI_CXXLD="g++-3.3"
  RTXI_CXXCOMPILE="${RTXI_LIBTOOL} --mode=compile --tag CXX ${RTXI_CXX}"
  RTXI_CXXLINK="${RTXI_LIBTOOL} --mode=link --tag CXX ${RTXI_CXXLD}"

  RTXI_INCS=""
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/share/qt3/include"
  RTXI_INCS="${RTXI_INCS} -I."
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/realtime/include"
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/share/qt3/include"
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/src/comedi/include"
  RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/src/rtxi/include"

  RTXI_DEFS="-D_REENTRANT -DQT_THREAD_SUPPORT"
  RTXI_CXXFLAGS="-g -O2 ${RTXI_INCS} ${RTXI_DEFS}"
  RTXI_LIBS="-L${ROOT}/usr/share/qt3/lib -lqt-mt"
##>>>>>>> 1.45
  RTXI_FLAGS="-DHAVE_CONFIG_H -D_REENTRANT -DQT_THREAD_SUPPORT"
  RTXI_LDFLAGS="-L${ROOT}/usr/realtime/lib -lpthread -module -avoid-version"
  RTXI_RPATH="${ROOT}/usr/local/lib/rtxi/models/"

  export MTT_RTXI_CXXCOMPILE="${RTXI_CXXCOMPILE}"
  export MTT_RTXI_CXXLINK="${RTXI_CXXLINK}"
  export MTT_RTXI_LIBTOOL="${RTXI_LIBTOOL}"
  export MTT_RTXI_CXXFLAGS="${RTXI_CXXFLAGS}"
  export MTT_RTXI_LIBS="${RTXI_LIBS}"
  export MTT_RTXI_FLAGS="${RTXI_RTXI_FLAGS}"
  export MTT_RTXI_LDFLAGS="${RTXI_LDFLAGS}"
  export MTT_RTXI_RPATH="${RTXI_RPATH}"

  ## End of RTXI environment configuration
  ##
  #############################################################

fi

Deleted mttroot/mtt/bin/mttrc.csh version [7afd308e13].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275



















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/csh
## Automatically generated from bashrc on Wed Aug 28 15:17:42 BST 2002 - DO NOT EDIT
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mttrc - sets up paths etc for mtt
# Usage: mttrc 

# Copyright (c) P.J.Gawthrop 1996,1977.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.35  2002/08/06 09:56:54  geraint
## Updated to work with changes in unstable version of Octave 2.1.36.
## Tested with 2.0.17 (ok) but will break earlier unstables (2.1.(<=35)).
##
## Revision 1.34  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.33  2002/05/08 11:39:36  gawthrop
## Added MTT_REP to PATH
##
## Revision 1.32  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.31  2002/05/02 20:12:45  geraint
## Added -Wl,--rpath to MTT_CXXLIBS. Sets the runtime linker path so that the
## sys-admin does not have to ldconfig the octave directory for -cc to work.
##
## Revision 1.30  2002/05/02 11:10:11  geraint
## s/loctave/loctinterp/
##
## Revision 1.29  2002/05/02 11:03:46  geraint
## Reinstated -liboctinterp and -lncurses; needed by xleftdiv.
##
## Revision 1.28  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.27  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.26  2002/04/26 16:16:33  geraint
## Removed unnecessary variables PLAT and GCCVERS.
##
## Revision 1.25  2002/04/02 09:16:39  geraint
## Tidied up library search paths, now assumes that system libraries are set up correctly.
## For Debian, this means installing the following: blas-dev, fftw-dev, lapack-dev, libncurses5-dev, libkpathsea-dev, libreadline-dev
## It may also be necessary to run /sbin/ldconfig on the relevant directories (especially Octave's).
##
## Revision 1.24  2001/10/15 14:28:35  gawthrop
## Now has . at start of components library path $MTT_COMPONENTS
##
## Revision 1.23  2001/07/24 22:32:49  gawthrop
## Use gv, not ghostview
##
## Revision 1.22  2001/04/12 03:08:00  geraint
## Improved sh->csh conversion, reduces environment namespace pollution.
##
## Revision 1.21  2001/04/10 13:56:13  gawthrop
## Uses standard mkoctfile
##
## Revision 1.20  2001/04/10 13:08:19  gawthrop
## Smoother translation to .cs using sh2csh
##
## Revision 1.19  2001/03/30 15:13:49  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.18  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.17.2.4  2001/03/06 03:48:43  geraint
## Print additional environment variable for "mtt -p".
## MTT_LDFLAGS defaults to " " to avoid installation warning.
##
## Revision 1.17.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.17.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.17.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.17  2000/12/27 16:46:13  peterg
## Stripped the mtt- from paths
##
## Revision 1.16  2000/12/27 15:16:44  peterg
##
## Revision 1.15  2000/12/27 14:57:43  peterg
## Now takes the base path as an argument
##
## Revision 1.14  2000/12/27 13:11:43  peterg
## *** empty log message ***
##
## Revision 1.13  2000/10/03 12:12:14  peterg
## New path structure to account for three way split in mtt tree
##
## Revision 1.12  2000/09/18 12:17:07  peterg
## Now includes to control system toolbox in OCTAVE_PATH
## Don't use -path stuff - use :: instead.
##
## Revision 1.11  2000/05/21 17:55:15  peterg
## New rep path
##
## Revision 1.10  2000/05/16 11:41:23  peterg
## *** empty log message ***
##
## Revision 1.9  1999/03/11 04:02:19  peterg
## Revised so that sh2csh does its stuff.
##
## Revision 1.8  1998/07/17 19:48:46  peterg
## *** empty log message ***
##
## Revision 1.7  1998/03/24 09:11:49  peterg
## Compatible with .csh version
##
## Revision 1.6  1998/03/13 11:53:29  peterg
## reduce --> reduce 64
##
## Revision 1.5  1998/01/16 08:55:01  peterg
## MAKE=make
##
## Revision 1.4  1998/01/06 09:14:51  peterg
## Added latex2html to setup
##
# Revision 1.3  1998/01/06  09:11:26  peterg
# Removed matlab from the setup
#
# Revision 1.2  1997/12/04  10:49:16  peterg
# Put under RCS at last
# Added CC variable
#
###############################################################

## When using csh, replace /usr/local/mtt/mttroot/mtt by the mtt base path, eg /usr/share/mtt/latest
setenv MTT_BASE /usr/local/mtt/mttroot/mtt

  echo Setting paths with base $MTT_BASE
  # The following line sets up the make to use -- gmake is the standard 
  # but you may wish to use lsmake for parallelism
  setenv MAKE 'make'
  
  # The following sets up the c compiler
  setenv CC 'gcc'
  
  # Setup the paths
  setenv MTTPATH $MTT_BASE/bin
  setenv MTT_LIB $MTT_BASE/lib
  setenv MTT_DOC $MTT_BASE/doc
  setenv MTT_CC $MTT_BASE/cc
  
  setenv MTT_COMPONENTS .:$MTT_LIB/comp
  setenv MTT_CRS $MTT_LIB/cr
  setenv MTT_EXAMPLES $MTT_LIB/examples
  setenv MTT_REP $MTT_LIB/rep
  
  setenv PATH $PATH\:$MTTPATH\:$MTTPATH/trans\:$MTT_CC\:$MTT_REP
  
  #Setup octave
  setenv MATRIX_PATH $MTTPATH/trans/m//
  setenv MATRIX_PATH $MATRIX_PATH\:$MTT_LIB/comp/simple//
  setenv MATRIX_PATH $MATRIX_PATH\:$MTT_LIB/control//
  setenv MATRIX_PATH $MATRIX_PATH\:$MTT_LIB/octave//\:\:
  
  setenv OCTAVE_PATH .\:$MATRIX_PATH
  setenv MATRIX "octave"
  
  # Setup the symbolic stuff
  setenv SYMBOLIC 'reduce 64'
  
  
  # Setup xfig
  setenv FIG "xfig  \
  	-startfontsize 20 \
  	-metric \
  	-portrait \
  	-startgridmode 2 \
  	-pheight 21 \
  	-pwidth 30 \
  	-library_dir $MTT_LIB/xfig/\
  	"
  
  # Setup ps viewer
  setenv PSVIEW 'gv'
  
  # Setup pdf viewer
  setenv PDFVIEW 'acroread'
  
  # Setup html viewer
  setenv HTMLVIEW 'netscape'
  
  # Setup dvi viewer
  setenv DVIVIEW 'xdvi'
  
  # Setup latex2html
  setenv LATEX2HTML "latex2html -contents_in_navigation -index_in_navigation -address http://mtt.sourceforge.net"
  
  # Ascend stuff
  setenv ASCENDLIBRARY $MTTPATH/ascend/lib
  
  # Oct file generation - use version with no optimisation.
  #setenv MKOCTFILE $MTT_LIB/octave/mkoctfile # This for no optimisation
  setenv MKOCTFILE mkoctfile

  #########################################################################################
  ##
  ## Configure environment for standalone compilation of files linked with Octave libraries
  ## (required for ode2odes.exe only)

    # location of Octave directories on local system (usually /usr, /usr/local or /opt)

set OCTAVEPREFIX="/usr"

    # include paths for Octave

set IOCTAVE="-I${OCTAVEPREFIX}/include/octave/ -I${OCTAVEPREFIX}/include/octave/octave"

    # library paths for Octave

set OCTAVEVERS=`octave --version | head -1 | gawk '{ print $4 }'`
set OCTAVEMINOR=`echo ${OCTAVEVERS} | gawk -F\. '{print $2}'`
    if [ "${OCTAVEMINOR}" = "0" ] ; then # stable
	LOCTAVE="-L${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS} -loctave -lcruft -loctinterp -Wl,--rpath,${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS}"
	LOCTAVE="-L${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS} -loctave -lcruft -loctinterp -Wl,--rpath,${OCTAVEPREFIX}/lib/octave-${OCTAVEVERS} -loct-pathsearch -loct-readline"
    fi
set LSYSTEM="-ldl -lm -lncurses -lkpathsea -lreadline -lblas -llapack -lfftw -lg2c"
    
    # C++ compiler options

set DEBUG="-g"
set OPTIM="-O3"
set FLAGS="-fno-rtti -fno-exceptions -fno-implicit-templates"

    # exported variables

    setenv MTT_CXX "g++"
    setenv MTT_CXXFLAGS "${DEBUG} ${OPTIM} ${FLAGS}"
    setenv MTT_CXXLIBS "${LOCTAVE} ${LSYSTEM}"
    setenv MTT_CXXINCS "-I. -I${MTT_LIB}/cc ${IOCTAVE}"
    setenv MTT_LDFLAGS " "

  ## End of Octave environment configuration
  ##
  #########################################################################################

  ############################################################  
  ##
  ## Configure environment for compilation of Matlab mex files
    
set MATLAB_ARCH="glnx86"
set MATLAB_ROOT="/usr/local/matlab6p1"
set MATLAB_FLAGS="-shared -fPIC -ansi -D_GNU_SOURCE -pthread"
set MATLAB_INCS="-I${MATLAB_ROOT}/extern/include"
set MATLAB_LIBS="-Wl,--rpath-link,${MATLAB_ROOT}/extern/lib/${MATLAB_ARCH},--rpath-link,${MATLAB_ROOT}/bin/${MATLAB_ARCH} -L${MATLAB_ROOT}/bin/${MATLAB_ARCH} -lmx -lmex -lm"

    # exported variables

    setenv MTT_MATLAB_FLAGS "${MATLAB_FLAGS} ${MATLAB_INCS} ${MATLAB_LIBS}"

  ## End of Matlab environment configuration
  ##
  #############################################################

Deleted mttroot/mtt/bin/sh2csh version [4b9c1fb401].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2001/04/12 03:08:00  geraint
## Improved sh->csh conversion, reduces environment namespace pollution.
## Still need to do proper if [ -z $MTT_BASE ] ... else ... fi conversion.
##
## Revision 1.2  1999/03/11 04:12:26  peterg
## Put in heading.
##
## Revision 1.1  1999/03/11 04:02:45  peterg
## Initial revision
##
###############################################################

#Converts mttrc to csh form.

date=`date`
wd=`pwd`
base=`dirname $wd`

echo Converting $1 to $1.csh using $base as default 

cat<<EOF >$1.csh
#!/bin/csh
## Automatically generated from bashrc on $date - DO NOT EDIT
EOF

# grep -v lines need to be replaced with proper if...then conversion
cat $1 |\
 sed 's/export[ \t]*\([A-Za-z0-9_]*\)=/setenv\ \1\ /' |\
 sed 's/^\([\ \t]*\)\([A-Za-z0-9_]*\)=/set\ \2=/' |\
 grep -v "if \[ -z " |\
 grep -v "echo mttrc requires one argument: eg mttrc /usr/share/mtt/latest" |\
 grep -v "else" |\
 grep -v -e "^fi" |\
 sed "s%\$1%$base%" \
>>$1.csh


echo done.


Deleted mttroot/mtt/bin/trans/ICD_txt2lang.sh version [9756a243af].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

sys=$1
lang=$2

ICD=${sys}_ICD.${lang}
txt=${sys}_ICD.txt
struc=${sys}_struc.txt

case ${lang} in
    c)	lb='['; rb=']'; offset=0; comment='//';;
    cc)	lb='('; rb=')'; offset=1; comment='//';;
    m)	lb='('; rb=')'; offset=0; comment='#';;
    *)	echo Language ${lang} not yet supported.; exit -1;;
esac

echo Creating ${ICD}

cat <<EOF > ${ICD}
${comment} Interface Control Definition mappings for system ${sys}
${comment} ${ICD}: Generated by MTT `date`

EOF

# ICD.txt Format:
# Input|Output ICD_Name PortName Causality: causality Units: units
# $1           $2       $3       $4         $5        $6     $7

cat <<EOF >> ${ICD}

${comment} Inputs

EOF
for name in `cat ${txt} | gawk '($1 == "Input:") { print $3 }'`
do
    num=`grep ${name} ${struc} | gawk '($1 == "input") { print $2 }'`
    grep ^Input ${txt} |\
	gawk '($3 == name) { printf ("\tmttu%c%d%c\t= %s;\n", lb, num-offset, rb, $2) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done

cat <<EOF >> ${ICD}

${comment} Outputs

EOF
for name in `cat ${txt} | gawk '($1 == "Output:") { print $3 }'`
do
    num=`grep ${name} ${struc} | gawk '($1 == "output") { print $2 }'`
    grep ^Output ${txt} |\
	gawk '($3 == name) { printf ("\t%-30s = mtty%c%d%c;\n", $2, lb, num-offset, rb) }'\
	lb=${lb} rb=${rb} name=${name} num=${num} offset=${offset} >> ${ICD}
done

Deleted mttroot/mtt/bin/trans/abg2cbg_m version [aeca6fdc92].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2cbg_m
#
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  2001/07/28 21:09:22  geraint
## Eliminated duplicate lines in type.sh.
##
## Revision 1.16  2001/07/26 04:07:28  gawthrop
## Changed a to w on open (Geraint's suggestion)
## Explictly close files
##
## Revision 1.15  2001/07/23 23:24:02  gawthrop
## Now only writes to type.sh and cbg.m when causality is complete
##
## Revision 1.14  2000/12/28 12:16:13  peterg
## *** empty log message ***
##
## Revision 1.13  1998/07/27 20:30:12  peterg
## *** empty log message ***
##
## Revision 1.12  1998/07/10 08:43:46  peterg
## Added -I switch
##
## Revision 1.11  1998/01/23 13:29:54  peterg
## $RMATRIX --> $MATRIX
##
# Revision 1.10  1996/12/04  21:51:02  peterg
# Now uses filenum instead of line name.
# Uses fopen
#
# Revision 1.9  1996/11/06  15:49:33  peterg
# Cahged $MATRIX to $RMATRIX
#
# Revision 1.8  1996/08/25  09:31:49  peter
# More error handling.
#
## Revision 1.7  1996/08/25 09:22:55  peter
## # Print errors, if any.
## mtt_error error.txt
##
## Revision 1.6  1996/08/24 14:36:01  peter
## Error handling included.
##
## Revision 1.5  1996/08/19 15:38:31  peter
## Removed bug work round.
##
## Revision 1.4  1996/08/16 14:28:45  peter
## Some debugging lines removed.
##
## Revision 1.3  1996/08/08 18:06:55  peter
## Unified naming scheme.
##
## Revision 1.2  1996/08/05 11:25:00  peter
## Removed bonds argument from abg2cbg.
## Removed call to $1_abg.
##
## Revision 1.1  1996/08/04 17:45:11  peter
## Initial revision
##
###############################################################

# The causal BG is described by four matrices
# (the same structure as the acausal BG except that Causality is 1 ot -1):
#   junctions: describes the junctions -
#     Column 1   Index of component (see components)
#     Column 2.. Indices of bonds on junction (see jbonds)
#                  rows may be padded with zeros
#
#    cjbonds:    describes the true bonds -
#     Column 1     Index of component (see components)
#     Column 2     Direction
#                    1 away from junction
#                   -1 towards junction
#     Column 3    Effort causality 
#                     1 stroke at arrow end
#                    -1 stroke at other end
#                     0 no stroke (ie acausal)
#     Column 4    Flow causality 
#                     1 stroke at arrow end
#                    -1 stroke at other end
#                     0 no stroke (ie acausal)
#     Columns 5:6  x,y coordinates of non-arrow end (in Fig)
#     Columns 7:8  x,y coordinates of arrow end (in Fig)
#
#   mbonds:    describes the modulation bonds -
#     Column 1     Index of component at non-arrow end
#     Column 2     Index of component at arrow end
#     Columns 4:5  x,y coordinates of non-arrow end (in Fig)
#     Columns 6:7  x,y coordinates of arrow end (in Fig)
#
#   components: describes the comonents -
#     Column 1     Type of component
#                    0  0-junction
#                    1  1-junction
#                    2  R component
#                    3  C component
#                    4  I component
#                    11 TF component
#                    12 GY component
#                    13 A  component
#     Column 2     Flag for explicit junction
#                    4  Explicit component (4 means text type)
#                    0  Implicit component
#     Column 3-14    fig file information (see fig documentation)
#
# Lists of under- and over-causal junctions are displayed.
#
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.


# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.

derivative=0;blurb=integral
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-derivative )
                derivative=1; blurb=derivative;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

infofile='mtt_info.txt'
errorfile='mtt_error.txt'
typefile="$1_type.sh"

# Remove the old log file
rm -f abg2cbg_m.log
rm -f $1_cbg.m
rm -f $typefile
rm -f $infofile


#Inform user
echo "Creating $1_cbg.m (maximise $blurb causality)"
echo Creating $1_type.sh

## Start the type.sh file
mtt_header $1 type sh > $typefile

# Use matrix manipulation to accomplish the transformation
$MATRIX << EOF  >abg2cbg_m.log  #2>mtt_error.txt

  infofilenum  = fopen("$infofile",'wt');
  errorfilenum = fopen("$errorfile",'wt');
  typefilenum  = fopen("$typefile",'wt');

  %Convert from acausal to causal bond graph in m-file form.
  system_name='$1';

  port_bonds = [];
  port_direction = [];
  port_status = [];
  [cbonds,status] = abg2cbg(system_name, '', '', port_bonds, port_direction, port_status, ...
      $derivative,typefilenum, infofilenum, errorfilenum);

    ## close the files
    fclose(infofilenum);
    fclose(errorfilenum);
    fclose(typefilenum);

EOF

cat $typefile | sort -u > ${typefile}.tmp
mv ${typefile}.tmp $typefile

if [ "$info" = "info" ]; then
  cat $infofile
fi

# cp $1_$1_cbg.m $1_cbg.m 2>> mtt_error.txt 

# Print errors, if any.
mtt_error mtt_error.txt

Deleted mttroot/mtt/bin/trans/abg2cmp_dia2txt version [1bb3659b08].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

### abg2cmp_dia2txt
## Creates list of components contained in _abg.dia
## Copyright (C) 2002 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

mtt_uncompress.sh $1_abg.dia
dia2abg.pl --create_component_list --diagram_name=$1

Deleted mttroot/mtt/bin/trans/abg2cmp_fig2txt version [ef01106a85].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

### abg2cmp_fig2txt
##  Creates list of components contained in _abg.fig
## Copyright (C) 2002 by Peter J. Gawthrop

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Log$
  ## Revision 1.3  2002/12/06 22:12:28  geraint
  ## Removed unique option from sort
  ## - prevents multiple anonymous components from existing
  ## - duplicate named components are caught by rbg_fig2m.awk anyway
  ##
  ## Revision 1.2  2002/12/06 11:47:49  gawthrop
  ## Checks levels in fig file to extract genuine components
  ## Puts comments at top of cmp.txt file
  ##
  ## Revision 1.1  2002/12/01 14:54:39  gawthrop
  ## Replaces defunct abg2lbl_fig2txt
  ##
  ##
  ###############################################################

system=$1
infile=${system}_abg.fig
outfile=${system}_cmp.txt
date=`date`

echo Creating ${outfile}

header() {
    cat <<EOF
## List of components contained in system ${system}
## File ${outfile}
## Created by mtt on ${date}

EOF
}
get_valid_components()

{
gawk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;
  length_terminator=4;

}
{
  object = $1;
  zero_depth =  (modulo10($4)==0)&&(object==text);
  if (zero_depth) {
    print substr($NF,1,length($NF)-length_terminator)
  }
}' 

}

remove_port_labels() {
  grep -v '^\[.*\]$'
}

## Create header
header > ${outfile}

## Make list of components
get_valid_components < ${infile} |\
   remove_port_labels |\
   sort >> ${outfile}

Deleted mttroot/mtt/bin/trans/abg2connections_m2dat version [123924ba9b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

### abg2connections_m2dat
## Creates connections.dat from abg.m
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

sys=$1

file=${sys}_connections.dat

${MATRIX} <<EOF  >abg2connections_m.log

abg = ${sys}_abg;

${sys}_connections = abg2connections (abg);

str = save_header_format_string;
save_header_format_string =  ["# Model Transformation Tools\t", ...
			      " -*-octave-*-\n", ...
			      "# Created by abg2connections_m\n", ...
			      str];

save -text ${file} ${sys}_connections;

EOF

Deleted mttroot/mtt/bin/trans/abg2cr_m2txt version [66557e28d3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2cr_m2txt

# Abg file to constitutive relationship conversion
# P.J.Gawthrop march 2000
# Copyright (C) 2000 by Peter J. Gawthrop



# Inform user
if [ "$1_cr.txt" -nt "$1_abg.m" ]; then
    echo "Using  $1_cr.txt"
    exit
else
    echo "Creating $1_cr.txt"
fi


rm -f mtt_error


# This is the main transformation using awk 
# And remove crs with same name as system
grep 'cr = ' $1_abg.m | gawk '
BEGIN {
# Include lin cr anyway.
print "lin"
}
{
  crs=substr($3,2,length($3)-3);
    N=split(crs,cr,";");
      for (i=1;i<=N;i++){
        if (length(cr[i])>0)
        print cr[i];
      }
}'  2>mtt_error.txt | sort -u | grep -v none | grep -v '\$[0-9]'> $1_cr.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt




Deleted mttroot/mtt/bin/trans/abg2ibg_dia2m version [0f6a6c0a05].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

### abg2ibg_dia2m
## Creates _ibg.m from _abg.dia
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

mtt_uncompress.sh $1_abg.dia
dia2abg.pl --create_ibg --diagram_name=$1

Deleted mttroot/mtt/bin/trans/abg2lbl_fig2txt version [914b9ec92b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350






























































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2lbl_fig2txt
#
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.27  2002/05/10 09:08:55  gawthrop
## Added EMTF and INTF
## Fixed bug in writing out component headings
##
## Revision 1.26  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.25  2001/10/15 14:27:00  gawthrop
## Now handles [1:N] style port labels
##
## Revision 1.24  2001/08/02 03:24:48  geraint
## Replaced mtt_version.sh with mtt_banner.sh - I think this was the intent.
##
## Revision 1.23  2001/07/26 04:08:35  gawthrop
## Removed lines deleting _type.sh and cbg.m
##  -- how did they get there ??
##
## Revision 1.22  2001/07/08 03:28:11  gawthrop
## Fixed a bug: abg2sympar_m2txt neads a _lbl.txt file when using
## "usinglabel" option
##
## Revision 1.21  2001/07/06 00:46:50  gawthrop
## Added -cr option -- forces cr to be loaded before the ese.r file
## This avoids causality problems when using multi-port Rs to represent
## arbitary equations
##
## Revision 1.20  2001/07/04 05:19:57  gawthrop
## Added RT & CT to list
##
## Revision 1.19  2001/07/03 23:51:10  gawthrop
## Now puts outline #Summary and #Description lines at top of lbl file
##
## Revision 1.18  2001/06/13 18:24:10  gawthrop
## Made "lin" default in place of "none"
## Still needs arg and cr alias clashes to be sorted ....
##
## Revision 1.17  2001/06/13 10:41:06  gawthrop
## Further changes towards aouto creation of lbl files.
## Prettified lbl files
##
## Revision 1.16  2001/06/11 19:43:49  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.15  2001/06/11 16:53:49  gawthrop
## Now uses abg2sympar_m2txt to get the arguments
##
## Revision 1.14  2001/06/11 15:06:58  gawthrop
## Now handles user-defined components
##
## Revision 1.13  2001/06/04 08:13:37  gawthrop
## Various changes to support PPP
##
## Revision 1.12  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.11  2000/09/19 11:14:30  peterg
## Now writes the first component type header correctely
##
## Revision 1.10  2000/01/26 10:11:10  peterg
## Added I component
##
## Revision 1.9  1999/11/10 00:47:08  peterg
## Replaced ifs by a table of cr/arg information
##
## Revision 1.8  1999/11/09 22:32:41  peterg
## Under RCS ready for using arrays to contaain defaults.
##
## Revision 1.7  1998/07/04 10:37:21  peterg
## Major revision to include:
## 	aliases
## 	new Style
## 	prettyfied
##
## Revision 1.6  1998/03/05 10:09:47  peterg
## Corrected bug in writing "other" components
##
## Revision 1.5  1998/03/02 09:26:18  peterg
## Now does default CR and args for the basic components only
## SS,I,R,C,GY,TF
## C now has a default of effort input.
##
## Revision 1.4  1998/02/23 16:20:33  peterg
## Summary line just contains the model name
##
## Revision 1.3  1997/05/09 14:21:35  peterg
## Default to flow,component_name
##
# Revision 1.2  1997/03/19  12:08:01  peterg
# No longer writes out non-unique names - now done in rbg_fig2m
#
# Revision 1.1  1997/03/18  13:55:01  peterg
# Initial revision
#
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997

infofile='mtt_info.txt'
typefile="$1_type.sh"
sensitivity=$2;
system=$1
outfile=$1_lbl.txt

if [ -n "$sensitivity" ]; then
    sys="-s ${system}"
else
    sys=${system}
fi

# Remove unwanted files
rm -f abg2lbl_fig2txt.log
rm -f $infofile
rm -f mtt_junk*

## Create lbl files beneath this one
mtt -q -u -l 1 ${sys} sub sh # Create the list
sh $1_sub.sh "abg2lbl_fig2txt " " $sensitivity"

if [ -f "$1_lbl.txt" ]; then
  ##echo "$1_lbl.txt exists in `pwd` - no action taken"
  exit
##else 
  ##echo "$1_lbl.txt dosn not exist in `pwd` "
fi

#Inform user
if [ -n "$sensitivity" ]; then
    echo "Creating ${outfile} (sensitivity version)"
else
    echo "Creating ${outfile}"
fi

write_header()

{
cat<<EOF
#SUMMARY ${system}
#DESCRIPTION Detailed description here

## System ${system}, representation lbl, language txt
## File ${system}_lbl.txt
## Generated by MTT on `date`

EOF
cat $MTT_DOC/mtt_banner.sh


}

write_blurb()
{
cat <<EOF

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----
EOF
}

create_lbl_body()
{

## Find names of all components
grep -v '\[[0-9]*:[0-9]*\]' $1_abg.fig  |\
gawk '/:/ {print $NF}'  | \
sed 's/\\001//' | \
sort | \
tee $1_raw_list | \
sort -u> $1_unique_raw_list


#Write out non-unique names
#echo 'Non-unique names (if any):'
#diff $1_unique_raw_list  $1_raw_list | grep '>' | sed 's/>/	/'

#Write out the outline lbl file
grep -v  '\[[0-9]*\]'  $1_unique_raw_list | \
gawk --field-separator ':' '
 BEGIN {
    OldComponent="None";
    default_cr = "lin";
 }
 { 
  Component = $1;
  Name = $2;
  Arg = $3;

##Aliases
  if (Component == "SS") {
    port_alias[++j] = Name;
  }
  else {
    alias[++i] = Name;
    if (length(sensitivity)>0) {
      s_arg = sprintf("%ss",Name);
      alias[++i] = s_arg;
      s_arg = sprintf(";%s",s_arg);
      Component_type = Component;
      Component = substr(Component,2);
      lin = "slin"
    }
   else {
      Component_type = Component;
      lin = "lin";
    }
  
 }

    ## Table of components
    cr["SS"] = "SS";  arg["SS"] = "external,external";

    cr["Se"] = "SS";  arg["Se"] = sprintf("external%s", s_arg);
    cr["Sf"] = "SS";  arg["Sf"] = sprintf("external%s", s_arg);

    cr["De"] = "SS";  arg["De"] = "external";
    cr["Df"] = "SS";  arg["Df"] = "external";

    cr["R"] = lin;  arg["R"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["C"] = lin;  arg["C"]  = sprintf("effort,%s%s", Name, s_arg);
    cr["I"] = lin;  arg["I"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["INTF"] = lin;  arg["INTF"]  = "";

    cr["CS"] = "lin";  arg["CS"]  = sprintf("effort,%s;%s_x0%s", Name, Name, s_arg);
    cr["IS"] = "lin";  arg["IS"]  = sprintf("flow,%s;%s_x0%s", Name, Name, s_arg);
    cr["INTFS"] = "lin";  arg["INTFS"]  = sprintf("%s_x0%s", Name, s_arg);

    cr["TF"] = "lin";  arg["TF"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["GY"] = "lin";  arg["GY"]  = sprintf("flow,%s%s", Name, s_arg);

    ##cr["EMTF"] = sprintf("%s", Name);  arg["EMTF"]  = sprintf("l%s",  s_arg);
    cr["EMTF"] = "lin";  arg["EMTF"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["AE"] = "lin";  arg["AE"]  = sprintf("%s%s", Name, s_arg);
    cr["AF"] = "lin";  arg["AF"]  = sprintf("%s%s", Name, s_arg);
    cr["AEf"] = "lin";  arg["AEf"]  = sprintf("%s%s", Name, s_arg);
    cr["AFe"] = "lin";  arg["AFe"]  = sprintf("%s%s", Name, s_arg);

    cr["CDx"] = "lin";  arg["CDx"]  = sprintf("%s%s", Name, s_arg);


    cr["FMR"] = lin;  arg["FMR"]  = sprintf("effort,%s%s", Name, s_arg);

    cr["RS"] = lin;  arg["RS"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["RT"] = lin;  arg["RT"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["CT"] = lin;  arg["CT"]  = sprintf("effort,%s%s", Name, s_arg);

    ## Put in the explicit arguments
    if (length(Arg)>0) {
      arg[Component] = Arg;
      if (match(Arg,"=")>0) # Its an equation type cr
        cr[Component] = "cr"
      else # assume a linear cr
        cr[Component] = "lin";
    }

  ## Print component header 
  if (Component != OldComponent) print "\n## Component type", Component_type

  ## Print Component
    printf("\t%s\t", Name);
    if (Component in cr)
      printf("%s\t\t", cr[Component])
    else 
      printf("%s\t\t", default_cr);

   if (Component in arg)
      printf("%s\t\t\n", arg[Component])
    else {
	print "lbl2args_txt2out", Component_type | "/bin/sh"; close("/bin/sh")
    }

    OldComponent=Component;
    delete arg[Component]; # Zap the element
    delete cr[Component]; # Zap the element
  }
  END{
    print "\n## Port aliases" >> "mtt_junk_alias.txt";
    for (k=1;k<=j;k++){
      if (port_alias[k] ~ "\\["){ # Only do ports
        port_name = substr(port_alias[k],2,length(port_alias[k])-2);
        if (length(sensitivity)==0)
          print "#ALIAS\t" port_name "\t" port_name >> "mtt_junk_alias.txt";
        else
          print "#ALIAS\t" port_name "\t" port_name "_1," port_name "_2" >> "mtt_junk_alias.txt";
      }
    }

#    print "\n% Argument aliases" >> "mtt_junk_alias.txt";
#    for (k=1;k<=i;k++){
#      print "%ALIAS\t\$" k "\t" alias[k] >> "mtt_junk_alias.txt";
#    }
 }' sensitivity=$sensitivity
}

create_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF
abg2sympar_m2txt ${system} ${system} use_label_file |\
gawk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
}

## Main 

create_lbl_body $1> $1_lbl.txt
create_arg_aliases > mtt_args.txt # using $1_lbl.txt
mv $1_lbl.txt mtt_junk_lbl.txt

write_header            > ${outfile}
cat mtt_junk_alias.txt >> ${outfile}
cat mtt_args.txt       >> ${outfile}
write_blurb            >> ${outfile}
cat mtt_junk_lbl.txt   >> ${outfile}
## Put a blank line at end
cat >> ${outfile} <<EOF

EOF
## Clean up
rm -f mtt_junk*





Deleted mttroot/mtt/bin/trans/abg2sabg_fig version [42ae42721b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sabg_fig
#
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:18:40  peterg
## Initial revision
##
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997

infofile='mtt_info.txt'
typefile="$1_type.sh"

# Remove the old log file
rm -f abg2sabg_fig.log
rm -f $1_cbg.m
rm -f $typefile
rm -f $infofile


#Inform user
echo Creating $1_sabg.txt

gawk '{\
    Depth=7;\
    print $Depth}' $1_abg.fig

Deleted mttroot/mtt/bin/trans/abg2sensitivity_fig version [019c577d2e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Converts abg.fig to sensitivity version

## Copyright (C) 1999 by Peter J. Gawthrop

filename=$1_abg.fig
sfilename=s$filename

if [ -f "$sfilename" ]; then
    echo $sfilename exists -- no action taken
    exit
fi

if [ -f $filename ]; then
    echo Using existing $filename
else
    echo "Looking for $1 in library"
    mtt -q  compcopy $1  
fi


echo Creating $sfilename   

gawk '
  function modulo10(x) {
    return x-int(x/10)*10
    }
  {

  level_index = 4;
  if ( match($NF,"001")&&(modulo10($level_index)==0)&&(index($NF,"[") != 1) ){
    last = $NF
    if ( (index($NF,"0") != 1)&&(index($NF,"1") != 1)&&(index($NF,"SS") != 1) ) {
      $NF = sprintf("s%s", $NF);
      print $0;
    }
    else {
      x_1_index = 10;
      x_2_index = 12;
      y_1_index = 11;
      y_2_index = 13;
      colour_index=3;
      yellow = 6;

      ## save details 
      colour=$colour_index;
      component=$NF;
      x_1 = $x_1_index;
      x_2 = $x_2_index;
      y_1 = $y_1_index;
      y_2 = $y_2_index;
      
      ## print the label
      $colour_index = yellow;
      $NF = "[1,2]\\001";
      $x_1_index = x_1+1;
      $x_2_index = x_2+1;
      $y_1_index = y_1+1;
      $y_2_index = y_2+1;
      print $0;

      ## print the component
      $colour_index = colour;
      $NF = component;
      $x_1_index = x_1;
      $x_1_index = x_1;
      $y_1_index = y_1;
      $y_2_index = y_2;
      print $0;

      
    }
  }
  else
    print $0;
'} < $filename >$sfilename



Deleted mttroot/mtt/bin/trans/abg2sub_fig2sh version [aa4b28a58d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sub_m2sh
  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.4  2002/04/22 10:25:47  gawthrop
  ## Handles unnamed components & ingnores artwork
  ##
  ## Revision 1.3  2001/10/15 14:27:34  gawthrop
  ## Now handles [1:N] style port labels
  ##
  ## Revision 1.2  2001/07/23 23:26:23  gawthrop
  ## Removed some boring user feedback
  ##
  ## Revision 1.1  2001/06/11 19:47:49  gawthrop
  ## Makes the sub.sh file directly from the abg.fig file
  ## Used for making lbl files (abg2lbl_fig2txt)
  ##
  ##
  ###############################################################

# Copyright (C) 1996--2002 by Peter J. Gawthrop



get_valid_components()

{
gawk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;

}
{
object = $1;
zero_depth =  (modulo10($4)==0)&&(object==text);
if (zero_depth) print $0

}' < $1_abg.fig

}
#if [ -f "$1_sub.sh" ]; then
#    echo Using "$1_sub.sh"
#    exit
#else
    #Inform user
    echo Creating $1_sub.sh    
#fi

echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components from the _abg file
get_valid_components $1 |\
grep -v '\[[0-9]*:[0-9]*\]' |\
grep -v '\[.*\]' |\
gawk '{if ($1==4) split($14,a,":"); print a[1]}'  |\
sed 's/\\001//' |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Deleted mttroot/mtt/bin/trans/abg2sub_m2sh version [2502a0a331].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sub_m2sh

# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/10/03 11:34:53  peterg
## Correct $MTT_LIB
##
## Revision 1.2  2000/03/17 09:53:10  peterg
## Removed irritating echo Using "$1_sub.sh"
##
## Revision 1.1  2000/03/15 21:23:20  peterg
## Initial revision
##
###############################################################


if [ -f "$1_sub.sh" ]; then
    #echo Using "$1_sub.sh"
    exit
else
    #Inform user
    echo Creating $1_sub.sh    
fi


echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _abg file
gawk '/type = / {print substr($3,2,length($3)-3)}' $1_abg.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
echo ls $MTT_LIB/comp/simple
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Deleted mttroot/mtt/bin/trans/abg2sympar_m2txt version [f1c08a0b7a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2sympar_m2txt

# Label file to symbolic parameters conversion
# Copyright (C) 2000 by Peter J. Gawthrop

# Inform user
##echo "Creating $1_sympar.txt" with $1 $2 $3

# Separation characters
SEPS='^=*;+/()-'
# Replace by ,
REPS='[,*]'

SystemName=$2
UseLabelFile=$3

if [ -n "$UseLabelFile" ]; then ## Take input from lbl.txt
     strip_comments < $1_lbl.txt  | tr $SEPS $REPS |\
     gawk '{printf("%s %s \"%s\",\n",$1,$2,$3)}' > mtt_stripped_file
else ## Take input from _abg.m
     cat $1_abg.m | grep "arg =" | tr $SEPS $REPS > mtt_stripped_file
fi

rm -f mtt_error
# This is the main transformation using gawk
cat mtt_stripped_file | \
gawk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
}

BEGIN {
  var = "[%|#][PAR|VAR]";
  not_an_arg = "effort flow state internal external zero unknown\
                mtt_e mtt_f\
		sqrt exp log sign sin asin cos acos tan atan \
		sin asin cos acos tan atan \
		sinh asinh cosh acosh tanh atanh \
                none abs";
  arg_line = "arg = ";
}
{
  ## Explicit VAR declarations
  if (match($1,var)>0) print $2 "\t" system_name;

   ## Implicit declarations from the arg list
##  if (match($1,"arg")>0) {
    args= substr($3,2,length($3)-3);
    if (length(args)>0)
      printf("%s\t%s\n", args,system_name)
##  }
}' system_name=$SystemName |\
grep -v '^\$' | mtt_strip_args | sort -u > mtt_stripped_args


## Now get the explicit declarations
if [ -n "$UseLabelFile" ]; then ## Take input from lbl.txt
    ext=_lbl.txt
else
    ext=_abg.m
fi

strip_pars.sh $1${ext} $1 |  sort -u > mtt_explicit_args

## And write sorted list
cat  mtt_explicit_args mtt_stripped_args 


Deleted mttroot/mtt/bin/trans/abg2tex version [5c7c8f0f51].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178


















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2tex
# Creates a tex file describing the system abg
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2004/08/26 16:11:48  geraint
## Fixed ignore() and pipe so that subsystems are included in reports again.
##
## Revision 1.6  2004/02/11 10:10:04  gawthrop
## Includes a _pic.fig file (schematic) if such exists
##
## Revision 1.5  2004/02/10 16:12:21  gawthrop
## Don't give details of Se De Sf Df INTF
##
## Revision 1.4  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.2  2000/11/27 17:45:00  peterg
## Removed "System" from  heading
##
## Revision 1.1  2000/11/27 15:11:15  peterg
## Initial revision
##
## Revision 1.7  1997/12/06 16:20:37  peterg
## Added another argument - the label
##
## Revision 1.6  1997/12/06 15:49:35  peterg
## Changed order of fig arguments to put filename first.
##
## Revision 1.5  1997/08/15 11:32:05  peterg
## Removed an echo left in by mistake
##
# Revision 1.4  1997/08/15  11:19:25  peterg
# Minto cosmetics.
#
## Revision 1.3  1997/05/21 12:07:22  peterg
## Replaced echo by cat -- much simpler.
##
## Revision 1.2  1997/05/19 16:25:53  peterg
## Explicit include of tex files .. latex2html seems to prefer this!
##
# Revision 1.1  1997/05/19  11:30:00  peterg
# Initial revision
#
###############################################################

## Subsystems that don't need documentation
ignore(){ 
   gawk '
BEGIN{
ignored = " Se De Sf Df INTF ";
}
{
     subsys = sprintf(" %s ", $1);
     if (match(ignored,subsys)==0)
       print $1 
  }'
}

#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-pdf )  pdf='-pdf'
                ;;
	-s )  sensitivity='-s'
                ;;

	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


if [ -z "$2" ]; then
  filename="$1_abg.tex";
  echo > $filename
  echo Creating $filename
  subsection='section'
else
  filename=$2
  subsection='subsection'
fi


#Section heading (if not at top level)
if [ -n "$2" ]; then
cat<<EOF >> $filename

%% Subsystem $1
  \subsection{\textbf{$1}}
    \label{sec:$1}
    \index{\textbf{$1} -- abg} 

EOF
else
mtt -q -u ${sensitivity} $1 abg m # Make sure all the subsystems exist -- nasty kludge
cat<<EOF > $filename
   % abg report for system $1 ($filename)
   % Generated by MTT at `date`
EOF
fi

# Figure
##echo mtt -q -u $pdf $1 abg ps
mtt -q -u  $pdf $1 abg ps
cat <<EOF  >> $filename

%%   \fig{`pwd`/$1_labg}{$1_abg}{0.9}{System \textbf{$1}: acausal bond graph}
   \tfig{`pwd`/$1_labg}{$1_abg}{0.9}{System \textbf{$1}: acausal bond graph}

EOF

## Put a schematic if exists (_pic.fig)
if [ -e "$1_pic.fig" ]; then
  echo Inserting $1_pic.fig
  fig2dev -L eps $1_pic.fig  > $1_pic.ps
cat <<EOF  >> $filename

   \fig{`pwd`/$1_pic}{$1_pic.ps}{0.9}{System \textbf{$1}: schematic diagram}

EOF
fi

# Description
mtt -q -u $1 desc tex
# Put in absolute pathnames in figures -- and fix bug in old desc files
sed "s;fig{;fig{`pwd`/;g" < $1_desc.tex |\
sed "s/Ref{$1_abg}/Ref{fig:$1_abg.ps}/" >> $filename

# Label file
mtt -q -u $1 lbl tex
cat<<EOF  >> $filename
 \sub$subsection{Summary information} 
 \label{sec:$1_lbl} 
 \index{\textbf{$1} -- lbl} 
EOF
cat $1_lbl.tex   >> $filename


# CRs
#mtt -q -u $1 cr tex
#cat<<EOF  >> $filename
# \sub$subsection{Constitutive relationships} 
# \label{sec:$1_cr} 
# \index{\textbf{$1} -- cr} 
#EOF
#cat $1_cr.tex   >> $filename

# Subsystems
mtt -q -u $1 sub tex 
cat<<EOF  >> $filename
 \sub$subsection{Subsystems} 
 \label{sec:$1_sub} 
 \index{\textbf{$1} -- subsystems} 
EOF
cat $1_sub.tex   >> $filename

#Now do the subsystems (if at top level)
if [ -z "$2" ]; then
    sub2subs $1 | sort -u | ignore |\
  gawk '{print "abg2tex", pdf, $1, filename}' pdf=$pdf filename=$filename | sh
fi

Deleted mttroot/mtt/bin/trans/abg_m2a4c version [18547a7f99].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg_m2a4c
#
# Acausal bond graph to ascend format

infofile='mtt_info.txt'
errorfile='mtt_error.txt'


# Remove the old log file
rm -f abg_m2a4c_m.log
rm -f $1_abg.a4c



#Inform user
echo "Creating $1_abg.a4c" 

# Use matrix manipulation to accomplish the transformation
octave -q << EOF  >$1_abg.a4c
    ABG = $1_abg;
    name = "$1";
    abg_m2a4c(ABG,name);
EOF

if [ "$info" = "info" ]; then
  cat $infofile
fi

Deleted mttroot/mtt/bin/trans/alias_txt2m version [00b2a256d4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: alias_m
# Creates the component aliases in text form

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/02 19:16:03  peterg
## Prettyfied output
##
## Revision 1.1  1998/07/02 09:21:55  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_alias.m

#Create the alias file complete with headers.
echo "function alias = $1_alias" > $1_alias.m
echo "%% Alias file ($1_alias.m)" >> $1_alias.m
echo "%% Generated by MTT at `date`" >> $1_alias.m

#Write out the variables 
gawk '{
       if (NF==2) {i++; print "alias."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "alias = 0;"
        }' $1_alias.txt >> $1_alias.m









Deleted mttroot/mtt/bin/trans/apply_crs version [60be95a20f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

sys=$1

# check for the existence of CRs that we need
crs=''
for cr in `cat ${sys}_cr.txt`; do
  if [ -f ${cr}.pm -o -f mtt/${cr}.pm ]; then
      crs="$crs $cr"
  fi
done

# should be reading the output from ese_r2make
# on standard input
${MTT_LIB}/cr/perl/apply_cr.pl ${crs}

Deleted mttroot/mtt/bin/trans/awk/lbl2cr.awk version [aa06076c55].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: lbl2cr.awk
# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.9  1998/03/08 21:01:40  peterg
## Now does multiple crs
##
## Revision 1.8  1998/03/06 09:15:28  peterg
## Ignores SS fields (assumes that if first field is a symbol then other
## field is and SS-style field.
##
## Revision 1.7  1997/04/22 12:50:15  peterg
## New much simpler version -- does not check for multiple crs -- these
## are removed later anyway.
##
# Revision 1.6  1997/03/22  15:15:44  peterg
# Ignores symbolic ($i) crs.
#
# Revision 1.5  1997/03/20  12:05:31  peterg
# Now just writes out the cr name.
#
# Revision 1.4  1996/11/09  20:38:45  peterg
# Put in new lib pat
#
## Revision 1.3  1996/11/04 14:51:14  peterg
## Added none to no cr list
##
# Revision 1.2  1996/11/02  10:22:22  peterg
# Now ignores SS lines.
#
###############################################################


function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
    }

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
    }


BEGIN {
comment = "%|#";
cr_delimiter = ";";
not_a_cr = "effort flow state internal external zero none";
is_a_SS = "internal external zero";
numeric = "[0-9]";
symbolic = "\044"; # Ascii $
symbol_count = 0;
symbols = "";

# Include lin cr anyway.
print "lin"
}
{
  if ( (match($1,comment)==0) && (NF>=3) ) {
      crs = $2
    n_crs = split(crs,cr,cr_delimiter);
    for (i = 1; i <= n_crs; i++) {
      first_char = substr(cr[i],1,1);
      if ( (matches(not_a_cr,cr[i])==0) &&
         (match(numeric,first_char)==0) &&
         (matches(is_a_SS,$3)==0))
	 print cr[i];
    }
  }
}

Deleted mttroot/mtt/bin/trans/awk/lbl2sympar.awk version [c5c057bec5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107











































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: lbl2sympar.awk
# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.13  1998/07/15 09:26:50  peterg
## Reinstated the second column of the sympar file - the system name
##
## Revision 1.12  1998/07/04 11:09:46  peterg
## Cleaned up - assumes new lbl style for SS
##
## Revision 1.11  1998/05/13 12:39:23  peterg
## Added `unknown' to list od names to avoid
##
## Revision 1.10  1998/03/26 13:03:23  peterg
## Changed SS field fudge.
##
## Revision 1.9  1998/02/16 16:09:57  peterg
## And taken it out again!
##
## Revision 1.8  1998/02/16 12:08:38  peterg
## Put back the matrix declaration
##
# Revision 1.7  1997/03/18  17:25:24  peterg
# Now just generates names - formatting removed.
#
# Revision 1.6  1996/12/07  20:02:43  peterg
# Fixed symbolic parameter bug.
#
## Revision 1.5  1996/12/07 18:06:50  peterg
## Now detects symbolic args ($1 etc) and ignores them.
##
# Revision 1.4  1996/08/30  18:45:32  peter
# Removed header stuff.
#
## Revision 1.3  1996/08/30 10:30:54  peter
## Switched order of args in matches.
##
## Revision 1.2  1996/08/30 09:35:10  peter
## Fixed problem with global variable in function.
##
## Revision 1.1  1996/08/24 13:34:48  peter
## Initial revision
##
###############################################################



function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
}


BEGIN {
sys_name = ARGV[1];
comment = "%|#";
var = "[%|#]VAR";
arg_delimiter = ",";
not_an_arg = "effort flow state internal external zero unknown 0 1";
SS_parameter = "internal external zero 0 1";
numeric = "[0-9-]";
symbol_count = 0;
symbols = "";
}
{
  if (match($1,var)>0) print $2 "\t" name;

  if ( (match($1,comment)==0) && (NF>=3) ) {
    n_args = split($3,arg,arg_delimiter);
    for (i = 1; i <= n_args; i++) {
      first_char = substr(arg[i],1,1);
      if ( (matches(not_an_arg,arg[i])==0) \
	   && (match(first_char,numeric)==0) \
	   && (match(arg[i],"\\$")==0) \
	   && (length(arg[i])>0) \
	   && (matches(symbols,arg[i]) ==0) ) {
	 print arg[i] "\t" name;
	  }
    }
  }
}





Deleted mttroot/mtt/bin/trans/awk/rbg_fig2m.awk version [fb6f8561fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854






















































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: rbg_fig2m.awk
# Raw  bond-graph conversion from fig to matlab
# P.J.Gawthrop June 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.46  2004/08/04 19:46:42  geraint
## Sorts components alphabetically (type:name) within the categories:
## internal ports, components, 0 junctions and 1 junctions.
##
## Standardising the order in which components are listed allows models
## built with different editors to interact correctly by separating the
## graphical information from the data which is required to build models.
##
## Revision 1.45  2004/04/07 12:17:43  gawthrop
## Handles new Fig header line.
##
## Revision 1.44  2002/05/25 09:23:47  gawthrop
## Self-naming components: name is mttTYPE or mttTYPE_2 ...
##
## Revision 1.43  2002/05/22 10:33:18  gawthrop
## Nameless components are now named according to type - replaces old
## mtt1 etc style.
##
## Revision 1.42  2002/03/26 12:05:27  geraint
## Escaped characters to eliminate awk warnings.
##
## Revision 1.41  2001/06/13 10:41:06  gawthrop
## Further changes towards aouto creation of lbl files.
## Prettified lbl files
##
## Revision 1.40  2001/06/11 19:43:50  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.39  2001/05/09 08:50:02  gawthrop
## Uses _art.fig to transmit the art work to the cbg.fig rep.
##
## Revision 1.38  2001/03/23 14:57:31  gawthrop
## Now puts space after header fields + writes _port.fig
##
## Revision 1.37  2000/09/14 08:43:32  peterg
## Add additional directional informatiuon to rbonds:
## 	cols 7-8 Arrow end directional bond
## 	cols 9-10 Arrow end directional bond
##
## Revision 1.36  1999/11/19 04:00:26  peterg
## Changed a comment to be more accurate.
##
## Revision 1.35  1999/07/25 22:19:45  peterg
## Fixed bug with false objects when compound objects present.
## -- Reset object to 0 after processing text.
##
## Revision 1.34  1999/02/17 06:23:49  peterg
## Bugs arising from Fig 3.2 fixed
##
## -- depth now zero modulo 10 (3.2 defaults to depth 100!!)
## -- horrible bug using = in place of == fixed.
##
## Revision 1.33  1998/08/10 15:51:06  peterg
## Comments may now be prefaced by # as well as %
##
## Revision 1.32  1998/07/27 20:30:03  peterg
## *** empty log message ***
##
## Revision 1.31  1998/04/16 13:18:13  peterg
## Now ignores spurious ports (in lbl but not Figure \ref{) but gives
## warning
##
## Revision 1.30  1998/04/12 15:01:17  peterg
## Converted to uniform port notation - always use []
##
## Revision 1.29  1998/04/12 12:35:32  peterg
## Named and unnamed SS handled in a uniform manner - in particular, the
## attributes are passed through
## wrote_component function used.
##
## Revision 1.28  1998/04/06 08:41:48  peterg
## Fixed bug due to adding (and then removing) 0 and 1 as port types
##
## Revision 1.27  1998/04/04 10:54:58  peterg
## Remove a debugging print statement
##
## Revision 1.26  1998/04/04 07:29:26  peterg
## SS now only port component
##
## Revision 1.25  1998/04/03 15:07:20  peterg
## Now correctly write 0/1 port names
##
## Revision 1.24  1998/04/03 14:02:50  peterg
## Added 0 and 1 to list of possible ports
##
## Revision 1.23  1998/02/01 18:37:41  peterg
## Don't print irritating warnings about ports listed in lbl files.
##
# Revision 1.22  1997/08/09  14:42:39  peterg
# Added underscore to port regexp
#
## Revision 1.21  1997/08/04 12:49:17  peterg
## Modified to use named (as opposed to numbered) ports.
## Generates a list of component ports in the .rbg file.
## As octave handles string vectors properly, the .cmp file format is not
## really necessary - but I've let it be for the moment.
##
## Revision 1.20  1997/03/19 12:02:01  peterg
## Now writes an error message if a lable is used twice in the fig file.
##
# Revision 1.19  1997/03/19  09:49:39  peterg
# Ports now written in cmp file.
#
# Revision 1.18  1997/03/19  09:42:08  peterg
# Now writes out the following additional fig  files:
# _head.fig	The fig header
# _bnd.fig	The bonds actually used
# _cmp.fig	The components actually used.
#
# Revision 1.17  1997/01/02  11:21:17  peterg
# Now assumes all components bonds etc at depth zero in fig file.
# Ie anything at depth>0 is ignored.
# Thanks to Donald for suggesting this.
#
## Revision 1.16  1996/12/30 20:00:29  peterg
## Fixed bent-bond bug.
## NB unfixed problems:
## 1. xfig writes multi line fields if more than about 5 segments.
## 2. rbg2abg takes a multi-segment bond as a straignt line between the
## end points - so computation of stroke and arrow directions may be
## iffy.
##
## Revision 1.15  1996/12/30 19:23:35  peterg
##  Allows for bent bonds - ie bonds with more than 2 line segments.
##
## Revision 1.14  1996/12/21 19:47:53  peterg
## Changed \* to \\*
##
## Revision 1.13  1996/12/21 19:47:23  peterg
## Put back under VC
##
# Revision 1.12  1996/08/24  16:30:12  peter
# Fixed error in nonport_regexp.
#
## Revision 1.11  1996/08/19 10:48:57  peter
## Added `-' to the component regexp.
##
## Revision 1.10  1996/08/19 09:03:13  peter
## Parses repetative components: ie suffixed by *n.
##
## Revision 1.9  1996/08/09 08:23:11  peter
## Fixed bug: ports not recognised.
##
## Revision 1.8  1996/08/05 20:12:43  peter
## Now writes a _fig.fig file.
##
## Revision 1.7  1996/08/05 18:44:56  peter
## Now writes out a _cbg file without ----- symbol.
##
## Revision 1.6  1996/08/05 12:17:37  peter
## n_ports now appear in the _abg file instead.
##
## Revision 1.5  1996/08/05 12:01:28  peter
## The _cmp function now returns the number of ports.
##
## Revision 1.4  1996/08/05 10:14:46  peter
## Made ports appear, in order, at top of component lists
##
## Revision 1.3  1996/08/04 20:32:28  peter
## Stopped complaint about missing lbl entry for port components
##
## Revision 1.2  1996/08/04 20:05:25  peter
## Included port components - eg SS:[1]
##
## Revision 1.1  1996/08/04 20:01:58  peter
## Initial revision
##
###############################################################


##############################################################
# This (g)awk script reads a fig file in fig 3.1 format.
# It interprets the picture as: bonds, arrows and components
# as follows:
#
# Bonds are firm (not dashed etc) polylines with n line segments - 
#  fig represents this by  a firstline record where
#    field 1 = 2 (always 2)
#    field 2 = 1 (polyline)
#    field 3 = 0 (style is a firm line)
#    field 7 = 0 (depth is zero [top level])
#    field 14 = 0 (no forward arrow)
#    field 15 = 0 (backward arrow) 
#    field 16 = Number of point in line (points=segments+1)
#  a data field starting with a tab followed by  points (x,y) cordinates
#
#
# Strokes are polylines with 1 line segment and and no arrow 
#  fig represents this by  a firstline record where
#    field 1 = 2 (always 2)
#    field 2 = 1 (polyline)
#    field 3 = 0 (style is a firm line)
#    field 14 = 0 (no forward arrow)
#    field 15 = 0 (backward arrow) 
#    field 16 = Number of point in line =2
#  a data field starting with a tab followed by 2 (x,y) cordinates
#
# Arrows are polylines with 1 line segment and an arrow 
#  fig represents this by  a firstline record where
#    field 1 = 2 (always 2)
#    field 2 = 1 (polyline)
#    field 3 = 0 (style is a firm line)
#    field 14 = 1 for a forward arrow  
#    field 15 = 1 for a backward arrow 
#  an additional data files
#  a data field starting with a tab followed by 2(x,y) cordinates
#
# Components appear in two files -- the fig file and the lbl file
# these two files are concatenated with the lbl file first
#  	The lbl file represents components by 3 fields
#		field  1 is the name
#		field  2 is the CR name
#		field  3 is the CR arguments
#  	The fig file represents components by 14 fields
#             field 1 = 4
#		fields 12 and 13 are the coordinates
#		field 14 is the type:name string terminated by \001
# To prevent text being confused with components, components consist
# of alphanumeric characters and : and _ only.
# 
# Components are sorted alphabetically ("type:name")
# within the following categories:
# 1) internal ports (SS:[...])
# 2) basic components, subsystems and external ports 
# 3) 0 junctions
# 4) 1 junctions
##############################################################

function modulo10(x) {
  return x-int(x/10)*10
    }

function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
    }

function write_component(i) {
    name = label[i,1];
    cr   = label[i,2];
    arg  = label[i,3];
    if (length(x[name])==0) {
        # print error - its in lbl but not fig file
        printf(warning_l, name);
    }
    else {
      component_index++;
      print x[name], y[name], info[name] >> b_file;
      printf("if i==%1.0f\n", component_index) 	>> c_file;
      printf("\tcomp_type = %s%s%s;\n", q, comp_type[name], q) >> c_file;
      printf("\tname = %s%s%s;\n", q, name, q) >> c_file;
      printf("\tcr = %s%s%s;\n", q, cr, q) >> c_file;
      printf("\targ = %s%s%s;\n", q, arg, q) >> c_file;
      printf("\trepetitions = %s;\n",  reps[name]) >> c_file;
      print "end" >> c_file
	}
  }

function process_lbl() {
# This puts the components in the lable file at the top of the list
# and saves up the corresponding CR and arguments
# note that there may be more than one component per label
  if ((match($1,comment_regexp)==0)&&(NF>0))
    { 
      i_label++;
      name = $1;
      CR   = $2;
      args = $3;

      label[i_label,1] = name; 
      label[i_label,2] = CR;
      label[i_label,3] = args;
	}
}

function sort_cmp() {
# Sorts components alphabetically by type then name
  for (i = 1; i <= i_label; i++) {
    name = label[i,1];
    type = comp_type[name];
    cmp_list[i] = sprintf ("'%s:%s'", type, name);
  }

  if (no_alpha_sort=="no_alpha_sort")
      print "Not sorting components alphabetically"
  else {
      print "Sorting components alphabetically";
      asort (cmp_list)
  };

  for (i = 1; i <= i_label; i++) {
    for (j = 1; j <= i_label; j++) {
      name = label[j,1];
      type = comp_type[name];
      typename = sprintf ("'%s:%s'", type, name);
      if (typename == cmp_list[i]) {
	sort_cmp_list[i] = j;
      }
    }
  }
}

function fig_info() {
# Grabs the fig-file information for a component
  return(sprintf("%s %s %s %s %s %s %s %s %s %s %s ", \
		 $1, $2, $3, $4, $5, $6, $7, \
		 $8, $9, $10, $11))
	 }

function type_name(type) {
#    if (type==1)
#      return "one"
#    else {
#      if (type==0)
#        return "zero"
#      else
#        return type
#    }
    return sprintf("mtt%s", type);
}

function process_text() {
# The text string is field 14 onwards
  str = $14; 
  for (i=15; i<=NF; i++) {
    str = sprintf("%s %s", str, $i)
      }

# The depth is field 4 (for strings)
  depth = modulo10($4);

# It is terminated by \001 - so delete this termination
  str = substr(str,1,length(str)-4);

# Zap maths
  ##gsub(/[()-+*/]/,"",str); 

# Lose the cr stuff (if present)
  if (depth==0) {
      N=split(str,a,delimiter);
      if (N==3)
	  str=sprintf("%s%s%s", a[1],delimiter,a[2]);
    }

# A component string contains only alphanumeric  _ and :
  isa_plain_component = match(str, component_regexp)==0;
# It must also be specified at depth 0 (modulo 10)
  isa_plain_component = isa_plain_component && (depth==0);

# A port is a string within []
  isa_port = (match(str, port_regexp)>0)

# It must also be specified at depth 0
  isa_port = isa_port && (depth==0);

# Vector port definitions
  isa_PORT = ((match(str, PORT_regexp)>0) && (depth==0));

  if (isa_PORT) {
    print str
  }

# A port component is an SS  followed by a port string
  isa_port_component = 0;
  if (match(str, delimiter)) {
    split(str,a,delimiter);
    isa_port_component = (match(a[1], port_component_regexp))&&
      (match(a[2], port_regexp)>0)
      }

# It must also be specified at depth 0
  isa_port_component = isa_port_component && (depth==0);

# A component is a plain or a port component
  isa_component = isa_plain_component||isa_port_component;

# Coordinates in fields 12 & 13
  x_coord = $12;
  y_coord = $13;

# Do the ports
  if (isa_port) {
    i_port++;
    port_name = str;
    ports[i_port] = sprintf("%s %s %s", x_coord, y_coord, port_name);
  }

# Do the port components
#  if (isa_port_component) {
#    i_port_component++;
#    type = a[1];
#    # Port name is the bit between the []
#    port_label  = substr(a[2],2,length(a[2])-2);
#    x_port[i_port_component] = x_coord;
#    y_port[i_port_component] = y_coord;
#    info_port[i_port_component] = fig_info();
#    port_labels[i_port_component] = port_label;
#      }

# Do the components
  if (isa_component) {
    i_text++;

# Get repetitions (if any)
    if (match(str,repetition_regexp) > 0) {
      split(str,b,repetition_delimiter);
      repetitions = b[2];
      str = b[1];
	}
    else {
      repetitions = "1";
    };

    named_component = (match(str,delimiter) > 0);
    if (named_component) {
      split(str,a,delimiter);
      type = a[1];
      name = a[2];
# Check  if name is in label file and if used already
      found = 0; name_used = 0;
      for (i=1; i<=i_label; i++) {
	  lname = label[i,1];
	if ( lname==name ) {
	  found = 1;
	  if (name in used) {
	    name_used = 1;
	    CR = label[i,2];
	    args = label[i,3];
	  }
	  else {
	    used[name] = 1
	      }
	  break
	    }
      }

if (!found) {
printf(warning_f, name);
i_label++;
CR = default_cr;
args = "";
label[i_label,1] = name; 
label[i_label,2] = CR;
label[i_label,3] = args
}

# Give it a new entry if already used
#  -- also tell user as it is an error now(?)
      if (name_used) {
	printf(warning_u, name);
	i_label++;
	i_name++;
	name = sprintf("%1.0f", i_name);
	label[i_label,1] = name; 
	label[i_label,2] = CR;
	label[i_label,3] = args
	  }
    }

# Unnamed component
    if (named_component==0) {
      type = str;

      if (type in name_index) 
        name_index[type]++
      else
        name_index[type] = 1;

      if (name_index[type]==1)
        name = sprintf("%s", type_name(type))
      else
        name = sprintf("%s_%i", type_name(type), name_index[type]);

      i_label++;
      label[i_label,1] = name;
      label[i_label,2] = default_cr;
      label[i_label,3] = default_args
	}

# Save in associative arrays by name	
    comp_type[name] = type;
    x[name] = x_coord;
    y[name] = y_coord;
    info[name] =  fig_info();
    reps[name] = repetitions;
  }

}

#Euclidean length of a line between (first_x,first_y) and (second_x,second_y)
function line_length(first_x,first_y,second_x,second_y) {
  x_length = second_x-first_x;
  y_length = second_y-first_y;
  return sqrt( x_length*x_length +  y_length*y_length );
}

# Returns 1 if (bond) arrow at beginning of field or 2 if arrow at end of field
function arrow_end(first_x,first_y,second_x,second_y,penultimate_x,penultimate_y,last_x,last_y) {
  if ( line_length(first_x,first_y,second_x,second_y) < line_length(first_x,first_y,second_x,second_y) ) {
  return 1
  }
  else {
  return 2
  }
}

function process_bond() {

  arg_count++;
  if ( (arg_count-arrow)==1 ) 
    {

#Save up bond coords - no arrow and more segments than a stroke has.
# Allows for bent bonds - but just write out the relevant coordinates
	if ( (!arrow)&& (NF>2*stroke_coords+1) ) {
	    i_bond++;
	    a_end = arrow_end($2,$3,$4,$5,$(NF-3),$(NF-2),$(NF-1),$NF);
	    if (a_end==1) {
		arrow_end_vector_x = $6-$4; 
		arrow_end_vector_y = $7-$5; 
		other_end_vector_x = $(NF-1)-$(NF-3);
		other_end_vector_y = $(NF)-$(NF-2);
		bonds[i_bond] = sprintf("%s %s %s %s %s %s %s %s %s %s", \
					$2, $3, $4, $5, $(NF-1), $(NF),
					arrow_end_vector_x,
					arrow_end_vector_y,
					other_end_vector_x,
					other_end_vector_y);
	    }
	    else {
		other_end_vector_x = $4-$2; 
		other_end_vector_y = $5-$3; 
		arrow_end_vector_x = $(NF-3)-$(NF-5);
		arrow_end_vector_y = $(NF-2)-$(NF-4);
		bonds[i_bond] = sprintf("%s %s %s %s %s %s %s %s %s %s", \
					$2, $3, $(NF-3),$(NF-2),$(NF-1),$NF,
					arrow_end_vector_x,
					arrow_end_vector_y,
					other_end_vector_x,
					other_end_vector_y);
	    }
      }
      
#Save up arrow coords 
      if ( (arrow)&&(NF==(2*arrow_coords+1)) ) {
	i_arrow++;
	arrows[i_arrow] = sprintf("%s %s %s %s",  $2, $3, $4, $5);
      }
      
#Save up stroke coords
      if ( (!arrow)&&(NF==(2*stroke_coords+1)) ) {
	i_stroke++;
	strokes[i_stroke] = sprintf("%s %s %s %s",  $2, $3, $4, $5);
      }
    }
}

function write_fig() {
# Create _fig.fig file from _abg file - not components
# and write out the components in a _cmp.fig file
# and write out the bonds in a _bnd.fig file

# The artwork -- not header and not zero depth
    
    if ((NF>2)&&(!zero_depth)) {
	art=$0;
	sub("----","    ",art)
	printf("%s\n", art) >> art_file
	    }
	    

#Everything except components
  if ( ((object!=text)||(isa_component==0)) ) {
    #Replace the data_symbol
    if (exact_match($1,data_symbol)) {
      field_1 = out_data_symbol
	}
    else {
      field_1 = $1
      }

    printf("%s",field_1)   >> fig_file
      for (i=2; i<=NF; i++)
	printf(" %s", $i)  >> fig_file;
    if (NF==1) 
	printf(" ")   >> fig_file; # Put space after header fields
    printf("\n") >> fig_file
    }

# Header
  if ($1=="#FIG") 
    printf("%s", $0)  >> head_file;

  if ( NF<3 ) {
	printf("%s", $1)  >> head_file;
        for (i=2; i<=NF; i++)
	  printf(" %s", $i)  >> head_file;
	if (NF==1) 
	    printf(" ")   >> head_file; # Put space after header fields
	printf("\n") >> head_file
    }
# Bonds
  if (isa_bond) {

    #Replace the data_symbol
    if (exact_match($1,data_symbol)) {
      field_1 = out_data_symbol
	}
    else {
      field_1 = $1
	}

    printf field_1   >> bnd_file
      for (i=2; i<=NF; i++)
	printf(" %s", $i)  >> bnd_file;
    printf("\n") >> bnd_file
      }

# Components & ports
  if ( isa_component||isa_port ) {
      for (i=1; i<=NF; i++)
	  printf(" %s", $i)  >> cmp_file;
      printf("\n") >> cmp_file
	  }

# Ports
  if ( isa_port_component ||isa_port) {
      for (i=1; i<=NF; i++)
	  printf(" %s", $i)  >> port_file;
      printf("\n") >> port_file
}
}

function process_fig() {
# Test for the fig format first line and data line
  data_line = (match($1,data_symbol)>0);
  first_line = (data_line==0)&&(NF>min_line_length);

#Process firstline
  if (first_line) {
    object = $1;
    sub_type = $2;
    style = $3;
    zero_depth = ((modulo10($7)==0)&&(object==polyline)) || ((modulo10($4)==0)&&(object==text))
    f_arrow = ($14==1)&&(object=polyline);
    b_arrow = ($15==1)&&(object=polyline);
    arrow = f_arrow||b_arrow;
    arg_count = 0;
  }

#Process text
  if (object==text) {
    process_text();
    object = 0; # Text on one line so reset object to zero- avoids compound problem
      }

# Process bond
isa_bond = (zero_depth &&\
       (object==polyline)&& \
       (sub_type==sub_polyline)&& \
       (style==firm_style) \
       );   

if ( isa_bond && data_line)
{
    process_bond()
      }   

if (isa_fig_file){
     write_fig()
    }

    }

BEGIN {
  sys_name = ARGV[1];
  delete ARGV[1];

  b_file = sprintf("%s_rbg.m", sys_name);
  c_file = sprintf("%s_cmp.m", sys_name);
  fig_file = sprintf("%s_fig.fig", sys_name);
  cmp_file = sprintf("%s_cmp.fig", sys_name);
  port_file = sprintf("%s_port.fig", sys_name);
  bnd_file = sprintf("%s_bnd.fig", sys_name); 
  head_file = sprintf("%s_head.fig", sys_name);
  art_file = sprintf("%s_art.fig", sys_name);

  warning_f = "WARNING %s \t in fig file but not lbl file  - using\n";
  warning_l = "WARNING %s \t in lbl file but not fig file  - ignoring\n";
  warning_p = "ERROR system ports are not consecutively numbered\n";
  warning_u = "ERROR %s has already appeared in the fig file\n";

  comment_regexp = "%|#"
  data_symbol = "----";
  out_data_symbol = "\t";
  default_cr = "";
  default_args = "";
  delimiter = ":";
  repetition_delimiter = "*";
  repetition_regexp = "\\*";
  q = "\047";
  terminator = "\\001";
  component_regexp = "[^0-9a-zA-Z_:*-]";
  port_regexp = "^[[a-zA-Z0-9_,]*]";
  nonport_regexp = "[a-zA-Z]";
  PORT_regexp = "^PORT .*=";  
  port_component_regexp = "SS";
  isa_fig_file = 0;
  min_line_length = 10;
  object = 0;
  polyline = 2;
  sub_polyline=1; 
  firm_style = 0;
  text = 4;
  compound_object = 6;
  bond_coords = 3;
  stroke_coords = 2;
  arrow_coords = 2;

  i_bond = 0;
  i_port = 0;
  i_stroke = 0;
  i_arrow = 0;
  i_label = 0;
  i_text = 0;
  i_port_component = 0;

  component_index = 0;
}
{
# Start of .fig file?
  if ($1=="#FIG") {
    isa_fig_file=1;
  }
  if (isa_fig_file==0) {
    process_lbl()    
      }
  else {
    process_fig()
      }
}

END {
#Print out the Octave functions
  printf("function [rbonds, rstrokes,rcomponents,port_coord,port_name,port_list] = %s_rbg\n", sys_name) > b_file;
  printf("%% [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = %s_rbg\n", sys_name) > b_file;
  printf("%% Generated by MTT\n\n") > b_file;

  printf("function [comp_type, name, cr, arg, repetitions] = %s_cmp(i)\n",\
		 sys_name) > c_file;
  printf("%% [comp_type, name, cr, arg, repetitions] = %s_cmp\n", sys_name) > c_file;
  printf("%% Generated by MTT\n\n") > c_file;

  printf("rbonds = [\n") >> b_file;
  for (i = 1; i <= i_bond; i++)
    print  bonds[i] >> b_file;
  for (i = 1; i <= i_arrow; i++)
    print  arrows[i], "-1 -1" >> b_file;
  printf("];\n") >> b_file;
  
  printf("rstrokes = [\n") >> b_file;
  for (i = 1; i <= i_stroke; i++)
    print  strokes[i] >> b_file;
  printf("];\n") >> b_file;

  printf("rcomponents = [") >> b_file;
  j = 0;

  sort_cmp();	# sort components alphabetically

# Do the port components, in order of appearance, first.
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (match(name,port_regexp))
      write_component(num);
  }
  
# then do the ordinary components, in order of appearance.
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if ((!match(comp_type[name],"0"))&&
	  (!match(comp_type[name],"1"))) 
	write_component(num);
  }
  
# followed by the 0 junctions
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if (match(comp_type[name],"0"))
	write_component(num);
  }
# and finally the 1 junctions
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if (match(comp_type[name],"1"))
	write_component(num);      
  }
  printf("];\n") >> b_file;
  
# Print the (internal) ports list
  printf("port_coord = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    printf("%s %s\n", a[1], a[2]) >> b_file;
  }
  printf("];\n\n") >> b_file;

  printf("port_name = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    # Dont Remove the []
    # name = substr(a[3],2,length(a[3])-2);
    name = a[3];
    printf("'%s'\n", name) >> b_file;
  }
  printf("];\n\n") >> b_file;

# Print the (external) port list - ignore spurious ports (in lbl, not fig)
  printf("port_list = [\n") >> b_file;
  for (i = 1; i <= i_label; i++) {
    name = label[i,1];
    if (length(x[name])>0) {
      if (match(name,port_regexp))
	printf("'%s'\n", name) >> b_file;
    }
  }
  printf("];\n\n") >> b_file;
  
}



Deleted mttroot/mtt/bin/trans/awk/rep_txt2make.awk version [1a899189e1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: rep_txt2make
# Converts the text file describing a report to makefile dependencies
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.3  1997/05/19  15:40:04  peterg
# Pass mtt swithches to the new make file
#
# Revision 1.2  1996/11/21  15:57:28  peterg
# Now runs mtt quietly.
#
# Revision 1.1  1996/08/18  19:59:00  peter
# Initial revision
#
###############################################################


{
  if (NF==2)
    if( match("tex txt r m ps",$2)>0)
      print "mtt -q", switches, system_name, $1, $2
}



Deleted mttroot/mtt/bin/trans/awk/rep_txt2tex.awk version [3c9239d1bd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: rep_txt2tex
# Converts the text file describing a report to a report.
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.5  1997/05/22  11:12:34  peterg
# Chaged figure label.
#
## Revision 1.4  1997/05/22 07:36:35  peterg
## \ref --> \Ref
##
## Revision 1.3  1997/05/19 16:43:34  peterg
## Explicit include of tex files 'cos latex2html prefers this!
##
# Revision 1.2  1997/05/19  16:11:10  peterg
# Modified section headers.
#
# Revision 1.1  1996/08/18  19:58:49  peter
# Initial revision
#
###############################################################


BEGIN {
  split(ARGV[1],a,"_");
  system_name = a[1];
  args = ARGV[2];
  comment="\%";
}
{
  if ((match($1,comment)==0)&&(NF==2)) {
    Representation = $1;
    Language = $2;
    Rep_lang = sprintf("%s_%s", Representation, Language);
    section_head = sprintf("System \\textbf{%s}: representation \\textbf{%s}, language \\textbf{%s}", \
			   system_name,Representation,Language);
# section headings
    print "\\section{" section_head "}";
    print "\\label{" Rep_lang "}";
    print "\\index{\\textbf{" system_name "} -- " Representation "}";

# tex files
    if( match("tex",Language)>0) {
      # printf("  \\input{%s_%s.%s}\n", system_name, Representation, Language);
      command = sprintf("cat %s_%s.%s", system_name, Representation, Language);
      system(command);    }
# text files
    if( match("txt r m c h",Language)>0) {
      print "  \\begin{verbatim}";
      command = sprintf("cat %s_%s.%s", system_name, Representation, Language);
      system(command);
      print "  \\end{verbatim}";  
    }
# ps files
    if( match("ps",Language)>0) {
      printf("This representation is given as Figure \\Ref{fig:%s}.\n", Rep_lang);
      print "  \\begin{figure}";
      printf("   \\shadowbox{ \\epsfig{file=%s_%s.%s,width=0.9\\linewidth} }\n", \
	     system_name, Representation, Language);
      printf("    \\caption{System \\textbf{%s}, representation %s}\n", system_name, Representation);
      printf("    \\label{fig:%s}\n", Rep_lang);
      print "  \\end{figure}";
    }
  }
}
END {

}



Deleted mttroot/mtt/bin/trans/awk/tex2doc.awk version [a8fccd0d60].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: tex2doc
# Encapsulates a tex file in a document.
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1997/04/15  11:18:49  peterg
# Uses supertabular package
#
# Revision 1.1  1996/08/18  20:00:10  peter
# Initial revision
#
###############################################################


END{
#  split(ARGV[1],a,"_");
#  system_name = a[1];
#  split(a[2],b,".");
#  representation = b[1];
  makefile = sprintf("%s_rep.make", $system_name, $representation);
  print "\\documentclass[12pt,a4paper]{article}";
  printf("\\title{System %s, representation %s}\n", \
	 system_name, representation) 
  print "\\author{Generated by MTT}";
  print "  \\usepackage{epsfig}";
  print "  \\usepackage{supertabular}";
  print "\\begin{document}";
  print "  \\maketitle";
  print"  \\input{}", system_nam,e $representation;
  print $system_name $representation
  print "\\end{document}"
}

Deleted mttroot/mtt/bin/trans/bg2eps version [b8f9ead8c5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

set +e				# prevent dia errors from halting MTT

sys=$1
rep=$2
ps=$3
eps=$4

dia_files=`ls ${sys}*_${rep}.dia 2>/dev/null | sed 's/\.dia$//'`
fig_files=`ls ${sys}*_${rep}.fig 2>/dev/null | sed 's/\.fig$//'`

for file in ${dia_files}
  do
  dia --export-to-format=eps ${file}.dia
  if [ "${ps}" != "eps" ]
      then mv ${file}.eps ${file}.${ps}
  fi
done

for file in ${fig_files}
  do
  fig2dev -L${eps} ${file}.fig > ${file}.${ps}
done

Deleted mttroot/mtt/bin/trans/c-tidy version [28f2822d80].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1997/02/04 18:50:07  peterg
## Initial revision
##
## Revision 1.2  1996/08/20 08:26:06  peter
## Version control header added.
##
###############################################################

# Bourne shell script: c_tidy
# Tidies up C format files
# P.J.Gawthrop 14 June 1990 13 Nov 1990, 19 Nov 93, April 1994, Dec 1994, 
# June 1995
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

# Remove blank lines
cat $1 | \
tr -s '\012' '\012'\
>junk
mv junk $1







Deleted mttroot/mtt/bin/trans/c_tidy version [58bf61dcc7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1997/02/04 18:52:34  peterg
## Copied from matlab tidy -- removed everthing except removal of blank
## lines
##
## Revision 1.1  1997/02/04 18:50:07  peterg
## Initial revision
##
## Revision 1.2  1996/08/20 08:26:06  peter
## Version control header added.
##
###############################################################

# Bourne shell script: c_tidy
# Tidies up C format files
# P.J.Gawthrop 14 June 1990 13 Nov 1990, 19 Nov 93, April 1994, Dec 1994, 
# June 1995
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

# Remove blank lines
cat $1 | \
tr -s '\012' '\012'\
>junk
mv junk $1







Deleted mttroot/mtt/bin/trans/can_r2m version [4c4db15907].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: can_r2m
# Reduce canonical forsm to matlab
# P.J.Gawthrop  January 8th 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################



# Inform user
echo Creating $1_can.m

# Remove the old log file
rm -f can_r2m.log

# Use reduce to accomplish the transformation
reduce >can_r2m.log << EOF

%Read in the definitions file
IN "$1_def.r";

%Read the reduce state-space A,B,C and D matrices file
IN "$1_can.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read in the parameter file
IN "$1_sympar.r";

OUT "$1_can.m";
%Headings - Matlab style
%(Note. The ;; are deleted by for2mat)

write "function [A_c,B_c,C_c,D_c,Con,Obs,K,L,A_comp,B_comp,C_comp] = $1_can;;";
write "%function [A_c,B_c,C_c,D_c,Con,Obs,K,L,A_comp,B_comp,C_comp] = $1_can;;";

write "%Canonical forms and controller design for system $1";
write "%File $1_can.m";
write "%Generated by MTT";
write "";

IF MTTNvar>0 THEN
BEGIN
  write "% Set the parameters";
  write "global ...;;";
  FOR i := 1:MTTNx DO
    write "alpha_c",i, " alpha_o",i, "...;;";
  
  FOR i := 1:MTTNvar DO
    BEGIN
      IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
        % Do nowt
      END
      ELSE  
      BEGIN
        write MTTVar(i,1), " ...";
      END;
    END;
    write " ";
END;


%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "MTTA_c = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTB_c = zeros(", MTTNx, ",", MTTNu, ");";
write "MTTC_c = zeros(", MTTNy, ",", MTTNx, ");";
write "MTTD_c = zeros(", MTTNy, ",", MTTNu, ");";

write "MTTCon = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTObs = zeros(", MTTNx, ",", MTTNx, ");";

write "MTTK = zeros(", MTTNy, ",", MTTNx, ");";
write "MTTL = zeros(", MTTNx, ",", MTTNu, ");";

write "MTTA_comp = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTB_comp = zeros(", MTTNx, ",", MTTNy, ");";
write "MTTC_comp = zeros(", MTTNu, ",", MTTNx, ");";


ON NERO;	% Suppress zero elements.
MTTA_c := MTTA_c;
MTTB_c := MTTB_c;
MTTC_c := MTTC_c;
MTTD_c := MTTD_c;

MTTCon := MTTCon; 
MTTObs := MTTObs; 


MTTK := MTTK; 
MTTL := MTTL;

MTTA_comp := MTTA_comp;
MTTB_comp := MTTB_comp;
MTTC_comp := MTTC_comp;
MTTD_comp := MTTD_comp;


OFF FORT;
write "";

SHUT "$1_can.m";

Deleted mttroot/mtt/bin/trans/can_r2tex version [5939f4edfe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193

































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: can_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Inform user
echo Creating $1_can.tex

# Remove the old log file
rm -f can_r2tex.log

# Use reduce to accomplish the transformation
reduce >can_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the canonical-form matrices file
in "$1_can.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

OUT "$1_can.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_can.tex";
write"";


% Controllable form
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Observer Gain matrix - observer form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$


% Controllable form
MTT_Matrix := MTTA_comp$ 
MTT_Matrix_name := "MTTA_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_comp$ 
MTT_Matrix_name := "MTTB_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_comp$ 
MTT_Matrix_name := "MTTC_comp"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$



write "\begin{equation}";
  write "MTTur = {", MTTu_r, "}";
write "\end{equation}";

SHUT "$1_can.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/cbg2ese_m2r version [fe2612a1bc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cbg2ese_m
#
#
# P.J.Gawthrop June 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$
## Revision 1.32  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.31  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.30  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.29.2.1  2001/06/26 22:29:05  geraint
## mtt_xargs.sh eliminates Arg list too long error for large models.
## (UNIX xargs does not work if the environment is too large).
##
## Revision 1.29  2001/03/29 19:24:14  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.28  2001/02/05 17:19:52  gawthrop
## Now gives unique names to the states of multiports. Second name
## onwards labeled with port number
##
## Revision 1.27  2000/12/05 12:09:56  peterg
## Changed function name to name()
##
## Revision 1.26  2000/12/05 09:04:54  peterg
## *** empty log message ***
##
## Revision 1.25  2000/12/01 14:51:26  peterg
## Major changes towards partioning
##
## - generates sub ese, def and struc
## - generates indices for conversion of subsystem in/out/state - but not used yet
##
## Revision 1.24  2000/11/30 15:12:55  peterg
## Zapped the declaration of subsystem connections - now in individual
## .def files
##
## Revision 1.23  2000/11/30 15:07:28  peterg
## Sorted out mtt_getsize
##
## Revision 1.22  2000/11/12 17:18:30  peterg
## Changed ' to "
##
## Revision 1.21  2000/10/16 08:40:35  peterg
## Whoops! Must touch mtt_aliased
##
## Revision 1.20  2000/10/16 08:36:31  peterg
## Creat empty _aliased file if it doesn't exist
##
## Revision 1.19  2000/10/12 19:25:39  peterg
## Now generateds the _aliased.txt file
##
## Revision 1.18  2000/09/15 08:09:42  peterg
## Removed another debugging line
##
## Revision 1.17  2000/09/15 08:06:17  peterg
## Removed debug lines
##
## Revision 1.16  2000/09/02 15:55:51  peterg
## *** empty log message ***
##
## Revision 1.15  1998/07/08 14:43:12  peterg
## Restored inforfile
##
## Revision 1.14  1998/07/08 08:26:26  peterg
## Added -I option -- if set prints out the information messages
##
## Revision 1.13  1998/05/12 14:49:10  peterg
## Don't write END; any more - ese-tidy does this now!
##
## Revision 1.12  1998/01/23 13:30:46  peterg
## $RMATRIX --> $MATRIX
##
## Revision 1.11  1997/12/16 18:05:03  peterg
## Increased size of structure vector by on to include unknown_inputs as
## 6th element
##
## Revision 1.10  1997/04/15 09:18:26  peterg
## Added structure file
##
# Revision 1.9  1996/12/07  18:21:25  peterg
# Now uses fopen + file number
#
## Revision 1.8  1996/12/05 10:05:28  peterg
## Removed the Octave switch: empty_list_elements_ok = 1;
## This is now in .octaverc
##
# Revision 1.7  1996/08/30  11:29:49  peter
# Added constitutive relationship to argument list.
# Put in explicit argument list to cbg2ese.
#
# Revision 1.6  1996/08/26  13:25:07  peterg
# Corrected error handling.
#
# Revision 1.5  1996/08/24  14:38:11  peter
# Error handling included.
#
## Revision 1.4  1996/08/19 09:02:12  peter
## Errors go to user - not log.
##
## Revision 1.3  1996/08/18 20:05:55  peter
## Included zero outputs.
##
## Revision 1.2  1996/08/08 18:08:37  peter
## Sorted out file naming scheme.
##
## Revision 1.1  1996/08/08 15:57:15  peter
## Initial revision
##
###############################################################

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


infofile='mtt_info.txt';
structurefile="$1_struc.txt";
eqnfile="$1_ese.r";
deffile="$1_def.r";


# Remove the old log file
rm -f cbg2ese_m.log

# Remove the info and error files
rm -f mtt_info.txt
rm -f mtt_error.txt
rm -f mtt_aliased.txt

# Remove relevent ese files
rm -f $1_ese.r $1_*_ese.r 

#Inform user
echo Creating $eqnfile $blurb
echo Creating $deffile
echo Creating $structurefile

# Use matrix manipulation to accomplish the transformation
# This creates an ese file for every subsystem.
$MATRIX << EOF > cbg2ese_m2r.log 2>mtt_error.txt

infofile = "$infofile";;
infofilenum = fopen(infofile,"wt");
structurefile = "$structurefile";;
structurefilenum = fopen(structurefile,"wt");
deffile = "$1_def.r";
deffilenum = fopen(deffile,"wt");

system_name = "$1";
system_type = "";
system_cr = "";
system_args = "";
full_name = "";
full_name_repetition = "";

% Structure matrix [states,nonstates,inputs,outputs,zero_outputs]

structure = zeros(1,7);  # Initialise structure vector

structure = cbg2ese(system_name, system_type, system_cr, ...
                     system_args, full_name, full_name_repetition, ...
                     1, structure, structurefilenum, infofilenum);
makedef(structure,deffilenum);
EOF

echo "END;" >> $1_def.r

if [ "$info" = "info" ]; then
  cat $infofile
fi

if [ -z "$partition" ]; then
  ## Don't partition

  # Create the composite ese file
  mtt_xargs.sh cat "$1_ese.r $1_*_ese.r $1_modpar.r"  > $1_ese.tmp 2>> /dev/null

  mv $1_ese.tmp $1_ese.r

  # Zap the sub ese files
  mtt_xargs.sh "rm -f" "$1_*_ese.r"

  echo "END;" >> $1_ese.r

else # Partition the system

  # Save up the full def file
  mv $1_def.r mtt_all_def.r

## Recreate def file from the ese file directly
makedef ()
{

echo Creating $1_def.r

Nx=`mtt_getsize -external $1 dX`
Nz=`mtt_getsize -external $1 z`
Ny=`mtt_getsize -external $1 y`
Nu=`mtt_getsize -external $1 u`
Nui=`mtt_getsize -external $1 ui`
Nuc=`mtt_getsize -internal $1 u`

# echo Ny $Ny Nu $Nu Nx $Nx Nui $Nui Nuc $Nuc

## Definitions file
octave -q <<EOF
  deffile = '$1_def.r';
  deffilenum = fopen(deffile,'wt');

  ## Set up the structure vector
  structure = zeros(1,7);  
  structure(1) = $Nx; # States
  structure(2) = $Nz; # Non-states
  structure(3) = $Nu; # Inputs
  structure(4) = $Ny; # Outputs
  structure(5) = 0;   # Zero outputs
  structure(6) = $Nui; #Internal inputs 
  structure(7) = $Nuc; # Connecting inputs

  makedef(structure,deffilenum);  #Create definitions
EOF

echo "END;" >> $1_def.r
}


get_indices ()
{
  sys=$1
  which=$2
  gawk '{if ($1==which) print $2}' which=$which < ${sys}_struc.txt
}

convert_indices ()
{
  sys=$1
  Which="input output state"
  for which in $Which; do
  
    indices=`get_indices ${sys} $which`
  
    case $which in
      input)
  	name=u
  	;;
      output)
  	name=y
  	;;
      state)
  	name=x
  	;;
      *)
  	
    esac
  
    new=0
    for old in $indices; do
      new=`expr $new + 1`
      pattern="MTT${name}(${old},1)"
      replacement="MTT${name}(${new},1)"
      mv ${sys}_ese.r mtt_junk
      sed "s/$pattern/$replacement/" <mtt_junk >${sys}_ese.r
    done
  done
}
  # Find subsystems
  subsystems=`mtt_get_subsystems $1`

  # Top level  
  makedef $1;
  echo "END;" >> $1_ese.r

  ## Subsystems
  for subsystem in $subsystems; do
    echo Connecting $subsystem
#    Ny=`mtt_getsize -internal ${subsystem}_1 y`
#    Nu=`mtt_getsize -internal ${subsystem}_1 u`
#    Nx=`mtt_getsize -internal ${subsystem}_1 u`
#    echo Ny $Ny Nu $Nu Nx $Nx


#    echo MATRIX "MTT_"$subsystem"_uc("$Nu",1);"  >> $1_def.r

    echo >> $1_ese.r
    echo %Subsystem input connections for $subsystem  >> $1_ese.r
    octave -q <<EOF                            >> $1_ese.r
    for i=1:$Nu
      printf("MTT_%s_uc(%i,1) := %s_1_MTTu%i;\n", "$subsystem", i, "$subsystem", i);
    endfor;
EOF
  ## Subsystems (Only works when no repetitions at this level)
  esefile=${subsystem}_ese.r
  echo Creating $esefile
  mtt_xargs.sh cat "${subsystem}_1_ese.r ${subsystem}_1_*_ese.r" > $esefile 2> /dev/null
  echo "END;" >> $esefile

  ## Def file for subsystem
  makedef ${subsystem}
  
  echo Creating ${subsystem}_struc.txt
  grep $subsystem < $1_struc.txt > ${subsystem}_struc.txt

  echo Converting subsystem indices
  convert_indices ${subsystem}

  done

fi


# Create the _alised file
touch mtt_aliased.txt
echo Creating $1_aliased.txt
mv mtt_aliased.txt $1_aliased.txt

# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile

# Relabel states with multiple ports
relabel_multiple_definitions(){
  mv $structurefile junk
  gawk '
  BEGIN{
     var_type_index=1;  
     oldname="";
  }
  {
     name=$4;
     newname=name;
     if ($1==var_type) {
       if (name==oldname)
         newname = sprintf("%s_%i",name, ++var_type_index);
       else
         var_type_index=1; 
   }
     $4 = newname
     for (i=1;i<NF;i++) printf("%s\t",$i);
     printf("%s\n", $NF)
     oldname = name;
  '} < junk var_type=$1> $structurefile
}

relabel_multiple_definitions input;
relabel_multiple_definitions output;
relabel_multiple_definitions state;

# Now invoke the standard error handling.
mtt_error mtt_error.txt







Deleted mttroot/mtt/bin/trans/cbg2pcbg version [fcf7f64a42].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/bash

## Colour the reactions in the path

## Colours
blue=1
green=2
cyan=3
red=4
magenta=5
yellow=6
colour=$magenta

## Fonts
Times_Bold_Italic=3
Helvetica_Bold_Oblique=19
Helvetica_Narrow_Bold_Oblique=23
font=${Helvetica_Bold_Oblique}

sys=$1
path="$2"

cp ${sys}_cbg.fig tmp.fig
for p in $path; do
    ##echo doing $p
    sed "s/\([0-9] [0-9]\) [0-9]* \([0-9]* [0-9]*\) [0-9]* \(.*:$p.001$\)/\1 $colour \2 $font \3/" \
	< tmp.fig >TMP.fig
    mv TMP.fig tmp.fig
done

mv  tmp.fig ${sys}_pcbg.fig

Deleted mttroot/mtt/bin/trans/cbg2sese_m2r version [f1a37f79fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  2003/03/13 15:44:53  gawthrop
  ## The main transformation for sorted elementary equations
  ##
  ## Revision 1.3  2003/03/13 09:00:22  peterg
  ## Revised for new mtt_component_eqn arg list
  ##
  ## Revision 1.2  2003/03/11 10:16:03  peterg
  ## Removed NAME argument
  ##
  ## Revision 1.1  2003/03/11 10:08:49  peterg
  ## Initial revision
  ##
  ##
  ###############################################################

## cbg2seqn_m2r: Converts causal bond graph into sorted equations
## Copyright (C) 2003 by Peter J. Gawthrop

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;

	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

infofile='mtt_info.txt';
strucfile=$1_struc.txt
outfile=$1_sese.r
make=mtt_make_sese.m
CD='%%%% ====='
## Inform user
echo Creating ${outfile}

## Header
create_header() {
cat<<EOF    
$CD File ${outfile}
$CD Created by MTT on `date`

EOF
}

## Setup states etc
set_known() {
  gawk '{
  name["state"]="x";
  name["input"]="u";

  if ($1==which) {
   printf("MTT%s_%s := MTT%s(%s,1);\n", name[$1], $4, name[$1], $2);
   }
}'  which=$1 < ${strucfile}      
}

## Setup outputs, derivatives etc
set_out() {
  gawk '{
  name["state"]="dx";
  name["output"]="y";

  if ($1==which) {
   printf("MTT%s(%s,1) := MTT%s_%s;\n", name[$1], $2, name[$1], $4);
   }
}'  which=$1 < ${strucfile}      
}


## Create the octave commands for state, output etc
create_octave() {
gawk '{
  if ($1==which) {
     printf("printf(\"\\n%s The %s equation for %s\");\n", CD, $1, $4);
     printf("[known] = mtt_component_eqn\\\n");
     printf("(\"%s\",1,mtt_other_causality(\"%s\"),known,\"\",\"\");\n", $4, $6);
   }
}' "CD=${CD}" which=$1 < ${strucfile}         
}

create_octave_header() {
cat <<EOF
## Octave commands to generate sese file
## Created by mtt on `date`

known = "";

EOF
}

## Header
create_header > ${outfile}
cat >> ${outfile}<<EOF
${CD} Set up the state and input variables

EOF
which_list="state input"
for which in ${which_list}; do
    set_known ${which} >> ${outfile}
done


## Create a file of octave commands
create_octave_header > ${make}
which_list="state output"
for which in ${which_list}; do
    create_octave ${which} >> ${make}
done


## Execute the m file
octave -q < ${make} >> ${outfile}

## Tail
cat >> ${outfile}<<EOF

${CD} Set up the state derivative and output variables

EOF
which_list="state output"
for which in ${which_list}; do
    set_out ${which} >> ${outfile}
done

cat<<EOF >> ${outfile}
END;
EOF

## Print info

if [ "$info" = "info" ]; then
  cat $infofile
fi

Deleted mttroot/mtt/bin/trans/cbg_m2dia version [ddc0cb4e01].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90


























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

### cbg_m2dia
##
## Creates cbg.dia from:
## abg.dia, ibg.m, connections.dat, cbg.m
##
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

sys=$1
name=$2

## need to fix MTT to create connections.dat using make
## in the meantime:
mtt -q ${sys} connections dat

dia=${sys}_abg.dia
if [ ! -f ${dia} ]; then
    # probably not a dia model
    exit;
fi

echo Creating ${name}_cbg.dia -- component type ${sys}

con=${sys}_connections.dat
out=${name}_cbg.dia

${MATRIX:-octave} -q <<EOF > cbg_m2dia_spec.txt
ibg	= ${sys}_ibg;
cbg	= ${name}_cbg;

## get connections data: ${sys}_connections
## structure with two cell arrays: head and tail 
## the index of each array element is the bond index
## the value of each array element is a component name
load -text ${sys}_connections.dat;
con	= ${sys}_connections;

nibgbonds = length (fieldnames (ibg.bonds));
ncbgbonds = length (con.head);

## map cbg data to connection data
for [bond, bond_name] = ibg.bonds

  head = bond.head.component;
  tail = bond.tail.component;

  i = index (head, ':');
  head = substr (head, i+1, length(head)-i);

  i = index (tail, ':');
  tail = substr (tail, i+1, length(tail)-i);

  ## index of bond in diagram
  idia = str2num (strrep (bond_name, "bond", ""));

  ## find index of bond in cbg
  e(idia) = f(idia) = 0;
  for i = 1 : ncbgbonds
    if (strcmp (con.head{i}, deblank (head)) && ...
	strcmp (con.tail{i}, deblank (tail)))
      e (idia) = cbg.bonds (i, 1); # effort
      f (idia) = cbg.bonds (i, 2); # flow
   endif
  endfor
endfor

espec	= "--change_effort_causality ";
fspec	= "--change_flow_causality   ";
for i = 1 : nibgbonds
  espec = sprintf ("%s%d:%d;", espec, i, e(i));
  fspec = sprintf ("%s%d:%d;", fspec, i, f(i));
endfor
disp (espec)
disp (fspec)
EOF

spec=`cat cbg_m2dia_spec.txt`

/usr/local/src/mtt/mttroot/mtt/bin/trans/dia2abg.pl \
    --diagram_name    $sys	\
    --dia_input_file  $dia	\
    --dia_output_file $out	\
    $spec

Deleted mttroot/mtt/bin/trans/cbg_m2fig version [f290f42a19].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cbg_m2fig
#
# Causal bond graph:  mfile format to fig file format
# The resultant fig file is the original _abg.fig with
# additional causal strokes superimposed.
#
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/03/23 14:55:03  gawthrop
## Fixed cosmetic bugs -- component display
##
## Revision 1.11  2000/12/28 12:19:49  peterg
## *** empty log message ***
##
## Revision 1.10  2000/09/14 12:04:48  peterg
## New 2 parameter version
##
## Revision 1.9  1998/01/23 13:31:23  peterg
## $RMATRIX --> $MATRIX
##
## Revision 1.8  1996/12/07 19:23:07  peterg
## Registered agian.
##
# Revision 1.7  1996/11/09  19:04:34  peterg
# Removed cp $1_$1_cbg.fig $1_cbg.fig.
#
## Revision 1.6  1996/11/06 15:58:46  peterg
## Changed Matrix to RMATRIX
##
# Revision 1.5  1996/11/02  10:16:50  peterg
# Changed stroke length to 150
#
# Revision 1.4  1996/08/25  09:28:59  peter
# More error handling.
#
## Revision 1.3  1996/08/24 14:40:31  peter
## Error handling included.
##
## Revision 1.2  1996/08/08 18:07:31  peter
## Sorted out naming scheme for files
##
## Revision 1.1  1996/08/05 20:13:56  peter
## Initial revision
##
###############################################################


# Remove the old log file
rm -f cbg_m2fig.log
rm -f mtt_info.txt

# The following sets up the fig header file for the system
# and each sub system.
# (ls $1_*_cbg.m \
# | sed 's/\(.*_\)\(.*_\)cbg.m/cp \2fig.fig \1\2cbg.fig/' \
#| sh ) 2>mtt_error.txt

#sh $1_type.sh 'cp ' '_fig.fig ' '_cbg.fig'> mtt_error.txt

# Copy the unchaging part of the figure file
cat $1_head.fig $1_port.fig $1_bnd.fig $1_art.fig> $2_cbg.fig

#Inform user
echo Creating $2_cbg.fig -- component type $1

# Use  matrix manipulation to accomplish the transformation
$MATRIX   <<EOF  2>mtt_error.txt > cbg_m2fig.log

  system_type = "$1"
  system_name = "$2"

  thick = 3; length = 150; red = 4; blue = 1; green = 12; font = 18;
  cbg2fig(system_name, system_type, '', ...
          length, thick, blue, ...
          font, green, red);
EOF

#cp $1_$1_cbg.fig $1_cbg.fig 2>> mtt_error.txt

# Print errors, if any.
mtt_error mtt_error.txt

Deleted mttroot/mtt/bin/trans/cmp2cmp_m version [da616cbb8d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2cmp_m
# Revises the component file (cmp) to account for aliases.

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:20:04  peterg
## Initial revision
##
###############################################################

# Inform user
echo Revising $1_cmp.m

# Copy the alias and cmp files.
cat $1_alias.txt $1_cmp.m > junk

#Create the cmp file complete with headers.
#echo "# Component file ($1_cmp.m)" #> $1_cmp.m
#echo "# Revised by MTT at `date`" #>> $1_cmp.m

#Write out the variables 
gawk '
BEGIN{
alias_file=1
Parameter_Regexp = "^_Parameter_"
Line_Regexp = "cr|arg"
quote = "\047"
}
{
  if (alias_file) {
    if (match($1,Parameter_Regexp)>0){
      alias[$2] = $1;
      sub(Parameter_Regexp,"$",alias[$2]); # Replace by $ format
    }
  }
  else {
    if (match($1,Line_Regexp)){
      cr_or_args = substr($3,2,length($3)-3); # It it a cr or arg line
      N=split(cr_or_args,a,";"); # Split into parts
      for (i=1;i<=N;i++){
        if (a[i] in alias)       # Replace by alias
          a[i] = alias[a[i]];
      }
      cr_or_args = a[1];         # Recombine
      for (i=2;i<=N;i++)
        cr_or_args = sprintf("%s;%s", cr_or_args, a[i]);
      print   "\t" $1 "\t" $2 "\t" quote cr_or_args quote
    }
    else
      print $0
  }
  if ($1=="###_END_OF_ALIAS_###")
    alias_file=0;
}' <junk > $1_cmp.m

rm -f junk








Deleted mttroot/mtt/bin/trans/cmp2lbl_txt version [cfe16ef4bc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361









































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2lbl_txt
#
# Component list to skeleton lable file
# Hacked from (now redundent) abg2lbl_txt

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/12/06 11:45:57  gawthrop
## Strips comments from _cmp.txt before processing
##
## Revision 1.1  2002/12/01 14:54:52  gawthrop
## Replaces defunct abg2lbl_fig2txt
##
##
## Old log from abg2lbl_fig2txt
## Revision 1.28  2002/10/30 00:04:22  gawthrop
## Added AEf and AFe to list
##
## Revision 1.27  2002/05/10 09:08:55  gawthrop
## Added EMTF and INTF
## Fixed bug in writing out component headings
##
## Revision 1.26  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.25  2001/10/15 14:27:00  gawthrop
## Now handles [1:N] style port labels
##
## Revision 1.24  2001/08/02 03:24:48  geraint
## Replaced mtt_version.sh with mtt_banner.sh - I think this was the intent.
##
## Revision 1.23  2001/07/26 04:08:35  gawthrop
## Removed lines deleting _type.sh and cbg.m
##  -- how did they get there ??
##
## Revision 1.22  2001/07/08 03:28:11  gawthrop
## Fixed a bug: abg2sympar_m2txt neads a _lbl.txt file when using
## "usinglabel" option
##
## Revision 1.21  2001/07/06 00:46:50  gawthrop
## Added -cr option -- forces cr to be loaded before the ese.r file
## This avoids causality problems when using multi-port Rs to represent
## arbitary equations
##
## Revision 1.20  2001/07/04 05:19:57  gawthrop
## Added RT & CT to list
##
## Revision 1.19  2001/07/03 23:51:10  gawthrop
## Now puts outline #Summary and #Description lines at top of lbl file
##
## Revision 1.18  2001/06/13 18:24:10  gawthrop
## Made "lin" default in place of "none"
## Still needs arg and cr alias clashes to be sorted ....
##
## Revision 1.17  2001/06/13 10:41:06  gawthrop
## Further changes towards aouto creation of lbl files.
## Prettified lbl files
##
## Revision 1.16  2001/06/11 19:43:49  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.15  2001/06/11 16:53:49  gawthrop
## Now uses abg2sympar_m2txt to get the arguments
##
## Revision 1.14  2001/06/11 15:06:58  gawthrop
## Now handles user-defined components
##
## Revision 1.13  2001/06/04 08:13:37  gawthrop
## Various changes to support PPP
##
## Revision 1.12  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.11  2000/09/19 11:14:30  peterg
## Now writes the first component type header correctely
##
## Revision 1.10  2000/01/26 10:11:10  peterg
## Added I component
##
## Revision 1.9  1999/11/10 00:47:08  peterg
## Replaced ifs by a table of cr/arg information
##
## Revision 1.8  1999/11/09 22:32:41  peterg
## Under RCS ready for using arrays to contaain defaults.
##
## Revision 1.7  1998/07/04 10:37:21  peterg
## Major revision to include:
## 	aliases
## 	new Style
## 	prettyfied
##
## Revision 1.6  1998/03/05 10:09:47  peterg
## Corrected bug in writing "other" components
##
## Revision 1.5  1998/03/02 09:26:18  peterg
## Now does default CR and args for the basic components only
## SS,I,R,C,GY,TF
## C now has a default of effort input.
##
## Revision 1.4  1998/02/23 16:20:33  peterg
## Summary line just contains the model name
##
## Revision 1.3  1997/05/09 14:21:35  peterg
## Default to flow,component_name
##
# Revision 1.2  1997/03/19  12:08:01  peterg
# No longer writes out non-unique names - now done in rbg_fig2m
#
# Revision 1.1  1997/03/18  13:55:01  peterg
# Initial revision
#
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997
# Copyright (C) 2002 by Peter J. Gawthrop

infofile='mtt_info.txt'
typefile="$1_type.sh"
sensitivity=$2;
system=$1
outfile=$1_lbl.txt

if [ -n "$sensitivity" ]; then
    sys="-s ${system}"
    sensitivity_switch=" -s "
else
    sys=${system}
fi

# Remove unwanted files
rm -f abg2lbl_fig2txt.log
rm -f $infofile
rm -f mtt_junk*

## Create lbl files beneath this one
mtt -q -u -l 1 ${sys} sub sh # Create the list
sh $1_sub.sh "echo mtt -q -l 1 ${sensitivity_switch}" " lbl txt" | sh

if [ -f "$1_lbl.txt" ]; then
  ##echo "$1_lbl.txt exists in `pwd` - no action taken"
  exit
##else 
  ##echo "$1_lbl.txt dosn not exist in `pwd` "
fi

#Inform user
if [ -n "$sensitivity" ]; then
    echo "Creating ${outfile} (sensitivity version)"
else
    echo "Creating ${outfile}"
fi

write_header()

{
cat<<EOF
#SUMMARY ${system}
#DESCRIPTION Detailed description here

## System ${system}, representation lbl, language txt
## File ${system}_lbl.txt
## Generated by MTT on `date`

EOF
cat $MTT_DOC/mtt_banner.sh


}

write_blurb()
{
cat <<EOF

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----
EOF
}

create_lbl_body()
{


#Write out the outline lbl file
strip_comments <$1_cmp.txt | grep -v  '\[[0-9]*\]' | \
gawk --field-separator ':' '
 BEGIN {
    OldComponent="None";
    default_cr = "lin";
 }
(NF == 1) {
  Component = $1 " (anonymous => default parameters)";
  Name = "# " $1;
  cr[Component] = "\t";
  arg[Component] = "\t";
}
(NF > 1) { 
  Component = $1;
  Name = $2;
  Arg = $3;
}
{
##Aliases
  if (Component == "SS") {
    port_alias[++j] = Name;
    Component_type = Component;
  }
  else {
    alias[++i] = Name;
    if (length(sensitivity)>0) {
      s_arg = sprintf("%ss",Name);
      alias[++i] = s_arg;
      s_arg = sprintf(";%s",s_arg);
      Component_type = Component;
      Component = substr(Component,2);
      lin = "slin"
    }
   else {
      Component_type = Component;
      lin = "lin";
    }
  
 }

    ## Table of components
    cr["SS"] = "SS";  arg["SS"] = "external,external";

    cr["Se"] = "SS";  arg["Se"] = sprintf("external%s", s_arg);
    cr["Sf"] = "SS";  arg["Sf"] = sprintf("external%s", s_arg);

    cr["De"] = "SS";  arg["De"] = "external";
    cr["Df"] = "SS";  arg["Df"] = "external";

    cr["R"] = lin;  arg["R"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["C"] = lin;  arg["C"]  = sprintf("effort,%s%s", Name, s_arg);
    cr["I"] = lin;  arg["I"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["INTF"] = lin;  arg["INTF"]  = "";

    cr["CS"] = "lin";  arg["CS"]  = sprintf("effort,%s;%s_x0%s", Name, Name, s_arg);
    cr["IS"] = "lin";  arg["IS"]  = sprintf("flow,%s;%s_x0%s", Name, Name, s_arg);
    cr["INTFS"] = "lin";  arg["INTFS"]  = sprintf("%s_x0%s", Name, s_arg);

    cr["TF"] = "lin";  arg["TF"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["GY"] = "lin";  arg["GY"]  = sprintf("flow,%s%s", Name, s_arg);

    ##cr["EMTF"] = sprintf("%s", Name);  arg["EMTF"]  = sprintf("l%s",  s_arg);
    cr["EMTF"] = "lin";  arg["EMTF"]  = sprintf("flow,%s%s", Name, s_arg);

    cr["AE"] = "lin";  arg["AE"]  = sprintf("%s%s", Name, s_arg);
    cr["AF"] = "lin";  arg["AF"]  = sprintf("%s%s", Name, s_arg);
    cr["AEf"] = "lin";  arg["AEf"]  = sprintf("%s%s", Name, s_arg);
    cr["AFe"] = "lin";  arg["AFe"]  = sprintf("%s%s", Name, s_arg);

    cr["CDx"] = "lin";  arg["CDx"]  = sprintf("%s%s", Name, s_arg);


    cr["FMR"] = lin;  arg["FMR"]  = sprintf("effort,%s%s", Name, s_arg);

    cr["RS"] = lin;  arg["RS"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["RT"] = lin;  arg["RT"]  = sprintf("flow,%s%s", Name, s_arg);
    cr["CT"] = lin;  arg["CT"]  = sprintf("effort,%s%s", Name, s_arg);

    ## Put in the explicit arguments
    if (length(Arg)>0) {
      arg[Component] = Arg;
      if (match(Arg,"=")>0) # Its an equation type cr
        cr[Component] = "cr"
      else # assume a linear cr
        cr[Component] = "lin";
    }

  ## Print component header 
  if (Component != OldComponent) print "\n## Component type", Component_type

  ## Print Component
    printf("\t%s\t", Name);
    if (Component in cr)
      printf("%s\t\t", cr[Component])
    else 
      printf("%s\t\t", default_cr);

   if (Component in arg)
      printf("%s\t\t\n", arg[Component])
    else {
	print "lbl2args_txt2out", Component_type | "/bin/sh"; close("/bin/sh")
    }

    OldComponent=Component;
    delete arg[Component]; # Zap the element
    delete cr[Component]; # Zap the element
  }
  END{
    print "\n## Port aliases" >> "mtt_junk_alias.txt";
    for (k=1;k<=j;k++){
      if (port_alias[k] ~ "\\["){ # Only do ports
        port_name = substr(port_alias[k],2,length(port_alias[k])-2);
        if (length(sensitivity)==0)
          print "#ALIAS\t" port_name "\t" port_name >> "mtt_junk_alias.txt";
        else
          print "#ALIAS\t" port_name "\t" port_name "_1," port_name "_2" >> "mtt_junk_alias.txt";
      }
    }

#    print "\n% Argument aliases" >> "mtt_junk_alias.txt";
#    for (k=1;k<=i;k++){
#      print "%ALIAS\t\$" k "\t" alias[k] >> "mtt_junk_alias.txt";
#    }
 }' sensitivity=$sensitivity
}

create_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF
abg2sympar_m2txt ${system} ${system} use_label_file |\
gawk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
}

## Main 

create_lbl_body $1> $1_lbl.txt
create_arg_aliases > mtt_args.txt # using $1_lbl.txt
mv $1_lbl.txt mtt_junk_lbl.txt

write_header            > ${outfile}
cat mtt_junk_alias.txt >> ${outfile}
cat mtt_args.txt       >> ${outfile}
write_blurb            >> ${outfile}
cat mtt_junk_lbl.txt   >> ${outfile}

## Put a blank line at end
cat >> ${outfile} <<EOF

EOF
## Clean up
rm -f mtt_junk*





Deleted mttroot/mtt/bin/trans/cmp2sub_m2sh version [abbcf4831f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2sub_m2sh

# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2000/10/03 11:34:29  peterg
## Put in correct $MTT_LIB
##
## Revision 1.7  2000/01/18 14:22:58  peterg
## Now exits if file already exists
##
## Revision 1.6  1999/08/25 21:20:07  peterg
## Don't list components starting with 0 ot 1
##
## Revision 1.5  1996/11/09 21:09:43  peterg
## Added lib path.
##
# Revision 1.4  1996/11/03  21:19:55  peterg
# Generates generic commands in form $1name$2.
#
## Revision 1.3  1996/11/01 12:48:21  peterg
## Run mtt in quiet mode.
##
## Revision 1.2  1996/10/20 19:22:41  peterg
## Cleans up after itself.
##
## Revision 1.1  1996/10/20 19:19:50  peterg
## Initial revision
##
###############################################################

if [ -f "$1_sub.sh" ]; then
    echo Using "$1_sub.sh"
    exit
else
    #Inform user
    echo Creating $1_sub.sh    
fi


echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _cmp file
gawk '/comp_type = / {print substr($3,2,length($3)-3)}' $1_cmp.m |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Deleted mttroot/mtt/bin/trans/cmp2sub_m2txt version [1729bdb196].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makecr

# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1996/09/12 19:28:55  peter
## Added rcs header.
##
## Revision 1.4  1996/09/12 12:06:38  peter
## Removed reducndant lines.
##
## Revision 1.3  1996/09/12 12:05:01  peter
## Removed default crs.
##
## Revision 1.2  1996/09/10 16:18:37  peter
## Uses default constitutive relationship mtt/cr/r
##
## Revision 1.1  1996/08/24 14:53:06  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_cr.r

echo % Default CR file			>  $1_cr.r
echo % File $1_cr.r			>> $1_cr.r
echo % Generated by MTT on `date`.	>> $1_cr.r
echo					>> $1_cr.r
cat $MTTPATH/trans/m/rcs_header.txt	>> $1_cr.r
echo 'END;'				>> $1_cr.r








Deleted mttroot/mtt/bin/trans/cmp2sub_txt2sh version [b21f209e4e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cmp2sub_txt2sh

# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/12/06 12:26:34  gawthrop
## Strips comments from cmp.txt file
##
## Revision 1.1  2002/12/03 23:26:08  geraint
## Convert _cmp.txt to _sub.sh.
## Slightly edited copy of (obsolete) abg2sub_m2sh.
##
## Revision 1.4  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  2000/10/03 11:34:53  peterg
## Correct $MTT_LIB
##
## Revision 1.2  2000/03/17 09:53:10  peterg
## Removed irritating echo Using "$1_sub.sh"
##
## Revision 1.1  2000/03/15 21:23:20  peterg
## Initial revision
##
###############################################################


if [ -f "$1_sub.sh" ]; then
    #echo Using "$1_sub.sh"
    exit
else
    #Inform user
    echo Creating $1_sub.sh    
fi


echo '# Commands to generate subsystem representations'>  $1_sub.sh
echo "# File $1_sub.sh"			>> $1_sub.sh
echo "# Generated by MTT on `date`."	>> $1_sub.sh
echo					>> $1_sub.sh

# Get a list of all components for the _abg file
strip_comments < $1_cmp.txt | gawk -F\: '{print $1}' |\
sort -u > mtt_tmp1

# Remove all components starting with 0 or 1
grep -v '^[01]' < mtt_tmp1 > mtt_tmp4

# Get a list of all standard simple components
# echo ls $MTT_LIB/comp/simple
ls $MTT_LIB/comp/simple |\
  gawk '/_cause.m/{split($1,a,"_");print(a[1])}'  >mtt_tmp2

# Get a list of all standard compound components
#ls $MTTPATH/comp/compound |\
#  gawk '/_abg.m/{split($1,a,"_");print(a[1])}'  >> mtt_tmp2

# Sorted combined list
cat mtt_tmp2 | \
  sed  's/^zero$/0/' |\
  sed  's/^one$/1/' |\
  sort -u >mtt_tmp3

# Print the non-standard components
comm mtt_tmp4 mtt_tmp3 |\
  gawk 'BEGIN{FS="\t"}{if (length($1)>0) print "$1" $1 "$2"}' \
  >>$1_sub.sh

# Clean up mtt_tmp files
#rm -f mtt_tmp?








Deleted mttroot/mtt/bin/trans/contents.tex version [23a4ae4ea9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Contents etc for MTT documents


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 11:52:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  \tableofcontents
  \newpage
  \listoffigures
  \newpage

Deleted mttroot/mtt/bin/trans/convert_simpar.sh version [884ce541cf].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Gets rid of redundant METHOD lines.
echo Converting $1
## backup
cp $1 $1_old
sed 's/METHOD/## METHOD/'< $1_old > $1



Deleted mttroot/mtt/bin/trans/cr_txt2r version [fd5454f1e3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################


# Bourne shell script: cr_txt2r

# Label file to constitutive relationship conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2002/05/09 15:52:09  gawthrop
## Now uses current cr file is its newer than abg.m
##
## Revision 1.13  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.12  2002/04/08 17:04:21  geraint
## Removed spurious "\n" from output.
##
## Revision 1.11  2000/08/01 07:34:33  peterg
## Replaced printf by echo
##
## Revision 1.10  2000/02/25 09:10:12  peterg
## Changed -e to -f in if [ -f "$crf" ]; then
##  -- cuased probs on SUN
##
## Revision 1.9  2000/02/16 15:58:17  peterg
## Set level='' not $2
##
## Revision 1.8  1998/11/20 09:48:31  peterg
## Remove the _lower stuff -- see idf this works now.
##
## Revision 1.7  1998/04/14 17:46:28  peterg
## To avoid clashes when creating for more thsan one top level file, adds
## _lower attribute to lower lecel constitutive relationship files.
## .constitutive relationship files only in top level _constitutive
## relationship files.
##
## Revision 1.6  1998/04/14 13:54:15  peterg
## Uses the _sub.sh rep to recursively generate and include sub systems.
##
## Revision 1.5  1998/03/09 13:36:00  peterg
## Cosmetic change
##
## Revision 1.4  1998/03/06 15:54:41  peterg
## Put message bcak in in simpler form
##
## Revision 1.3  1998/03/06 15:51:06  peterg
## Zapped the irritating error message
##
## Revision 1.2  1998/03/04 15:32:53  peterg
## Major revision.
## Now just includes cr files using in"";
## Two sorts of CR:
## 	generic (.cr)
## 	tied to a system (_cr.r)
##
## Revision 1.1  1998/03/04 15:31:14  peterg
## Initial revision
##
# Revision 1.3  1997/04/09  12:59:43  peterg
# Looks for .cr file in current directory - copies from library if they
# don't already exist.
#
# Revision 1.2  1997/04/09  09:25:55  peterg
# Now copies .cr files from linrary to here (if they don't exist
# already).
#
# Revision 1.1  1997/04/09  09:08:12  peterg
# Initial revision
#
###############################################################

# The level of the recursion null at top level; _lower at lower levels.

level='' ## Used to be $2 - now set to null.

abgfile=$1_abg.m
crfile=$1_cr.r
CRFILE=$1_cr.r

if [ -f "$crfile" ]; then
    echo "Using    $crfile"
else
    # Inform user
    echo "Creating $crfile"

    echo "% Constitutive relation file for $1 ($crfile)" > $crfile
    echo "% Generated by MTT at `date`" >> $crfile

    echo  >> $crfile

    # Recursively create subsystem CR files -- at lower level
    sh $1_sub.sh 'cr_txt2r ' ' _lower' 
    
    # Include subsystem CR files
    sh $1_sub.sh 'echo ' "_cr.r" |\
    gawk '{
      print "in \"" $1 "\";"
    }'  >> $crfile

##  if [ -z "$level" ]; then

    # Copy .cr files
    gawk '{
	 if (NF>0) {
         print "mtt -q -u crcopy " $1; 
         }
    }' $1_cr.txt  | sh

    # Include the .cr files
#    gawk '{
#	 if (NF>0) {
#         print "in \"" $1 ".cr\";"
#         }
#    }' $1_cr.txt  >> $crfile

    ## list of the crs
    crs=`cat $1_cr.txt`
    for cr in $crs; do
        crf=$cr'_cr.r'
	if [ -f "$crf" ]; then
##	   printf "\045 (%s exists)\n" $crf >> $crfile
	   echo "% ($crf exists)"  >> $crfile
	else
##	   printf 'in "%s.cr";\n' $cr >> $crfile
	   echo 'in "'$cr.cr'";' >> $crfile
	fi
    done
##  fi
echo 'END;' >> $crfile

fi
# Now invoke the standard error handling.
#mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/cse2csm_r version [5225d88b5f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193

































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2csm_r
# Constrained-state equation to linear constrained-state matrices conversion
# P.J.Gawthrop  6th September 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/04/07 19:11:59  peterg
## reduce --> $SYMBOLIC
##
## Revision 1.6  2000/04/06 11:27:56  peterg
## Removed the in _cr.r
##
## Revision 1.5  1999/12/08 02:04:46  peterg
## Removed bug - uj := MTTU(j,1); not commented out
##
## Revision 1.4  1999/11/22 23:49:50  peterg
## Writes out the new MTTNx and MTTNy
##
## Revision 1.3  1999/11/22 23:38:51  peterg
## Now does scse 2 scsm as well.
## Uses mkid.
##
## Revision 1.2  1998/07/13 09:56:31  peterg
## Back under RCS for major revision
##
# Revision 1.1  1996/08/25  10:13:37  peter
# Initial revision
#
###############################################################

# Inform user
echo Creating $1_$2.r

case $2 in
    csm)
	rep=cse;
	;;
    scsm)
	rep=scse;
	;;
    *)
	echo Representation must be csm or scsm;
        exit
esac
# Remove the old log file
rm -f cse2csm_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >cse2csm_r.log << EOF

in "$1_def.r";
in "$1_$rep.r";
%%in "$1_cr.r";
%%in "$1_sympar.r";

OFF Echo;
OFF Nat;

% Get rid of the old mttx and u - now use mkid instead
clear MTTx, MTTu;

IF (MTTNx>0) THEN
BEGIN
% Find MTTA : the A matrix
matrix MTTA(MTTNx,MTTNx);

  FOR j := 1:MTTNx DO
    BEGIN
    %xj := MTTX(j,1);
    xj := mkid(MTTx,j);
    FOR i := 1:MTTNx DO
      MTTA(i,j) := df(MTTEdx(i,1), xj, 1);
    END;
END;

IF (MTTNx>0) AND (MTTNu>0) THEN
BEGIN
% Find MTTB : the B matrix
matrix MTTB(MTTNx,MTTNu);

  FOR j := 1:MTTNu DO
    BEGIN
    %uj := MTTU(j,1);
    uj := mkid(MTTu,j);
    FOR i := 1:MTTNx DO
      MTTB(i,j) := df(MTTEdx(i,1), uj, 1);
    END;
END;

IF (MTTNx>0) AND (MTTNy>0) THEN
BEGIN
% Find MTTC : the C matrix
matrix MTTC(MTTNy,MTTNx);

  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNx DO
    BEGIN
      %xj := MTTX(j,1);
      xj := mkid(MTTx,j);
      MTTC(i,j) := df(MTTY(i,1), xj, 1);
    END;
END;

IF (MTTNy>0) AND (MTTNu>0) THEN
BEGIN

% Find MTTD : the D matrix
matrix MTTD(MTTNy,MTTNu);

  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO
    BEGIN
      %uj := MTTU(j,1);
      uj := mkid(MTTu,j);
      MTTD(i,j) := df(MTTY(i,1), uj, 1);
    END;
END;

%Substitute the ss values
in "$1_sspar.r";

%Create the output file
OUT "$1_$2.r";

% Constants

write "% New constants";
write "MTTNx := ", MTTNx, ";";
write "MTTNy := ", MTTNy, ";";


%Write out the matrices.
IF MTTNx>0 THEN
BEGIN
  write "matrix MTTE(", MTTNx, ",", MTTNx, ");";
  FOR i := 1:MTTNx DO
   FOR j := 1:MTTNx DO IF MTTE(i,j) NEQ 0 THEN
      write "MTTE(", i, ",", j, ") := ", MTTE(i,j);

  write "matrix MTTA(", MTTNx, ",", MTTNx, ");";
  FOR i := 1:MTTNx DO
   FOR j := 1:MTTNx DO IF MTTA(i,j) NEQ 0 THEN
      write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
END;

IF MTTNx>0 THEN
IF MTTNu>0 THEN
BEGIN
  write "matrix MTTB(", MTTNx, ",", MTTNu, ");";
  FOR i := 1:MTTNx DO
   FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
      write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
END;

%Write it out
IF MTTNy>0 THEN
IF MTTNx>0 THEN
BEGIN
  write "matrix MTTC(", MTTNy, ",", MTTNx, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNx DO IF MTTC(i,j) NEQ 0 THEN
      write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
END;

IF MTTNy>0 THEN IF MTTNu>0 THEN 
BEGIN
  write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
      write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
END;

write "END;";

SHUT "$1_$2.r";

EOF

# Now invoke the standard error handling.
mtt_error_r cse2csm_r.log



Deleted mttroot/mtt/bin/trans/cse2ode_r version [280cac859b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2ode_r
# Reduce constrained-state equations to ode.
# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Dec 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3.4.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.3.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.3  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.2  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.1.4.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.1  2000/12/28 12:21:31  peterg
## Put under RCS
##
## Revision 1.2  1997/01/06 21:17:10  peterg
## Removed:  OFF Exp; OFF GCD;
##
## Revision 1.1  1996/08/25 10:05:45  peter
## Initial revision
##
###############################################################

optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-optimise_global )
	    optimise='-optimise_global'
	    optimise_msg=' with global optimisation' ;;
	-optimise_local )
	    optimise='-optimise_local'
	    optimise_msg=' with local optimisation' ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Create the reduce output code
def2write_r $1 ode
def2write_r $1 odeo

#Inform user
echo Creating $1_ode.r $optimise_msg
echo Creating $1_odeo.r $optimise_msg

# Remove the old log file
rm -f cse2ode_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >cse2ode_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

%Read the definitions file
in "$1_def.r";

%Read the substitution file
in "$1_subs.r";

%Read the constrained-state equations file
in "$1_cse.r";

%Read the algebraic equations file
in "$1_ae.r";

IF MTTNx>0 THEN
 IF MTTNz>0 THEN
   MTTdXX := MTTE^(-1)*MTTEdX
 ELSE
   MTTdXX := MTTEdX;

%Remove all dX terms from y - a rather nasty method, sorry!
  MTTdX1 := 0;
  MTTdX2 := 0;
  MTTdX3 := 0;
  MTTdX4 := 0;
  MTTdX5 := 0;
  MTTdX6 := 0;
  MTTdX7 := 0;
  MTTdX8 := 0;
  MTTdX9 := 0;
  MTTdX10 := 0;
  MTTdX11 := 0;
  MTTdX12 := 0;
  MTTdX13 := 0;
  MTTdX14 := 0;
  MTTdX15 := 0;
  MTTdX16 := 0;
  MTTdX17 := 0;
  MTTdX18 := 0;
  MTTdX19 := 0;
  MTTdX20 := 0;

%Substitute  dX into y;
IF MTTNz>0 THEN
  IF MTTNx>0 THEN
    MTTY := MTTY + MTTEyx*MTTdX;

OFF Echo;
OFF Nat;

MTTdX := MTTdXX;

%Write out the  ordinary differential equations.
OUT "$1_ode.r";
write "%File: $1_ode.r";
in ("$1_ode_write.r");
write "in ""$1_odeo.r"";";
write "END;";
SHUT "$1_ode.r";

%Write out the  output equations
OUT "$1_odeo.r";
write "%File: $1_odeo.r";
in ("$1_odeo_write.r");
write "END;";
SHUT "$1_odeo.r";
quit;
EOF

if [ ${optimise:-""} = "-optimise_global" ]; then
    mtt_optimise global $1 ode
    mtt_optimise global $1 odeo
elif [ ${optimise:-""} = "-optimise_local" ]; then
    mtt_optimise local $1 ode
    mtt_optimise local $1 odeo
fi

# Now invoke the standard error handling.
mtt_error_r cse2ode_r.log

Deleted mttroot/mtt/bin/trans/cse2rfe_r version [5e4feb17e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181





















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2rfe_r
# Reduce  constrained-state equations to robot matrices
# Experimental version!
# State vector should have momenta in odd rows,angles in even;
# the last row should have the gravity velocity term.
# There should be one output (only) for each joint velocity.
# P.J.Gawthrop, Nov 92, Dec 93, May 1994
# Copyright (c) P.J.Gawthrop, 1992, May 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1996/12/05 12:10:00  peterg
## Version history added.
##
###############################################################

# Inform user
echo Creating $1_rfe.r

# Remove the old log file
rm -f cse2rfe_r.log

# Use reduce to accomplish the transformation
reduce >cse2rfe_r.log << EOF

IN "$1_def.r";
IN "$1_sympar.r";
IN "$1_csm.r";
IN "$1_cse.r";

MTTN2 := MTTNy;


%Find E11 and E12 matrices
MATRIX MTTE11(MTTN2,MTTN2), MTTE12(MTTN2,MTTN2);
FOR i := 1:MTTN2 DO
  FOR j := 1:MTTN2 DO
  BEGIN
    MTTE11(i,j) := MTTE(2*i-1,2*j-1);
    MTTE12(i,j) := MTTE(2*i-1,2*j);
  END;

%Find inertia matrix
MATRIX MTTImi(MTTN2,MTTN2);
FOR i := 1:MTTN2 DO
  BEGIN
    MTTImi(i,i) := MTTC(i,2*i-1);
   END;

MTTIm := MTTImi^-1;

%Find gravity matrix if there is an extra gravity state
MATRIX MTTG(MTTN2,1);
MTTNy2 := 2*MTTNy;
IF ( (MTTNx-1)/MTTNy2 = 1) THEN
FOR i := 1:MTTN2 DO
  BEGIN
    MTTG(i,1) := MTTE(2*i-1,MTTNx);
   END;



%Find V matrix from RHS of equation
MTTu1 := 0;
MTTu2 := 0;
MTTu3 := 0;
MTTu4 := 0;
MTTu5 := 0;
MTTu6 := 0;

MTTx2 := theta_1;
MTTx4 := theta_2;
MTTx6 := theta_3;
MTTx8 := theta_4;
MTTx10 := theta_5;
MTTx12 := theta_6;

MTTx1 := dot_theta_1*MTTIm(1,1);
MTTx3 := dot_theta_2*MTTIm(2,2);
MTTx5 := dot_theta_3*MTTIm(2,3);

MATRIX MTTdt(6,1);
MTTdt(1,1) := dot_theta_1;
MTTdt(2,1) := dot_theta_2;
MTTdt(3,1) := dot_theta_3;
MTTdt(4,1) := dot_theta_4;
MTTdt(5,1) := dot_theta_5;
MTTdt(6,1) := dot_theta_6;

MATRIX dtheta(MTTN2,1);
FOR i := 1:MTTN2 DO
  BEGIN
    dtheta(i,1) := MTTdt(i,1);
   END;

MATRIX MTTVrhs(MTTN2,1);
MATRIX MTTV(MTTN2,1);
FOR i := 1:MTTN2 DO
  BEGIN
    MTTVrhs(i,1) := MTTEdX(2*i-1,1);
   END;

%Find V matrix 
MTTV := MTTE12*dtheta - MTTVrhs;

%Find C matrix
MATRIX MTTC(MTTN2,MTTN2);
k := 0;
FOR i := 1:MTTN2 DO
  FOR j := 1:MTTN2 DO
  BEGIN
  coeffs := coeff(MTTV(i,1),MTTdt(j,1));
  IF length(coeffs)>2 THEN co := part(coeffs,3) ELSE co := 0;
  MTTC(i,j) := co;
  END;

%Find B matrix
MTTN3 := MTTN2*(MTTN2-1)/2;

IF MTTN3>0 THEN
BEGIN
MATRIX MTTB(MTTN2,MTTN3);
FOR i := 1:MTTN2 DO
BEGIN
  counter := 0;
  FOR j := 1:MTTN2-1 DO
  BEGIN
  coeffs := coeff(MTTV(i,1),MTTdt(j,1));
  IF length(coeffs)>1 THEN co := part(coeffs,2) ELSE co := 0;
    FOR k := j+1:MTTN2 DO
    BEGIN 
    counter := counter+1;
    coeffs2 := coeff(co,MTTdt(k,1));
    IF length(coeffs2)>1 THEN co2 := part(coeffs2,2) ELSE co2 := 0;
     MTTB(i,counter) := co2;
    END;
  END;
END;
END;

OFF Echo;
OFF Nat;
ON NERO;

OUT "$1_rfe.r";

%% M
write "MATRIX MTTM(", MTTN2, ",", MTTN2, ")";
MTTM := MTTE11*MTTIm;

%% V
write "MATRIX MTTRV(", MTTN2, ",1)";
MTTRV := MTTV;

%% 

write "MATRIX MTTRC(", MTTN2, ",", MTTN2, ")";
MTTRC := MTTC;

IF MTTN3>0 THEN
  BEGIN
  write "MATRIX MTTRB(", MTTN2, ",", MTTN3, ")";
  MTTRB := MTTRB;
END;

write "MATRIX MTTRG(", MTTN2, ", 1)";
MTTRG := MTTG;

write ";END;"$
SHUT "$1_rfe.r";
quit;
EOF

Deleted mttroot/mtt/bin/trans/cse2scse_r version [31a5612a2e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258


































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2scse_r
# Reduce constrained-state equations to sensitivity version
# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Dec 1994
# Copyright (c) P.J.Gawthrop, 1999

# 	$Id$	

# Arguments
system=$1; 
system_def=$1_def.r
system_cse=$1_cse.r
system_scse=$1_scse.r

# Parameters
n=`echo $2 | sed 's/,/ /g' |wc -w` ## Number of parameters

## Parameter information for reduce.
parameters=`echo $2 | sed 's/,/ /g' |\
 gawk '{
   for (i=1; i<=NF; i++) {
      printf("mttpar(%i,1) := %s;\n", i, $i);
      printf("mttcoef(%i,1) := %ss;\n", i, $i);
   }
  }'`

## Update sympar list.
echo Recreating $1_sympar.txt
# Zap any sensitivity coeficients
mv $1_sympar.txt mtt_junk
grep -v MTT_Sensitivity_Coefficients mtt_junk > $1_sympar.txt

# Create the new sens coeffs at end of list.
echo $2 | sed 's/,/ /g' |\
gawk '{
   for (i=1; i<=NF; i++) {
      printf("%ss\tMTT_Sensitivity_Coefficients\n",$i);
   }
  }' >> $1_sympar.txt

touch $1_sympar.txt

matrix="matrix mttpar("$n",1); matrix mttcoef("$n",1);"

# Number of states
Nx=`grep "MTTNx " <$system_def | gawk '{print $3}' | sed 's/;//'`

#Inform user
echo Creating $system_scse "(for parameters $2, $Nx states)"

# Remove the old log file
rm -f cse2scse_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC  << EOF >cse2scse_r.log

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

%Read the definitions file
in "$system_def";

%Read the constrained-state equations file
in "$system_cse";

% Declare the parameter matrix and fill it
$matrix
$parameters
mtt_n_par := $n;

MTTNx2 := 2*MTTNx;
MTTNy2 := 2*MTTNy;

% Compute the sensitivity E matrix
matrix MTTssE(MTTNx,MTTNx);
clear MTTx; % Dont use - mkid is better

FOR ii := 1:MTTNx DO
  FOR jj := 1:MTTNx DO
  IF MTTE(ii,jj) NEQ 0 THEN IF MTTE(ii,jj) NEQ 1 THEN
  BEGIN
    % First with respect to theta...
    FOR kk := 1:mtt_n_par DO
    BEGIN
      mttpar_k := mttpar(kk,1);
      mttcoef_k := mttcoef(kk,1);
      MTTssE(ii,jj) := MTTssE(ii,jj) + df(MTTE(ii,jj), mttpar_k)*mttcoef_k;
    END;
    % then with respect to x
    FOR i := 1:MTTNx DO
    BEGIN
      xi := mkid(MTTx,i);
      sxi := mkid(MTTsx,i);
      MTTssE(ii,jj) := MTTssE(ii,jj) + df(MTTE(ii,jj), xi)*sxi;
    END;
  END;

% Compute the sensitivity of the RHS of the cse
matrix MTTssEdx(MTTNx,1);
FOR ii := 1:MTTNx DO
BEGIN 
  % First with respect to theta
    FOR kk := 1:mtt_n_par DO
    BEGIN
      mttpar_k := mttpar(kk,1);
      mttcoef_k := mttcoef(kk,1);
      MTTssEdx(ii,1) := MTTssEdx(ii,1) + df(MTTEdx(ii,1), mttpar_k)*mttcoef_k;
    END;
% Then with respect to x
  FOR i := 1:MTTNx DO
  BEGIN
    xi := mkid(MTTx,i);
    sxi := mkid(MTTsx,i);
    MTTssEdx(ii,1) := MTTssEdx(ii,1) + df(MTTEdx(ii,1), xi)*sxi;
  END; 
END; 

% Sensitivity output function
matrix MTTssY(MTTNy,1);
FOR ii := 1:MTTNy DO
BEGIN 
  % First with respect to theta
    FOR kk := 1:mtt_n_par DO
    BEGIN
      mttpar_k := mttpar(kk,1);
      mttcoef_k := mttcoef(kk,1);
      MTTssY(ii,1) := MTTssY(ii,1) + df(MTTY(ii,1), mttpar_k)*mttcoef_k;
    END;
% Then with respect to x
  FOR i := 1:MTTNx DO
  BEGIN
    xi := mkid(MTTx,i);
    sxi := mkid(MTTsx,i);
    MTTssY(ii,1) := MTTssY(ii,1) + df(MTTY(ii,1), xi)*sxi;
  END; 
END; 


% Now reorganise everything into composite system
%  - odd rows are the system 
%  - even rows are the sensitivity system
% NB at this stage, the states are numbered incorrectly - sorted out below.

%E matrix 
matrix MTTsE(MTTNx2,MTTNx2);
FOR i := 1:MTTNx DO
  FOR j := 1:MTTNx DO
  BEGIN
    MTTsE(2*i-1,2*j-1) := MTTE(i,j);  % System
    MTTsE(2*i,2*j)     := MTTE(i,j);  % Sensitivity system
    MTTsE(2*i,2*j-1)   := MTTssE(i,j);  % Sensitivity system
  END; 

%dX matrix
matrix MTTsEdX(MTTNx2,1);

FOR i := 1:MTTNx DO
BEGIN
  MTTsEdX(2*i-1,1) := MTTEdx(i,1);
  MTTsEdX(2*i,1)   := MTTssEdx(i,1);
END; 

%Y matrix
matrix MTTsY(MTTNy2,1);%dX matrix
matrix MTTsEdX(MTTNx2,1);

FOR i := 1:MTTNx DO
BEGIN
  MTTsEdX(2*i-1,1) := MTTEdx(i,1);
  MTTsEdX(2*i,1)   := MTTssEdx(i,1);
END; 


FOR i := 1:MTTNy DO
BEGIN
  MTTsY(2*i-1,1) := MTTY(i,1);
  MTTsY(2*i,1)   := MTTssY(i,1);
END; 




OFF nat;

OUT "$system_scse";

write "%File: $system_scse";

% Constants

write "% New constants";
write "MTTNx := ", MTTNx2, ";";
write "MTTNy := ", MTTNy2, ";";

% E matrix
MTT_Matrix := MTTsE$ 
MTT_Matrix_name := "MTTE"$
MTT_Matrix_n := MTTNx2$
MTT_Matrix_m := MTTNx2$
Reduce_Matrix()$

% State derivative
MTT_Matrix := MTTsEdX$ 
MTT_Matrix_name := "MTTEdX"$
MTT_Matrix_n := MTTNx2$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTsY$ 
MTT_Matrix_name := "MTTY"$
MTT_Matrix_n := MTTNy2$
MTT_Matrix_m := 1$
Reduce_Matrix()$

write "END;";

SHUT "$system_scse";
quit;
EOF

# Now invoke the standard error handling.
mtt_error_r cse2scse_r.log


## Now reorganise the  states
mv -f $system_scse mtt_junk


##echo "Nx = $Nx"
gawk '{
  ## Make sure all MTTn variables are followed by a space
  gsub(/mttx[0-9]*/, "& ");

  for (i=Nx;i>0;i--) {

    state = sprintf("mttx%i ",i);
    newstate = sprintf("mttx%i ",2*i-1);
    sstate = sprintf("mttsx%i",i);
    newsstate = sprintf("mttx%i",2*i);

    gsub(state,newstate);
    gsub(sstate,newsstate);

  }
  print $0
}' Nx=$Nx <mtt_junk > $system_scse






Deleted mttroot/mtt/bin/trans/cse2smx_lang version [a64f19c513].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232








































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2smx_lang
# Constrained-state equation to state matrices with x vector
# Used for implicit integration
# Copyright (C) 2000 by Peter J. Gawthrop
## Modified from eailier version


# Args
## Now default to matrix form
matrix='yes'
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
    -noglobals)
	noglobals='-noglobals';
	;;
    -parameters)
	parameters='-parameters';
	;;
    -matrix)
	matrix='yes';
	;;
    -optimise_global | -optimise_local )
	optimise='LOAD SCOPE; ON GENTRANOPT;';
        iname='INAME mtt_o;';
	;;
    -fixcc )
        fix_mtt_pow='FOR ALL x,y LET x^y = mtt_pow(x,y);'
        operator='OPERATOR mtt_pow;'
        blurb2='fixing c and cc code';
        unfix_mtt_pow='FOR ALL x,y CLEAR x^y;'
        unfix_pow='FOR ALL x,y LET pow(x,y) = x^y;';
		;;
    *)
	echo $1 is an unknown option
        exit;;
  esac
  shift
done

## Representation
if [ -z $1 ]; then
    echo 'usage [options] cse2smx_lang system [smx|smxa|smxax]'
    exit
fi


# Language
if [ -n "$3" ]; then
    lang=$3
else
    lang="m"
fi

## Representation
if [ -z $2 ]; then
    rep=smx;
else
    rep=$2
fi

case $rep in
    smx)
	nrep=0;
        out='[mtta,mttax]';
        nmatrix=1;
	;;
    smxa)
        nrep=1;
	if [ -n "$matrix" ]; then
          blurb="in matrix form";
          nmatrix=1;
	else
          blurb="in vector form";
          nmatrix=0;
	fi
        out='mtta';
	;;
    smxax)
	nrep=2
        out='mttax';
        nmatrix=0;
	;;
    *) echo Representation $2 not recognised;
       exit;;
esac


# Inform user
if [ -n "$optimise" ]; then
    blurbopt=' using code optimisation'
fi

echo Creating $1_$rep.$lang $blurb $blurbopt $blurb2
#echo Creating $1_smxx.$lang
#echo Creating $1_smxtx.$lang

# Remove the old log file
rm -f cse2smx_r.log
rm -f $1_smx.$lang
rm -f $1_smxx.$lang
rm -f $1_smxtx.$lang
rm -f $1_$rep.body

# Use reduce to accomplish the transformation
$SYMBOLIC << EOF  >cse2smx_lang.log

${operator} %% Define mtt_pow if needed
lang := $lang;

in "$1_subs.r";
in "$1_def.r";
in "$1_cse.r";
in "$1_cr.r";


clear mttx; % Dont need this now - use mkid instead

OFF Echo;

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'Pascal;
ON GENTRANSEG; % Segmentation

OFF GENDECS;  % No declarations
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_tmp;
%% '
% Optimise
$optimise


ON GETDECS;    % Create decrarations automatically
DEFTYPE!* := 'REAL; % and default to real

%%% The following is a bug fix  from ZIB to fix 
%%% segmentation violation problem
symbolic procedure maxtype type;
% ------------------------------------------------------------------- ;
% A type may be a pair (l u) wher l is the minimum type for a variable;
% and  u is the maximum type. This procedure returns the maximum type.;
% ------------------------------------------------------------------- ;
   if atom type
   then type
   else if pairp cdr type then cadr type else car type;

% This fix handles the case that the type is a list with ONE entry.
% Should never happen ?? W.N.
%%%%%% End of bug fix

%Set up output according to the language.
 OFF NAT;
 GENTRANOUT "$1_$rep.body";

% Set up output according to the language.
    IF (lang = r) THEN 
    BEGIN
      write "matrix mtta(", mttnx, ",", mttnx, ");";    
      write "matrix mttb(", mttnx, ",", mttnu, ");";    
      write "matrix mttc(", mttny, ",", mttnx, ");";    
      write "matrix mttd(", mttny, ",", mttnu, ");";    
    END;

 ${unfix_pow} %% set pow(x,y) to x^y

% find MTTA : the A matrix
  FOR i := 1:MTTNx DO
  BEGIN
    mttAAx_i := 0;
    FOR j := 1:MTTNx DO
    BEGIN
      ${unfix_mtt_pow} %% Revert to x^y form
      ij := i + MTTNx*(j-1);
      xj := mkid(mttx,j);
      a_ij := df(MTTEdx(i,1), xj, 1);
      aa_ij := MTTE(i,j) - mttt*a_ij;
      ${fix_mtt_pow} %% set x^y to mtt_pow(x,y)
      IF (aa_ij NEQ 0) THEN
        IF ($nmatrix EQ 1) THEN
        BEGIN
          %% Write a  with full indexing
          $iname
          GENTRAN mtta(i,j) ::=: aa_ij;
        END;
        IF (($nmatrix EQ 0) AND ($nrep EQ 1)) THEN
        BEGIN
          %% Write a  with vector indexing
          $iname
          GENTRAN mtta(ij) ::=: aa_ij;
        END;
        mttAAx_i := mttAAx_i + aa_ij*xj;
      END;
      IF (mttAAx_i NEQ 0) THEN
        IF (($nrep EQ 0) OR ($nrep EQ 2)) THEN
        BEGIN
          $iname
          GENTRAN mttax(i) ::=: mttAAx_i;
        END;


  END;

  
%Shut the  output according to the language.
 GENTRANSHUT "$1_$rep.body";
EOF

fix_broken_numbers ( ) {
    sed -e "/[0-9.]$/ N" -e "s/\([0-9.]\)[\n\t\ ]*\([0-9]\)/\1\2/g"
}

refix_pow() {
    sed 's/mtt_pow/pow/g'
}

if [ "$lang" = "m" ]; then
#  lang_header $noglobals $parameters $1 $rep m 'mttx,mttu,mttt,mttpar' $out > $1_$rep.m
  mtt_header $1 $rep m > $1_$rep.m
  cat $1_$rep.body | fix_broken_numbers | refix_pow | mtt_p2m >> $1_$rep.m
  echo "## END Code" >> $1_$rep.m
  echo "endfunction" >> $1_$rep.m
fi
 
# Now invoke the standard error handling.
mtt_error_r cse2smx_lang.log

Deleted mttroot/mtt/bin/trans/cse_r2m version [4aef2899f0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse_r2m
# Reduce constrained-state to simulab  constrained-state equations  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994.
# Copyright (c) P.J.Gawthrop 1991, 1994.

# Output must be filtered by matlab_tidy.

#Inform user
echo Creating $1_cse.m

# Remove the old log file
rm -f cse_r2m.log

# Use reduce to accomplish the transformation
reduce >cse_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  constrained-state equations   file
in "$1_cse.r";

%Read the reduce  substitution file
in "$1_subs.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
%%in "$1_sympar.r";


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
OFF Nat;

ON NERO;        % Suppress zero elements

OUT "$1_cse.m";

%Headings - Simulab style
%(Note. The ;; are deleted by for2mat)

write "function [sys,x0] = $1_cse(t,x,u,flag,xInitial);";

IF MTTNvar>0 THEN
BEGIN
  write "% Read in the parameters";
  write "global ...;;";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), " ..."
                  ELSE write MTTVar(i,1), ";"
  END;
END;


write "%Constrained-state eqns in Simulab form for system $1;;";
write "%File $1_cse.m;;";
write "%Generated by MTT;;";


write "if nargin<4; flag=0; end;";	
write "if (abs(flag) == 1) | (abs(flag) == 3)";	
write "% Set up the State variables";
FOR i := 1:MTTNx DO
BEGIN
  write "MTTx", i, " = x(", i, ");";
END;

write "% Set up the Input variables";
IF MTTNu>0 THEN
FOR i := 1:MTTNu DO
BEGIN
  write "MTTu", i, " = u(", i, ");";
END;
write "end;";

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "if abs(flag) == 1	%State derivative";

write "MTTE = zeros(", MTTNx, ",", MTTNx, ");";
MTTE := MTTE;
MTTEdx := MTTEdx;
write "sys = MTTE\MTTEdx;";

write "elseif abs(flag) == 3	%Outputs";
MTTy := MTTy;
write "sys = MTTy;";

write "elseif abs(flag) == 0	%Structure";
write "	sys = [", MTTNx, ",0,", MTTNy, ",", MTTNu, ",0,0]";
write "	if nargin<5; xInitial = zeros(", MTTNx, ",1); end;";
write "	x0  = xInitial;";
write "end;";
SHUT "$1_cse.m";

Deleted mttroot/mtt/bin/trans/cse_r2tex version [a671e2cc38].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132




































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse_r2tex
# Reduce constrained-state to LaTex constrained-state equations.
# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Jan 1995
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2000/08/24 11:48:55  peterg
## Include _subs file
##
## Revision 1.5  1999/11/22 23:44:47  peterg
## Now does scse as well
##
## Revision 1.4  1999/11/22 23:04:08  peterg
## *** empty log message ***
##
# Revision 1.3  1996/11/12  09:53:59  peterg
# Reads in the params.r file now.
#
# Revision 1.2  1996/11/12  09:11:20  peterg
# Removed all the hoorrible name changes
#
# Revision 1.1  1996/11/05  09:19:28  peterg
# Initial revision
#
###############################################################

#Inform user
echo Creating $1_$2.tex

# Remove the old log file
rm -f cse_r2tex.log

# Use reduce to accomplish the transformation
reduce >cse_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the parameter file
%%in "$1_params.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the constrained-state equations file
in "$1_$2.r";

OFF Echo;
OFF Nat;

OUT "$1_$2.tex";

%Write out the  constrained-state equations.

write "%File: $1_$2.tex";

write "%constrained-state equations";
	IF MTTNx>0 THEN
	FOR Row := 1:MTTNx DO
	BEGIN
	        write"\begin{equation}";
		write "\dot MTTEX", Row, " = ";
		write "{";
		write MTTEdX(Row,1);
		write "}";
		write"\end{equation}";
	END;



	IF MTTNy>0 THEN
	FOR Row := 1:MTTNy DO
	BEGIN
		write"\begin{equation}";
		write "MTTy", Row, " = ";
		write "{";
		write MTTy(Row,1);
		write "}";
		write"\end{equation}";
	END;


IF MTTNx NEQ 0 THEN
BEGIN
write "%  - E matrix";
write "\begin{equation}";
write "MTTE = \begin{pmatrix}";
	FOR Row := 1:MTTNx DO
	BEGIN
		FOR Col := 1:MTTNx DO
		BEGIN
			Write "{", MTTE(Row,Col), "}";
			IF Col<MTTNx THEN Write "&"
		END;

	IF Row<MTTNx THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;



%write "%  - E matrix";
%write "\begin{eqnarray}";
%	FOR Row := 1:MTTNx DO
%	BEGIN
%	  FOR Col := 1:MTTNx DO %IF MTTE(Row,Col) NEQ 0 THEN
%	  BEGIN
%	      Write "MTTE", Row, Col, " &=& {", MTTE(Row,Col), "}";
% 	      IF Row<MTTNx OR Col<MTTNx THEN Write "\cr";
%	  END;   
%	END;
%write "\end{eqnarray}";


SHUT "$1_$2.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/csm2sm_r version [f4ea164861].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162


































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: csm2sm_r
# Constrained-state equation to linear constrained-state matrices conversion
# P.J.Gawthrop  6th September 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2.4.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.2.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.2  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.1  2000/12/28 12:24:03  peterg
## Put under RCS
##
## Revision 1.2  1996/08/25 10:11:32  peter
## Added END in output file.
## Error handling.
##
## Revision 1.1  1996/08/19 15:06:16  peter
## Initial revision
##
###############################################################

optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-optimise_global )
	    optimise='-optimise_global'
	    optimise_msg=' with global optimisation' ;;
       	-optimise_local )
	    optimise='-optimise_local'
	    optimise_msg=' with local optimisation' ;;
	* )
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Create the reduce output code
def2write_r $1 $2

# Inform user
echo Creating $1_$2.r $optimise_msg

case $2 in
    sm)
        rep=csm;
        ;;
    ssm)
        rep=scsm
        ;;
    *)
        echo Representation must be sm or ssm
esac

# Remove the old log file
rm -f csm2sm_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >csm2sm_r.log << EOF

in "$1_def.r";
in "$1_$rep.r";
in "$1_cr.r";
%%in "$1_sympar.r";

OFF Echo;
OFF Nat;

% Find MTTA and MTTB : the A and B matrices

MTTinvE := MTTE^(-1);
MTTA := MTTinvE*MTTA;
MTTB := MTTinvE*MTTB;

% Create the matrix declarations
OUT "$1_$2.r1";
write "MATRIX MTTA(", MTTNx, ",", MTTNx, ")$"; 
write "MATRIX MTTB(", MTTNx, ",", MTTNu, ")$"; 
write "MATRIX MTTC(", MTTNy, ",", MTTNx, ")$"; 
write "MATRIX MTTD(", MTTNy, ",", MTTNu, ")$"; 
SHUT "$1_$2.r1";

%Create the output file
OUT "$1_$2.r2";
write "%File: $1_ode.r";

write "% New constants";
write "MTTNx := ", MTTNx, ";";
write "MTTNy := ", MTTNy, ";";

in ("$1_sm_write.r");

%Write out the matrices.
% IF MTTNx>0 THEN
% BEGIN
%   write "matrix MTTA(", MTTNx, ",", MTTNx, ");";
%   FOR i := 1:MTTNx DO
%    FOR j := 1:MTTNx DO IF MTTA(i,j) NEQ 0 THEN
%       write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
% END;

% IF MTTNx>0 THEN
% IF MTTNu>0 THEN
% BEGIN
%   write "matrix MTTB(", MTTNx, ",", MTTNu, ");";
%   FOR i := 1:MTTNx DO
%    FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
%       write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
% END;

% %Write it out
% IF MTTNy>0 THEN
% IF MTTNx>0 THEN
% BEGIN
%   write "matrix MTTC(", MTTNy, ",", MTTNx, ");";
%   FOR i := 1:MTTNy DO
%     FOR j := 1:MTTNx DO IF MTTC(i,j) NEQ 0 THEN
%       write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
% END;

% IF MTTNy>0 THEN IF MTTNu>0 THEN 
% BEGIN
%   write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
%   FOR i := 1:MTTNy DO
%     FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
%       write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
% END;

write "END;";

SHUT "$1_$2.r2";
quit;

EOF

cat $1_$2.r1 $1_$2.r2 > $1_$2.r

if [ ${optimise:-""} = "-optimise_global" ]; then
    mtt_optimise global $1 $2
elif [ ${optimise:-""} = "-optimise_local" ]; then
    mtt_optimise local $1 $2
fi

# Now invoke the standard error handling.
mtt_error_r csm2sm_r.log

Deleted mttroot/mtt/bin/trans/csm_r2m version [79de729926].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: csm_r2m
# Reduce constained state-space A,B,C,D and E matrices to Matlab
# P.J.Gawthrop July 1990, Feb 1991, May 1991, Sep 91, Dec 93, Jan 94, May 94.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1996/08/19 18:40:02  peter
## read in the nuim_par function etc.
##
## Revision 1.1  1996/08/19 16:27:04  peter
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_$2.m

# Remove the old log file
rm -f csm_r2m.log

# Use reduce to accomplish the transformation
reduce >csm_r2m.log << EOF

%Read in the definitions file
in "$1_def.r";

%Read the reduce state-space A,B,C and D matrices file
in "$1_$2.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read in the parameter file
%%in "$1_sympar.r";


OUT "$1_$2.m";

%Headings - Matlab style
%(Note. The ;; are deleted by for2mat)

IF MTTNvar>0 THEN
BEGIN
  write "function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
                  ELSE write MTTVar(i,1), ");;";
  END;
END
ELSE write "function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2;;";


IF MTTNvar>0 THEN
BEGIN
  write "%function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write "%", MTTVar(i,1), ",..."
                  ELSE write "%", MTTVar(i,1), ");;";
  END;
END
ELSE write "%function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2;;";


write "%Linearised constrained-state matrices for system $1";
write "%File $1_$2.m";
write "%Generated by MTT";

IF MTTNvar>0 THEN
BEGIN
  write "% Read in the parameters";
  write "[ ...;;";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
                  ELSE write MTTVar(i,1), "] = $1_numpar"
  END;
  write "% Read in the arguments";
  write "$1_args";
END;

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "MTTA = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTB = zeros(", MTTNx, ",", MTTNu, ");";
write "MTTC = zeros(", MTTNy, ",", MTTNx, ");";
write "MTTD = zeros(", MTTNy, ",", MTTNu, ");";
write "MTTE = zeros(", MTTNx, ",", MTTNx, ");";

ON NERO;	% Suppress zero elements.
MTTA := MTTA;
MTTB := MTTB;
MTTC := MTTC;
MTTD := MTTD;
MTTE := MTTE;

SHUT "$1_$2.m";

Deleted mttroot/mtt/bin/trans/csm_r2tex version [c5c521eb67].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: csm_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994.

# Inform user
echo Creating $1_$2.tex

# Remove the old log file
rm -f csm_r2tex.log

# Use reduce to accomplish the transformation
reduce >csm_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the constrained-state matrices file
in "$1_$2.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

OUT "$1_$2.tex";

%Write out the constrained-state matrices.
write "%constrained-state  matrices $1";
write "%File: $1_$2.tex";
write"";

write "%constrained-state matrices";

MTT_Matrix := MTTA$ 
MTT_Matrix_name := "MTTA"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB$ 
MTT_Matrix_name := "MTTB"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC$ 
MTT_Matrix_name := "MTTC"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD$ 
MTT_Matrix_name := "MTTD"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTE$ 
MTT_Matrix_name := "MTTE"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

SHUT "$1_$2.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/ctf_r2tex version [995ac3d6a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ctf_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Inform user
echo Creating $1_ctf.tex

# Remove the old log file
rm -f ctf_r2tex.log

# Use reduce to accomplish the transformation
reduce >ctf_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the smconical-form matrices file
in "$1_ctf.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_ctf.tex";

%Write out the canonical matrices
write "%Controler TF $1";
write "%File: $1_ctf.tex";
write"";

MTT_Matrix := MTTcTF$ 
MTT_Matrix_name := "MTTcTF"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNy$
Latex_Matrix()$


SHUT "$1_ctf.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/dae2cse_r version [7002845624].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542






























































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2cse_r
# Differential-algebraic equations to constrained-state equations
# P.J.Gawthrop 14 June 1991, 8 Aug 1991, 2 April 1992, 14 April 1994, 28 Dec 94
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.28  2005/09/07 17:04:12  geraint
## Fixes chi for cse representation.
##
## Revision 1.27  2005/03/21 11:50:39  gawthrop
## Don't write an empty cseo file
##
## Revision 1.26  2002/10/28 23:31:21  gawthrop
## Added additional term to MTTEdx to account for zdot terms on
## Right-Hand Side state equations
##
## Revision 1.25  2002/09/18 19:46:48  geraint
## Refined test to reduce shell loop overhead for unnecessary E matrix.
## Removed unnecessary attempt to optimise cse.
## Fixes sm representation.
##
## Revision 1.24  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.23.2.3  2002/09/12 18:50:50  geraint
## Uncommented cse optimisations - they seem to work ok.
##
## Revision 1.23.2.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.23.2.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.23  2002/07/10 17:43:05  geraint
## Added feature [ 562453 ] Optimisation of algebraic equations.
##
## Revision 1.22  2002/06/28 15:35:47  geraint
## Commented out aej.r generation (not used yet).
##
## Revision 1.21  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.20.2.1  2002/06/05 11:14:50  geraint
## ae.r now generated using def2write_r like cse?.r
## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r.
##
## Revision 1.20  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.19  2001/10/26 01:01:49  geraint
## fixcc when rdae_is_dae (-cr).
##
## Revision 1.18  2001/10/05 23:37:32  geraint
## Fixed assignment statement in ae.r when RHS=0.
##
## Revision 1.17  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.16  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.15.2.4  2001/06/26 00:55:48  geraint
## Writes algebraic equation Jacobian _aej.r (not used yet).
##
## Revision 1.15.2.3  2001/05/09 00:19:22  geraint
## Fixed EOF error when MTTNYZ=0.
##
## Revision 1.15.2.2  2001/05/05 20:50:16  geraint
## Fixed errors when MTTNx=0.
##
## Revision 1.15.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.15  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.14.2.1  2001/03/19 00:29:08  geraint
## Parse switches (-A) before calling def2write_r.
## Update $1_def.* instead of removing.
##
## Revision 1.14  2000/12/28 12:24:35  peterg
## *** empty log message ***
##
## Revision 1.13  2000/10/11 08:52:46  peterg
## Creates csex (cse with dxe only) rep.
##
## Revision 1.12  2000/10/10 21:00:58  peterg
## New code genration
##
## Revision 1.11  1998/11/26 09:18:55  peterg
## Incluse subs.r
##
## Revision 1.10  1998/11/18 13:50:29  peterg
## Removed writeing of EYz matrix
##
## Revision 1.9  1998/11/18 10:53:38  peterg
## Put in some more "IF MTTNx>0 THEN" to avoid error messages when no
## states.
##
## Revision 1.8  1998/11/10 08:54:34  peterg
## Put in "IF MTTNx>0 THEN" to prevent probs when Nx=0
##  -- still a couple of apparent error messages - but answers now
## correct
##
## Revision 1.7  1998/10/05 10:46:15  peterg
## Commented out redundant MTTY := MTTY + MTTEyx*MTTEdX;
##
## Revision 1.6  1998/07/19 12:44:35  peterg
## Set MTTYz := 0 if the array is empty - avoids irritating error
## message.
##
## Revision 1.5  1998/05/20 15:23:26  peterg
## Put MTTYz := MTTYz outsise the BEGIN/END
##
## Revision 1.4  1998/05/20 15:13:09  peterg
## Writes out algebraic equations (if any).
##
## Revision 1.3  1998/03/03 09:02:46  peterg
## Replaced MTTEyx*MTTEdX + MTTEyu*MTTdu; term
##
## Revision 1.2  1997/08/26 08:22:36  peterg
## Changed
## MTTY := MTTY + MTTEyx*MTTdX + MTTEyu*MTTdu;
## to
## MTTY := MTTY + MTTEyx*MTTEdX + MTTEyu*MTTdu;
##
## This sorts out the problem when dz appears in the output equation.
##
## Revision 1.1  1997/08/26 08:20:18  peterg
## Initial revision
##
## Revision 1.2  1996/08/25 09:57:30  peter
## Sorted out bug when MTTNz=0
##
## Revision 1.1  1996/08/15 16:47:02  peter
## Initial revision
##
###############################################################

#Explicit solution option and optimise option
solve=0; solve_msg=''
optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
        -A )
                solve=1
		solve_msg=' with explicit solution of algebraic equations' ;;
	-fixcc )
		fixcc='-fixcc'
                include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'`
                fix_msg='fixing c and cc code';
		;;
        -optimise_global )
	    optimise='-optimise_global'
	    optimise_msg=' with global optimisation' ;;
	-optimise_local )
	    optimise='-optimise_local'
	    optimise_msg=' with local optimisation' ;;
        *)
                echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Create the reduce output code
def2write_r $fixcc $1 ae 
def2write_r $fixcc $1 cse 
def2write_r $fixcc $1 csex # Version without E matrix
def2write_r $fixcc $1 cseo

echo "Creating $1_ae.r $optimise_msg"
echo "Creating $1_cse.r $solve_msg $optimise_msg $fix_msg"
echo "Creating $1_csex.r $optimise_msg"
echo "Creating $1_cseo.r $optimise_msg"

# Remove the old log file
rm -f dae2cse_r.log

# Remove some files
rm -f $1_ae.r? $1_cse.r? $1_cseo.r?

# Use reduce to accomplish the transformation
$SYMBOLIC >dae2cse_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

OFF Echo;
OFF Nat;
ON NERO;

%Fix c code if required
$include

in "$1_def.r";
MTTdxs := MTTdX;  %Save the symbolic form of dX

in "$1_subs.r";
in "$1_dae.r";


%Create F_x, F_y matrices - assumming equations are 
% linear in dZ
IF MTTNz>0 THEN 
BEGIN

IF MTTNx>0 THEN 
BEGIN

% Find MTTFx;
write "% Find MTTFx;";

matrix MTTFx(MTTNx,MTTNz);
FOR j := 1:MTTNz DO
  BEGIN
  dzj := MTTdZ(j,1);
  FOR i := 1:MTTNx DO
    MTTFx(i,j) := df(MTTdX(i,1), dzj, 1);
  END;

END;

% Find MTTFy;
write "% Find MTTFy;";

matrix MTTFy(MTTNy,MTTNz);
FOR j := 1:MTTNz DO
  BEGIN
  dzj := MTTdZ(j,1);
  FOR i := 1:MTTNy DO
    MTTFy(i,j) := df(MTTy(i,1), dzj, 1);
  END;

%Create G_x, G_u matrices 
write "%Create G_x, G_u matrices ";


% Find MTTGx;
IF MTTNx>0 THEN 
BEGIN
write "% Find MTTGx;";

matrix MTTGx(MTTNz,MTTNx);
FOR j := 1:MTTNx DO
  BEGIN
  xj := MTTX(j,1);
  FOR i := 1:MTTNz DO
    MTTGx(i,j) := df(MTTZ(i,1), xj, 1);
  END;
END;

% Find MTTGu;
write "% Find MTTGu;";

matrix MTTGu(MTTNz,MTTNu);
FOR j := 1:MTTNu DO
  BEGIN
  uj := MTTu(j,1);
  FOR i := 1:MTTNz DO
    MTTGu(i,j) := df(MTTZ(i,1), uj, 1);
  END;

%Create E matrices
write "%Create E matrices";

IF MTTNx>0 THEN 
BEGIN
matrix MTTExx(MTTNx,MTTNx); MTTExx := MTTFx*MTTGx;
matrix MTTExu(MTTNx,MTTNu); MTTExu := MTTFx*MTTGu;
matrix MTTEyx(MTTNy,MTTNx); MTTEyx := MTTFy*MTTGx;
matrix MTTE(MTTNx,MTTNx);   MTTE := MTTI - MTTExx;
END;
matrix MTTEyu(MTTNy,MTTNu); MTTEyu := MTTFy*MTTGu;




  %% The following gets rid of the dZs; there must be a better way.
  MTTdZ1 := 0;
  MTTdZ2 := 0;
  MTTdZ3 := 0;
  MTTdZ4 := 0;
  MTTdZ5 := 0;
  MTTdZ6 := 0;
  MTTdZ7 := 0;
  MTTdZ8 := 0;
  MTTdZ9 := 0;
  MTTdZ10 := 0;
  MTTdZ11 := 0;
  MTTdZ12 := 0;
  MTTdZ13 := 0;
  MTTdZ14 := 0;
  MTTdZ15 := 0;
  MTTdZ16 := 0;
  MTTdZ17 := 0;
  MTTdZ18 := 0;
  MTTdZ19 := 0;

IF MTTNx>0 THEN 
BEGIN
MTTEdX := MTTdX; %Ie MTTEdX is MTTdX with the dz terms deleted ie EdX.
MTTdX := MTTdXs;  %Restore the symbolic dX

%% Add on input derivative terms
MTTEdX := MTTEdX + MTTExu*MTTdu;
%% Add on output derivative terms
MTTEdx := MTTEdX + MTTEyx*(MTTE^(-1))*MTTEdX;
END;


%%%%%MTTY := MTTY + MTTEyx*MTTEdX;
%%% This causes the matrix mismatch
%%% MTTdXs and MTTdu need setting in _def.r file
MTTY := MTTY +  MTTEyu*MTTdu;

IF MTTNx>0 THEN 
  MTTY := MTTY + MTTEyx*(MTTE^(-1))*MTTEdX;


END; %%of MTTNz>0

IF MTTNz=0 THEN 
BEGIN
  MTTEdX := MTTdX;
  MTTE   := MTTI;
END;

IF (MTTNyz>0) AND ($solve>0) THEN
BEGIN
  %%%% Try and solve algebraic loops!!

  %Create list of the relevant equations 
  MTT_eqns := {};
  FOR i := 1:MTTNyz DO
    MTT_eqns := append(MTT_eqns,{MTTyz(i,1)});

  %Create list of the relevant unknowns
  MTT_unknowns := {};
  FOR i := 1:MTTNyz DO
    MTT_unknowns := append(MTT_unknowns,{MTTUi(i,1)});

  %Solve the algebraic equations symbolically
    MTT_sol := solve(MTT_eqns,MTT_unknowns);
  %The result seems to be in an extra list - I dont know why
  % So remove the outer list with first.
  % But only if more than one list element!

  if MTTNyz>1 THEN
    MTT_sol := first(MTT_sol);

  %Substitute back into the equations
  FOR i := 1:MTTNyz DO
  BEGIN
    MTT_sol_i := first(MTT_sol); MTT_sol := rest(MTT_sol);
    set(lhs(MTT_sol_i),rhs(MTT_sol_i));
  END;

  % No algebraic variables left!
  MTTNYz := 0;
END; % IF MTTNyz>0 and $solve

%OUT "$1_aej.r";
%IF (MTTNyz>0) THEN % as above
%BEGIN
%    WRITE "MATRIX MTTyzj(",MTTNyz,",",MTTNyz,")";
%    WRITE "%File: $1_aej.r";
%    FOR i := 1:MTTNyz DO
%	FOR j := 1:MTTNyz DO
%	BEGIN
%	   didj := df(MTTyz(i,1),mkid('mttui,j));
%	   IF (didj NEQ 0) THEN
%	      WRITE "MTTyzj(",i,",",j,") := ",didj," +0";
%	END;
%END;
%WRITE ";END;";
%SHUT "$1_aej.r";

IF MTTNyz>0 THEN % not $solve or solution failed
BEGIN
OUT "$1_ae.r1";
write "MATRIX MTTYZ(", MTTNyz, ",", 1, ")$";
SHUT "$1_ae.r1";
END;
OUT "$1_ae.r2";
write "%File: $1_ae.r";
in ("$1_ae_write.r");
write "END;";
SHUT "$1_ae.r2";

% Create the matrix declarations
OUT "$1_cse.r1";
write "%";
IF (MTTNx > 0) THEN
BEGIN
    write "MATRIX MTTEdx(", MTTNx, ",", 1, ")$"; 
    write "MATRIX MTTE(", MTTNx, ",", MTTNx, ")$"; 
END;
SHUT "$1_cse.r1";

OUT "$1_csex.r1";
write "%File:$1_csex.r1";
IF (MTTNx > 0) THEN
    write "MATRIX MTTEdx(", MTTNx, ",", 1, ")$"; 
SHUT "$1_csex.r1";

IF MTTNy>0 THEN
BEGIN
  OUT "$1_cseo.r1";
  write "MATRIX MTTY(", MTTNy, ",", 1, ")$"; 
  SHUT "$1_cseo.r1";
END;

%%Create the _cse.r file
OUT "$1_cse.r2";
write "%File: $1_cse.r";
in ("$1_cse_write.r");
write "in ""$1_cseo.r"";";
write "END;";

% % State derivative
% MTT_Matrix := MTTEdX$ 
% MTT_Matrix_name := "MTTEdX"$
% MTT_Matrix_n := MTTNx$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

% % Output
% MTT_Matrix := MTTY$ 
% MTT_Matrix_name := "MTTY"$
% MTT_Matrix_n := MTTNy$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

% % Inputs
% MTT_Matrix := MTTU$ 
% MTT_Matrix_name := "MTTU"$
% MTT_Matrix_n := MTTNu$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$
% MTT_Matrix := MTTdU$ 
% MTT_Matrix_name := "MTTdU"$
% MTT_Matrix_n := MTTNu$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

% % E matrix
% MTT_Matrix := MTTE$ 
% MTT_Matrix_name := "MTTE"$
% MTT_Matrix_n := MTTNx$
% MTT_Matrix_m := MTTNx$
% Reduce_Matrix()$

% % Eyx matrix
% MTT_Matrix := MTTEyx$ 
% MTT_Matrix_name := "MTTEyx"$
% MTT_Matrix_n := MTTNy$
% MTT_Matrix_m := MTTNx$
% %Reduce_Matrix()$

% % Yz
% MTT_Matrix := MTTYz$ 
% MTT_Matrix_name := "MTTYz"$
% MTT_Matrix_n := MTTNyz$
% MTT_Matrix_m := 1$
% Reduce_Matrix()$

write ";END;";

SHUT "$1_cse.r2";

OUT "$1_csex.r2";
write "%File: $1_cse.r";
in ("$1_csex_write.r");
write "END;";
SHUT "$1_csex.r2";

%Write out the  output equations
OUT "$1_cseo.r2";
write "%File: $1_cseo.r";
IF MTTNy>0 THEN
   in ("$1_cseo_write.r");
write "END;";
SHUT "$1_cseo.r2";
quit;
EOF

touch $1_ae.r1 $1_ae.r2
touch $1_cseo.r1
touch $1_cseo.r2
cat $1_ae.r1 $1_ae.r2 > $1_ae.r
cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ ${optimise:-""} = "-optimise_global" ]; then
    mtt_optimise global $1 ae
    mtt_optimise global $1 cseo
    mtt_optimise global $1 csex
elif [ ${optimise:-""} = "-optimise_local" ]; then
    mtt_optimise local $1 ae
    mtt_optimise local $1 cseo
    mtt_optimise local $1 csex
fi

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files"
    gawk '{
     if ($1=="MTTNyz") 
       print "MTTNyz := 0;" 
     else print $0
    }' $1_def.r > mtt_junk
  # Make sure it preserves the time stamp!!
  # and remove dependent reps
   touch -r $1_def.r mtt_junk
   mv mtt_junk $1_def.r
   for file in `ls $1_def.*`; do
      if [ $file != $1_def.r ]; then
          ext=`echo $file|gawk -F\. '{print $2}'`
          mtt -q $1 def $ext
      fi
   done
fi


# Now invoke the standard error handling.
mtt_error_r dae2cse_r.log

Deleted mttroot/mtt/bin/trans/dae2daes_m version [2d36d30236].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116




















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2daesol_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/05/14 08:14:28  peterg
## Now reads in data from the simpar file.
##
## Revision 1.5  1998/05/13 16:42:03  peterg
## Fixed various bugs etc.
##
# Revision 1.4  1996/08/24  14:27:59  peter
# Global parameters.
# Error handling.
#
## Revision 1.3  1996/08/18 12:00:19  peter
## Unified format of responses.
##
## Revision 1.2  1996/08/16 13:17:57  peter
## Changed default args to include nx+nz
## Fixed bug with vector outputs.
##
## Revision 1.1  1996/08/15 16:24:55  peter
## Initial revision
##
###############################################################


echo Creating $1_daes.m
echo Creating $1_daeso.m
rm -f dae2daes_m.log
rm -f $1_daes.m
rm -f $1_daeso.m


$MATRIX << EOF > dae2daes_m.log 2>mtt_error.txt

  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
  
  % Number of descriptor "states"
  NX = nx+2*nz+nyz;

  %Read in parameters
  $1_numpar; 
 
  %Read in state (needs redoing for descriptor xevtor
  %x = $1_state;


  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;  %Just in case its in the parameter list

  %Defaults
  if exist('T')==0
    T=[0:0.1:10]
  end;

  if exist('x0')==0
    x0 = zeros(NX,1);
  end;

  if exist('dx0')==0
   dx0 = zeros(NX,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

if NX>0
  x = dassl("$1_dae", x0, dx0,  T);
  write_matrix([T,x], '$1_daes');
else
  x = zeros(size(T));
end;

if ny>0
  i=0;
  Y = [];
  for tt=T'
    i=i+1;
    y = $1_daeo(x(i,:),tt);
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_daeso');
end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt








Deleted mttroot/mtt/bin/trans/dae2daes_m version [27f1864b05].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116




















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2daesol_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/05/14 08:14:28  peterg
## Now reads in data from the simpar file.
##
## Revision 1.5  1998/05/13 16:42:03  peterg
## Fixed various bugs etc.
##
# Revision 1.4  1996/08/24  14:27:59  peter
# Global parameters.
# Error handling.
#
## Revision 1.3  1996/08/18 12:00:19  peter
## Unified format of responses.
##
## Revision 1.2  1996/08/16 13:17:57  peter
## Changed default args to include nx+nz
## Fixed bug with vector outputs.
##
## Revision 1.1  1996/08/15 16:24:55  peter
## Initial revision
##
###############################################################


echo Creating $1_daes.m
echo Creating $1_daeso.m
rm -f dae2daes_m.log
rm -f $1_daes.m
rm -f $1_daeso.m


$MATRIX << EOF > dae2daes_m.log 2>mtt_error.txt

  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
  
  % Number of descriptor "states"
  NX = nx+2*nz+nyz;

  %Read in parameters
  $1_numpar; 
 
  %Read in state (needs redoing for descriptor xevtor
  %x = $1_state;


  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;  %Just in case its in the parameter list

  %Defaults
  if exist('T')==0
    T=[0:0.1:10]
  end;

  if exist('x0')==0
    x0 = zeros(NX,1);
  end;

  if exist('dx0')==0
   dx0 = zeros(NX,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

if NX>0
  x = dassl("$1_dae", x0, dx0,  T);
  write_matrix([T,x], '$1_daes');
else
  x = zeros(size(T));
end;

if ny>0
  i=0;
  Y = [];
  for tt=T'
    i=i+1;
    y = $1_daeo(x(i,:),tt)';
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_daeso');
end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt








Deleted mttroot/mtt/bin/trans/dae2dm_r version [ba38e9420b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333













































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae2dm_r
# Differential-algebraic equation to linear descriptor matrices conversion
# P.J.Gawthrop  8th May 1991, 7 June 1991, April 1994.
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2005/03/21 11:44:06  gawthrop
## Avoid error messages when no inputs or no outputs or no states
##
## Revision 1.3  1998/07/27 20:25:36  peterg
## *** empty log message ***
##
# Revision 1.2  1996/08/25  09:53:35  peter
# Error handling added.
#
## Revision 1.1  1996/08/18 20:03:51  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_dm.r

# Remove the old log file
rm -f dae2dm_r.log

# Use reduce to accomplish the transformation
reduce >dae2dm_r.log << EOF

in "$1_def.r";
in "$1_dae.r";
in "$1_cr.r";
%%in "$1_sympar.r";

OFF Echo;
OFF Nat;


%Total number of descriptor variables
MTTN := MTTNx + 2*MTTNz + MTTNyz;

IF MTTN>0 THEN
BEGIN
% Find MTTE : the E matrix
matrix MTTE(MTTN,MTTN);

% First row partition
IF MTTNx>0 THEN 
    FOR j := 1:MTTNx DO
      MTTE(j,j) := 1;

% Second row partition
  IF MTTNz>0 THEN 
     FOR j := 1:MTTNz DO
      MTTE(j+MTTNx, j+MTTNx) := 1;

% Find MTTA : the A matrix

% First row partition: x
IF MTTN>0 THEN 
  BEGIN
  matrix MTTA(MTTN,MTTN);
  FOR j := 1:MTTNx DO
    BEGIN
    xj := MTTX(j,1);
    FOR i := 1:MTTNx DO
      MTTA(i,j) := df(MTTdX(i,1), xj, 1);
    END;

  IF MTTNz>0 THEN 
     FOR j := 1:MTTNz DO
       BEGIN
       dzj := MTTdz(j,1);
       FOR i := 1:MTTNx DO
         MTTA(i, j + MTTNx + MTTNz) := df(MTTdX(i,1), dzj, 1);
       END;

  IF MTTNyz>0 THEN 
     FOR j := 1:MTTNyz DO
       BEGIN
       uij := MTTUi(j,1);
       FOR i := 1:MTTNx DO
         MTTA(i, j + MTTNx + 2*MTTNz) := df(MTTdX(i,1), uij, 1);
       END;
  END;

% Second row partition: z
IF MTTNz>0 THEN 
  FOR j := 1:MTTNz DO
    MTTA(j + MTTNx, j + MTTNx + MTTNz) := 1;

% Third row partition
IF MTTNz>0 THEN 
  BEGIN
  IF MTTNx>0 THEN 
  FOR j := 1:MTTNx DO
    BEGIN
    xj := MTTX(j,1);
    FOR i := 1:MTTNz DO
      MTTA(i + MTTNx + MTTNz,j) := df(MTTZ(i,1), xj, 1);
    END;

   FOR j := 1:MTTNz DO
	MTTA(j + MTTNx + MTTNz, j + MTTNx) := -1;

   FOR j := 1:MTTNz DO
     BEGIN
     dzj := MTTdz(j,1);
     FOR i := 1:MTTNz DO
       MTTA(i + MTTNx + MTTNz, j + MTTNx + MTTNz) := df(MTTZ(i,1), dzj, 1);
     END;

  IF MTTNyz>0 THEN 
     FOR j := 1:MTTNyz DO
       BEGIN
       uij := MTTUi(j,1);
       FOR i := 1:MTTNz DO
         MTTA(i+MTTNx+MTTNz, j+MTTNx+2*MTTNz) := df(MTTZ(i,1), uij, 1);
       END;
  END;


% Fourth row partition
IF MTTNyz>0 THEN 
  BEGIN
  IF MTTNx>0 THEN 
  FOR j := 1:MTTNx DO
    BEGIN
    xj := MTTX(j,1);
    FOR i := 1:MTTNyz DO
      MTTA(i + MTTNx + 2*MTTNz,j) := df(MTTYz(i,1), xj, 1);
    END;

  IF MTTNz>0 THEN 
  FOR j := 1:MTTNz DO
    BEGIN
     dzj := MTTdz(j,1);
    FOR i := 1:MTTNyz DO
      MTTA(i + MTTNx + 2*MTTNz, j + MTTNx + MTTNz) := df(MTTYz(i,1), dzj, 1);
    END;

  IF MTTNyz>0 THEN 
     FOR j := 1:MTTNyz DO
       BEGIN
       uij := MTTUi(j,1);
       FOR i := 1:MTTNyz DO
         MTTA(i+MTTNx+2*MTTNz, j+MTTNx+2*MTTNz) := df(MTTYz(i,1), uij, 1);
       END;
  END;

% Find MTTB : the B matrix

IF MTTNu>0 THEN
BEGIN
matrix MTTB(MTTN,MTTNu);

% First row partition
IF MTTNx>0 THEN 
  BEGIN
  FOR j := 1:MTTNu DO
    BEGIN
    uj := MTTU(j,1);
    FOR i := 1:MTTNx DO
      MTTB(i,j) := df(MTTdX(i,1), uj, 1);
    END;
  END;

% Third row partition
IF MTTNz>0 THEN 
  BEGIN
  FOR j := 1:MTTNu DO
    BEGIN
    uj := MTTU(j,1);
    FOR i := 1:MTTNz DO
      MTTB(i + MTTNx + MTTNz ,j) := df(MTTZ(i,1), uj, 1);
    END;
  END;

% Fourth row partition
IF MTTNyz>0 THEN 
  BEGIN
  FOR j := 1:MTTNu DO
    BEGIN
    uj := MTTU(j,1);
    FOR i := 1:MTTNyz DO
      MTTB(i + MTTNx + 2*MTTNz,j) := df(MTTYz(i,1), uj, 1);
    END;
  END;

END;

% Find MTTC : the C matrix
IF MTTNy>0 THEN
BEGIN
matrix MTTC(MTTNy,MTTN);

% First column partition
IF MTTNx>0 THEN 
  BEGIN
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNx DO
    BEGIN
      xj := MTTX(j,1);
      MTTC(i,j) := df(MTTY(i,1), xj, 1);
    END;
  END;

% Third column partition
IF MTTNz>0 THEN 
  BEGIN
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNz DO
    BEGIN
      dzj := MTTdZ(j,1);
      MTTC(i, j + MTTNx + MTTNz) := df(MTTY(i,1), dzj, 1);
    END;
  END;

% Fourth column partition
IF MTTNyz>0 THEN 
  BEGIN
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNyz DO
    BEGIN
      uij := MTTUi(j,1);
      MTTC(i, j + MTTNx + 2*MTTNz) := df(MTTY(i,1), uij, 1);
    END;
  END;

END;
END; %of MTTN>0

% Find MTTD : the D matrix
IF MTTNy>0 THEN
IF MTTNu>0 THEN
BEGIN
  matrix MTTD(MTTNy,MTTNu);
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO
    BEGIN
      uj := MTTU(j,1);
      MTTD(i,j) := df(MTTY(i,1), uj, 1);
    END;
END;

%Zap the dz terms (not a nice way)
MTTdz1 := 0;
MTTdz2 := 0;
MTTdz3 := 0;
MTTdz4 := 0;
MTTdz5 := 0;
MTTdz6 := 0;
MTTdz7 := 0;
MTTdz8 := 0;
MTTdz9 := 0;
MTTdz10 := 0;
MTTdz11 := 0;
MTTdz12 := 0;
MTTdz13 := 0;
MTTdz14 := 0;
MTTdz15 := 0;
MTTdz16 := 0;
MTTdz17 := 0;
MTTdz18 := 0;
MTTdz19 := 0;


%Substitute the ss values
in "$1_sspar.r";

%Create the output file
OUT "$1_dm.r";

%Write out the matrices.
IF MTTN>0 THEN
BEGIN
  write "matrix MTTE(", MTTN, ",", MTTN, ");";
  FOR i := 1:MTTN DO
   FOR j := 1:MTTN DO IF MTTE(i,j) NEQ 0 THEN
      write "MTTE(", i, ",", j, ") := ", MTTE(i,j);

  write "matrix MTTA(", MTTN, ",", MTTN, ");";
  FOR i := 1:MTTN DO
   FOR j := 1:MTTN DO IF MTTA(i,j) NEQ 0 THEN
      write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
END;

IF MTTN>0 THEN
IF MTTNu>0 THEN
BEGIN
  write "matrix MTTB(", MTTN, ",", MTTNu, ");";
  FOR i := 1:MTTN DO
   FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
      write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
END;

%Write it out
IF MTTNy>0 THEN
IF MTTN>0 THEN
BEGIN
  write "matrix MTTC(", MTTNy, ",", MTTN, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTN DO IF MTTC(i,j) NEQ 0 THEN
      write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
END;

IF MTTNy>0 THEN IF MTTNu>0 THEN 
BEGIN
  write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
  FOR i := 1:MTTNy DO
    FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
      write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
END;

write "END;";

SHUT "$1_dm.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r dae2dm_r.log

Deleted mttroot/mtt/bin/trans/dae2ker_r version [d1d098f9c2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
## Shell script dae2ker_r
## Converts dae to behavioral kernal rep. 


echo Creating $1_ker.r

$SYMBOLIC > dae2ker.log <<EOF

% Read the files
in "$1_dae.r";

% Substitute for the non-state derivatives
FOR i:=1:MTTNz DO
BEGIN
  set(mkid(mttdz,i),s*mttz(i,1));
END;

% Create a list algebraic equations set to zero
eq_list:={}; v_list:={};
FOR i:=1:MTTNyz DO
BEGIN
  eq_list := append(eq_list, {MTTyz(i,1)=0});
  v_list := append(v_list,{mkid(mttui,i)});
END;

eq_list; v_list;

%Solve for the "unknown" latent variables
sol := solve(eq_list,v_list);

% Substitute into the manifest variables array
FOR i:=1:MTTNy DO
BEGIN
  mtty(i,1) := sub(sol,mtty(i,1));  
END;

% Eliminate the "external" latent variables
eq_list:={}; v_list:={};
FOR i:=1:MTTNy DO
BEGIN
  u_i := mkid(mttu,i);
  w_i := mkid(mttw,i);
  eq_list := append(eq_list, {w_i=MTTy(i,1)});

  IF i>MTTNu THEN
    v_list := append({w_i},v_list)
  ELSE
    v_list := append({u_i},v_list);
END;

eq_list; v_list;
sol := solve(eq_list,v_list);
sol := first(sol);

% Pluck out the manifest variable solutions
behaviour_list:={};
FOR i:=1:(MTTNy-MTTNu) DO
BEGIN
  soli := first(sol);
  sol := rest(sol);
  behaviour := DEN(RHS(soli))*LHS(soli) - NUM(RHS(soli)) = 0;
  behaviour_list := append(behaviour_list, {behaviour});
END;
behaviour_list := behaviour_list;

MATRIX MTTR(MTTNy-MTTNu,MTTNy);
FOR i:=1:(MTTNy-MTTNu) DO
BEGIN
  FOR j:=1:MTTNy DO
  BEGIN
    w_j := mkid(mttw,j);
    coeffs := coeff(lhs(first(behaviour_list)),w_j);
    IF length(coeffs)>1 THEN
      MTTR(i,j) := second(coeff(lhs(first(behaviour_list)),w_j));
  END;
  behaviour_list := rest(behaviour_list);
END;

%% Now do coefficient matrices

OFF NAT;
OUT "$1_ker.r";
write "MATRIX MTTR(", MTTNy-MTTNu, ",", MTTNy, ");";
MTTR := MTTR;
SHUT "$1_ker.r";


EOF

Deleted mttroot/mtt/bin/trans/dae2lde_r version [b551dcb121].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lde2ode.r
# Reduce differential-algebraic equations to Lagranges equations
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2.4.3  2002/09/13 10:10:42  geraint
## Commented out optimisation.
##
## Revision 1.2.4.2  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.2.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.2  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.1  2000/12/28 12:25:13  peterg
## Initial revision
##
###############################################################

optimise=''; optimise_msg=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-optimise_global )
#	    optimise='-optimise_global'
#	    optimise_msg=' with global optimisation' ;;
	    optimise=''
	    optimise_msg='' ;;
	-optimise_local )
#	    optimise='-optimise_local'
#	    optimise_msg=' with local optimisation' ;;
	    optimise=''
	    optimise_msg='' ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Create the reduce output code
def2write_r $1 lde
def2write_r $1 ldeo

#Inform user
echo Creating $1_lde.r $optimise_msg
echo Creating $1_ldeo.r $optimise_msg

# Remove the old log file
rm -f cse2lde_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC  << EOF >cse2lde_r.log

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

%Read the definitions file
in "$1_def.r";

%Read the substitution file
in "$1_subs.r";

%Read the dae file
in "$1_dae.r";

% Zap bits we dont need
clear mttui, mttu, mttdu, mttx, mttdz;

%% The lagrangian eqns are those set to zero.
MTTL := mttyz;

% Create the second derivative of z
MATRIX mttddz(MTTNz,1);
FOR i := 1:MTTNz DO
BEGIN
  mttuii := mkid(mttui,i);
  mttdduii := mkid(mttddui,i);
  mttddz(i,1) :=  sub(mttuii=mttdduii,mttz(i,1));
END;
mttddz;

% Create Lagranges Equations
FOR j := 1:MTTNyz DO
BEGIN
  %% Create derivative of the equations by substituting:
  %du for u
  mttuj := mkid(mttu,j);
  mttduj := mkid(mttdu,j);
  MTTL :=  sub(mttuj=mttduj,MTTL);

  % dv for v
  mttuij := mkid(mttui,j);
  mttduij := mkid(mttdui,j);
  MTTL :=  sub(mttuij=mttduij,MTTL);

  % dx for x
  mttxj := mkid(mttx,j);
  MTTL :=  sub(mttxj=mttdx(j,1),MTTL);

  % ddz for dz
  mttdzj := mkid(mttdz,j);
  MTTL :=  sub(mttdzj=mttddz(j,1),MTTL);

END;

L = MTTL;

OFF Echo;
OFF Nat;


%Write out the  ordinary differential equations.
OUT "$1_lde.r";
write "%File: $1_lde.r";
in ("$1_lde_write.r");
write "in ""$1_ldeo.r"";";
write "END;";
SHUT "$1_lde.r";

%Write out the  output equations
OUT "$1_ldeo.r";
write "%File: $1_ldeo.r";
in ("$1_ldeo_write.r");
write "END;";
SHUT "$1_ldeo.r";
quit;
EOF

# TODO: edit mtt_optimise to accept lde and ldeo
# if [ ${optimise:-""} = "-optimise_global" ]; then
#     mtt_optimise global $1 lde
#     mtt_optimise global $1 ldeo
# elif [ ${optimise:-""} = "-optimise_local" ]; then
#     mtt_optimise local $1 lde
#     mtt_optimise local $1 ldeo
# fi

# Now invoke the standard error handling.
mtt_error_r cse2lde_r.log

Deleted mttroot/mtt/bin/trans/dae_r2m version [d91c90bd7e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309





















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae_r2m
# Reduce DAE to OCTAVE (DASSL) DAE  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95, Aug 97.
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1998/05/13 16:43:03  peterg
## Now uses matlab_matrix to write the matrices
## Various bug fixes
## New global generation method
##
# Revision 1.6  1997/08/28  14:07:16  peterg
# Changed MTTDx to MTTDeriv
#
# Revision 1.5  1996/08/24  14:27:29  peter
# Global parameters.
#
## Revision 1.4  1996/08/18 20:02:21  peter
## Include zero outputs.
##
## Revision 1.3  1996/08/16 13:10:53  peter
## Fixed bug Ny changed to Nx in redidual loop.
##
## Revision 1.2  1996/08/16 08:57:34  peter
## Reads $1_input.
##
## Revision 1.1  1996/08/15 16:46:06  peter
## Initial revision
##
###############################################################


# WARNING this is experimental!!
# It asumes that the output y is NOT dependent on derivatives of
#  z or u.


#Inform user
echo Creating $1_dae.m
echo Creating $1_daeo.m


# Remove the old log file
rm -f dae_r2m.log

# Remove temp. files
rm -f $1_dae.m?
rm -f $1_daeo.m?

# Use reduce to accomplish the transformation
$SYMBOLIC >dae_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  DAE   file
in "$1_dae.r";

% Matrix output function
in"$MTTPATH/trans/matlab_matrix.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
%%in "$1_sympar.r";


%% ON NERO;        % Suppress zero elements

%Define the common part of the functions.

PROCEDURE common;
BEGIN

  write "% Read in the input";
  write "u = $1_input(x,t)";

 % write "% Read in the arguments";
 % write "$1_args";
  
  write "% Set up the State variables";
  FOR i := 1:MTTNx DO
  BEGIN
    write "mttx", i, " = mttx(", i, ");";
  END;

  write "% Set up the non-state variables";
  FOR i := 1:MTTNz DO
  BEGIN
    write "mttz", i, " = mttx(", MTTNx+ i, ");";
  END;
  write "% Set up the non-state derivatives";
  FOR i := 1:MTTNz DO
  BEGIN
    write "mttdz", i, " = mttx(", MTTNx+MTTNz+ i, ");";
  END;

   write "% Set up the internal inputs";
  FOR i := 1:MTTNyz DO
  BEGIN
    write "mttui", i, " = mttx(", MTTNx+2*MTTNz+i, ");";
  END;
  
  write "% Set up the Input variables";
  IF MTTNu>0 THEN
  FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ");";
  END;
END;
  
% Firstly do the residual = f(dx,x,t) function.

% MTTGx and u are the derivatives of z wrt x and u respectively

% Find MTTGx;
if MTTNz>0 THEN
BEGIN
matrix MTTGx(MTTNz,MTTNx);
FOR j := 1:MTTNx DO
  BEGIN
  xj := MTTX(j,1);
  FOR i := 1:MTTNz DO
    MTTGx(i,j) := df(MTTZ(i,1), xj, 1);
  END;

% Find MTTGu;
matrix MTTGu(MTTNz,MTTNu);
FOR j := 1:MTTNu DO
  BEGIN
  uj := MTTu(j,1);
  FOR i := 1:MTTNz DO
    MTTGu(i,j) := df(MTTZ(i,1), uj, 1);
  END;
END;

IF MTTNz=0 THEN
BEGIN
  MTTGx := 0;
  MTTGu := 0;
  MTTz := 0;
END;

OUT "$1_dae.m1";
write "function residual = $1_dae(mttx,deriv0,t);";
write "% residuals = $1_dae(dx,x,t);";
write "%DAE in DASSL $1;;";
write "%File $1_dae.m;;";
write "%Generated by MTT;;";


common();
SHUT "$1_dae.m1";

GENTRANOUT "$1_dae.m3";
write "% State derivative";
IF MTTNX>0 THEN
BEGIN
  MTT_Matrix := MTTdX$ 
  MTT_Matrix_name := "deriv"$
  MTT_Matrix_n := MTTNx$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN deriv := mtt_matrix$
END;

IF MTTNYz>0 THEN
BEGIN
  MTT_Matrix := MTTYz$ 
  MTT_Matrix_name := "MTTYz"$
  MTT_Matrix_n := MTTNYz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTYz := mtt_matrix$
END;

if MTTNz>0 THEN
BEGIN
  MTT_Matrix := MTTz$ 
  MTT_Matrix_name := "MTTz"$
  MTT_Matrix_n := MTTNz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTz := mtt_matrix$

  MTT_Matrix := MTTGu$ 
  MTT_Matrix_name := "MTTGu"$
  MTT_Matrix_n := MTTNz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTGu := mtt_matrix$

  MTT_Matrix := MTTGu$ 
  MTT_Matrix_name := "MTTGx"$
  MTT_Matrix_n := MTTNz$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN MTTGx := mtt_matrix$

END;


SHUT "$1_dae.m3";

OUT "$1_dae.m4";
%  write "% Set up the non-state derivatives";
%  FOR i := 1:MTTNz DO
%    write "mttdz", i, " = mttderiv0(", MTTNx+ i, ");";
%  END;

write "j = 0;";

%Residual has 3 parts as follows:
%Part 1: dx/dt - dx_0/dt
if MTTNx>0 THEN
BEGIN
  write "for i=1:", MTTNx, ";;";
  write "  j = j+1";
  write "  residual(j) = deriv(i)-deriv0(j);";
  write "end;";
END;

%Part 2: dz/dt - dz_0/dt
IF MTTNz>0 THEN
BEGIN
  if MTTNx>0 THEN
    write "mttdzx = mttgx*mttdx"
  ELSE
    write "mttdzx = zeros(", MTTNz, ",1);";


  if MTTNu>0 THEN
    write "mttdzu = mttgu*mttdu"
  ELSE
    write "mttdzu = zeros(", MTTNz, ",1);";

  write "mttdz = mttdzx + mttdzu";

  write "for i=1:", MTTNz, ";;";
  write "  j = j+1";
  write "  residual(j) = mttdz(i)-mttderiv0(j);";
  write "end;";
END;

%Part 3: v=0 (the algebraic bits)
IF MTTNyz>0 THEN
BEGIN  
  write "for i=1:", MTTNyz, ";;";
  write "  j = j+1";
  write "  residual(j) = mttyz(i)";
  write "end;";
END;

SHUT "$1_dae.m4";


% Now do the y = g(x,t) function.
OUT "$1_daeo.m1";
  
write "function mtty = $1_daeo(mttx,t);";
write "% mtty = $1_daeo(mttx,t);";
write "%DAE in Simulab form for system $1;;";
write "%File $1_daeo.m;;";
write "%Generated by MTT;;";

SHUT "$1_daeo.m1";

OUT "$1_daeo.m3";
common();


%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 500$
OFF period$

MTTy := MTTy;

SHUT "$1_daeo.m3";

EOF

# Create the globals
sympar2global_txt2m $1> $1_dae.m2
sympar2global_txt2m $1> $1_daeo.m2

# Put together the pieces
cat $1_dae.m?>$1_dae.m
cat $1_daeo.m?>$1_daeo.m







Deleted mttroot/mtt/bin/trans/dae_r2tex version [ed25283fdf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193

































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dae_r2tex
# Reduce differential-algebraic to LaTex differential-algebraic equations.
# P.J.Gawthrop 10th May 1991, April 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1998/01/23 16:08:09  peterg
## changed eqnarray to equation + aligned
##
## Revision 1.3  1997/06/13 13:30:43  peterg
## Removed eqn labels.
##
# Revision 1.2  1996/12/19  10:25:15  peterg
# Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
# conversion.
#
# Revision 1.1  1996/10/21  08:50:15  peterg
# Initial revision
#
###############################################################


while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

# Inform user
echo Creating $1_dae.tex $blurb

logname=dae_r2tex.log

# Remove the old log file
rm -f dae_r2tex.log

# Use reduce to accomplish the transformation
$SYMBOLIC >$logname << EOF

%Read the definitions file
in "$1_def.r";

%Read the differential-algebraic equations file
in "$1_dae.r";

%Read the symbolic parameter file
%%in "$1_sympar.r";


OFF Echo;
OFF Nat;


%Read the substitution file
in "$1_subs.r";

%Read the simplifying expressions file
IN "$1_simp.r";

% Read the formating function
in "$MTTPATH/trans/latex_equations.r";

OUT "$1_dae.tex";

%Write out the  differential-algebraic equations.

write "%File: $1_dae.tex";

write "%differential-algebraic equations";
%ON Rounded;
%Precision 5;

latex_equations();

SHUT "$1_dae.tex";
quit;
EOF

if [ -n "$partition" ]; then
  rm -f mtt_junk
  # Now for the subsystems
  # Find subsystems
  subsystems=`mtt_get_subsystems $1`

  for subsystem in $subsystems; do
  echo Doing $subsystem
  ucname="MTT_"$subsystem"_uc"
  subsystem_dae=$subsystem"_dae"
  #subname=`echo $subsystem | mtt_remove_underscore`

  Nu=`mtt_getsize -internal $subsystem"_1" u`
  echo Nu $Nu

  # Use symbolic algebra to accomplish the transformation
  $SYMBOLIC >$logname  << EOF


  %Read the definitions file
  in "$1_def.r";
  
  
  %Read the symbolic parameter file
  %%in "$1_sympar.r";
  
  
  % Read the formating function
  in  "$MTTPATH/trans/latex_equations.r";

  OFF Echo;
  OFF Nat;
  
  
  %Read the substitution file
  in "$1_subs.r";
  
  %Read the simplifying expressions file
  IN "$1_simp.r";

  %Read the differential-algebraic equations file
  in "$1_dae.r";

  %Create the output file
  OUT "mtt_junk_1";

  % Connecting inputs
  IF $Nu>0 THEN
  BEGIN
    write "\section{Subsystem $subsystem}";

    write "\subsection{Connections}";
    write"\begin{itemize}";
  FOR Row := 1:$Nu DO
    BEGIN
  	write "\item Input ", Row, " is connected to ";
  	write $ucname(Row,1);
    END;
    write"\end{itemize}";
  END;
  SHUT "mtt_junk_1";

  %Read the differential-algebraic equations file
  in "$subsystem_dae.r";

  %Create the output file
  OUT "mtt_junk_2";
  write "\subsection{Dynamics}";
   latex_equations();
  SHUT "mtt_junk_2";

EOF
  echo >> $1_dae.tex
  echo %Connections for subsystem $subsystem >> $1_dae.tex

  # Sort out underscores and remove mtt to avoide post processor
  cat mtt_junk_1 | mtt_remove_underscore | sed 's/mtt//g'>> $1_dae.tex
  cat mtt_junk_2  >> $1_dae.tex
  rm -rf mtt_junk_?
  done
fi


# Now invoke the standard error handling.
mtt_error_r dae_r2tex.log











Deleted mttroot/mtt/bin/trans/dat22dat version [cbdbd4dbd6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat22dat
# Splits the data file into output and state bits

# Copyright (c) P.J.Gawthrop 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2000/10/17 12:24:02  peterg
## Three argument generic version
##
## Revision 1.9  2000/09/27 16:12:50  peterg
## Use expr to evaluate arithmetic - compatible with sh (as opposed to
## bash)
##
## Revision 1.8  2000/09/21 10:07:06  peterg
## Now correctely writes out the state into _odes.dat rep.
##
## Revision 1.7  2000/04/06 09:02:46  peterg
## Removed bash let commands as unsupported by sh
## Do arithmetic within awk - yuk
##
## Revision 1.6  2000/04/06 08:36:15  peterg
## *** empty log message ***
##
## Revision 1.5  1999/03/15 22:42:52  peterg
## Strip comments (put in by Octave save function)
##
## Revision 1.4  1999/03/15 21:55:36  peterg
## Does away with the # symbol in the file - uses _de to get Nx Ny
## instead
##
###############################################################
if [ -z "$1" ]; then
  echo "Usage: dat22dat system ode|odes so|s"
  exit
fi

# Find Nx and Ny
Nx=`mtt_getsize $1 x` # States
Ny=`mtt_getsize $1 y` # Outputs

case $3 in
    so)
	First=1; Last=`expr $First + $Ny`
	;;
    s)
	First=`expr $Ny + 2`; Last=`expr $First + $Nx`
	;;
    *)
	First=1; Last=`expr $Ny + 1`
        ;;
esac

echo Creating $1_$2$3.dat

gawk '{
      ## Extract the data
      if (index($1,"#") != 1){
        for (i=First;i<=Last;i++)
	  printf("%s ", $i);
      printf("\n"); 
  }
}' First=$First Last=$Last <$1_$2s.dat2  > $1_$2$3.dat

Deleted mttroot/mtt/bin/trans/dat22sg.sh version [2702996b8e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147



















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

# Convert simulation data to SciGraphica (v 0.61) Project file ($sys_odes.sg)

sys=$1

write_project_header ()
{
    cat <<EOF
<?xml version="1.0"?>

<sg:Project xmlns:sg="http://scigraphica.sourceforge.net">
  <sg:Summary>
    <sg:Item>
      <sg:name>application</sg:name>
      <sg:val-string>scigraphica</sg:val-string>
    </sg:Item>
    <sg:Item>
      <sg:name>author</sg:name>
      <sg:val-string>MTT:${USER}</sg:val-string>
    </sg:Item>
  </sg:Summary>

EOF
}

write_project_footer ()
{
    echo ''
    echo '</sg:Project>'
}

write_worksheet_header ()
{
    name=$1 ; ncol=$2 ; nrow=$3
    cat <<EOF

<sgw:Worksheet xmlns:sgw="http://scigraphica.sourceforge.net">
  <sgw:Summary>
    <sgw:Item>
      <sgw:name>application</sgw:name>
      <sgw:val-string>scigraphica</sgw:val-string>
    </sgw:Item>
    <sgw:Item>
      <sgw:name>author</sgw:name>
      <sgw:val-string>MTT:${USER}</sgw:val-string>
    </sgw:Item>
  </sgw:Summary>
  <sgw:Geometry Width="400" Height="350"/>
  <sgw:Name>${name}</sgw:Name>
  <sgw:MaxCol>${ncol}</sgw:MaxCol>
  <sgw:MaxRow>${nrow}</sgw:MaxRow>
  <sgw:Begin>-1</sgw:Begin>
  <sgw:End>-1</sgw:End>
EOF
}

write_worksheet_footer ()
{
    echo ''
    echo '</sgw:Worksheet>'
}

write_column_headings ()
{
    gawk '{ printf ("  <sgw:Column No=\"%d\" Width=\"80\" Title=\"%s\" Format=\"0\" Precision=\"3\">\n  </sgw:Column>\n", NR-1,$0) }'
}

write_output_headings ()
{
    sys=$1
    ${MATRIX} -q <<EOF | write_column_headings
	[u_names,y_names,x_names] = ${sys}_struc;
	printf ("Time\n");
	disp (y_names);
EOF
}

write_state_headings ()
{
    sys=$1
    ${MATRIX} -q <<EOF | write_column_headings
	[u_names,y_names,x_names] = ${sys}_struc;
	printf ("Time\n");
	disp (x_names);
EOF
}

write_cell_values ()
{
    sys=$1 ; vec=$2
    ${MATRIX} -q <<EOF
function write_cell (row,col,val)
    printf ("\n");
    printf ("  <sgw:Cell Row=\"%d\" Col=\"%d\">\n", row,col);
    printf ("    <sgw:Content>%f</sgw:Content>\n", val);
    printf ("    <sgw:Formula>%f</sgw:Formula>\n", val);
    printf ("  </sgw:Cell>\n");
endfunction

    [u_names,y_names,x_names] = ${sys}_struc;
    ncol = size(${vec}_names)(1);

    load ("${sys}_odes.dat2");
    nrow = size(mtt_data)(1);

    # write Time
    for r = 1:nrow
	write_cell (r-1,0,mtt_data(r,1));
    endfor

    if ("${vec}" == "y")
	offset = 1;
    elseif ("${vec}" == "x")
	offset = size(y_names)(1);
    endif

    for r = 1:nrow
	for c = 1:ncol
	    write_cell (r-1,c,mtt_data(r,c+offset));
	endfor
    endfor
EOF
}

file=${sys}_odes.sg

NX=`mtt_getsize ${sys} x`
NY=`mtt_getsize ${sys} y`
NTMP=`wc -l ${sys}_odes.dat2 | gawk '{print $1}'`
NROW=`expr ${NTMP} - 4`		# 4 comment lines in mtt_data

{
    write_project_header
    # states
    write_worksheet_header	"X_${sys}" ${NX} ${NROW}
    write_state_headings	${sys}
    write_cell_values		${sys} x
    write_worksheet_footer
    # outputs
    write_worksheet_header	"Y_${sys}" ${NY} ${NROW}
    write_output_headings	${sys}
    write_cell_values		${sys} y
    write_worksheet_footer
    write_project_footer
} > ${file}

Deleted mttroot/mtt/bin/trans/dat2gdat version [11ab5c7503].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135







































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2gdat

# Converts a data file in data format to gplot data format

# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/04/16 11:36:03  gawthrop
## These were flagged with M on cvs update
##
## Revision 1.1  2000/12/28 12:26:15  peterg
## Put under RCS
##
## Revision 1.8  1998/09/29 20:01:27  peterg
## 4th argument for nyquist style files - ie differnt x for each y
##
## Revision 1.7  1997/12/04 22:10:32  peterg
## Handles argument list - variable names.
##
## Revision 1.6  1997/05/22 10:34:05  peterg
## Changed argument structure.
##
## Revision 1.5  1997/05/22 10:11:19  peterg
## Fixed parametetr bug
##
# Revision 1.4  1997/05/16  13:03:10  peterg
# Now selects variables to display.
#
# Revision 1.3  1996/08/26  13:02:58  peterg
# Cahged awk to awk.
#
# Revision 1.2  1996/08/15  11:49:11  peter
# Puts a blank line at the end of the file:
#  this allows user to cat files for use in gnuplot.
#
## Revision 1.1  1996/08/14 09:13:52  peter
## Initial revision
##
###############################################################

echo Creating $1_$2.gdat
rm -f $1_$2.gdat

DifferentX=$4;

# Convert multi-columns into gnuplot format -
# ie stack two columns vertically separated by blank lines

#Get the desired data index
which=`name2index $1 "$3"`
echo $1 $3 $which

if [ -z "$DifferentX" ]; then
gawk '
BEGIN{
  row=0; col=0;
}
{ 
  if (row==0) {
     N=split(which,Which,",");
    }
  row++;
  j=1;
  if (Which[1]==0) {
    x[row] = $1;
    for (i=1; i<NF; i++) {
      ycol = i+1;
      y[row,j++] = $ycol;
    }
  }
  else {
  xcol = Which[1];
  x[row] = $xcol
  for (i=1; i<N; i++) {
      ycol = Which[i+1];
      y[row,j++] = $ycol;
    }
  }
  cols=j-1;
}
END {
  rows = row;
  for (col = 1; col <= cols; col++) {
    for (row = 1; row <= rows; row++) {
      print x[row], y[row,col]
    };
  if (col<=cols) {
    printf("\n")
  }
  }
}'  which="$which" <$1_$2.dat >   $1_$2.gdat

else
gawk '
BEGIN{
  row=0; col=0;
}
{ 
  row++; cols=NF/2
    for (i=1; i<=cols; i++) {
      ycol=2*i;
      xcol=ycol-1;
      x[row,i] = $xcol
      y[row,i] = $ycol;
    }
}
END {
  rows = row;
  for (col = 1; col <= cols; col++) {
    for (row = 1; row <= rows; row++) {
      print x[row,col], y[row,col]
    };
  if (col<=cols) {
    printf("\n")
  }
  }
}'   <$1_$2.dat >   $1_$2.gdat
    
fi






Deleted mttroot/mtt/bin/trans/dat2sdat version [e7c1c34fa1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2sdat

# Structure file - dat to sdat conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997, 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1.4.1  2001/06/26 00:57:21  geraint
## Prints more useful name.
##
## Revision 1.1  2000/12/28 12:26:34  peterg
## Put under RCS
##
## Revision 1.1  1999/03/28 21:29:40  peterg
## Initial revision
##
###############################################################

if [ "$2" = "odes" ]; then
    which="state"
else
    which="output"
fi

awk '
BEGIN{
printf("Time");
}
{ 
  if ($1==which)
    printf(" %s(%s)", $4, $5);
}
END{
printf("\n");
}
'  SYSTEM=$1 which=$which  < $1_struc.txt

cat $1_$2.dat



Deleted mttroot/mtt/bin/trans/dat2siag version [ce0ee2cbb1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2siag
# Converts data to siag (scheme in a grid) format - ie columns become rows.

# Data file dat to sdat conversion
# P.J.Gawthrop February 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/04/16 22:22:06  geraint
## *** empty log message ***
##
## Revision 1.1  1999/03/29 03:35:13  peterg
## Initial revision
##
###############################################################




# This is the main transformation using awk
gawk '{
    i++
    for (j=1;j<=NF;j++)
	data[i,j]=$j;
    Cols=NF;
    Rows++;
}
END{
    for (j=1;j<=Cols;j++) {
	for (i=1;i<=Rows;i++){
	    printf("%s ", data[i,j]);
	}
	printf("\n");
    }
}'


Deleted mttroot/mtt/bin/trans/def2write_r version [58e178bc16].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: def2write.r
# Generates r code to write matrices
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.16.2.3  2002/09/10 23:24:19  geraint
## Rationalised local and global optimisations.
## Fixes presentation of locally optimised code (ode view).
## Much more elegant :-)
##
## Revision 1.16.2.2  2002/09/10 22:09:14  geraint
## Fixed presentation of globally optimised equations (ode view).
##
## Revision 1.16.2.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.16  2002/09/03 19:34:15  geraint
## Write EdX regardless - csex is needed to create ode when not optimised.
##
## Revision 1.15  2002/08/29 15:45:20  geraint
## Tests for existence of matrix before entering shell loop.
## Tests for existence of expression before attempting to write or optimise.
##
## Revision 1.14  2002/08/09 14:34:45  geraint
## Fix to prevent numbers being formed with a decimal point in the exponent, Reduce cannot handle these.
##
## Revision 1.13  2002/07/10 17:43:05  geraint
## Added feature [ 562453 ] Optimisation of algebraic equations.
##
## Revision 1.12  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.11.2.1  2002/06/05 11:14:51  geraint
## ae.r now generated using def2write_r like cse?.r
## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r.
##
## Revision 1.11  2002/05/17 09:14:58  geraint
## Optimises each line in a separate session. Allows larger models to be built.
##
## Revision 1.10  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.9  2001/07/27 23:29:10  geraint
## Optimises only when requested (-opt).
##
## Revision 1.8  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.7.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.7  2001/04/11 09:44:26  gawthrop
## Fixed cc and c problems to do with pow(x,y) and integers
## mtt/lib/reduce/fix_c.r is included in rdae2dae and cse2smx_lang for
## -c, -cc and -oct options
##
## Revision 1.6  2000/11/29 20:48:53  peterg
## Zapped unnecessary Npar creation
##
## Revision 1.5  2000/11/09 10:12:24  peterg
## Removed debugging line
##
## Revision 1.4  2000/10/14 16:19:54  peterg
## Just optimize one line at a time ...
##
## Revision 1.3  2000/10/11 09:07:17  peterg
## Added csex rep (cse without E)
##
## Revision 1.2  2000/10/10 21:02:17  peterg
## Added cse reps
##
## Revision 1.1  2000/10/10 09:07:32  peterg
## Initial revision
##
###############################################################

optimise=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-fixcc )
	    include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'` ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

sys=$1 # System name
rep=$2 # System representation

# Inform User
echo Creating $1_$2_write.r

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nxx=`mtt_getsize $sys xx` # States x States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Outputs 
Nyz=`mtt_getsize $sys yz` # Zero outputs
#Npar=`wc -l $sys\_sympar.txt | gawk '{print $1}'`

# Set up representation-specific stuff
case $rep in
    ae)
	matrices='Yz'
	ns="$Nyz"
	ms="1"
	;;
    cse)
        matrices='EdX E'
        ns="$Nx $Nx"
        ms="1 $Nx"
	;;
    csex)
        matrices='EdX'
        ns="$Nx"
        ms="1"
	;;
    cseo)
        matrices='Y'
        ns="$Ny"
        ms="1"
	;;
    lde)
        matrices='L'
        ns="$Nyz"
        ms="1"
	;;
    ldeo)
        matrices='Y Yz'
        ns="$Ny $Nyz"
        ms="1 1"
	;;
    ode)
        matrices='dX'
        ns="$Nx"
        ms="1"
	;;
    odeo)
        matrices='Y'
        ns="$Ny"
        ms="1 1"
	;;
    sm)
        matrices='A B C D'
        ns="$Nx $Nx $Ny $Ny"
        ms="$Nx $Nu $Nx $Nu"
	;;
    *)
        echo def2write_r: representation $rep not recognised
        exit
esac

# Remove log files
rm -f def2write_r1.log def2write_r2.log

# Write out the code
echo "" > $1_$2_write.r

echo 'off echo$' >> $1_$2_write.r
echo 'load gentran$' >> $1_$2_write.r

for matrix in $matrices; do
    ignore_matrix="no"
    if [ "$matrix" = "E" ]; then
	matrix_exists=`grep -i MTTE ${sys}_dae.r | wc -l | gawk '{print $1}'`
	if [ ! $matrix_exists -gt 0 ]; then
	    ignore_matrix="yes"
	    n=`first "$ns"`; ns=`rest "$ns"` 
	    m=`first "$ms"`; ms=`rest "$ms"`
 	    is=`n2m 1 $n`;
	    echo "write \"% Begin Matrix MTTE\"$" >> $1_$2_write.r
	    for i in $is; do
		echo 'write'
		name=`echo MTTE'('$i','$i')'`
		echo '  '$comma$name ':=' $name '$'
	    done >> $1_$2_write.r
	    echo "write \"% End Matrix MTTE\"$" >> $1_$2_write.r
	fi
    fi
    if [ ! "$ignore_matrix" = "yes" ]; then
	n=`first "$ns"`; ns=`rest "$ns"` 
	m=`first "$ms"`; ms=`rest "$ms"`
	is=`n2m 1 $n`; 
	js=`n2m 1 $m`; 
	echo "write \"% Begin Matrix MTT${matrix}\"$" >> $1_$2_write.r
	if [ $n -ge 1 ]; then
	    for i in $is; do
		for j in $js; do
		    echo 'write'
		    name=`echo MTT$matrix'('$i','$j')'`
		    echo '  '$comma$name ':=' $name '$'
		done
	    done
	fi >> $1_$2_write.r
	echo "write \"% End Matrix MTT${matrix}\"$" >> $1_$2_write.r
    fi
done
echo ';END;'                           >>$1_$2_write.r

Deleted mttroot/mtt/bin/trans/def_r2m version [b27ff6c61a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: def_r2m
# transforms definitions from reduce to m file.
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/25 10:21:37  peterg
## Entirely rewritten
##
## Revision 1.1  1998/07/25 07:10:41  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_def.m

# Remove the old log file
rm -f def_r2m.log


# Header
cat <<EOF > $1_def.m
function  [nx,ny,nu,nz,nyz] = $1_def;
% function  [nx,ny,nu,nz,nyz] = $1_def;
% System $1, representation def, language m
% File $1_def.m;
% Generated by MTT on `date`;
%
EOF

# Constants
Nx=`grep "MTTNx " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Ny=`grep "MTTNy " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nu=`grep "MTTNu " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nz=`grep "MTTNz " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
Nyz=`grep "MTTNyz " <$1_def.r | gawk '{print $3}' | sed 's/;//'`


cat<<EOF >> $1_def.m 
  nx = $Nx;
  ny = $Ny;
  nu = $Nu;
  nz = $Nz;
  nyz = $Nyz;
EOF

Deleted mttroot/mtt/bin/trans/dia2abg.pl version [c5d3faf6c4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571



























































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/usr/bin/perl -w

#----------------------------------------------------------------------------
# dia2abg.pl
# Copyright (C) 2002; David Hoover.
# Modified      2004  Geraint Bevan.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# 
# The GNU General Public License should be found in the file license.txt.
# For more information about free software, visit http://www.fsf.org/
#----------------------------------------------------------------------------

#############################################################################
# Given a DIA diagram, the script has functions that perform the following
# MTT (model transformation tools) functions:
# 1. Write a _cmp.txt file containing component types:names
# 2. Write a _ibg.m file containing an acausal bond graph suitable for 
#    processing by MTT.
# 3. Modify a diagram by changing causality as desired.
#############################################################################

#----------------------------------------------------------------------------
# Dia uses a unique id for each object.
# get_component_data and get_bond_data read the xml file and collect
# important information about component and bond id's, component
# names, and bond connectivity.  These data structures are described here:

# The %component_id_tag hash provides component names and types:
#
# key=component_id
# value=component type:name

# 'start' ALWAYS refers to dia's interpretation of start.  This means,
# when you draw a line or an arrow, 'start' is the point where you
# initally press down the mouse button.  'end' is the point where you
# release the mouse button.  'start' and 'end' have nothing to do with
# a bond's direction.  A half arrow could be on a dia 'start' or 'end'
# point.

# The %bond_id_start_id and %bond_id_end_id hashes provides
# connectivity info for line start points and end points:
#
# key=bond_id
# value=component_id

# The %bond_id_arrow_on_start hash is a boolean that indicates whether
# the power arrow (half head) is on the dia line start point.
#
# key=bond_id
# value=boolean arrow_on_start

# The %bond_id_effort_causality hash is a boolean that provides the
# effort arrow-oriented causality.
#
# key=bond_id
# value=arrow-oriented effort causality.

# The %bond_id_flow_causality hash is a boolean that provides the
# flow arrow-oriented causality.
#
# key=bond_id
# value=arrow-oriented flow causality.

# %mtt_bond_id_index provides a unique positive integer index for each
# Dia bond ID.  The index is written to the ibg.m file for mtt.

# The %component_id_type, %component_id_name, %component_id_reps hashes
# store the information from _cmp.m for each component
#
# key=component_id
# value=component type, name or number of repetitions

#----------------------------------------------------------------------------

#----------------------------MAIN PROGRAM------------------------------------
use strict;
use Getopt::Long;
use XML::DOM;

my (%component_id_tag, %bond_id_start_id, %bond_id_end_id,
    $objects, %mtt_bond_id_index,
    %bond_id_arrow_on_start, %bond_id_flow_causality, %bond_id_effort_causality,
    %bond_id_start_label,%bond_id_end_label);

my (%component_id_type, %component_id_name, %component_id_reps);

# Parse user options:
my $diagram_name		= '';
my $dia_input_file		= '';
my $dia_output_file		= '';
my $component_list_file		= '';
my $debug			= 0;
my $create_component_list	= 0;
my $create_ibg			= 0;
my $ibg_file			= '';
my $change_flow_causality	= '';
my $change_effort_causality	= '';
GetOptions ('diagram_name=s'		=> \$diagram_name,
	    'dia_input_file=s'		=> \$dia_input_file,
	    'dia_output_file=s'		=> \$dia_output_file,
	    'component_list_file=s'	=> \$component_list_file,
	    'debug'			=> \$debug,
	    'create_component_list'	=> \$create_component_list,
	    'create_ibg'		=> \$create_ibg,
	    'ibg_file=s'		=> \$ibg_file,
	    'change_flow_causality=s'	=> \$change_flow_causality,
	    'change_effort_causality=s'	=> \$change_effort_causality,
	    );

die usage() if $diagram_name eq '';

# Use defaults if necessary:
$dia_input_file      = $diagram_name . "_abg.dia" if ($dia_input_file      eq '');
$dia_output_file     = $diagram_name . "_cbg.dia" if ($dia_output_file     eq '');
$ibg_file            = $diagram_name . "_ibg.m"   if ($ibg_file            eq '');
$component_list_file = $diagram_name . "_cmp.txt" if ($component_list_file eq '');

# Start Parsing XML, and creating files:
my $dom = new XML::DOM::Parser;
my ($doc);

$doc = $dom->parsefile($dia_input_file);
$objects = get_objects_node($doc,"Bond Graph");

get_component_data($objects);
parse_component_data();

get_bond_data($objects);

create_component_list() if ($create_component_list);

if ($create_ibg) {
    open (OUT,">$ibg_file") ||
	die "Cannot open $ibg_file for writing.\n";
    output_ibg();
    
}   

if ($change_flow_causality ne '' || $change_effort_causality ne '') {
    open (DIA_OUT,">$dia_output_file") ||
	die "Cannot open $dia_output_file for writing.\n";
    print DIA_OUT $doc->toString;
    close DIA_OUT;
}

exit 0;


#----------------------------SUBROUTINES-------------------------------------
sub create_component_list {
    my ($type, $name);

    print_debug("CREATING unique_raw_list...\n");
    open (RAW,">$component_list_file") ||
	die "Cannot open $component_list_file for writing.\n";

    my (%reverse_component_id_tag) = reverse (%component_id_tag);
    foreach my $val (sort values(%component_id_tag)) {	
	my ($id, $type);
	$id = $reverse_component_id_tag{$val};
	$type = $component_id_type{$id};
	$_ = $val;
	id_cleaner();
	$val =  $_;
	print RAW $val . "\n";
    }
    close(RAW);
}

sub get_objects_node {
    my ( $doc_node, $layer_name )= @_;
    my ($root,$layer_node,$objects);

    $root = get_first_element_subnode($doc_node);
    die "could not find top-level element dia_diagram.\n"
	unless $root->getTagName eq 'dia:diagram';
    
    $layer_node = get_first_subnode_by_nodename_attribute(0,$root,"dia:layer","name",$layer_name);
    die "I found no dia:layer named $layer_name.  Are you sure the diagram has one?\n" unless
	$layer_node->getTagName eq 'dia:layer' &&
	$layer_node->getAttributeNode("name")->getValue eq $layer_name;
    
    $objects = $layer_node->getElementsByTagName('dia:object');

    return $objects;
}

sub output_ibg_header {
    my ($date);
    $date = `date`; chomp($date);

    print OUT <<"EOF";
## -*-octave-*- put Emacs into Octave mode

function [${diagram_name}] =  ${diagram_name}_ibg

  ## Intermediate bond graph representation of $diagram_name
  ## Generated by MTT on $date

  ## head refers to the harpoon end of a bond
  ## tail refers to the other end of a bond
  ## causality.? is the end at which ? is imposed


EOF
}

sub output_ibg_footer {
    print OUT <<"EOF";
endfunction
EOF
}

sub output_ibg {
    my ($key,$component,$type,$name,
	%reverse_mtt_bond_id_index,$mtt_bond_id,$dia_bond_id,
	@bonds,
	$bond_id,$start,$end,$id,
	$head,$head_component,$head_type,$head_name,
	$tail,$tail_component,$tail_type,$tail_name,
	$start_label,$end_label,
	$head_label,$tail_label,
	$effort_causality,$flow_causality);

    output_ibg_header();

    %reverse_mtt_bond_id_index = reverse (%mtt_bond_id_index);

    @bonds = (sort keys (%reverse_mtt_bond_id_index));
    foreach $mtt_bond_id (@bonds) {
 
	$dia_bond_id = $reverse_mtt_bond_id_index{$mtt_bond_id};

	$start = $bond_id_start_id{$dia_bond_id};
	$end   = $bond_id_end_id  {$dia_bond_id};

	if ($bond_id_arrow_on_start{$dia_bond_id}) {
	    $head = $end;
	    $tail = $start;
	} else {
	    $head = $start;
	    $tail = $end;
	}

	$start_label = $bond_id_start_label{$dia_bond_id};
	$end_label   = $bond_id_end_label  {$dia_bond_id};

	# treat label as a comment if not enclosed by [ ]
	if ($start_label !~  /\[.*\]/) {
	    $start_label = "[]";
	}
	if ($end_label !~ /\[.*\]/) {
	    $end_label = "[]";
	}

	if ($bond_id_arrow_on_start{$dia_bond_id}) {
	    $head_label = $end_label;
	    $tail_label = $start_label;
	} else {
	    $head_label = $start_label;
	    $tail_label = $end_label;
	}

	$head_component = "$component_id_type{$head}:$component_id_name{$head}";
	$tail_component = "$component_id_type{$tail}:$component_id_name{$tail}";

	$effort_causality = $bond_id_effort_causality{$dia_bond_id};
	$flow_causality   = $bond_id_flow_causality  {$dia_bond_id};

	for ($effort_causality) {
	    if (/-1/) { $effort_causality = "tail";}
	    if (/0/) { $effort_causality = "none";}
	    if (/1/) { $effort_causality = "head";}
	}
	for ($flow_causality) {
	    if (/-1/) { $flow_causality = "head";}
	    if (/0/) { $flow_causality = "none";}
	    if (/1/) { $flow_causality = "tail";}
	}
		       
	print OUT
	    "  ## bond $mtt_bond_id \n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "head.component = \"${head_component}\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "tail.component = \"${tail_component}\";\n";

	print OUT
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "head.ports = \"$head_label\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "tail.ports = \"$tail_label\";\n";

	print OUT
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "causality.effort = \"$effort_causality\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "causality.flow = \"$flow_causality\";\n\n";
    }
    
    output_ibg_footer();
}

sub get_component_data {
    my ( $objects_node )= @_;
    my($obj,$id,$attr,$comp,$strattr,$str_elem,$string);

    print_debug("READING COMPONENTS FROM $dia_input_file...\n");
    for my $i (0..$objects_node->getLength-1) {
      $obj = $objects_node->item($i);
      next if ($obj->getAttributeNode("type")->getValue ne "BondGraph - MTT port");
      
      $id = $obj->getAttributeNode("id")->getValue;
      print_debug($id . "\n");
      
      $attr = get_first_subnode_by_nodename_attribute(0,$obj,"dia:attribute","name","text");
      $comp = get_first_subnode_by_nodename_attribute(0,$attr,"dia:composite","type","text");
      $strattr = get_first_subnode_by_nodename_attribute(0,$comp,"dia:attribute","name","string");
      $str_elem = get_first_element_subnode($strattr);
      $string = get_first_text_subnode($str_elem);
      $component_id_tag{$id} = $string->getData;
  }
    die "There are no components!\n" unless keys(%component_id_tag) > 0;
}

sub parse_component_data {
    my (%anon_index, $id, $component);

    while (($id, $component) = each (%component_id_tag)) {
	$_ = $component;
	id_cleaner();
	$component = $_;
	my ($type_name, $repetitions) = split (/\*/, $component);
	if (! $repetitions) {
	    $type_name = $component;
	    $repetitions = 1;
	}
	my ($type, $name) = split (/:/, $type_name);
	if (! $name) {
	    $type = $type_name;
	    if (! defined ($anon_index{$type})) {
		$anon_index{$type} = 1;
		$name = "mtt${type}";
	    } else {
		my $num = ++$anon_index{$type};
		$name = "mtt${type}_${num}";
	    }
	}
	$component_id_type{$id} = $type;
	$component_id_name{$id} = $name;
	$component_id_reps{$id} = $repetitions;
    }
}

# Dia stores its attributes in a strange way, not using typical xml attributes.
sub get_dia_attribute_value {
    my ($type, $attribute_node )= @_;
    my ($subnode);
    $subnode = get_first_subnode_by_nodename_attribute(0,$attribute_node,$type);

    return $subnode->getAttributeNode("val")->getValue;
}

# Dia stores its attributes in a strange way, not using typical xml attributes.
sub set_dia_attribute_value {
    my ($type, $attribute_node, $new_value )= @_;
    my ($subnode);
    $subnode = get_first_subnode_by_nodename_attribute(0,$attribute_node,$type);

    $subnode->setAttribute(val => $new_value);
#    return $subnode->getAttributeNode("val")->getValue;
}

sub get_dia_attribute_string {
    my ($attribute) = @_;
    my ($str_elem, $string);
    $str_elem = get_first_element_subnode($attribute);
    $string = get_first_text_subnode($str_elem)->getData;
    $string =~ s/\#//g;
    return $string;
}

sub get_arrow_info {
    my ( $object_node, $id, $id_index )= @_;
    my($attribute,$attributes);

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "arrow_on_start");
    $bond_id_arrow_on_start{$id} = defined($attribute) ? get_dia_attribute_value("dia:boolean",$attribute) : 0;

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "effort_causality");
    change_causality($id_index, $attribute, $change_effort_causality);
    $bond_id_effort_causality{$id} = defined($attribute) ? get_dia_attribute_value("dia:enum",$attribute)-1 : 1;

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "flow_causality");
    change_causality($id_index, $attribute, $change_flow_causality);
    $bond_id_flow_causality{$id} = defined($attribute) ? get_dia_attribute_value("dia:enum",$attribute)-1 : 1;

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "start_label");
    $bond_id_start_label{$id} = defined($attribute) ? get_dia_attribute_string($attribute) : "[]";

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "end_label");
    $bond_id_end_label{$id} = defined($attribute) ? get_dia_attribute_string($attribute) : "[]";
}

sub change_causality() {
    my ($id_index, $attribute_node, $causality_change_string)=@_;
    my ($mtt_id, $arrow_oriented_causality);

    foreach my $id_causality (split(/;/,$causality_change_string)) {
	($mtt_id, $arrow_oriented_causality) = split(/:/,$id_causality);
	if ($mtt_id eq "all" || $id_index == $mtt_id) {
	    set_dia_attribute_value("dia:enum",$attribute_node,$arrow_oriented_causality + 1);
	}
    }
}

sub get_bond_data {
    my ( $objects_node )= @_;
    my ($id_index, $obj, $id, $connections, $connection, $to, $handle,
	$connections_att);

    print_debug("READING BONDS FROM $dia_input_file...\n");
    $id_index = 0;
    for my $i (0..$objects_node->getLength-1) {
      $obj = $objects_node->item($i);
      next if ($obj->getAttributeNode("type")->getValue ne "BondGraph - MTT bond");
      
      $id = $obj->getAttributeNode("id")->getValue;
      
      print_debug("Bond " . $id . ":\n");
      $mtt_bond_id_index{$id} = ++$id_index;
      
      get_arrow_info($obj,$id,$id_index);
      print_debug("Flow causality ($id):" . $bond_id_flow_causality{$id} . "\n");
      print_debug("Effort causality ($id):" . $bond_id_effort_causality{$id} . "\n");
      print_debug("Arrow on start ($id):" . $bond_id_arrow_on_start{$id} . "\n");

      # get connection info
      $connections_att = $obj->getElementsByTagName('dia:connections');
      die "A bond without connections exists!\n"
	  unless $connections_att->getLength > 0;

      $connections = $connections_att->item(0)->getElementsByTagName('dia:connection');
      die "Bond $id does not have two connections!\n" unless
	  $connections->getLength == 2;

      for my $j (0..$connections->getLength-1) {
	  
	  $connection = $connections->item($j);
	  $handle = $connection->getAttributeNode("handle")->getValue;
	  $to = $connection->getAttributeNode("to")->getValue;
	  
	  print_debug("handle " . $handle . "\n");
	  print_debug("to " . $to . "\n");
	  
	  if ($handle eq "0") {
	      $bond_id_start_id{$id} = $to;
	  } else {
	      $bond_id_end_id{$id} = $to;
	  }
      }
  }
    die "There are no bonds!\n" unless keys(%mtt_bond_id_index) > 0;
}

# if($relax), then this routine will return 'undef' instead of dying, if valid node not found.
sub get_first_subnode_by_nodename_attribute {
    my ( $relax, $node, $nodename, $key, $value)= @_;
    my ($subnodes,$subnode);

    $subnodes = $node->getChildNodes;
    
    for my $k (0..$subnodes->getLength-1) {
      next if ($subnodes->item($k)->getNodeType != ELEMENT_NODE);
      next if ($subnodes->item($k)->getNodeName ne $nodename);
      $subnode = $subnodes->item($k);
      next if defined($value) && defined($key) &&
	  ($subnode->getAttributeNode($key)->getValue ne $value);
      
      return $subnode;
  }
    if($relax) {
	return undef;
    } else {
	die "I found no subnode of " . $node->getNodeName .
	    " named $nodename with key/value pair: ($key,$value).\n" unless
	    $subnode->getTagName eq $nodename &&
	    $subnode->getAttributeNode($key)->getValue eq $value;
    }
}

sub get_first_element_subnode {
    my ( $node )= @_;
    my ($subnodes,$subnode);

    $subnodes = $node->getChildNodes;
    
    for my $k (0..$subnodes->getLength-1) {
      next if ($subnodes->item($k)->getNodeType != ELEMENT_NODE);
      $subnode = $subnodes->item($k);

      return $subnode;
  }
    die " I found no element subnode of " . $node->getNodeName . "." unless
	$subnode->getNodeType == ELEMENT_NODE;
}

sub get_first_text_subnode {
    my ( $node )= @_;
    my ($subnodes,$subnode);

    $subnodes = $node->getChildNodes;
    
    for my $k (0..$subnodes->getLength-1) {
      next if ($subnodes->item($k)->getNodeType != TEXT_NODE);
      $subnode = $subnodes->item($k);

      return $subnode;
  }
    die " I found no text subnode of " . $node->getNodeName . "." unless
	$subnode->getNodeType == TEXT_NODE;
}

sub id_cleaner {
    s/#?([^#]*)#?/$1/;
}

sub print_debug {
    print STDERR $_[0] if ($debug);
}

sub usage {
    return 
	"\n" .
	"Usage: dia2abg.pl --diagram_name <diagram_name> [options]\n" .
	"Options:\n" .
	"\t--dia_input_file  <dia_input_file>\n" .
	"\t--dia_output_file <dia_output_file>\n" .
	"\t--component_list_file\n" .
	"\t--create_component_list\n" .
	"\t--create_ibg\n" .
	"\t--debug\n" .
	"\t--ibg_file <ibg_file>\n" .
	"\t--change_flow_causality <bond causality spec>\n" .
	"\t--change_effort_causality <bond causality spec>\n" .
	"\n" .
	"\t\tBond causality spec:\n" .
	"\t\t 'bond:causality;bond:causality;...'\n" .
	"\t\tbond:\n" .
	"\t\t [mtt_bond_id|all]\n" .
	"\t\tcausality:\n" .
	"\t\t [-1|0|1]\n" .
	"\n" .
	"\t\tCausality is arrow-oriented-causality.\n" .
	"\t\tAny causality changes are made BEFORE further processing.\n" .
	"\n"
}

Deleted mttroot/mtt/bin/trans/dir2paths version [45c39d446b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dir2paths
# Finds paths of all valid MTT examples

# P.J.Gawthrop Mar 98
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/11/10 17:12:15  peterg
## Removed sorting
##
## Revision 1.1  1998/03/11 10:32:35  peterg
## Initial revision
##
###############################################################


dotdot=$2 # Set to ../ if we are in MTT_work


# Create paths for all valid examples - ie dir name is system name
find $dotdot$1 -name '*_abg.fig' -print |\
  gawk '{
   N=split($1,name,"/"); 
   printf("%s", name[1]);
   for (i=2;i<N;i++) printf("/%s", name[i]); 
   printf(" %s %s\n", name[N-1], name[N]);
  }' |\
  gawk '{
  correctname=sprintf("%s_abg.fig", $2);
  if ($3==correctname) print  $1,$2
  }'

Deleted mttroot/mtt/bin/trans/dir2rep version [bc594f5e2a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dir2rep
# Creates a rep file for a directory

# P.J.Gawthrop Dec 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/12/28 12:26:45  peterg
## *** empty log message ***
##
## Revision 1.2  1998/03/11 10:32:11  peterg
## Now uses dir2paths transformation
##
## Revision 1.1  1998/02/05 13:31:25  peterg
## Initial revision
##
###############################################################

dotdot=$2 # Set to ../ if we are in MTT_work

# Inform user
echo "Creating $1_rep.txt (Directory version)"

# Headings
echo "% Verbal description for directory $1 ($1_rep.txt)"> $1_rep.txt
echo "% Generated by MTT on" `date`. >> $1_rep.txt                  	   

# Create paths for all valid examples - ie dir name is system name
dir2paths $1 $2 | sed 's/Introduction/AAAAA/g' | sort | sed 's/AAAAA/Introduction/g' | \
gawk '{
     print "mtt -t -d " $1,$2 " rep tex";
  }' >> $1_rep.txt

Deleted mttroot/mtt/bin/trans/dm2fr_m version [905d7cb644].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169









































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm2fr_m

# Transformation: descriptor matrix to frequency response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15  2003/05/08 18:46:45  gawthrop
## Fixed range bug by using isfield in place of exists
##
## Revision 1.14  2000/05/20 15:35:18  peterg
## Parameterised version
##
## Revision 1.13  1998/09/03 09:12:32  peterg
## Removed debugging lines
##
## Revision 1.12  1998/09/02 12:02:14  peterg
## Added mttinput paramater
##
## Revision 1.11  1998/08/11 13:32:42  peterg
## Lowercase mttLAST etc
##
## Revision 1.10  1998/07/27 20:27:25  peterg
## Now get parameters for simpar file.
##
## Revision 1.9  1998/02/26 15:12:26  peterg
## Removed parameter stuff
##
# Revision 1.8  1996/08/30  14:54:36  peter
# Took back lock.
#
## Revision 1.7  1996/08/24  14:23:00  peter
## Global parameter passing.
## Proper error handling.
#
## Revision 1.6  1996/08/16 14:26:07  peter
## Fixed multi-output bug.
## Made sure that u0 is ok.
##
## Revision 1.5  1996/08/15 16:23:02  peter
## Now uses W in place of w for consistancy with time responses.
##
## Revision 1.4  1996/08/15 11:52:42  peter
## Now creats a number of versions:
## fr 	complex frequency response
## lmfr 	log  magnitude of fr
## lpfr  	phase of fr
## nyfr  	real and imag parts - Nyquist style
## nifr 	Nichols style.
##
## Revision 1.3  1996/08/11 19:08:08  peter
## Parameter passing now enabled.
##
## Revision 1.2  1996/08/11 09:32:12  peter
## Now takes the numpar parameters correctly
##
## Revision 1.1  1996/08/10 14:11:11  peter
## Initial revision
##
###############################################################

echo Creating $1_fr.m
echo Creating $1_lmfr.m
echo Creating $1_lpfr.m
echo Creating $1_nyfr.m
echo Creating $1_nifr.m

#if [ "$2" = "" ]; 
#then
#  PARAMS='W=logspace(-1,2,100); u0=zeros(nu,1); u0(1)=1;'
#  echo Using default parameter $PARAMS
#else
#  PARAMS=$2;
#fi

$MATRIX << EOF > dm2fr_m.log 2>mtt_error.txt

# Data
  mttpar=$1_numpar;

# Simulation parameters
  simpar=$1_simpar;

  [nx,ny,nu,nz,nyz] = $1_def;

  %Defaults
  
  if (isfield(simpar,"wmin")==0)
    simpar.wmin = -1;
  end;

  if (isfield(simpar,"wmax")==0)
    simpar.wmax = 2
  end;

  if (isfield(simpar,"wsteps")==0)
    simpar.wsteps = 100;
  end;

  W = logspace(simpar.wmin,simpar.wmax,simpar.wsteps)';
  if (isfield(simpar,"mttinput")==0)
    mttinput = 1;
  end;
  mttu0 = zeros(nu,1);
  mttu0(mttinput) = 1;

  [n,m]=size(W);
  if m>n
    W=W';
  end;

  [n,m]=size(mttu0);
  if m>n
    mttu0=mttu0';
  end;

  [A,B,C,D,E] = $1_dm(mttpar);
  fr = dm2fr(A,B,C,D,E,W,mttu0);
  lw = log10(W);
  lmfr = log10(abs(fr));
  pfr = angle(fr)*180/pi;

% Complex frequency response
  write_matrix([W fr], "$1_fr");

% Log magnitude v log frequency
  write_matrix([lw lmfr], "$1_lmfr");

% Angle v log frequency
  write_matrix([lw pfr], "$1_lpfr");

% Nyquist style
  re = real(fr);
  im = imag(fr);
  nyq = [re(:,1) im(:,1)];
  for i = 2:ny
    nyq = [nyq re(:,i) im(:,i)];
  end;
  write_matrix(nyq, "$1_nyfr");

% Nichols style
  re = lmfr;
  im = pfr;
  nic = [im(:,1) re(:,1)];
  for i = 2:ny
    nic = [nic im(:,i) re(:,i)];
  end;
  write_matrix(nic, "$1_nifr");

EOF

# Now invoke the standard error handling,"
mtt_error mtt_error.txt






Deleted mttroot/mtt/bin/trans/dm2ir_m2dat version [d3255be9a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dat2ps

# Tramsforms descriptor matrix rep to frequency response dat.


# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1996/08/11 19:48:29  peter
## Parameter passing added.
##
## Revision 1.2  1996/08/11 10:40:00  peter
## Now handles e and NaN numbers.
##
## Revision 1.1  1996/08/10 14:15:03  peter
## Initial revision
##
###############################################################

echo Creating $1_ir.dat

if [ "$2" = "" ]; 
then
  PARAMS='t=[0:0.1:10]'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi


$MATRIX << EOF | gawk '$1 !~ /[A-MO-Zb-cf-z]/ && NF>0 {print} '  >$1_ir.dat

  $PARAMS;
  [n,m]=size(t);
  if m>n
    t=t';
  end;

  [A,B,C,D,E] = $1_dm($1_numpar);
  y = dm2ir(A,B,C,D,E,t);

  [Ny,Nu]=size(D);
  NN = Ny*Nu;

  xy = [t y(:,1)];
  for i=2:NN
    xy = [xy t y(:,i)];
  end;
xy

EOF

Deleted mttroot/mtt/bin/trans/dm2tf_r version [60f01453cb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm2tf_r
# Reduce  descriptor matrices to transfer function
# P.J.Gawthrop 8th May 1991, Dec 1993, April 1994.
# Copyright (c) P.J.Gawthrop, 1991, 1993, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/03/27 15:00:23  peterg
## reduce ---> symbolic
##
## Revision 1.1  1996/08/25 10:09:55  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_tf.r

# Remove the old log file
rm -f dm2tf_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >dm2tf_r.log << EOF

%ON FLOAT;

IN "$1_def.r";
IN "$1_dm.r";
IN "$1_subs.r";

OFF Echo;
OFF Nat;

%create sE-A
%MTT_SEA := s*MTTE-MTTA;

%Find the denominator of the TF - det(sE-A);
%comden := det(MTT_SEA);

%Find the Adjoint transpose.
%matrix AdjT(MTTNx,MTTNx);
%FOR i := 1:MTTNx DO
%  BEGIN
%  FOR j := 1:MTTNx DO
%    AdjT(i,j) := cofactor(MTT_SEA,i,j);
%  END;

%Adj := TP(AdjT);

%Find the numerator matrix
%Num := MTTC*Adj*MTTB + MTTD*comden;


%Create the transfer function matrix
MTTTF := MTTD;
IF MTTNy>0 THEN MTTTF := MTTTF + (MTTC * ((s*MTTE-MTTA)^-1) * MTTB);

%MTTTF := Num/comden;


OUT "$1_tf.r";

%Declare the transfer function matrix
write "matrix MTTTF(", MTTNy, ",", MTTNu, ")$"$

%And write it.
%MTTTF := MTTTF;
FOR i := 1:MTTNy DO
  BEGIN
  FOR j := 1:MTTNu DO
    IF MTTTF(i,j) NEQ 0 THEN write "MTTTF(", i, ",", j, ") := ", MTTTF(i,j)$
  END;

write ";END;"$
SHUT "$1_tf.r";

EOF

# Now invoke the standard error handling.
mtt_error_r dm2tf_r.log

Deleted mttroot/mtt/bin/trans/dm_r2m version [dc94c23287].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131



































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm_r2m
# Reduce descriptor state-space A,B,C,D and E matrices to Matlab
# P.J.Gawthrop 29th July 1990, 6th Feb 1991, 28 May 1991, Dec 1993, Jan 94
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993,1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1998/04/13 11:01:55  peterg
## Now uses generic header : matlab_header
##
# Revision 1.6  1997/04/16  13:43:29  peterg
# Added matrix dimenensions
#
# Revision 1.5  1997/02/24  14:44:28  peterg
# Ignores numerical parameters in global list.
#
## Revision 1.4  1996/08/24 14:16:25  peter
## Global parameter passing.
##
## Revision 1.3  1996/08/18 12:02:46  peter
## Fixed bug when some matrices are empty.
##
## Revision 1.2  1996/08/12 20:22:20  peter
## Paramaters passed via an internal call to _numpar.
## _args script can overide these parameters - sneaky.
##
## Revision 1.1  1996/08/12 19:09:13  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_dm.m

# Remove the old log file
rm -f dm_r2m.log

# Use reduce to accomplish the transformation
reduce >dm_r2m.log << EOF

ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab

%Read in the definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read in the parameter file
%%in "$1_sympar.r";

%Read the reduce state-space A,B,C and D matrices file
in "$1_dm.r";

IF MTTNvar>0 THEN
BEGIN
  write "% Set the parameters";
  write "global ...;;";
  FOR i := 1:MTTNvar DO
    BEGIN
      IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
        % Do nowt
      END
      ELSE  
      BEGIN
        write MTTVar(i,1), " ...";
      END;
    END;
    write " ";
END;


%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

MTTN := MTTNx + 2*MTTNz + MTTNyz;
write "MTTA = zeros(", MTTN, ",", MTTN, ");";
write "MTTB = zeros(", MTTN, ",", MTTNu, ");";
write "MTTC = zeros(", MTTNy, ",", MTTN, ");";
write "MTTD = zeros(", MTTNy, ",", MTTNu, ");";
write "MTTE = zeros(", MTTN, ",", MTTN, ");";

OUT "$1_dm.1";

ON NERO;	% Suppress zero elements.
MTTA := MTTA;
MTTB := MTTB;
MTTC := MTTC;
MTTD := MTTD;
MTTE := MTTE;

SHUT "$1_dm.1";


EOF

# Header
matlab_header $1 dm 'A,B,C,D,E'> $1_dm.m

#Define array sizes.
grep -v 'function' $1_def.m | grep -v '%' >>  $1_dm.m
echo 'mtta = zeros(nx+nyz+2*nz,nx+nyz+2*nz);' >>  $1_dm.m
echo 'mttb = zeros(nx+nyz+2*nz,nu);' >>  $1_dm.m
echo 'mttc = zeros(ny,nx+nyz+2*nz);' >>  $1_dm.m
echo 'mttd = zeros(ny,nu);' >>  $1_dm.m
echo 'mtte = zeros(nx+nyz+2*nz,nx+nyz+2*nz);' >>  $1_dm.m


#Code
cat $1_dm.1 >> $1_dm.m


rm -f $1_dm.1


Deleted mttroot/mtt/bin/trans/dm_r2tex version [acd65c348e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163



































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm_r2tex
# Reduce descriptor matrices to LaTex descriptor matrices.
# P.J.Gawthrop 9 June 1990, 8th July 1990, 14 Feb 1991, 10th May 1991, 4th June 1991
# Copyright (c) P.J.Gawthrop, 1990, 1991.

#Inform user
echo Creating $1_dm.tex

# Remove the old log file
rm -f dm_r2tex.log

# Use reduce to accomplish the transformation
reduce >dm_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Number of descriptor variables
MTTN := MTTNx + 2*MTTNz + MTTNyz;

%Read the descriptor matrices file
in "$1_dm.r";

OFF Echo;
OFF Nat;

OUT "$1_dm.tex";

%Write out the descriptor matrices.
write "%Descriptor matrices $1";
write "%File: $1_dm.tex";
write"";

write "%Descriptor matrices";

%IF (MTTNz+MTTNyz) NEQ 0 THEN
%BEGIN
%  write "%  - E matrix";
%  write "\begin{equation}";
%  write "MTTE = MTTI_0(", MTTNx+MTTNz, ",", MTTNz+MTTNyz, ")";
%  write "\end{equation}";
%END;


IF MTTN NEQ 0 THEN
IF (MTTNz+MTTNyz) > 0 THEN
BEGIN
write "%  - E matrix";
write "\begin{equation}";
write "MTTE = \begin{pmatrix}";
	FOR Row := 1:MTTN DO
	BEGIN
		FOR Col := 1:MTTN DO
		BEGIN
			Write "{", MTTE(Row,Col), "}";
			IF Col<MTTN THEN Write "&"
		END;

	IF Row<MTTN THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;



IF MTTN NEQ 0 THEN
BEGIN
write "%  - A matrix";
write "\begin{equation}";
write "MTTA = \begin{pmatrix}";
	FOR Row := 1:MTTN DO
	BEGIN
		FOR Col := 1:MTTN DO
		BEGIN
			Write "{", MTTA(Row,Col), "}";
			IF Col<MTTN THEN Write "&"
		END;

	IF Row<MTTN THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;

IF MTTN NEQ 0 THEN IF MTTNu NEQ 0 THEN
BEGIN
write "%  - B matrix";
write "\begin{equation}";
write "MTTB = \begin{pmatrix}";
	FOR Row := 1:MTTN DO
	BEGIN
		FOR Col := 1:MTTNu DO
		BEGIN
			Write "{", MTTB(Row,Col), "}";
			IF Col<MTTNu THEN Write "&"
		END;

	IF Row<MTTN THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;

IF MTTN NEQ 0 THEN IF MTTNy NEQ 0 THEN
BEGIN
write "%  - C matrix";
write "\begin{equation}";
write "MTTC = \begin{pmatrix}";
	FOR Row := 1:MTTNy DO
	BEGIN
		FOR Col := 1:MTTN DO
		BEGIN
			Write "{", MTTC(Row,Col), "}";
			IF Col<MTTN THEN Write "&"
		END;

	IF Row<MTTNy THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;

IF MTTNy NEQ 0 THEN IF MTTNu NEQ 0 THEN
BEGIN
write "%  - D matrix";
write "\begin{equation}";
write "MTTD = \begin{pmatrix}";
	FOR Row := 1:MTTNy DO
	BEGIN
		FOR Col := 1:MTTNu DO
		BEGIN
			Write "{", MTTD(Row,Col), "}";
			IF Col<MTTNu THEN Write "&"
		END;

	IF Row<MTTNy THEN Write "\cr";
	END;
	Write "\end{pmatrix}";
write "\end{equation}";
END;




SHUT "$1_dm.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/doc2dvi version [e8e1f97833].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: doc2dvi
# Converts doc file to dvi file

# Copyright (c) P.J.Gawthrop 1998


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/11/24 12:03:27  peterg
## Indexing of book docs.
##
## Revision 1.2  1998/04/15 18:40:43  peterg
## Run LateX three times
##
## Revision 1.1  1998/03/03 08:35:50  peterg
## Initial revision
##
###############################################################

system=$1
documenttype=$2

# Inform user
echo "Creating $system.dvi"

#Run latex , bibtex and makeindex
latex $system.doc > doc2dvi.log
bibtex $system    >> doc2dvi.log
latex $system.doc >> doc2dvi.log
latex $system.doc >> doc2dvi.log

if [ "$documenttype" = "book" ]; then
    makeindex $system >> doc2dvi.log
else
    touch $system.ind
fi

latex $system.doc >> doc2dvi.log
latex $system.doc >> doc2dvi.log

# Make sure transformation succeeeds
exit 0

Deleted mttroot/mtt/bin/trans/doc2pdf version [17899ec521].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: doc2pdf
# Converts doc file to pdf file

# Copyright (c) P.J.Gawthrop 1998


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
##
###############################################################

system=$1
documenttype=$2

# Inform user
echo "Creating $system.pdf"

#Run pdflatex , bibtex and makeindex
pdflatex $system.doc > doc2pdf.log
bibtex $system    >> doc2pdf.log
pdflatex $system.doc >> doc2pdf.log
pdflatex $system.doc >> doc2pdf.log

if [ "$documenttype" = "book" ]; then
    makeindex $system >> doc2pdf.log
else
    touch $system.ind
fi

pdflatex $system.doc >> doc2pdf.log
pdflatex $system.doc >> doc2pdf.log

# Make sure transformation succeeeds
exit 0

Deleted mttroot/mtt/bin/trans/doc2ps version [d08f5c88d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: doc2dvi
# Converts doc file to dvi file

# Copyright (c) P.J.Gawthrop 1998


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1999/11/02 07:56:46  peterg
## Removed documenttype in blurb
##
## Revision 1.3  1998/11/24 12:03:27  peterg
## Indexing of book docs.
##
## Revision 1.2  1998/04/15 18:40:43  peterg
## Run LateX three times
##
## Revision 1.1  1998/03/03 08:35:50  peterg
## Initial revision
##
###############################################################

system=$1
documenttype=$2

# Inform user
echo "Creating $system.ps"

doc2dvi $system $documenttype

dvips -o $system.ps $1 

# Make sure transformation succeeeds
exit 0

Deleted mttroot/mtt/bin/trans/ese2rdae_r version [c877f50297].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294






































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ese2rdae_r
# Reduce equations to raw differential-algebraic equation conversion
# P.J.Gawthrop  8th May 1991, May 1994, June 1996
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2002/08/30 15:39:04  geraint
## Read fix_c.r before ese.r and explicitly overload ** operator with pow().
## These changes are required for the Codemist version of Reduce.
##
## Revision 1.13  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.12.2.2  2002/06/05 17:28:00  geraint
## Cosmetic change.
##
## Revision 1.12.2.1  2002/06/05 11:14:51  geraint
## ae.r now generated using def2write_r like cse?.r
## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r.
##
## These changes produce the desired result (optimised algebraic equations) but
## have highlighted a problem; when optimisation fails, Reduce does not write
## a result. For complicated systems, this can lead to missing assignments in
## the resultant code.
##
## Revision 1.12  2001/07/23 23:31:17  gawthrop
## Added -cr option to load CRs first - avoids alg. loops with R
## implementation of mutiports.
##
## Revision 1.11  2001/07/06 00:46:50  gawthrop
## Added -cr option -- forces cr to be loaded before the ese.r file
## This avoids causality problems when using multi-port Rs to represent
## arbitary equations
##
## Revision 1.10  2000/11/30 15:23:16  peterg
## Taken out all subsystem stuff - now done in mtt using
## mtt_make_subsystems
##
## Revision 1.9  2000/09/07 12:18:31  peterg
## Prettified layout of this file
##
## Revision 1.8  2000/09/07 12:07:26  peterg
## *** empty log message ***
##
## Revision 1.7  2000/09/01 13:34:15  peterg
## Exit on option error
##
## Revision 1.6  2000/09/01 13:30:32  peterg
## Added -partition switch
##
## Revision 1.5  2000/09/01 12:14:57  peterg
## Added connecti9ng inputs
##
## Revision 1.4  1998/04/07 15:06:46  peterg
## Correct log file name
##
## Revision 1.3  1998/03/07 12:57:19  peterg
## Fixed logname bug
##
## Revision 1.2  1998/03/07 12:51:20  peterg
## This is the new version of ese2dae - it does not do the CRs at this
## stage to give reduce an easier time.
##
## rese2ese_r does the constitutive relationship bit
##
## Revision 1.1  1998/03/07 12:49:31  peterg
## Initial revision
##
## Revision 1.12  1998/01/31 16:22:59  peterg
## Added IF MTTNx>0 THEN and IF MTTNy>0 THEN before the relevant
## assignements of MTTdX and MTTY to themselves.
##
## Revision 1.11  1997/09/18 09:45:08  peterg
## Canged the comment about linux reduce -- reduce reads this for some
## reason.
##
## Revision 1.10  1997/09/15 14:21:18  peterg
## Reads ese file twice to avoid a bug in Linux reduce !!!???
##
## Revision 1.9  1997/08/30 09:59:31  peterg
## Changed mehtod of writing out mtty to avoid a strange segmentation violation.
## Now uses MTTY := MTTY; approach.
##
## Revision 1.8  1997/04/23 09:31:20  peterg
## Now reads in the (top level) def file in the generated reduce code.
##
# Revision 1.7  1997/04/23  09:23:15  peterg
# Two argument version in preparation for heirarchical version
#
# Revision 1.6  1996/11/21  15:47:48  peterg
# Now inputs _params.r not _sympar.r
#
## Revision 1.5  1996/11/02 10:17:35  peterg
## Removed default constitutive relationship input.
##
# Revision 1.4  1996/09/12  12:10:05  peter
# Now reads the default constitutive relationship file.
#
## Revision 1.3  1996/08/25 09:43:26  peter
## General error handling.
##
## Revision 1.2  1996/08/25 08:31:28  peter
## Error handling added.
##
###############################################################


while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-cr )
                load_cr=yes;
                blurb2=' using cr and subs first';
                ;;
      -fixcc )
		include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'`
		blurb3='fixing c and cc code';
		;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
      -sort )
	  	sort=sort;
		blurb1='using sorted equations';
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

#Create the top-level system name
topname=$1

#Create the system names
if [ -z "$2" ]; 
    then
	sysname=$topname;
    else
	sysname=$1_$2;
fi

defname=$topname"_def.r"
crname=$topname"_cr.r"
subsname=$topname"_subs.r"
paramname=$topname"_params.r"
daename=$sysname"_rdae.r"

if [ -n "$sort" ]; then
    esename=$sysname"_sese.r"
else
    esename=$sysname"_ese.r"
fi

logname=ese2rdae.log

if [ -n "${load_cr}" ]; then
    load_cr_comm="in \"${crname}\";"
    load_subs_comm="in \"${subsname}\";"
fi

# Inform user
echo Creating $daename $blurb $blurb1 $blurb2 $blurb3

# Remove the old log file
rm -f $logname

# Use symbolic algebra to accomplish the transformation
$SYMBOLIC >$logname  << EOF

%Read in the cr and sub when  -cr is set
$load_cr_comm
$load_subs_comm

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

% Definitions
in "$defname";

% Fix c code if required
$include

% Elementary system equations
in "$esename";

OFF Echo;
OFF Nat;

%Create the output file
OUT "$daename";

write "in ""$defname""";

% State
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Nonstate
MTT_Matrix := MTTZ$ 
MTT_Matrix_name := "MTTZ"$
MTT_Matrix_n := MTTNz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTy$ 
MTT_Matrix_name := "MTTy"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Zero outputs
MTT_Matrix := MTTYz$ 
MTT_Matrix_name := "MTTYz"$
MTT_Matrix_n := MTTNyz$
MTT_Matrix_m := 1$
Reduce_Matrix()$


SHUT "$daename";
quit;

EOF

#if [ -n "$partition" ]; then
#  rm -f mtt_junk
#  # Now for the subsystems
#  # Find subsystems
#  subsystems=`mtt_get_subsystems $1`
#
#  for subsystem in $subsystems; do
#    echo Doing $subsystem
#    ucname="MTT_"$subsystem"_uc"
#  
#    Nu=`mtt_getsize -internal $subsystem u`
#    echo Nu $Nu
#  
#    # Use symbolic algebra to accomplish the transformation
#    $SYMBOLIC >$logname  << EOF
#  
#    %Read the formatting function
#    in "$MTTPATH/trans/reduce_matrix.r";
#  
#    % Definitions
#    in "$defname";
#  
#    % Elementary system equations
#    in "$esename";
#  
#    OFF Echo;
#    OFF Nat;
#   
#    %Create the output file
#    OUT "mtt_junk";
#    % Connecting inputs
#    MTT_Matrix := $ucname $
#    MTT_Matrix_name := "$ucname" $
#    MTT_Matrix_n := $Nu $
#    MTT_Matrix_m := 1$
#    Reduce_Matrix()$
#  
#    shut "mtt_junk";
#EOF
#    echo >> $1_rdae.r
#    echo %Connections for subsystem $subsystem  >> $1_rdae.r
#    echo >> $1_rdae.r
#  
#    cat mtt_junk >> $1_rdae.r
#    rm -rf mtt_junk
#  done
#fi

echo "END;" >> $1_rdae.r

# Now invoke the standard error handling.
mtt_error_r $logname

Deleted mttroot/mtt/bin/trans/ese_r2txt.pl version [afe19321de].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/perl -w

use strict;

$/ = ';';			# statements are terminated by ;
while (<STDIN>) {
    chomp;
    s/%.*\n//g;			# strip comments (% to end of line)
    s/(\s)*//g;			# strip whitespace
    s/^END$//;			# strip junk
    next if /^(\s)*$/;		# skip blank lines
    printf ("%s\n", $_);	# print what remains
}

Deleted mttroot/mtt/bin/trans/ese_tidy version [351111a9a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Bourne shell script: ese_tidy
# Tidies up Matlab format files
# P.J.Gawthrop May 1998
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

#Puts the state & output equations at the end of the file

grep -v '^MTT' $1_ese.r>junk1
grep '^MTT' $1_ese.r>junk2
echo 'END;' >junk3
cat junk1 junk2 junk3> $1_ese.r




Deleted mttroot/mtt/bin/trans/ese_txt2make.pl version [5c51d89569].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205













































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/perl -w
#
#     ese_txt2make.pl - sorts equations using Make
#     Copyright (C) 2004  Geraint Paul Bevan
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#		--------------------------
#		Model Transformation Tools
#		--------------------------
#
# Creates a makefile from the elementary system equations
# Executing the makefile causes make to sort the equations
#
#-------------------------------------------------------------------------------

use strict;
use Getopt::Long;

my %dependencies;		# left-values right-dependencies
my %expressions;		# left-values right-expression

my $sys		= '';
my $debug	=  0;
my $infile	= '';
my $outfile	= '';

GetOptions ('sys=s'	=> \$sys,
	    'debug'	=> \$debug,
	    'infile=s'	=> \$infile,
	    'outfile=s'	=> \$outfile);

# default file names
$infile	 = "${sys}_ese.txt"	if ($infile  eq '');
$outfile = "${sys}_ese.make"	if ($outfile eq '');

#-------------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------------

if ($debug) {
    my $logfile = "ese_txt2make_${sys}.log";
    open (LOG, ">$logfile") or die ("MTT: ese_txt2make, cannot open $logfile");
}

# First the elementary system equations are read
# and placed in the "expressions" hash.
read_ese_txt ();

# Then the occurence of any lvalue in the expression
# of any other is sought. 
get_dependencies ();

# Finally the expressions are written to a makefile
# where the targets are the left hand values and the
# pre-requisites are the dependencies
write_make ($sys);

close (LOG) if ($debug);

#-------------------------------------------------------------------------------
# subroutines
#-------------------------------------------------------------------------------
sub read_ese_txt {

    open (ESE, $infile)
	or die ("MTT Error:\nese_txt2make, cannot open $infile\n");

    while (<ESE>) {

	chomp;

	# separate the left and right side of equations
	# and assign them to the expressions hash
	my ($lvar,$expr) = split (/:=/);
	$expressions{$lvar} = $expr;

	print LOG "$lvar\t= $expressions{$lvar}\n" if $debug;
    }
    
    close (ESE);
}
#-------------------------------------------------------------------------------
sub get_dependencies {

    # compare the pattern to each expression
    foreach my $lvar (keys %expressions) {
	$dependencies{$lvar} = "";
	$_ = $expressions{$lvar};
	for my $lvar2 (keys %expressions) {
	    if ($expressions{$lvar} =~ /$lvar2/) {
		# a left value has been found in the expression
		# add it to the dependencies for this lvar
		$dependencies{$lvar} = "$dependencies{$lvar} $lvar2";
	    }
	}
	print LOG "$lvar:\t$dependencies{$lvar}\n" if $debug;
    }
}
#-------------------------------------------------------------------------------
sub write_make {
    
    # create lists of rates, states and tmpvars so that
    # separate rules can be created in the makefile
    my @list_of_rates;
    my @list_of_outputs;
    my @list_of_unknown;
    my @list_of_nonstates;
    my @list_of_tmpvars;

    for my $lvar (sort (keys %expressions)) {
	if ($lvar =~ /^MTTdX\(/) {
	    @list_of_rates = (@list_of_rates, $lvar) ;
	} elsif ($lvar =~ /^MTTy\(/) {
	    @list_of_outputs = (@list_of_outputs, $lvar);
	} elsif ($lvar =~ /^MTTyz/) {
	    @list_of_unknown = (@list_of_unknown, $lvar);
	} elsif ($lvar =~ /^MTTz/) {
	    @list_of_nonstates = (@list_of_nonstates, $lvar);
	} elsif ($lvar =~ /^${sys}_/) {
	    @list_of_tmpvars = (@list_of_tmpvars, $lvar);
	} else {
	    die "MTT Error:\nese_txt2make, unclassified variable: $lvar\n";
	}
    }
    my @sorted_rates     = sort (@list_of_rates);
    my @sorted_outputs   = sort (@list_of_outputs);
    my @sorted_unknown   = sort (@list_of_unknown);
    my @sorted_nonstates = sort (@list_of_nonstates);
    my @sorted_tmpvars   = sort (@list_of_tmpvars);


    # write the header
    open (ESE, ">$outfile") or
	die ("MTT Error:\nese_txt2make, cannot open $outfile\n");

    my $date = localtime;

    print ESE
	"# $outfile\t-*-makefile-*-\n" .
	"#\n";

    print ESE
	"#\t\t--------------------------\n" .
	"#\t\tModel Transformation Tools\n" .
	"#\t\t--------------------------\n" .
        "#\n" .
	"# Created by MTT: $date\n\n";    

    # write the rules that external programs use
    print ESE
        "all: declare_tmpvars MTTdX MTTy\n\n" .
	"MTTdX: @sorted_rates\n\n" .
	"MTTy:  @sorted_outputs\n\n" .
	"MTTyz: @sorted_unknown\n\n" .
	"MTTz:  @sorted_nonstates\n\n";
    
    # set the default output format:
    # double tmpvar;
    # lvalue := expression;
    print ESE
	"# default output format\n" .
	"ifeq (\"\$(assignment)\",\"\")\n" .
	"assignment=:=\n" .
	"endif\n\n" .
	"ifeq (\"\$(declaration)\",\"\")\n" .
	"declaration=double\n" .
	"endif\n\n" .
	"ifeq (\"\$(terminator)\",\"\")\n" .
	"terminator=;\n" .
	"endif\n\n";

    # write a rule to declare the temporary variables
    print ESE
	"# declare temporary variables\n" .
	"declare_tmpvars:\n";
    for my $var (@sorted_tmpvars) {
	print ESE "\t\@echo \"\$(declaration) $var \$(terminator)\"\n";
    }
    print ESE "\n";

    # write the equations
    print ESE "# the equations\n";
    for my $lvar (sort (keys %expressions)) {
	print ESE "$lvar: $dependencies{$lvar}\n";
	print ESE "\t\@echo \"$lvar \$(assignment) " .
	    "$expressions{$lvar} \$(terminator)\"\n\n";
    }
    print ESE "\n";

    close (ESE);
}
#-------------------------------------------------------------------------------

Deleted mttroot/mtt/bin/trans/examples_txt2tk version [f746b105d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: examples_txt2tk
# Creates tk/tcl file for xmtt.
# Copyright (c) P.J.Gawthrop, 1998,1999


# Examples menu
gawk 'BEGIN{
    basemenu=".exam.exam"
    oldmenu=basemenu
    OLDPATH="";
    }
    {
    if (NF>1){
    PATH=$1;
    N=split(PATH,path,"/"); # Find current example path
    oldN=split(OLDPATH,oldpath,"/"); # Find last example path
    same=1; menu=basemenu;
    while ((path[same]==oldpath[same])&&(same<=N)){
       menu=menu"."tolower(path[same])
       same++
    }
      oldmenu=menu
      for (i=same;i<N;i++){
        menu=tolower(menu"."path[i])
        category=path[i];
	printf("\n# Example category %s (%i)\n", category, N)
        printf("%s  add  cascade -label \"%s\" -menu %s \n", oldmenu, category, menu);
        printf("menu %s\n", menu)
	oldmenu=menu
      }
    oldN=N
    OLDPATH=PATH
    oldcategory=category
    split($2,EXAMPLE,"_");
    example = EXAMPLE[1];
    printf(" set mtt \"xmtt --example %s\" \n", example); 
    printf("%s add command -label %s -command \" exec $mtt &\"\n", menu, example);
 }
}' 

Deleted mttroot/mtt/bin/trans/first version [6060a423fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: first
# Gives first of space seperated string
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

echo $1 | cut -d ' ' -f 1 

Deleted mttroot/mtt/bin/trans/gdat2fig version [2b58db4954].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: gdat2ps

# Converts a data file in gplot format to a ps file

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 12:29:52  peterg
## Initial revision
##
## Revision 1.8  1997/12/07 18:45:44  peterg
## Set to monochrome (not colour). This gives clearer plots.
##
## Revision 1.7  1996/08/26 13:04:43  peterg
## Changed $() to ``.
##
# Revision 1.6  1996/08/16  14:51:21  peter
# Put in some cosmetic postscript options.
#
## Revision 1.5  1996/08/15 09:37:58  peter
## Parameters in title.
##
## Revision 1.4  1996/08/14 09:21:17  peter
## Gnu plot conversion now done externally in dat2gdat
##
## Revision 1.3  1996/08/10 14:12:48  peter
## Revised to new dat format: [x y x y x y] in place of [x y y y].
##
## Revision 1.2  1996/08/10 12:54:56  peter
## Reorganised data file for gnuplot input.
##
## Revision 1.1  1996/08/10 09:52:39  peter
## Initial revision
##
###############################################################

echo Creating $1.fig

gnuplot << EOF
  set terminal fig color portrait fontsize 16 size 20 10 metric
  set output '$1.fig'
  set grid
  set title "MTT simulation on `date` "
  set nokey
  plot '$1.gdat' with lines
  exit

EOF

## Add a gold box to give a nice picture
cat >> $1.fig <<EOF
2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5
	 9675 5310 9675 270 225 270 225 5310 9675 5310
EOF

Deleted mttroot/mtt/bin/trans/gdat2ps version [de49bc31ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: gdat2ps

# Converts a data file in gplot format to a ps file

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1996/08/26 13:04:43  peterg
## Changed $() to ``.
##
# Revision 1.6  1996/08/16  14:51:21  peter
# Put in some cosmetic postscript options.
#
## Revision 1.5  1996/08/15 09:37:58  peter
## Parameters in title.
##
## Revision 1.4  1996/08/14 09:21:17  peter
## Gnu plot conversion now done externally in dat2gdat
##
## Revision 1.3  1996/08/10 14:12:48  peter
## Revised to new dat format: [x y x y x y] in place of [x y y y].
##
## Revision 1.2  1996/08/10 12:54:56  peter
## Reorganised data file for gnuplot input.
##
## Revision 1.1  1996/08/10 09:52:39  peter
## Initial revision
##
###############################################################

echo Creating $1.ps

gnuplot << EOF
  set terminal postscript eps monochrome "Times-Roman" 24
  set size 1.5,1.5
  set output '$1.ps'
  set grid
  set title "`date` $2 "
  plot '$1.gdat' with lines
  exit
EOF

Deleted mttroot/mtt/bin/trans/gdat2view version [5424332042].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: gdat2view

# Converts a data file in gplot format to  view 

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1996/08/15  09:36:00  peter
# Parameters in title.
#
## Revision 1.1  1996/08/15 08:50:20  peter
## Initial revision
##
###############################################################


# echo Creating view of $1

gnuplot << EOF
  set grid
#  set title "$1. Generated by MTT on $(date)"
  set title "`date` $2 "
  plot '$1.gdat' with lines
  pause 100000
EOF

Deleted mttroot/mtt/bin/trans/ibg2abg_m version [6f2e346232].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ibg2abg_m
# Based on rbg2abg_m

while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-I )
	    info=info ;;
	-nounits )
	    units=no ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Set up some vars
sys=$1
lbl_file=${sys}_lbl.txt
abg_file=${sys}_abg.m
err=mtt_error.txt
log=ibg2abg_m_${sys}.log

# Remove the old log file
rm -f ibg2abg_m.log
rm -f ${abg_file}

# Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');
  
  ## Interpret data from the ibg representation
  ibonds = $1_ibg;
  bonds = ibonds.bonds;

  [bonds,components,n_vector_bonds] = ibg2abg(name,bonds, ...
					      infofile,errorfile)

  ## Write the acausal bond graph m-file
  write_abg(name,bonds,components,n_vector_bonds);
EOF

# Set the units for the abg file
test_units()
{
      grep '^[\s]*[#|%]UNITS' < ${lbl_file} >/dev/null
  if [ $? = "0" ]; then 
    grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
    gawk '{
      printf("mtt_units.sh %s %s %s %s %s\n", sys, $2, $3, $4, $5)
    }' sys=${sys}  | sh | grep ERROR
    if [ $? = "0" ]; then
      echo "    " *MTT_ERROR: domains and units are not OK - exiting
      exit 1  
    else
      echo "    " domains and units are OK 
    fi
  else
    echo "  no domains or units declared"
  fi
} 

check_ports_exist()
{
 declared_ports=`grep '^[\s]*[#|%]UNITS' < ${lbl_file} | gawk '{print $2}'`
  for declared_port in $declared_ports; do
    grep "${sys}\.ports\.${declared_port}\.type" ${abg_file} >/dev/null
    if [ $? = "1" ]; then
      echo "*MTT_ERROR: Units declared for non-existent port ${declared_port}"
      exit 1
    fi
  done
}

set_units()
{ 
  grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
  gawk '{
    printf("  %s.ports.%s.domain = \"%s\";\n", sys, $2, $3);
    printf("  %s.ports.%s.units.effort = \"%s\";\n", sys, $2, $4);
    printf("  %s.ports.%s.units.flow = \"%s\";\n", sys, $2, $5);
  }' sys=${sys}
} 

if [ -z "$units" ]; then
  echo Checking port domains and units
  check_ports_exist;
  test_units;
  echo "## Port domain and units" >> ${abg_file}
  set_units >> ${abg_file}
fi

# Append any VAR declarations
if [ -f "$1_lbl.txt" ]; then
  echo "## Explicit variable declarations" >> ${abg_file}
  grep '^[\s]*[%|#][V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
  grep '^[\s]*[%|#]NOT[V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
fi

# Close off the function
echo "endfunction" >> ${abg_file}

# Errors and info
if [ "$info" = "info" ]; then
    cat mtt_info.txt
fi

if mtt_error mtt_error.txt; then
    exit 0
else
    exit 1
fi

Deleted mttroot/mtt/bin/trans/icd2ICD_txt22txt.sh version [bb77e3bfab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

sys=$1
icd=${sys}_*_icd.txt2
ICD=${sys}_ICD.txt

echo Creating ${ICD}

# lbl.txt ICD Format:
# [#|%]ICD PortName EffortName,EffortUnit;FlowName,FlowUnit
# $1       $2       $3
# Comma / Semi-colon distinction unenforced

# icd.txt Format
# PortName EffortName,EffortUnit;FlowName,FlowUnit input|output,input|output
# $1       $2         $3         $4       $5       $6           $7

cat <<EOF > ${ICD}
## Interface Control Definition for System ${sys}
## ${ICD}: Generated by MTT `date`

EOF

cat ${icd}		|\
    sed 's/[\,\;]/\ /g'	|\
    gawk '
    ($2 != "null" && $6 == "input")  { printf ("Input:  %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "input")  { printf ("Input:  %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ($2 != "null" && $6 == "output") { printf ("Output: %-30s %-30s Causality: Effort   Units: %s\n", $2, $1, $3) }
    ($4 != "null" && $7 == "output") { printf ("Output: %-30s %-30s Causality: Flow     Units: %s\n", $4, $1, $5) }
    ' | sort >> ${ICD}

Deleted mttroot/mtt/bin/trans/icd_txt2m.sh version [9439894fee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

# Inform user
echo Creating $1_icd.m

#Create the component ICD file complete with headers.
echo "function icd = $1_icd" > $1_icd.m
echo "%% Component icd file ($1_icd.m)" >> $1_icd.m
echo "%% Generated by MTT at `date`" >> $1_icd.m

#Write out the variables 
gawk '{
       if (NF==2) {i++; print "icd."$1 "\t = \""$2"\";"}
     
     }
     END{
       if (i==0) print "icd = 0;"
        }' $1_icd.txt >> $1_icd.m

Deleted mttroot/mtt/bin/trans/ker_r2tex version [efd3e610b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ker_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994, 1996.
# Copyright (C) 2001 by Peter J. Gawthrop


# Inform user
echo Creating $1_ker.tex

# Remove the old log file
rm -f ker_r2tex.log

# Use reduce to accomplish the transformation
reduce >ker_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the constrained-state matrices file
in "$1_ker.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

MATRIX MTT_Matrix(MTTNy-MTTNu,MTTNy);

OUT "$1_ker.tex";

%Write out the kernel matrix
write "%Kernel  matrices $1";
write "%File: $1_ker.tex";
write"";

MTT_Matrix := MTTR$ 
MTT_Matrix_name := "MTTR"$
MTT_Matrix_n := MTTNy-MTTNu$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$

SHUT "$1_ker.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/labg_fig2ps version [3fff3368d1].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: labg_fig2ps

# Eps figures from labg rep.
echo Creating $1.ps
fig2ps --nogv --forcespecial --add=$MTT_LIB/latex/bg $1.fig >/dev/null

Deleted mttroot/mtt/bin/trans/landscape2portrait.sh version [2711c6c9b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: landscape2portrait.sh
# Converts one or more figure files from landscape mode to portrait mode

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ###############################################################

# Copyright (C) 2001 by Peter J. Gawthrop

figfiles=$*

for figfile in $figfiles; do
    count=`grep -c Landscape $figfile`
    if [ "$count" = "1" ]; then
       echo Converting $figfile
       mv $figfile ${figfile}.bak
       sed 's/Landscape/Portrait/'< ${figfile}.bak > $figfile
    fi
done

Deleted mttroot/mtt/bin/trans/lang_header version [63caba35a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243



















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

# Generates function header for a computer language
# PJ Gawthrop May 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  2000/05/11 08:03:02  peterg
## Remove the mtt no global stuff
##
## Revision 1.10  2000/04/18 11:14:32  peterg
## - parameters option
##
## Revision 1.9  2000/04/08 10:23:38  peterg
## Added -noglobal option
##
## Revision 1.8  1999/02/16 04:14:53  peterg
## Small change to modeline generation
##
## Revision 1.7  1999/01/20 22:19:21  peterg
## Puts emacs mode line at top of .m files
##
## Revision 1.6  1998/07/27 20:30:39  peterg
## Mods for dm rep - no globals ...
##
## Revision 1.5  1998/07/25 20:42:30  peterg
## No assignements for switch either
##
## Revision 1.4  1998/07/25 10:43:10  peterg
## No assignments of x or u if sm rep.
##
## Revision 1.3  1998/07/19 15:52:15  peterg
## Don't call the _input function - make it external from now on ...
##
## Revision 1.2  1998/05/24 12:47:39  peterg
## This still needs worjk doing for c generation!!
##
## Revision 1.1  1998/05/23 16:17:40  peterg
## Initial revision
##
###############################################################

# Args
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
    -noglobals)
	noglobals=noglobals;
	;;
    -parameters)
	parameters=parameters;
	;;
    *)
	echo $1 is an unknown option
        exit;;
  esac
  shift
done

# Set up the language specific stuff
system=$1
rep=$2
language=$3
args=$4
output=$5
extras=$6

case $language in
    m)
	modeline='% -*-octave-*- Put Emacs into octave-mode%';
	ext='m';
	Lc='#';
	Rc='#';
	Lb='(';
	Rb=')';
	;;
    p)
	modeline='% -*-octave-*- Put Emacs into octave-mode%';
	ext='m';
	Lc='#';
	Rc='#';
	Lb='[';
	Rb=']';
	;;
    c)
	ext='c';
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    java)
	ext='java';
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac


######### Octave (matlab) code
if [ "$language" = m ]; then
cat <<EOF
function $output = $1_$rep($args);
% $output = $1_$rep($args);
%System $system, representation $rep, language $language;
%File $1_$rep.$ext;
%Generated by MTT on `date`;
%
EOF
fi


######### c code
if [ "$language" = c ]; then
cat <<EOF
void $1_$rep() {
/*
System $system, representation $rep, language $language;
File $1_$rep.$ext;
Generated by MTT on `date`;

NB Arrays are be defined to be one larger than expected
 - the 0 element is not used.
*/

EOF

# Appropriate emacs mode line
cat <<EOF
$modeline
EOF

# Declarations
$MATRIX -q  <<EOF 
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;

  printf("$Lc Declare standard arrays $Rc\n");
  printf("  extern double mtty[%i]; \t $Lc $1_ode output $Rc\n", ny+1);
  printf("  extern double mttdx[%i]; \t $Lc $1_ode state derivative $Rc\n", nx+1);
  printf("  extern double mttx[%i]; \t $Lc $1_ode state $Rc\n", nx+1);
  printf("  extern double mttu[%i]; \t $Lc $1_ode input $Rc\n\n", nu+1);

  printf("$Lc Dummy variable list $Rc\n");
  printf("  double t0;\n\n");


  printf("$Lc State variable list $Rc\n");
  for i = 1:nx
    printf("  double mttx%i;\n",i);
  end;
printf("\n");

printf("$Lc State variable input list $Rc\n");
for i = 1:nu
  printf("  double mttu%i;\n",i);
end;
printf("\n");

printf("$Lc Counter $Rc\n");
printf("  int i;\n");
printf("\n");

printf("$Lc Time $Rc\n");
printf("  double t;\n");
printf("\n");

EOF

fi

if [ "$language" = "java" ]; then
cat <<EOF
public class $1_ode{
/*
System $system, representation $rep, language $language;
File $1_$rep.$ext;
Generated by MTT on `date`;
*/

EOF
fi

# Any extra bits ..
if [ -n "$extras" ]; then
cat <<EOF
$Lc Extra bits here $Rc
$extras
EOF
fi

# Globals
if [ -z "$noglobals" ]; then
    sympar2global_txt2lang $1 $language
else
cat<<EOF
global ...
mtt_no_globals ;
EOF
fi

# Explicit parameters
if [ -n "$parameters" ]; then
    sympar2par_txt2m $1 
fi

## if [ "$language" = "c" ] || [ "$language" = "m" ]; then
##   if [ "$rep" != "sm" ]&&[ "$rep" != "dm" ]&&[ "$rep" != "switch" ]; then
##   # Common part - ode (c and m)
##   # Use octave for this bit - needs the definition file
##   $MATRIX -q  <<EOF 
##     %System structure
##     [nx,ny,nu,nz,nyz] = $1_def;
## 
##   printf("$Lc====== Set up the state variables ======$Rc\n");
##   for i = 1:nx
##     printf("  mttx%i = mttx$Lb%i$Rb;\n",i,i);
##   end;
##   printf("\n");
## 
##   printf("$Lc====== Set up the input variables ======$Rc\n");
##   for i = 1:nu
##   printf("  mttu%i = mttu$Lb%i$Rb;\n",i,i);
##   end;
##   printf("\n");
## 
## EOF
##  fi
## fi
## #if [ "$language" = "java" ]; then

#$MATRIX -q <<EOF   
#    printf("JAVA\n");
#EOF

#fi

Deleted mttroot/mtt/bin/trans/lang_matrix.r version [f4b204b20b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in computer - language form
% P.J.Gawthrop  March 1998, May 1988
% Copyright (c) P.J.Gawthrop, 1998



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.7  2000/08/29 17:33:59  peterg
% % After much fiddling about ..
% %  now does global optimisation (over all elements of matrix / vector)
% %  still fails for _sm.m
% %
% % Revision 1.6  2000/08/25 09:23:40  peterg
% % Made both names the same!
% %
% % Revision 1.5  2000/08/24 17:12:01  peterg
% % Now optimises using SCOPE
% %
% % Revision 1.4  1998/07/27 17:34:59  peterg
% % Sorted syntax errors
% %
% % Revision 1.3  1998/07/27 16:31:10  peterg
% % Sorted out to work with mtt_r2m
% %
% % Revision 1.2  1998/05/23 15:00:27  peterg
% % Removed the name = matrix statement - now done by sed.
% %
% % Revision 1.1  1998/05/23 10:49:25  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



PROCEDURE Lang_Matrix();
BEGIN
%INAME(mtt_o); % Set temp name
GENTRAN mtt_matrix :=: mtt_matrix;

%     FOR row := 1:MTT_Matrix_n DO
%     BEGIN
%       IF MTT_Matrix_m>1 THEN
%       BEGIN
%         FOR col := 1:MTT_Matrix_m DO
%         BEGIN
%               IF (row EQ 1) AND (col EQ 1) THEN DELAYOPTS;
%               INAME(mtt_o); % Set temp name
%               %SETLENGTH(2); % Adjust optimisation
%               gentran declare mtt_matrix_element:REAL;
%               gentran declare mtt_matrix:REAL;
%               mtt_matrix_element := mtt_matrix(row,col);
%               GENTRAN mtt_matrix(row,col) ::=: mtt_matrix_element;
%               IF (row EQ MTT_matrix_n) AND (col EQ MTT_Matrix_m) THEN MAKEOPTS;
%             END;
%       END
%       ELSE
%         BEGIN
%           IF (row EQ 1) THEN DELAYOPTS;
%           INAME(mtt_o); % Set temp name
%           GENTRAN mtt_matrix(row) ::=: mtt_matrix(row,1);
%           IF (row EQ MTT_matrix_n) THEN MAKEOPTS;
%         END;
%     END
END;

END;;


Deleted mttroot/mtt/bin/trans/latex_equations.r version [25e7283cc5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Reduce file to generate equations
% Copyright (C) 2000 by Peter J. Gawthrop

PROCEDURE latex_equations;
BEGIN
IF MTTNx>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
  FOR Row := 1:MTTNx DO
  BEGIN
	write "\dot MTTX", Row, " &= "$
	write "{"$
	write MTTdx(Row,1)$
	write "}"$
        IF Row<MTTNx THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$
END$

IF MTTNz>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
FOR Row := 1:MTTNz DO
  BEGIN
	write "MTTz", Row, " &= "$
	write "{"$
	write MTTz(Row,1)$
	write "}"$
        IF Row<MTTNz THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$

END$

IF MTTNyz>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
FOR Row := 1:MTTNyz DO
  BEGIN
	write "0 &= "$
	write "{"$
	write MTTyz(Row,1)$
	write "}"$
        IF Row<MTTNyz THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$

END$

IF MTTNy>0 THEN
BEGIN
  write"\begin{equation}"$
  write"\begin{aligned}"$
FOR Row := 1:MTTNy DO
  BEGIN
	write "MTTy", Row, " &= "$
	write "{"$
	write MTTy(Row,1)$
	write "}"$
        IF Row<MTTNy THEN write "\cr"$
  END$
  write"\end{aligned}"$
  write"\end{equation}"$

END$

END$

END$

Deleted mttroot/mtt/bin/trans/latex_matrix.r version [a9950295a9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in latex form
% P.J.Gawthrop  January 22 1998
% Copyright (c) P.J.Gawthrop, 1998

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Version control history
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $Id$
%% $Log$
%% Revision 1.6  2000/10/10 21:02:42  peterg
%% *** empty log message ***
%%
%% Revision 1.5  2000/08/09 10:41:39  peterg
%% Changed criterion form 3 to 5
%%
%% Revision 1.4  1998/11/10 14:15:36  peterg
%% Now does matrix style for m<3
%%
%% Revision 1.3  1998/03/14 11:07:09  peterg
%% Removed comma from array subscript
%%
%% Revision 1.2  1998/02/25 22:11:28  peterg
%% Added big matrix version
%%
%% Revision 1.1  1998/01/22 09:59:36  peterg
%% Initial revision
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


PROCEDURE Latex_Matrix;
BEGIN
IF MTT_Matrix_m<10 THEN %% Do matrix style version
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      write "\begin{equation}";
      write MTT_Matrix_name, " = \begin{pmatrix}";
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          write "{", MTT_Matrix(Row,Col), "}";
          IF Col<MTT_Matrix_m THEN Write "&"
        END;

	IF Row<MTT_Matrix_n THEN Write "\cr";
      END;
      write "\end{pmatrix}";
      write "\end{equation}";
    END;
END
ELSE  %% write out the elements one-by-one.
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          MTT_element := MTT_Matrix(Row,Col);
          IF MTT_element NEQ 0 THEN
          BEGIN
            write "\begin{equation}";
            write MTT_Matrix_name, "_", Row, Col, " = {", MTT_element, "}\cr";
            write "\end{equation}";
          END;
        END;
      END;
    END;
END;
END;

END;;

Deleted mttroot/mtt/bin/trans/latex_matrix_no.r version [5376ee5dcb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in latex form
% P.J.Gawthrop  January 22 1998
% Copyright (c) P.J.Gawthrop, 1998

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Version control history
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $Id$
%% $Log$
%% Revision 1.7  2000/11/02 14:28:08  peterg
%% and up to 10 ...
%%
%% Revision 1.6  2000/10/10 21:02:42  peterg
%% *** empty log message ***
%%
%% Revision 1.5  2000/08/09 10:41:39  peterg
%% Changed criterion form 3 to 5
%%
%% Revision 1.4  1998/11/10 14:15:36  peterg
%% Now does matrix style for m<3
%%
%% Revision 1.3  1998/03/14 11:07:09  peterg
%% Removed comma from array subscript
%%
%% Revision 1.2  1998/02/25 22:11:28  peterg
%% Added big matrix version
%%
%% Revision 1.1  1998/01/22 09:59:36  peterg
%% Initial revision
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



PROCEDURE Latex_Matrix;
BEGIN
IF MTT_Matrix_m<10 THEN %% Do matrix style version
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      write "\begin{equation}";
      write MTT_Matrix_name, " = \begin{matrix}";
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          write "{", MTT_Matrix(Row,Col), "}";
          IF Col<MTT_Matrix_m THEN Write "&"
        END;

	IF Row<MTT_Matrix_n THEN Write "\cr";
      END;
      write "\end{matrix}";
      write "\end{equation}";
    END;
END
ELSE  %% write out the elements one-by-one.
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
      FOR Row := 1:MTT_Matrix_n DO
      BEGIN
        FOR Col := 1:MTT_Matrix_m DO
        BEGIN
          MTT_element := MTT_Matrix(Row,Col);
          IF MTT_element NEQ 0 THEN
          BEGIN
            write "\begin{equation}";
            write MTT_Matrix_name, "_", Row, Col, " = {", MTT_element, "}\cr";
            write "\end{equation}";
          END;
        END;
      END;
    END;
END;
END;

END;;

Deleted mttroot/mtt/bin/trans/latex_tidy version [99494feab4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186


























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: latex_tidy
# Tidies up LaTex format files
# P.J.Gawthrop 12 June 1990, Dec 1994
# Copyright (c) P.J.Gawthrop, 1990, 1994

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.24  2003/08/17 11:35:45  gawthrop
## Zapped ^ to uparrow conversion.
##
## Revision 1.23  2003/08/17 11:35:07  gawthrop
## Fixed problem with parentheses
##
## Revision 1.22  2002/09/26 08:33:54  geraint
## Removed comma from pattern so that braces are places around each argument
## of a function call. Added greek letter nu as a special variable.
##
## Revision 1.21  2002/08/21 18:11:15  geraint
## Replaced |x| with |{x}|. LaTeX now renders abs(fractions) correctly.
##
## Revision 1.20  2002/08/20 19:33:21  geraint
## Minor bug fixes and enhancements (I hope):
##
## Delimited expressions within function calls to prevent denominators from continuing beyond commas.
## Allow latex to adjust size of parentheses according to expression within.
## Replaced ^ with \uparrow (less misleading - latex maths doesn't understand operator precedence or words).
## Replaced abs(x) with |x| when x does not contain brackets.
##
## Revision 1.19  2002/08/19 14:37:05  geraint
## Fixed eta, beta, theta, Theta and zeta.
##
## Revision 1.18  2001/06/11 19:43:50  gawthrop
## MTT is now much more sophisticated in generating lbl files
## Labels can contain maths
## Repetative components are now broken
##
## Revision 1.17  2000/12/28 12:31:15  peterg
## *** empty log message ***
##
## Revision 1.16  2000/10/10 21:03:20  peterg
## *** empty log message ***
##
## Revision 1.15  1998/04/07 08:44:11  peterg
## zapped eta - it messes up theta
##
## Revision 1.14  1998/02/25 22:12:07  peterg
## Added , to regexp for subscripts
##
## Revision 1.13  1998/02/18 09:06:07  peterg
## Added dX0
##
## Revision 1.12  1998/02/09 14:11:08  peterg
## Added ctf --> D(s)
##
## Revision 1.11  1998/01/30 15:15:14  peterg
## Sorted out superscript problem
##
# Revision 1.10  1997/08/19  10:38:26  peterg
# Added pi to the list
#
## Revision 1.9  1997/02/24 13:02:17  peterg
## Added gamma and delta transformations
##
## Revision 1.8  1996/12/31 16:14:53  peterg
## Now handles multi-character subscripts.
##
## Revision 1.7  1996/12/19 10:24:29  peterg
## Uniform conversion of mttxi --> x_{i} for x,u,y and z
## Convert ???mttx to mtt x for  x,u,y and z
##
## Revision 1.6  1996/12/12 16:03:19  peterg
## Removed global argument stuff for y - its already done in the
## translation.
##
## Revision 1.5  1996/12/12 15:59:06  peterg
## Generic handling of subscript for y,u,ui
##
## Revision 1.4  1996/12/12 15:54:20  peterg
## Saved it.
##
## Revision 1.3  1996/08/30 14:36:46  peter
## Added some more subscripts.
## -- its high time this was rewritten in awk or perl!!!
##
## Revision 1.2  1996/08/19 14:35:51  peter
## Prettyfied z dot.
##
## Revision 1.1  1996/08/18 20:03:12  peter
## Initial revision
##
###############################################################
 
cat $1 | \
tr "[A-Z]" "[a-z]" | \
sed \
    -e "s/_\([a-z0-9]*\)/_{\1}/g" \
    -e "s/\// \\\over /g" \
    -e "s/[0-9a-z_]*mtty/mtty/g" \
    -e "s/[0-9a-z_]*mttu/mttu/g" \
    -e "s/mttx\([0-9]*\)/x_{\1}/g" \
    -e "s/mttex\([0-9]*\)/\\\chi_{\1}/g" \
    -e "s/mttddui\([0-9]*\)/\\\ddot{v}_{\1}/g" \
    -e "s/mttdui\([0-9]*\)/\\\dot{v}_{\1}/g" \
    -e "s/mttui\([0-9]*\)/v_{\1}/g" \
    -e "s/mttu\([0-9]*\)/u_{\1}/g" \
    -e "s/mtty\([0-9]*\)/y_{\1}/g" \
    -e "s/mttz\([0-9]*\)/z_{\1}/g" \
    -e "s/mttdx0/\\\dot x_0/g" \
    -e "s/mttdx/\\\dot x/g" \
    -e "s/mttdz/\\\dot z_/g" \
    -e "s/mttdu/\\\dot u_/g" \
    -e "s/dot_/ \\\dot /g" \
    -e "s/mtttf/G(s)/g" \
    -e "s/mttctf/D(s)/g" \
    -e "s/mtta/A/g" \
    -e "s/mttb/B/g" \
    -e "s/mttc/C/g" \
    -e "s/mttd/D/g" \
    -e "s/mtte/E/g" \
    -e "s/mttg/G/g" \
    -e "s/mtti/I/g" \
    -e "s/mttk/K/g" \
    -e "s/mttl/L/g" \
    -e "s/mttm/M/g" \
    -e "s/mtttheta/\\\Theta/g" \
    -e "s/mtto/O/g" \
    -e "s/mttv/V/g" \
    -e "s/mtty0/y_0/g" \
    -e "s/mttu0/u_0/g" \
    -e "s/mttx/x/g" \
    -e "s/mttz/z/g" \
    -e "s/mttyy/Y/g" \
    -e "s/mttw/w/g" \
    -e "s/mttt/T/g" \
    -e "s/mttpar//g" \
    -e "s/!/\\\/g" \
    -e "s/\\$//g" \
    -e "s/f\{0,1\}abs(\([^()]*\))/|{ \1 }|/g" \
    -e "s/(\([^(),]*\),/( { \1 } ,/g" \
    -e "s/,\([^(),]*\),/, { \1 } ,/g" \
    -e "s/,\([^(),]*\))/, { \1 } )/g" \
    -e "s/(/{\\\\left (/g" \
    -e "s/\*\*/^/g" \
    -e "s/\*/ /g" \
    -e "s/)/\\\right )}/g" \
    -e "s/sqrt/\\\sqrt/g" \
    -e "s/theta/\\\theta/g" \
    -e "s/tau/\\\tau/g" \
    -e "s/alpha/\\\alpha/g" \
    -e "s/beta/\\\beta/g" \
    -e "s/gamma/\\\gamma/g" \
    -e "s/delta/\\\delta/g" \
    -e "s/epsilon/\\\epsilon/g" \
    -e "s/\([^b(Th)(th)z]\)eta/\1\\\eta/g" \
    -e "s/^eta/\\\eta/g" \
    -e "s/kappa/\\\kappa/g" \
    -e "s/lambd/\\lambda/g" \
    -e "s/lambda/\\\lambda/g" \
    -e "s/mu/\\\mu/g" \
    -e "s/nu/\\\nu/g" \
    -e "s/phi/\\\phi/g" \
    -e "s/pi/\\\pi/g" \
    -e "s/rho/\\\rho/g" \
    -e "s/sigma/\\\sigma/g" \
    -e "s/omega/\\\omega/g" \
    -e "s/zeta/\\\zeta/g" \
    -e "s/infty/\\\infty/g" \
    -e "s/sin/\\\sin/g" \
    -e "s/cos/\\\cos/g" \
    -e "s/23/{23}/g" \
    -e "s/+-/ -/g" \
 | cat -s  | \
sed -e "s/ $//g" | \
tr  -s '\012' '\012' \
>junk

mv junk $1

Deleted mttroot/mtt/bin/trans/lbl2alias_txt version [5801411229].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2alias_txt2txt
# Creates the component aliases in text form

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/02 08:34:00  peterg
## Renamed to lbl2alias_txt2txt
##
## Revision 1.1  1998/07/02 08:14:07  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_alias.txt

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
grep '[%|#]ALIAS' $1_lbl.txt |\
gawk '{print $2,$3}' >> $1_alias.txt









Deleted mttroot/mtt/bin/trans/lbl2alias_txt2txt version [8e2770c7f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2alias_txt2txt
# Creates the component aliases in text form

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/07/17 19:46:56  peterg
## No change
##
## Revision 1.5  1998/07/17 16:31:37  peterg
## Ignore component aliases (with /)
##
## Revision 1.4  1998/07/03 15:21:26  peterg
## Replace sub by gsub -- need to replace ALL ,
##
## Revision 1.3  1998/07/03 13:49:03  peterg
## Flips the order of alias and name when $ is involved.
##
## Revision 1.2  1998/07/03 07:54:39  peterg
## Tidied
##
## Revision 1.1  1998/07/02 09:22:10  peterg
## Initial revision
##
## Revision 1.2  1998/07/02 08:34:00  peterg
## Renamed to lbl2alias_txt2txt
##
## Revision 1.1  1998/07/02 08:14:07  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_alias.txt

#Create the alias file complete with headers.
echo "# Alias file ($1_alias.txt)" > $1_alias.txt
echo "# Generated by MTT at `date`" >> $1_alias.txt

#Write out the variables 
    grep '[%|#]ALIAS' $1_lbl.txt |\
    gawk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          alias=$2; name =$3
        }
        else{
          alias=$3; name =$2
        }
        gsub(",","__",alias); #Replace ,
        n=split(alias,a,"|");
        for (i=1; i<=n; i++)
          print a[i] "\t" name;
	   }
      }
      END{
      print "###_END_OF_ALIAS_###"
     }' >> $1_alias.txt









Deleted mttroot/mtt/bin/trans/lbl2args_txt2out version [81dc428574].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Writes argument list to standard output ready for use in calling lbl file

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:08  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ## Revision 1.1  2001/06/11 15:06:58  gawthrop
  ## Now handles user-defined components
  ##
  ###############################################################

# Copyright (C) 2001 by Peter J. Gawthrop

if [ -f "$1_lbl.txt" ]; then
grep '[#%]ALIAS' $1_lbl.txt |\

gawk '{
  if (match($2,"\\$[0-9]")==1) ## Test if its a argument alias
  {
    i = substr($2,2);
    arg[i] = $3
    N++
  }
}
END{
    for (j=1;j<=N;j++){
      if (length(arg[j])==0)
        arg[j] = "??";
    }
    for (j=1;j<N;j++){
      if (length(arg[j])==0)
        arg[j] = "??";
      printf("%s;", arg[j]);
    }
    printf("%s\n",arg[N]);
}'
fi

Deleted mttroot/mtt/bin/trans/lbl2cmp_txt2m.pl version [aba4e1a1e3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301













































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/perl -w

### lbl2cmp_txt2m
## Creates _cmp.m from _lbl.txt
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

use strict;
use diagnostics;
use Getopt::Long;

sub usage;
sub read_cmp_file;
sub read_cmp_line;
sub name_anonymous_component;
sub port_or_component_or_junction;
sub read_lbl_file;
sub read_lbl_line;
sub sort_components;
sub sort_rule;
sub write_header;
sub write_body;
sub write_component;

my $debug = 0;

## fields to write to cmp.m
my (@component_name,
    %component_type,    
    %component_cr,
    %component_arg,
    %component_rep);

my (%sorted_component_list,
    %component_class,
    %anonymous_component_type_index);

## files to read/write
my ($cmp, $lbl, $out);

my $sys = '';

GetOptions ('sys=s' => \$sys,
	    'debug' => \$debug);

die usage() if ($sys eq '');

if ($debug) {
    my $logfile = "lbl2cmp_txt2m_${sys}.log";
    open (LOG, ">$logfile") or die ("MTT: lbl2cmp_txt2m, cannot open $logfile");
}

$cmp = "${sys}_cmp.txt";
$lbl = "${sys}_lbl.txt";
$out = "${sys}_cmp.m";

read_cmp_file();
read_lbl_file();
sort_components();
write_header();
write_body();

close (LOG) if ($debug);

sub usage() {
    return "Usage: lbl2cmp_txt2m --sys=<sys>\n";
}

sub read_cmp_file() {
    my ($line, $name, $type, $class, $rep, $i);

    open (CMP, $cmp) or die ("MTT: lbl2cmp_txt2m, cannot open $cmp");

    $i = 0;
    while (<CMP>) {
	
	chomp;
	# skip blank lines
	next if (/^(\s)*$/);
	# skip comments
	next if (/^(\s)*[%\#]/);
	# remove leading and trailing whitespace
	s/^\s*(\S.*\S)\s*$/$1/;
	
	$line = $_;
	print LOG "read_cmp_file: line='${line}'\n" if ($debug);

	# cmp provides type, name and repetition information
	# class is inferred from type and name
	# (cr and args are placeholders)

	($type, $name, $rep) = read_cmp_line($line);
	$name = name_anonymous_component($type) if ($name eq '');	
	$class = port_or_component_or_junction ($type, $name);

	$component_name  [$i++]   = $name;
	$component_type  {$name}  = $type;
	$component_rep   {$name}  = $rep;
	$component_cr    {$name}  = '';
	$component_arg   {$name}  = '';
	$component_class {$name}  = $class;
    }
    close (CMP);
}

sub read_cmp_line() {
    my $line = $_;
    my ($type, $name, $rep, $misc);
    
    ($type, $misc) = split (/:/, $line);
    $type = $line unless defined ($type);

    if (defined ($misc)) {
	($name, $rep) = split (/\*/, $misc);
	$name = $misc unless defined ($name);
    }

    $name = '' unless defined $name;
    $rep  = 1  unless defined $rep;
    
    print LOG "read_cmp_line: type='$type', name='$name', rep='$rep'\n" if ($debug);
    return ($type, $name, $rep);
}

sub name_anonymous_component() {
    my $type = $_;
    my ($name, $num);
    if (defined ($anonymous_component_type_index{$type})) {
	$num = ++$anonymous_component_type_index{$type};
	$name = "mtt${type}_${num}";
    } else {
	$anonymous_component_type_index{$type} = 1;
	$name = "mtt${type}";
    }
    print LOG "name_anonymous_component: type='${type}', name='${name}'\n" if ($debug);
    return ($name);
}

sub port_or_component_or_junction() {

    # ports are internal SS components (SS:[...])
    # junctions are '0' and '1' types
    # everything else is a component, including external SS types.

    my ($type, $name) = @_;
    my $retval;
    if ($type eq "SS") {
	$_ = $name;
	if (/\[.+\]/) {
	    $retval = "port";
	} else {
	    $retval = "component";
	}
    } elsif ($type eq "0") {
	$retval = "0junction";
    } elsif ($type eq "1") {
	$retval = "1junction";
    } else {
	$retval = "component";
    }
    print LOG "port_or_component_or_junction: type='$type', name='$name' class='$retval'\n" if ($debug);
    return ($retval);
}

sub read_lbl_file() {
    my (@line, $name, $type, $cr, $arg, $i);
    
    open (LBL, $lbl) or die ("MTT: lbl2cmp_txt2m, cannot open $lbl");
    
    $i = 0;
    while (<LBL>) {
	
	chomp;
	# skip blank lines
	next if (/^(\s)*$/);
	# skip comments
	next if (/^(\s)*[%\#]/);
	# remove leading and trailing whitespace
	s/^\s*(\S.*\S)\s*$/$1/;
	
	# lbl provides name, cr and arg information

	($name, $cr, $arg) = read_lbl_line (@line);
	
	$component_cr{$name}  = $cr;
	$component_arg{$name} = $arg;
    }

    close (LBL);
}

sub read_lbl_line() {
    my @line = @_;
    my ($name, $cr, $arg);

    @line = split (/\s+/);
    $name = shift (@line);

    # strip repetitions (if any)
    $name =~ s/([^\*]*)\*.*/$1/;

    $cr  = shift (@line);
    $arg = shift (@line);

    $cr   = '' unless defined ($cr);
    $arg  = '' unless defined ($arg);
    
    print LOG "read_lbl_line: name='$name' cr='$cr' arg='$arg'\n" if ($debug);
    return ($name, $cr, $arg);
}

sub write_header() {
    my $date = `date`;
    chomp ($date);

    open (OUT, ">$out") or
	die "MTT: cannot open $out for writing.\n";
    
    print OUT << "EOF";
## $out -*-octave-*-
## Generated by MTT on $date
    
function [comp_type, name, cr, arg, repetitions] = ${sys}_cmp(i)

EOF

    close (OUT);
}

sub sort_components ()
{
    # sorts components into alphabetical order (type:name)
    # within the classes: ports, components then junctions.

    my ($name, $class, $i, $j, $target);

    $i = 0;
    foreach $target ("port", "component", "0junction", "1junction") {
	my @sorted_list = sort (sort_rule @component_name);
	for $name (@sorted_list) {
	    $class = $component_class{$name};
	    if ($class eq $target) {
		if (! defined ($sorted_component_list{$name})) {
		    $sorted_component_list{$name} = $i++;
		    print LOG "sorted: '$name' '$i'\n" if ($debug); 
		}
	    }
	}
    }
}

sub sort_rule ()
{
    my ($type1, $name1, $string1,
	$type2, $name2, $string2);

    $name1 = $a;
    $name2 = $b;

    $type1 = $component_type{$name1};
    $type2 = $component_type{$name2};

    $string1 = sprintf ("%s:%s", $type1, $name1);
    $string2 = sprintf ("%s:%s", $type2, $name2);

    return ($string1 cmp $string2);
}
    
    
sub write_body() {
    my (%reverse_sorted_component_list, $name);
    
    %reverse_sorted_component_list = reverse (%sorted_component_list);
    for (my $key = 0; $key < scalar @component_name; $key++) {
	$name = $reverse_sorted_component_list{$key};
	write_component ($name);
    }
}

sub write_component() {
    my ($name) = @_;

    my $i = $sorted_component_list{$name}+1;

    open (OUT, ">>$out") or
	die "MTT: cannot open $out for writing.\n";

    print OUT
	"if (i == $i)\n" .
	"\tcomp_type   = '$component_type{$name}';\n" .
	"\tname        = '$name';\n" .
	"\tcr          = '$component_cr{$name}';\n" .
	"\targ         = '$component_arg{$name}';\n" .
	"\trepetitions =  $component_rep{$name} ;\n" .
	"end\n";

    close (OUT);
}

Deleted mttroot/mtt/bin/trans/lbl2component version [f6ffaf551e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2component
# Creates the commands to pull down components from libraries

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2003/08/09 00:29:52  geraint
## Fixed grep error when lbl file doesn't exist.
##
## Revision 1.4  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  1998/07/28 11:23:31  peterg
## Put / explicitly in awk.
##
## Revision 1.2  1998/07/27 08:38:11  peterg
## Just look for / in the relevant field.
##
## Revision 1.1  1998/07/17 17:04:50  peterg
## Initial revision
##
###############################################################

if [ -f "$1_lbl.txt" ]; then
  ## Regexp for an alias
  alias='^[#%]ALIAS'
  grep $alias $1_lbl.txt | gawk '{if (match($3,"/")>0) print "mtt -q compcopy " $3}'
fi









Deleted mttroot/mtt/bin/trans/lbl2cr_txt2r version [44253224e2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2cr_txt2r

# Label file to constitutive relationship conversion
# P.J.GawthropNovemebr 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:32:06  peterg
## Put under RCS
##
# Revision 1.3  1996/11/03  21:11:44  peterg
# Removed END; statement
#
## Revision 1.2  1996/11/02 10:20:53  peterg
## Created from lbl2sympar
##
###############################################################


# Inform user
echo "Creating $1_cr.r"

rm -f mtt_error

#Write some file headers
echo "%% constitutive relationship  file ($1_cr.r)" > $1_cr.r
echo "%% Generated by MTT at `date`" >> $1_cr.r

# This is the main transformation using awk
gawk -f $MTTPATH/trans/awk/lbl2cr.awk <$1_lbl.txt  2>mtt_error.txt | \
	sh >> $1_cr.r

# Now invoke the standard error handling.
#mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/lbl2icd_txt2txt.sh version [2a3b38ea21].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2icd_txt2txt
# Creates the component ICDs in text form

# Adapted from lbl2alias_txt2txt

sys=$1
icd=${sys}_icd.txt
lbl=${sys}_lbl.txt

# Inform user
echo Creating ${icd}

#Create the ICD file complete with headers.
echo "# Component ICD file ($1_icd.txt)" > ${icd}
echo "# Generated by MTT at `date`" >> ${icd}

#Write out the variables 
    grep '[%|#]ICD' ${lbl} |\
    gawk '{
      if (match($3,"/")==0){
        if (match($2,"\\$")==0){
          icd=$2; name =$3
        }
        else{
          icd=$3; name =$2
        }
        n=split(icd,a,"|");
        for (i=1; i<=n; i++)
          print a[i] "\t" name;
	   }
      }
      END{
      print "###_END_OF_ICD_###"
     }' >> ${icd}

Deleted mttroot/mtt/bin/trans/lbl2modpar_txt version [7d9600f181].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2modpar_txt2txt
# Creates the component modpares in text form

# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$
## Revision 1.1  2001/03/29 19:24:14  gawthrop
## Can now use c representations of crs when using -c option
##
###############################################################

# Inform user
echo Creating $1_modpar.txt

#Create the modpar file complete with headers.
echo "# Modpar file ($1_modpar.txt)" > $1_modpar.txt
echo "# Generated by MTT at `date`" >> $1_modpar.txt

#Write out the variables 
grep '[%|#]MODPAR' $1_lbl.txt |\
gawk '{printf("%s\t%s\n", $2,$3)}' >> $1_modpar.txt

echo "# End of $1_modpar.txt" >> $1_modpar.txt








Deleted mttroot/mtt/bin/trans/lbl2sympar_txt2r version [d2dc2feb77].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2sympar_txt2r

# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2000/12/28 12:32:06  peterg
## Put under RCS
##
# Revision 1.6  1996/12/07  19:39:51  peterg
# Minor debugging.
#
## Revision 1.5  1996/09/12 17:18:44  peter
## Don't add an RCS header ..
##
## Revision 1.4  1996/08/30 19:01:21  peter
## Added headers to sympar file.
##
## Revision 1.3  1996/08/30 10:18:33  peter
## New path for awk script.
##
## Revision 1.2  1996/08/30 10:04:20  peter
## Included `;' in demimiter list.
##
# Revision 1.1  1996/08/24  13:34:09  peter
# Initial revision
#
###############################################################


# Inform user
echo "Creating $1_sympar.r"

rm -f mtt_error

#Write some file headers
echo "%% Symbolic parameter file ($1_sympar.r)" > $1_sympar.r
echo "%% Generated by MTT at `date`" >> $1_sympar.r

# This is the main transformation using awk
tr ';' ',' <  $1_lbl.txt | \
gawk -f $MTTPATH/trans/awk/lbl2sympar.awk | sort >> $1_sympar.r 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/lbl_txt2tex version [04d132b22f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156




























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl_txt2tex
# Latex summary of the lbl file

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.11  2002/04/19 08:39:45  gawthrop
## Changed \# to # and \% to # to avoid warning in latest gawk version
##
## Revision 1.10  2000/12/28 12:32:06  peterg
## Put under RCS
##
## Revision 1.9  2000/11/16 13:11:06  peterg
## Included PAR and UNITS declarations
##
## Revision 1.8  1999/02/17 21:42:19  peterg
## Replaced print by printf to avoid extra nl in paragraph command.
##
## Revision 1.7  1998/07/27 12:56:26  peterg
## Splits up | separated expressions.
##
## Revision 1.6  1998/07/27 10:56:31  peterg
## Cosmetics.
##
## Revision 1.5  1998/07/27 08:29:44  peterg
## Include a comment field in the aliases
##
## Revision 1.4  1998/07/17 19:46:44  peterg
## Included component alias.
##
## Revision 1.3  1998/07/16 20:39:52  peterg
## More cosmetic changes
##
## Revision 1.2  1998/07/16 16:34:09  peterg
## Cosmetic changes
##
## Revision 1.1  1998/07/16 16:31:47  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_lbl.tex

#Create the alias file complete with headers.
echo "% Label summary file ($1_lbl.tex)" > $1_lbl.tex
echo "% Generated by MTT at `date`" >> $1_lbl.tex

#Write out the Description
    grep '[%|#]SUMMARY' $1_lbl.txt | sed 's/_/\\_/g'  |\
    gawk '{
           printf("\\paragraph{System %s:",$2);
           for (i=3;i<=NF;i++) printf("%s ",$i); print ""
           print  "}"
         }' >> $1_lbl.tex
#    grep '[%|#]DESCRIPTION' $1_lbl.txt | sed 's/_/\\_/g'  |\
#    gawk '{
#           for (i=2;i<=NF;i++) printf("%s ",$i); print ""
#         }' >> $1_lbl.tex

#Write out the aliases
cat <<EOF >> $1_lbl.tex
\paragraph{Interface information:}
\begin{description}
EOF
    grep '[%|#]ALIAS' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
      N=split($2,a,"|");
      for (i=1;i<=N;i++){
        if (match(a[i],"\\$")>0){
          printf("\\item [Parameter \\%s] represents actual parameter ",a[i])
        }
        else if (match($3,"/")>0){
          printf("\\item [Component %s]  is in library ",a[i])
        }
        else{
          printf("\\item [Port %s] represents actual port ",a[i])
        }
        printf("\\textbf{%s}",$3)
        if (match($4,"[#%]")==1) printf(" -- ");
        for (j=5;j<=NF;j++) printf(" %s", $j)
        printf("\n");
        }
      }
    END{if (NR==0) print "\\item This component has no ALIAS declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF

#Write out the VARS
cat <<EOF >> $1_lbl.tex
\paragraph{Variable declarations:}
\begin{description}
EOF
    grep '[%|#][V|P]AR' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
        printf("\\item %s\n",$2)
      }
    END{if (NR==0) print "\\item This component has no PAR declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF


#Write out the UNITS
cat <<EOF >> $1_lbl.tex
\paragraph{Units declarations:}
\begin{description}
EOF
    grep '[%|#]UNITS' $1_lbl.txt | sed 's/_/\\_/g' |\
    gawk '{
        printf("\\item [Port %s] has domain %s\n",$2, $3)
	printf("\\begin{description}\n")
        printf("\\item [Effort units] %s\n",$4)
        printf("\\item [Flow units] %s\n",$5)
	printf("\\end{description}\n")
      }
    END{if (NR==0) print "\\item This component has no UNITs declarations"
}' >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF

# Write the actual lbl file
cat >> $1_lbl.tex <<EOF
\subsubsection*{The label file: $1\_lbl.txt}
\begin{verbatim}
EOF
cat $1_lbl.txt >> $1_lbl.tex
cat >> $1_lbl.tex <<EOF
\end{verbatim}
EOF







Deleted mttroot/mtt/bin/trans/lde_r2tex version [d2cd6c0a98].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lde_r2tex
# Reduce differential-algebraic to LaTex differential-algebraic equations.
# P.J.Gawthrop 10th May 1991, April 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/01/23 15:51:01  peterg
## Repleace eqnarray by equation + aligned -- this works with Latex2html
##
## Revision 1.2  1996/12/20 08:59:10  peterg
## Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
## conversion.
##
## Revision 1.1  1996/12/20 08:53:57  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_lde.tex

# Remove the old log file
rm -f lde_r2tex.log

# Use reduce to accomplish the transformation
reduce >lde_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the differential-algebraic equations file
in "$1_lde.r";

%Read the symbolic parameter file
%%in "$1_sympar.r";



OFF Echo;
OFF Nat;

%Read the substitution file
IN "$1_subs.r";

%Read the simplifying expressions file
IN "$1_simp.r";

OUT "$1_lde.tex";

%Write out the  differential-algebraic equations.

write "%File: $1_lde.tex";

write "%ordinary differential equations";
write "% Generated by MTT";

IF MTTNyz>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_lde_x}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNx DO
  BEGIN
	write "{";
	write MTTl(Row,1);
	write "}";
	write " &= 0";
        IF Row<MTTNx THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;


IF MTTNy>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_lde_y}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNy DO
  BEGIN
	write "MTTy", Row, " &= ";
	write "{";
	write MTTy(Row,1);
	write "}";
        IF Row<MTTNy THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;





SHUT "$1_lde.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/m/abg2cbg.m version [27f38055ab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550






































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [port_bonds, status] = abg2cbg(system_name, system_type, full_name,
					port_bonds,
					port_bond_direction,
					port_status,
					derivative_causality,
					typefile, infofile, errorfile)

  ## abg2cbg - acausal to causal bg conversion
  ##
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function  abg2cbg.m
  ## Acausal bond graph to causal bond graph: mfile format
  ## [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.53  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.52  2004/09/07 18:22:53  geraint
  ## ## Issues a more helpful error message than the cryptic Octave stuff
  ## ## if there are unconnected ports.
  ## ##
  ## ## Revision 1.51  2004/02/20 20:42:40  geraint
  ## ## Initialize Flipped.cons with [] instead of "".
  ## ##
  ## ## Revision 1.50  2003/03/13 15:18:39  gawthrop
  ## ## Now uses __ to delimit subsystems in names.
  ## ##
  ## ## Revision 1.49  2001/07/26 05:02:53  geraint
  ## ## Now writes cbg.fig when under-causal (again).
  ## ##
  ## ## Revision 1.48  2001/07/23 23:20:27  gawthrop
  ## ## Now only writes to type.sh and cbg.m when causality is completed.
  ## ##
  ## ## Revision 1.47  2000/03/20 16:45:26  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.46  2000/02/17 16:14:49  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.45  1999/11/01 03:17:45  peterg
  ## ## Added extra info - current subsystem
  ## ##
  ## ## Revision 1.44  1999/03/11 23:54:11  peterg
  ## ## Include possibility of vector SS when finding port_bond_index
  ## ##
  ## ## Revision 1.43  1998/12/14 15:19:36  peterg
  ## ## Added missing "derivative_causality," argument to recursive call of
  ## ## this function
  ## ##
  ## ## Revision 1.42  1998/12/03 14:55:40  peterg
  ## ## Now uses number of components with complete causality to measure
  ## ## progress of algorithm -- Done.
  ## ## This replaces bond count -- done.
  ## ##
  ## ## Revision 1.41  1998/11/20 10:52:28  peterg
  ## ## Copies port bonds if the port bonds ARE set
  ## ## -- replaces Copies port bonds if the component bonds are NOT set
  ## ##
  ## ## Revision 1.40  1998/09/02 11:47:09  peterg
  ## ## Now uses explicit ordered list of ports instead of port.index.
  ## ## Note that subsystems are still treated in arbitrary order.
  ## ##
  ## ## Revision 1.39  1998/08/25 20:06:16  peterg
  ## ## Writes flipped port info
  ## ##
  ## ## Revision 1.38  1998/08/25 09:15:28  peterg
  ## ## Fixed couple of problems with using two copies of the one data
  ## ## stucture:
  ## ##
  ## ## ABG_field and ABG.field
  ## ##
  ## ## Maybe this is conceptually wrong?
  ## ##
  ## ## Revision 1.37  1998/08/25 08:33:29  peterg
  ## ## Now does ports as well - fixed string prob by using deblank
  ## ##
  ## ## Revision 1.36  1998/08/25 06:44:40  peterg
  ## ## Furhter revisions
  ## ##
  ## ## Revision 1.35  1998/08/24 10:16:32  peterg
  ## ## Coverted to new structure - still needs status sorting.
  ## ##
  ## ## Revision 1.34  1998/08/24 07:35:03  peterg
  ## ## About to go to new abg format.
  ## ##
  ## ## Revision 1.33  1998/07/29 13:36:37  peterg
  ## ## Don't set port status if there aren't any ports.
  ## ##
  ## ## Revision 1.32  1998/07/28 19:06:11  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.31  1998/07/28 13:15:10  peterg
  ## ## Vector SS ports included.
  ## ##
  ## ## Revision 1.30  1998/07/27 20:29:49  peterg
  ## ## Had another go at causality ....
  ## ##   1. Impose external causality onto all port bonds
  ## ##   2. Set C_cause.m so that it DOESN'T set causality
  ## ##       -- I_cause is already ok !
  ## ##
  ## ## Revision 1.29  1998/07/10 09:01:42  peterg
  ## ## Added error + info file in new form
  ## ##
  ## ## Revision 1.28  1998/07/08 09:23:42  peterg
  ## ## Undid the previous change -- needs more thought.
  ## ##
  ## ## Revision 1.27  1998/07/03 19:03:31  peterg
  ## ## Always override the causality of port bonds!
  ## ##
  ## ## Revision 1.26  1998/06/27 13:24:04  peterg
  ## ## Causality now set correctly for:
  ## ## 	multi-port C and I
  ## ## 	C and I with arrows pointing in
  ## ##
  ## ## Revision 1.25  1998/06/25 18:53:30  peterg
  ## ## Actually, the previous comment was optimistic.
  ## ## The port causalities on a compound are now forced to be the same as
  ## ## that specified by a a _cuase.m file (if it exists)
  ## ##
  ## ## Revision 1.24  1998/06/25 17:45:03  peterg
  ## ## No change -- but checked that explicit causality works!
  ## ##
  ## ## Revision 1.23  1998/04/04 10:46:37  peterg
  ## ## Coerces port bonds to have smae direction as the imposing bonds
  ## ## _cbg now generates the (coerced) components as welll as the (coerced)
  ## ## causality.
  ## ##
  ## ## Revision 1.22  1997/08/19 10:21:09  peterg
  ## ## Only copy port cuaslity info if not already set within the
  ## ## subsystem. I thought I'd done this already ....
  ## ##
  ## ## Revision 1.21  1997/08/18 16:25:25  peterg
  ## ## Minor bug fixes
  ## ##
  ## ## Revision 1.20  1997/08/18 12:45:24  peterg
  ## ## Replaced: comp_bonds = bonds(bond_list,:)
  ## ## by: 	for kk = 1:n_comp
  ## ## 	  comp_bonds(kk,:) = bonds(comp(kk),:);
  ## ## 	end;
  ## ##
  ## ## to avoid an octave bug in 1.92.
  ## ##
  ## ## Revision 1.19  1997/08/18 11:23:59  peterg
  ## ## Main component loop now misses out the ports (SS:[]) -- the causality
  ## ## is merely passed through these components.
  ## ##
  ## ## Revision 1.18  1997/08/08 08:11:04  peterg
  ## ## Suppress compoment trace.
  ## ##
  ## ## Revision 1.17  1997/08/07 16:10:13  peterg
  ## ## Move the if status ..  to the beginning of the main loop.
  ## ##
  ## ## Revision 1.16  1997/08/04 13:11:19  peterg
  ## ## Only change to component-orientated causality for simple components
  ## ## NOT for compound components.
  ## ##
  ## ## Revision 1.15  1997/01/05 12:25:59  peterg
  ## ## More informative message about port bonds incompatible with  ports
  ## ##
  ## ## Revision 1.14  1996/12/31 16:20:42  peterg
  ## ## Just write causality information at top level -- it gets a bit
  ## ## voluminous if written at deeper levels.
  ## ##
  ## ## Revision 1.13  1996/12/31 11:49:09  peterg
  ## ## Don't copy port bond causality if already set -- allows subsystem
  ## ## causality to be preset directely on named SS.
  ## ##
  ## ## Revision 1.12  1996/12/31 11:42:36  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.11  1996/12/07  17:10:48  peterg
  ## ## Allows port SS at top level - ie takes it to be an ardianry SS at top
  ## ## level.
  ## ##
  ## ## Revision 1.10  1996/12/04 21:48:55  peterg
  ## ## Compares full-name with empty string (instead of testing for zero
  ## ## length.
  ## ##
  ## ## Revision 1.9  1996/08/30  12:55:40  peter
  ## ## More heirachical stuff added.
  ## ##
  ## ## Revision 1.8  1996/08/26  10:04:25  peterg
  ## ## Fixed error due to a line wrap.
  ## ##
  ## ##Revision 1.7  1996/08/16  12:58:58  peter
  ## ## Now does preferred causality of I and C.
  ## ## Revision 1.6  1996/08/09 08:27:29  peter
  ## ## Added a few deguging lines
  ## ##
  ## ## Revision 1.5  1996/08/08 18:06:18  peter
  ## ## Unified file naming scheme
  ## ##
  ## ## Revision 1.4  1996/08/08 08:30:06  peter
  ## ## The cbg filename contains the system name - this makes things easier
  ## ## when setting up the m to fig translation and m to ese translation
  ## ##
  ## ## Revision 1.3  1996/08/05 18:53:21  peter
  ## ## Fixed bug passing causality from subsystems.
  ## ##
  ## ## Revision 1.2  1996/08/05 15:41:41  peter
  ## ## Now recursively does causality on subsystems.
  ## ##
  ## ## Revision 1.1  1996/08/04 17:55:55  peter
  ## ## Initial revision
  ## ##
  ## ###############################################################


  mtt_info(sprintf("Completing causality for subsystem %s", system_name), infofile);

  pc = '%';
  sub_delim = "__";		# Subsystem delimiter

  if nargin<1
    system_name = 'no_name';
  end;

  if nargin<4
    port_bonds = [];
  end;

  if nargin<5
    infofile = 'stdout';
  end;

  ## Are we at the top level of the heirarchy?
  at_top_level = strcmp(full_name, '');

  ## Create a file to contain shell commands which map subsystem types 
  ## onto components
#   if at_top_level # Then at top level
#     fprintf(typefile, "# Commands to map types onto subsystems\n");
#     fprintf(typefile, "# File %s_type.sh\n", system_name);
#     fprintf(typefile, "# Generated by MTT at %s\n\n", ctime(time));
#   end;

  ## Create the (full) system name
  if at_top_level
    full_name = system_name;
    system_type = system_name;
  else
    full_name = [full_name, sub_delim, system_name];
  end;
  
  fun_name = [system_type, "_abg"];

  disp("====================================");
  disp(["BEGIN: ", full_name, " (", fun_name, ")"]);
  disp("====================================");

  ## If no such function - then there is nothing to be done.
  if exist(fun_name)~=2
    mtt_error(["m-file ", fun_name, " does not exist"], errorfile);
    bonds = [];
    status = [];
    return
  end;

  ## Evaluate the system function to get the bonds and number of ports
  ##eval(["[bonds,components,n_ports,N_ports]=", fun_name, ";"]);
  eval(["[ABG]=", fun_name, ";"]);
  !isfield(ABG,"subsystems")
  if !isfield(ABG,"subsystems")# Are there any subsystems?
    return;			# Nothing to do
  else
    [n_subsystems,junk] = size(fieldnames(ABG.subsystems))
  endif
  
  if isfield(ABG,"portlist")# Are there any ports?
    [n_ports,junk] = size(ABG.portlist);
    ##     port_bond_index=zeros(n_ports,1);
    i_port = 0;
    for i=1:n_ports		# Find indices of the internal ports
      name = deblank(ABG.portlist(i,:)); # Name of this port
      eval(["port = ABG.ports.",name,";"]); # Extract port info
      for j=1:length(port.connections) # Maybe vector SS
	port_bond_index(++i_port) = abs(port.connections(j));
      endfor;
    endfor
  else
    n_ports = 0;
  endif				   

  
  [n_bonds,columns] = size(ABG.bonds);# Find number of bonds
  if (columns ~= 2)&(n_bonds>0)
    error("Incorrect bonds matrix: must have 2 columns");
  end;

  
  ## Find number of components
  ##  [n_components,m_components] = size(components);
  ##  if n_components==0 # there is nothing to be done
  ##    return
  ##  end;


  
  ## Coerce the port (SS:[]) component bonds to have the same direction as
  ## of the bonds in the encapsulating system -- but not at top level
  Flipped.ports="";Flipped.subs="";Flipped.cons=[];
  
  if (n_ports>0)&&(!at_top_level) # Coerce directions
    for i=1:n_ports
      name = deblank(ABG.portlist(i,:)); # Name of this port
      eval(["port = ABG.ports.",name,";"]); # Extract port info
      disp ("----");
      i
      name
      port
      port_bond_direction
      port.connections

      if (i > max (size (port_bond_direction)))
	the_system = sprintf ("\"%s:%s\"", system_type, system_name);
	mtt_error (sprintf ("Please check that %s has no disconnected ports.", the_system));
	mtt_error (sprintf ("abg2cbg: port_bond_direction(%d) does not exist.", i));
	exit(1);
      end
      if (sign(port.connections)!=port_bond_direction(i)) # Direction different?
      	eval(["ABG.ports.",name,".connections = - port.connections;"]); # Flip direction at port
	Flipped.ports=[Flipped.ports;name];	# Remember which port has been flipped
        bond_index=abs(port.connections); # Index of bond on port
      	mtt_info(sprintf("Flip port %s on %s" ...
			 ,name,full_name),infofile); # And report
      	for [subsystem,name] = ABG.subsystems # and at the other end
	  for k=1:length(subsystem.connections)
	    if (abs(subsystem.connections(k))==bond_index) # Then flip the connection
	      eval(["ABG.subsystems.",name,".connections(k)   = -subsystem.connections(k);"]);
	      Flipped.subs=[Flipped.subs;name];	# Remember which subsystem has been flipped
	      Flipped.cons=[Flipped.cons;k];	# Remember which connection has been flipped
      	      mtt_info(sprintf("Flip subsystem %s on %s" ...
			       ,name,full_name),infofile); # And report
	    endif
	  endfor
      	endfor			# subsystem = ABG.subsystems

      	ABG.bonds(bond_index,:) = -ABG.bonds(bond_index,:);	# Flip the bond causalities 
	##(these are arrow-orientated)
      endif			# Is the direction different?
    endfor			# port = ABG.ports
  endif				# (n_ports>0)&&(!at_top_level)

  ## If not at top level, then copy the port bonds.
  if !at_top_level		# Find number of port bonds

    for j=1:n_ports
      jj = port_bond_index(j); # The index of the bond
      for k = 1:2
	##	if ABG.bonds(jj,k)==0 # only copy if not already set
	##	  ABG.bonds(jj,k) = port_bonds(j,k);
	##	endif
	if port_bonds(j,k)!=0	# only copy if port bonds are set
	  ABG.bonds(jj,k) = port_bonds(j,k);
	endif
      endfor
    endfor
  else
    n_port_bonds=0;
  endif
  
  ## Causality indicator
  total = 2*n_bonds;
  done = sum(sum(abs(ABG.bonds)))/total*100;

  fields=["ports";"subsystems"];	# Do for both ports and subsystems -
  ## ports first
  for i=1:2
    field=deblank(fields(i,:));
    if isfield(ABG,field);
      eval(["ABG_field = ABG.",field, ";"]);
      field,ABG_field
      
      sum_ok = 0; n_comp = 0;
      for [subsystem,name] = ABG_field# Find % status = 0 (causally complete)
    	eval(["ok = (ABG_field.",name,".status==0);"]);
	sum_ok = sum_ok + ok; n_comp ++;
      endfor;
      Done = sum_ok/n_comp*100
      
      ## Outer while loop sets preferred causality
      ci_index=1;

      ##      for [subsystem,name] = ABG_field# Set new status field to -1
      ##    	eval(["ABG_field.",name,".status=-1;"]);
      ##      endfor;
      
      while( ci_index>0)
    	old_done = inf;
    	old_Done = inf;
	
    	while Done!=old_Done	# Inner loop propagates causality
	  old_Done = Done;
	  for [subsystem,name] = ABG_field
	    name,subsystem
      	    if subsystem.status != 0 # only do this if causality not yet complete
	      comp = subsystem.connections; # Get the bonds on this component
	      bond_list = abs(comp);
	      direction = sign(comp)'*[1 1];
              n_bonds = length(bond_list);

	      if strcmp(subsystem.type,"0") # Change names
	    	subsystem.type = "zero";
	      end;
	      if strcmp(subsystem.type,"1")
	    	subsystem.type = "one";
	      end;
	      
	      cause_name = [subsystem.type, "_cause"];# Component causality procedure name
	      eqn_name = [subsystem.type, "_eqn"]; #Component equation procedure name
	      
	      comp_bonds=[];	# Bonds on this component (arrow-orientated) -- these become the
	      for kk = 1:n_bonds # port bonds on the ith component of this subsystem.
	    	comp_bonds(kk,:) = ABG.bonds(bond_list(kk),:);
	      end;

	      if exist(eqn_name)!=2 # Try a compound component
		## Port status depends on whether the corresponding bonds are
		##  fully causal at this stage.
            	one = ones(n_bonds,1);
            	port_status = (sum(abs(comp_bonds'))'==2*one) - one;
		
	    	port_bond_direction = -sign(subsystem.connections)'; # Direction of bonds

            	if exist(cause_name)==2	# If there is a predefined causality function; use it
		  comp_bonds = comp_bonds.*(port_bond_direction*[1 1]);	# Convert from arrow orientated to component orientated causality
		  eval([ "[comp_bonds] = ", cause_name, "(comp_bonds);" ]); # Evaluate the built-in causality procedure

		  comp_bonds = comp_bonds.*(port_bond_direction*[1 1]);	# and convert from component orientated to arrow orientated causality
            	end;
		
		port_bond_direction,comp_bonds
	    	[comp_bonds,subsystem.status] = abg2cbg(name, subsystem.type, full_name, 
							comp_bonds, port_bond_direction, port_status, ...
							derivative_causality, ...
						    	typefile, infofile, errorfile);

		
	      else # its a simple component -- or explicit causality defined
		mtt_info(sprintf("Completing causality for component %s (%s)",
				 name, subsystem.type), infofile);
	    	disp(["---", name, " (", cause_name, ") ---"]);
	    	comp_bonds_in = comp_bonds
	    	
		## Convert from arrow orientated to component orientated causality
	    	comp_bonds = comp_bonds.*direction;
	    	
		## Evaluate the built-in causality procedure
		##eval([ "[comp_bonds,status(i)] = ", cause_name, "(comp_bonds);" ]);
	    	eval([ "[comp_bonds,subsystem.status] = ", cause_name, "(comp_bonds)" ]);
		## and convert from component orientated to arrow orientated causality
            	comp_bonds = comp_bonds.*direction; 
		
	    	comp_bonds_out = comp_bonds
	      end;
	      
	      ABG.bonds(bond_list,:) = comp_bonds;# Update the full bonds list
	      eval(["ABG_field.",name,".status = subsystem.status;"]);
    	    end;
	  end;

	  sum_ok = 0; n_comp = 0;
	  for [subsystem,name] = ABG_field# Find % status = 0 (causally complete)
    	    eval(["ok = (ABG_field.",name,".status==0);"]);
	    sum_ok = sum_ok + ok; n_comp ++;
	  endfor;

	  Done = sum_ok/n_comp*100
	  done = sum(sum(abs(ABG.bonds)))/total*100
	  ##disp(sprintf("Causality is #3.0f#s complete.", done, pc), infofile));
	  
    	endwhile			# done!=old_done
  	
    	[name,prefered] = getdynamic(ABG_field) # Set causality of a C or I which is not already set
    	if prefered==0
	  ci_index=0;
    	else
	  disp("Set causality of a C or I which is not already set")
	  eval(["ci_bond_index = ABG.",field,".",name,".connections;"]); # Get bonds
	  ci_direction = sign(ci_bond_index);
	  ci_bond_index = abs(ci_bond_index);
	  if derivative_causality
	    prefered = -prefered;
	  end;
	  ABG.bonds(ci_bond_index,1:2) = prefered*ci_direction'*[1 1]
	  eval(["ABG.subsystems.",name,".status=0"]); #set status of the C or I
    	endif
      endwhile			# ( ci_index>0)
      eval(["ABG.",field," = ABG_field;"]); # Copy back to actual structure
    endif			# isfield(CBG,field(i,:));
  endfor
  ##  if n_ports>0
  ##    status(1:n_ports) = zeros(n_ports,1); # Port status not relevant
  ##  endif;
  
  ## Print final causality
  ##  final_done =  (sum(status==zeros(n_components,1))/n_components)*100;
  
  if at_top_level
    mtt_info(sprintf("Final causality of %s is %3.0f%s complete.", ...
		     full_name, Done, pc), infofile);
    
    if Done<100
      mtt_error(sprintf("Unable to complete causality"),errorfile);
    end;
  endif				# at_top_level
  


  
  ## Return the port bonds - arrow orientated causality - and the direction 
  status=0;
  if !at_top_level # Not at top level
    port_bonds = ABG.bonds(port_bond_index,:); # Return port bonds
  endif;				# at top level

  for [subsystem,name] = ABG.subsystems
    if subsystem.status==-1	# Under causal
      status=-1;
      mtt_info(sprintf("Component %s (%s) is undercausal", name, subsystem.type), ...
	       infofile);
    elseif subsystem.status==1;	# Over causal
      status=-1;
      mtt_info(sprintf("Component %s (%s) is overcausal", name, subsystem.type), ...
	       infofile);
    endif;
  endfor;			# [subsystem,name] = ABG.subsystems

  ## write out the component .cbg file
    disp(["Writing ", full_name]);
    write_cbg(full_name,system_type,ABG,Flipped);
    fprintf(typefile, "$1%s$2%s$3\n", system_type, full_name);
  


  status, port_bonds
  disp("====================================");
  disp(["END: ", full_name, " (", fun_name, ")"]);
  disp("====================================");


endfunction;

Deleted mttroot/mtt/bin/trans/m/abg2connections.m version [83377ee03d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- put Emacs into Octave mode
##
##     ###################################### 
##     ##### Model Transformation Tools #####
##     ######################################
##
## abg2connections_m
##
## Creates a cell array recording the name of the
## component at each end of every bond.
##
## This data may differ from ibg.m because of the
## expansion of vector bonds that takes place
## during the generation of abg.m

function connections = abg2connections (abg)

  substructures = {"ports", "subsystems"};

  for i = [1,2]
    substruct = substructures{i};
    
    if (isfield (abg, substruct))
      for [val, key] = eval (sprintf ("abg.%s", substruct))
	for bond_id = val.connections
	  if (bond_id > 0)
	    connections.head {+bond_id} = key
	  else
	    connections.tail {-bond_id} = key
	  endif
	endfor
      endfor
    endif

  endfor

endfunction

Deleted mttroot/mtt/bin/trans/m/add_bond.m version [575ba3aab9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function comp_list = add_bond(comp_list,bond_number,comp_number);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Adds a new bond entry to a list of components -- pads the list appropriately.

[N,M] = size(comp_list);
if M==0
  M=1;
end;

if comp_number>N % Pad with zeros
  comp_list = [comp_list;zeros(comp_number-N,M)];
end;

this_comp = [nozeros(comp_list(comp_number,:)), bond_number];

L = length(this_comp);

[N,M] = size(comp_list);

if L<M %pad new row with zeros
  comp_list(comp_number,:) = [this_comp, zeros(1,M-L)];
elseif L>M %pad matrix with zeros and insert new row
  comp_list = [comp_list zeros(N,L-M)];
  comp_list(comp_number,:) = this_comp;
else %Sizes match so just insert
  comp_list(comp_number,:) = this_comp;
end;

Deleted mttroot/mtt/bin/trans/m/add_row.m version [8618dcbf0d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function New=add_row(Old,Row); # Adds a row to end of matrix

  [N,M]=size(Old);
  [n,m] = size(Row);

  if m>M
    Old = [Old, zeros(N,m-M)];	# Pad with zeros
  elseif M>m
    Row = [Row, zeros(n,M-m)];
  endif

  New = [Old;Row];

endfunction

	   

Deleted mttroot/mtt/bin/trans/m/adjbond.m version [266020f198].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [index,distance] = adjbond(point,arrow_end,other_end);
% adjbond:  Determines the bond closest to the point 
%  [index,distance] = adjbond(point,arrow_end,other_end);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[n,m] = size(other_end);
one = ones(n,1);
arrow_distance = length2d(one*point - arrow_end);
min_arrow_distance = min(arrow_distance);

other_distance = length2d(one*point - other_end);
min_other_distance = min(other_distance);

min_distance = min([arrow_distance; other_distance]);

adjacent = [arrow_distance, other_distance] == min_distance*[one one];
[index,n] = getindex(adjacent,1);
distance = min_distance;

Deleted mttroot/mtt/bin/trans/m/adjcomp.m version [142766d077].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function indices = adjcomp(arrow_end,other_end,components);
% adjcomp: Determines the two components at each end of the bond



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[n,m] = size(components);
one = ones(n,1);

arrow_distance = length2d(one*arrow_end - components(:,1:2));
min_arrow_distance = min(arrow_distance);

other_distance = length2d(one*other_end - components(:,1:2));
min_other_distance = min(other_distance);

arrow_adjacent = arrow_distance==min_arrow_distance*one;
other_adjacent = other_distance==min_other_distance*one;
[index,n] = getindex([arrow_adjacent,other_adjacent],1);

if index(1,2)==1
  indices = index(1:2,1)';
else
  indices = index(2:-1:1,1)';
end;


Deleted mttroot/mtt/bin/trans/m/alias_args.m version [52ee84b0ea].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function args = alias_args(args,alias,delim,message,FileID,sys_name)

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2012/10/15 19:16:03  geraint
## split is obsolete in Octave, replaced with strsplit
##
## Revision 1.9  2009/11/02 16:54:03  geraint
## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
##
## Revision 1.8  2001/06/13 16:07:15  gawthrop
## Fixed bug with three separators in a row eg )/(
##
## Revision 1.7  2001/06/13 14:50:15  gawthrop
## Operator ^ now ok in args in abg and/or lbl
##
## Revision 1.6  2001/04/23 16:23:30  gawthrop
## Now stips ; from bottlom level argument list - allows aliasing of
## parts of a,b,c (eg a,b by using a,b;c
##
## Revision 1.5  2000/10/12 19:27:20  peterg
## Now writes out the aliased args ...
##
## Revision 1.4  2000/09/14 13:35:43  peterg
## appended '(' and ')' to SEPS
##   -- otherwise first argument after '(' doesn't get substituted
## (Fixed by Geraint)
##
## Revision 1.3  1998/08/11 14:09:05  peterg
## Replaced incorrect length(args>0) with !isempty(args)
##
## Revision 1.2  1998/07/27 10:24:20  peterg
## Included , in the the list of seperators (SEPS)
## This makes it substitute for bits of args separated by commas.
##
## Revision 1.1  1998/07/03 18:29:40  peterg
## Initial revision
##
###############################################################

  if isstruct(alias)
    if !isempty(args)
      Args = char(strsplit(args,delim)); args="";
      [N,M]= size(Args);
      for i=1:N
        arg = deblank(Args(i,:));
        arg_ = strrep(arg,",","__");
        if isfield(alias,arg_)
          eval(["new_arg = alias.", arg_,";"]);
  	  mtt_info(["Replacing ", arg, "\t by ", ...
		    new_arg, message],FileID);
  	  mtt_save_alias(arg,sys_name);
##	  printf("%s --> %s\n",arg,new_arg);
          arg = new_arg;
## 	else
## 	  mtt_info(["NOT replacing ", arg, message],FileID);
        end
        SEPS = ",+-*/()^";
        for j = 1:length(SEPS)
	  if (length(arg)>1)&&(length(findstr(arg,SEPS(j)))>0)
	    arg = alias_args(arg,alias,SEPS(j),message,FileID,sys_name);
	  end 
	end;
        args = sprintf("%s%s%s", args, delim, arg);
      end
      if (length(args)>1)
	if (substr(args,1,1)==delim)
	  args = substr(args,2); # loose leading delimiter
	endif
      endif
      
    end
  end;
endfunction;





Deleted mttroot/mtt/bin/trans/m/args2arg.m version [88e206959b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function arg = args2arg(args,n,FS)
% args2arg - pulls the nth argument from a FS-separated list.
% FS defaults to `;'.
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  args2arg.m
% arg = args2arg(args,n,FS) 
% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/08/30 09:58:55  peter
% %% Uses str2ch to exteact a char from a string.
% %%
% %% Revision 1.1  1996/08/27  12:50:43  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Field separator
if nargin<3
  FS = ';';
end;

Deleted mttroot/mtt/bin/trans/m/cause2index.m version [d105a576d5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function index = cause2index (causality)

  ## usage:  index = cause2index (causality)
  ##
  ## 

  if isstr(causality)
    if strcmp(causality,"effort")
      index = 1;
    elseif strcmp(causality,"flow")
      index = 2;
    elseif strcmp(causality,"state")
      index = 3
    else
      error(sprintf("Causality ""%s"" not recognised",causality));
    endif
    
  else
    if causality==1
      index = 1;
    elseif causality==-1
      index = 2;
    else
      error(sprintf("Causality ""%i"" not recognised",causality));
    endif
  endif

endfunction

Deleted mttroot/mtt/bin/trans/m/cause2name.m version [1ae26e00bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = cause2name(causality)
% cause2name - converts causality to a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cause2name
% name = cause2name(causality)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if causality==1
  name = 'effort';
elseif causality ==-1
  name = 'flow';
else
  name = 'state';
end;

Deleted mttroot/mtt/bin/trans/m/cause2num.m version [596056c3f2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function num = cause2num(causality)
% cause2num - converts causality to a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cause2num
% num = cause2num(causality)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if causality==1
  num = 1;
elseif causality ==-1
  num = 2;
else
  num = 3;
end;

Deleted mttroot/mtt/bin/trans/m/cbg2ese.m version [fbe5a968f6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614






































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function structure = cbg2ese(system_name, system_type, system_cr, ...
			     system_args, full_name, full_name_repetition, ...
			     repetition,...
			     structure, structure_file,infofilenum)
  ## Set up globals to count the component inputs and outputs. This relies on
  ## the named SS (the ports) being in the correct order. Using globals here
  ## avoids changing the common argument list for all _eqn files for something
  ## which is only used for named SS components.
  global local_u_index
  global local_y_index
  global at_top_level
  ## 
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function  cbg2ese.m
  ## Acausal bond graph to causal bond graph: mfile format
  ## Structure matrix [states,nonstates,inputs,outputs,zero_outputs]
  
  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.54  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.53  2005/03/21 11:09:47  gawthrop
  ## ## Now handles bicausal SS component -
  ## ##   ie source-source or sensor-sensor
  ## ##
  ## ## Revision 1.52  2004/09/12 22:27:27  geraint
  ## ## Appended 't' to fopen mode string to open in text mode.
  ## ##
  ## ## Revision 1.51  2003/05/16 11:16:28  gawthrop
  ## ## Fixed bug with multiports
  ## ##
  ## ## Revision 1.50  2003/05/08 18:47:50  gawthrop
  ## ## Fixed __ bug when using * representations
  ## ##
  ## ## Revision 1.49  2003/03/13 15:19:04  gawthrop
  ## ## Now uses __ to delimit subsystems in names.
  ## ##
  ## ## Revision 1.48  2003/03/13 15:10:26  gawthrop
  ## ## Removed redundant final column
  ## ##
  ## ## Revision 1.47  2003/02/28 09:12:17  gawthrop
  ## ## Two more columns in _stuc.txt: causality and subsystem name
  ## ##
  ## ## Revision 1.46  2002/08/20 15:51:17  gawthrop
  ## ## Update to work with ident DIY rep
  ## ##
  ## ## Revision 1.45  2002/05/22 09:15:03  gawthrop
  ## ## Non-repetitive components no longer use _1 in names
  ## ##
  ## ## Revision 1.44  2001/11/11 18:12:30  geraint
  ## ## Moved fflush(structure_file) out of loop.
  ## ##
  ## ## Revision 1.43  2001/11/11 08:32:00  geraint
  ## ## fflush (structure_file).
  ## ##
  ## ## Revision 1.42  2001/04/23 16:23:30  gawthrop
  ## ## Now stips ; from bottlom level argument list - allows aliasing of
  ## ## parts of a,b,c (eg a,b by using a,b;c
  ## ##
  ## ## Revision 1.41  2001/04/15 21:15:41  geraint
  ## ## Added interface definition rep: _ICD.(txt|c|cc|m).
  ## ##
  ## ## Revision 1.40  2001/02/05 01:50:29  geraint
  ## ## No unit type comparison at ports if either is "none".
  ## ##
  ## ## Revision 1.40  2000/12/16 08:10:55  geraint
  ## ## No unit type comparison at ports if either is "none".
  ## ##
  ## ## Revision 1.39  2000/11/16 12:54:14  peterg
  ## ## Added checking of unit consistency at ports
  ## ##
  ## ## Revision 1.38  2000/11/16 10:00:57  peterg
  ## ## *** empty log message ***
  ## ##
  ## ## Revision 1.37  2000/11/12 16:45:57  peterg
  ## ## Close ese file before recursive call of cbg2ese -- reopen when
  ## ## finished.
  ## ## THis prevents a new file being opened for each subsystem which fails
  ## ## when > 1K files opened
  ## ##
  ## ## Revision 1.36  2000/10/13 10:54:47  peterg
  ## ## Now writes out a unique name for each state etc
  ## ##
  ## ## Revision 1.35  2000/10/12 19:27:47  peterg
  ## ## Now writes the aliased args
  ## ##
  ## ## Revision 1.34  2000/09/01 08:42:44  peterg
  ## ## Cahged somes ends to end for etc for clarity
  ## ##
  ## ## Revision 1.33  2000/09/01 08:05:32  peterg
  ## ## Reformatted with out changing function
  ## ##
  ## ## Revision 1.32  1998/11/16 13:01:19  peterg
  ## ## Fixed problem with repetitions>1 due to new data structures -- now
  ## ## computes initial next_bond correctly
  ## ##
  ## ## Revision 1.31  1998/09/24 12:57:44  peterg
  ## ## Now ignores aliasing if no arguments given.
  ## ##
  ## ## Revision 1.30  1998/09/02 11:14:23  peterg
  ## ## Revised to use ordered lists of subsystems and ports
  ## ##
  ## ## Revision 1.29  1998/08/25 09:22:34  peterg
  ## ## Correctely recognises port SSs its now easy -- they are in there own
  ## ## field
  ## ##
  ## ## Revision 1.28  1998/08/25 08:31:42  peterg
  ## ## Fixed bug - didn't find the ports - use deblank
  ## ##
  ## ## Revision 1.27  1998/08/25 07:16:49  peterg
  ## ## Modified to data struture representation
  ## ##
  ## ## Revision 1.26  1998/08/24 14:53:55  peterg
  ## ## Uses new _cbg structure.
  ## ##
  ## ## Revision 1.25  1998/07/28 19:05:12  peterg
  ## ## Sttill has vector SS port bug?
  ## ##
  ## ## Revision 1.24  1998/07/27 10:26:02  peterg
  ## ## No change - but fixed bug in alias_args
  ## ##
  ## ## Revision 1.23  1998/07/08 12:33:51  peterg
  ## ## Reinstated the infofilenum parameter.
  ## ##
  ## ## Revision 1.22  1998/07/04 07:10:27  peterg
  ## ## Don't evaluate alias if no constitutive relationship or args and write
  ## ## message.
  ## ##
  ## ## Revision 1.21  1998/07/03 18:58:58  peterg
  ## ## Put arg alias stuff within function alias_args
  ## ## Called recursively to handle arithmetic expressions
  ## ##
  ## ## Revision 1.20  1998/07/03 14:39:09  peterg
  ## ## Added info messages a bit busy now!
  ## ##
  ## ## Revision 1.19  1998/04/12 11:58:19  peterg
  ## ## Rename port components by changing name_r to [name_r
  ## ##
  ## ## Revision 1.18  1998/04/11 18:59:16  peterg
  ## ## at_top_level now global - passed to SS components
  ## ##
  ## ## Revision 1.17  1998/04/04 10:47:31  peterg
  ## ## Uses (coerced) components from _cbg file - _abg not now used here.
  ## ##
  ## ## Revision 1.16  1998/03/06 09:38:58  peterg
  ## ## Now writes correct structure file for multiport C & I
  ## ##
  ## ## Revision 1.15  1997/12/16 18:24:33  peterg
  ## ## Added unknown_input to structure list
  ## ##
  ## ## Revision 1.14  1997/08/26 07:51:10  peterg
  ## ## Now counts the local input and outputs by order of appearence rather
  ## ## than by port number - it therfore handles ports with bicausality correctely.
  ## ##
  ## ## Revision 1.13  1997/05/19 16:45:56  peterg
  ## ## Fixed ISW bug -- deleted spurious ISW_eqn.m file
  ## ##
  ## ## Revision 1.12  1997/04/15  09:17:26  peterg
  ## ## Added the structure file - contains details of states etc.
  ## ## 
  ## ## Revision 1.11  1996/12/07 18:20:11  peterg
  ## ## Replaces null argument by a default and tells user.
  ## ##
  ## ## Revision 1.10  1996/12/07 17:37:07  peterg
  ## ## Now handles numbered SS ports appearing at top level.
  ## ##
  ## ## Revision 1.9  1996/12/04 21:49:47  peterg
  ## ## Compares full-name with empty string (instead of testing for zero
  ## ## length)
  ## ##
  ## ## Revision 1.8  1996/08/30  16:36:08  peter
  ## ## More info written to ese files.
  ## ##
  ## ## Revision 1.7  1996/08/30 11:23:13  peter
  ## ## Argument substitution implemented.
  ## ##
  ## ## Revision 1.6  1996/08/27  08:04:52  peterg
  ## ## Handles complex components and repetative components.
  ## ##
  ## ## Revision 1.5  1996/08/24  15:02:23  peter
  ## ## Writes `END;' to keep reduce happy.
  ## ##
  ## ## Revision 1.4  1996/08/19 09:03:41  peter
  ## ## Handles repeating components.
  ## ##
  ## ## Revision 1.3  1996/08/18 20:08:02  peter
  ## ## Included additional structure: structure(5) = zero_outputs.
  ## ##
  ## ## Revision 1.2  1996/08/08 18:08:11  peter
  ## ## Sorted out file naming sceme
  ## ##
  ## ## Revision 1.1  1996/08/08 15:53:23  peter
  ## ## Initial revision
  ## ##
  ## #############################################################
  
  ## disp("cbg2ese");
  ## system_name, system_type, full_name, repetition
  
  pc = "%";
  sub_delim = "__";		# Subsystem delimiter
  

  unit_error = "Component %s connects inconsistent ports with units %s and %s";
  unit_info = "Component %s connects ports with units %s and %s";  

  ## Set up the names corresponding to the structure matrix.
  structure_name = [
		    "state        ",
		    "nonstate     ",
		    "input        ",
		    "output       ",
		    "zero_output  ",
		    "unknown_input"];
  
  
  ## Are we at the top level of the heirarchy?
  at_top_level = strcmp(full_name, "");
  
  ## Create the (full) system name
  if at_top_level
    full_name = system_name;
    full_name_repetition = system_name;
    system_type = system_name;
  else
    full_name = [full_name, sub_delim, system_name];

    if (repetition>1)
      full_name_repetition = [full_name_repetition, ...
			      sub_delim, system_name, sub_delim, ...
			      num2str(repetition)];
    else
      full_name_repetition = [full_name_repetition, ...
			      sub_delim, system_name];
    endif
    
  end;
  
  
  
  cbg_name = [full_name, "_cbg"];
  if exist(cbg_name)~=2		# Return if cbg file doesn't exist
    disp([cbg_name, " does not exist"]);
    return
  end;
  
  ## Setup files
  ese_name = [full_name_repetition, "_ese.r"];
  ese_file = fopen(ese_name, "wt") # open file (first time)
  icd_file = fopen([full_name_repetition,"_icd.txt2"],"wt")

  fprintf(ese_file, "\n%s%s Equation file for system %s (file %s)\n", ...
	  pc, pc, full_name_repetition, ese_name);
  fprintf(ese_file, "%s%s Generated by MTT\n\n", pc, pc);
  
  ## Evaluate the system function to get the bonds
  eval(["CBG = ", cbg_name, ";"]);
  ##eval(["[bonds,status,system_type,components] = ", cbg_name, ";"]);
  ##  abg_name = [system_type, "_abg"];
  ##  cmp_name = [system_type, "_cmp"];
  ##  alias_name = [system_type, "_alias"];
  
  ## No longer needed - cbg now has components:  
  ##  eval(["[junk,components]=", abg_name, ";"]);
  
  ## Find number of bonds
  [n_bonds,columns] = size(CBG.bonds);
  if (columns ~= 2)&(n_bonds>0)
    error("Incorrect bonds matrix: must have 2 columns");
  endif;

  ## Set up initial bond units
  for i=1:n_bonds
    bond_effort_unit(i,:)="null";
    bond_flow_unit(i,:)="null";
  endfor

  ##  ## Find number of components
  ##  [n_components,columns] = size(components);
  ##  n_components = n_components
  
  ## Set up the first dummy bond number - needed for repetative components
  ##  next_bond = max(max(abs(components)))+1;
  next_bond = n_bonds+1;
  
  ## Set up the counters for the labelled SS. These are, by definition,
  ## encountered first and so the counters will not be messed up by subsystems.
  local_u_index = 0;
  local_y_index = 0;
  
  if (length(system_args)==0)
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s(%s)", ...
		     system_name,system_type), infofilenum);
    AliasingArguments=0;
  else
    AliasingArguments=1;
  endif;
  
  if (length(system_cr)==0)
    mtt_info(sprintf("No cr given so no cr aliasing done for system %s(%s)", ...
		     system_name,system_type), infofilenum);
    AliasingCRs=0;
  else
    AliasingCRs=1;  endif;
  
  
  fields=["ports";"subsystems"]; # Do for both ports and subsystems -
  ## ports first
  lists=["portlist";"subsystemlist"];
  for i=1:2
    field=deblank(fields(i,:));
    list=deblank(lists(i,:));
    if isfield(CBG,list);
      eval(["namelist=CBG.",list,";"]); # List of ports/subsystems
      [N,M]=size(namelist);	# Number of ports/subsystems
      for j=1:N
      	comp_name = deblank(namelist(j,:)); # Name of this component
	eval(["subsystem=CBG.",field,".",comp_name,";"]); # Pluck out the details
    	comp = subsystem.connections; # Connections
    	bond_list = abs(comp);
    	direction = sign(comp)'*[1 1];
				# Convert from arrow orientated to component orientated causality
    	comp_bonds = CBG.bonds(bond_list,:).*direction;
	
    	## disp(["---- ", field, " ---"]);    
    	
	if AliasingArguments	# Alias the args list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s", ...
			    comp_name,subsystem.type,full_name);    
    	  if isfield(CBG,"alias")
	    subsystem.arg = alias_args(subsystem.arg,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;
	
	if AliasingCRs	# Alias the CR list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s", ...
			    comp_name,subsystem.type,full_name);    
    	  if isfield(CBG,"alias")
	    subsystem.cr = alias_args(subsystem.cr,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;

	## Substitute positional ($1 etc) arguments
    	subsystem.cr = subs_arg(subsystem.cr,system_cr, ...
				"lin",full_name,subsystem.type,comp_name,infofilenum);
    	subsystem.arg = subs_arg(subsystem.arg,system_args, ...
				 "1",full_name,subsystem.type,comp_name,infofilenum);
    	
	## change name of 0 and 1 components -- matlab doesn't like numbers here
    	if strcmp(subsystem.type,"0")
	  subsystem.type = "zero";
    	endif;
    	if strcmp(subsystem.type,"1")
	  subsystem.type = "one";
    	endif;
    	
    	ports = length(bond_list);
    	
    	if subsystem.repetitions>1
	  port_pairs = ports/2;
	  if round(port_pairs)~=port_pairs;
	    mtt_info(["Repeated component ", comp_name, ...
		      " has an odd number of ports - ignoring repetitions"], infofilenum);
	    subsystem.repetitions = 1;
	  endif;
    	endif;
    	
    	if subsystem.repetitions>1
	  odd_bonds = bond_list(1:2:ports-1);
	  even_bonds = bond_list(2:2:ports);
    	endif;
    	
    	for k = 1:subsystem.repetitions
	  
	  if subsystem.repetitions>1
	    
	    if k==1
	      bond_list(1:2:ports-1) = odd_bonds;
	    else
	      bond_list(1:2:ports-1) = bond_list(2:2:ports);
	    endif;
	    
	    if k==subsystem.repetitions
	      bond_list(2:2:ports) = even_bonds;
	    else
	      new_bonds = [next_bond:next_bond+port_pairs-1];
	      next_bond = next_bond+port_pairs;
	      bond_list(2:2:ports) = new_bonds;
	    endif;
	    
	  endif;
	  
	  ## Invoke the appropriate equation-generating procedure
	  name_r = full_name_repetition;
	  eqn_name = [subsystem.type, "_eqn"];
	  
	  if exist(eqn_name)~=2 ## Try a compound component
            fclose(ese_file);	# Close but reopen later

	    disp("---PUSH---"); bond_list, comp_name, subsystem.type
	    structure = cbg2ese(comp_name, subsystem.type, subsystem.cr, subsystem.arg, ...
				full_name, full_name_repetition, ...
				k, structure,  structure_file, infofilenum);
	    
	    disp("---POP---");
	    ese_file = fopen(ese_name, "at") # open file (again)

	    eval(["subABG = ",subsystem.type , "_abg;"]); # Get the information

	    ## Link up the bonds for this compound component
	    fprintf(ese_file, ...
		    "\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		    pc, comp_name, subsystem.type);
	    
	    if (k>1)
	      name_comp_name = sprintf("%s%s%s%s%d", ...
				       full_name_repetition, sub_delim, ...
				       comp_name, sub_delim, k);
	    else
	      name_comp_name = sprintf("%s%s%s", ...
				       full_name_repetition, sub_delim, ...
				       comp_name);
	    endif
	    
	    
	    printf("\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		   pc, comp_name, subsystem.type);
	    
	    u_index = 0; y_index = 0; ## Count the inputs and outputs
	    for port_number=1:length(bond_list)
	      repetition,port_number
              port_bond_number = bond_list(port_number)
# 	      this_bond_effort_unit = ...
# 		  deblank(bond_effort_unit(port_bond_number,:))
# 	      this_bond_flow_unit = ...
# 		  deblank(bond_flow_unit(port_bond_number,:));

# 	      ## Extract the unit/domain stuff
#               this_port_name = subABG.portlist(port_number,:);
              
#               eval(sprintf("this_port = subABG.ports.%s;", ...
# 			   this_port_name));
# 	      if isfield(this_port,"units")
#                 eval(["effort_unit = ...
# 		    subABG.ports.",this_port_name,".units.effort;"]);
#                 eval(["flow_unit = ...
# 		    subABG.ports.",this_port_name,".units.flow;"]);
# 	      else
# 		effort_unit = "none";
# 		flow_unit = "none";
# 	      endif

# 	      ## and check consistency
#               ## Efforts
# 	      if strcmp(this_bond_effort_unit,"null") # set
# 		bond_effort_unit = ...
# 		    [bond_effort_unit(1:port_bond_number-1,:)
# 		     effort_unit
# 		     bond_effort_unit(port_bond_number+1:n_bonds,:)
# 		     ]
# 	      elseif (!strcmp(this_bond_effort_unit,"none") && !strcmp(effort_unit,"none")) # check
# 		mtt_info(sprintf(unit_info,full_name, effort_unit, ...
# 				 this_bond_effort_unit), infofilenum);
# 		if !strcmp(this_bond_effort_unit,effort_unit)
# 		  error_string = sprintf(unit_error, full_name, ...
# 					 effort_unit, ...
# 					 this_bond_effort_unit);
# 		  mtt_error(error_string);
# 		endif
# 	      endif
# 	      ## Flows
# 	      if strcmp(this_bond_flow_unit,"null") # set
# 		bond_flow_unit = ...
# 		    [bond_flow_unit(1:port_bond_number-1,:)
# 		     flow_unit
# 		     bond_flow_unit(port_bond_number+1:n_bonds,:)
# 		     ]
# 	      elseif (!strcmp(this_bond_flow_unit,"none") && !strcmp(flow_unit,"none")) # check
# 		mtt_info(sprintf(unit_info,full_name, flow_unit, ...
# 				 this_bond_flow_unit), infofilenum);
# 		if !strcmp(this_bond_flow_unit,flow_unit)
# 		  error_string = sprintf(unit_error, full_name, ...
# 					 flow_unit, ...
# 					 this_bond_flow_unit);
# 		  mtt_error(error_string);
# 		endif
# 	      endif
	      

	      ## Effort
	      if comp_bonds(port_number,1)==1 # Source
	     	u_index = u_index + 1;
	     	fprintf(ese_file, "%s_MTTu%d := %s;\n", ...
		 	name_comp_name, u_index, varname(name_r, ...
							 bond_list(port_number),1));
	      else # Sensor
	     	y_index = y_index + 1;
	     	fprintf(ese_file, "%s := %s_MTTy%d;\n", ...
		 	varname(name_r, ...
				bond_list(port_number),1), name_comp_name, y_index);
	      end;
	      ## Flow
	      if comp_bonds(port_number,2)==-1 # Source
	     	u_index = u_index + 1;
	     	fprintf(ese_file, "%s_MTTu%d := %s;\n", ...
		 	name_comp_name, u_index, varname(name_r, ...
							 bond_list(port_number),-1));
	      else # Sensor
	     	y_index = y_index + 1;
	     	fprintf(ese_file, "%s := %s_MTTy%d;\n", ...
		 	varname(name_r, ...
				bond_list(port_number),-1), name_comp_name, y_index);
	      end;	
	    end;
	    
	  else # its a simple component
	    fprintf(ese_file, "\n\t%s Equations for component %s (%s), repetition %d\n\n", ...
		    pc, comp_name, subsystem.type,k);
	    
	    
	    ##				# Is it a named port? (Name begins with [)
	    ##            Named_Port = (comp_name(1)=="[");
	    
	    if strcmp(field,"ports") #Add [ to start of name
	      name_r = ["[" name_r];
	    endif;
	    
	    ## Save the current structure
	    old_structure = structure;
	    
	    ## Generate the simple component equations
	    ## .. firstly replacing ; by , in argument list
	    subsystem_arg = strrep(subsystem.arg,";",",");

	    eval(["structure = ", ...
		  eqn_name, ...
		  "(name_r,bond_list,comp_bonds, ...
		    direction,subsystem.cr,subsystem_arg,structure,ese_file);" ]);
	    
	    ## If structure has changed, write info to structure file.
	    structure_change = structure-old_structure;
	    
	    ## The following line is to avoid probs with multiport C or I
	    ## it needs changing to handle multi ports correctly
	    structure_changes = sum(structure_change);
	    
	    structure_change = structure_change>zeros(size(structure_change));
 	    if structure_changes>0
 	      which_indices = getindex(structure_change,1);
 	      which_indices = which_indices(:,2)';
 	      for which_index=which_indices
 	    	value = structure(which_index);
	    	value_change=value-old_structure(which_index);
 	    	for k=1:value_change
		  if strcmp(subsystem.type,"SS") # One port, may be bicausal
		    cause_name = cause2name(-comp_bonds(1,k));
		  else		# Maybe multiport - but unicausal
		    cause_name = cause2name(-comp_bonds(k,1));
		  endif
 		  fprintf(structure_file, ...
 			  "%s\t%i\t%s\t%s%s%s\t%i\t%s\n", ...
 			  structure_name(which_index,:), value-k+1, ...
 			  comp_name, full_name_repetition, sub_delim, comp_name, ...
 			  repetition, cause_name); 
 	    	endfor;
 	      endfor;
 	    endif;
	  endif
	endfor
	fflush (structure_file);

	## component interface definition
	if isfield(CBG,"icd")
	  if isfield(CBG.icd,comp_name)
	    if AliasingArguments
	      subsystem.icd = alias_args(eval(["CBG.icd.",comp_name]),CBG.alias,";",message,infofilenum,full_name);
	    endif
	  endif
	  if (isfield(subsystem,"icd"))
	    subsystem.icd = subs_arg(subsystem.icd,system_args, ...
				     "null",full_name,subsystem.type,comp_name,infofilenum);
	    
	    fprintf(icd_file,"%s_%s\t%s\t",full_name_repetition,comp_name,subsystem.icd);
	    if (comp_bonds(1) == 1)
	      fprintf(icd_file,"output,");
	    elseif (comp_bonds(1) == -1)
	      fprintf(icd_file,"input,");
	    endif
	    if (comp_bonds(2) == 1)
	      fprintf(icd_file,"input\n");
	    elseif (comp_bonds(2) == -1)
	      fprintf(icd_file,"output\n");
	    endif
	  endif
	endif			# End of component interface definition

      endfor			# [subsystem,comp_name] = CBG_field
    endif			# isfield(CBG,field)
  endfor			# i=1:2

  fclose(icd_file);
  fclose(ese_file);		# Close
  
endfunction



Deleted mttroot/mtt/bin/trans/m/cbg2fig.m version [7c46356009].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318






























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function cbg2fig(system_name, system_type, full_name, ...
                 stroke_length, stroke_thickness, stroke_colour, ...
                 comp_font, comp_colour_u, comp_colour_o)

  ## cbg2fig - converts causal bg to figure
  ##
  ##     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% Model
  ##     Transformation Tools %%%%%
  ##     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ##
  ## Matlab function  cbg_m2fig Causal bond graph:  mfile format to fig
  ## file format The resultant fig file is the original _abg.fig with
  ## additional causal strokes superimposed. cbg2fig(system_name, ...
  ## system_type, full_name, ... stroke_length, stroke_thickness,
  ## stroke_colour, ... comp_font, comp_colour_u, comp_colour_o)
  ## Note this uses geometric info from _rbg.fig - so don't use with
  ## -abg switch.  

  ## P.J.Gawthrop May 1996
  ## Copyright (c) P.J.Gawthrop, 1996.

  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% Version control history
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% $Id$
  ## %% $Log$
  ## %% Revision 1.17  2004/09/12 22:27:27  geraint
  ## %% Appended 't' to fopen mode string to open in text mode.
  ## %%
  ## %% Revision 1.16  2001/03/23 14:58:16  gawthrop
  ## %% Fixed cosmetic bugs -- component display
  ## %%
  ## %% Revision 1.15  2001/03/23 11:20:20  gawthrop
  ## %% Fixed bug with vector components --NB takes geometric info from _rbg.fig
  ## %%
  ## %% Revision 1.14  2000/09/14 12:07:15  peterg
  ## %% Fixed overwriting of ports.
  ## %%
  ## %% Revision 1.13  2000/09/14 09:12:19  peterg
  ## %% Fixed stroke orientation bug with bent bonds
  ## %% Uses new info from the _rbg.m file - 4 new cols in rbonds
  ## %%
  ## %% Revision 1.12  2000/09/14 08:07:00  peterg
  ## %% Reformated as an Octave function
  ## %%
  ## %% Revision 1.11  2000/01/18 14:52:02  peterg
  ## %% Removed recursion --- maybe put back via a flag later
  ## %%
  ## %% Revision 1.10  1998/12/14 15:27:32  peterg
  ## %% Added separate handling of ports ( poss zero)
  ## %%
  ## %% Revision 1.9  1998/08/25 06:43:02  peterg
  ## %% Revised (partially) for data strucures - needs to include graphic info
  ## %% in abg file.
  ## %%
  ## %% Revision 1.8  1998/04/04 10:45:01  peterg
  ## %% Don't do strokes on port bonds
  ## %%
  ## %% Revision 1.7  1997/08/19 09:49:19  peterg
  ## %% Modified to take account of the expanded vector bonds. Only displays
  ## %% causality corresponding to the bond connecting the first element of
  ## %% the vector ports.
  ## %%
  ## %% Revision 1.6  1997/08/19 09:41:47  peterg
  ## %% Some debugging lines added.
  ## %%
  ## %% Revision 1.5  1997/05/16  07:33:45  peterg
  ## %% Now checks to see if sub system is a simple component before
  ## %% recursion.
  ## %% 0 --> zero
  ## %% 1 --> one
  ## %%
  ## %% Revision 1.4  1996/12/07  21:34:52  peterg
  ## %% Tests for null string with strcmp
  ## %% 
  ## %% Revision 1.3  1996/08/08  15:52:28  peter
  ## %% Recursive version.
  ## %% Fails due to octave bug - reported.
  ## %%
  ## %% Revision 1.2  1996/08/05 20:15:39  peter
  ## %% Prepared for recursive version.
  ## %%
  ## %% Revision 1.1  1996/08/05 18:12:25  peter
  ## %% Initial revision
  ## %%
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  if nargin<4
    stroke_length = 20;
  end;

  if nargin<5
    stroke_thickness = 2;
  end;

  if nargin<6
    stroke_colour = 1; %Blue
  end;

  if nargin<7
    comp_font = 18; %Helvetica bold
  end;

  if nargin<8
    comp_colour_u = 12; %Green
  end;

  if nargin<9
    comp_colour_o = 4; %Red
  end;

  ## Create a back slash '\' character.
  bs = char(92);

  ## Create the (full) system name
  if strcmp(full_name,'')
    full_name = system_name;
  else
    full_name = [full_name, '_', system_name];
  end;

  full_name_type = [full_name, '_', system_type];
  ## $$$ fig_name = [full_name_type, '_cbg.fig'];
  fig_name = [full_name, '_cbg.fig']
  
  ## Return if initial fig file doesn't exist
  if exist(fig_name)~=2
    return
  end;

  ## Setup file - append to the fig file
  filenum = fopen(fig_name, 'at');

  ## Get the raw and the processed bonds
  eval(['[rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = ', system_type, '_rbg;']);
  eval(["ABG = ", system_type, "_abg;"]);
  bonds=ABG.bonds;

  ## Original number of bonds
  [n_bonds,junk] = size(rbonds);

  ## Get the causal bonds
  #eval(['[cbonds,status]=', full_name, '_cbg;']);
  eval(["CBG = ", full_name, "_cbg;"]);
  cbonds=CBG.bonds;

  ## Check sizes
  [Rows,Columns] = size(rcomponents);
  if (Columns ~= 13)
    error('Incorrect rcomponents matrix: must have 13 columns');
  end;
  M_components = Columns;
  N_rcomponents = Rows;		# Number of raw components

  [N_rports,junk] = size(port_list);
  [N_components, Columns] = size(CBG.subsystemlist); # Number of derived
						     # components

  if isfield(CBG,'portlist')
    [N_ports, Columns] = size(CBG.portlist);
  else
    N_ports = 0;
  end


  ## Rotation matrix
  rot = [0 -1; 1 0];


  ## Determine coordinates of the arrow end of the bond and the other end
  ## and other geometry
  other_end_1 = rbonds(:,1:2);
  arrow_end = rbonds(:,3:4);
  other_end_2 = rbonds(:,5:6);

  distance_1 = length2d(other_end_1 - arrow_end);
  distance_2 = length2d(other_end_2 - arrow_end);
  which_end = (distance_1>distance_2)*[1 1];
  one = ones(size(which_end));
  other_end = which_end.*other_end_1 + (one-which_end).*other_end_2;
  arrow_barb = which_end.*other_end_2 + (one-which_end).*other_end_1;
  arrow_vector =  arrow_barb-arrow_end;
  unit_arrow_vector = arrow_vector./(length2d(arrow_vector)*[1 1]);
  
  ## Extract directional information
  arrow_end_direction = [rbonds(:,7), rbonds(:,8)];
  other_end_direction = [rbonds(:,9), rbonds(:,10)];


  ## Get indices of bonds with changed causality -- but ignore the extra bonds
  ## due to vector bond expansion
  changed_e = bonds(1:n_bonds,1)~=cbonds(1:n_bonds,1);
  changed_f = bonds(1:n_bonds,2)~=cbonds(1:n_bonds,2);
  changed = changed_e|changed_f;

  index_e  = getindex(changed_e,1)';
  index_f  = getindex(changed_f,1)';
  index_ef  = getindex(changed,1)';

  ## Print the new strokes in fig format
  if index_ef(1,1)>0
    for i = index_e		# Do the effort stroke - opp. side to arrow
      if cbonds(i,1)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;

      ## Work out the direction for the stroke (right angles to bond)
      unit_bond_vector = bond_vector./(length2d(bond_vector)*[1 1]);
      unit_stroke_vector = (rot*unit_bond_vector')';
      
      sig = sign(unit_arrow_vector(i,:)*unit_stroke_vector');
      stroke_end_2 = stroke_end_1 - stroke_length*sig*unit_stroke_vector;
      

      ## print the fig3 format firstline spec.
      polyline = 2; 
      firstline = fig3(polyline,stroke_thickness,stroke_colour);
      fprintf(filenum, '%s\n', firstline);

      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;

    for i = index_f		# Do the flow stroke - same side as arrow
      if cbonds(i,2)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;
      
      ## Work out the direction for the stroke (right angles to bond)
      unit_bond_vector = bond_vector./(length2d(bond_vector)*[1 1]);
      unit_stroke_vector = (rot*unit_bond_vector')';
      
      sig = sign(unit_arrow_vector(i,:)*unit_stroke_vector');
      stroke_end_2 = stroke_end_1 + stroke_length*sig*unit_stroke_vector;

      ## print the fig3 format firstline spec.
      polyline = 2; 
      firstline = fig3(polyline,stroke_thickness,stroke_colour);
      fprintf(filenum, '%s\n', firstline);

      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;
  end;

  ## Print all the components - coloured acording to causality.
  ## Miss out the ports
  
  for i = N_rports+1:N_rcomponents
    eval(['[comp_type,comp_name] = ', system_type, '_cmp(i);']);
    eval(["comp_status = CBG.subsystems.", comp_name, ".status;"]);

#     if i>N_rports			# Subsystem
#       comp_name = CBG.subsystemlist(i-N_rports,:);
#       eval(["comp_status = CBG.subsystems.", comp_name, ".status;"]);
#     else
#       comp_name = CBG.portlist(i,:);
#       eval(["comp_status = CBG.ports.", comp_name, ".status;"]);
#     end

    
    fig_params = rcomponents(i,3:M_components);
    coords = rcomponents(i,1:2);
    
    if comp_status==-1		# Then under causal
      fig_params(3) = comp_colour_u;
      fig_params(6) = comp_font;
    end;

    if comp_status==1		# Then over causal
      fig_params(3) = comp_colour_o;
      fig_params(6) = comp_font;
    end;


    ## Now print the component in fig format
    
    if index(comp_name,"mtt")==1 # Its a dummy name
      typename = comp_type;	# just show type
    else
      typename = [comp_type,":",comp_name];
    endif;

    Terminator = [bs, '001'];  
    real_index = 8;
    for j = 1:length(fig_params)
      if j==real_index
	fprintf(filenum, '%2.4f ', fig_params(j));
      else
	fprintf(filenum, '%i ', fig_params(j));
      endif
      

    endfor
    
    

    fprintf(filenum, '%1.0f %1.0f ', coords(1), coords(2)); 
    fprintf(filenum, '%s%s\n', typename, Terminator);

  endfor

  ## Close the file
  fclose(filenum);
  return

endfunction

Deleted mttroot/mtt/bin/trans/m/cr2name.m version [27c939caaa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function crname = cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args,port);
% cr2name - Constructs a string for the cr of a component.
% % 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cr2name
% cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args);

% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/08/22  18:31:06  peter
% %% Fixed comment bug.
% %%
% %% Revision 1.1  1996/08/22 13:14:39  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin<7
  port=0
end;


if length(args)==0
  a_comma = '';
else
  a_comma = ',';
end;

if length(cr)==0
  cause_name = '';
  lp = '';
  rp = '';
  c_comma = '';
else
  cause_name = cause2name(LHS_cause);
  lp = '(';
  rp = ')';
  c_comma = ',';
end

if port == 0
  port_name = '';
  p_comma = '';
else
  port_name = sprintf('%1.0f',port);
  p_comma = ',';
end;

crname = sprintf('%s%s%s%s%s%s%s%s%s\t%s', ...
    cr,lp, args, a_comma, port_name, p_comma, cause_name, c_comma, ...
    varname(name, RHS_number,RHS_cause),rp);
    
    





Deleted mttroot/mtt/bin/trans/m/csm2sm.m version [82261a8899].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D] = csm2sm(A,B,C,D,E);
% [A,B,C,D] = csm2sm(A,B,C,D,E);
% Converts constrained-state matrices to state matrices.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


A = E\A;
B = E\B;

Deleted mttroot/mtt/bin/trans/m/dm2fr.m version [55c366535d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  fr = dm2fr(A,B,C,D,E,W,u0)
# fr = dm2fr(A,B,C,D,E,W,u0)
# Descriptor matrix to frequency response.
# A,B,C,D,E - descriptor matrices
# W vector of frequency points
# u0 input gain vector: u = u0*unit phasor

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.8  1997/06/13 13:05:38  peterg
# ## Replaced 'C*( (E*j*w - A) \ B*u0 ' by  C*( inv(E*j*w - A)*B*u0 ). \
# ## seems to have a bug for complex nos (??)
# ##
# ## Revision 1.7  1996/11/06  16:40:38  peterg
# ## Explicit definition of j
# ##
# ## Revision 1.6  1996/08/24  14:22:23  peter
# ## Put in a ; to avoid excessive log output.
# ##
# ## Revision 1.5  1996/08/16 14:26:37  peter
# ## Check and fix size of u0.
# ##
# ## Revision 1.4  1996/08/15 12:50:51  peter
# ## Put in a conj to undo effect of transpose.
# ##
# ## Revision 1.3  1996/08/15 11:53:44  peter
# ## Now has u0 input vector
# ##
# ## Revision 1.2  1996/08/15 10:24:28  peter
# ## Includes u0 argument.
# ##
# ## Revision 1.1  1996/08/10 14:11:28  peter
# ## Initial revision
# ##
# ###############################################################

[Ny,Nu] = size(D);
[Ny,Nx] = size(C);
N = length(W);

if nargin<7
  U0 = zeros(Nu,1);
  U0(1) = 1;
else
  for i=1:Nu
    U0(i) = u0(i);
  end;
end;

u0 = U0;

[n,m]=size(W);
if m>n
  W=W';
end;

[n,m]=size(u0);
if m>n
  u0=u0';
end;

j = sqrt(-1);
fr = zeros(N,Ny);
i = 0;
for w = W'
  i = i+1;
  ##   EjA = E*j*w - A;
  ##   iEjA = conj(EjA)*inv(conj(EjA)*EjA);
  ##   FR = C*iEjA*B*u0 + D*u0;
  FR = C*( (E*j*w - A) \ B*u0 ) + D*u0;
  ## FR = C*( inv(E*j*w - A)*B*u0 ) + D*u0;
  fr(i,:) = conj(FR');
end;













Deleted mttroot/mtt/bin/trans/m/dm2ir.m version [205a34d87e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ir = dm2ir(A,B,C,D,E,T);
% ir = dm2ir(A,B,C,D,E,T);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/08/10 14:16:04  peter
% %% Now has T vector input - it was tmax & tstep
% %%
% %% Revision 1.2  1996/08/10 11:49:39  peter
% %% Fixed multi-input/output problem
% %%
% %% Revision 1.1  1996/08/10 10:26:00  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;

[Ny,Nu] = size(D);
NN=Ny*Nu;

ir = zeros(N,NN);
i = 0;
for t = T'
  i=i+1;
  ir(i,:) = reshape(C*expm(A*t)*B, 1,NN);
end;

Deleted mttroot/mtt/bin/trans/m/dm2sr.m version [ef0adb9b22].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/08/15 08:34:08  peter
% %% Added step gain (u0) and initial condition (x0)
% %%
% %% Revision 1.3  1996/08/11 19:33:24  peter
% %% Replaced exp by expm - whoops!
% %%
% %% Revision 1.2  1996/08/11 10:37:40  peter
% %% Corrected mistake in step-response calculation.
% %%
% %% Revision 1.1  1996/08/11 09:42:40  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if nargin<7
  u0 = zeros(Nu,1);
  u0(1) = 1;
end;

if nargin<8
  x0 = zeros(Nx,1);
end;

[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;

one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);
i = 0;
for t = T'
  i=i+1;
  if Nx>0
    expAt = expm(A*t);
    x = ( A\(expAt-one) )*B*u0 + expAt*x0;
    X(i,:) = x';
    if Ny>0
      y = C*x + D*u0;
      Y(i,:) = y';
    end;
  elseif Ny>0
    y = D*u0;
    Y(i,:) = y';
  end;
end;

Deleted mttroot/mtt/bin/trans/m/equation.m version [20f1c9cc29].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function eqn =  equation(comp_type, name,cr,args,outbond,outcause,outport, ...
                         inbonds,incauses,inports)
  ## eqn is a string containing the equation
  ## 
  ## 
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function equations.m
  ## eqn =  equation(name,cr,args,outbond,outcause,outport, ...
  ##                              inbonds,incauses,inports)


  ## ############################################################### ## Version
  ## control history
  ## ############################################################### ## $Id:
  ## equation.m,v 1.6 2000/12/27 16:06:00 peterg Exp $ ## $Log:
  ## equation.m,v $ ## Revision 1.6  2000/12/27 16:06:00  peterg ## ***
  ## empty log message *** ## ## Revision 1.5  1996/12/05  11:26:51
  ## peterg ## Null strings now detected with strcmp not length. ## ##
  ## Revision 1.4  1996/09/12 16:42:01  peter ## Default now out side
  ## this function - need to be none for each ## component. ## ##
  ## Revision 1.3  1996/09/12 12:03:58  peter ## Added some error
  ## checking. ## If no constitutive relationship, only add diagonal
  ## elementts to ## default unity output. ## ## Revision 1.2
  ## 1996/09/10 11:29:47  peter ## Removed causality & port info when no
  ## constitutive relationship. ## ## Revision 1.1  1996/09/10 11:11:11peter
  ## ## Initial revision ##
  ## ###############################################################


  ## Find the number of inports
  nports = length(inbonds);

  ## Check some arguments
  if length(incauses) ~= nports
    error("equation.m: incauses inconsistent with inbonds");
  endif


  if length(inports) ~= nports
    error("equation.m: inports inconsistent with inbonds");
  endif


  ## Set up LHS
  LHS = varname(name, outbond, outcause);

  ## Set up various strings to get correct syntax if some strings are empty
  if strcmp(cr,"")
    cause_name = "";
    port_name = "";
    lp = "";
    rp = "";
    c_comma = "";
  else
    cause_name = cause2name(outcause);
    port_name = sprintf("%i", outport');
    lp = sprintf("(%s, ", comp_type); 
    rp = ")";
    c_comma = ",";
  end

  if strcmp(args,"")
    a_comma = "";
  else
    a_comma = ",";
  endif


  ## Set up first line of RHS
  RHS1 = sprintf("%s%s%s%s%s%s%s%s", ...
		 cr, lp, args, a_comma, cause_name, c_comma, port_name, c_comma);


  ## Set up rest of RHS - the input variables, causality and ports.
  RHS2 = "";
  for i=1:nports
    RHS2 = sprintf("%s\t%s", ...
		   RHS2, varname(name, inbonds(i), incauses(i)));
    
    if strcmp(cr,"")==0 # add the causality & port info
      RHS2 = sprintf("%s,%s,%i", ...
		     RHS2, cause2name(incauses(i)), inports(i));
      
    endif
    
    if (i<nports) # Add a comma
      RHS2 = sprintf("%s,",RHS2);
    else
      RHS2 = sprintf("%s",RHS2);

    endif

  endfor
  
  
  
  ## Set up equation
  eqn = sprintf("%s := %s%s%s;\n", LHS, RHS1, RHS2, rp);

endfunction

Deleted mttroot/mtt/bin/trans/m/fig3.m version [482caa1bd5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function first_line = fig3(object,thickness,colour)
% first_line = fig3(object,thickness,colour)
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Matlab function fig3.m
% Provides the "first line" format for polyines and text objects
% See fig 3 documentation for details
%
% P.J.Gawthrop June 1996
% Copyright (c) P.J.Gawthrop, 1996.

red = 4;
blue = 1;

if (object==2)	%Polyline
  sub_type = 1;
  line_style = 0;

  if nargin<2
    thickness = 3;
  end;

  if nargin<3
    colour = red;
  end;
  
  fill_colour = -1;
  depth = 0;
  pen_style = 0;
  area_fill = -1;
  style_val = 0.0;
  join_style = 0;
  cap_style = 0;
  radius = -1;
  f_arrow = 0;
  b_arrow = 0;
  npoints = 2;
  first_line = [... 
    int2str(object), ' ', ... 
    int2str(sub_type), ' ', ... 
    int2str(line_style), ' ', ...
    int2str(thickness), ' ', ...
    int2str(colour), ' ', ...
    int2str(fill_colour), ' ', ...
    int2str(depth), ' ', ...
    int2str(pen_style), ' ', ...
    int2str(area_fill), ' ', ...
    num2str(style_val), ' ' ...
    int2str(join_style), ' ', ...
    int2str(cap_style), ' ', ...
    int2str(radius), ' ', ...
    int2str(f_arrow), ' ', ...
    int2str(b_arrow), ' ', ...
    int2str(npoints)];
 
elseif (object==4) %text


else
  error('Object must be 2 (polyline) or 4(text)');
end;



Deleted mttroot/mtt/bin/trans/m/figfig.m version [f08a96551e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function figfig(filename,language,boxed,monochrome,key)
  ## Usage: figfig(filename[,language,boxed,monochrome])
  ## Puts octave figure into fig file (filename.fig)
  ## If second argument, converts to filename.language using fig2dev
  ## eg:
  ##    figfig("foo");
  ##    figfig("foo","eps");
  ##    figfig("foo","pdf");
  ## Boxed=1 gives a box around the figure
  ## Monochrome=1 gives a monchrome plot
  ## key=1 gives the key legend

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.11  2004/03/15 11:44:34  gawthrop
  ## Yet another option (to allow legend).
  ##
  ## Revision 1.10  2003/08/19 13:13:28  gawthrop
  ## No legend
  ##
  ## Revision 1.9  2002/09/12 08:39:27  gawthrop
  ## Removed spurious text
  ##
  ## Revision 1.8  2002/09/11 15:04:59  gawthrop
  ## Optional boxing
  ##
  ## Revision 1.7  2002/08/20 15:51:17  gawthrop
  ## Update to work with ident DIY rep
  ##
  ## Revision 1.6  2001/05/24 07:44:36  gawthrop
  ## Minor updates ..
  ##
  ## Revision 1.5  2001/05/10 19:08:35  gawthrop
  ## Cosmetic improvements
  ##
  ## Revision 1.4  2001/05/08 15:18:12  gawthrop
  ## Added trig and hyperbolic functions to argument exclusion list
  ##
  ## Revision 1.3  2001/04/10 12:54:50  gawthrop
  ## Minor fixes for sensitivity versions
  ##
  ## Revision 1.2  2000/12/27 16:06:02  peterg
  ## *** empty log message ***
  ##
  ## Revision 1.1  2000/11/03 10:43:10  peterg
  ## Initial revision
  ###############################################################

  if nargin<3
    boxed=0;
  endif
  
  if nargin<4
    monochrome=0;
  endif
  
  if nargin<5
    key=0;
  endif
  
  
  figfilename = sprintf("%s.fig",filename);
  
  eval(sprintf("gset output \"%s\" ",figfilename));

  if key!=1
    gset nokey			# No legend
  endif
  
  if (monochrome==1)
    gset term fig monochrome portrait fontsize 16 size 20 10 metric thickness 3
  else
    gset term fig color portrait fontsize 16 size 20 10 metric thickness 3
  endif
  replot;
  gset term x11
  gset output
  replot;

  if boxed # Add a box - makes a visible bounding box
    fid = fopen(figfilename,"a+t");
    fprintf(fid,"2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5\n");
    fprintf(fid,"\t9675 5310 9675 270 225 270 225 5310 9675 5310\n");
    fclose(fid);
  endif
  

  if nargin>1			# Do a file in another langueage
    sleep(1);
    psfilename = sprintf("%s.%s",filename,language);
    convert = sprintf("fig2dev -L%s %s > %s", language, figfilename, psfilename);
    system(convert);
  endif

  gset key			# Put it back
endfunction

Deleted mttroot/mtt/bin/trans/m/getdynamic.m version [96484d5f7e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,prefered] = getdynamic(subsystems);
# Get the index of a dynamic components which is not set.

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1996/08/16 12:51:22  peter
# ## Removed debugging lines.
# ##
# ## Revision 1.1  1996/08/16 12:50:41  peter
# ## Initial revision
# ##
# ###############################################################

  prefered = 0;			# No prefered causality to start with
  for [subsystem,name] = subsystems
    if subsystem.status==-1 # Undercausal
      if strcmp(subsystem.type,'C')
      	prefered=-1;
      	break;
      endif;
      if strcmp(subsystem.type,'I')
      	prefered=1;
      	break;
      endif;
    endif;
  endfor;

  if prefered==0
    name = "";
  end;
  
endfunction

Deleted mttroot/mtt/bin/trans/m/getindex.m version [b17581b243].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [index, n, otherindex, m] = getindex(array,value);
% Finds the n indices of the elements of array equal to value
% otherindex contains indeces of the the m other  elements.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[N,M] = size(array);
n=0; m=0;
for i=1:N
  for j = 1:M
    if array(i,j)==value
      n=n+1;
      index(n,:) = [i j];
    else
      m=m+1;
      otherindex(m,:) = [i j];
    end;
  end;
end;


if (M==1)&(n>0)
  index = index(:,1);
end;

if (M==1)&(m>0)
  otherindex = otherindex(:,1);
end;

% Octave doesn't like empty matrices
if n==0
  index=0;
end;

if m==0
  otherindex=0;
end;



Deleted mttroot/mtt/bin/trans/m/ibg2abg.m version [acf7448537].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635



























































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*-

function [bonds,components,n_vector_bonds] = ...
      ibg2abg(name,bonds,infofile,errorfile)

  ## write useful quantity of data to log
  struct_levels_to_print(6);

  ################################
  ## create component structure ##
  ################################
  
  ## loop over each bond in ibg.m file
  for [bond, bond_name] = bonds
    ## get the bond number
    bond_name
    i = str2num(strtok(bond_name, "bond"))

    ## populate "head" and "tail" structures
    ## then copy the contents to an overall structure

    ## track (signed) vector bond number within each component
    head.index = +i
    tail.index = -i

    ## extract type of component at each end
    head_type = deblank(char(strsplit(bond.head.component, ":"))(1,:))
    tail_type = deblank(char(strsplit(bond.tail.component, ":"))(1,:))

    ## extract name of component at each end
    head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:))
    tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:))

    ## extract port label data
    head.label = bond.head.ports
    tail.label = bond.tail.ports

    disp("--checking head and tail for components or ports --") 
    ## determine whether internal port or subsystem
    ## and fix names of ports
    if (strcmp(head_type, "SS") & (index(head_name, "[") == 1))
      head_comp_or_port = "port"
      head_name = mtt_strip_name(head_name);
    else
      head_comp_or_port = "comp"
    endif
    if (strcmp(tail_type, "SS") & (index(tail_name, "[") == 1))
      tail_comp_or_port = "port"
      tail_name = mtt_strip_name(tail_name);
    else
      tail_comp_or_port = "comp"
    endif

    ## copy data to object structure (objects)
    cmd = sprintf("objects.%s.%s.type = '%s';",
		  head_comp_or_port, head_name, head_type)
    eval(cmd)
    cmd = sprintf("objects.%s.%s.type = '%s';",
		  tail_comp_or_port, tail_name, tail_type)
    eval(cmd)
    
    cmd = sprintf("objects.%s.%s.bond%i = head;", 
		  head_comp_or_port, head_name, i)
    eval(cmd)
    cmd = sprintf("objects.%s.%s.bond%i = tail;", 
		  tail_comp_or_port, tail_name, i)
    eval(cmd)
  endfor    

  disp("--finished extracting data from ibg.m --")
  objects
    
  ## object structure:
  ##
  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       bond%i
  ##         label
  ##   port
  ##     %s (name)
  ##       type
  ##       bond%i
  ##         label
  ##
  ## "comp" contains components, subsystems and external SS
  ## "port" contains internal SS:[...]

  ####################################################
  ## count number of vector bonds on each component ##
  ####################################################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      n = size(fieldnames(comp))(1) - 1;
      eval(sprintf("objects.comp.%s.n_bonds = %i;",
		   comp_name, n));
    endfor
  endif
  
  if (isfield(objects, "port"))
    for [port, port_name] = objects.port
      n = size(fieldnames(port))(1) - 1;
      eval(sprintf("objects.port.%s.n_bonds = %i;",
		   port_name, n));
    endfor
  endif

  disp("-- finished counting number of bonds on components --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label

  ########################################################
  ## ensure labels exist on all ports of each component ##
  ########################################################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      if (strcmp(comp.type, "0") | strcmp(comp.type, "1"))

	## convert type
	if (strcmp(comp.type, "0"))
	  comp.type = "zero";
	elseif (strcmp(comp.type, "1"))
	  comp.type = "one";
	endif

	## component is a junction
	n_named_ports = 0;
	
	## get labelled ports
	for [bond, bond_name] = comp
	  if (index(bond_name, "bond") == 1)
	    if (! isfield (bond, "label"))
	      bond.label = "[]"
	    endif
	    if (! strcmp(bond.label, "[]"))
	      n_named_ports += 1;
	      port_label = bond.label;
	    endif
	  endif
	  eval(sprintf("comp.%s = bond;", bond_name));
	endfor
	
	## attach labels to unlabelled ports
	if (n_named_ports == 0)
	  mtt_info(sprintf("Defaulting all ports on junction %s to 'in'", ...
			   comp_name), infofile);
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      bond.label = "in";
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	elseif (n_named_ports == 1)
	  mtt_info(sprintf("Defaulting all ports on junction %s to %s", ...
			   comp_name, port_label), infofile);
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      bond.label = port_label;
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	elseif (n_named_ports != comp.n_bonds)
	  mtt_error(sprintf("Junction must have 0,1 or %i port labels", ...
			    comp.n_bonds), errorfile);
	endif
	
      else
	## component is not a junction
	for [bond, bond_name] = comp
	  if (index(bond_name, "bond") == 1)
	    if (strcmp(bond.label, "[]"))
	      if (bond.index > 0)
		bond.label = "in";
	      else
		bond.label = "out";
	      endif
	    else
	      bond.label = mtt_strip_name(bond.label);
	    endif
	  endif
	  eval(sprintf("comp.%s = bond;", bond_name));
	endfor
      endif
      
      eval(sprintf("objects.comp.%s = comp;", comp_name));
    endfor
  endif

  ####################
  ## expand aliases ##
  ####################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      if ((! strcmp(comp.type, "zero")) & (! strcmp(comp.type, "one")))
	alias = eval(sprintf("%s_alias", comp.type));
	if (isstruct(alias))
	  for [bond, bond_name] = comp;
	    if (isstruct(bond))
	      if (isfield(alias, bond.label))
		old_name = bond.label;
		new_name = eval(sprintf("alias.%s", old_name));
		bond.label = new_name;
		mtt_info(sprintf("Aliasing [%s] on %s (%s) to [%s]",
				 old_name, comp_name, comp.type, new_name),
			 infofile);
	      endif
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	endif
	eval(sprintf("objects.comp.%s = comp;", comp_name));
      endif
    endfor
  endif

  disp("-- finished expanding aliases --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label

  ##########################################
  ## create sub-bonds according to labels ##
  ##########################################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      for [bond, bond_name] = comp
	if (index(bond_name, "bond") == 1)
	  [sub_bonds, n_sub_bonds] = split_port(bond.label);
	  for i = 1:n_sub_bonds
	    eval(sprintf("bond.subbond%i.label = '%s';",
			 i, deblank(sub_bonds(i,:))))
	  endfor
	endif
	eval(sprintf("comp.%s = bond;", bond_name));
      endfor
      eval(sprintf("objects.comp.%s = comp;", comp_name));
    endfor
  endif

  if (isfield(objects, "port"))
    for [port, port_name] = objects.port
      for [bond, bond_name] = port
	if (index(bond_name, "bond") == 1)
	  [sub_bonds, n_sub_bonds] = split_port(bond.label);
	  for i = 1:n_sub_bonds
	    eval(sprintf("bond.subbond%i.label = '%s';",
			 i, deblank(sub_bonds(i,:))));
	  endfor
	endif
	eval(sprintf("port.%s = bond;", bond_name));
      endfor
      eval(sprintf("objects.port.%s = port;", port_name));
    endfor
  endif

  disp("-- finished creating sub-bonds --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i

  #########################################
  ## assign a unique number to each bond ##
  #########################################

  unique_bond_number = 0;
  
  for [bond, bond_name] = bonds
    i = str2num(strtok(bond_name, "bond"));

    ## extract type of component at each end
    head.type = deblank(char(strsplit(bond.head.component, ":"))(1,:));
    tail.type = deblank(char(strsplit(bond.tail.component, ":"))(1,:));

    ## extract name of component at each end
    head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:));
    tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:));
 
    ## determine whether internal port or subsystem
    ## and fix names of ports
    if (strcmp(head.type, "SS") & (index(head_name, "[") == 1))
      head_comp_or_port = "port";
      head_name = mtt_strip_name(head_name);
    else
      head_comp_or_port = "comp";
    endif
    if (strcmp(tail.type, "SS") & (index(tail_name, "[") == 1))
      tail_comp_or_port = "port";
      tail_name = mtt_strip_name(tail_name);
    else
      tail_comp_or_port = "comp";
    endif

    ## create strings to reference each component
    head_str = sprintf("objects.%s.%s.bond%i",
		       head_comp_or_port, head_name, i)
    tail_str = sprintf("objects.%s.%s.bond%i",
		       tail_comp_or_port, tail_name, i)

    head_bond = eval(head_str);
    tail_bond = eval(tail_str);
    
    ## check compatible sizes
    head.n_subs = size(fieldnames(head_bond))(1) - 2;
    tail.n_subs = size(fieldnames(tail_bond))(1) - 2;
    if (head.n_subs != tail.n_subs)
      mtt_error(sprintf("Vector ports '%s' (%s:%s) and '%s' (%s:%s) are not compatible",
			head_bond.label, head.type, head_name,
			tail_bond.label, tail.type, tail_name),
		errorfile);
    elseif (head.n_subs > 1)
      mtt_info(sprintf("Vector port '%s'(%s:%s) matches '%s' (%s:%s)",
		       head_bond.label, head.type, head_name,
		       tail_bond.label, tail.type, tail_type),
	       infofile);
    endif

    ## write type at other end
    eval(sprintf("%s.other_end_type = '%s';",
		 head_str, tail.type));
    eval(sprintf("%s.other_end_type = '%s';",
		 tail_str, head.type));

    ## assign bond number
    for i = 1:head.n_subs
      ++unique_bond_number;
      eval(sprintf("%s.subbond%i.index = +%i;",
		   head_str, i, unique_bond_number));
      eval(sprintf("%s.subbond%i.index = -%i;",
		   tail_str, i, unique_bond_number));

      ## write causality for bond
      if (strcmp(bond.causality.effort, "head"))
	eval(sprintf("causality(%i,1) = +1;", unique_bond_number));
      elseif (strcmp(bond.causality.effort, "tail"))
	eval(sprintf("causality(%i,1) = -1;", unique_bond_number));
      else
	eval(sprintf("causality(%i,1) = 0;", unique_bond_number));
      endif

      if (strcmp(bond.causality.flow, "head"))
	eval(sprintf("causality(%i,2) = -1;", unique_bond_number));
      elseif (strcmp(bond.causality.flow, "tail"))
	eval(sprintf("causality(%i,2) = +1;", unique_bond_number));
      else
	eval(sprintf("causality(%i,2) = 0;", unique_bond_number));
      endif
      
    endfor
  endfor

  disp("-- finished assigning unique numbers to bonds --")
  objects
  
  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index

  ## causality matrix is called "bonds"
  bonds = causality
  disp("-- finished writing bonds matrix --")  

  #################################
  ## map component data to cmp.m ##
  #################################

  ## count number of components
  if (isfield(objects, "comp"))
    n_comps = size(fieldnames(objects.comp), 1)
  else
    n_comps = 0;
  endif

  ## count number of internal ports
  if (isfield(objects, "port"))
    n_ports = size(fieldnames(objects.port), 1)
  else
    n_ports = 0;
  endif

  ## read data from _cmp.m
  for cmp = 1:(n_comps + n_ports)
    [this_type, this_name] = eval(sprintf("%s_cmp(%i)", name, cmp));
    ## determine if internal port (and fix name) or subsystem
    if (strcmp(this_type, "SS") & (index(this_name, "[") == 1))
      comp_or_port = "port";
      this_name = mtt_strip_name(this_name)
    else
      comp_or_port = "comp";
    endif
    eval(sprintf("objects.%s.%s.index = cmp;", comp_or_port, this_name));
  endfor

  disp("-- finished getting component indices from cmp.m --")
  objects

  ## objects
  ##   comp
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index
  ##       index
  ##   port
  ##     %s (name)
  ##       type
  ##       n_bonds
  ##       bond%i
  ##         label
  ##         subbond%i
  ##           index
  ##       index

  ##########################
  ## write n_vector_bonds ##
  ##########################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      n_vector_bonds(comp.index,1) = comp.n_bonds;
    endfor
  endif

  disp("-- finished writing n_vector_bonds --")
  n_vector_bonds

  ###########################################
  ## Write connections matrix (components) ##
  ###########################################
  
  if (isfield(objects, "comp"))
    n_comps = size(fieldnames(objects.comp))(1);
  else
    n_comps = 0;
  endif

  components = zeros(n_comps+n_ports, max(n_vector_bonds));

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      ## get portlist for component      
      if exist([comp.type, '_cause']) == 0
 	eval(sprintf("ABG = %s_abg;", comp.type));
 	if isfield(ABG, "portlist")
 	  port_list = ABG.portlist;
 	else
 	  error(sprintf("Component %s has no ports", comp.type));
 	endif
      else
	## must be a simple component:
	## lib/comp/simple/comp_ports.m assigns port numbers
 	port_list = comp_ports(comp.type, comp.n_bonds)
      endif
      ## but do what with it?

      counter = 0;

      n_ports = size(port_list,1)
      if (strcmp(comp.type, "zero")) | (strcmp(comp.type, "one"))
	for port = 1 : n_ports
	  component_type = comp.type
	  the_port_list = port_list
	  the_port = port
	  label = port_list(port,:)
	  if (index (label, "[") == 1)
	    label = mtt_strip_name(label)
	  endif
	  label = deblank(label)
	  
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      for [sub_bond, sub_bond_name] = bond
		
		if (index(sub_bond_name, "subbond") == 1)
		  sub_bond_label = sub_bond.label
		  if (index (sub_bond_label, "[") == 1)
		    sub_bond_label = mtt_strip_name(sub_bond_label)
		  endif
		  sub_bond_label = deblank(sub_bond_label)
		  		  
		  if (strcmp(sub_bond_label, label) | strcmp (sub_bond_label,"in"))
		    components(comp.index, ++counter) = sub_bond.index
		  endif
		  
		endif
	      endfor
	    endif
	  endfor
	endfor
	
      elseif (n_ports == 1)
	## no ordering necessary
	for [bond, bond_name] = comp
	  if (index(bond_name, "bond") == 1)
	    for [sub_bond, sub_bond_name] = bond
	      if (index(sub_bond_name, "subbond") == 1)
		components(comp.index, ++counter) = sub_bond.index
	      endif
	    endfor
	  endif
	endfor

      else
	## multiple ports, need to order them
	for port = 1 : n_ports
	  component_type = comp.type
	  the_port_list = port_list
	  the_port = port
	  label = port_list(port,:)
	  if (index (label, "[") == 1)
	    label = mtt_strip_name(label)
	  endif
	  label = deblank(label)
		    	  
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      for [sub_bond, sub_bond_name] = bond

		if (index(sub_bond_name, "subbond") == 1)
		  sub_bond_label = sub_bond.label
		  if (index (sub_bond_label, "[") == 1)
		    sub_bond_label = mtt_strip_name(sub_bond_label)
		  endif
		  sub_bond_label = deblank(sub_bond_label)

		  ## unalias sub_bond label
		  if exist([comp.type, '_alias'])
		    eval(sprintf("alias = %s_alias", comp.type))
		    if isstruct(alias)
		      while_counter = 0;
		      while isfield(alias, sub_bond_label)
			old_sub_bond_label = sub_bond_label;
			sub_bond_label = eval(sprintf("alias.%s", sub_bond_label))
			if strcmp(old_sub_bond_label, sub_bond_label)
			  break;
			endif
		      endwhile
		    endif
		  endif
		    
		  if (strcmp(sub_bond_label, label))
		    components(comp.index, ++counter) = sub_bond.index
		  endif

		endif
	      endfor
	    endif
	  endfor
	endfor

      endif
    endfor
  endif
  disp("-- finished getting port_list --")
  port_list
  
   if (isfield(objects, "port"))
     for [port, port_name] = objects.port
       counter = 0;
       for [bond, bond_name] = port
 	if (index(bond_name, "bond") == 1)
 	  for [sub_bond, sub_bond_name] = bond
 	    if (index(sub_bond_name, "subbond") == 1)
 	      components(port.index, ++counter) = sub_bond.index;
 	    endif
 	  endfor
 	endif
       endfor
     endfor
   endif

  disp("-- finished writing components matrix --")
  components

endfunction

Deleted mttroot/mtt/bin/trans/m/length2d.m version [ad2755e59c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function len = length2d(vector_array)
% length2d - Finds (geometric) length of row vectors stacked 
% into a column vector
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  length2d
% len = length2d(vector_array)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% 

len = sqrt(sum(vector_array'.^2)');

Deleted mttroot/mtt/bin/trans/m/makedef.m version [4b8ed092ca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131



































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function makedef(structure,deffilenum);

  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% Version control history
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% $Id$
  ## %% $Log$
  ## %% Revision 1.8  2000/10/20 13:26:41  peterg
  ## %% Made sure that mttui not declared twice
  ## %%
  ## %% Revision 1.7  2000/10/20 13:16:29  peterg
  ## %% Reformated
  ## %%
  ## %% Revision 1.6  1996/12/07 18:21:57  peterg
  ## %% Now uses fopen + file number
  ## %%
  ## %% Revision 1.5  1996/11/09 21:05:44  peterg
  ## %% Only generates MTTIm when at least 2 states!
  ## %%
  ## %% Revision 1.4  1996/08/30  19:42:36  peter
  ## %% Added newline at end of file.
  ## %%
  ## %% Revision 1.3  1996/08/24 15:06:22  peter
  ## %% Write `END;' at end to please reduce.
  ## %%
  ## %% Revision 1.2  1996/08/18 20:05:20  peter
  ## %% Put unded version control
  ## %%
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



  states = structure(1);
  nonstates=structure(2);
  inputs=structure(3);
  outputs=structure(4);
  zero_outputs = structure(5);
  internal_inputs = structure(6);
  connecting_inputs = structure(7);

  pc = '%';
  ## Declare reduce constants;
  fprintf(deffilenum, 'MTTNx := %1.0f;\n', states);
  fprintf(deffilenum, 'MTTNz := %1.0f;\n', nonstates);
  fprintf(deffilenum, 'MTTNu := %1.0f;\n', inputs);
  fprintf(deffilenum, 'MTTNy := %1.0f;\n', outputs);
  fprintf(deffilenum, 'MTTNyz := %1.0f;\n', zero_outputs);
  fprintf(deffilenum, 'MTTNui := %1.0f;\n', internal_inputs);
  fprintf(deffilenum, 'MTTNuc := %1.0f;\n', connecting_inputs);

  ## Declare reduce matrices
  fprintf(deffilenum, '%s Declare reduce matrices\n', pc);
  if states>0
    fprintf(deffilenum, 'matrix MTTx(%1.0f,1);\n', states);
    fprintf(deffilenum, 'matrix MTTdx(%1.0f,1);\n', states);
  endif

  if nonstates>0
    fprintf(deffilenum, 'matrix MTTz(%1.0f,1);\n', nonstates);
    fprintf(deffilenum, 'matrix MTTdz(%1.0f,1);\n', nonstates);
  endif

  if inputs>0
    fprintf(deffilenum, 'matrix MTTu(%1.0f,1);\n', inputs);
    fprintf(deffilenum, 'matrix MTTdu(%1.0f,1);\n', inputs);
  endif

  if outputs>0
    fprintf(deffilenum, 'matrix MTTy(%1.0f,1);\n', outputs);
  endif

  if zero_outputs>0
    fprintf(deffilenum, 'matrix MTTyz(%1.0f,1);\n', zero_outputs);
    fprintf(deffilenum, 'matrix MTTui(%1.0f,1);\n', zero_outputs);
  elseif internal_inputs>0
    fprintf(deffilenum, 'matrix MTTui(%1.0f,1);\n', inputs);
  endif

  if connecting_inputs>0
    fprintf(deffilenum, 'matrix MTTuc(%1.0f,1);\n', connecting_inputs);
  endif


  ## Make an Nx x Nx unit matrix
  if states>0
    fprintf(deffilenum, 'matrix MTTI(%1.0f,%1.0f);\n', states,states);
    for i = 1:states
      fprintf(deffilenum, 'MTTI(%1.0f,%1.0f) := 1;\n', i, i);
    end
  endif


  ## Make an Nx/2 x Nx/2 unit matrix
  if states>1
    fprintf(deffilenum, 'matrix MTTIm(%1.0f,%1.0f);\n', states/2,states/2);
    for i = 1:states/2
      fprintf(deffilenum, 'MTTIM(%1.0f,%1.0f) := 1;\n', i, i);
    end
  endif


  ## Set the y, yz, du, u, x and dx matrices
  fprintf(deffilenum, '%s Set the y, yz, u and x matrices\n', pc);
  for i=1:outputs
    fprintf(deffilenum, 'MTTy(%1.0f,1) := MTTy%1.0f;\n', i, i);
  endfor

  for i=1:zero_outputs
    fprintf(deffilenum, 'MTTyz(%1.0f,1) := MTTyz%1.0f;\n', i, i);
    fprintf(deffilenum, 'MTTui(%1.0f,1) := MTTui%1.0f;\n', i, i);
  endfor

  for i=1:inputs
    fprintf(deffilenum, 'MTTu(%1.0f,1) := MTTu%1.0f;\n', i, i);
  endfor

  for i=1:inputs
    fprintf(deffilenum, 'MTTdu(%1.0f,1) := MTTdu%1.0f;\n', i, i);
  endfor

  for i=1:states
    fprintf(deffilenum, 'MTTx(%1.0f,1) := MTTx%1.0f;\n', i, i);
  endfor

  for i=1:nonstates
    fprintf(deffilenum, 'MTTdz(%1.0f,1) := MTTdz%1.0f;\n', i, i);
  endfor

  fflush (deffilenum);

endfunction

Deleted mttroot/mtt/bin/trans/m/mat2mfile.m version [e8cb0dd3b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  mat2mfile(matrix, matrix_name, filenum);
% mat2mfile - writes a matrix as part of an  m-file
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  mat2mfile
% mat2mfile(matrix, matrix_name, filenum)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/04 21:53:00  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

%Writes out a matrix as a matlab m-file

[N, M] = size(matrix);

empty = (N==1)&(M==1)&(matrix(1,1)==0);

%Write out the matrix
fprintf(filenum, '%s = [\n', matrix_name);

if ~empty
  for i = 1:N,
    for j = 1:M
      fprintf(filenum, '%1.0f ', matrix(i,j));
    end;
    fprintf(filenum, '\n');
  end;
else
  fprintf(filenum,'0');
end;
fprintf(filenum, '];\n');
fprintf(filenum, '\n');

Deleted mttroot/mtt/bin/trans/m/mat2tex.m version [557dae5024].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function tex = mat2tex(mat)
  ## mat2tex: converts matrix into LaTeX form.
  ## tex = mat2tex(mat)
  

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  1999/03/25 01:33:51  peterg
  ## Initial revision
  ##
  ###############################################################

  [n,m]=size(mat);

  for i=1:n
    for j=1:m
      if mat(i,j) == 0
	printf("0    ");
	else
	  printf("%5.2f", mat(i,j));
	endif
      if j<m
 	printf("&");
      endif
    endfor
      printf("\\\\\n");
  endfor
  
endfunction



Deleted mttroot/mtt/bin/trans/m/mtt.m version [f788927636].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mtt (sys,rep,lang)

  ## usage:  mtt (system[,representation,language])
  ##
  ## Invokes mtt from octave to generate system_representation.language
  ## Ie equivalent to "mtt system representation language" at the shell
  ## Representation and language defualt to "sm" and "m" respectively

  if nargin<2
    rep='sm';
  endif
  
  if nargin<3
    lang='m';
  endif

  filename = sprintf("%s_%s.%s", sys, rep, lang);

  command = sprintf("mtt -q %s %s %s", sys, rep, lang);
  system(command);


endfunction

Deleted mttroot/mtt/bin/trans/m/mtt2sys.m version [7280c84db2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function sys = mtt2sys (Name,par)

  ## usage:  sys = mtt2sys (Name[,par])
  ##
  ## Creates a sys structure for the Octave Control Systems Toolbox
  ## from an MTT system with name "Name"
  ## Optional second argument is system parameter list
  ## Assumes that Name_sm.m, Name_struc.m and Name_numpar.m exist

  ## Copyright (C) 2000 by Peter J Gawthrop


  if nargin<1
    error("missing system name, usage:  sys = mtt2sys (Name)");
  else
    ## Create function names
    numpar_name = sprintf("%s_numpar",Name);
    sm_name = sprintf("%s_sm",Name);
    struc_name = sprintf("%s_struc",Name);
  endif

  if nargin<2			# Use predefined parameters
    mtt(Name,"numpar");
    eval(sprintf("par=%s_numpar;", Name)); # Parameters
    mtt(Name,"sm");		# Create state matrices
    mtt(Name,"struc");		# Create structure info
    mtt(Name,"sympar");		# Create sympar details
  else				# Only create other file if not there
    if  exist(sm_name)!=2
      mtt(Name,"sm");		# Create state matrices
    endif

    if  exist(struc_name)!=2
      mtt(Name,"struc");	# Create state matrices
    endif

  endif
 
  eval(sprintf("[A,B,C,D]=%s_sm(par);", Name)); # State matrices
  sys = ss(A,B,C,D);		# Sys form
  if (rindex(version,"2.0."))	# stable (pre-list)
    eval(sprintf("[sys.inname,sys.outname,sys.stname]=%s_struc;", Name)); # Setup names
  else 				# development version
    eval(sprintf("[mtt_inname,mtt_outname,mtt_stname]=%s_struc;",Name)); # Setup names
    eval(sprintf("sys = syssetsignals(sys,\"in\", mtt_inname);"));
    eval(sprintf("sys = syssetsignals(sys,\"out\",mtt_outname);"));
    eval(sprintf("sys = syssetsignals(sys,\"st\", mtt_stname);"));
  endif
endfunction






Deleted mttroot/mtt/bin/trans/m/mtt_alias.m version [95ae877303].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [args] = mtt_alias (fullname,args,default);
  ## usage:  [cr,args] = mtt_alias (fullname,cr,args)
  ##
  ## Aliasing code for mtt.
  ## Abstracted from cbg2ese for use in cbg2sese_m2r

  ## Copyright (C) 2003 by Peter J. Gawthrop

  filenum = -1;			# No file number for messages

  [Name,name] = mtt_subname(fullname); # Split fullname

  if (length(args)==0)
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s", ...
		     fullname));
    return
  endif
  
  ## Info for component and surrounding subsystem
  cbg = mtt_cbg(fullname);	# Structure for this component

  if (length(Name)==0)
    return
  else
    Cbg = mtt_cbg(Name);		# Structure for this subsystem
  endif
  

  ## Argument aliasing
  message = sprintf("\tfor component  %s within %s",name,Name);
  if isfield(cbg,"alias")
    args = alias_args(args,cbg.alias,";",message,filenum,fullname);
  endif;

  ## Substitute positional params
  Args = eval(sprintf("Cbg.subsystems.%s.arg;", name));
  args = subs_arg(args,Args,default,Name,"",name,filenum);

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_cbg.m version [d685c05ad4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function cbg = mtt_cbg (name)

  ## usage:  cbg = mtt_cbg (name)
  ##
  ## Gets the cbg (causal bond graph) structure for system name
  ## Copyright (C) 2003 by Peter J. Gawthrop


  ## File name   
  cbg_file = sprintf("%s_cbg",name);

  if (exist(cbg_file)==0)
    error(sprintf("mtt_cbg: subsystem \"%s\" does not exist", name));
  endif
  
  ## Subsystem data structure
  cbg = eval(sprintf("%s;", cbg_file));

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_check_sigs.m version [9dbc2e2795].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function N = mtt_check_sigs (outsig,insigs)

  ## usage:  N = mtt_check_sigs (outsig,insigs)
  ##
  ## 

  ##  A signal has the columns: bond number signal causality (+1 or -1)
  ##  and component port number

  M=3;

  ## Sanity check
  [N_out,M_out] = size(outsig);
  if N_out!=1
    error("There must be exactly one outbond");
  endif
  [N_in,M_in] = size(insigs);
  if (M_out!=M)||(M_in!=M)
    error(sprintf("There must be exactly %i elements to a bond (number, causality, port)",M));
  endif

  N = N_in;

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_component_eqn.m version [a190371a3c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291



































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [known] = mtt_component_eqn (fullname, port, causality, ...
				      known, Cbg)

  ## function [known] = mtt_component_eqn (fullname, port, causality, known)
  ##
  ## Recursively finds the equations giving the signal of specified
  ## causality on the specified port of component named "name" within
  ## subsystem Name 

  ## fullname:  name of component and subsystem
  ## port: port number of component
  ## causality: effort or flow
  ## know_list: list of components already known

  ## Data structures.
  ## A signal is a row vector containing three numbers:
  ##   Index -- a unique (within a subsystem) signed integer
  ##            abs(index) is the unique bond number, sign is the direction.
  ##   Causality -- 1 for effort, -1 for flow
  ##   Port -- the port of the component to which it is connected.
  ## 

  [Name,name] = mtt_subname(fullname); # Split fullname

  SD = "__";			# Subsystem delimiter
  CD = "\n%%";			# Comment delimiter
  arg_default = "1";		# Default aliased arg
  cr_default = "lin";		# Default aliased arg

  DEBUG = 0;

  if DEBUG
    disp("=======================================");
    fullname, name, Name, port,causality,known
  endif
  
  eqn="## No equation -- something wrong"; # Default

  if length(known)<2		# Invalid
    known = "  ";
  endif

  if length(Name)>0
    cbg = mtt_cbg(Name);		# Structure for this subsystem
    if isfield (cbg, "ports")
      ## Combine ports with the other subsystems
      for [component_structure, component] = cbg.ports
	eval(sprintf("cbg.subsystems.%s=cbg.ports.%s;",component,component));
      endfor
    endif
  endif


  if length(name)>0 		# Alias
    ##Alias arguments
    eval(sprintf("ARG=cbg.subsystems.%s.arg;", name)); # Arguments
    ARG = mtt_alias (Name,ARG,arg_default); # Alias them
    eval(sprintf("cbg.subsystems.%s.arg=ARG;", name)); # and copy
    ## Alias CRs
    eval(sprintf("CR=cbg.subsystems.%s.cr;", name)); # CRs
    CR = mtt_alias (Name,CR,cr_default); # Alias them
    eval(sprintf("cbg.subsystems.%s.cr=CR;", name)); # and copy
  else			  # Call to a subsystem (represented by name="")
    if !isfield(cbg,"portlist")
      N_ports = 0;
    else
      [N_ports,M_ports] = size(cbg.portlist);
    endif
    
    if port>N_ports
      error(sprintf("port (%i) > N_ports (%i)", port, N_ports));
    else			# Get name and find equation
      name = deblank(cbg.portlist(port,:));
      if DEBUG
	disp("----> lower-level system")
      endif
      known = mtt_component_eqn (mtt_fullname(Name,name), 1, ...
				 causality, known, cbg);
      return
    endif
  endif
  

  ## Other causality representations
  if strcmp(causality,"effort")
    i_cause = 1;
    othercausality = "flow";
    index_cause = 1;
    cause = "e";
  elseif strcmp(causality,"flow")
    i_cause = -1;
    othercausality = "effort";
    index_cause = 2;
    cause = "f";
  else
    error(sprintf("mtt_component_eqn: causality %s invalid", causality));
  endif
  
  ## A useful composite name
  name_port_cause = sprintf("%s_%i_%s",name, port, cause);
  full_name_port_cause = mtt_fullname(Name,name_port_cause);

  ## If value is known, don't do anything.
  if findstr(sprintf(" %s ", full_name_port_cause), known)>0
    eqn = sprintf("%s The %s signal on port %i of %s is known already", ...
		  CD, causality, port, name);
    return
  else			# Add to list
    known = sprintf("%s %s", known, full_name_port_cause);
  endif
  
  
  
  ## Component type
  comp_type = eval(sprintf("cbg.subsystems.%s.type;", name));
  if DEBUG
    comp_type
  endif
  
  ## Component cr
  cr = eval(sprintf("cbg.subsystems.%s.cr;", name));

  ## Component arg
  arg = eval(sprintf("cbg.subsystems.%s.arg;", name));

  ## To which bond(s) is the component connected?
  connections = eval(sprintf("cbg.subsystems.%s.connections;", name));
  bond_list = abs(connections);	# Unsigned list 
  out_bond_number = bond_list(port);	# The bond at the output of this component
  direction = sign(connections); # Bond directions
  directions = direction'*[1 1]; 

  ## List of system bonds
  bonds = cbg.bonds;

  ## List of component bond causality (component-orientated causality)
  comp_bonds = bonds(bond_list,:).*directions; # Component bonds

  ## What components are at the other ends of the in bonds?
  ## Effort
  [in_e_bonds,in_e_components,in_e_ports,N_e] = mtt_component_inputs ...
      (name,comp_type,causality,"effort",comp_bonds,connections,cbg);
  ## Flow
  [in_f_bonds,in_f_components,in_f_ports,N_f] = mtt_component_inputs ...
      (name,comp_type,causality,"flow",comp_bonds,connections,cbg);


  ##Composite values
  N_ef = N_e + N_f;
  in_ef_bonds = [in_e_bonds; in_f_bonds];
  in_ef_components = [in_e_components; in_f_components];
  in_ef_ports = [in_e_ports; in_f_ports];
  in_causality = [ones(N_e,1); -ones(N_f,1)];

  ## Lists of signals relevant to this component
  outsig = [out_bond_number i_cause port];
  insigs = [in_ef_bonds in_causality in_ef_ports];
  innames = in_ef_components;

  if DEBUG
    outsig
    insigs
    innames
  endif
  
  ## Is the signal the output of a port?
  is_port_output = 0;			# Default
  if isfield (cbg, "ports")
    if isfield (cbg.ports,name)
      is_port_output = (outsig(2)!=insigs(1,2));
    endif
  endif
  
  if is_port_output
    ## Which port (number) is it?
    [N_ports,M_ports] = size(cbg.portlist);
    for i=1:N_ports
      if strcmp(deblank(cbg.portlist(i,:)), name)
	port_index = i;
	break;
      endif
    endfor

    ## File containing data structure
    NAME = mtt_subname(Name);
    CBG = mtt_cbg(NAME);
    
    ## And to which component (at higher level) is it connected?
    [new_Name,new_name] = mtt_subname(Name);
    port_bond = eval(sprintf("CBG.subsystems.%s.connections(%i);", new_name, port_index));
    [in_name, in_port, in_bond] = mtt_other_end (new_name,port_bond,CBG);

    ## Find its equation
    if DEBUG
      disp("----> higher level system")
    endif
    

    known = mtt_component_eqn (mtt_fullname(new_Name,in_name), ...
			       in_port, causality, known, cbg);

    LHS = Source_seqn ("external",Name);
    RHS = varname(NAME, abs(in_bond), i_cause);
    eqn = sprintf("%s%s%s := %s;", LHS, SD, name, RHS);

    if !DEBUG
      comment = sprintf("%s PORT", CD);
      disp(sprintf("%s\n%s",comment, eqn));
    endif

  endif
  

  ## Handle special components
  if strcmp(comp_type,"0")||strcmp(comp_type,"1") # Junctions
    [eqn,insigs,innames] = junction_seqn (comp_type,Name, outsig, ...
					  insigs, innames);
  else				# Everything else
    if exist(sprintf("%s_cause", comp_type)) # Simple component
      ## Do the equations
      [eqn,insigs,innames] = eval(sprintf("%s_seqn (Name, name, cr, ...
						    arg, outsig, ...
						    insigs, ...
						    innames, is_port_output);", ...
					  comp_type));
      ## Resolve CR
      eqn = mtt_resolve_cr(eqn);

    else			# Compound component
      new_NAME = Name;
      new_Name = mtt_fullname(Name,name);
      new_name = "";
      
      ## Get relevant data structure
      Cbg = mtt_cbg(new_Name);
      port_name = Cbg.portlist(port,:);

      LHS = varname(Name, outsig(1,1), outsig(1,2));
      RHS = Sensor_seqn ("external",new_Name);
      eqn = sprintf("%s := %s%s%s;", LHS, RHS, SD, port_name);

      if DEBUG
	disp("----> same-level subsystem")
      endif

      [known] = mtt_component_eqn ...
   	  (mtt_fullname(new_Name,new_name), port, causality, known, cbg);
      
    endif
  endif

  comment = ...
      sprintf("%s Equation for %s signal on port %i of %s (%s), subsystem %s.", ...
     	      CD, causality, port, name, comp_type, Name);

  if DEBUG
    disp(sprintf("%s\n%s",comment, eqn));
  endif
  
  is_external = mtt_is_external(comp_type,outsig, insigs, is_port_output);

  if !is_external
    ## Find the corresponding input equations
    [N_other,M_other] = size(insigs);
    for i = 1:N_other
      if insigs(i,2)==1
	other_causality = "effort";
      else
	other_causality = "flow";
      endif

      other_port = insigs(i,3);
      other_name = deblank(innames(i,:));
      if DEBUG
	disp("----> same-level component")
      endif
      

      [known] = mtt_component_eqn ...
    	  (mtt_fullname(Name,other_name), other_port, other_causality, ...
	   known, cbg);
    endfor
  endif

  ## Write this signal
  ##comment_2 = sprintf("Connected to:%s", in_component_list);
  if !DEBUG
    disp(sprintf("%s\n%s",comment, eqn));
  endif

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_component_inputs.m version [6889a2a85b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [in_bonds,in_components,in_ports,N] = mtt_component_inputs ...
      (name,comp_type, out_causality, causality,comp_bonds,bond_list,cbg)

  ## usage:  [in_bonds,in_components,in_ports,N] = mtt_component_inputs 
  ##      (name,comp_type, out_causality, causality,comp_bonds,bond_list,cbg)
  ##
  ## 


  ## Other causality representations  if strcmp(causality,"effort")
  if strcmp(causality,"effort")
    i_cause = 1;
    othercausality = "flow";
    index_cause = 1;
  elseif strcmp(causality,"flow")
    i_cause = -1;
    othercausality = "effort";
    index_cause = 2;
  else
    error(sprintf("mtt_component_eqn: causality %s invalid", causality));
  endif
  
  in_index = find(comp_bonds(:,index_cause)==i_cause);
  all_in_bonds = bond_list(in_index);
  N_all = length(all_in_bonds);

  ## What components are at the other ends of the in bonds?
  [in_components,in_ports,in_bonds] = mtt_other_end (name,all_in_bonds,cbg);
  N = length(in_bonds);
endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_error.m version [85c51b0617].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mtt_error(message, errorfile);
% mtt_error(message, errorfile);

% function [bonds, status] = abg2cbg(bonds,components,system_name,filename)
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/12/03 16:21:27  peterg
% %% Initial revision
% %%
% %% Revision 1.2  1997/02/11 10:06:42  peterg
% %% Removed a debugging line.
% %%
% %% Revision 1.1  1996/08/18  20:06:57  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Set default file if it isn't there already
if nargin<2
  errorfile = fopen('mtt_error.txt','at');
end;

fprintf(errorfile, '*MTT ERROR : %s\n', message);

#error('MTT exiting this transformation on error');

Deleted mttroot/mtt/bin/trans/m/mtt_euler.m version [3653e4fcc1].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function [x] = mtt_euler(x,dx,dt,Nx,open) # Euler update
  I_open = nozeros(open.*[1:Nx]'); # Indices of open switches
  x(I_open) = 0.0;		# Open switches have zero state
  I = nozeros(!open.*[1:Nx]');	# Indices of states to update
  x(I) = x(I) + dx(I)*dt;	# Update states except open switches.
endfunction;

Deleted mttroot/mtt/bin/trans/m/mtt_fullname.m version [95049fcb51].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
function fullname = mtt_fullname (subname,compname)

  ## usage:  fullname = mtt_fullname (subname,compname)
  ##
  ## Finds the standard mtt name of the component

  delim = "__";
  fullname = sprintf("%s%s%s", subname, delim, compname);

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_identify.m version [21f7e88261].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [theta,Theta,Error,Y] = mtt_identify (system_name,y_s,theta_0,criterion,max_iterations)

  ## usage:  [theta,Theta,Error] = mtt_identify (system_name,theta_0,criterion,max_iterations)
  ##      y_s   actual system output
  ##      theta_0   initial parameter estimate
  ##      criterion convergence criterion
  ##      max_iterations limit to number of iterations

  if nargin<4
    criterion = 1e-5;
  endif
  
  if nargin <5
    max_iterations = 20;
  endif

  alpha = 1.0;
  e_last = 1e20;
  error=1e10;
  theta = theta_0;
  Theta = [];
  Error = [];
  Y = [];
  iterations = 0;
  while abs(e_last-error)>criterion
    theta
    iterations = iterations + 1;
    e_last = error;
    [t,y,y_theta] = mtt_ssimulate(system_name,theta); # Simulate system
    Theta = [Theta theta];	# Save parameters
    Y = [Y y];			# Save output
    E = (y - y_s);		# Error(t)
    error = (E'*E);			# Sum the error
    Error = [Error error];
    theta = theta - alpha*((y_theta'*y_theta)\(y_theta'*E));
  endwhile

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_implicit.m version [d63b98c98d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [x] = mtt_implicit(x,dx,AA,AAx,dt,Nx,open); 
  ## x = mtt_implicit(x,dx,AA,AAx,dt,Nx,open); 
  ## Implicit integration update

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.3  1999/04/20 06:14:53  peterg
  ## ## Reorder to make equivalent to .p version
  ## ##
  ## ## Revision 1.2  1999/04/20 00:58:22  peterg
  ## ## Set open-switch states to zero
  ## ##
  ## ## Revision 1.1  1999/04/02 06:23:20  peterg
  ## ## Initial revision
  ## ##
  ## ###############################################################

  ## Copyright (C) 1999 by P.J. Gawthrop

  I = nozeros(!open.*[1:Nx]');	# Indices of states to update
  x(I) = AA(I,I)\(AAx(I) + dx(I)*dt);	# Implicit update (except open switches);
  I_open = nozeros(open.*[1:Nx]'); # Indices of open switches
  x(I_open) = 0.0;		# Open switches have zero state

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_info.m version [5fc6fed510].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mtt_info(info, infofile);
  ## mtt_info(info, infofile);

  ## function [bonds, status] = abg2cbg(bonds,components,system_name,filename)
  ## 
  ##     ###################################### 
  ##     ##### Model Transformation Tools #####
  ##     ######################################

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.4  2003/03/24 12:18:00  gawthrop
  ## ## Default file when no second argument
  ## ##
  ## ## Revision 1.3  2000/11/12 17:10:51  peterg
  ## ## Close file if it is opened
  ## ## Reformated  octave style
  ## ##
  ## ## Revision 1.2  1997/02/11 10:06:42  peterg
  ## ## Removed a debugging line.
  ## ##
  ## ## Revision 1.1  1996/08/18  20:06:57  peter
  ## ## Initial revision
  ## ##
  ## ###############################################################

  ## Set default file if it isn't there already

  if nargin<2
    nofile = 1;
  elseif infofile<0
    nofile = 1;
  else
    nofile = 0;
  endif
  
  if nofile
    infofile = fopen("mtt_info.txt","at");
  end;

  fprintf(infofile, "INFORMATION: %s\n", info);

  if nofile
    fclose(infofile);
  end;

endfunction





Deleted mttroot/mtt/bin/trans/m/mtt_is_external.m version [5dcc4690eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function is_external = mtt_is_external (comp_type,outsig, insigs, is_port)

  ## usage:  is_external = mtt_is_external (comp_type,outsig, insigs, is_port)
  ##
  ## This is to determine if mtt_component_equation should look for
  ## another equation. If is_external, the varable is available as a
  ## system input and therfore requires no further equation.
  ## I suspect that it needs more work.


  if nargin<4
    is_port = 0;
  endif

  is_external = 0;			# Default

  if is_port
    is_external = 0;
  elseif strcmp(comp_type,"SS");
    is_external = insigs(1,2)!=outsig(2);
  else
    is_external = 0;
  endif

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_isunique.m version [6397cfa01f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function u = mtt_isunique(x);
% if all the elements of x are different, returns 1 else returns 0


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/18 19:38:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

n = length(x);
u=1

disp("--checking uniqueness --")
x
for i=1:n
  for j = 1:i-1
    if iscell(x)
      if x{i}==x{j}
	u = 0
	break;
      end;
    else
      if x(i)==x(j)
	u = 0
	break;
      end;
    end
  end;
end;

Deleted mttroot/mtt/bin/trans/m/mtt_name2names.m version [e20ba547b3].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
function names = mtt_name2names (name)

  ## usage:  names = mtt_name2names (name)
  ##
  ## Converts standard mtt name to an array of subsystem names

  ## Copyright (C) 2003 by Peter J. Gawthrop

  delim ="__";			# MTT delimiter
  names = char(strsplit(name,delim));

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_names2name.m version [569f4874eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = mtt_names2name (names)

  ## usage:  name = names2name (names)
  ##
  ## Converts array of subsystem names to a standard mtt name

  delim ="__";			# MTT delimiter

  [n,m] = size(names);
  name = deblank(names(1,:));

  for i = 2:n
    name = sprintf("%s%s%s", name, delim, deblank(names(i,:)));
  endfor

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_optimise.m version [261e38eb89].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [theta,Theta,Error,Y,iterations] = mtt_optimise (system_name,y_s,theta_0,method,free,weight,criterion,max_iterations,alpha,View)
  ## Usage: [theta,Theta,Error,Y,iterations] = mtt_optimise (system_name,y_s,theta_0,method,free,weight,criterion,max_iterations,alpha)
  ##  system_name     String containg system name
  ##  y_s   actual system output
  ##  theta_0   initial parameter estimate
  ##  free  Indices of the free parameters within theta_0
  ##  weight Weighting function - same dimension as y_s
  ##  method "time" or "freq"
  ##  criterion convergence criterion
  ##  max_iterations limit to number of iterations
  ##  alpha  Optimisation gain parameter

  ## Copyright (C) 1999 by Peter J. Gawthrop

  if nargin<4
    method="time";
  endif

  N = length(theta_0);
  if nargin<5
    free = [1:N];
  endif
  
  if nargin<6
    weight = ones(size(y_s));
  endif

  if nargin<7
    criterion = 1e-7;
  endif
  
  if nargin <8
    max_iterations = 25;
  endif

  if nargin<9
    alpha = 0.1;
  endif
  
  if nargin<10
    View = 0;
  endif
  
  if (!strcmp(method,"time"))&&(!strcmp(method,"freq"))
    error("method must be either time or freq")
  endif
  
  [n_data,n_y] = size(y_s);

  n_th = length(free);
  error_old = inf;
  error=1e50;
  theta = theta_0;
  Theta = [];
  Error = [];
  Y = [];
  iterations = 0;
  while (abs(error_old-error)>criterion)&&(abs(error)>criterion)&&(iterations<max_iterations)
    iterations = iterations + 1;
    error_old_old = error_old;
    error_old = error;
    eval(sprintf("[t,y,y_theta] = \
	mtt_s%s(system_name,theta,free);",method)); # Simulate system

    if View
      xlabel("");
      title(sprintf("mtt_optimise: Weighted actual and estimated Interation %i", iterations));
      plot(t,y.*weight,t,y_s.*weight);
    endif
    
    error = 0; 
    J = zeros(n_th,1);
    JJ = zeros(n_th,n_th);
    for i = 1:n_y
      E = weight(:,i).*(y(:,i) - y_s(:,i)); # Weighted error
      error = error + (E'*E);	# Sum the error

      Weight = weight(:,i)*ones(1,n_th); # Sensitivity weight
      y_theta_w = Weight.*y_theta(:,i:n_y:n_y*n_th); # Weighted sensitivity
      J  = J + real(y_theta_w'*E); # Jacobian
      JJ = JJ + real(y_theta_w'*y_theta_w); # Newton Euler approx Hessian
    endfor

    error
 
    if error<(error_old+criterion) # Save some diagnostics
      Error = [Error error];	# Save error
      Theta = [Theta theta];	# Save parameters
      Y = [Y y];		# Save output
    endif

    ## Update the estimate if we are not done yet.
    if (abs(error_old-error)>criterion)&&(abs(error)>criterion)&&(iterations<max_iterations)
      if error>(error_old+criterion) # Reduce step size and try again
        factor = 10;
	disp(sprintf("%2.2f*step",alpha));
	error = error_old;	# Go back to previous error value
	error_old = inf;	# Don't let it think its converged
	theta(free) = theta(free)  + step; # Reverse step
	step = alpha*step;	# new stepsize
      else			# Recompute step size
	tol = 1e-5;
	step =  pinv(JJ,tol)*J;	# Step size
	#step =  pinv(JJ)*J;	# Step size (built in tol)
      endif
      theta(free) = theta(free) - step; # Increment parameters
    endif
 ##   theta
  endwhile
endfunction


Deleted mttroot/mtt/bin/trans/m/mtt_other_causality.m version [1f9cfc8d6c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function other = mtt_other_causality (causality)

  ## usage:  other = mtt_other_causality (causality)
  ##
  ## 

  causality = deblank(causality);
  if strcmp(causality,"effort");
    other = "flow";
  elseif strcmp(causality,"flow");
    other = "effort";
  elseif strcmp(causality,"e");
    other = "f";
  elseif strcmp(causality,"f");
    other = "e";
  else
    error(sprintf("Causality \"%s\" not recognised",causality));
  endif
  

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_other_end.m version [dfe2387a77].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [in_components,in_ports,in_bonds] = mtt_other_end (name,all_in_bonds,cbg);

  ## usage:  [in_components,in_ports,in_bonds] = mtt_other_end (name,all_in_bonds,cbg);
  ##
  ## 

  ## What components are at the other ends of the in bonds?
  in_components = "";
  in_ports = [];
  in_bonds = [];
  in_direction = [];
  for i = 1:length(all_in_bonds);
    for [component_structure, component] = cbg.subsystems
      if !strcmp(name,component)
	other_connections = component_structure.connections;
	one = ones(size(other_connections));
	port = find(abs(all_in_bonds(i))*one==abs(other_connections));
	if (length(port)==1)
	  in_components = [in_components; component];
	  in_bonds = [in_bonds; all_in_bonds(i)];
	  in_ports = [in_ports; port];
	endif
      endif
    endfor
  endfor

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_resolve_cr.m version [bb4d4bdb2d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function eqn = mtt_resolve_cr (eqn)
  ## usage:  eqn = mtt_resolve_cr (eqn)


  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2003/03/24 12:20:28  gawthrop
  ## *** empty log message ***
  ##
  ## Revision 1.1  2003/03/24 10:19:42  gawthrop
  ## Documentation added
  ##
  ###############################################################

  ## Temporary version to resolve lin only!

  ## How many equations here?
  N = length(findstr(eqn,"="));
  EQNS = char(strsplit(eqn,";"));

  eqn = "";
  for i = 1:N
      
      ## Split equation
      EQN = char(strsplit(EQNS(i,:),":="));
      LHS = deblank(EQN(1,:));
      RHS = deblank(EQN(2,:));

      if index(RHS,"lin(")>0	# lin cr is here

      RHS = sprintf("%s;", RHS); # Put back ;

      ## Make function into a list
      RHS = strrep(RHS,"lin(","{lin,");
      RHS = strrep(RHS,");","}");

      ## Convert "R" to R etc
      RHS = strrep(RHS,"\"","");
      
      
      RHS = g_subs(RHS, "{{lin,$6,$3,$1,$5,1,$2,$3,1}}", "{$2*$1}");
      RHS = g_subs(RHS, "{{lin,$6,$3,$1,$5,1,$2,$4,1}}", "{$2/$1}");
    endif

    eqn_i = sprintf("%s := %s;", LHS, RHS);
    eqn = sprintf("%s %s", eqn, eqn_i);
  endfor

endfunction
    

Deleted mttroot/mtt/bin/trans/m/mtt_save_alias.m version [d6d06732d5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mtt_save_alias (arg,system_name)

  ## usage:  mtt_save_alias (arg,system_name,FileID)
  ##
  ##
  ##     ###################################### 
  ##     #### Model  Transformation Tools #####
  ##     ######################################

  ## ############################################################### 
  ## Version
  ## control history
  ## ############################################################### ## $Id:
  ## mtt_info.m,v 1.2 1997/02/11 10:06:42 peterg Exp peterg $ ## $Log:
  ## mtt_info.m,v $ ## Revision 1.2  1997/02/11 10:06:42  peterg ##
  ## ###############################################################

  fileid = fopen('mtt_aliased.txt','at');
  fprintf(fileid, "%s\t%s\n", arg,system_name);
  fclose(fileid);
endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_sfreq.m version [22eb1c42b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [w,y,y_theta] = mtt_sfreq(system_name,theta,free);
  ## usage: [w,y,y_theta] = mtt_sfreq(system_name,theta,free);
  ##
  ## Frequency response with name system_name and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## y_theta contains the corresponding sensitivity functions
  ## Assumes system generated by the sBG approach
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Assumes SISO system 

  global mtt_n_parameters mtt_parameters # Global "argc argv"
  global mtt_w # Frequencies (if not specified in simpar file
 N = length(theta);

  eval(sprintf("[nx,ny,nu,nz,nyz] = %s_def;", system_name));
  if nargin<3
    free = 1;
  endif
  
  y_theta = [];

  if length(free)==0
    free=1;			# Make the loop happen once to get y and X
  endif
  
  [n,m]  = size(free);
  if m==1
    free = free';
  endif
  
  
  eval(sprintf("%s_simpar;", system_name)); # Read the "simulation"
					    # parameters
  if exist("mttwmin")		# Compute frequency range
    w = logspace(mttwmin,mttwmax,mttwsteps)'; # Frequency range
  else				# use global mtt_w
    w = mtt_w;
  endif
  
  y_theta = [];
  mtt_n_parameters = 1+N;
  mtt_parameters(2:1+N) = theta; # The actual parameters
  for i = free
    mtt_parameters(1) = i; # Select wich sens. function
    eval(sprintf("%s_numpar;", system_name)); # Read the parameters
    eval(sprintf("[A,B,C,D,E] = %s_dm;", system_name)); # Evaluate the
				# descriptor matrices
    fr = dm2fr(A,B,C,D,E,w);
    y_theta = [y_theta fr(:,2)]; # Sensitivity frequency response
  endfor

  y = fr(:,1);			# Actual frequency response
  
  
endfunction



Deleted mttroot/mtt/bin/trans/m/mtt_simulate.m version [cbe0b154db].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [t,y,y_theta] = mtt_simulate(system_name,theta);
  ## usage: [t,y,y_theta] = mtt_simulate(r);
  ##
  ## Simulate system with name system and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Simulate using mtt-generated function
  y_theta = [];
   for i=1:length(theta)
     args="";
     for j=1:length(theta)
       i_sensitivity=(j==i);
       args = sprintf("%s%i %g ",args, i_sensitivity, theta(j));
     endfor

     command = sprintf("./%s_ode2odes.out %s > mtt_data.dat\n", system_name, args);
     system(command);

     ## Retrieve data
     load -force mtt_data.dat
     t = mtt_data(:,1);
     y = mtt_data(:,2);
     y_theta = [y_theta mtt_data(:,3)];
   endfor

endfunction



Deleted mttroot/mtt/bin/trans/m/mtt_ssimulate.m version [5b7c3603ee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [t,y,y_theta] = mtt_ssimulate(system_name,theta);
  ## usage: [t,y,y_theta] = mtt_ssimulate(system_name,theta);
  ##
  ## Simulate system with name system_name and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## y_theta contains the corresponding sensitivity functions
  ## Assumes system generated by the sBG approach
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Simulate using mtt-generated function
  y_theta = [];
   for i=1:length(theta)
     args="";
     for j=1:length(theta)
       i_sensitivity=(j==i);
       args = sprintf("%s%i %g ",args, i_sensitivity, theta(j));
     endfor

     command = sprintf("./%s_ode2odes.out %s > mtt_data.dat\n", system_name, args);
     system(command);

     ## Retrieve data
     load -force mtt_data.dat
     t = mtt_data(:,1);
     y = mtt_data(:,2);
     y_theta = [y_theta mtt_data(:,3)];
   endfor

endfunction



Deleted mttroot/mtt/bin/trans/m/mtt_stime.m version [588e121a7c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [t,y,y_theta,x,x_last] = mtt_stime(system_name,theta,free);
  ## usage: [t,y,y_theta,x,x_last] = mtt_stime(system_name,theta);
  ##
  ## Simulate system with name system_name and parameter vector theta
  ## The order of components in theta is determined in system_numpar.txt:
  ## y_theta contains the corresponding sensitivity functions
  ## Assumes system generated by the sBG approach
  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## 	$Id$	

  ## Simulate using mtt-generated function

  N = length(theta);

  eval(sprintf("[nx,ny,nu,nz,nyz] = %s_def;", system_name));
  if nargin<3
    free = 1;
  endif
  
  y_theta = [];

  if length(free)==0
    free=1;			# Make the loop happen once to get y and X
  endif
  
  [n,m]  = size(free);
  if m==1
    free = free';
  endif
  
  for i=free
    args=sprintf("%i",i);
    for j=1:length(theta)
      args = sprintf("%s %g",args, theta(j));
    endfor

    ## Run system and replace NaN by 1e30 -- easier to handle
    file_name = sprintf("%s_input.dat", system_name);
    if exist(file_name)==2	# Then use data from this file ...
      command = sprintf("./%s_ode2odes.out %s < %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", ...
			system_name, args, file_name);
    else
      command = sprintf("./%s_ode2odes.out %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", ...
			system_name, args);
    endif
      
   system(command);

    ## Retrieve out_data
    load -force mtt_out_data.dat
    y_theta = [y_theta mtt_out_data(:,3:2:1+ny)];
  endfor

  ## System out_data
  [n,m]=size(mtt_out_data);
  t = mtt_out_data(:,1);
  y = mtt_out_data(:,2:2:ny);
  x = mtt_out_data(:,3+ny:m);
  x_last = mtt_out_data(n,3+ny:m);
endfunction



Deleted mttroot/mtt/bin/trans/m/mtt_strip_name.m version [04fb8c767f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function stripped_name = mtt_strip_name (name)

  ## usage:  stripped_name = mtt_strip_name (name)
  ##
  ## Removes blanks and [] from a port name

  if (length(name)==0)
    error("Zero length port name found");
  endif


  [N,M] = size(name)
  if N>1
    error("Cannot resolve port names: redraw abg.fig");
  endif
  
  
  stripped_name = deblank(name); # remove blanks
  stripped_name = stripped_name(2:length(stripped_name)-1);
  stripped_name = deblank(stripped_name); # remove blanks

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_subname.m version [653459832d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [subname, compname] = mtt_subname (name)

  ## usage:  subname = mtt_subname (name)
  ##
  ## Finds the subsystem name from the component name
  ## Copyright (C) 2003 by Peter J. Gawthrop


  names = mtt_name2names(name);
  [n,m] = size(names);

  if n<2			# Simple name
    subname = "";
    compname = name;
  else				# Compound name
    subname = mtt_names2name(names(1:n-1,:));
    compname = deblank(names(n,:));
  endif

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_type_name.m version [6cb1565552].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function NewType = mtt_type_name (OldType)

  ## usage:  NewType = mtt_type_name (OldType)
  ##
  ## 

  if OldType=="0";
    NewType = "Zero";
  elseif OldType=="1";
    NewType = "One";
  else
    NewType = OldType;
  endif

endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_update.m version [27453a1721].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
function [x] = mtt_update(dx,x,dt,STEPFACTOR,METHOD,name);

  if (METHOD==1)		#Euler
    ddt = dt/STEPFACTOR;
    x = x + dx*ddt;
  elseif (METHOD==2)		#Linear implicit or Implicit
    eval("[AA,AAx] = ",name,"_smx;");
    x = AA\(AAx + dx*dt);
  else
    error("Method %i is not defined", METHOD);
  endif;

endfunction;

Deleted mttroot/mtt/bin/trans/m/mtt_write.m version [72eb26e77f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mtt_write(t,x,y,nx,ny,first);

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2002/05/13 08:52:23  gawthrop
## FIRST parameter of simpar now specifies first printed point -
## simulation still starts at zero
##
## Revision 1.5  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.4  1999/03/15 23:05:29  peterg
## A complete rewrite - now puts into a Global matrix MTT_data
##
## Revision 1.3  1999/03/15 21:57:00  peterg
## Removed the # symbol
##
###############################################################

global MTT_data
  if (t==0.0)
    MTT_data=[];
  endif

  if (t>= first)
    MTT_data = [MTT_data; t,y(:)',t,x(:)'];
  endif
  
endfunction

Deleted mttroot/mtt/bin/trans/m/mtt_zeroswitches.m version [ac6908b24d].

1
2
3
4




-
-
-
-
function [x] = mtt_zeroswitches(x,Nx,open)
  I_open = nozeros(open.*[1:Nx]'); # Indices of open switches
  x(I_open) = 0.0;		   # Open switches have zero states
endfunction;

Deleted mttroot/mtt/bin/trans/m/name_in_list.m version [d44d5cda78].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function index = name_in_list(name,list)

% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  name_in_list.m
% Finds name in list and returns index -- zero if not found


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/23 09:22:05  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[N,M] = size(list);
if N<1
  error('list must have at least one element');
end;

index = 0;

for i = 1:N
 j = findstr(name,list(i,:));
 if (length(j)==1)
    if j(1)==1
      if index==0
        index = i;
      else 
        index = [index i];
      end
    end
 end;
end;

Deleted mttroot/mtt/bin/trans/m/nozeros.m version [e7ac91823e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function v = nozeros (v0,tol)

  ## usage:  v = nozeros (v0,tol)
  ##
  ## Zaps the zeros in a vector with tolerance tol (defaults to zero)

  ## Copyright (C) 2000 by Peter J. Gawthrop

  if nargin<2
    tol=eps;
  endif
  
  
  v = [];
  j=0;
  for i = 1:length(v0)
    if abs(v0(i))>tol
      j=j+1;
      v(1,j) = v0(i);
    end;
  end;
  

endfunction

Deleted mttroot/mtt/bin/trans/m/pol2root2tex.m version [f78af4d947].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function tex = pol2root2tex(pol,name,f)
  ## pol2tex: converts polynomial into LaTeX form as (s-z_1)..(s-z_n)
  ## tex = pol2root2tex(pol,[name,f])
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/05/10 19:08:35  gawthrop
  ## Cosmetic improvements
  ##
  ## Revision 1.1  2001/05/10 11:44:40  gawthrop
  ## Useful conversion functions
  ##
  ## Revision 1.1  1999/05/24 22:05:53  peterg
  ## Initial revision
  ##
  ###############################################################

  if nargin<2
    name = "s"
  endif
  
  if nargin<3
    f = "%2.2f";
  endif

  n = length(pol)-1;

  if n>0
    r = sort(roots(pol));
  endif
  
  gain = pol(1);

  complex=0;
  if ((gain==1)&&(n>0))
    tex="";
  else
    tex = sprintf("%g", gain);
  endif
  
  for i=1:n
    if real(r(i))<0
      r_plusminus = '+';
    else
      r_plusminus = '-';
    endif
    if imag(r(i))<0
      i_plusminus = '+';
    else
      i_plusminus = '-';
    endif

    if complex
      complex=0;
    else
      if abs(imag(r(i)))<1e-5
	ff = sprintf("%%s (%s %%s %s)",name, f);
	tex = sprintf(ff, tex, r_plusminus, abs(r(i)));
      else
	ff = sprintf("%%s (%s %%s %s \\pm j %s)", name, f, f);
	tex = sprintf(ff, tex, r_plusminus, abs(real(r(i))), imag(r(i)));
	complex=1;
      endif
    endif
  endfor
  
endfunction



Deleted mttroot/mtt/bin/trans/m/pol2tex.m version [20e8117d85].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function tex = pol2tex(pol,name,f)
  ## pol2tex: converts polynomial into LaTeX form.
  ## tex = pol2tex(pol,[name,f])
  
  ## pol  polynomial (row vector)
  ## name name of the variable (eg s or z)
  ## f    format of the coefficients (eg %2.4f)

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.3  2001/07/11 03:58:41  gawthrop
  ## removed {}
  ##
  ## Revision 1.2  2001/05/10 19:08:35  gawthrop
  ## Cosmetic improvements
  ##
  ## Revision 1.1  2001/05/10 11:44:40  gawthrop
  ## Useful conversion functions
  ##
  ## Revision 1.1  1999/03/25 01:33:51  peterg
  ## Initial revision
  ##
  ###############################################################

  if nargin<2
    name = "s";
  endif
  
  if nargin<3
    f = "%2.2f";
  endif
  
  n = length(pol);
  if n<1
    tex = "--";
    return
  endif

  if pol(1) == 1
    if n>1
      tex = '';
    else
      tex = '1';
    endif
  else
    ff = sprintf(" %s",f);
    tex = sprintf(ff, pol(1));
  endif
  
  if n>2
    tex = sprintf("%s%s^%i", tex, name, n-1);
  elseif n==2
    tex = sprintf("%s%s", tex, name);
  else
    tex = sprintf("%s", tex);
  endif

  for i=2:n
    if pol(i)<0
      plusminus = '-';
    else
      plusminus = '+';
    endif
    ff = sprintf("%%s %%s %s",f);
    tex = sprintf(ff, tex, plusminus, abs(pol(i)));
    if i<n-1
      tex = sprintf("%s%s^%i", tex, name, n-i);
    elseif i==n-1
      tex = sprintf("%s%s", tex, name); 
    else
      tex = sprintf("%s", tex);
    endif
  endfor
endfunction



Deleted mttroot/mtt/bin/trans/m/pow.m version [0360ed3c86].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
function z = pow (x,y)

  ## usage:  z = pow (x,y)
  ##
  ## Computes z = x^y

  z = x^y;

endfunction

Deleted mttroot/mtt/bin/trans/m/printcr.m version [33c745664a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  printcr(name,outport,bond_number,cr,args,RHS_cause,eqnfile)
## printcr - prints cr and arguments
## Assumes that the (multiport) component is unicausal.
## 
##     ###################################### 
##     ##### Model Transformation Tools #####
##     ######################################
## 
## Octave function  printcr
## printcr(name,outport,bond_number,cr,args,RHS_cause,eqnfile


## ###############################################################
## ## Version control history
## ###############################################################
## ## $Id$
## ## $Log$
## ## Revision 1.2  2003/01/07 09:11:53  gawthrop
## ## Octavised
## ##
## ## Revision 1.1  1998/07/25 09:47:43  peterg
## ## Initial revision
## ##
## ###############################################################



  if nargin<7
    eqnfile = "stdout";
  endif

  ## Find the number of ports
  ports = length(RHS_cause);

  ## Print the CR
  if length(cr) == 0 # No CR given - use unity CR
    fprintf(eqnfile, "%s;\n", varname(name,bond_number(outport), ...
				      RHS_cause(outport)));
  else # CR exists
    fprintf(eqnfile, "%s(%s", cr, name); # The CR name and component type
    if ports>1 # Multi ports - port no. is first arg of CR
      fprintf(eqnfile, "#1.0f,", outport);
    endif
    fprintf(eqnfile, "%s", args); # Print the arguments
    for port = 1:ports # Print the input causalities and values
      fprintf(eqnfile, "\n\t\t,%s,%s", cause2name(RHS_cause(port)), ...
	      varname(name,bond_number(port), RHS_cause(port)));
    endif
    fprintf(eqnfile, "\n\t\t);\n");
  endif
endfunction


Deleted mttroot/mtt/bin/trans/m/psfig.m version [e433f0a0b8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function psfig(filename)
  ## Usage: psfig(filename)
  ## Puts figure into ps file

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  1999/11/30 23:26:21  peterg
  ## Initial revision
  ##
  ## Revision 1.3  1999/09/04 02:23:30  peterg
  ## Removed mv stuff - now uses gset on actual file
  ##
  ## Revision 1.2  1999/06/15 02:05:44  peterg
  ## Now adds a .ps if not there already
  ##
  ## Revision 1.1  1999/03/25 01:35:00  peterg
  ## Initial revision
  ##
  ###############################################################

  ## Add .ps if not there already
  if !index(filename,".")	# Is there a .
    filename = sprintf("%s.ps",filename);
  endif
  
  eval(sprintf("gset output \"%s\" ",filename));
  gset linestyle 1 lw 4		# Thicker lines
  gset linestyle 2 lw 4		# Thicker lines
  gset linestyle 3 lw 4		# Thicker lines
  gset linestyle 4 lw 4		# Thicker lines
  gset linestyle 5 lw 4		# Thicker lines


  gset term postscript eps 
  replot;
  gset term x11
  gset output 
  replot;

endfunction

Deleted mttroot/mtt/bin/trans/m/rbg2abg.m version [19a07974ce].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692




















































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents, ...
				      port_coord,port_name, ...
				      infofile,errorfile)

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.51  2012/10/15 19:22:44  geraint
  ## ## mtt_isunique replaces unique which masks a built-in function.
  ## ##
  ## ## Revision 1.50  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.49  2004/07/22 13:18:02  geraint
  ## ## Minor typo in error message.
  ## ##
  ## ## Revision 1.48  2004/02/19 18:27:47  geraint
  ## ## [ 852694 ] octave 2.1.52 breaks rbg2abg
  ## ##
  ## ## Octave now prefers row vectors to column vectors.
  ## ##
  ## ## Revision 1.47  2002/08/27 16:09:01  geraint
  ## ## Added port_name to error message when multiple bonds are near a port.
  ## ##
  ## ## Revision 1.46  2000/09/11 08:22:02  peterg
  ## ## Checks for absent port list in subsystem abg file.
  ## ##
  ## ## Revision 1.45  1999/10/19 02:13:31  peterg
  ## ## Now assigns correct bonds to the new junction port names
  ## ##
  ## ## Revision 1.44  1999/10/19 00:05:44  peterg
  ## ## Now defaults junction ports when only one specified (for vector junctions)
  ## ##
  ## ## Revision 1.43  1999/10/18 04:08:46  peterg
  ## ## Now computes n_vector_bonds -- number apparent (maybe vector) bonds per component.
  ## ## Neeeded to vectorise junctions.
  ## ##
  ## ## Revision 1.42  1999/08/25 21:45:03  peterg
  ## ## Spurious start to vector 0 and 1
  ## ##
  ## ## Revision 1.41  1999/08/19 21:12:33  peterg
  ## ## Tidied and started implementaation of vector junctions
  ## ##
  ## ## Revision 1.40  1999/08/19 05:39:55  peterg
  ## ## Put into octave format
  ## ##
  ## ## Revision 1.39  1999/08/19 05:22:16  peterg
  ## ## To RCS prior to inplementing vector junctions
  ## ##
  ## ## Revision 1.38  1999/03/12 00:58:06  peterg
  ## ## Now gets portlist from the _abg.m file NOT the _rbg.m file
  ## ## - this allows expansion of vector SS ports.
  ## ##
  ## ## Revision 1.37  1998/07/28 19:06:43  peterg
  ## ## Still some bugs (vector SS ports)??
  ## ##
  ## ## Revision 1.36  1998/07/28 10:30:50  peterg
  ## ## Implemented vector SS ports.
  ## ##
  ## ## Revision 1.35  1998/07/08 15:35:15  peterg
  ## ## Added errorfile argument
  ## ##
  ## ## Revision 1.34  1998/07/02 19:41:29  peterg
  ## ## Fixed empty port string bug - set to null string.
  ## ##
  ## ## Revision 1.33  1998/07/02 17:16:06  peterg
  ## ## Commented out redundent code -- obsolete due to new default mechanism
  ## ##
  ## ## Revision 1.32  1998/07/02 15:12:05  peterg
  ## ## Added hard error reporting
  ## ## Added error when two unlabled bonds point in.
  ## ##
  ## ## Revision 1.31  1998/07/02 14:30:50  peterg
  ## ## Corrected various bugs - including resettting n_ports to correct value
  ## ##
  ## ## Revision 1.30  1998/07/02 13:40:50  peterg
  ## ## Added extra ports names (due to defaults) to relevant lists:
  ## ## 	port_name
  ## ## 	port_bond
  ## ##
  ## ## Revision 1.29  1998/07/02 13:28:31  peterg
  ## ## Added defaults in new form BEFORE alias expansion
  ## ##
  ## ## Revision 1.28  1998/07/02 12:36:05  peterg
  ## ## Removed debugging lines
  ## ##
  ## ## Revision 1.27  1998/07/02 12:24:02  peterg
  ## ## Expand port aliases
  ## ##
  ## ## Revision 1.26  1998/04/16 14:07:51  peterg
  ## ## Sorted out [] problem with vector ports -- new octave function
  ## ## split_port
  ## ##
  ## ## Revision 1.25  1998/04/12 15:01:04  peterg
  ## ## Converted to uniform port notation - always use []
  ## ##
  ## ## Revision 1.24  1998/02/19 08:57:16  peterg
  ## ## Fixed mtt-info bug -- confused filename with number
  ## ##
  ## ## Revision 1.23  1997/12/04 14:24:22  peterg
  ## ## Removed error message about through-pointing arrows
  ## ##
  ## ## Revision 1.22  1997/09/18 19:49:37  peterg
  ## ## Added test for uniquness of bonds on a component -- if non-unique
  ## ## implies same component at both ends of a bond.
  ## ##
  ## ## Revision 1.21  1997/09/16  15:14:14  peterg
  ## ## Added warning if a component has no bonds.
  ## ##
  ## ## Revision 1.20  1997/08/18  19:39:48  peterg
  ## ## Now generates (exampaded) port_bond list correctely
  ## ##
  ## ## Revision 1.19  1997/08/14  11:59:47  peterg
  ## ## Vector ports added!!
  ## ##
  ## ## Revision 1.18  1997/08/14  11:01:42  peterg
  ## ## Reordered algorithms as follows:
  ## ## bond end coordinates
  ## ## associate port labels with bonds (port_bond)
  ## ## associate bonds with components
  ## ## unsorted list of bonds on each component (components)
  ## ## interpret strokes and setup the causality of the bonds (bonds)
  ## ## expand vector ports & add new bonds and connections
  ## ## sort bonds on each component according to the labels -- two ports
  ## ## default included here.
  ## ##
  ## ## Revision 1.17  1997/08/09 11:31:16  peterg
  ## ## Default two port list is [in;out] (or [out;in])
  ## ## Dont do global default if no ports labels.
  ## ##
  ## ## Revision 1.16  1997/08/07  16:12:36  peterg
  ## ## Fixed sorting bug: now puts the jth component from the unsorted list
  ## ## into the kth component of the sorted list .. not vice versa!
  ## ##
  ## ## Revision 1.15  1997/08/06  21:43:19  peterg
  ## ## Corrected error in creating component list: the kth component of the
  ## ## list is given by the jth component of the original list NOT vice
  ## ## versa.
  ## ##
  ## ## Revision 1.14  1997/08/04 14:18:55  peterg
  ## ## If no ports labels at all, just use the default component list.
  ## ##
  ## ## Revision 1.13  1997/08/04 12:50:39  peterg
  ## ## Many bug fixes to the named port version + tied up the logic and
  ## ## supporting comments.
  ## ##
  ## ## Revision 1.12  1997/08/02 19:37:53  peterg
  ## ## Now uses named ports.
  ## ##
  ## ## Revision 1.11  1997/04/29 09:12:37  peterg
  ## ## Added error message if port label near to >1 bond.
  ## ##
  ## ## Revision 1.10  1997/03/17  13:45:42  peterg
  ## ## Added more error info.
  ## ##
  ## ## Revision 1.9  1996/12/31  11:25:57  peterg
  ## ## Clearer error messages for incorrect ports.
  ## ##
  ## ## Revision 1.8  1996/12/04 21:52:39  peterg
  ## ## Now uses fopen.
  ## ##
  ## ## Revision 1.7  1996/11/01 18:01:57  peterg
  ## ## Rationalised port ordering.
  ## ## Fixed port bug.
  ## ##
  ## ## Revision 1.6  1996/08/25 08:27:14  peter
  ## ## Now checks ports correctely - I hope.
  ## ##
  ## ## Revision 1.5  1996/08/24 19:21:26  peter
  ## ## More specific error messages.
  ## ##
  ## ## Revision 1.4  1996/08/24 18:00:33  peter
  ## ## Fixed bug with finding ports.
  ## ##
  ## ## Revision 1.3  1996/08/09 08:26:35  peter
  ## ## Cosmetic tidy up.
  ## ##
  ## ## Revision 1.2  1996/08/04 18:37:57  peter
  ## ## Fixed  no causal strokes bug.
  ## ##
  ## ## Revision 1.1  1996/08/04 18:30:14  peter
  ## ## Initial revision
  ## ##
  ## ###############################################################


  ##Default to no components
  components = [0];

  ## Xfig scaling factor
  scale = 1200.0/2.54546;

  ## Rotation matrix
  rot = [0 -1; 1 0];

  ## Find number of strokes
  [n_strokes,columns] = size(rstrokes);
  if (columns ~= 4)&(n_strokes>0)
    error('Incorrect rstrokes matrix: must have 4 columns');
  endif


  ## Find number of bonds
  [n_bonds,columns] = size(rbonds);
  if (columns ~= 6)&(n_bonds>0)
    error('Incorrect rbonds matrix: must have 6 columns');
  endif


  ## Find number of components
  [n_components,columns] = size(rcomponents);

  ## Find the number of ports refered to within the component
  [n_ports,columns] = size(port_coord)

  ## If port_name is empty, make it a empty string
  if (length(port_name)==0)
    port_name="";
  endif


  ## Determine coordinates of the arrow end of the bond and the other end
  other_end_1 = rbonds(:,1:2);
  arrow_end   = rbonds(:,3:4);
  other_end_2 = rbonds(:,5:6);

  distance_1   = length2d(other_end_1 - arrow_end);
  distance_2   = length2d(other_end_2 - arrow_end);
  which_end    = (distance_1>distance_2)*[1 1];
  one          = ones(size(which_end));
  other_end    = which_end.*other_end_1 + (one-which_end).*other_end_2;
  arrow_vector = ( which_end.*other_end_2 + (one-which_end).*other_end_1 ) - ...
      arrow_end;
  
  ## Locate the bond end nearest to each port
  ## col 1 of port_near_bond contains a signed bond number (+ for arrow end)
  ## col 2  of port_near_bond contains the corresponding port index
  port_bond = [];
  for i = 1:n_ports
    near_bond = adjbond(port_coord(i,1:2),arrow_end,other_end);
    [rows,cols]=size(near_bond);
    if rows>1
      error(sprintf ...
	    ("A port is near to more than one bond at coordinates %g,%g %s\n", ...
	     port_coord(i,1)/scale,  port_coord(i,2)/scale, deblank(port_name(i,:))));
    endif
    

    ##The (signed) bond corresponding to the ith port label
    port_bond(i,1) = near_bond(1)*sign(1.5-near_bond(2));
  endfor

  port_bond
  ##We now have the (signed) bond (port_bond(i)) correponding to the
  ## ith port label within the component 

  ## Locate the components at the ends of each bond
  ## col 1 of comp_near_bond contain the component nearest to the arrow end
  ## col 2 of comp_near_bond contain the component nearest to the other end
  for i = 1:n_bonds
    comp_near_bond(i,:) = adjcomp(arrow_end(i,:),other_end(i,:),rcomponents);
  endfor

  comp_near_bond
  ## We now have a list (comp_near_bond) of the component(s) at each end
  ## of each bond

  ## Now do a list of the bonds on each component - unsorted at this stage.
  ## Also expand aliases using the alias list for each component
  components = []; 
  i_vector=0;			# Counter for vector components
  for i = 1:n_components
    ##Get component type
    eval(['[comp_type, comp_name] = ', name, '_cmp(i)']);

    
    ## There are n_comp_bonds bonds on this component with corresponding index
    [index,n_comp_bonds] = getindex(comp_near_bond,i);

    if index(1,1)==0
      mtt_error(sprintf("Component %s (%s) has no bonds", comp_name,
			comp_type),errorfile);
    endif
    
    
    ## Create the signed list of bonds on this component
    one = ones(n_comp_bonds,1);
    bond_list = index(:,1); %  bond at component
    
    ## Check that all bonds are unique -- error if not
    if mtt_isunique(bond_list)==0
      mtt_error(sprintf("Component %s (%s) is at both ends of a bond", comp_name,
			comp_type),errorfile);
    endif
    
    

    ## which end of bond at component?
    bond_end = index(:,2); 
    direction = -sign(bond_end-1.5*one);
    signed_bond_list = bond_list.*direction;
    components = add_bond(components,signed_bond_list',i);
    
    ## Unalias and/or default all the ports on this componen
    unlabelled_ports = 0;  
    in_bonds = 0;
    out_bonds = 0;
    if ((comp_type=="0")||(comp_type=="1")) # A junction
      disp("---- default junctions ---- ");
      junction_names = 0;
      for j=1:n_comp_bonds
	port_name_index = getindex(port_bond,signed_bond_list(j));
	if port_name_index>0
	  junction_port_name = port_name(port_name_index,:);
	  named_bond_index = j;
	  junction_names++;
	endif
      endfor
      if junction_names==1	# one named port
	mtt_info(sprintf("Defaulting all ports on junction %s to %s", comp_name, junction_port_name));
	## Make the other n-1 names the same.
	junction_port_name = mtt_strip_name(junction_port_name);
	for j=1:n_comp_bonds;
	  if j!=named_bond_index
	    port_name = [port_name; ["[" junction_port_name "]"]]; # add to list
	    [port_name_index,junk] = size(port_name); # the corresponding index
	    port_bond(port_name_index,:) = signed_bond_list(j); # add to port bond
	  endif
	endfor
      elseif (junction_names!=0)&&(junction_names!=n_comp_bonds) # not allowed
	mtt_error(sprintf("Junction %s must have 0, 1 or %i port labels", comp_name,n_comp_bonds),errorfile);
      endif
      port_name = port_name
    else			# Not a junction
      for j=1:n_comp_bonds
	signed_bond = signed_bond_list(j);
	port_name_index = getindex(port_bond,signed_bond);
	port_direction = sign(signed_bond);
	
	if port_name_index==0	# There is no port on this bond - so try
				# to default
	  unlabelled_ports++;
	  if(unlabelled_ports==1)
	    if port_direction>0
	      in_bonds++;
	      port_name_i = "in";
	    else
	      out_bonds++;
	      port_name_i = "out";
	    endif
	    
	  elseif (unlabelled_ports==2)
	    if port_direction>0
	      if (++in_bonds>1)
		mtt_error(["More than one unlabelled INport on component " ...
			   comp_name " (" comp_type ")"],errorfile);
	      else
		port_name_i = "in";
	      end
	    else
	      if (++out_bonds>1)
		mtt_error(["More than one unlabelled OUTport on component " ...
			   comp_name " (" comp_type ")"],errorfile);
	      else
		port_name_i = "out";
	      end
	    endif
	    
	  else
	    mtt_error(["More than two unlabelled ports on component " ...
		       comp_name " (" comp_type ")"],errorfile);
          endif
	  
	  mtt_info(["Defaulting port name [" port_name_i "]\t on component " ...
		    comp_name " (" comp_type ")" ],infofile);
	  port_name = [port_name; ["[" port_name_i "]"]];	# add to list
	  [port_name_index,junk] = size(port_name); # the corresponding
				# index
	  port_bond(port_name_index,:) = signed_bond; # add to port bond
	else  
	  port_name_i = mtt_strip_name(port_name(port_name_index,:))
	  ## port_name_i = deblank(port_name(port_name_index,:));
	  ## port_name_i = port_name_i(2:length(port_name_i)-1) # strip []
	endif
	
	
	## Replace by alias -- if any
    	eval( ["alias = ", comp_type, '_alias';]); # Get aliases
    	if isstruct(alias)		# are there any aliases
          if isfield(alias,port_name_i) # Is this an alias?
	    eval(["new_port_name_i = alias.",port_name_i]);
	    mtt_info(["Aliasing name [" port_name_i "]\t on component " ...
		      comp_name " (" comp_type ")\t to [" new_port_name_i "]"],infofile);
	    port_name = replace_name(port_name, ...
				     ["[",new_port_name_i,"]"], ...
				     port_name_index);
	  endif
	  
      	endif
	
      endfor
      
    endif
    
  endfor
  
  ## At this point, every port should be labeled (port_name) and ...
  ## associated with a bond (port_bond).
  disp("--- Completed portnames and the corresponding bonds ---")
  port_name, port_bond


  ## Deduce causality from the strokes (if any) and create the list of bonds
  causality = zeros(n_bonds,2);
  if n_strokes>0
    ## Find out location of centre and ends of stroke.
    stroke_end_1 = [rstrokes(:,1) rstrokes(:,2)];
    stroke_end_2 = [rstrokes(:,3) rstrokes(:,4)];
    
    stroke_centre = (stroke_end_1 + stroke_end_2)/2;
    stroke_vector = (stroke_end_1 - stroke_end_2);
    stroke_length = length2d(stroke_vector);

    ## Deduce bond causality from the strokes 
    for i = 1:n_strokes
      stroke = [stroke_centre(i,:) 
		stroke_end_1(i,:)
		stroke_end_2(i,:)];


      ## Find the nearest bond end.
      [index,distance] = adjbond(stroke(1,:),arrow_end,other_end);
      if (distance>2*stroke_length(i))
	info = sprintf('Stroke at (%4.3f,%4.3f) is %4.3f away from the nearest bond\n', ...
		       stroke(1,1)/scale, stroke(1,2)/scale, distance/scale);
      endif
      
      
      ## Bond end coordinates
      j = index(1,1);
      which_end = index(1,2)==1;
      bond_end = arrow_end(j,:)*which_end + other_end(j,:)*(1-which_end);
      
      ## Now decide which bit of the stroke is nearest
      stroke_index = adjbond(bond_end,stroke,zeros(size(stroke)));
      
      if stroke_index(1)==1 ## uni-causal stroke
	causality(j,1:2) = (2*which_end-1)*[1 1];
      else ## bicausal stroke
	## Find out whether stroke is on flow side of bond
	stroke_direction = stroke(1,:) - stroke(stroke_index(1),:);
	flow_side = stroke_direction*arrow_vector(j,:)'>0;
	causality(j,1+flow_side) = 2*which_end-1;
      endif
      
    endfor
    
  endif


  bonds = causality;


  ## Find number of bonds on each component BEFORE vectorisation
  for i=1:n_components
    n_vector_bonds(i,1) = length(nozeros(components(i,:)))
  endfor
  
  ## Now expand vector ports
  disp("Expanding vector ports");
  [n_bonds,junk] = size(bonds);
  n_ports = length(port_bond);
  n_exp_ports=n_ports;
  exp_port_name="";
  exp_port_bond = [];
  ##exp_comps = [];
  for i=1:n_ports
    port_name_i = port_name(i,:)
    [subport,n_subports] = split_port(port_name_i, ','); ## Find the components of the vector port

    if n_subports==1 ## an ordinary port
      exp_port_name = [exp_port_name; subport(1,:)]; ## Write out the only port
      exp_port_bond = [exp_port_bond; port_bond(i)]; ## and the port_bond
    else ## its a vector port
      ## Check that there is a corresponding vector port at the other end of the
      ## bond
      signed_bond_index = port_bond(i);
      [other_bond_index,n_other] = getindex(port_bond,-signed_bond_index);
      if n_other == 1
	other_port_name = port_name(other_bond_index,:);
	[other_subport,n_other_subports] = split_port(other_port_name, ',');
	if n_other_subports~=n_subports
	  mtt_error(['Vector ports ', port_name_i, ' and ', other_port_name, 'are not compatible'],errorfile);
	end
      else # No explicit matching vector port
 	mtt_error(['Vector port ', port_name_i, ' has no matching port'], errorfile);
      endif
      
      
      if other_bond_index>i ##then its not been done yet
	mtt_info(["Vector port: ", port_name_i],infofile);
	mtt_info(["matching: ", other_port_name],infofile);
	## Remove sign info.
	bond_index = abs(signed_bond_index);
	sig = sign(signed_bond_index);
	
	## Put the first element of each port list in the expanded list
	exp_port_name = [exp_port_name; subport(1,:)];
	exp_port_name = [exp_port_name; other_subport(1,:)];
	
	## Add to the expanded port_bond list
	exp_port_bond = [exp_port_bond; signed_bond_index; ...
			 -signed_bond_index];
	
	## Add the other names to the expanded list and augment the bonds,
	## components and port_bond lists.
	for j=2:n_subports
	  ## Add a new name (for each end) to give a non-vector list
	  exp_port_name = [exp_port_name; subport(j,:)];
	  exp_port_name = [exp_port_name; other_subport(j,:)];
	  
	  ## Add one more bond to the list
	  bonds = [bonds; bonds(bond_index,:)];
	  n_bonds = n_bonds + 1;
	  
	  ## Add bond to the expanded port_bond list (ports at both ends)
	  exp_port_bond = [exp_port_bond; sig*n_bonds; -sig*n_bonds];


	  ## Add the new bond to the component at both ends (taking note 
	  ## of the direction).
	  arrow_index = comp_near_bond(bond_index,1);
	  components = add_bond(components, n_bonds, arrow_index);
	  other_index = comp_near_bond(bond_index,2);
	  components = add_bond(components, -n_bonds, other_index);
	endfor
	
      endif
      
    endif
    
  endfor



  ##Replace old list by new
  port_name = exp_port_name
  port_bond = exp_port_bond

  ## Resize the lists
  [n_ports,junk] = size(port_name);

  port_name, components
  ## Produce a list of bonds on each component (within this component) 
  ##  - sorted if explicit port numbers
  for i = 1:n_components    
    disp('-----------------');
    ##Get component type
    eval(['[comp_type, comp_name] = ', name, '_cmp(i)']);


    ##Convert junction names   
    if comp_type(1)=='0'	# Zero junction
      comp_type = 'zero';
      isa_junction = 1;
    elseif comp_type(1)=='1'	# One junction
      comp_type = 'one';
      isa_junction = 1;
    else
      isa_junction = 0;
    endif

    ## Find the (unsorted) bond list on this component
    signed_bond_list = nozeros(components(i,:));
    n_comp_bonds = length(signed_bond_list);
    direction = sign(signed_bond_list);
    
    ##Find the port list for this component
    if exist([comp_type, '_cause'])==0
      eval(["ABG = ",comp_type, "_abg;"]);
      if isfield (ABG, "portlist")
	port_list = ABG.portlist;
      else
	error(sprintf("Component %s has no ports", comp_type));
        port_list = [];
      endif
    else
      port_list=comp_ports(comp_type,n_comp_bonds)
    endif
    

    [n_comp_ports,m_comp_ports] = size(port_list);
    subport_list="";
    for p=1:n_comp_ports		# Expand any vector ports
      [subport,n_sub] = split_port(port_list(p,:), ','); # Find the components
				# of the vector port
      if n_sub>1
	mtt_info(sprintf("Expanding vector port %s of component type %s", ...
			 port_list(p,:), comp_type, infofile));	
      endif
      
      subport_list = [subport_list; subport];
    endfor
    
    port_list = subport_list;	# Set the expanded port list.
    

    ## Check that number of bonds on the component is the same as the number of
    ## ports
    [n_comp_ports,m_comp_ports] = size(port_list);
    if (n_comp_ports~=n_comp_bonds) & ...
	  ~(strcmp(comp_type,'zero')|strcmp(comp_type,'one'))
      message=sprintf('Component %s (%s) has %1.0f impinging bonds but has %1.0f ports', ...
		      comp_name,comp_type,n_comp_bonds,n_comp_ports);
      mtt_error(message, errorfile);
    endif
    
    
    unsorted_port_list="";
    if n_ports>0 ## then there are some named ports
      ## so find those associated with the bonds on this component.
      k=0; 
      for j = 1:n_comp_bonds
	b = signed_bond_list(j); 
	## Find the port label on component end of bond (if any)
	[port_index,m] = getindex(port_bond,b);
	if m==1
	  k=k+1;
	  unsorted_port_list(k,:) = port_name(port_index,:);
	endif
	
      endfor
      
    else 
      k=0;
    endif
    
    %Compute the number of labeled ports
    [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
    if m_unsorted_ports==0
      n_unsorted_ports = 0;
    endif
    
    ## Junctions (order of ports unimportant)
    if strcmp(comp_type,'zero')|strcmp(comp_type,'one')
      for j = 1:n_comp_bonds
	components(i,j) = signed_bond_list(j);
      endfor
      
    else ##Order of ports is important
      unsorted_port_list, port_list
      if n_unsorted_ports==0
	mtt_error(['Component ', comp_name, ' (', comp_type, ') has no labeled ports'], errorfile); 
      endif
      
      ##Write out the signed bond list in the correct order
      unsorted_port_list
      [n_list,m_list] = size(unsorted_port_list);
      if n_list!=n_comp_bonds
	error(sprintf("Component %s (%s) has %i bonds but %i port labels", ...
		      comp_name, comp_type, n_comp_bonds, n_list))
      endif

      for j = 1:n_comp_bonds
	j
	name_k = unsorted_port_list(j,:)
	k = name_in_list(name_k, port_list);
	## Check that it only appears once in port list
	if length(k)>1
	  mtt_error(['Component ', comp_name, ' (', comp_type, ') has ports with the same name:  ', name_k], errorfile); 
	endif
	
	
	##Check that it only appears one in the label list
	kk = name_in_list(name_k,unsorted_port_list);
	if length(kk)>1
	  mtt_error(['Component ', comp_name, ' (', comp_type, ') has multiple port labels:  ', name_k], errorfile); 
	endif
	
	
	if k==0
	  mtt_error(['Component ', comp_name, ' (', comp_type, ') has an unrecognised port: ', name_k], errorfile); 
	else
	  components(i,k) = signed_bond_list(j);     
	endif
      endfor
    endif
  endfor

endfunction

Deleted mttroot/mtt/bin/trans/m/rbg2ibg.m version [ec747e75b4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*-

function [bonds] = ...
      rbg2ibg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, ...
	      infofile, errorfile)

  rbonds
  rstrokes
  rcomponents
  port_coord
  port_name

  ## Default to no components
  components = [0];

  ## Xfig scaling factor
  scale = 1200.0/2.54546;

  ## Rotation matrix
  rot = [0, -1; 1, 0];

  ## Find number of strokes
  [n_strokes,columns] = size(rstrokes);
  if ((columns ~= 4) & (n_strokes > 0))
    error('Incorrect rstrokes matrix: must have 4 columns');
  endif

  ## Find number of bonds
  [n_bonds,columns] = size(rbonds);
  if ((columns ~= 6) & (n_bonds > 0))
    error('Incorrect rbonds matrix: must have 6 columns');
  endif

  ## Find number of components
  [n_components,columns] = size(rcomponents);

  ## Find number of ports referred to
  [n_ports,columns] = size(port_coord);
  
  ## If port_name empty, make it empty string
  if (length(port_name) == 0)
    port_name="";
  endif
  
  ## Determine coordinates of arrow end of bond and other end
  other_end_1	= rbonds(:,1:2);
  arrow_end	= rbonds(:,3:4);
  other_end_2	= rbonds(:,5:6);

  distance_1	= length2d(other_end_1 - arrow_end);
  distance_2	= length2d(other_end_2 - arrow_end);
  which_end	= (distance_1 > distance_2) * [1, 1];
  one		= ones(size(which_end));
  other_end	= which_end .* other_end_1 + (one - which_end) .* ...
      other_end_2;
  arrow_vector	= (which_end .* other_end_2 + (one - which_end) .* ...
		   other_end_1) - arrow_end;
  
  ## Locate bond end nearest each port
  ## col 1 of port_near_bond contains a signed bond number (+ for arrow
  ## end)
  ## col 2 of port_near_bond contains the corresponding port index
  port_bond = [];
  for i = 1:n_ports
    near_bond = adjbond(port_coord(i,1:2), arrow_end, other_end);
    [rows,cols] = size(near_bond);
    if (rows > 1)
      error(sprintf ...
	    ("A port is near to more than one bond at coordinates ...
	  %g,%g %s\n", ...
	     port_coord(i,1)/scale, port_coord(i,2)/scale, ...
	     deblank(port_name(i,:))));
    endif
    
    ## The (signed) bond corresponding to the ith port label
    port_bond(i,1) = near_bond(1) * sign(1.5 - near_bond(2));
  endfor
  port_bond

  ## Now have (signed) bond (port_bond(i)) corresponding to the ith port
  ## Create inverse mapping
  for i = 1:n_bonds
    eval(sprintf('bond_port_head%i = "[]"', i))
    eval(sprintf('bond_port_tail%i = "[]"', i))
  endfor  
  for i = 1:n_ports
    if (port_bond(i) > 0)
      eval(sprintf('bond_port_head%i = "%s"', port_bond(i), ...
		   deblank(port_name(i,:))))
    else
      eval(sprintf('bond_port_tail%i = "%s"', -port_bond(i), ...
		   deblank(port_name(i,:))))
    endif
  endfor
  
  ## Locate the components at the ends of each bond
  ## col 1 of comp_near_bond contains component nearest to the arrow end
  ## col 2 of comp_near_bond contains component nearest other end
  for i = 1:n_bonds
    comp_near_bond(i,:) = adjcomp(arrow_end(i,:), other_end(i,:), ...
				  rcomponents);
  endfor
  comp_near_bond

  ## Deduce causality from the strokes (if any)
  causality = zeros(n_bonds,2);
  if (n_strokes > 0)
    ## Find location of centre and ends of stroke
    stroke_end_1	= [rstrokes(:,1), rstrokes(:,2)];
    stroke_end_2	= [rstrokes(:,3), rstrokes(:,4)];

    stroke_centre	= (stroke_end_1 + stroke_end_2)/2;
    stroke_vector	= (stroke_end_1 - stroke_end_2);
    stroke_length	= length2d(stroke_vector);

    for i = 1:n_strokes
      stroke = [stroke_centre(i,:)
		stroke_end_1(i,:)
		stroke_end_2(i,:)];


      ## Find the nearest bond end
      [index,distance] = adjbond(stroke(1,:),arrow_end,other_end);
      if (distance > (2 * stroke_length(i)))
	info = sprintf('Stroke at (%4.3f,%4.3f) is %4.3f away from the nearest bond\n', ...
		       stroke(1,1)/scale, stroke(1,2)/scale, ...
		       distance/scale);
      endif

      ## Bond end coordinates
      j = index(1,1);
      which_end = (index(1,2) == 1);
      bond_end = arrow_end(j,:) * which_end + other_end(j,:) * (1 - ...
								which_end);
      
      ## Now decide which bit of the stroke is nearest
      stroke_index = adjbond(bond_end, stroke, zeros(size(stroke)));

      if (stroke_index(1) == 1)	# uni-causal stroke
	causality(j,1:2) = (2 * which_end - 1) * [1, 1];
      else			# bi-causal stroke
	stroke_direction = stroke(1,:) - stroke(stroke_index(1),:);
	flow_side = stroke_direction * arrow_vector(j,:)' > 0;
	causality(j,1+flow_side) = 2 * which_end - 1;
      endif
    endfor
  endif
  causality

  ## Write data
  for i = 1:n_bonds
    [hc_type, hc_name] = eval([name, '_cmp(comp_near_bond(i,1))']);
    [tc_type, tc_name] = eval([name, '_cmp(comp_near_bond(i,2))']);
    ## components
    eval(sprintf("bonds.bond%i.head.component\t= '%s:%s'", i, hc_type, ...
		 hc_name));
    eval(sprintf("bonds.bond%i.tail.component\t= '%s:%s'", i, tc_type, ...
		 tc_name));
    ## ports
    eval(sprintf("bonds.bond%i.head.ports\t= bond_port_head%i", i, i));
    eval(sprintf("bonds.bond%i.tail.ports\t= bond_port_tail%i", i, i));
    ## causality
    if (causality(i,1) == 1)
      effort_causality = "head"
    elseif (causality(i,1) == -1)
      effort_causality = "tail"
    else
      effort_causality = "none"
    endif

    if (causality(i,2) == 1)
      flow_causality = "tail"
    elseif (causality(i,2) == -1)
      flow_causality = "head"
    else
      flow_causality = "none"
    endif
    
    eval(sprintf("bonds.bond%i.causality.effort\t= '%s'", i, effort_causality));
    eval(sprintf("bonds.bond%i.causality.flow\t= '%s'", i, flow_causality));
  endfor

endfunction

Deleted mttroot/mtt/bin/trans/m/rc_sim.m version [bf245ec09e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y,x] = rc_sim(mttx_0,mttU,mttT,MTTpar);

  ## Initialise
  [MTTu]  = zero_input(1);	# Zero the input

  [MTTx] = mttx_0;	        # Read in initial state

  N = length(mttT);
  Nx = length(mttx_0);

  y = zeros(1,N);
  x = zeros(Nx,N);

  mttdt = mttT(2)-mttT(1);
  for i = 1:N
    MTTt = mttT(i);
    MTTu = mttU(i);
    [MTTy] = rc_cseo(MTTx,MTTu,MTTt,MTTpar);    # Output 
    y(1,i) = MTTy;
    x(:,i) = MTTx;
    if 1>0			# Dont if no states
      [MTTdx] = rc_cse(MTTx,MTTu,MTTt,MTTpar); # State derivative
      [mttAA] = rc_smxa(MTTx,MTTu,mttdt,MTTpar);	# (I-Adt)
      [mttAA] = reshape(mttAA,Nx,Nx);
      [mttAAx] = rc_smxax(MTTx,MTTu,mttdt,MTTpar);	# (I-Adt)x
      [MTTopen] = rc_switchopen(MTTx);        # Open switches
      [MTTx] = mtt_implicit(MTTx,MTTdx,mttAA,mttAAx,mttdt,1,MTTopen); # Implicit update
    else 
    endif;			# 1>0

  endfor;				# Integration loop

endfunction

Deleted mttroot/mtt/bin/trans/m/rcs_header.txt version [52b8d3c3d8].

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Deleted mttroot/mtt/bin/trans/m/replace_name.m version [f5eb963580].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function string_array = replace_name(string_array, new, index); 
% Replaces a row of a string vector with a string of arbitary length.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 12:36:39  peterg
## Initial revision
##
###############################################################

string_array,new,index
  [N,M]=size(string_array);
  L = length(new);
  
  if index>N 
    error(["String array has less than ", num2str(index), " rows"]);
  end;
  
  if L<M			# Pad the new string
    new = [new, blanks(M-L)];
  elseif M<L			# Pad the array
    for i=1:L-M
      string_array=[string_array, blanks(N)'];
    end
  end

  string_array(index,:) = new;	# Replace ith row by new string

endfunction

    
    


Deleted mttroot/mtt/bin/trans/m/sign2name.m version [815733e396].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = sign2name(sign);
% sign2name - converts sign to a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sign2name


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



if sign==1
  name = '+';
elseif sign ==-1
  name = '-';
else
  name = '??';
end;

Deleted mttroot/mtt/bin/trans/m/sm2ir.m version [4fd52f72ba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% sm2ir - state matrix to impulse response.
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sm2ir
% [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% A,B,C,D,E - (constrained) state matrices
% T vector of time points
% u0 input gain vector: u = u0*unit impulse.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/12/05 10:17:34  peterg
% %% Put in version control history.
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if max(max(abs(D)))~=0
  mtt_info('D matrix non-zero - ignoring');
end;

if nargin<6
  u0 = zeros(Nu,1);
  u0(1) = 1;
end;

if nargin<7
  x0 = zeros(Nx,1);
end;

[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;



one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);

dt = T(2)-T(1);% Assumes fixed interval
##expAdt = expm(A*dt); % Compute matrix exponential
##expAt = one;
i = 0;
x = (B*u0+x0);
for t = T'
  i=i+1;
  if Nx>0
    ##expAt = expm(A*t);
    ##x = expAdt*x;
     x = expm(A*t)*(B*u0+x0);
    X(i,:) = x';
    if Ny>0
      y = C*x;
      Y(i,:) = y';
    end;
  end;
end;






Deleted mttroot/mtt/bin/trans/m/sm2sr.m version [d2d3e4bb56].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% sm2sr - Constrained-state matrix to step response.
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sm2sr
% [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% A,B,C,D,E - (constrained) state matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/12/05 10:18:52  peterg
% %% Saved (quite old) version which integrates IR to give SR
% %%
% %% Revision 1.3  1996/10/27  10:39:04  peterg
% %% Only compute matrix exponential once.
% %%
% %% Revision 1.2  1996/09/10  16:48:21  peter
% %% Changed ar counts in default settings.
% %%
% %% Revision 1.1  1996/08/19 15:34:29  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if nargin<6
  u0 = zeros(Nu,1);
  u0(1) = 1;
end;

if nargin<7
  x0 = zeros(Nx,1);
end;

[N,M] = size(T);
if M>N
  T = T';
  N = M;
end;



one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);

dt = T(2)-T(1);% Assumes fixed interval
expAdt = expm(A*dt); % Compute matrix exponential
i = 0;
expAt = one;

for t = T'
  i=i+1;
  if Nx>0
    x = ( A\(expAt-one) )*B*u0 + expAt*x0;
    expAt = expAt*expAdt;
    X(i,:) = x';
    if Ny>0
      y = C*x + D*u0;
      Y(i,:) = y';
    end;
  elseif Ny>0
    y = D*u0;
    Y(i,:) = y';
  end;
end;

% $$$ % Compute the impulse response
% $$$ [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% $$$ 
% $$$ % Assume fixed sample interval
% $$$ dT = T(2)-T(1);
% $$$ 
% $$$ % Do an Euler integration on it
% $$$  Y = mtt_euler(Y,dT);
% $$$  
% $$$  if nargout>1
% $$$    X = mtt_euler(X,dT);
% $$$  end;
% $$$  



Deleted mttroot/mtt/bin/trans/m/split_port.m version [bf18ef5846].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [subport,n]=split_port(port_name);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/04/16 14:08:00  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



  subport = "";
  raw_subport = char(strsplit(port_name, ',')); # Find the components of the vector
				# port 
  [n,m] = size(raw_subport);	# Number of ports

  for i = 1:n
    s = deblank(raw_subport(i,:));
    l = length(s);

    if s(1)=="["		# Remove leading [ (if any)
      l = l-1;
      s = substr(s,2,l);
    end

    if s(l)=="]"		# Remove trailing ] (if any)
      l = l-1;
      s = substr(s,1,l);
    end

    s = ["[",s,"]"];		# Surround by []
    
    subport = [subport ;s];	# Return to the array
  end;

endfunction;





Deleted mttroot/mtt/bin/trans/m/str2ch.m version [6886463212].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ch = str2ch(str,n)
% str2ch - pulls the nth char from a string
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  str2ch.m
% ch = str2ch(str,n)
% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/12/04 21:39:55  peterg
% %% Changed to handle null string (octave returns lenghth of 1)
% %%
% %% Revision 1.1  1996/08/30  09:54:44  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
implicit_str_to_num_ok = 1;

astr = abs(str);
if (n>0) &  (n<=length(str)) & (strcmp(str,'')==0)
  ch = char(astr(n));
else
  ch = '';
end;















Deleted mttroot/mtt/bin/trans/m/subs_arg.m version [9eca75053a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function args_out = subs_arg(args,Args, ...
    default,full_name,comp_type,comp_name,fileID)
% subs_arg - substitutes arguments into args from Args
% FS defaults to `;'.
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  subs_arg.m
% args_out = subs_arg(args,Args,default,comp_type,comp_name,infofile)
% Copyright (c) P.J. Gawthrop, 1996.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2001/07/03 22:59:10  gawthrop
% %% Fixed problems with argument passing for CRs
% %%
% %% Revision 1.6  1998/07/27 09:53:44  peterg
% %% No change
% %%
% %% Revision 1.5  1998/07/21 16:43:26  peterg
% %% Now writes to an explicit fileID - otherwise we may run out of IDs.
% %%
% %% Revision 1.4  1996/12/10 16:04:11  peterg
% %% Changed file handling on mtt_info.
% %%
% %% Revision 1.3  1996/12/07  18:19:39  peterg
% %% Replaces null argument by a default and tells user.
% %%
% %% Revision 1.2  1996/12/04 21:47:41  peterg
% %% Skips main loop when arg is null.
% %%
% %% Revision 1.1  1996/12/04 21:46:52  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Symbolic argument sign
S = '$';

args_out = '';
if strcmp(args,'')==0
  L = length(args);
  args_count = 1;
  num_count=0;
  while args_count <= L
    ch = str2ch(args,args_count);
    if ch~=S % copy character
      args_out = [args_out, ch];
      args_count = args_count+1;
    else % find argument number
      args_count = args_count+1;
 	
      ch = str2ch(args,args_count);    
      ## Modification for $p1 $a1 etc
      if !((ch>='0') & (ch<='9')) # It's not numerical - so loose it
	args_count = args_count+1;
	ch = str2ch(args,args_count);    
      endif

     i=0;
      while (ch>='0') & (ch<='9')
	i = 10*i + abs(ch)-abs('0');
	if args_count==L
	  args_count = args_count+1;
	  break
	end;
	args_count = args_count+1;
	ch = str2ch(args,args_count);
      end;
      arg_out = args2arg(Args,i);


      % Test for empty argument -- replace by default and tell user
      message = 'Argument %1.0f of component %s(%s) of system %s is undefined - \n replacing by %s';
      if strcmp(arg_out,'')
	info = sprintf(message, ...
	    i, comp_name, comp_type, full_name, default);
	arg_out = default;
      else
	info = sprintf("Replacing $%i \t by %s for component %s (%s) ...
	within %s", i, arg_out, comp_name, comp_type, full_name);
      end;
      mtt_info(info,fileID);
      args_out = [args_out, arg_out];
    end;
  end;
end;

Deleted mttroot/mtt/bin/trans/m/varname.m version [936a174266].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = varname(name,index,causality);
  ## varname - Creates name of bond graph variable
  ## Usage: name = varname(name,index,causality);
 
##     ###################################### 
##     ##### Model Transformation Tools #####
##     ######################################
## 
## Matlab function  varname.m
## Copyright (C) 1994-2003 by Peter J. Gawthrop


# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.4  2003/03/24 09:09:52  gawthrop
# ## Reformated to octave standard
# ## Now writes variables in non-matrix form
# ##
# ## Revision 1.3  2003/03/13 14:22:34  gawthrop
# ## No negative bond numbers
# ##
# ## Revision 1.2  2000/12/27 16:06:15  peterg
# ## *** empty log message ***
# ##
# ## Revision 1.1  1996/08/27 08:08:44  peterg
# ## Initial revision
# ##
# ###############################################################


# # bond_name = [name,'_bond'];
# # name =sprintf('%s%1.0f_%s', bond_name, index, cause2name(causality));

# # bond_name = [name,'('];
# # name =sprintf('%s(%1.0f,%1.0f)', name, abs(index), cause2num(causality));

  name =sprintf('%s_%i_%s', name, abs(index), cause2name(causality));

endfunction

Deleted mttroot/mtt/bin/trans/m/write_abg.m version [1dcbed067b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200








































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function write_abg(system_name,bonds,connections,n_vector_bonds);

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  2004/09/12 22:27:27  geraint
## Appended 't' to fopen mode string to open in text mode.
##
## Revision 1.10  2004/08/09 14:47:28  gawthrop
## Changed arg to args to avoid strange octave bug
##
## Revision 1.9  2001/04/15 21:15:41  geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.8  1999/10/18 22:41:41  peterg
## Corrected vector junction expansion
##
## Revision 1.7  1999/10/18 05:16:51  peterg
## Now vectorises 0 and 1 junctions !!
##
## Revision 1.6  1998/09/02 11:35:20  peterg
## Removed port.index field
##
## Revision 1.5  1998/09/02 10:30:30  peterg
## Now writes out list of ports ans list of subsystems.
## These ordereded lists determine the order of processing of ports ans
## subsystems.
##
## Revision 1.4  1998/08/26 12:45:38  peterg
## Just prefix ports (comps can't start with numeral)
## Prefix with mttp
##
## Revision 1.3  1998/08/26 12:31:07  peterg
## numerical names prefixed by mtt
##
## Revision 1.2  1998/08/26 11:59:20  peterg
## Don't use strrep to remove[]
##
## Revision 1.1  1998/08/25 06:22:02  peterg
## Initial revision
##
###############################################################


  fid=fopen([system_name,"_abg.m"], "wt");
  [N,M]=size(connections);
  Sformat = "  %s.subsystems.%s.%s = \"%s\";\n";
  PSformat = "  %s.ports.%s.%s = \"%s\";\n";
  Iformat = "  %s.subsystems.%s.%s = %i;\n";
  PIformat = "  %s.ports.%s.%s = %i;\n";
  Cformat = "  %s.subsystems.%s.connections = [";
  PCformat = "  %s.ports.%s.connections = [";
  Bformat = "  %s.bonds = [\n";

  fprintf(fid,"function [%s] =  %s_abg\n", system_name, system_name);
  fprintf(fid,"# This function is the acausal bond graph representation of %s\n",system_name);
  fprintf(fid,"# Generated by MTT on %s",ctime(time));
  fprintf(fid,"# The file is in Octave format\n");

  fprintf(fid,"\n# Subsystems and Ports\n");
  i_port=0; SubsystemList = ""; PortList ="";
  for i=1:N
    eval(["[comp_type, name, cr, args, repetitions] = ", system_name, "_cmp(i);"]);
    c = nozeros(connections(i,:));# Connections to this component
    m = length(c);		# Number of connections

    ## Vectorise junctions?
    n_bonds = n_vector_bonds(i);
    if strcmp(comp_type,"0")||strcmp(comp_type,"1")
            n_vector = m/n_bonds;
	    m_vector = n_bonds;
    else
      n_vector = 1;
      m_vector = m;
    endif
      
    if index(name,"[")==0	# Not a port
      for i_vector = 1:n_vector;

	if i_vector>1		# Extras
	  new_name = sprintf("%sv%i", name,i_vector);
	else
	  new_name = name;
	endif
	
	SubsystemList = [SubsystemList; new_name];
	fprintf(fid,"\n# Component %s\n", new_name);
	fprintf(fid,Sformat,system_name,new_name,"type",comp_type);
	fprintf(fid,Sformat,system_name,new_name,"cr",cr);
	fprintf(fid,Sformat,system_name,new_name,"arg",args);
	fprintf(fid,Iformat,system_name,new_name,"repetitions",repetitions);
	fprintf(fid,Iformat,system_name,new_name,"status",-1);

	##Connections
	fprintf(fid,Cformat,system_name,new_name);
	## Each vector junction has n*m bonds
	## n - dimension of vector
	## m - number of bonds
	
	## The first m bonds (in c) correspond to the first vector element
	if i_vector==1		
	  for j=1:m_vector
      	    fprintf(fid,"%i ", c(j) );
	  endfor
	  ## The next block of n-1 bonds are the first bonds on vector elements 2,3 ...
	  ## followed by a  block of n-1 bonds being the second bonds on vector elements 2,3 ...
	  ## etc
	else	
	  k = m_vector+i_vector-1; # index of first bond at level i_vector
	  for j=1:m_vector
      	    fprintf(fid,"%i ", c(k) );
	    k = k + n_vector-1;
	  endfor
	endif
	
	fprintf(fid,"];\n");
      endfor
    else			# Its a port
      name=name(2:length(name)-1); # Strip []
      ch=name(1);		# First char of name
      if (ch>="0")&&(ch<="9")	# Its a numeral
      	name=["mttp",name];	# prefix by mttp
      endif;

      for i_port=1:m
	if m>1			# Index the port name
	  name_i = sprintf("%s_%i",name,i_port);
	else
	  name_i = name;	# Leave it alone
	endif;

	PortList = [PortList; name_i]; # Update port list
	
	fprintf(fid,"\n# Port %s\n", name_i); 
	fprintf(fid,PSformat,system_name,name_i,"type",comp_type);
	fprintf(fid,PSformat,system_name,name_i,"cr",cr);
	fprintf(fid,PSformat,system_name,name_i,"arg",args);
	fprintf(fid,PIformat,system_name,name_i,"repetitions",repetitions);
	fprintf(fid,PIformat,system_name,name_i,"status",-1);
	
	fprintf(fid,PCformat,system_name,name_i);
      	fprintf(fid,"%i ", c(i_port));
	fprintf(fid,"];\n");

      endfor;
    endif;
  endfor;

  [N,M]=size(PortList);
  if N>0			# Put name in list
    fprintf(fid,"\n# Ordered list of Port names\n");
    for i=1:N
      fprintf(fid,"  %s.portlist(%i,:) = \"%s\";\n", system_name, i, PortList(i,:));
    endfor;
  endif;

  [N,M]=size(SubsystemList);
  if N>0			# Put name in list
    fprintf(fid,"\n# Ordered list of subsystem names\n");
    for i=1:N
      fprintf(fid,"  %s.subsystemlist(%i,:) = \"%s\";\n", system_name, i, SubsystemList(i,:));
    endfor;
  endif;


  fprintf(fid,"\n# Bonds \n");
  [N,M]=size(bonds);		# Bonds
  fprintf(fid,Bformat,system_name);
  for i=1:N
    fprintf(fid,"      ");
    for j=1:M
      fprintf(fid,"%i ", bonds(i,j));
    endfor;
    fprintf(fid,"\n");
  endfor;
  fprintf(fid,"      ];\n");
    
  fprintf(fid,"\n# Aliases \n");
  fprintf(fid,"# A double underscore __ represents a comma \n");
  eval(["alias = ", system_name, "_alias;"]);
  if isstruct(alias)
    for [val,key] = alias
      fprintf(fid,"%s.alias.%s = \"%s\";\n", system_name,key,val);
    endfor
  endif

  fprintf(fid,"\n# Interface Definition\n");
  eval(["icd = ",system_name, "_icd;"]);
  if isstruct(icd)
    for [val,key] = icd
      fprintf(fid,"%s.icd.%s = \"%s\";\n",system_name,key,val);
    endfor
  endif
	

  fclose(fid);
  

Deleted mttroot/mtt/bin/trans/m/write_cbg.m version [cabf88aa9f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function write_cbg(system_name,system_type,system,Flipped)

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2004/09/12 22:27:27  geraint
## Appended 't' to fopen mode string to open in text mode.
##
## Revision 1.4  1998/08/26 12:26:17  peterg
## Replaced if N>0 by   if (N>0)&&(M>0)		# Flipped ports exist
##
## Revision 1.3  1998/08/25 20:05:33  peterg
## Write flipped port info
##
## Revision 1.2  1998/08/25 06:21:19  peterg
## Just writes additional information; basic info from the abg structure.
##
## Revision 1.1  1998/08/25 05:55:10  peterg
## Initial revision
##
###############################################################


  fid=fopen([system_name,"_cbg.m"], "wt");# Open file

  StatusFormat = "  %s.%s.%s.status = %i;\n";
  Bformat = "  %s.bonds = [\n";
  Iformat = "  %s.%s.%s.connections(%i) = %i;\n";


  fprintf(fid,"function [%s] =  %s_cbg\n", system_name, system_name);
  fprintf(fid,"# This function is the causal bond graph representation of %s\n",system_name);
  fprintf(fid,"# Generated by MTT on %s",ctime(time));
  fprintf(fid,"# The file is in Octave format\n");
  
  fprintf(fid,"\n# Acausal bond graph structure\n");
  fprintf(fid,"  [%s] =  %s_abg;\n", system_name, system_type);

  fprintf(fid,"\n# Status information\n");
#  if isfield(system,"ports")
#    for [port,name]=system.ports
#      fprintf(fid,StatusFormat,system_name,"ports",name,port.status);
#    endfor;
#  endif
  if isfield(system,"subsystems")
    for [subsystem,name]=system.subsystems
      fprintf(fid,StatusFormat,system_name,"subsystems",name,subsystem.status);
    endfor;
  endif
  
  [N,M]=size(system.bonds);		# Bonds
  fprintf(fid,"\n# Causal bond information\n");
  fprintf(fid,Bformat,system_name);
  for i=1:N
    fprintf(fid,"      ");
    for j=1:M
      fprintf(fid,"%i ", system.bonds(i,j));
    endfor;
    fprintf(fid,"\n");
  endfor;
  fprintf(fid,"      ];\n");

  [N,M]=size(Flipped.ports);
  if (N>0)&&(M>0)		# Flipped ports exist
    fprintf(fid,"\n# Flipped port information\n");
    for i=1:N
      name=deblank(Flipped.ports(i,:));
      eval(["con = system.ports.",name,".connections;"]);
      fprintf(fid,Iformat,system_name,"ports",name,1,con);
    endfor;
  endif;

  [N,M]=size(Flipped.subs);
  if (N>0)&&(M>0)		# Flipped subs exist
    for i=1:N
      name=deblank(Flipped.subs(i,:));
      k=Flipped.cons(i);
      eval(["con = system.subsystems.",name,".connections(",num2str(k),");"]);
      fprintf(fid,Iformat,system_name,"subsystems",name,k,con);
    endfor;
  endif;

  fclose(fid);
  

Deleted mttroot/mtt/bin/trans/m/write_ibg.m version [bff06207d1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*-

function write_ibg(system_name,bonds);
  
  fid = fopen([system_name,"_ibg.m"], "wt");
  [nbonds, junk] = size(fieldnames(bonds));
  format_hc = "  %s.bonds.bond%i.head.component\t= \"%s\";\n";
  format_tc = "  %s.bonds.bond%i.tail.component\t= \"%s\";\n";
  format_hp = "  %s.bonds.bond%i.head.ports\t= \"%s\";\n";
  format_tp = "  %s.bonds.bond%i.tail.ports\t= \"%s\";\n";
  format_ce = "  %s.bonds.bond%i.causality.effort\t= \"%s\";\n";
  format_cf = "  %s.bonds.bond%i.causality.flow\t= \"%s\";\n";

  fprintf(fid, "## -*-octave-*-\n\n");
  fprintf(fid, "function [%s] = %s_ibg\n\n", system_name, system_name);
  fprintf(fid, "  ## Intermediate bond graph representation of %s\n", ...
	  system_name);

  fprintf(fid, "  ## Generated by MTT on %s\n", ctime(time));
  fprintf(fid, "  ## head refers to the harpoon end of a bond\n");
  fprintf(fid, "  ## tail refers to the other end of a bond\n");
  fprintf(fid, "  ## causality.? is the end at which ? is imposed\n\n");

  for i=1:nbonds
    fprintf(fid, "\n  ## bond %i\n", i);
    fprintf(fid, format_hc, system_name, i, ...
	    eval(sprintf("bonds.bond%i.head.component", i)));
    fprintf(fid, format_tc, system_name, i, ...
	    eval(sprintf("bonds.bond%i.tail.component", i)));
    fprintf(fid, format_hp, system_name, i, ...
	    eval(sprintf("bonds.bond%i.head.ports", i)));
    fprintf(fid, format_tp, system_name, i, ...
	    eval(sprintf("bonds.bond%i.tail.ports", i)));
    fprintf(fid, format_ce, system_name, i, ...
	    eval(sprintf("bonds.bond%i.causality.effort", i)));
    fprintf(fid, format_cf, system_name, i, ...
	    eval(sprintf("bonds.bond%i.causality.flow", i)));
  endfor;

  fprintf(fid, "\nendfunction\n");
  fclose(fid);

endfunction;

Deleted mttroot/mtt/bin/trans/m/write_matrix.m version [80adc0845c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function write_matrix(matrix,name,extn);

% Writes the matrix function file

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.9  2006/09/27 13:55:08  geraint
% %% Write complex numbers in polar form instead of real and imaginary parts.
% %%
% %% Revision 1.8  2004/09/12 22:27:27  geraint
% %% Appended 't' to fopen mode string to open in text mode.
% %%
% %% Revision 1.7  2002/05/15 16:37:30  gawthrop
% %% Added third argument (file extension)
% %%
% %% Revision 1.6  2000/12/27 16:06:17  peterg
% %% *** empty log message ***
% %%
% %% Revision 1.5  1998/02/03 08:40:39  peterg
% %% Fixed a horrible bug -- changed filename -> filenum
% %%
% %% Revision 1.4  1996/08/15  11:56:11  peter
% %% Does complex matrices.
% %%
% %% Revision 1.3  1996/08/14 19:20:41  peter
% %% Fixed output naming bug.
% %%
% %% Revision 1.2  1996/08/14 08:36:52  peter
% %% Puts a tab between columns.
% %%
% %% Revision 1.1  1996/08/14 08:21:27  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if nargin<3
  extn="m";
endif

filename = sprintf("%s.%s", name, extn);
filenum = fopen(filename,'wt');

% Write the function m-file for the causal bond graph
pc = '%';
fprintf(filenum, 'function data = %s\n', name);
fprintf(filenum, '%s data = %s\n\n', pc, name);

fprintf(filenum, 'data = [\n');

[N,M] = size(matrix);
for row = 1:N
  for col = 1:M
    value = matrix(row,col);
    if iscomplex(value)
	fprintf(filenum, '%g*e^(%g*i)', abs(value),angle(value));
    else
	fprintf(filenum, '%g', value);
    end
    if col<M
      fprintf(filenum, '\t');
    end
  end;
  fprintf(filenum, '\n');
end;

fprintf(filenum, '];\n');
fprintf(filenum, '\n');

fclose(filenum);


Deleted mttroot/mtt/bin/trans/m/zero_input.m version [2299a73554].

1
2
3



-
-
-
function [x] = zero_input(N);
  x = zeros(N,1);
endfunction;

Deleted mttroot/mtt/bin/trans/m/zero_matrix.m version [4f191aac68].

1
2
3



-
-
-
function [A] = zero_matrix(N);
  A = zeros(N,N);
endfunction;

Deleted mttroot/mtt/bin/trans/m2dat version [f209734a96].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: m2dat

# Transforms data in .m file to just the data - ie strips the matlab stuff

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1996/08/14 08:36:16  peter
## Initial revision
##
###############################################################

echo Creating $1.dat

gawk '$1 ~ /[0-9]/ && NF>0 {print} ' <$1.m  >$1.dat

Deleted mttroot/mtt/bin/trans/make_ode2odes version [4c433b0d7e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429





















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
    ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.90  2005/04/26 23:43:34  geraint
## Reset open switches after update to eliminate overshoots.
##
## Revision 1.89  2004/08/29 16:04:44  geraint
## Fixed ae for non-sorted code.
##
## Revision 1.88  2004/08/29 13:15:28  geraint
## Uses sys_sae instead of sys_ae if sorted equations are being used.
##
## Revision 1.87  2004/08/29 01:46:56  geraint
## Added rules to create ode2odes for sorted system: sesx and sesy.
##
## Revision 1.86  2004/08/29 00:19:49  geraint
## Defaults to noAlgebraicSolver.
##
## Revision 1.85  2003/06/25 12:46:06  gawthrop
## Input only changed one per print interval
## No effect if stepfactor=1
## Fixes bug when _input.m is compiled using -stdin option
## and stepfactor>1
##
## Revision 1.84  2003/04/17 20:57:29  geraint
## Added -sort option to allow direct generation of ode2odes.m using sese.m
## instead of ode/csex.
##
## "mtt -sort rc odeso view" works without Reduce installed!!!
##
## Revision 1.83  2002/08/07 14:27:14  geraint
## Changes to make "-i dassl" work again.
##
## Revision 1.82  2002/07/24 14:00:12  geraint
## Corrected arguments passed to mtt_write when dumping data (sigint).
##
## Revision 1.81  2002/07/11 13:00:23  geraint
## Declared more function arguments to be "const" - improves compiler optimisation.
##
## Revision 1.80  2002/05/22 09:35:49  geraint
## Added insertor variable to stop sh-mode font-lock from getting hopelessly confused by embedded C++.
##
## Revision 1.79  2002/05/20 13:42:31  gawthrop
## Uses simpar.first for first printed output
##
## Revision 1.78  2002/05/11 01:14:17  geraint
## Fix for [ 553218 ] simpar.oct and simpar.m different.
## Translation added between ColumnVector in base .cc and Octave_map in .oct.
##
## Revision 1.77  2002/05/08 16:03:32  geraint
## Added mex support for ode2odes: mtt sys ode2odes mexglx.
## This mex stuff seems to require octave2.1-headers.
##
## Revision 1.76  2002/05/08 14:14:55  geraint
## Tidied up ode2odes code - reduced interweaving of STANDALONE/OCTAVEDLD sections
##
## Revision 1.75  2002/05/07 13:48:42  geraint
## Improved clarity of code generated for -cc and -oct (except ode2odes).
## Octave DEFUN_DLDs now call (rather than replace) their .cc equivalents.
##
## Revision 1.74  2002/05/01 17:30:56  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
## if necessary.
##
## Revision 1.73  2002/05/01 12:24:41  geraint
## Removed unnecessary inclusion of load-save.h.
##
## Revision 1.72  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.71  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp
## (and thus libreadline, libkpathsea, libncurses, etc).
##
## Revision 1.70  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.69  2002/04/17 13:46:58  geraint
## #include <fstream> for -oct as well as -cc.
##
## Revision 1.68  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).
##
## Revision 1.67  2002/04/09 12:04:21  geraint
## Replaced ios:: with std::ios:: for g++-3.0 compatability.
##
## Revision 1.66  2002/03/26 11:58:58  geraint
## Added cputime monitoring.
##
## Revision 1.65  2001/11/15 06:24:11  geraint
## Updated (-i dassl) residual function to use new DAEFunc (octave-2.1.35).
## YZ residual dependency on Ui still requires some work.
##
## Revision 1.64  2001/08/08 02:15:00  geraint
## Rationalisation of solver code, beginning with algebraic solvers.
##
## Revision 1.63  2001/08/07 04:39:24  geraint
## Consolidated dassl and residual functions.
##
## Revision 1.62  2001/08/01 22:14:32  geraint
## Bug fix for dassl.
##
## Revision 1.61  2001/08/01 04:06:07  geraint
## Added -i dassl for -cc and -oct.
##
## Revision 1.60  2001/07/16 22:23:00  geraint
## Fixed misleading variable name in .cc rep.
##
## Revision 1.59  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.58  2001/07/13 00:51:39  geraint
## Fixed generation of odes.sg from .m and .oct simulations.
## .cc, .m and .oct simulations now all write mtt_data (lower case).
##
## Revision 1.57.2.5  2001/07/13 04:02:31  geraint
## Implemented numerical algebraic solution for _ode2odes.oct.
##
## Revision 1.57.2.4  2001/07/02 00:34:56  geraint
## gcc-3.0 compatibility.
##
## Revision 1.57.2.3  2001/06/25 23:28:29  geraint
## Generic mtt_rate and mtt_output - allows method independent calls.
##
## Revision 1.57.2.2  2001/06/05 03:20:40  geraint
## added -ae option to select algebraic equation solution method.
##
## Revision 1.57.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.57  2001/04/01 03:38:54  geraint
## Reset row to zero after write to file, ready for subsequent runs.
## Eliminates SIGSEGV in Octave when _ode2odes called multiple times.
##
## Revision 1.56  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.55  2001/03/27 13:21:59  geraint
## Octave version compatibility for save_ascii_data(_for_plotting).
##
## Revision 1.54  2001/03/27 01:14:27  geraint
## Improved determination of Octave version.
##
## Revision 1.53  2001/03/21 03:24:59  geraint
## Calculate inputs before outputs (.cc).
##
## Revision 1.52  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.51.2.7  2001/03/17 09:51:07  geraint
## Implemented Runge-Kutta IV fixed-step method (-i rk4).
##
## Revision 1.51.2.6  2001/03/16 03:56:13  geraint
## Removed psignal/siginfo.h - problematic and unnecessary.
##
## Revision 1.51.2.5  2001/03/12 23:16:37  geraint
## Minor improvements to signal handling (.exe).
##
## Revision 1.51.2.4  2001/03/12 03:59:30  geraint
## SIGINT  (C-c C-c) now causes simulation data to be dumped to MTT.core.
## SIGQUIT (C-c C-\) as for SIGINT, then raises default SIGQUIT.
## SIGFPE  as for SIGINT, then raises default SIGABRT.
##
## Revision 1.51.2.3  2001/03/07 04:06:55  geraint
## Irix: catch SIGFPE and write data before aborting (.exe).
## GNU/Linux: nada.
##
## Revision 1.51.2.2  2001/03/02 00:45:21  geraint
## Separated Euler and Implicit methods in .cc code and dependencies.
##
## Revision 1.51.2.1  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.51  2001/02/19 06:33:19  geraint
## Removed operation form loop.
##
## Revision 1.50  2001/02/18 09:18:49  geraint
## Removed temporary Matrices from mtt_implicit.cc
##
## Revision 1.49  2001/02/14 06:06:34  geraint
## Removed octave_value_list wrappers from standalone.exe - speed improvements
##
## Revision 1.48  2001/02/11 07:08:59  geraint
## Static declarations of octave_value_lists: small .exe speed improvement
##
## Revision 1.47  2001/02/11 05:25:52  geraint
## Reduced number of matrix operations during .oct simulation data write
##
## Revision 1.46  2001/02/05 08:32:31  geraint
## typo
##
## Revision 1.45  2001/02/05 04:32:35  geraint
## Octave version 2.1.x compatability and #ifdef statements for standalone rep
##
## Revision 1.46  2001/01/08 06:21:59  geraint
## #ifdef STANDALONE stuff
##
## Revision 1.45  2001/01/07 01:25:49  geraint
## Compatibility with Octave 2.1.33
##
## Revision 1.44  2000/12/05 12:11:45  peterg
## Changed function name to name()
##
## Revision 1.43  2000/12/04 10:59:40  peterg
## *** empty log message ***
##
## Revision 1.42  2000/11/10 14:19:50  peterg
## Corrected the csex and cseo functions
##
## Revision 1.41  2000/11/09 17:06:39  peterg
## Now does euler for cc
##
## Revision 1.40  2000/10/17 09:55:00  peterg
## Replaced switchopen by logic
##
## Revision 1.39  2000/10/14 08:04:40  peterg
## Changed arguments to _inout for consistency
##
## Revision 1.38  2000/10/11 09:08:08  peterg
## cse --> csex
##
## Revision 1.37  2000/08/01 12:25:06  peterg
## Now includes euler
##
## Revision 1.36  2000/05/19 17:48:16  peterg
## Argument to state
##
## Revision 1.35  2000/05/18 18:59:40  peterg
## Removed the First time stuff
##
## Revision 1.34  2000/05/16 18:56:14  peterg
## *** empty log message ***
##
## Revision 1.33  2000/05/11 19:33:18  peterg
## Uniform version for _sim.m
##
## Revision 1.32  2000/05/11 08:30:00  peterg

##
## Revision 1.31  2000/05/10 18:33:25  peterg
## Use smxa and smxax in place of smx
##
## Revision 1.30  2000/04/18 11:24:19  peterg
## Removed _numpar.
##
## Revision 1.29  2000/04/07 19:10:57  peterg
## *** empty log message ***
##
## Revision 1.28  1999/12/08 05:56:52  peterg
## Reordered the writing of the input and output.
## Note that last value now discarded.
##
## Revision 1.27  1999/11/15 22:47:53  peterg
## Generates method-specific code.
##
## Revision 1.26  1999/10/20 01:31:43  peterg
## *** empty log message ***
##
## Revision 1.25  1999/08/29 06:55:26  peterg
## Removed [MTTu]  = zero_input($Nu);	# Zero the input
## to avoide the p2c bug ????
##
## Revision 1.24  1999/08/27 06:02:16  peterg
## removed zero_input to avoid p2c bug
##
## Revision 1.23  1999/08/02 13:39:19  peterg
## Replaced zero_vector by zero_input
##
## Revision 1.22  1999/04/20 06:16:07  peterg
## Removed initialisation of AA and AAx
## Remove _switch calls -- uses _switchopen exclusively
##
## Revision 1.21  1999/04/02 06:29:25  peterg
## New implicit method - solves numerical prob with ISW
##
## Revision 1.20  1999/04/02 02:13:58  peterg
## Back to RCS
##
## Revision 1.19  1999/03/30 21:39:25  peterg
## In implicit approach, set derivatives to zero (when switch is off)
## before update. This seems to stop numerical leakage though non-return
## switches.
##
## Revision 1.18  1999/03/15 01:17:07  peterg
## Removed some spurious debugging code
##
## Revision 1.17  1999/03/15 01:09:15  peterg
## Fixed bugs when Nx=0 (no state)
##
## Revision 1.16  1999/03/06 02:28:38  peterg
## Rearranged evaluation to: state - input - output - write
##
## Revision 1.15  1999/03/06 02:19:43  peterg
## Changed args to _input
##
## Revision 1.14  1998/10/01 16:02:01  peterg
## Integration with switches handled separately fro Euler and Implicit.
##
## Revision 1.13  1998/09/30 17:41:24  peterg
## Implicit method now allows for switches via _switchA
##
## Revision 1.12  1998/08/27 08:55:18  peterg
## Mods to integration methods
##
## Revision 1.11  1998/08/25 12:28:31  peterg
## Move initila switch to after initial input
##
## Revision 1.10  1998/08/25 12:22:45  peterg
## Put _switch after update and also at initilisation
##
## Revision 1.9  1998/08/15 13:46:59  peterg
## New versions of integration routines
##
## Revision 1.8  1998/08/11 13:28:03  peterg
## Lowercase mttLAST etc
##
## Revision 1.7  1998/07/30 11:29:54  peterg
## Added implicit integration stuff
##
## Revision 1.6  1998/07/30 10:44:37  peterg
## INcluded othe integration methods.
##
## Revision 1.5  1998/07/26 11:02:20  peterg
## Put mtt or MTT  in front of variable names to avoid clashes with
## globals
##
## Revision 1.4  1998/07/25 20:14:00  peterg
## update code added for flexibility and octave efficiency
##
###############################################################


# Bourne shell script: make_ode2odes

# Copyright (c) P.J.Gawthrop July 1998.

# Tell user
sys=$1
lang=$2
filename=${sys}_ode2odes.${lang}

if [ -n "$3" ]; then
  method=$3    
else
  method=implicit  
fi

if [ -n "$4" ]; then
    algebraic_solver=$4
else
  algebraic_solver="noAlgebraicSolver"
fi

if [ -n "$5" ]; then
    sorted_equations=$5
else
    sorted_equations="no"
fi

insertor=\<\<			# help emacs sh-mode handle C++ lines

echo Creating $filename with $method integration method

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Outputs  

case "$method" in
    "implicit")
	ae=ae
	ode=csex
	odeo=cseo
	algorithm="mtt_implicit(x,dx,AA,AAx,ddt,$Nx,open_switches)"
	;;
    "dassl")
	case "$sorted_equations" in
	    "make")		# used by sese generated by make
		ae=sae
		ode=sesx
		odeo=sesy
		;;
	    "seqn")		# shouldn't be here unless mtt has changed
		ae=ae
		ode=sese
		odeo=sese
		;;
	    "no" | *)	
		ae=ae
		ode=ode
		odeo=odeo
		;;
	esac
	algorithm="mtt_dassl(x,u,t,par,dx,ddt,MTTNX,MTTNYZ,open_switches)"
	;;
    "sorted_euler")		# used by sese generated from seqn
	algorithm="mtt_euler(x,dx,ddt,$Nx,open_switches)"
	;;
    "euler" | "rk4" | *)
	case "$sorted_equations" in
	    "make")		# used by sese generated by make
		ae=sae
		ode=sesx
		odeo=sesy
		;;
	    "seqn")		# shouldn't be here unless mtt has changed
		ae=ae
		ode=sese
		odeo=sese
		;;
	    "no" | *)	
		ae=ae
		ode=ode
		odeo=odeo
		;;
	esac
	algorithm="mtt_euler(x,dx,ddt,$Nx,open_switches)"
	;;
esac

make_m()
{
#lang_header  $1 ode2odes m  'x,par,simpar' '[Y,X,t]' > $filename
mtt_header ${sys} ode2odes m > $filename
cat <<EOF >> $filename 
global MTT_data

  if nargin<3
    simpar = ${sys}_simpar(); 
    [simpar.dt] = mtt_simpar_update;
  endif
  if nargin<2
    par = ${sys}_numpar(); 
    [par] = mtt_numpar_update(par);
  endif
  if nargin<1
    [x0]  =  ${sys}_state(par); 
    [x0] = mtt_state_update(x);
  endif

  ## Initialise
  t = 0.0;
  ddt = simpar.dt/simpar.stepfactor;
  ilast = round(simpar.last/ddt)+1; # Total number of steps
  x = x0;

## Following removed due to p2c bug
##  [u]  = zero_input($Nu);		# Zero the input
  for MTTi=1:$Ny
    y(MTTi) = 0;
  endfor;

  mttj = 0;
    for it = 1:ilast		#Integration loop
EOF

cat <<EOF >> $filename
    if mttj==0
      [u] = ${sys}_input(x,y,t,par);	# Input
EOF

if [ "$method" = "sorted_euler" ]; then
cat <<EOF >> $filename
      [dx,y] = ${sys}_sese(x,u,t,par); # Output
EOF
else
cat <<EOF >> $filename
      [y] = ${sys}_$odeo(x,u,t,par);  # Output 
EOF
fi

cat <<EOF >> $filename
      mtt_write(t,x,y,$Nx,$Ny,simpar.first);   # Write it out
    endif
EOF

if [ "$method" = "rk4" ]; then
cat << EOF >> $filename
    [k1] = ddt * ${sys}_${ode}(x,u,t,par);
    [k2] = ddt * ${sys}_${ode}(x+k1/2,u,t+ddt/2,par);
    [k3] = ddt * ${sys}_${ode}(x+k2/2,u,t+ddt/2,par);
    [k4] = ddt * ${sys}_${ode}(x+k3,u,t+ddt,par);
    [dx] = [k1 + 2.0 * [k2 + k3] + k4] / (6.0 * ddt);
EOF
elif [ "$method" = "sorted_euler" ]; then
cat <<EOF >> $filename
    [dx,y] = ${sys}_sese(x,u,t,par); # State derivative and Output
EOF
else
cat << EOF >> $filename
    [dx] = ${sys}_$ode(x,u,t,par);	# State derivative
EOF
fi

if [ "$method" = "implicit" ]; then
cat<< EOF >> $filename

    [AA] = ${sys}_smxa(x,u,ddt,par);	# (I-Adt) and (I-Adt)x
    [AAx] = ${sys}_smxax(x,u,ddt,par); # (I-Adt) and (I-Adt)x

EOF
fi

cat <<EOF >> $filename
    [open_switches] = ${sys}_logic(x,u,t,par); # Switch logic
    [x] = $algorithm; # Integration update
    [open_switches] = ${sys}_logic(x,u,t,par); # Switch logic
    [x] = mtt_zeroswitches(x,$Nx,open_switches);
    t = t + ddt;   # Time update
    mttj = mttj+1;    # Increment counter
    if mttj==simpar.stepfactor
       mttj = 0;      # Reset counter
    endif

  endfor;			# Integration loop

## Create the output data
    mtt_data = MTT_data;
endfunction

EOF
} # make_m

make_cc() 
{
# get octave version
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	feval_header=toplev.h
	;;
    1) # development
	vector_value=column_vector_value
	feval_header=parse.h
	;;
    *)
	vector_value=column_vector_value
	feval_header=parse.h
	;;
esac

cat <<EOF  > $filename

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#define MATLABMEX  2
#define RTXI       3
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#include <octave/oct.h>
#include <octave/lo-mappers.h>
#include <octave/variables.h>

#if (CODEGENTARGET == OCTAVEDLD)
#include <octave/${feval_header}>
#endif // (CODEGENTARGET == OCTAVEDLD)

#include "${sys}_def.h"
#include "${sys}_sympar.h"

#include "mtt_${algebraic_solver}.hh"

#include <fstream>
#if (CODEGENTARGET != OCTAVEDLD)

extern ColumnVector ${sys}_${ae} (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_input (
	const ColumnVector &x,
	const ColumnVector &y,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_logic (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_numpar (
	void);

extern ColumnVector ${sys}_simpar (
     	void);

extern ColumnVector ${sys}_state (
	const ColumnVector &par);

extern ColumnVector ${sys}_${ode} (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_${odeo} (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

EOF
case "$method" in
    "implicit")
	cat <<EOF >> $filename
extern ColumnVector Fmtt_implicit (
	ColumnVector &x,
	ColumnVector &dx,
	Matrix &AA,
	ColumnVector &AAx,
	const double &ddt,
	const int &nx,
	const ColumnVector &open_switches);

extern Matrix ${sys}_smxa (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);

extern ColumnVector ${sys}_smxax (
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par);
 
EOF
    ;;
    "dassl")
	cat <<EOF >> $filename
extern ColumnVector Fmtt_dassl (
	ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par,
	const ColumnVector &dx,
	const double &ddt,
	const int nx,
	const int nyz,
	const ColumnVector &open_switches);

EOF
    ;;
    "euler" | "rk4" | *)
	cat <<EOF >> $filename
extern ColumnVector Fmtt_euler (
	ColumnVector &x,
	const ColumnVector &dx,
	const double &ddt,
	const int &nx,
	const ColumnVector &open_switches);
 
EOF
    ;;
esac
cat <<EOF >> $filename

#endif // (CODEGENTARGET != OCTAVEDLD)

ColumnVector
mtt_ae (const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
    return ${sys}_${ae}(x,u,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    static octave_value_list args, f;
    args (0) = octave_value (x);
    args (1) = octave_value (u);
    args (2) = octave_value (t);
    args (3) = octave_value (par);
    f = feval ("${sys}_${ae}", args, 1);
    return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_input (const ColumnVector &x,
	   const ColumnVector &y,
	   const double &t,
	   const ColumnVector &par)
{
  static MTT::${algebraic_solver} ae(MTTNPAR,MTTNU,MTTNX,MTTNY,MTTNYZ);
  static ColumnVector u  (MTTNU);

#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  u = ${sys}_input (x, y, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (y);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_input", args, 1);
  u = f(0).${vector_value} ();
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  if (MTTNYZ == 0)
    {
      return u;
    }
  else
    {
      return ae.solve(x,u,t,par);
    }
}

inline ColumnVector
mtt_logic (const ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_logic (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_logic", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_numpar (void)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_numpar ();
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  f = feval ("${sys}_numpar", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_simpar (void)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_simpar ();
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  f = feval ("${sys}_simpar", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_state (const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_state (par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (par);
  f = feval ("${sys}_state", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_rate (const ColumnVector &x,
	  const ColumnVector &u,
	  const double &t,
	  const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_${ode} (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_${ode}", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_output (const ColumnVector &x,
	    const ColumnVector &u,
	    const double &t,
	    const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_${odeo} (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_${odeo}", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_zeroswitches (ColumnVector &x,
		  const int Nx,
		  const ColumnVector &openx)
{
  for (register int i = 0; i < Nx; i++) {
    if (0 != openx (i)) {
      x(i) = 0.0;
    }
  }
  return x;
}
  

EOF
case "$method" in
    "implicit")
	cat <<EOF >> $filename
inline ColumnVector
mtt_implicit (ColumnVector &x,
	      ColumnVector &dx,
	      Matrix &AA,
	      ColumnVector &AAx,
	      const double &ddt,
	      const int &nx,
	      const ColumnVector &open_switches)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return Fmtt_implicit (x, dx, AA, AAx, ddt, nx, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (AA);
  args (3) = octave_value (AAx);
  args (4) = octave_value (ddt);
  args (5) = octave_value ((double)nx);
  args (6) = octave_value (open_switches);
  f = feval ("mtt_implicit", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline Matrix
mtt_smxa (const ColumnVector &x,
	  const ColumnVector &u,
	  const double &t,
	  const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_smxa (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_smxa", args, 1);
  return f(0).matrix_value ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

inline ColumnVector
mtt_smxax (const ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   const ColumnVector &par)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return ${sys}_smxax (x, u, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_smxax", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

EOF
    ;;
    "dassl")
cat <<EOF >> $filename
inline ColumnVector
mtt_dassl (ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   const ColumnVector &par,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const int &nyz,
	   const ColumnVector &open_switches)
{
#if (CODEGENTARGET != OCTAVEDLD)
   return Fmtt_dassl (x, u, t, par, dx, ddt, nx, nyz, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
   static octave_value_list args, f;
    args (0) = octave_value (x);
    args (1) = octave_value (u);
    args (2) = octave_value (t);
    args (3) = octave_value (par);
    args (4) = octave_value (dx);
    args (5) = octave_value (ddt);
    args (6) = octave_value (static_cast<double> (nx));
    args (7) = octave_value (static_cast<double> (nyz));
    args (8) = octave_value (open_switches);
    f = feval ("mtt_dassl", args, 1);
    return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

#if (CODEGENTARGET != OCTAVEDLD)
ColumnVector
Fmtt_residual (const ColumnVector &X,
	      const ColumnVector &DX,
	      double t,
	      int &ires)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_residual, args, , "mtt_residual")
{
    static ColumnVector	X  (MTTNX+MTTNYZ);
    static ColumnVector	DX (MTTNX+MTTNYZ);
    static double      	t;
    static int		ires;

    X  = args(0).${vector_value} ();
    DX = args(1).${vector_value} ();
    t  = args(2).double_value ();
    ires = static_cast<int>(args(3).double_value ());
#endif // (CODEGENTARGET != OCTAVEDLD)

    static ColumnVector residual (MTTNX+MTTNYZ);
    static ColumnVector U (MTTNU+MTTNYZ);
    static ColumnVector u (MTTNU);
    static ColumnVector y (MTTNY,0.0);
    static ColumnVector par (MTTNPAR);
    static ColumnVector dx(MTTNX);
    static ColumnVector yz(MTTNYZ);

    static ColumnVector x (MTTNX);
    static ColumnVector ui (MTTNYZ);

    static octave_value_list new_args;

    x = X.extract (0,MTTNX-1);
    if (MTTNYZ > 0)
      ui = X.extract (MTTNX,MTTNX+MTTNYZ-1);    

#if (CODEGENTARGET != OCTAVEDLD)
    par = ${sys}_numpar();
    u = ${sys}_input(x,y,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    par = feval ("${sys}_numpar",  new_args, 1)(0).${vector_value} ();
    new_args(0) = octave_value (x);
    new_args(1) = octave_value (u);
    new_args(2) = octave_value (t);
    new_args(3) = octave_value (par);
    u = feval ("${sys}_input", new_args, 1)(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)

    U.insert (u,0);
    if (MTTNYZ > 0)
      U.insert (ui,MTTNU);

#if (CODEGENTARGET != OCTAVEDLD)
    dx = ${sys}_${ode} (x,U,t,par);
    yz = ${sys}_${ae} (x,U,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    new_args(1) = octave_value (U);
    dx = feval ("${sys}_${ode}", new_args, 1)(0).${vector_value} ();
    yz = feval ("${sys}_${ae}", new_args, 1)(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)

    for (register int i = 0; i < MTTNX; i++)
      residual (i) = dx(i) - DX(i);
    
    if (MTTNYZ > 0)
      {
	residual.insert (yz,MTTNX);

	// XXX:
	// DASSL needs residual to be dependent on Ui and Uidot
	// mtt_dassl always sets the initial Ui to zero, so
	// Ui - h*Uidot should equal zero BUT, we don't know h
	static double t_old;
	double step;
	if (t != t_old)
	  {
	    step = t - t_old;
	    t = t_old;
	  }
	else
	  step = t;	
	for (register int i = MTTNX; i < MTTNX+MTTNYZ; i++)
	  residual(i) += X(i) - DX(i)*step;
      }

#if (CODEGENTARGET != OCTAVEDLD)
    return residual;
#elif (CODEGENTARGET == OCTAVEDLD)
    return octave_value (residual);
#endif // (CODEGENTARGET != OCTAVEDLD)
}
    
EOF
    ;;
    "euler" | "rk4" | *)
cat <<EOF >> $filename
inline ColumnVector
mtt_euler (ColumnVector &x,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const ColumnVector &open_switches)
{
#if (CODEGENTARGET != OCTAVEDLD)
  return Fmtt_euler (x, dx, ddt, nx, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (ddt);
  args (3) = octave_value ((double)nx);
  args (4) = octave_value (open_switches);
  f = feval ("mtt_euler", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET != OCTAVEDLD)
}

EOF
    ;;
esac
cat <<EOF >> $filename

inline void
mtt_write (const double &t,
	   const ColumnVector &x,
	   const ColumnVector &y,
           const double &first,
	   const int &nrows,
	   const bool dump_data = false,
	   std::ostream &file = std::cout)
{
  static Matrix data;
  static int row;

  if (dump_data)
    {
       if (row > 0)
         {
           Matrix written_data = data.extract (0, 0, row-1, data.cols ()-1);
	   file $insertor "# name: mtt_dump" $insertor std::endl
		$insertor "# type: matrix" $insertor std::endl
		$insertor "# rows: " $insertor written_data.rows () $insertor std::endl
		$insertor "# columns: " $insertor written_data.columns () $insertor std::endl
		$insertor written_data;
	   file.flush ();
	 }
       return;
    }

  const int nx = x.length (), ny = y.length ();
  register int col = 0;

  if (0 == row)
    data = Matrix (nrows, 1+ny+1+nx, 0.0);

  if (t >= first) {
  data.elem (row, col) = t;
  for (register int i = 0; i < ny; i++)
    data.elem (row, ++col) = y.elem (i);
  data.elem (row, ++col) = t;
  for (register int i = 0; i < nx; i++)
    data.elem (row, ++col) = x.elem (i);

  row++;
  };

  static std::fstream fcputime ("MTT.cputime", std::ios::out | std::ios::trunc | std::ios::app);
  static clock_t cputime0 = clock();
  static clock_t cputime1 = cputime0;
  clock_t cputime = clock();
  fcputime $insertor t $insertor '\t'
	   $insertor static_cast <double> (cputime - cputime0) / CLOCKS_PER_SEC $insertor '\t'
	   $insertor static_cast <double> (cputime - cputime1) / CLOCKS_PER_SEC $insertor std::endl;
  cputime1 = cputime;

  if (nrows == row)
    {
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == RTXI))
      file $insertor "# name: mtt_dump" $insertor std::endl
	   $insertor "# type: matrix" $insertor std::endl
	   $insertor "# rows: " $insertor data.rows () $insertor std::endl
	   $insertor "# columns: " $insertor data.columns () $insertor std::endl
	   $insertor data;
      file.flush ();
#elif ((CODEGENTARGET == OCTAVEDLD) || (CODEGENTARGET == MATLABMEX))
  set_global_value ("MTT_data", data);
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == RTXI))
    row = 0;
    fcputime.close();
    }
}

#if (CODEGENTARGET == RTXI)
#include "${sys}_rtxi.h"
void
${sys}::execute(void)
{
  static ColumnVector simpar (8), par (MTTNPAR), state0 (MTTNX);

  simpar	= mtt_simpar ();
  par		= mtt_numpar ();
  state0	= mtt_state (par);
  
#else

void
${sys}_ode2odes (const ColumnVector &state0,
		 const ColumnVector &par,
		 const ColumnVector &simpar)
{
#endif // (CODEGENTARGET == RTXI)
  static double first, dt, last, stepfactor;
  first		= simpar (0);
  last		= simpar (1);
  dt		= simpar (2);
  stepfactor	= simpar (3);

  static ColumnVector	dx (MTTNX, 0.0);
  static ColumnVector	x (MTTNX, 0.0);
  static ColumnVector	u (MTTNU, 0.0);
  static ColumnVector	y (MTTNY, 0.0);

  static Matrix	AA (MTTNX, MTTNX, 0.0);
  static ColumnVector	AAx (MTTNX, 0.0);
  
  static ColumnVector	open_switches (MTTNX, 0.0);

  register double t	= 0.0;

  const double	ddt	= dt / stepfactor;
  const int	ilast	= static_cast<int> (round ( last  / ddt)) + 1;
  const int	nrows	= static_cast<int> (round ((last - first) / dt)) + 1;

  for (register int i = 0; i < MTTNY; i++)
    {
      y (i) = 0.0;
#if (CODEGENTARGET == RTXI)
      output(i) = y(i);
#endif // (CODEGENTARGET == RTXI)
    }

  for (register int i = 0; i < MTTNX; i++)
    {
      x (i) = state0 (i);
    }

  for (register int j = 0, i = 1; i <= ilast; i++)
    {
#if (CODEGENTARGET != RTXI)
      u	= mtt_input (x, y, t, par);
#else
      for (register int i = 0; i < MTTNU; i++) {
	u(i) = input(i);
      }
#endif // (CODEGENTARGET != RTXI)
      y	= mtt_output (x, u, t, par);
      if (0 == j)
	{
#if (CODEGENTARGET != RTXI)
	  mtt_write (t, x, y, first, nrows);
#else
	  for (register int i = 0; i < MTTNU; i++) {
	    output(i) = y(i);
	  }
#endif // (CODEGENTARGET != RTXI)
	}
EOF
case "$method" in
    "rk4")
	cat << EOF >> $filename
      {
        static ColumnVector
          k1 (MTTNX,0.0),
          k2 (MTTNX,0.0),
          k3 (MTTNX,0.0),
          k4 (MTTNX,0.0);

        const double
          t1 = t + ddt/2.0,
          t2 = t + ddt;

        ColumnVector
          x1 (x),
          x2 (x),
          x3 (x);

        k1 = ddt * mtt_rate (x , u, t , par); x1 += k1 * 0.5;
        k2 = ddt * mtt_rate (x1, u, t1, par); x2 += k2 * 0.5;
        k3 = ddt * mtt_rate (x2, u, t1, par); x3 += k3;
        k4 = ddt * mtt_rate (x3, u, t2, par);
        dx = (k1 + 2.0 * (k2 + k3) + k4) / (6.0 * ddt);
      }
EOF
    ;;
    "dassl")
    ;;
    "implicit")
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, par);
      AA = mtt_smxa (x, u, ddt, par);
      AAx = mtt_smxax (x, u, ddt, par);
EOF
    ;;
    "euler" | *)
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, par);
EOF
    ;;
esac

## Common stuff
cat <<EOF >> $filename
      open_switches = mtt_logic (x, u, t, par);
      x =  $algorithm; 
      open_switches = mtt_logic (x, u, t, par);
      x = mtt_zeroswitches (x, $Nx, open_switches);
      t += ddt;
      j++;
      j = (j == static_cast<int> (stepfactor)) ? 0 : j;
    }

}

#if (CODEGENTARGET == STANDALONE)
#include <csignal>

void set_signal_handlers (void);

void dump_data (std::ostream &file)
{
  ColumnVector null (0);
  mtt_write (0.0, null, null, 0, 0, true, file);
}

void handle_signal (int signum)
{
  // handle some signals to ensure data is written.
  std::cerr $insertor "# Writing data to MTT.core (signal " $insertor signum $insertor ")" $insertor std::endl;
  std::ofstream corefile ("MTT.core");
  dump_data (corefile);
  switch (signum)
    {
      case SIGFPE:
        // Intel chips do not raise SIGFPE for DIVZERO :-(
	// raise (SIGABRT);
        break;
      case SIGINT:
	break;
      case SIGQUIT:
	signal (SIGQUIT, SIG_DFL);
	raise (SIGQUIT);
	break;
      default:
        std::cerr $insertor "# Warning: make_ode2odes needs updating!" $insertor std::endl;
	signal (signum, SIG_DFL);
	raise (signum);
        break;
    }
  corefile.close ();
  set_signal_handlers ();
}

void set_signal_handlers (void)
{
  signal (SIGFPE,	handle_signal);
  signal (SIGINT,	handle_signal);
  signal (SIGQUIT,	handle_signal);
}

int
main (void)
{
  set_signal_handlers ();

  static ColumnVector simpar (8), numpar (MTTNPAR), state0 (MTTNX);

  simpar	= mtt_simpar ();
  numpar	= mtt_numpar ();
  state0	= mtt_state (numpar);

  ${sys}_ode2odes (state0, numpar, simpar);

  return 0;
}
#elif (CODEGENTARGET == OCTAVEDLD)
#include <mtt_simpar.hh>

DEFUN_DLD (${sys}_ode2odes, args, ,
"Octave ode2odes representation of system with $method integration method\nUsage: mtt_data = ${sys}_ode2odes (state0, numpar, simpar)\n")
{
  static octave_value_list retval;

  static ColumnVector	state0 (MTTNX);
  static ColumnVector	numpar (MTTNPAR);
  static ColumnVector	simpar (8);
  
  int nargin = args.length ();
  switch (nargin)
    {
    case 3:
      simpar	= mtt_simpar (args(2).map_value ());
      numpar	= args(1).${vector_value} ();
      state0	= args(0).${vector_value} ();
      break;
    case 2:
      simpar	= mtt_simpar ();
      numpar	= args(1).${vector_value} ();
      state0	= args(0).${vector_value} ();
      break;
    case 1:
      simpar	= mtt_simpar ();
      numpar	= mtt_numpar ();
      state0	= args(0).${vector_value} ();
      break;
    case 0:
      simpar	= mtt_simpar ();
      numpar	= mtt_numpar ();
      state0	= mtt_state (numpar);
      break;
    default:
      usage("${sys}_ode2odes (x par simpar)", nargin);
      error("aborting.");
    }

  ${sys}_ode2odes (state0, numpar, simpar);
    
  retval = octave_value (get_global_value ("MTT_data"));
  return (retval);
}
#elif (CODEGENTARGET == MATLABMEX)
#include <mtt_matlab_octave.hh>

extern "C" {
  void
  mexFunction (int nlhs, mxArray *plhs[],
	       int nrhs, const mxArray *prhs[])
  {
    static ColumnVector	state0 (MTTNX);
    static ColumnVector	numpar (MTTNPAR);
    static ColumnVector	simpar (8);

    initialize_symbol_tables ();
    
    switch (nrhs)
      {
      case 3:
	simpar	= mtt_ColumnVector (prhs[2]);
	numpar	= mtt_ColumnVector (prhs[1]);
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 2:
	simpar	= mtt_simpar ();
	numpar	= mtt_ColumnVector (prhs[1]);
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 1:
	simpar	= mtt_simpar ();
	numpar	= mtt_numpar ();
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 0:
	simpar	= mtt_simpar ();
	numpar	= mtt_numpar ();
	state0	= mtt_state (numpar);
	break;
      default:
	std::cerr $insertor "usage: ${sys}_ode2odes (x par simpar)" $insertor std::endl;
	return;
      }

    ${sys}_ode2odes (state0, numpar, simpar);

    plhs[0] = mtt_mxArray (get_global_value ("MTT_data").matrix_value ());
  }
}

#endif // (CODEGENTARGET == STANDALONE)

EOF
}

case ${lang} in
    m)
        make_m	
	;;
    cc)
	make_cc
	;;
    *)
	echo Language ${lang} is not supported
esac

Deleted mttroot/mtt/bin/trans/make_sim version [266de8bd1f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Makes the sensitivity simulation
## Copyright (C) 2001 by Peter J. Gawthrop

sys=$1
lang=$2

outfile=${sys}_sim.${lang}

echo Creating $outfile

make_m() {
mtt_header ${sys} sim m  >  ${outfile}
cat >> ${outfile} <<EOF

 ## Pass input as a global
 global MTT_input MTT_input_index MTT_input_last

  [nx,ny] = ${sys}_def;
  y_par = [];
  MTT_input = u;
  [MTT_input_last,m] = size(u);

  MTT_input_index = 0;
  [mtt_data] = ${sys}_ode2odes(x0,par,simpar);
  y = mtt_data(:,2:1+ny);
  x = mtt_data(:,3+ny:2+ny+nx);
  ypar = [];

  if nargout>2
    ## Create time vector
    [N,M] = size(y);
    t = mtt_data(:,1);
  endif;

endfunction
EOF

}

case ${lang} in
    m)
	make_m
	;;
    *)
	echo Language ${lang} not supported - sorry
esac

Deleted mttroot/mtt/bin/trans/make_ssim version [c5f9aeda27].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Makes the sensitivity simulation
## Copyright (C) 2001 by Peter J. Gawthrop

sys=$1
lang=$2

outfile=${sys}_ssim.${lang}

echo Creating $outfile
make_m() {
mtt_header ${sys} ssim m >  ${outfile}
cat >> ${outfile} <<EOF

  ## Pass input as a global
  global MTT_input MTT_input_index MTT_input_last

  if nargin>4  
    [n,m] = size(index);
    if (n>m)       # Make sure its a row vector
      index = index';
    endif
  endif

  [nx2,ny2] = ${sys}_def;
  y_par = [];
  MTT_input = u;
  [MTT_input_last,m] = size(u);

  if nargin<5			# No index given
    MTT_input_index = 0;
    [mtt_data] = ${sys}_ode2odes(x0,par,simpar);
    y = mtt_data(:,2:2:1+ny2);
    x = mtt_data(:,3+ny2:2:2+ny2+nx2);
    ypar = [];
  else				# Compute sensitivities as well
    for i=index
      MTT_input_index = 0;
      p = par;           # Reset parameters
      p(i) = 1;          # Set sensitivity index to 1
      [mtt_data] = ${sys}_ode2odes(x0,p,simpar);
      if (i==index(1))
	y = mtt_data(:,2:2:1+ny2);
      endif
      y_par = [y_par, mtt_data(:,3:2:2+ny2)];
      x = mtt_data(:,3+ny2:2+ny2+nx2);
    endfor
  endif

  if nargout>3
    ## Create time vector
    [N,M] = size(y);
        t = mtt_data(:,1);
  endif;

endfunction
EOF

}

case ${lang} in
    m)
	make_m
	;;
    *)
	echo Language ${lang} not supported - sorry
esac

Deleted mttroot/mtt/bin/trans/make_stdin version [912a3db110].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174














































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

## 	$Id$	

# Copyright (C) 1999,2000 by Peter J. Gawthrop

# Tell user
Sys=$1
lang=$2
date=`date`
outfile=$1_input.$2

Nu=`mtt_getsize ${Sys} u` # Inputs 
echo  "Creating $outfile for standard input"

## Pascal code
make_p()
{
cat <<EOF > $outfile
PROCEDURE ${Sys}_input(VAR mttu : InputVector;
                       mttx : StateVector;
                       mtty : OutputVector;
                       mttt : REAL;
                       par  : ParameterVector);

{Created by MTT on $date for standard input to simulation}

VAR t : REAL; Start:BOOLEAN;

BEGIN{${Sys}_input}
  {Zap comments}
  IF (input^ = chr("#")) THEN
  BEGIN
    readln;
    WHILE (input^ = chr("#")) DO readln;
  END;

  read(t); { Read, and discard, first column (time) }
  FOR mtti:=1 TO $Nu DO {Read the inputs}
    read(mttu[mtti]);
  readln; {Next line}


END{${Sys}_input};
EOF
}

make_m() {
mtt_header ${Sys} input m stdin > $outfile
cat >> $outfile <<EOF
## The "standard input"
global MTT_input MTT_input_index MTT_input_last
  
  MTT_input_index = min(++MTT_input_index,MTT_input_last);
  mttu = MTT_input(MTT_input_index,:);
## END Code
endfunction
EOF

}


make_cc() {
cat > $outfile <<EOF
// -*-c++-*- Put emacs into c++-mode

// 
// System ${Sys}, representation input, language oct; 
// File ${Sys}_input.oct; 
// Generated by MTT on `date`; 

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
#include <octave/oct.h>
#include "${Sys}_def.h"

void strip_comments (istream &str)
{
  char c;
  c = str.peek ();
  while (c == '#')
    {
      str.unsetf(ios::skipws);
      while (c != '\n')
	{
	  str >> c;
	}
      str.setf(ios::skipws);
      c = str.peek ();
    }
}

ColumnVector ${Sys}_input (
	ColumnVector	&mttx,
	ColumnVector	&mtty,
	const double	&mttt,
	ColumnVector	&mttpar
)
{
#elif (CODEGENTARGET == OCTAVEDLD)
#include <octave/oct.h>
#include <variables.h>
#include "${Sys}_def.h"

DEFUN_DLD (${Sys}_input, args, ,
"Usage: [mttu] = ${Sys}_input()\n\
Octave input (-stdin) representation of system ${Sys}\n\
Generated by MTT on `date`")
{

  octave_value_list retval;
#endif // (CODEGENTARGET == STANDALONE)

  ColumnVector	mttu	(MTTNU);

  // Set up the mttu vector
#if (CODEGENTARGET == OCTAVEDLD)
  int MTT_input_index	= static_cast<int>(get_global_value ("MTT_input_index").double_value ());
  int MTT_input_last	= static_cast<int>(get_global_value ("MTT_input_last").double_value ());
  Matrix MTT_input 	= get_global_value ("MTT_input").matrix_value();

  mttu = MTT_input.row (MTT_input_index);

  if (MTT_input_index < (MTT_input_last - 1))
    {
      set_global_value ("MTT_input_index", static_cast<double>(++MTT_input_index));
    }
  
#elif (CODEGENTARGET == STANDALONE)
  double t, u;
  strip_comments (cin);
  cin >> t;
  for (register int i = 0; i < MTTNU; i++)
    {      
      cin >> u;
      mttu(i) = u;
    }
#endif // (CODEGENTARGET == OCTAVEDLD)


#if (CODEGENTARGET == OCTAVEDLD)
  retval (0)	= octave_value (mttu);
  return (retval);
}
#elif (CODEGENTARGET == STANDALONE)
  return mttu;
}
#endif // (CODEGENTARGET == OCTAVEDLD)
EOF
}

case $lang in
    p)
	make_p 
	;;
    m)
	make_m
	;;
    cc)
	make_cc
	;;
    *)
	echo language $lang not supported - sorry
esac

Deleted mttroot/mtt/bin/trans/makecr version [b85c8207c2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makecr

# Copyright (c) P.J.Gawthrop 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1996/09/12 12:06:38  peter
## Removed reducndant lines.
##
## Revision 1.3  1996/09/12 12:05:01  peter
## Removed default crs.
##
## Revision 1.2  1996/09/10 16:18:37  peter
## Uses default constitutive relationship mtt/cr/r
##
## Revision 1.1  1996/08/24 14:53:06  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_cr.r

echo % Default CR file			>  $1_cr.r
echo % File $1_cr.r			>> $1_cr.r
echo % Generated by MTT on `date`.	>> $1_cr.r
echo					>> $1_cr.r
cat $MTTPATH/trans/m/rcs_header.txt	>> $1_cr.r
echo 'END;'				>> $1_cr.r








Deleted mttroot/mtt/bin/trans/makedesc version [3172bb98c8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: maketex
# Makes template for (TeX) system description.

# P.J.Gawthrop August 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1999/03/03 01:07:27  peterg
## Label the figure correctely,
##
## Revision 1.3  1998/07/22 08:58:51  peterg
## Corrected spelling.
##
## Revision 1.2  1997/05/21 10:00:51  peterg
## Tidied up.
##
## Revision 1.1  1997/05/21 09:19:27  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_desc.tex

echo '% -*-latex-*- Put EMACS into LaTeX-mode' > $1_desc.tex
echo "% Verbal description for system $1 ($1_desc.tex)" >> $1_desc.tex
echo "% Generated by MTT on" `date`. >> $1_desc.tex                  	   
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_desc.tex

cat<<EOF >> $1_desc.tex
The acausal bond graph of system \textbf{$1} is
displayed in Figure \Ref{fig:$1_abg.ps}  
EOF

if [ -e "$1_pic.fig" ]; then
cat<<EOF >> $1_desc.tex
and the schematic diagram in Figure \Ref{fig:$1_pic.ps}
EOF
fi
   
cat<<EOF >> $1_desc.tex
.
The label file is listed in Section \Ref{sec:$1_lbl} and the
subsystems are listed in Section \Ref{sec:$1_sub}.
EOF

Deleted mttroot/mtt/bin/trans/makedoc version [4df074a97b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makedoc
# Encapsulates a tex file in a document.

# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/27 15:53:42  peterg
## Initial revision
##
## Revision 1.1  1997/05/17 13:55:42  peterg
## Initial revision
##
# Revision 1.2  1997/04/23  10:06:51  peterg
# Put output in the correct file!
#
# Revision 1.1  1997/04/23  10:03:41  peterg
# Initial revision
#
###############################################################

date=`date`
switches=$1
system=$2
representation=$3
lang=$4
args=$5
documenttype=$6
ps=$7

if [ "$documenttype" = "book" ]; then
  document=book
else
  document=article
fi

if [ "$documenttype" = "book" ]||[ "$documenttype" = "article" ]; then
    title="\title{Report on $system}"
else
    title="\title{System $system, representation $representation}"
fi

filename=$2_$3.doc
texname=$2_$3.tex
indexname=$2_$3.ind

# Inform user
echo "Creating $filename"
# Make arguments acceptable to LateX
Args=`echo $args | sed 's/_/\\\_/g'`

cat<<EOF  > $filename 
\nonstopmode
\documentclass[12pt,a4paper]{$document}
    $title
    \author{Generated by MTT using :\\\\
     (mtt $switches $system $representation $lang $Args)}
    \date{$date}
EOF

if [ "$documenttype" = "book" ]; then
  cat <<EOF   >> $filename 
  \makeindex
EOF
fi


##cp -v $MTTPATH/trans/*.sty .
##cat  >> $filename <<EOF
##\usepackage{mtt_$ps}
##EOF

## Explicitly include style files - avoids latex2html problem
cat $MTTPATH/trans/mtt.sty $MTTPATH/trans/mtt_$ps.sty >> $filename

cat <<EOF  >> $filename 
\begin{document}
  \maketitle
EOF

if [ "$documenttype" = "book" ]||[ "$documenttype" = "article" ]; then
  cat $MTTPATH/trans/contents.tex >> $filename
fi

cat <<EOF  >> $filename 
%Fancy headings
  \pagestyle{fancy}
  \renewcommand{\sectionmark}[1]{\markboth{#1}{}}
  \lhead{Report \textbf{$system}}
  \rhead{Representation \textbf{$representation}}
  \rfoot{Page \thepage.}\cfoot{}
  \lfoot{\emph{$date}}

  \input{$texname}
EOF

if [ "$documenttype" = "book" ]; then
  cat <<EOF   >> $filename 
  \input{$indexname}
EOF
fi

cat<<EOF  >> $filename 
\end{document}
EOF












Deleted mttroot/mtt/bin/trans/makerep_txt version [62dfdf7ad4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makerep_tex
# Makes template for (TeX) system description.

# P.J.Gawthrop July 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2000/11/15 10:56:45  peterg
## Added state tex
##
## Revision 1.5  2000/11/04 12:32:43  peterg
## Added more reps + more default reps
##
## Revision 1.4  1999/03/02 22:02:16  peterg
## Octave-mode style
##
## Revision 1.3  1998/11/18 10:47:39  peterg
## Added transfer function rep
##
## Revision 1.2  1998/11/10 09:16:41  peterg
## Added structure rep
##
## Revision 1.1  1998/07/22 09:14:42  peterg
## Initial revision
##
###############################################################


#Inform user
echo Creating $1_rep.txt

cat <<EOF > $1_rep.txt
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system $1 ($1_rep.txt)
## Generated by MTT on" `date`.

EOF

cat $MTTPATH/trans/rcs_header.sh >> $1_rep.txt

cat <<EOF >> $1_rep.txt
mtt $1 abg tex			# The system description
mtt $1 cbg ps 		        # The causal bond graph
mtt $1 struc tex	        # The system structure
mtt $1 sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt $1 dae tex	        # The system dae
## mtt $1 ode tex	        # The system ode 
## mtt $1 sspar tex		# Steady-state parameters
## mtt $1 ss tex 		# Steady state
## mtt $1 dm tex		# Descriptor matrices (of linearised system)
## mtt $1 sm tex		# State matrices (of linearised system)
## mtt $1 tf tex		# Transfer function (of linearised system)
## mtt $1 lmfr ps		# log modulus of frequency response (of linearised system)
## mtt $1 simpar txt		# Simulation parameters
## mtt $1 numpar txt		# Numerical simulation parameters
## mtt $1 state txt		# Simulation initial state
## mtt $1 input txt		# Simulation input
## mtt $1 logic txt		# Logic control
## mtt $1 odeso ps		# Simulation output

## mtt $1 rep txt		# This file
EOF

Deleted mttroot/mtt/bin/trans/makesspar version [52aff62f6f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makesspar
# Makes default sspar file: all states zero.

# P.J.Gawthrop February 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/02/09 14:13:39  peterg
## Put octave stuff to /dev/null
##
## Revision 1.2  1998/02/09 08:39:27  peterg
## Set inputs to zero as well.
##
## Revision 1.1  1998/02/06 15:53:49  peterg
## Initial revision
##
###############################################################


#Inform user
echo Creating $1_sspar.r

echo "% Steady-state parameters for system $1 ($1_sspar.r)"> $1_sspar.r
echo "% Generated by MTT on" `date`. >> $1_sspar.r                  	   
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_sspar.r
echo "% Set all states and inputs to zero" >> $1_sspar.r                  	   

$MATRIX  <<EOF >> /dev/null

fnum=fopen("$1_sspar.r","at");

[nx,ny,nu,nz,nyz] = $1_def;

for i = 1:nx
  fprintf(fnum,"MTTX%i := 0;\n", i);
end;
fprintf(fnum,"\n");
for i = 1:nu
  fprintf(fnum,"MTTU%i := 0;\n", i);
end;
   
  
EOF

 
echo "END;;" >> $1_sspar.r   

Deleted mttroot/mtt/bin/trans/makesubs version [409b406455].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: makesubs
# Makes the default substitution file

# Copyright (C) 2000 by Peter J. Gawthrop


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.1  2000/12/28 09:09:52  peterg
## Initial revision
##
##
###############################################################

#Inform user
echo Creating $1_subs.r

cat > $1_subs.r <<EOF
% Default SUBS file
% File $1_subs.r
% Generated by MTT on `date`.

EOF

cat $MTTPATH/trans/m/rcs_header.txt	>> $1_subs.r

cat >> $1_subs.r <<EOF
% Put algebraic substitution commands here
FOR ALL i LET arbint(i) = 0; % Zap arbitary constants
END;
EOF


exit

## NB the following messes up the expansion switch ????
cat >> $1_subs.r <<EOF
% Ordering switch
ORDER
EOF

# Symbolic params first
gawk '{
  print $1 ","
}' < $1_sympar.txt >> $1_subs.r

# Then states
Nx=`mtt_getsize $1 x` # States

gawk 'END{
  for (k=1;k<Nx;k++){
    printf("mttx%i,\n", k);
  }
    printf("mttx%i;\n", Nx);
  
}' Nx=$Nx < $1_sympar.txt >> $1_subs.r

cat >> $1_subs.r <<EOF
END;
EOF









Deleted mttroot/mtt/bin/trans/matlab_header version [f6f0a00194].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: matlab_header
# Generic octave function header


#Write some file headers
echo "function [$3] = $1_$2" 
echo "% $2 function for system $1 ($1_$2.m)"   
echo "% Generated by MTT at `date`"  
echo  

#Globals
sympar2global_txt2m $1 
echo  ';'
echo  



Deleted mttroot/mtt/bin/trans/matlab_matrix.r version [d9d59df9cf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in matlab form
% P.J.Gawthrop  March 1998
% Copyright (c) P.J.Gawthrop, 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/03/22 10:26:47  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'FORTRAN;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 400;

PROCEDURE matlab_Matrix;
BEGIN
  ON NERO;
  write "mtt_matrix = zeros(", mtt_matrix_n, ",", mtt_matrix_m, ");";
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
    FOR i := 1:MTT_Matrix_n DO
      IF MTT_Matrix_m>1 THEN
        BEGIN
          FOR j := 1:MTT_Matrix_m DO 
            GENTRAN mtt_matrix(i,j) ::=: mtt_matrix(i,j);
        END
        ELSE
        BEGIN
         GENTRAN mtt_matrix(i) ::=: mtt_matrix(i,1);
        END;
    END;
  write MTT_matrix_name, " = mtt_matrix;";
END;

END;;


Deleted mttroot/mtt/bin/trans/matlab_tidy version [3301711ae7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.3  1997/08/28  13:41:57  peterg
# Removes translation of:
# mttx
# mttdx
# mtty
# mttu
#
# Revision 1.2  1996/08/20  08:26:06  peter
# Version control header added.
#
###############################################################

# Bourne shell script: matlab_tidy
# Tidies up Matlab format files
# P.J.Gawthrop 14 June 1990 13 Nov 1990, 19 Nov 93, April 1994, Dec 1994, 
# June 1995
# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995.

#rm junk
#tr "[A-Z]" "[a-z]" | \

cat $1 | \
sed -e "s/      //" \
    -e "s/      //" \
    -e "s/\$\$//" \
    -e "s/\.\.;;/../" \
    -e "s/\$/;/g" \
    -e "s/;;;//g" \
    -e "s/;;/;/g" \
    -e "s/\.;/./g" \
    -e "s/,;/,/g" \
    -e "s/\*\*/^/g" \
    -e "s/nocr /nocr/g" \
    -e "s/nocr\\nl/nocr/g" \
    -e "s/;;/;/g" \
    -e "s/:=/=/g" \
    -e "s/ e  /e/g" \
    -e "s/*;/* .../g" \
    -e "s/+;/+ .../g" \
    -e "s/     . //g" \
    -e "s/^;$//g" \
    -e "s/\.\.\\$/../g"  \
    -e "s/\\$/;/g"  \
    -e "s/inv(mtte)\*/mtte\\\/g"\
    -e "s/\\$//" |\
tr -s '\012' '\012'\
>junk
mv junk $1




Deleted mttroot/mtt/bin/trans/modpar_txt2r version [46d5afca36].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: modpar_txt2r
# Creates the reduce code for modulated parameters

# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $$Id$
## $Log$
## Revision 1.2  2002/04/16 11:36:03  gawthrop
## These were flagged with M on cvs update
##
## Revision 1.1  2001/04/02 08:19:18  gawthrop
## Translates modulated parameters into reduce
##
###############################################################

# Inform user
echo Creating $1_modpar.r

#Create the modpar file complete with headers.
echo "% Modpar file ($1_modpar.r)" > $1_modpar.r
echo "% Generated by MTT at `date`" >> $1_modpar.r

parameters=`strip_comments < $1_modpar.txt |  cut -f1`
inputs=`strip_comments < $1_modpar.txt |  cut -f2`


for parameter in $parameters; do
    grep $1_${parameter}_ $1_struc.txt |\
    gawk 'BEGIN{
               name["input"] = "u";
               name["output"] = "y";
               name["state"] = "x";
               name["nonstate"] = "z";
	      }
	 {
           printf("%s := mtt%s(%i,1);\n", parameter, name[$1],  $2)
         }' parameter=$parameter >> $1_modpar.r
done

Deleted mttroot/mtt/bin/trans/mtt.sty version [bc0db184f2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% mtt.sty -- LaTeX style file for MTT
% P.J.Gawthrop May 1997
% Copyright (c) P.J.Gawthrop, 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.11  2009/06/26 01:09:50  geraint
% %% fancyheadings is deprecated, replaced by fancyhdr
% %%
% %% Revision 1.10  2005/03/15 13:36:17  gawthrop
% %% Pretty abg figure in reports.
% %%
% %% Revision 1.9  2003/05/08 18:43:02  gawthrop
% %% Generate pdf from ps (using hyperref package for links etc)
% %%
% %% Revision 1.8  2000/12/01 14:15:16  peterg
% %% Removed hyperref stuff to mtt_pdf.sty
% %%
% %% Revision 1.7  2000/11/28 18:28:29  peterg
% %% Removed fancy box - messes up TOC
% %%
% %% Revision 1.6  2000/11/28 18:09:06  peterg
% %% Tidied up:
% %% added hyperef
% %% put fig stuff into mtt_ps.sty and mtt_pdf.sty
% %%
% %% Revision 1.5  1998/11/23 10:45:49  peterg
% %% Reinstated supertabular
% %%
% %% Revision 1.4  1998/07/01 17:34:43  peterg
% %% No change
% %%
% %% Revision 1.3  1997/12/06 16:22:10  peterg
% %% Added another argument - the label.
% %%
% %% Revision 1.2  1997/12/06 15:51:06  peterg
% %% Cahged order of fig args to put file first.
% %%
% %% Revision 1.1  1997/05/19 16:48:10  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Font
\usepackage{times}
%%\usepackage{mathptm}

%Verbatim file input
\usepackage{verbatim}
\usepackage{moreverb}

%Long tables
\usepackage{supertabular}

%AMS maths
  \usepackage{amsmath}

%Fancy headings
  %%\usepackage{fancyheadings}
  \usepackage{fancyhdr}

%Fancy boxes
%\usepackage{fancybox}


% Read in a verbatim file
\newcommand{\txt}[2]{
  \subsubsection*{#1}
  \verbatimtabinput{#2}
}

% Read in a LaTeX file
\newcommand{\Input}[1]{
  \input{#1}
}


% Page refs as well.
\newcommand{\Ref}[1]{\ref{#1} (on page \pageref{#1})}

%% Latex in figures etc
\newcommand{\B}[1]{\text{\sffamily\textbf{#1}}}
\newcommand{\BB}[2]{$\B{#1}$:$\mathbf{#2}$}

Deleted mttroot/mtt/bin/trans/mtt2reps_txt version [14bdc5a92e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

# mtt2reps_txt: Gives a tabular listing of representations and languages
# P J Gawthrop July 1998, October 1998
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/07/24 04:18:32  gawthrop
## Fixed problem with shell expanding * (used as important rep marker)
##
## Revision 1.11  2001/04/28 03:38:36  geraint
## Refined selection of matching patterns - checks for exact match.
##
## Revision 1.10  2000/09/14 07:54:13  peterg
## Removed -e option in echo
##
## Revision 1.9  2000/04/05 08:34:30  peterg
## removed output tab
##
## Revision 1.8  2000/04/05 08:04:01  peterg
## Minor reorganisation
##
## Revision 1.7  2000/04/04 16:15:14  peterg
## Fixed awk prob - must be the same sep. for each field (?)
## So tr tab to space
##
## Revision 1.6  2000/04/04 13:09:51  peterg
## *** empty log message ***
##
## Revision 1.5  2000/01/19 17:26:12  peterg
## Now includes the representation title.
##
## Revision 1.4  1999/03/09 00:03:06  peterg
## Revisions for xmtt
##
## Revision 1.3  1999/03/08 21:24:43  peterg
## Handles * representations:
##
## 	rep* is special
##         rep shows all possible languages
##
## Revision 1.2  1999/03/08 06:34:07  peterg
## Removed mtt help - replaced by grep #SUMMARY - quicker
##
## Revision 1.1  1998/10/20 08:15:08  peterg
## Initial revision
##
###############################################################

sep='|'; # Separates the languages from the rest.

## List of all representations (deleting the *)
representations=`grep '#SUMMARY' $MTTPATH/mtt | gawk '{sub("\*","+"); print $2'} | sort -u `


for rep in $representations ; do
    Rep=`echo $rep | tr '+' '*'`
    ## Title should be same for all languages -- but extract the first non-empty version
      title=`grep '#SUMMARY' $MTTPATH/mtt | tr '\t' ' ' | grep "[ *]$Rep[ *]" | \
      gawk  '{if (NF>2) {for (i=3;i<NF-1;i++) printf("%s ",$i); NF1=NF-1; printf("%s\n",$NF1)}}' |\
      head -1`
      
    language=`grep '#SUMMARY' $MTTPATH/mtt |\
      gawk '
        {
          if (index(rep,"*")==length(rep)){
            if ($2==rep) print $NF
          }
          else
            if (($2==rep)||($2==sprintf("%s*",rep))) print $NF
        }' rep=$Rep |\
      sort -u | sed 's/[()]//g'` 

      Title='('$title')'
      echo "$Rep" $Title  $sep $language
     
done




Deleted mttroot/mtt/bin/trans/mtt_error version [36e03ad5ab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_error
# Does the error handing for transformations and forces error exit.
# P.J.Gawthrop  August 1996
# Copyright (c) P.J.Gawthrop, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2000/12/28 12:34:49  peterg
## Put under RCS
##
## Revision 1.7  1998/03/06 17:14:09  peterg
## Cospetic change to message
##
## Revision 1.6  1998/03/05 10:17:41  peterg
## Cosmetic change
##
## Revision 1.5  1998/03/05 10:14:37  peterg
## Toned down the error warning message
##
## Revision 1.4  1998/02/26 10:21:51  peterg
## Revised to take account of new (??) wc output - now echos the file
## name (??)
##
## Revision 1.3  1998/02/25 21:35:00  peterg
## Put "" round if argument in case $err_length is null.
##
## Revision 1.2  1996/08/26 09:46:37  peterg
## Changed $() to ``
##
# Revision 1.1  1996/08/25  09:20:00  peter
# Initial revision
#
###############################################################

error_file=$1;

# Test for errors and print if any
err_length=`wc -c <$error_file | gawk '{print $1}'`
if [ "$err_length" != "0" ]
then
    echo "INFORMATION: An MTT transformation has generated the following messages"
#  echo "             (which may not be important)"
  cat $error_file
  exit 1
else
  exit 0
fi

Deleted mttroot/mtt/bin/trans/mtt_error_r version [8500aa4349].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_error_r
# Does the error handing for transformations and forces error exit.
# This is the version for resuce which does not use error output.
# P.J.Gawthrop  August 1996
# Copyright (c) P.J.Gawthrop, 1996

log_file=$1

#Reduce writes errors to std output with ***** in front.
grep '\*\*\*\*\*' $log_file >mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt

Deleted mttroot/mtt/bin/trans/mtt_fix_integers version [511eb60f9c].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

mttmatrix='\(mtt[A-Za-z][A-Za-z]*\)'
integer='\([0-9][0-9]*\)'

mtt_join_lines | gawk -v RS=${1:-"$"} -v ORS=${2:-"$\n"} ' {
str = $0;
str1 = gensub ( /([^A-Za-z_0-9\.\+])([0-9]+)([^\.0-9])/ , "\\1\\2.0\\3" , "g", str );
str2 = gensub ( /([^e]\+)([0-9]+)([^\.0-9])/ , "\\1\\2.0\\3" , "g", str1 );
str3 = gensub ( /([^A-Za-z_0-9\.\+])([0-9]+)e([0-9]+).0([^\.0-9])/ , "\\1\\2\\3\\4" , "g" , str2)
printf "%s$\n", str3 ;
}' | sed -e "s/$mttmatrix($integer\.0,/\1(\2,/g"

Deleted mttroot/mtt/bin/trans/mtt_get_subsystems version [368cf1b1dc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Gets the subsystems

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-strip )
                strip=yes;
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

subsystems=`sh $1_sub.sh "echo grep " " $1_abg.m" |\
            sh | gawk -F '.' '{print $3}'`

if [ -n "$strip" ]; then
      echo $subsystems  
   else
      for subsystem in $subsystems; do
	# echo -n $1_$subsystem' '
        echo $1_$subsystem #| gawk '{printf("%s ",$1)}'
    done
    echo
fi










Deleted mttroot/mtt/bin/trans/mtt_getsize version [59fbe2a583].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_getsize

# Gets array sizes for the def.r file
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-internal )
                internal=yes;
		;;
	-external )
                external=yes;
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

if [ -n "$internal" ]; then
    name=MTT$2"[0-9]"; # echo $name
    grep -i "$name" $1_ese.r | wc -l
    exit
fi

if [ -n "$external" ]; then
    name="^MTT"$2"("; #echo $name
    grep -i "$name" $1_ese.r | wc -l
    exit
fi

## The original version for external sizes.
if [ "$2" = "xx" ]; then
  n=`mtt_getsize $1 x`
  N=`echo "$n * $n" | bc` 
else
  N=`grep "MTTN$2 " <$1_def.r | gawk '{print $3}' | sed 's/;//'`
fi

echo $N

Deleted mttroot/mtt/bin/trans/mtt_header version [342dc555fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148




























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_header
# Headings for functions
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.67  2005/11/16 00:43:15  geraint
## rtxi
##
## Revision 1.66  2005/02/17 18:54:23  geraint
## Fixed a bash-sim: replaced let with $(( ))
##
## Revision 1.65  2004/08/29 13:14:29  geraint
## Added rule to make header for sae (sorted algebraic equations).
##
## Revision 1.64  2004/08/29 01:48:46  geraint
## Added rules to create headers for sorted systems: sesx and sesy.
##
## Revision 1.63  2004/08/28 22:08:41  geraint
## Fixed zeromatrices statements: spaces instead of commas
##
## Revision 1.62  2004/07/19 22:22:25  geraint
## Fixed initialisation of ColumnVectors for -oct.
##
## Revision 1.61  2004/06/21 16:30:41  gawthrop
## Don't zero for cc code
##
## Revision 1.60  2004/06/21 16:05:58  gawthrop
## Zapped comment that causes
##
## Revision 1.59  2004/06/20 13:53:06  gawthrop
## Initialise for numpar as well
##
## Revision 1.58  2004/06/20 13:34:11  gawthrop
## Create vectors using zeros(N,1) - avoids new octave
## default to row vector - more reps now included
##
## Revision 1.57  2004/06/20 10:18:00  gawthrop
## Explicitly size vectors - avoid default row vector bug
##
## Revision 1.56  2003/04/17 20:07:33  geraint
## Added rule to create _sese.m
##
## Revision 1.55  2002/10/30 01:15:20  gawthrop
## Now gives correct-size matrices for dm rep.
##
## Revision 1.54  2002/07/11 13:00:23  geraint
## Declared more function arguments to be "const" - improves compiler optimisation.
##
## Revision 1.53  2002/06/10 23:22:16  geraint
## Fixed problem with Matlab fsolve failing because of "user function returned Inf or Nan" (fsolve.m, line 245).
##
## Revision 1.52  2002/05/27 14:52:15  geraint
## Parameters in sfun reps are now declared using sympar.h at the top of the
## sfun*.c file instead of in individual functions. This causes the optimisation
## variables (mtt_tmp*) to be declared correctly without causing conflicts in the
## scope of parameter declarations.
##
## Revision 1.51  2002/05/19 13:01:21  geraint
## Numerical solution of algebraic equations implemented for S-function target.
##
## Equation solving requires the Matlab Optimization Toolbox to be installed.
##
## Code has been changed from C++ to C to allow mex files to be built with LCC,
## the compiler bundled with Matlab.
##
## Parameters are now obtained from numpar.c instead of a dialogue box.
##
## `mtt <sys> sfun zip` creates all necessary files for building the model mex files.
##
## Revision 1.50  2002/05/15 14:22:25  geraint
## Code for Simulink S-function target written direct to sfun.cc instead of
## calling .mexglx files. This eliminates the sfun dependency on Octave
## ColumnVectors. sys_sfun.cc should build directly on a MS Windows machine
## (can't test this yet).
##
## added sfun.zip target to create source code to export.
##
## Revision 1.49  2002/05/11 01:14:17  geraint
## Fix for [ 553218 ] simpar.oct and simpar.m different.
## Translation added between ColumnVector in base .cc and Octave_map in .oct.
##
## Revision 1.48  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.47  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.46  2002/05/07 13:48:43  geraint
## Improved clarity of code generated for -cc and -oct (except ode2odes).
## Octave DEFUN_DLDs now call (rather than replace) their .cc equivalents.
##
## Revision 1.45  2002/05/02 09:30:22  gawthrop
## _ssim.m now returns t as 4th arg
##
## Revision 1.44  2002/05/01 17:30:56  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
## if necessary.
##
## Revision 1.43  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp
## (and thus libreadline, libkpathsea, libncurses, etc).
##
## Revision 1.42  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.41  2002/04/23 17:46:05  gawthrop
## _sim.m now returns time as third argument
##
## Revision 1.40  2002/04/17 16:23:59  geraint
## Partial fix for [ 545113 ] zeros missing in c++.
## Fixes -oct by removing duplicate initialisation (-c is still outstanding).
##
## Revision 1.39  2002/04/15 10:54:31  geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u"  (Reduce:see NERO)).
##
## Revision 1.38  2001/07/23 23:43:15  gawthrop
## header only version does not need to compute sizes from _def.r
##
## Revision 1.37  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.36  2001/07/12 04:00:51  gawthrop
## Now zeros y correctly - ie Ny NOT Nx elements
##
## Revision 1.35  2001/06/13 10:39:51  gawthrop
## Zeros output matices in csex and cseo just in case some elements are
## actually zero and not set in code. Works for m and oct.
##
## Revision 1.34  2001/05/26 18:36:43  gawthrop
## Further modifications. Now works on rcPPP
##  -- next jobs:
##     add identification to ppp_nlin_sim
##     create real-time ppp_nlin_run
##
## Revision 1.33  2001/05/26 15:46:38  gawthrop
## Updated to account for new nonlinear ppp
##
## Revision 1.32  2001/05/24 07:42:12  gawthrop
## Included and updated the missing tf_r2m
##
## Revision 1.31.2.2  2001/07/02 00:34:56  geraint
## gcc-3.0 compatibility.
##
## Revision 1.31.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.31  2001/04/03 14:49:42  gawthrop
## Revised to incorporate new ssim (sensitivity simulation)
## representation (m only just now).
##
## Revision 1.30  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.29  2001/03/27 13:10:23  geraint
## Improved determination of Octave version.
##
## Revision 1.28  2001/02/17 03:48:17  geraint
## Use assignment LHS to gather tmp variable names.
## Prevents collection of long expressions, eg: tmp34*(tmp75
##
## Revision 1.27  2001/02/14 06:06:34  geraint
## Removed octave_value_list wrappers from standalone.exe - speed improvements
##
## Revision 1.26  2001/02/05 08:50:58  geraint
## Octave 2.1.x compatability.
##
## Revision 1.28  2001/01/17 21:16:15  geraint
## uncomment parameter assignments in .m reps
##
## Revision 1.27  2001/01/14 23:51:26  geraint
## declare parameters as variables instead of constants
##
## Revision 1.26  2001/01/07 21:22:47  geraint
## Compatibility with Octave 2.1.x
## vector_value ---> column_vector_value
##
## Revision 1.25  2000/12/05 12:05:26  peterg
## Changed to () form
##
## Revision 1.24  2000/12/05 10:04:52  peterg
## Fixed dummy variable bug
##
## Revision 1.23  2000/12/05 09:47:50  peterg
## Include crs as c files
##
## Revision 1.22  2000/12/04 12:19:12  peterg
## Changed $() to `` and $() to expr for sh compatibility -- geraint
##
## Revision 1.21  2000/12/04 08:52:40  peterg
## Zapped () in functions for sh compatibility
##
## Revision 1.20  2000/12/04 08:19:27  peterg
## Added switch declarations - in logic.cc
##
## Revision 1.19  2000/12/03 16:11:43  peterg
## Corrected bug in logic declatations
##
## Revision 1.18  2000/12/03 16:06:22  peterg
## Fixed bug in generating dummies
## Added logic declarations
##
## Revision 1.17  2000/12/01 20:55:01  peterg
## Added Geraint's fix for zeroing matrices
##
## Revision 1.16  2000/12/01 17:56:30  peterg
## Removed spurious  echo '## Set matrices to zero' - thanks Geraint
##
## Revision 1.15  2000/11/29 21:06:16  peterg
## Removed Npar creation - not needed??
##
## Revision 1.14  2000/11/27 11:51:43  peterg
## Added zero matrices in matlab code
##
## Revision 1.13  2000/11/09 17:19:52  peterg
## Geraint's pow() mods
##
## Revision 1.12  2000/11/09 16:09:46  peterg
## Declare dummy variables (mtt_s1 etc)
##
## Revision 1.11  2000/11/09 15:29:35  peterg
## lower-case declarations
##
## Revision 1.10  2000/11/07 17:20:51  peterg
## useful-functions.hh now included locally
##
## Revision 1.9  2000/11/07 16:56:24  peterg
## Version from Geraint
##
## Revision 1.2  2000/11/03 00:55:42  geraint
## typo: missed out 'd' in mttedx
## todo: need to accommodate mttsimpar
##
## Revision 1.1  2000/11/02 04:28:39  geraint
## Initial revision
##
## Revision 1.8  2000/10/17 16:35:03  peterg
## No parameter,state or input conversion in txt files
##
## Revision 1.7  2000/10/17 09:53:20  peterg
## Fixed logic rep
##
## Revision 1.6  2000/10/17 08:37:23  peterg
## Included logic rep
##
## Revision 1.5  2000/10/14 09:12:14  peterg
## No dies arguments and output itself
##
## Revision 1.4  2000/10/14 06:49:31  peterg
## Make parameter listing representation dependent
##
## Revision 1.3  2000/10/11 08:59:15  peterg
## Added csex rep
##
## Revision 1.2  2000/10/11 08:01:42  peterg
## Added noglobal fudge
 ##
## Revision 1.1  2000/10/10 21:02:27  peterg
## Initial revision
##
###############################################################

# Arguments
system=$1
rep=$2
language=$3
fun_name=${1}_${2}

other=$4 # Anything else eg stdin

insertor=\<\<			# help emacs sh-mode with C++ lines


if [ -z "$system" ]; then
  echo 'Usage: mtt_header sys rep lang [stdin]'
  exit
fi


# get octave version
octave_development=`octave --version | gawk '{print $4}' | gawk -F\. '{print $2}'`
case `$MATRIX --version | gawk -F\. '{print $2}'` in
    0) # stable
	vector_value=vector_value
	;;
    1) # development
	vector_value=column_vector_value
	;;
    *)
	vector_value=column_vector_value
	;;
esac


# Representation-specific stuff

eqnargs='mttx,mttu,mttt,mttpar'
inputeqnargs='mttx,mtty,mttt,mttpar'
case $rep in
    ae)
	states=yes;
	inputs=yes;
	parameters=yes;
	output=mttyz;
	args=$eqnargs;
	;;
    cse)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mttdx,mtte'
        args=$eqnargs
	zeromatrices='dx e'
	;;
    csex)
	states=yes;
        inputs=yes;
	parameters=yes;
        output=mttedx
        args=$eqnargs
        zeromatrices='edx';
	;;
    cseo)
	states=yes;
        inputs=yes;
	parameters=yes;
        output=mtty
        args=$eqnargs
        zeromatrices='y';
	;;
    dm)
	states=no;
	inputs=no;
	parameters=yes;
        output='mtta,mttb,mttc,mttd,mtte'
        args=mttpar
        zeromatrices='a b c d e';
	;;
   input)
	inputs=no;
        output=mttu
        args=$inputeqnargs
        if [ "$other" = "stdin" ]; then
	  states=no;
	  parameters=no;
          declareinputs=no;
        else
	  states=yes;
	  parameters=yes;
          declareinputs=yes
	  declarestates=yes
	  zeromatrices='u'
        fi
	;;
    logic)
	states=no;
	inputs=no;
	parameters=yes;
        output=mttopen
        args=$eqnargs
        declareinputs=yes
        declarestates=yes
	declareswitches=yes
        zeromatrices='open';
	;;
    numpar)
	states=no;
	inputs=no;
	parameters=no;
        output='mttpar'
	zeromatrices='par'
	;;
    ode)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mttdx,mtty'
        args=$eqnargs
	zeromatrices='dx y'
	;;
    odeo)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mtty'
        args=$eqnargs
	zeromatrices='y'
	;;
    ode2odes)
	states=no;
        inputs=no;
	parameters=no;
        output='mtt_data'
        args='x0,par,simpar'
	;;
    simpar)
	states=no;
	inputs=no;
	parameters=no;
	output='mttsimpar'
	oct_rep_include="#include <mtt_simpar.hh>"
	oct_return_type="mtt_simpar"
	;;
    sae)
	states=yes;
	inputs=yes;
	parameters=yes;
	output=mttyz;
	args=$eqnargs;
	;;
    sese)
	states=yes;
	inputs=yes;
	parameters=yes;
	output="mttdx,mtty";
	args=$eqnargs;
	zeromatrices="dx y";
	;;
    sesx)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mttdx'
        args=$eqnargs
	zeromatrices='dx'
	;;
    sesy)
	states=yes;
        inputs=yes;
	parameters=yes;
        output='mtty'
        args=$eqnargs
	zeromatrices='y'
	;;
    sm)
	states=no;
	inputs=no;
	parameters=yes;
        output='mtta,mttb,mttc,mttd'
        args=mttpar;
        zeromatrices='a b c d';
	;;
     smxa)
	states=no;
        inputs=no;
	parameters=yes;
        output='mtta'
        args=$eqnargs
        zeromatrices='a';
	;;
    smxax)
	states=no;
        inputs=no;
	parameters=yes;
        output='mttax'
        args=$eqnargs
        zeromatrices='ax';
	;;
    state)
	states=no;
	inputs=no;
	parameters=yes;
        output=mttx
        args=mttpar
        declarestates=yes
	zeromatrices='x'
	;;
    sim)
	states=no;
        inputs=no;
	parameters=no;
        output='y,x,t'
        args='x0,par,simpar,u'
	;;
    ssim)
	states=no;
        inputs=no;
	parameters=no;
        output='y,y_par,x,t'
        args='x0,par,simpar,u,index'
	;;
    tf)
	states=no;
	inputs=no;
	parameters=yes;
        output='mttnum,mttden'
        args=mttpar;
	;;    
    type)
	states=no;
	inputs=no;
	parameters=no;
	header_only=yes;
	;;

     *)
	echo Representation $rep not supported - sorry; exit 1
esac

## Sort out parentheses
if [ -n "$args" ]; then
    Args='('$args')'
fi
if [ -n "$output" ]; then
    Output="[$output] = "
fi


# Lanuage specific stuff
case $language in
    m)
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function="function"
	declaration="$Output$1_$rep$Args;"
        if [ "$other" != "stdin" ]; then
	  noglobals=true; # Fudge to make mtt_m2p work
        fi     
        start='## BEGIN Code'
        finish='## END Code'
        var_declaration=
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;
    sh)
	modeline='## -*-shell-script-*- Put Emacs into shell-script-mode ##';
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function=""
	declaration=""
        start=''
        parameters=no
	states=no
	inputs=no
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;
    txt)
	modeline='## -*-octave-*- Put Emacs into octave-mode ##';
	Lc='##';
	Rc='';
	Lb='(';
	Rb=')';
	function=""
	declaration=""
        start=''
        parameters=no
	states=no
	inputs=no
        declarestates=no
        declareinputs=no
	declareswitches=no
	;;
    oct)
	modeline="// -*-c++-*- Put Emacs into c++-mode";
	Lc='//';
	Lb='(';
	Rb=')';
	oct_header=yes;
        constant_declaration="const double "
        var_declaration="double "
	minusone="-1"
	map="_map"
        declaredummies=yes
	;;
    c)
	modeline="/* -*-c-*- Put Emacs into c-mode */";
	Lc='/*'
	Rc='*/'
	Lb='['
	Rb=']'
	constant_declaration="const double "
	var_declaration="double "
	minusone="-1"
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

if [ "$rep" = "simpar" ]; then
   output=${output}${map}    # Output is simpar_map in this case
fi

get_sizes()
    {
    Nx=`mtt_getsize $system x` # States
    Nz=`mtt_getsize $system z` # Non-states
    Nxx=`mtt_getsize $system xx` # States x States
    Nu=`mtt_getsize $system u` # Inputs 
    Ny=`mtt_getsize $system y` # Outputs 
    Nyz=`mtt_getsize $system yz` # Zero outputs

    case ${rep} in
	dm)
	Nx=$(( $Nx + 2 * $Nz + $Nyz )) # Matrices not usual size
	;;
	*)
	
    esac
    Npar=`wc -l $system\_sympar.txt | gawk '{print $1}'`
    }

zero_matrices()
{
## Set matrices to zero
echo
for name in $zeromatrices; do
    case $name in
	a)
	    N=$Nx; M=$Nx
	    ;;
	b)
	    N=$Nx; M=$Nu
	    ;;
	c)
	    N=$Ny; M=$Nx
	    ;;
	d)
	    N=$Ny; M=$Nu
	    ;;
	e)
	    N=$Nx; M=$Nx
	    ;;
	x)
	    N=$Nx; M=0
	    ;;
	dx)
	    N=$Nx; M=0
	    ;;
	edx)
	    N=$Nx; M=0
	    ;;
	y)
	    N=$Ny; M=0
	    ;;
	u)
	    N=$Nu; M=0
	    ;;
	open)
	    N=$Nx; M=0
	    ;;
	ax)
	    N=$Nx; M=0
	    ;;
	par)
	    N=$Npar; M=0
	    ;;
	*)
	    
    esac

    case ${language} in
	m)
	  if [ "$M" = "0" ]; then
	      M=1;
	  fi
          echo "   mtt$name = zeros($N,$M);"	
	;;
	oct)
	    if [ "$M" = "0" ]; then
		echo "   mtt$name = zeros($N);"
	    else
		echo "   mtt$name = zeros($N,$M);"
	    fi
	    ;;
        *)
    esac
done
}

declare_dummies()
{
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
    grep "${dummy}[0-9]*[ \t\n]*=" < ${fun_name}.m |\
    gawk '{ 
          if (match($1,dummy)==1)
             print $1
         }' dummy=$dummy >> mtt_dummies
done

dummy_list=`sort -u mtt_dummies`

# Comments
cat <<EOF

$Lc  Declarations of dummies $Rc
EOF

for dummy in $dummy_list; do
    echo '  ' $var_declaration $dummy';'
done
} # declare_dummies

declare_switches ()
{
cat <<EOF

$Lc  Declarations of switches $Rc
EOF
 strip_comments <${system}_switch.txt |\
 gawk '{printf("  double %s_logic = 0;\n", tolower($1))}' 
} # declare_switches

declare_vars()
{
# Grab the names
names=`gawk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`

# Comments
cat <<EOF

$Lc  Declarations for $1 names $Rc
EOF
# Declarations
for name in $names; do
    echo '  '$var_declaration $name';'
done
}


array2constant()
{
# Parameters
if [ "$parameters" = "yes" ]; then
cat <<EOF

$Lc Parameters $Rc
EOF
sympar2par_txt2m ${system} ""  "$var_declaration" "$minusone" "$Lb" "$Rb"
fi

# States
if [ "$states" = "yes" ]; then
cat <<EOF

$Lc States $Rc
EOF
N=`n2m 1 $Nx`
for i in $N; do
    echo $constant_declaration 'mttx'$i' = mttx'$Lb$i$minusone$Rb ';'
done
fi

if [ "$declarestates" = "yes" ]; then
  declare_vars state
fi

# Inputs
if [ "$inputs" = "yes" ]; then
cat <<EOF

$Lc Inputs $Rc
EOF

N=`n2m 1 $Nu`
for i in $N; do
  echo $constant_declaration 'mttu'$i' = mttu'$Lb$i$minusone$Rb';'
done
cat <<EOF

$Lc Unknown Inputs $Rc
EOF

Ni=`n2m 1 $Nyz`
for i in $Ni; do
  echo $constant_declaration 'mttui'$i' = mttu'$Lb$Nu+$i$minusone$Rb';'
done
fi

if [ "$declareinputs" = "yes" ]; then
  declare_vars input
fi

if [ "$declaredummies" = "yes" ]; then
  declare_dummies
fi

if [ "$declareswitches" = "yes" ]; then
  declare_switches
fi


zero_matrices;

}

# Argument specific stuff
get_arg_specific_stuff ()
{
    arg_name=${1:-""}
    case ${arg_name} in
	mtta | mtte)
	    arg_type="Matrix"
	    arg_init="(MTTNX,MTTNX,0.0)"
	    ;;
	mttb)
	    arg_type="Matrix"
	    arg_init="(MTTNX,MTTNU,0.0)"
	    ;;
	mttc)
	    arg_type="Matrix"
	    arg_init="(MTTNY,MTTNX,0.0)"
	    ;;
	mttd)
	    arg_type="Matrix"
	    arg_init="(MTTNY,MTTNU,0.0)"
	    ;;
	mttax | mttdx | mttedx | mttx | mttopen)
	    arg_type="ColumnVector"
	    arg_init="(MTTNX,0.0)"
	    ;;
	mttpar)
	    arg_type="ColumnVector"
	    arg_init="(MTTNPAR,0.0)"
	    ;;
	mttsimpar_map)
	    arg_type="ColumnVector"
	    arg_init="(8,0.0)";
	    ;;
	mttu)
	    arg_type="ColumnVector"
	    arg_init="(MTTNU,0.0)"
	    ;;
	mttyz)
	    arg_type="ColumnVector"
	    arg_init="(MTTNYZ,0.0)"
	    ;;
	mtty)
	    arg_type="ColumnVector"
	    arg_init="(MTTNY,0.0)"
	    ;;
	mttt)
	    arg_type="double"
	    arg_init=""
	    ;;
	nil)
	    arg_type="void *"
	    arg_init="(0x0)"
	    ;;
	*)
	    echo "Argument ${arg} not supported - sorry"; exit 1
    esac
}


get_field ()
{ # parse comma separated string
    s=${1:-""}					# comma separated string
    i=${2:-0}					# field number in string

    if [ 0 -eq ${i} ]; then			# return number of fields
	echo ${s} |\
	gawk -F\, '{ print NF }'
    else					# return ith field
	echo ${s} |\
	gawk -F\, -v i=${i} '{ print $i }'
    fi
}


get_extra_fields ()
{ # return list of words in s2 and not in s1
    s1=${1:-""}					# comma separated list
    s2=${2:-""}					# comma separated list

    c1=`get_field ${s1} 0`			# count words in s1
    c2=`get_field ${s2} 0`			# count words in s2
	
    ans=""
	
    i2=0					# s2 word index
    while [ ${i2} -lt ${c2} ]; do
        flag=0					# appearance of word in s1 and s2?
	i2=`expr ${i2} + 1`
	w2=`get_field ${s2} ${i2}`		# i2 th word in s2
	i1=0					# s1 word index
	while [ ${i1} -lt ${c1} ]; do
	    i1=`expr ${i1} + 1`
	    w1=`get_field ${s1} ${i1}`		# i1 th word in s1
	    if [ ${w2} = ${w1} ]; then
		flag=1				# w2 occurs in s1
	    fi
        done
	if [ ${flag} -eq 0 ]; then		# w2 is not in s1?
	    if [ -z ${ans:-""} ]; then		#  string is empty?
		ans=${w2}			#   assign w2
	    else
		ans=${ans},${w2}		#   append w2
	    fi
        fi
    done
    echo ${ans}
}


write_cc_header ()
{
    first_output=`get_field ${output:-""} 1`
    get_arg_specific_stuff ${first_output}
    # Should multiple vector outputs be returned as a single matrix?
    
    cat <<EOF

#include <octave/oct.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#define MATLABMEX  2
#define RTXI       3
#ifndef CODEGENTARGET
#define CODEGENTARGET STANDALONE
#endif // CODEGENTARGET

${arg_type} ${system}_${rep} (
EOF
    if [ -z ${args:-""} ]; then
	printf "\tvoid"
    else
	c=`get_field ${args:-""} 0`
	i=0
	while [ ${i} -lt ${c} ]; do
	    i=`expr ${i} + 1`
	    if [ ${i} -lt ${c} ]; then
		comma=","
	    else
		comma=""
	    fi
	    w=`get_field ${args} ${i}`
	    get_arg_specific_stuff ${w}
	    printf "\tconst ${arg_type}\t&${w}${comma}\n"
	done
    fi
    cat <<EOF
)
{
EOF

    if [ -z ${output:-""} ]; then
	printf "/* write_cc_header: no output specified. */"
    else
	c=`get_field ${output:-""} 0`
	i=0
	while [ ${i} -lt ${c} ]; do
	    i=`expr ${i} + 1`
	    w=`get_field ${output} ${i}`
	    get_arg_specific_stuff ${w}
	    printf "\tstatic ${arg_type}\t${w}${arg_init};\n"
	done
    fi
}

write_cc_footer ()
{
    first_output=`get_field ${output:-""} 1`
    # Should multiple vector outputs be returned as a single matrix?

    cat <<EOF
// BEGIN Code
// END   Code

  return ${first_output};
}

EOF
}


map_oct_inputs ()
{
    s=${1:-""}					# comma separated input list
    if [ -z ${s:-""} ];then return; fi
    c=`get_field ${s} 0`			# count of inputs
    i=0
    printf "  if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n"
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
	w=`get_field ${s} ${i}`		# argument name
	get_arg_specific_stuff ${w}
	case ${arg_type} in
	    "double")
		printf "  const ${arg_type}\t${w}\t= args(${j}).double_value ();\n"
		;;
	    ColumnVector | Matrix | *)
		printf "  const ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
		;;
	esac
    done
}	

map_mex_cc_inputs ()
{
    s=${1:-""}					# comma separated input list
    if [ -z ${s:-""} ];then return; fi
    c=`get_field ${s} 0`			# count of inputs
    i=0
    cat <<EOF
    if (${c} != nrhs)
     {
       std::cerr $insertor "${fun_name} expected " $insertor ${c} $insertor " argument(s): ${s}" $insertor std::endl;
       return;
     }
EOF
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
        w=`get_field ${s} ${i}`		# argument name
	get_arg_specific_stuff ${w}
	case ${arg_type} in
	    "const double")
		printf "  ${arg_type}\t${w}\t= mtt_double (prhs [${j}]);\n"
		;;
	    ColumnVector | Matrix | *)
		printf "  ${arg_type}\t${w}\t= mtt_${arg_type} (prhs [${j}]);\n"
		;;
	esac
    done
}	
    

write_oct()
{
    first_output=`get_field ${output:-""} 1`
    func=${1:-"<insert function name>"}
    args=${2:-""}
    cat <<EOF
#if (CODEGENTARGET == OCTAVEDLD)
$oct_rep_include

DEFUN_DLD (${system}_${rep}, args, ,
"Usage: [$first_output] = ${system}_${rep}($args)\nOctave ${rep} representation of system ${system}\nGenerated by MTT on `date`")
{
  static octave_value_list retval;

EOF
    map_oct_inputs ${args}
    cat <<EOF

  retval (0) = octave_value ($oct_return_type (${func} (${args})));
  return retval;
}
#endif // (CODEGENTARGET == OCTAVEDLD)

EOF
}

write_mex_cc ()
{
    func=${1:-"<insert function name>"}
    args=${2:-""}
    cat <<EOF
#if (CODEGENTARGET == MATLABMEX)
#include <mtt_matlab_octave.hh>

extern "C"
{
  void mexFunction (int nlhs, mxArray *plhs[],
		    int nrhs, const mxArray *prhs[])
  {
EOF
  map_mex_cc_inputs ${args}
cat <<EOF
  plhs[0] = mtt_mxArray (${func} (${args}));
  }
}
#endif

EOF
}

# Header information
cat<<EOF
$modeline
$function $declaration
$Lc $declaration
$Lc System $system, representation $rep, language $language; $Rc
$Lc File $1_$rep.$language; $Rc
$Lc Generated by MTT on `date`; $Rc
EOF

if [ -n "${header_only}" ]; then
    exit
else
    get_sizes;
fi

if [ ${language} = "oct" ];then
# standalone
    write_cc_header
    array2constant
    write_cc_footer
# oct and mex code
    write_oct ${system}_${rep} ${args}
    write_mex_cc ${system}_${rep} ${args}
elif [ $language = "c" ]; then
    array2constant
    cat <<EOF
/* BEGIN Code */
/* END Code */
EOF
else

if [ -n "$noglobals" ]; then
cat<<EOF

## Horrible fudge to make mtt_m2p work
global ...
mtt_no_globals ;
EOF
fi

## Arrays 
array2constant

# Mark start of code
echo
echo $start

fi

Deleted mttroot/mtt/bin/trans/mtt_join_lines version [95d87c9e44].

1
2
3
4
5





-
-
-
-
-
#! /bin/sh

gawk '{ printf ( "%s" , $0 ) }'		|\
    gawk -v RS="$" '{ printf "%s$\n", $0 }'	|\
    gawk -v RS=";" '{ printf "%s;\n", $0 }'

Deleted mttroot/mtt/bin/trans/mtt_langname version [080d1d07c0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_langname

# Returns the language name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | gawk -F '.' '{print $2}'

Deleted mttroot/mtt/bin/trans/mtt_m2p version [5aa349fe2c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634


























































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_m2p
# Reduce octave 2 Pascal converter for MTT   
# P.J.Gawthrop July 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.67  2002/04/18 17:02:15  gawthrop
## foo=zeros(3,1) translated as zero_state(foo,3)
##
## Revision 1.66  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.65  2001/02/09 02:56:46  geraint
## Translate some binary operators
## Allows use of ! in logic.txt
##
## Revision 1.64  2001/02/03 14:00:01  gawthrop
## Geraint's temp. variable patch applied
##
## Revision 1.63  2000/12/04 08:24:29  peterg
## Added swithc logic declarations
##
## Revision 1.62  2000/12/03 17:15:18  peterg
## *** empty log message ***
##
## Revision 1.61  2000/11/10 14:46:53  peterg
## More fixes to avoid interpering variables as funs - basicly all
## functions now have at least ()
##
## Revision 1.60  2000/11/10 09:38:30  peterg
## Got rid of sys_name functions with no ()
##
## Revision 1.59  2000/11/10 09:29:31  peterg
## Changed the name regexp to be at least 3 characters long
##  - avoids problem translating som state files - but needs more work
##
## Revision 1.58  2000/10/17 09:54:29  peterg
## replaced switchopen by logic
##
## Revision 1.57  2000/10/15 10:35:35  peterg
## Fixed _input.p header
##
## Revision 1.56  2000/10/14 09:14:24  peterg
## *** empty log message ***
##
## Revision 1.55  2000/10/11 09:06:17  peterg
## New csex rep (uses scope optimisation)
##
## Revision 1.54  2000/09/30 14:10:06  peterg
## Zap lines containing "Remove in mtt_m2p"
##
## Revision 1.53  2000/08/24 17:10:59  peterg
## New dummy variables mtt_o (for optimisation), mtt_s (for segmentation)
##
## Revision 1.52  2000/08/24 08:30:45  peterg
## *** empty log message ***
##
## Revision 1.51  2000/08/01 12:25:24  peterg
## Some changes to include files
##
## Revision 1.50  2000/05/19 17:46:41  peterg
## New version of state with par argument
##
## Revision 1.49  2000/05/18 09:45:45  peterg
## Fixed missing ;
##
## Revision 1.48  2000/05/18 09:39:38  peterg
## Removed fifth argument from _input
##
## Revision 1.47  2000/05/16 18:56:03  peterg
## Upgraded for new simulation approach - uses data files to input
## parameters -- no more argv stuff
##
## Revision 1.46  2000/05/16 11:59:01  peterg
## Updated for new data file parameter/state update
##
## Revision 1.45  2000/05/13 13:16:52  peterg
## Matrix initialisation for smxa
##
## Revision 1.44  2000/05/13 11:52:16  peterg
## A now matrix in smxa rep
##
## Revision 1.43  2000/05/11 19:35:16  peterg
## Major revisions for new paprameter passing versions
##
## Revision 1.42  2000/04/18 11:11:44  peterg
## mtt_parameters ---> mttpar
## mtt_n_parameters ---> mttnpar
##
## Revision 1.41  2000/04/18 10:13:43  peterg
## Getargs now after numpar file
##
## Revision 1.40  2000/04/07 19:09:04  peterg
## New smxa and smxax reps
##
## Revision 1.39  2000/04/07 13:38:13  peterg
## New mtt_getsize to replace bc
##
## Revision 1.38  2000/04/07 13:24:41  peterg
## Modified for smxa and smxax
##
## Revision 1.37  2000/04/07 08:17:37  peterg
## Added mttpar to the arg list of cse and cseo
##
## Revision 1.36  1999/11/29 06:49:26  peterg
## Upped number of mtt_tnn
##
## Revision 1.35  1999/11/15 22:47:17  peterg
## Generates method-specific code for the ode2odeso rep.
##
## Revision 1.34  1999/10/28 05:08:48  peterg
## Added elseif
##
## Revision 1.33  1999/09/17 04:25:01  peterg
## END --> END; in translation
##
## Revision 1.32  1999/08/29 06:54:42  peterg
## Added code (mtt_parameters, get args etc) to allow arguments to the
## a.out file
##
## Revision 1.31  1999/08/02 13:40:03  peterg
## Added zero-state and zero_input to include list
## Removed zero_matrix
##
## Revision 1.30  1999/04/20 06:16:46  peterg
## Removed calls to _switch.m
##
## Revision 1.29  1999/04/02 06:27:55  peterg
## Modified for new implicit method with swoitches
##
## Revision 1.28  1999/02/17 02:59:54  peterg
## Added -q switch to mtt
##
## Revision 1.27  1999/02/16 21:56:52  peterg
## Now gets standard include files directly from source,
##
## Revision 1.26  1999/02/16 21:43:54  peterg
## Revises smx generation.
##
## Revision 1.25  1999/02/16 04:38:09  peterg
## Now forces creation of _smx file if METHOD=IMPLICIT in simpar.txt
##
## Revision 1.24  1998/11/18 16:56:15  peterg
## Now handles comments after IFS
##
## Revision 1.23  1998/11/18 14:38:01  peterg
## Now convert ALL globals to VAR .. the last one isn't repeated now
##
## Revision 1.22  1998/11/17 17:39:45  peterg
## Put _smx include at end of list (?????)
##
## Revision 1.21  1998/11/17 17:26:11  peterg
## Put sign.p first
##
## Revision 1.20  1998/10/01 16:01:09  peterg
## Now does implicit integration with switches
##
## Revision 1.19  1998/09/29 15:37:18  peterg
## Declare mttINPUT
##
## Revision 1.18  1998/08/27 08:55:40  peterg
## Mods to integration methods
##
## Revision 1.17  1998/08/27 07:38:40  peterg
## About to change to new integration (Euler/Implicit only)
##
## Revision 1.16  1998/08/19 08:46:00  peterg
## Now translates ; % to #
##
## Revision 1.15  1998/08/15 13:46:01  peterg
## Included new sparse update routines
##
## Revision 1.14  1998/08/12 15:21:12  peterg
## Added type definition for the SVD procedures
##
## Revision 1.13  1998/08/11 09:32:07  peterg
## Added comments at procedure begin and end.
##
## Revision 1.12  1998/07/30 11:30:42  peterg
## Included zeros function
##
## Revision 1.11  1998/07/29 14:18:34  peterg
## Reorganised rep dependednt output
##
## Revision 1.10  1998/07/27 20:26:15  peterg
## Added new VARs mttWSTEPS, MTTWMIN,mttWMAX
##
## Revision 1.9  1998/07/27 17:20:42  peterg
## Allow , between ()
##
## Revision 1.8  1998/07/26 19:38:17  peterg
## Replaced t0..t9 by mtt_temp0..
##
## Revision 1.7  1998/07/25 20:06:23  peterg
## Does the mtt_update function
##
## Revision 1.6  1998/07/25 16:59:40  peterg
## Give other procedures local i,j vars.
##
## Revision 1.5  1998/07/25 15:06:17  peterg
## Added DDT VAR
##
## Revision 1.4  1998/07/25 15:05:54  peterg
## DD
##
## Revision 1.3  1998/07/25 14:03:30  peterg
## Added () to [] conversion when the variable is i j k or an integer or
## combination
##
## Revision 1.2  1998/07/25 12:39:57  peterg
## begin on same line as for and if
##
## Revision 1.1  1998/07/25 09:42:52  peterg
## Initial revision
##
###############################################################



# Set up variables
args=`echo $1 | sed 's/_/ /' | sed 's/\./ /'`
Sys=`echo $args  | gawk '{print $1}'`
sys=`echo $Sys  | gawk '{print tolower($1)}'`
rep=`echo $args  | gawk '{print $2}'`
Sys_rep="$Sys""_""$rep"
Sys_smx="$Sys""_smx"
Sys_smxp="$Sys""_smx.p"
Filename="$Sys""_""$rep.p"
filename="$sys""_""$rep.p"

Method=$2; # The integration method
Stdin=$3;  # Using standard input

if [ -n "$Method" ]; then
  MethodBlurb=" with $Method integration method"
fi

if [ -n "$Stdin" ]; then
   StdinBlurb=" using standard input"
fi

# Inform user
  echo Creating $Filename $MethodBlurb $StdinBlurb 

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nxx=`mtt_getsize $Sys xx` # States x States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | gawk '{print $1}'`


#if [ "$rep" = "simpar" ]; then
#    mtt -q $Sys smx p
#fi

# Heading
(case $rep in
    state)
        echo "PROCEDURE $Sys_rep(VAR mttx : StateVector; 
                                     mttpar : ParameterVector);"
        ;;
    numpar)
        echo "PROCEDURE $Sys_rep(VAR mttpar : ParameterVector);"
        ;;
    simpar)
        echo "PROCEDURE $Sys_rep(VAR mttsimpar : SimulationParameters);"
        ;;
    input)
        echo "PROCEDURE $Sys_rep(VAR mttu : InputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mtty : OutputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    logic)
	echo "PROCEDURE $Sys_rep(VAR mttopen : StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    ode)
	echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    odeo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    csex)
	echo "PROCEDURE $Sys_rep(VAR mttedx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    cseo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"

	;;
    smx )
	echo "PROCEDURE $Sys_rep(VAR mtta       : StateMatrix;"
	echo "                   VAR mttax      : StateVector;"
	echo "                       mttx       : StateVector;"
	echo "                       mttu       : InputVector;"
	echo "                       mttdt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    smxa )
	echo "PROCEDURE $Sys_rep(VAR mtta       : StateMatrix;"
	echo "                       mttx       : StateVector;"
	echo "                       mttu       : InputVector;"
	echo "                       mttt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    smxax )
	echo "PROCEDURE $Sys_rep(VAR mttax      : StateVector;"
	echo "                       mttx       : StateVector;"
	echo "                       mttu       : InputVector;"
	echo "                       mttt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    ode2odes)
	echo "PROGRAM $Sys_rep;"
        echo ""
	echo "CONST"
	echo "    MTT_MaxParameters = 100;"
	echo "    MTT_Npar = $Npar;"
	echo "    MTT_Nx = $Nx;"
        echo ""
	echo "TYPE"
	echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"
	echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"
	echo "    OutputVector = ARRAY[1..$Ny] OF REAL;"
	echo "    ParameterVector = ARRAY[1..$Npar] OF REAL;"
	echo "    SimulationParameters = RECORD"
	echo "    dt, first, input, last, stepfactor, wmax, wmin, wsteps: REAL"
	echo "                           END;"
	echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;"
	echo "    StateMatrixVector  = ARRAY[1..$Nxx] OF REAL;"
	echo "    glnparray    = StateVector;"
	echo "    glmparray    = StateVector;"
	echo "    glnarray     = StateVector;"
	echo "    glnpbynp     = StateMatrix;"
	echo "    glmpbynp     = StateMatrix;"
	## echo "    IntegrationMethod = 1..4;"
	echo ""
	echo "VAR"
	echo "    simpar                      : SimulationParameters;"
        echo "    t,ddt                       : REAL;"
	echo "    x,x0,dx,AAx                 : StateVector;"
	echo "    mttx,mttdx,mttAAx,mttedx    : StateVector;"
	echo "    u,mttu                      : InputVector;"
	echo "    y,mtty                      : OutputVector;"
	echo "    par                         : ParameterVector;"
	echo "    mttpar                      : ParameterVector;"
	echo "    mttnpar                     : INTEGER;"
	echo "    AA,mtte                     : StateMatrix;"
	echo "    MTTi,MTTj,it,iLast: INTEGER;"
	##echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	## echo "    mttMETHOD : IntegrationMethod;"
	echo "    open_switches  : StateVector;"
	echo "    numparfile, statefile, simparfile  : TEXT;"
        strip_comments <${Sys}_switch.txt |\
          gawk '{printf("%s_logic : REAL;\n", tolower($1))}' 
	echo ""
        mtt_txt2declare $Sys sympar p
        mtt_txt2declare $Sys struc p
        ;;
#    switchopen)
#	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
#	echo "VAR"
#	echo "    MTTi,MTTj :  INTEGER;"
#	;;
    *)	echo "PROCEDURE $Sys_rep;"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
        ;;
esac) > $Filename

cat<<EOF >> $Filename

{*** System $Sys, rep $rep, language Pascal, file $Filename ***}
{*** Translated by MTT from $Sys_rep.m on `date` ***}

EOF

# Regexps
  name="[a-zA-Z0-9_]*"
  fun_name="$Sys\_$name"
  mttfun_name=$name
  tab='	'
  space="[ $tab]*"
  spaces="[ $tab][ $tab]*"
  non_space="[^ ]*"
  args='[a-zA-Z0-9,._"]*'

# Body	
fix_operators ()
{
    m_neq="(\!\=)|(\~\=)"
    m_not="\!"
    m__eq="\=\="

    p_neq="\<\>"
    p_not="NOT\ "
    p__eq="\="

    sed "s/$m_neq/$p_neq/g"	|\
    sed "s/$m_not/$p_not/g"	|\
    sed "s/$m__eq/$p__eq/g"
}

cat $Sys_rep.m |\
grep -v 'Remove in mtt_m2p'  |\
grep -v '^[ ]*function'  |\
grep -v '^[ ]*endfunction'  |\
grep -v 'MTT_data'  |\
sed "s/^$space%/#/" | sed "s/\([;)]$space\)%/\1#/" |\
gawk -F# '{printf("%s",$1) 
          if (NF>1) printf("{* %s *}", $2)
          printf("\n") 
         }' |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)/\2(\1)/" |\
sed "s/$space\($non_space\)$spaces=${spaces}zeros(\([0-9]*\),1)/zero_state(\1,\2)/" |\
sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/,)/)/" |\
fix_operators |\
gawk '
function printvar(Name,N) {
  if (N<1) return;
  width = 10;
  kk = 0; 
  for (k=1;k<=N;k++) {
    printf("mtt%s%i", Name, k);
    if (k==N)
      printf(" : REAL;\n")
    else
      printf(", "); 
    kk++;
    if (kk==width){printf("\n"); kk=0}
  }
}
BEGIN{
  comment_regexp = "{"
  doing_header = 0
  doing_globals = 0
  N_tmp = 100;
  inc ="$I"
}
{
  if ($1=="global") 
    doing_globals = 1
  else{ 
    if (doing_globals==1){
      global[++i]=$1; 
      if (match($0,";")==0){
      }
      else{
        doing_globals = 0
        doing_header = 1
      }
    }
    else 
    {
      if (doing_header==1){
        if (rep=="ode2odes"){
          printf("\n{%s $MTTPATH/trans/p/mtt_write.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_par_update.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/sign.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_euler.p}\n",inc)
          #printf("{%s $MTTPATH/trans/p/mtt_solve.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_implicit.p}\n",inc)
          #printf("{%s $MTTPATH/trans/p/zero_matrix.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_input.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_state.p}\n",inc)
          printf("{%s %s_simpar.p}\n",inc,Sys) 
          printf("{%s %s_numpar.p}\n",inc,Sys)
          # printf("{%s $MTTPATH/trans/p/mtt_getargs.p}\n",inc)
          printf("{%s %s_state.p}\n",inc,Sys)
          printf("{%s %s_input.p}\n",inc,Sys)

          if (Method=="euler") {
            printf("{%s %s_ode.p}\n",inc,Sys)
            printf("{%s %s_odeo.p}\n",inc,Sys)
          }
          if (Method=="implicit") {
            printf("{%s %s_csex.p}\n",inc,Sys)
            printf("{%s %s_cseo.p}\n",inc,Sys)
            printf("\n{%s %s_smxa.p}\n",inc,Sys);
            printf("\n{%s %s_smxax.p}\n",inc,Sys);
          }
          printf("{%s %s_logic.p}\n\n",inc,Sys)

          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN{%s}\n", Sys_rep)
          printf("  open(statefile,\"%s_state.dat\");\n", Sys)
          printf("  open(simparfile,\"%s_simpar.dat\");\n", Sys)
          printf("  open(numparfile,\"%s_numpar.dat\");\n", Sys)
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("VAR \n");
          for (k=1;k<i;k++) printf("  %s,\n",global[k])
          printf("%s : REAL;\n", global[i])
          printvar("x",Nx);
          printvar("u",Nu);
          printvar("y",Ny);
	  if ((rep=="ode")||(rep=="odeo")||(rep=="csex")||(rep=="cseo")||(rep=="smx")||(rep=="smxa")||(rep=="smxax")){
	    printvar("_tmp",N_tmp);
	    printvar("_s",N_tmp);
	  }
          printf("VAR mtt_i, mtt_j : INTEGER;\n");
          #if ( (rep=="smxa")||(rep=="smxax") ) {
          #  printvar("_t",Nt);
          #}
          printf("\nBEGIN{%s}\n", Sys_rep)
          if (rep=="smxa"){
            printf("FOR mtt_i:= 1 to %i DO\n\tFOR mtt_j:= 1 to %i DO\n\tmtta[mtt_i,mtt_j] := 0;\n", Nx,Nx);
          }
          if (rep=="smxax"){
            printf("FOR mtt_i:= 1 to %i DO\n\tmttax[mtt_i] := 0;\n", Nx);
          }
       }
        doing_header = 0;
      }
      if (match($1,comment_regexp)>0){
        if (doing_header==1)
          comment[++j] = $0
        else
          printf("%s\n", $0)
      }
      else {
        if ($1=="if") {
          sub(/==/, "=", $0)
            gsub(/&&/," AND ",$0)
            gsub(/\|\|/," OR ",$0)
          printf("%s THEN BEGIN\n", $0)
        }
        else { 
          #if ((match($1,"mtt_write")>0)&&(length(Stdin)>0)) {
          # sub(/mtt_write/, "if NOT eof THEN mtt_write");
          #}
          if ($1=="for"){
            if (($2=="it")&&(length(Stdin)>0)){
	      printf("WHILE NOT eof DO BEGIN {Integration loop}\n")
            }
            else {
              sub(/:/," TO ",$0)
              sub(/=/,":=",$0)
              printf("%s DO BEGIN\n", $0)
            } 
          }
          else{
            sub(/=/,":=",$0)
            sub(/endif/,"END;{IF}",$0)
            sub(/endfor/,"END;{FOR}",$0)
            sub(/elseif/,"END ELSEIF BEGIN",$0)
            sub(/else/,"END ELSE BEGIN",$0)
            gsub(/\^/,"**",$0)
            gsub(/&&/," AND ",$0)
            gsub(/\|\|/," OR ",$0)
            printf("%s\n",$0)
          }
        }
      }
    }
  }
}
END{
  if (rep=="def"){
    printf("EULER = 1,\n")
    printf("IMPLICITL = 2;\n")
    printf("IMPLICIT = 3;\n")
    }
    else
      if (rep=="ode2odes")
                printf("END{%s}.\n", Sys_rep)
      else
        printf("END{%s};\n", Sys_rep)
}' Sys=$Sys sys=$sys Sys_rep=$Sys_rep rep=$rep \
   Nx=$Nx Nu=$Nu Ny=$Ny Method=$Method Stdin=$Stdin |\
sed 's/\\$//'    |\
sed 's/(\([ijk0-9,]*\))/\[\1\]/g'    |\
sed 's/(\(MTT[ijk0-9],[0-9]*\))/\[\1\]/g' |\
sed 's/(\([0-9]*,MTT[ijk0-9]\))/\[\1\]/g' |\
sed 's/(\(MTT[ijk0-9],MTT[ijk0-9]\))/\[\1\]/g' |\
sed 's/(\(MTT[ijk0-9,]*\))/\[\1\]/g'  |\
sed 's/switcha(mttAA,/switcha(/g'   |\
sed 's/switch(MTTx,/switch(/g'  |\
sed 's/if nargin<[1-9] THEN//'  |\
sed 's/if nargin>[0-9] THEN//'  \
>> $Filename

# p2c doesn't like mixed case filenames!
#if [ "$Filename" != "$filename" ]; then
#  echo Creating $filename
#  cp -f $Filename $filename
#fi

if [ "$rep" = "ode2odes" ]; then
    # Explicitly include files
    mtt_pinclude $Filename>junk.p
    mv junk.p $Filename
fi



Deleted mttroot/mtt/bin/trans/mtt_make_menu version [2bfaf2eae8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_make_menu
# Creates tk/tcl menus for xmtt.
# Copyright (c) P.J.Gawthrop, 1998,1999

## Paths for its files
dotfile="$HOME/.mtt"
xdotfile="${dotfile}/xmtt"

repfile="${xdotfile}/reps"
exfile="${xdotfile}/examples"

#MTT blurb
title=`mtt --version`

#Collect all systems (inc dir name)
pwd=`pwd`;
dirname=`basename $pwd`
systems=`echo *_abg.fig | sed 's/\([a-zA-Z0-9]*\)_abg.fig/\1/g'`
dirname_in_systems=`echo $systems | grep -c $dirname`
if [ "$dirname_in_systems" = "0" ]; then
    systems="$systems $dirname"
fi

# Default system
system=$dirname

cat<<EOF
# Default system
set system "$system"

# Arguments to mtt
set args {-q}

# Default the again command
set mtt {mtt \$args warranty}

# The top level menu
button .mtt -text "$title \n Directory: $dirname \n NO WARRANTY \n (press for details)" -command "exec mtt warranty &"
menubutton .man -text "Manual" -menu .man.man
menubutton .util  -text "Utilities" -menu .util.util
menubutton .opt  -text "Options" -menu .opt.opt
menubutton .sys -text "Systems" -menu .sys.sys
menubutton .rep -text "Representations (major)" -menu .rep.rep
menubutton .repall -text "Representations (all)" -menu .repall.repall
menubutton .exam -text "Examples" -menu .exam.exam
#button .again -text "Again" -command "exec echo \$mtt &; exec \$mtt  &"
button .mtt_quit -text "Quit" -command exit
pack .mtt .exam .rep  .repall .sys  .util .opt  .man .mtt_quit

 
menu .man.man
.man.man add command -label "Browser (html)" -command "exec mtt -q hinfo &"
.man.man add command -label "Info" -command "exec xterm -e mtt -q info &"
.man.man add command -label "Text (ps)" -command "exec mtt -q manual &"

menu .util.util
# .mtt.opt.util add command -label "copy example" -command 
# .mtt.opt.util add command -label "copy" 
.util.util add command -label "clean" -command "exec mtt -q Clean &"
.util.util add command -label "recursive clean" -command "exec mtt -q rclean &"

menu .opt.opt


# System choice
menu .sys.sys
EOF

for sys in $systems; do
    echo .sys.sys add radio -label "{$sys}"  -command {set system "{$sys}"} 
done

# Create the options menu
mtt |  gawk '{
  if (Options) {
    option=substr($1,2);
    label="";
    if ($1 ~ /^-/) {
      for (i=2;i<=NF;i++)
        label = sprintf("%s %s",label,$i);
      printf(".opt.opt add check -label \"%s (-%s)\" -variable %s -command {set args \"$args -%s\" }\n", label, option, option, option); 
    }
  }
  if ($1=="Options:") Options = 1;
}'

# Examples menu
cat <<EOF
menu .exam.exam
EOF

echo '#' Examples menu
strip_comments <${exfile} | examples_txt2tk

# Representations menu
echo '#' Representations menu
cat<<EOF
menu .rep.rep
menu .repall.repall
EOF

strip_comments <${repfile}  | reps_txt2tk 

Deleted mttroot/mtt/bin/trans/mtt_make_sim version [39947db7aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245





















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

   ###################################### 
   ##### Model Transformation Tools #####
   ######################################


# Bourne shell script: mtt_make_sim
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.7  2000/05/19 17:47:35  peterg
## Fixed bug in oct version but still needs proper check
##
## Revision 1.6  2000/05/17 17:20:49  peterg
## Fixed bugs with ny>1. Could be made faster by not generating y when
## y_sim >1
##
## Revision 1.5  2000/05/17 16:01:42  peterg
## Fixed bug for n_y>1
##
## Revision 1.4  2000/05/16 18:57:15  peterg
## Still debugging
##
## Revision 1.3  2000/05/16 11:59:34  peterg
## Stard new version with data files not argv.
##
## Revision 1.2  2000/05/11 19:32:29  peterg
## Put in c version + sensitivity computation
##
## Revision 1.1  2000/04/08 10:43:26  peterg
## Initial revision
##
###############################################################

# Tell user
Sys=$1
method=$2
computation=$3

if [ -z "$method" ]; then
    method=implicit    
fi

if [ -n "$computation" ]; then
   blurb="for language $computation"    
fi

echo  "Creating $1_sim.m with $method integration method $blurb"

if [ $method = "implicit" ]; then
    ode=cse
    odeo=cseo
else
    ode=ode
    odeo=odeo
fi

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | gawk '{print $1}'`

# Header
lang_header -noglobals $1 sim m 'x0,u,t,par,sensitivities' '[y,ys]' > $1_sim.m

cat >> $1_sim.m <<EOF
##  tick=time; 
  if nargin<5
    sensitivities = [];
  endif;

  ##Sizes
  N = length(t);
  [n_u,N_u] = size(u);

  ## Doing sensitivities (assumes sensitivity system is invoked)
  n_sens = length(sensitivities);
  doing_sensitivities = (n_sens>0);
  if doing_sensitivities
    n_y = $Ny/2;
    doing_state=0;
    ys = [];
  else
    n_y = $Ny;
    doing_state=(nargout>1);
  endif;



  ## Initialise
  ui = zeros(n_u,1);	# Initial control
  [xi] = x0;	        # Read in initial state

  ## Timing parameters
  first = t(1);
  dt = t(2) - t(1);
  n_t = length(t);
  last = t(n_t);
EOF

if [ "$computation" = "c" ]; then
cat >> $1_sim.m <<EOF
  T = "";
  S = "";

  S = [S;"Save\t"];
  tim = time;

  ## Create the system input file
  t1 = [0:N_u-1]*dt; # Create time vector from zero (to fit u);
  ut = [t1' u'];
  save -text $1_input.dat ut 

  ## Create the state file
  xi = [[1:$Nx]' x0]; #'
  save -text   $1_state.dat xi

  ## Create the sympar file
  save -text   $1_simpar.dat dt

  ## Create the numpar file
  [n_par,m_par] = size(par);
  if m_par==1
    if n_par!=$Npar
      error(sprintf("Number of parameters is %i, should be %i", n_par, $Npar));
    else
      ipar= [[1:$Npar]' par]; #' 
    endif
  elseif m_par==2
    ipar = par;
  else
    error(sprintf("Number of parameter columns is %i, should be 1 or 2", m_par));
  endif;

  if !doing_sensitivities
      save -text   $1_numpar.dat ipar 
  endif;

  dtime = time-tim;
  T = [T; num2str(dtime)];

  ## main simulation loop
  n_sim = max(1,n_sens);
  for i_sim=1:n_sim
    i_1 = 2;

    if doing_state
      i_2 = i_1 + n_y - 1;
      i_3 = i_1 + n_y + 1;
      i_4 = i_1 + n_y + $Nx;
    else
      if doing_sensitivities
        i_2 = 1 + 2*n_y;
        ipars = [ipar; [sensitivities(i_sim) 1]];
        save -text   $1_numpar.dat ipars 
      else
        i_2 = i_1 + n_y -1;
      endif
    endif;

      if doing_state # Need to cut twice
        command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i,%i-%i | tail -%i;", i_1,i_2,i_3,i_4,n_t);
      else # not doing_state
        command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i | tail -%i;", i_1,i_2,n_t);
      endif

  ## Execute external programme
  S = [S;sprintf("Run %i\t",i_sim)];
  tim = time;
  yy_str=system(command);
  dtime = time-tim;
  T = [T; num2str(dtime)];

  ## Convert data
  S = [S;sprintf("Conv %i\t",i_sim)];
  tim = time;
  yy = str2num(yy_str)'; #'
  dtime = time-tim;
  T = [T; num2str(dtime)];


  [N_yy,M_yy] = size(yy);

  if i_sim==1
    if doing_sensitivities
      y = yy(1:n_y:2*n_y,:);              # Output
      ys = yy(2:n_y:2*n_y,:);
    else
      y = yy(1:n_y,:);
    endif;
    if doing_state 
      i_1 = n_y+1;
      i_2 = i_1 + $Nx - 1;
      ys = yy(i_1:i_2,:);
    endif;
  else # i_sim>1
    if doing_sensitivities
      ys =  [ys; yy(2:n_y:2*n_y,:)];
    endif; 
  endif

   endfor;
  ##RealTime = [S T]
endfunction

EOF
    
else

cat >> $1_sim.m <<EOF    
  A = zeros($Nx,$Nx);
  Ax = zeros($Nx,1);
  dx = zeros($Nx,1);

  ## Step size
  dt = t(2)-t(1);
  iFirst = first/dt;
  for i = 1:N
    ti = t(i);
    ui = u(:,i);
    yi = $1_cseo(xi,ui,ti,par);    # Output 
    y(:,i) = yi;
    x(:,i) = xi;
    dxi = $1_cse(xi,ui,ti,par); # State derivative
    A = $1_smxa(xi,ui,dt,par);	# (I-Adt)
    #A = reshape(A,$Nx,$Nx);
    Ax = $1_smxax(xi,ui,dt,par);	# (I-Adt)x
    #open = eval(sprintf("%s_switchopen(x);", system_name));        # Open switches
    #x = mtt_implicit(x,dx,A,Ax,dt,$Nx,zeros(20,1)); # Implicit update
    xi = A\(Ax + dxi*dt);        # Implicit update
  endfor;			

endfunction
EOF
fi

Deleted mttroot/mtt/bin/trans/mtt_make_substruc version [39e2eb4e04].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

# Makes subsystem structure files for partitioning
# Copyright (C) 2000 by Peter J. Gawthrop

sys=$1
rep=$2
lang=$3

echo Creating structure files for subsystems
# Get subsystems
  subsystems=`mtt_get_subsystems -strip ${sys}`;

for subsystem in $subsystems; do
  grep $subsystem < ${sys}_struc.txt > ${sys}_${subsystem}_struc.txt
done

Deleted mttroot/mtt/bin/trans/mtt_make_subsystems version [9acb3856cd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

# Makes subsystems for partitioning
# Copyright (C) 2000 by Peter J. Gawthrop

sys=$1
rep=$2
lang=$3

echo Creating subsystem representations for ${sys}_${rep}.${lang}
# Get subsystems
  subsystems=`mtt_get_subsystems -strip ${sys}`;

for subsystem in $subsystems; do
    
mtt $options -u -q -sub $subsystem ${sys} ${rep} ${lang}
    ## Repeating systems need sorting out !!!!
    #cp $1_$subsystem"_"$2.$3 $1_$subsystem"_1_"$2.$3
done

Deleted mttroot/mtt/bin/trans/mtt_make_sympar version [ce08d18b4a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139











































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_make_sympar
# Makes the sympar.txt file
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2004/09/02 22:06:09  geraint
## Does not issue warnings about Reduce reserved words if the
## second argument (use_reduce) is "no".
##
## Revision 1.11  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.10  2001/07/28 21:10:18  geraint
## Generate warning instead of error if reserved word used.
##
## Revision 1.9  2001/07/23 05:16:39  geraint
## Simple filter for Reduce reserved words in sympar.
##
## Revision 1.8  2001/07/04 06:00:12  gawthrop
## Fixed a funny with tr - changed SEPS and REPS - something to do with ^
##
## Revision 1.7  2001/04/13 07:14:12  geraint
## Implemented lower level lbl.txt recognition of #NOT[V|P]AR
##
## Revision 1.6  2001/04/10 12:54:50  gawthrop
## Minor fixes for sensitivity versions
##
## Revision 1.5  2000/11/03 14:57:06  peterg
## Corrected regexp notvar
##
## Revision 1.4  2000/11/02 18:53:46  peterg
## Added NOPAR words to unwanted list.
##
## Revision 1.3  2000/10/16 09:41:29  peterg
## Fixed bug with printing a blank line.
##
## Revision 1.2  2000/10/16 09:10:08  peterg
## Now strips out "unwanted" bits frome the _aliased.txt file
##
## Revision 1.1  2000/10/12 19:24:28  peterg
## Initial revision
##
##
###############################################################


sys=$1 # System name
filename=$1_sympar.txt

use_reduce=$2

# Inform user
echo Creating $filename

# Create list of all sympars including those that are aliased
sh $1_type.sh 'echo ' ' ' ' ' |\
gawk '{printf("abg2sympar_m2txt %s %s\n ", $1, $2)}' |\
sh | sort -u > mtt_all_sympar.txt

# Sort the aliased list
mtt_strip_args < $1_aliased.txt | sort -u  > mtt_aliased_sort.txt

# Create list of unwanted stuff
cat  mtt_aliased_sort.txt> mtt_unwanted.txt

notvar="[%|#]NOT[V|P]AR";
sh $1_type.sh 'strip_notvars.sh ' ' ' ' mtt_unwanted.txt'

sort -u mtt_unwanted.txt > mtt_unwanted_sort.txt

# Compare it with the aliased list and show the differences
diff mtt_all_sympar.txt mtt_unwanted_sort.txt |\
gawk '{if ($1=="<") printf("%s\t%s\n", $2,$3)}' > mtt_sympar.txt

# Assume same name in different system is the same
gawk '{
    if ($1==name){
	sysname[i++]=$2
    }
    
    if ($1!=name){
        if (length(name)>0){
          printf("%s\t",name)
          comma="";
          for (j=1;j<=i;j++){
            printf("%s%s", comma, sysname[j]);
            comma=",";
          }
          printf("\n")
        }
        i=1;
        sysname[1]=$2;
    }
    name = $1
}
END{
        printf("%s\t",name)
        comma="";
        for (j=1;j<=i;j++){
          printf("%s%s", comma, sysname[j]);
          comma=",";
        }
        printf("\n")

}' < mtt_sympar.txt >$filename

if [ ! "${use_reduce}" = "no" ]; then
    reserved_words=`\
    cat ${MTT_LIB}/reduce/reserved_words.txt	|\
    gawk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
    sympar_words=`\
    cat ${filename}				|\
    cut -f1					|\
    gawk '{printf "%s ", $0}'			|\
    tr [a-z] [A-Z]`
    flag=0
    for reserved_word in ${reserved_words}; do
	for sympar_word in ${sympar_words}; do
	    if [ ${sympar_word} = ${reserved_word} ]; then
		echo ""
		echo "*** MTT Warning:"
		echo "    ${sympar_word} is reserved (Reduce)"
		echo ""
	    fi
	done
    done
fi

Deleted mttroot/mtt/bin/trans/mtt_mend_lines version [0579d4ac5f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

# Copyright (C) 2000 by Peter J. Gawthrop

# Fixes broken lines from reduce.

#sed 's/[^#]\(.*\)[^;]$/\1\\/' 

gawk '{
  if ((match($1,"#")==0)&&(match($1,"global")==0)&&(match($1,"endfunction")==0)) {
    if(match($0,";")!=length($0))
      printf("%s \\\n",$0)
    else
      print $0
  }
  else print $0
   
}'

Deleted mttroot/mtt/bin/trans/mtt_multi version [cdd0534fee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

# Does mutiple commands down the hierarchy

command=$1
system=$2
rep=$3
lang=$4
relative_level=$5

current_level=`echo $system | gawk '{N=split($1,foo,"_"); print N-1}'`

if [ -z "$relative_level" ]; then
  relative_level=0;    
fi

mtt_xargs.sh "ls" "$2*_$3.$4"  |\
gawk '{
  level=split($1,foo,"_")-2;
  maxlevel = current_level +  relative_level;
  if (level<=maxlevel) print command, $0, "&";
'} command=$command relative_level=$relative_level current_level=$current_level

Deleted mttroot/mtt/bin/trans/mtt_name2array version [3800132da3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_name2array

# Generates array elements from names
# Copyright (C) 2000 by Peter J. Gawthrop


case $2 in
    numpar)
        name=mttpar
	cat $1_sympar.txt>mtt_infile
	;;
    state)
        name=mttx
	gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    input)
        name=mttu
	gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
        <$1_struc.txt >mtt_infile
	;;
    *)
	echo Repesentation $2 not supported
esac

case $3 in
    zero)
	  strip_comments <mtt_infile | grep "$filter"  |\
          gawk '{
          i++; printf("  %s = 0.0;\n", tolower($1));
          }'
	;;
    set)
	  strip_comments <mtt_infile  |\
         gawk '{
           i++; printf("  %s(%i)\t= %s;\n", name, i, tolower($1));
         }' name=$name
        ;;
    *)
         strip_comments <mtt_infile  |\
         gawk '{
           i++; printf("  %s \t= %s(%i);\n", tolower($1), name, i);
         }' name=$name
	;;
esac




Deleted mttroot/mtt/bin/trans/mtt_optimise version [ed8d518642].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124




























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

# script uses Reduce + Scope to optimise a vector
# either global (an entire vector) or local (line-by-line)

extent=$1			# global or local
system=$2
representation=$3

# error codes
E_REP_NOT_SUPPORTED=-19
E_FILE_NOT_EXIST=-20

case $representation in
    ae)
	matrix=yz ;
	nmatrix=`mtt_getsize $system yz` ;;
    csex)
	matrix=edx ;
	nmatrix=`mtt_getsize $system x` ;;
    ode)
	matrix=dx ;
	nmatrix=`mtt_getsize $system x` ;;
    cseo | odeo)
	matrix=y ;
	nmatrix=`mtt_getsize $system y` ;;
    *)
	exit $E_REP_NOT_SUPPORTED;;
esac

# Global optimisation: Generate a command of the form
# optimise mtt?(1,1) :=: mtt?(1,1), mtt?(2,1) :=: mtt?(2,1), ..., INAME mtt_tmp$
#
# Local optimisation: Generate a command of the form
# optimise mtt?(1,1) :=: mtt?(1,1) INAME mtt_tmp$ \
# optimise mtt?(2,1) :=: mtt?(2,1) INAME mtt_tmp$ ...
case $extent in
    "global" )
	delimiter=", "
	terminate="INAME mtt_tmp$"
	;;
    "local" )
	delimiter=" INAME mtt_tmp$ optimize"
	terminate="$"
	;;
    * )
	echo "*** unknown scope for optimisation"
	echo "*** should be global or local"
	exit -1
	;;
esac

if [ $nmatrix -gt 0 ]; then
    command="optimize"
    counter=1
    while [ $counter -le $nmatrix ]; do
	command="$command mtt$matrix($counter,1) :=: mtt$matrix($counter,1)$delimiter"
	counter=`expr $counter + 1`
    done
    command="$command $terminate"
else
    command=""
fi

logfile=${system}_${representation}_optimisation.log
tmpfile=${system}_${representation}_optimisation.tmp
outfile=${system}_${representation}.r

if [ ! -f $outfile ]; then
    exit $E_FILE_NOT_EXIST
fi

find_code ()
{
    file_in=${1:-${IN}}
    portion=${2:-"body"}
    head=`cat ${file_in} | gawk '($2 == "Begin" && $3 == "Matrix") { print NR }'`
    foot=`cat ${file_in} | gawk '($2 == "End"   && $3 == "Matrix") { print NR }'`
    case ${portion} in
	head)
	    start=0
	    end=${head}
	    ;;
	body)
	    start=${head}
	    end=${foot}
	    ;;
	foot)
	    start=${foot}
	    end=end
	    ;;
	*)
	    echo "Error in find_code: portion unknown"
	    return -1
	    ;;
    esac
    cat ${file_in} |\
    gawk --assign start=${start} --assign end=${end} '
	(start < NR && NR < end) { print $0 }'
};


# Use Reduce to perform the optimisation
${SYMBOLIC:-reduce} <<EOF > $logfile 2>&1
off nat;
in "${system}_def.r";
in "$outfile";
load scope;
out "$tmpfile";
$command;
shut "$tmpfile";
$end;
EOF

cp $outfile $outfile.unoptimised
cp $tmpfile $outfile.tmp

find_code $outfile head > $tmpfile.head
cat $tmpfile | mtt_fix_integers > $tmpfile.body
find_code $outfile foot > $tmpfile.foot
cat $tmpfile.head $tmpfile.body $tmpfile.foot > $outfile
echo ";end;" >> $outfile

mtt_error_r $logfile

Deleted mttroot/mtt/bin/trans/mtt_p2C version [4c8ad0a9b3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: p2C

# Pascal to a c program - intermediate step for mtt_p2oct
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	


sys_rep="$1_$2"
begin="BEGIN{$sys_rep}"

# Inform user
# echo "Creating $1_$2.pas"

# Find system constants
Nx=`mtt_getsize $1 x`
Nxx=`mtt_getsize $1 xx`
Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

Npar=`wc -l $1_sympar.txt | gawk '{print $1}'`


echo "PROCEDURE $1_$2;" > $1_$2.pas
echo "TYPE"             >>$1_$2.pas
echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"        >>$1_$2.pas
echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;" >>$1_$2.pas
echo "    StateMatrixVector  = ARRAY[1..$Nxx] OF REAL;" >>$1_$2.pas
echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"        >>$1_$2.pas
echo "    OutputVector  = ARRAY[1..$Ny] OF REAL;"       >>$1_$2.pas
echo "    ParameterVector  = ARRAY[1..$Npar] OF REAL;"  >>$1_$2.pas


# Create the predefined vars
echo "VAR"     >>$1_$2.pas
gawk '{
       printf("%s,", $1)
     }
     END{print "JUNK : REAL;"}'< $1_sympar.txt     >>$1_$2.pas

if [ "$2" = "ode2odes" ]; then
    first='PROCEDURE'
    gawk '
    {
    if (writing) print $0;
    if (i++==0) writing=1
    if (match($1,"PROCEDURE")==1) writing=0;
    }'  < $1_$2.p >>$1_$2.pas
else
    first='BEGIN'

 # Convert VAR format in the headings
    gawk 'BEGIN{writing=1}
    {
    if (match($1,"BEGIN")==1) writing=0;
    if (writing) print $0;
    }'  < $1_$2.p | \
    sed \
	-e 's/PROCEDURE [a-zA-Z_0-9]*(VAR/VAR/' \
	-e 's/PROCEDURE [a-zA-Z_0-9]*;//' \
	-e 's/REAL);/REAL;/' \
	-e 's/OutputVector);/OutputVector;/' \
	-e 's/ParameterVector);/ParameterVector;/' \
	>>$1_$2.pas
fi

# Write out the actual code until the begining of the procedure
gawk 'BEGIN{writing=0}
{
  if (match($1,first)==1) writing=1;
  if (writing) print $0;
  if (match($1,begin)==1) writing=0;

}' begin=$begin first=$first   < $1_$2.p  >>$1_$2.pas

# Write out the parameters
echo {Parameters}   >>$1_$2.pas
gawk '{
       printf("  %s \t:= mttpar[%i];\n", $1, ++i);
     }'< $1_sympar.txt  >>$1_$2.pas

# Write out the actual code from the end of the procedure
gawk 'BEGIN{writing=0}
{
  if (writing) print $0;
  if (match($1,begin)==1) writing=1;
}' begin=$begin   < $1_$2.p  >>$1_$2.pas

#echo "Creating $1_$2.C"
p2c -o $1_$2.C $1_$2.pas > mtt_p2C.log 2>> mtt_p2C.log


Deleted mttroot/mtt/bin/trans/mtt_p2c version [d5850baa69].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_p2c
# Pascal to c converter for MTT
# Uses the wonderful GNU p2c by  Dave Gillespie, daveg@csvax.cs.caltech.edu.    
# P.J.Gawthrop July 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  2001/04/11 07:36:10  gawthrop
## Now uses system_cr.h in place of system.h in .c rep -
##   compatible with older code
##
## Revision 1.11  2001/03/29 19:24:14  gawthrop
## Can now use c representations of crs when using -c option
##
## Revision 1.10  2000/09/15 09:01:41  peterg
## Updated internal comments
##
## Revision 1.9  2000/05/16 18:56:58  peterg
## Now realised that libp2c.a avoids many probs - so simplified it.
##
## Revision 1.8  2000/05/11 19:34:50  peterg
## *** empty log message ***
##
## Revision 1.7  1999/08/29 06:14:27  peterg
## No longer remove "PASCAL_MAIN"
##
## Revision 1.6  1999/04/20 06:17:15  peterg
## Fudge to avoid a bizzare bug (?) in p2c which corrupts "zero_matrix"
##
## Revision 1.5  1998/08/12 14:14:18  peterg
## Added pretty heading and explicitly include p2c header.
##
## Revision 1.4  1998/07/29 13:56:34  peterg
## Replces p2c include by local include.
##
## Revision 1.3  1998/07/27 20:32:51  peterg
## Now gives immediate warnings
##
## Revision 1.2  1998/07/25 16:35:43  peterg
## Sorted out log files etc
##
## Revision 1.1  1998/07/25 16:28:38  peterg
## Initial revision
##
###############################################################


# Options
info=''
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;
                ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

## Create p2crc with various configs.
cat > p2crc <<EOF
EatNotes [221]   # No warning messages about symbols
EOF

# Inform user
echo Creating $1_$2.c

# Use p2c to do the translation 
p2c -V  $1_$2.p  | grep Warning # > mtt_p2c.log 2>> mtt_p2c.log
cat $1_$2.log >> mtt_p2c.log
mv $1_$2.c mtt_junk.c

# Change p2c.h include.
#mv $1_$2.c mtt_junk1#
#cat mtt_junk1 | grep -v 'p2c/p2c.h'> mtt_junk2

# pretty heading
DATE=`date`

cat <<EOF  >$1_$2.c
/* C program  $1_$2.c */
/* Generated by MTT on $DATE */

/* Compile with gcc -lm -lp2c $1_$2.c -o $1_$2.out */
/* Note that p2c must be correctly installed so that p2c.h and libp2c.a are accessible */

/* Header file for user-defined crs (implemented in c) */ 
#include "$1_cr.h"
EOF

#cat<<EOF >>$1_$2.c
#/* The following is the header file included here for completeness */
#EOF

#cat $MTTPATH/trans/c/p2c.h >> $1_$2.c

#cat <<EOF >> $1_$2.c
#/* End of the header file. */
#
#
#EOF

## The sed item is to avoid a bizzare bug (?) in p2c which corrupts "zero_matrix"
###cat mtt_junk2 | sed 's/zero_matrix/mttmat/g'>> $1_$2.c

## Sort out the pascal EOF, PASCAL_MAIN etc
cat mtt_junk.c |\
 grep -v PASCAL_MAIN >> $1_$2.c

if [ -n "$info" ]; then
    cat mtt_p2c.log
fi

# Remove the garbage
rm -f mtt_junk.c

Deleted mttroot/mtt/bin/trans/mtt_p2cc version [9cd1ab95be].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_p2cc

# Pascal to .cc (for octave .oct files).
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	

## Extract the system and rep names.
sys=`mtt_sysname $1` 
rep=`mtt_repname $1` 
sys_rep=$sys"_"$rep

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Inputs 

# Create the representation code
mtt_p2C $sys $rep

# Inform user
echo Creating $sys_rep.cc

# Create the c++ code
# Heading
date=`date`

cat > $sys_rep.cc <<EOF
#include <octave/oct.h>

DEFUN_DLD ($sys_rep, args, ,
	   "Usage: $sys_rep(x,u,t,par)\n$sys_rep was generated by MTT on $date")
{
  ColumnVector mttx = args(0).vector_value ();
  ColumnVector mttu = args(1).vector_value ();
  double mttt = args(2).double_value ();
  ColumnVector mttpar = args(3).vector_value ();

EOF

case "$rep" in
    ode)
	echo "  ColumnVector mttdx ($Nx);" >> $sys_rep.cc
	;;
    odeo)
	echo "  ColumnVector mtty ($Ny);" >> $sys_rep.cc
	;;
    cse)
	echo "  ColumnVector mttdx ($Nx);" >> $sys_rep.cc
	;;
    cseo)
	echo "  ColumnVector mtty ($Ny);" >> $sys_rep.cc
	;;
    smx | smxa | smxax)
        Nxx=`echo "$Nx*$Nx" | bc`
	echo "  Matrix mtta ($Nx,$Nx);" >> $sys_rep.cc
	echo "  ColumnVector mttax ($Nx);" >> $sys_rep.cc
	;;
    *)
	
esac

#Extract Type info
echo '/* Types */'                >> $sys_rep.cc
grep typedef $sys_rep.C              >> $sys_rep.cc

#Extract the rep code converting [] to () and deleting mtt variables etc
#The awk part detects the begin and end of the relevant code.
echo "/* Representation $rep information */" >> $sys_rep.cc
gawk '{
  if ( (match($1,"}")==1)&&(NF>1)) writing=0;
  if ( (writing) && !(match($2,"mtt[a-z]")==1) ) print $0;
  if (match($1,"{")==1) writing=1;
}' <$sys_rep.C |\
sed 's/\[\([a-z0-9_]*\)\]\[\([a-z0-9_]*\)\]/(\1,\2)/g' |\
sed 's/\[\([a-z_0-9]*\)\]/(\1)/g' >> $sys_rep.cc

# Tail
cat >> $sys_rep.cc <<EOF

EOF

case "$rep" in
    ode)
        echo "return octave_value (mttdx);" >> $sys_rep.cc;
	;;
    odeo)
        echo "return octave_value (mtty); " >> $sys_rep.cc;
	;;
    cse)
        echo "return octave_value (mttdx);" >> $sys_rep.cc;
	;;
    cseo)
        echo "return octave_value (mtty); " >> $sys_rep.cc;
	;;
    smxa)
        echo "return octave_value (mtta); " >> $sys_rep.cc;
	;;
    smxax)
        echo "return octave_value (mttax); " >> $sys_rep.cc;
	;;
    *)
	
esac

# Terminating }
echo "}" >> $sys_rep.cc;

# Convert to octave loadable code
#echo Creating $sys_rep.oct
#mkoctfile $sys_rep.cc

Deleted mttroot/mtt/bin/trans/mtt_p2m version [a6fa5071b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
## Chages the Pascal output from gentran to octave form
# Copyright (C) 2000 by Peter J. Gawthrop

sed 's/begin$//' |\
sed 's/end$//' |\
sed 's/end;$/;/' |\
sed 's/\[\([0-9,]*\)\]/(\1)/g' |\
sed 's/:=/ = /' |\
sed 's/\*\*/\^/g' |\
sed 's/mtt\([a-z]\)\([a-z]*\)\([0-9]\)\([0-9]*\)/mtt\1\2(\3\4)/g' |\
gawk '{
  sub(/^[\ ]*/, "", $0)
  sub(/\$$/, ";", $0)
  
  if (match($NF,"[;#.%]$")==0){
    Previous[++i] = $0
  }
  else {
    for (j=1;j<=i;j++) printf("%s", Previous[j]);
    printf("%s\n", $0) 
    i=0;
  }
}' |\
sed 's/#/%/g'

Deleted mttroot/mtt/bin/trans/mtt_pdf.sty version [9e3fc0e565].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Style file for postscript document

\usepackage{mtt} % Common stuff

% Figure definition
\newcommand{\fig}[4]{
  \begin{figure}[htbp]
    \begin{center}
      \fbox{
        \pdfimage width #3\linewidth {#1.pdf}
        %\includegraphics[width=#3\linewidth]{#1.ps}
        }
        \caption{#4}
      \label{fig:#2}
    \end{center}
  \end{figure}
  }

% Hyper stuff
\usepackage[implicit=true,
            bookmarks=true,
            pdfauthor={MTT},
            pdftitle={MTT report},
            pdfsubject={MTT},
            pdfkeywords={MTT, bond graphs}]{hyperref}

Deleted mttroot/mtt/bin/trans/mtt_pinclude version [2dabecc7a7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# pinclude - explicitly includes Pascal files - p2c has probs. doing this

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:56:46  peterg
## Put under RCS
##
###############################################################



gawk ' {
  if ( (match($1,"{\\$I")>0) || (match($1,"\\*\\$I")>0) ) {
    sub(/}/,"",$2); 
    command=sprintf("mtt_pinclude %s",$2); 
    system(command)
  }
  else{
  print $0
  }
  

}' <$1

Deleted mttroot/mtt/bin/trans/mtt_prepend.sh version [83feb02b68].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

usage ()
{
cat <<EOF

Usage: $0 [-p] file1 file2

       prepend file1 to file2
    
    options:

      -p preserves time attribute

EOF
}

preserve=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-p)
	    preserve='-p'
	    ;;
	-h)
	    usage
	    exit
	    ;;
	 *)
	    echo "Error: invalid option ($1)"
	    usage;
	    exit;
	    ;;
    esac
    shift
done

if [ $# -ne 2 ]; then
    usage;
    exit;
fi

file1=$1
file2=$2
tmp=mtt_prepend.sh_$file1_$file2.tmp

if [ ${preserve:=""} = "-p" ]; then
    time=mtt_prepend.sh_$file2.time
    touch -r $file2 $time
fi

cat $file1 $file2 > $tmp

if [ ${preserve:=""} = "-p" ]; then
    touch -r $time $tmp
    rm $time
fi

cp $preserve $tmp $file2
rm $tmp

Deleted mttroot/mtt/bin/trans/mtt_ps.sty version [54d658c739].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Style file for postscript document

%%\usepackage{mtt} % Common stuff (Needs to be explicit now)

%Postscript figures 
\usepackage{graphicx,color}

% Figure definition
\newcommand{\fig}[4]{
  \begin{figure}[htbp]
    \begin{center}
      \fbox{
        \includegraphics[width=#3\linewidth,height=18cm,keepaspectratio]{#1.ps}
        }
        \caption{#4}
      \label{fig:#2}
    \end{center}
  \end{figure}
  }

  \newcommand{\tfig}[4]{
    \begin{figure}[htbp]
      \begin{center}
        \fbox{
          \resizebox{#3\linewidth}{!}{\input{#1}}
        }
        \caption{#4}
        \label{fig:#2}
      \end{center}
    \end{figure}
  }


% Hyper stuff
\usepackage[implicit=true,
            bookmarks=true,
            pdfauthor={MTT},
            pdftitle={MTT report},
            pdfsubject={MTT},
            pdfkeywords={MTT, bond graphs}]{hyperref}

Deleted mttroot/mtt/bin/trans/mtt_r2m version [0603bb581c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_r2m
# Reduce to octave conversion
# Based on obsolete ode_r2m  and ode_r2lang
# Based on obsolete mtt_r2m_old
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95, May 1998
# July 1998
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996, 1998
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.33  2004/08/29 03:17:02  geraint
## Vectorise sesx and sesy.
##
## Revision 1.32  2003/04/17 20:07:33  geraint
## Added rule to create _sese.m
##
## Revision 1.31  2002/09/16 08:08:00  geraint
## Merged changes from global-optimisation branch.
##
## Revision 1.30.4.1  2002/09/03 23:44:43  geraint
## adding global optimisation (-optg).
##
## Revision 1.30  2002/03/26 11:59:54  geraint
## Added dummy -optimise switch to prevent falling over for -cc generation.
##
## Revision 1.29  2001/09/07 00:25:56  geraint
## Partial fix for insidious bug which eliminates lines of code when parameter
## names of the form (in* or off*) start continuation lines.
##
## Revision 1.28  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.27.4.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.27  2001/02/08 00:39:56  geraint
## Removed clear from code generated by: mtt -c -i euler -o
##
## Revision 1.26  2000/11/27 11:52:10  peterg
## Changed some greps to be case insensitive
##
## Revision 1.25  2000/10/14 08:50:07  peterg
## Use new mtt_header
##
## Revision 1.24  2000/10/11 09:07:53  peterg
## Vectorisation
## csex rep.
##
## Revision 1.23  2000/10/10 21:00:43  peterg
## More reps added
##
## Revision 1.22  2000/09/15 08:27:07  peterg
## Removed debugging lines
##
## Revision 1.21  2000/08/30 11:43:40  peterg
## -optimise switch added
##
## Revision 1.20  2000/08/30 10:43:17  peterg
## Simplified version using GENTRAN matrix :=: matrix
## lang_matrix is no longer used at all
##
## Revision 1.19  2000/08/28 20:17:59  peterg
## Put in Winfried Neun's bug fix
## -- prevents segmentation violation using optimised gentran when matrix
## comtains a number
##
## Revision 1.18  2000/08/24 17:11:40  peterg
## Now optimises as well as segmenting - uses the SCOPE package
##
## Revision 1.17  2000/05/20 15:23:56  peterg
## Paramererised version of sm etc etc (using -parameter switch)
##
## Revision 1.16  2000/04/18 11:14:18  peterg
## Put in the -parameters option
##
## Revision 1.15  2000/02/10 14:58:57  peterg
## *** empty log message ***
##
## Revision 1.14  1999/12/08 02:06:00  peterg
## Now incudes csm rep.
##
## Revision 1.13  1999/11/23 00:59:14  peterg
## Now does ssm.m
##
## Revision 1.12  1999/11/15 22:57:20  peterg
## Removed a debugging line
##
## Revision 1.11  1999/11/01 21:20:14  peterg
## Removed the E matrix from the cse file.
##
## Revision 1.10  1999/10/27 07:38:30  peterg
## Now does cse version -- but not needed now exept for Euler integration
##
## Revision 1.9  1999/10/26 23:47:58  peterg
## Now does cse.m file
##
## Revision 1.8  1999/07/26 06:07:19  peterg
## Reinstated removal of the odeo.p file
##
## Revision 1.7  1999/03/16 00:38:06  peterg
## Done some more tidying up
##
## Revision 1.6  1999/03/15 07:29:25  peterg
## Fixed various obscure reduce bugs
## THIS NEEDS A MAJOR REWRITE!!!!
##
## Revision 1.5  1998/08/13 16:25:07  peterg
## Removed some documentation form odeo.m
##
## Revision 1.4  1998/08/13 15:10:47  peterg
## Change temp var name to mtt_t1 etc
##
## Revision 1.3  1998/08/13 12:43:19  peterg
## Cahnged tmp variable to mtt_1 etc
##
## Revision 1.2  1998/07/27 20:26:44  peterg
## Put in correct N and M values for dm rep
##
## Revision 1.1  1998/07/27 16:30:26  peterg
## Initial revision
##
###############################################################


# Args
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
    -noglobals)
	noglobals='-noglobals';
	;;
    -parameters)
	parameters='-parameters';
        par='mttpar'
	;;
    -optimise_local | -optimise_global )
	;;
    *)
	echo $1 is an unknown option
        exit;;
  esac
  shift
done

# Set up some strings
rep=$2
ext=m
out=$1"_"$rep.$ext

#Inform user
echo Creating $out

# Remove the old log file
rm -f mtt_r2m.log

#Header
case $rep in
    ae|csex|cseo|ode|odeo|sae|sese|sesx|sesy)
    vectorise=yes
       ;;
    *)
esac

    mtt_header  $1 $rep $ext  > mtt_junk

#Convert from the (optimised) r file
echo >> mtt_junk
echo '## Code' >> mtt_junk
strip_comments<$1_$2.r |\
tr [A-Z] [a-z] |\
grep -vi 'MATRIX ' |\
grep -vi 'END;' |\
grep -vi 'clear mtt' |\
grep -v '^off .*\$' |\
grep -v '^in .*\$' |\
sed \
    -e "s/^mtt/  mtt/" \
    -e "s/:=/=/" \
    -e "s/\\$/;/" \
 >> mtt_junk
echo '## END Code' >> mtt_junk
echo endfunction >> mtt_junk

# Mend broken lines
mtt_mend_lines < mtt_junk > mtt_junk_mended
# Vectorise (n,1) arrays when appropriate
if [ -n "$vectorise" ]; then
     mtt_vectorise <mtt_junk_mended >$out
else
     mv mtt_junk_mended $out
fi

# Now invoke the standard error handling.
#mtt_error_r mtt_r2m.log



Deleted mttroot/mtt/bin/trans/mtt_remove_underscore version [539a78771f].

1
2
3



-
-
-
#!/bin/sh

sed 's/_/\\_/g'

Deleted mttroot/mtt/bin/trans/mtt_repname version [bde7d0e306].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_repname

# Returns the representation name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | tr '.' '_' | gawk -F '_' '{print $2}'

Deleted mttroot/mtt/bin/trans/mtt_strip_args version [bcb8540542].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: strip args
# Strips unwanted bits from a list of arguments
# Label file to symbolic parameters conversion
# Copyright (C) 2000 by Peter J. Gawthrop

## $Id$  ##
## $Log$
## Revision 1.6  2001/07/04 06:00:12  gawthrop
## Fixed a funny with tr - changed SEPS and REPS - something to do with ^
##
## Revision 1.5  2001/06/13 14:50:13  gawthrop
## Operator ^ now ok in args in abg and/or lbl
##
## Revision 1.4  2001/05/08 15:18:10  gawthrop
## Added trig and hyperbolic functions to argument exclusion list
##
## Revision 1.3  2000/10/17 12:33:13  peterg
## Added mtt_mod to the zapped list
##
## Revision 1.2  2000/10/16 09:06:26  peterg
## Write out the system as a second columns as well
##
## Revision 1.1  2000/10/16 09:04:04  peterg
## Initial revision
## ##
# Inform user
#echo "Creating $1_sympar.txt"

# Separation characters
SEPS='^=*;+/()-'
# Replace by ,
REPS='[,*]'


# This is the main transformation using gawk
tr $SEPS $REPS | \
gawk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}

function matches(names, name) {
  n_matches = split(names,match_name);
  matched = 0;
  for (i_matches = 1; i_matches <= n_matches; i_matches++) {
    if ( exact_match(name,match_name[i_matches]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
}

BEGIN {
 not_an_arg = "effort flow state internal external zero unknown\
                mtt_e mtt_f\
		sqrt exp log sign sin asin cos acos tan atan \
		sin asin cos acos tan atan \
		sinh asinh cosh acosh tanh atanh \
                none abs";
}
{
    args=$1
    sys=$2
    N=split(args, arg, ",");
    for (i=1;i<=N;i++){
      if ( (length(arg[i])>0)&&(matches(not_an_arg,arg[i])==0)&&(match(arg[i],"^[0-9]+[.]*")==0) ){
        printf("%s\t%s\n", arg[i], sys);
      }
  }
}' |\
grep -v '^\$' 



Deleted mttroot/mtt/bin/trans/mtt_sysname version [4a73c625bc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_sysname

# Returns the system name from System_rep.lang

# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

echo $1 | gawk -F '_' '{print $1}'

Deleted mttroot/mtt/bin/trans/mtt_txt2declare version [63bdb9c744].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2declare

# Symbolic parameters to variable declaration
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/10/14 09:32:50  peterg
## struc version only does state and input
##
## Revision 1.1  2000/10/14 09:26:48  peterg
## Initial revision
##
## Revision 1.1  2000/10/11 09:08:20  peterg
## Initial revision
##

###############################################################

sys=$1
what=$2
language=$3

case $language in
    p)
        first="VAR";
        delim=", ";
        last=': REAL;';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

case $what in
    struc)
	strip_comments < $sys"_"$what".txt" | gawk '{if (($1=="state")||($1=="input"))
                                                      print $4;
                                                   }' >mtt_names
	;;
    sympar)
      	strip_comments < $sys"_"$what".txt" | gawk '{print $1}' >mtt_names
	;;
    *)
	echo Argument 2 must be struc or sympar
esac

# Start
cat<<EOF
$first
EOF
#Write out the variables 
gawk '{
  i++; 
  var[i] = tolower($1);
}
END{
  n = i;
  for (i=1; i<n; i++){
    printf("%s%s",var[i], delim);
    j++; 
    if (j>4){
    printf("\n"); j=0;
    }
  }
  printf("%s%s\n",var[n], last);

}' "delim=$delim" "last=$last" mtt_names


Deleted mttroot/mtt/bin/trans/mtt_txt2m version [46dbec9921].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292




































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_txt2m
# Converts txt file to matlab file (for numpar and state)

# Copyright (c) P.J.Gawthrop 1998


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.17  2002/04/28 18:41:27  geraint
# %% Fixed [ 549658 ] awk should be gawk.
# %% Replaced calls to awk with call to gawk.
# %%
# %% Revision 1.16  2002/04/18 17:51:11  gawthrop
# %% Put default values in _simpar.m in case of missing values in txt file
# %%
# %% Revision 1.15  2002/03/26 12:00:37  geraint
# %% Escaped characters to eliminate awk warnings.
# %%
# %% Revision 1.14  2001/07/13 04:54:04  geraint
# %% Branch merge: numerical-algebraic-solution back to main.
# %%
# %% Revision 1.13.4.2  2001/07/09 00:24:58  geraint
# %% input rep: Removed input name mapping, left state name mapping.
# %%
# %% Revision 1.13.4.1  2001/06/26 01:01:28  geraint
# %% Makes input and state names available for input rep.
# %%
# %% Revision 1.13  2001/02/05 03:33:18  geraint
# %% Convert user-defined txt to lower-case in translation.
# %% Required by logic.m (Octave is case sensitive).
# %%
# %% Revision 1.12  2000/11/08 11:20:49  peterg
# %% removed the empty matrix stuff
# %%
# %% Revision 1.11  2000/10/17 09:55:21  peterg
# %% Added logic rep
# %%
# %% Revision 1.10  2000/10/15 09:51:50  peterg
# %% Set array code in input rep
# %%
# %% Revision 1.9  2000/10/13 11:07:33  peterg
# %% Started conversion to new style state, input ext
# %%
# %% Revision 1.8  2000/09/30 13:53:07  peterg
# %% Default to empty matix in numpar.m -- avoids probs for parameter-free systems
# %%
# %% Revision 1.7  2000/05/19 17:46:17  peterg
# %% Give argument to state
# %%
# %% Revision 1.6  2000/05/19 14:59:03  peterg
# %% MTT --> mtt in fun output
# %%
# %% Revision 1.5  2000/05/19 14:05:10  peterg
# %% Zero parameters in the numpar.m file
# %%
# %% Revision 1.4  2000/05/18 12:05:42  peterg
# %% Replaced sympar by sympars in numpar rep
# %%
# %% Revision 1.3  2000/05/11 16:09:24  peterg
# %% Put in simpar.first parameter
# %%
# %% Revision 1.2  2000/05/11 12:16:46  peterg
# %% New version of simpar - with record
# %%
# %% Revision 1.1  2000/05/11 10:55:57  peterg
# %% Initial revision
# %%
# %% Revision 1.19  2000/02/11 13:35:16  peterg
# %% Added the new MTTpar generation
# %%
# %% Revision 1.18  1999/11/14 22:22:17  peterg
# %% Removed checks for implicit - now done at command-line level.
# %%
# %% Revision 1.17  1999/11/04 04:54:24  peterg
# %% Removed recreation of smx file.
# %%
# %% Revision 1.16  1999/03/06 02:18:10  peterg
# %% Changed argument list.
# %%
# %% Revision 1.15  1999/02/16 21:44:38  peterg
# %% Revised smx generation
# %%
# %% Revision 1.14  1999/02/16 04:38:22  peterg
# %% Now forces creation of _smx file if METHOD=IMPLICIT in simpar.txt
# %%
# %% Revision 1.13  1998/08/31 11:43:37  peterg
# %% Now lower cases globals in numpar files
# %%
# %% Revision 1.12  1998/08/14 10:47:31  peterg
# %% Put ImplicitS sub before Implicit!!
# %%
# %% Revision 1.11  1998/08/14 10:43:44  peterg
# %% Added ImplicitS - sparse integration
# %%
# %% Revision 1.10  1998/08/11 13:27:51  peterg
# %% Lowercase mttLAST etc
# %%
# %% Revision 1.9  1998/07/30 15:07:17  peterg
# %% Added _ to the disallowed chars around t
# %%
# %% Revision 1.8  1998/07/30 12:52:38  peterg
# %% Adds ; to end of statements
# %% Translates ' to " before removal
# %%
# %% Revision 1.7  1998/07/30 09:32:33  peterg
# %% Replaces:
# %% 	euler by 1
# %% 	implicitl by 1
# %% 	implicit  by 3
# %%
# %% Revision 1.6  1998/07/27 18:59:11  peterg
# %% Added WMIN etc
# %%
# %% Revision 1.5  1998/07/26 11:54:20  peterg
# %% Added  mtt to variables
# %%
# %% Revision 1.4  1998/07/26 09:50:12  peterg
# %% More forgiving of txt sytax.
# %%
# %% -- can use () or ()
# %% -- can use mttx() or x()
# %% -- can use mttu() or u()
# %%
# %% Revision 1.3  1998/07/25 20:40:35  peterg
# %% All vars in lower case now
# %%
# %% Revision 1.2  1998/07/25 09:48:31  peterg
# %% Tidied up for Pascal version
# %%
# %% Revision 1.1  1998/02/25 22:10:25  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

system=$1
representation=$2
outfile=$1_$2.m

tolower () { tr [A-Z] [a-z] ;}

# Inform user
echo Creating $outfile

#Create the rep  file complete with headers.
case $representation in
    input)
      name=mttu
      arraycode=$representation
      ;;
    logic)
      name=mttx
      ;;
    numpar)
       name=mttpar
      arraycode=$representation
      ;;
    simpar)
      ;;
    state)
      name=mttx
      arraycode=$representation
      ;;
    *)
      echo Representation $representation not supported
      exit
      #echo "function $name = $1_$2$arg" > $outfile
      #echo "%% $2 file ($1_$2.m)" >> $outfile
      #echo "%% Generated by MTT at `date`" >> $outfile
      #echo "% Global variable list" >>  $outfile
      #sympar2global_txt2m $1 >> $outfile
      ;;
esac

# Generate the header
mtt_header $system $representation m  > $outfile

## Special for logic rep
if [ "$representation" = "logic" ]; then
  echo >> $outfile
  echo "## Inputs" >> $outfile
  mtt_name2array $system input >> $outfile # Set up input by name
  echo >> $outfile
  echo "## States" >>$outfile
  mtt_name2array $system state >> $outfile # Set up state by name
fi

## Special for input rep
if [ "$representation" = "input" ]; then
  echo >> $outfile
  echo "## States" >>$outfile
  mtt_name2array $system state >> $outfile # Set up state by name
fi

## Special for simpar rep
if [ "$representation" = "simpar" ]; then
  cat >> $outfile<<EOF

## Defaults (in case of missing values in txt file)
  mttsimpar.first       =  0.0;      
  mttsimpar.last        =  10.0;      
  mttsimpar.dt          =  0.1;        
  mttsimpar.stepfactor  =  1;          
  mttsimpar.wmin        =  -1;         
  mttsimpar.wmax        =  2;          
  mttsimpar.wsteps      =  100;        
  mttsimpar.input       =  1; 

EOF
fi

# Write out the code from the txt file
echo >> $outfile
echo "## User defined code from $1_$2.txt" >> $outfile
cat  $1_$2.txt | strip_comments | grep -v METHOD |\
gawk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");
  if (N==2) {
    LHS = a[1];
    RHS = a[2];
    gsub(quote, doublequote, RHS);
    sub(/^[ 	]*FIRST/, "MTTsimpar.FIRST", LHS);
    sub(/^[ 	]*DT/, "MTTsimpar.DT", LHS);
    sub(/^[ 	]*LAST/, "MTTsimpar.LAST", LHS);
    sub(/^[ 	]*STEPFACTOR/, "MTTsimpar.STEPFACTOR", LHS);
    sub(/^[ 	]*METHOD/, "MTTsimpar.METHOD", LHS);
    sub(/^[ 	]*WMIN/, "MTTsimpar.WMIN", LHS);
    sub(/^[ 	]*WMAX/, "MTTsimpar.WMAX", LHS);
    sub(/^[ 	]*WSTEPS/, "MTTsimpar.WSTEPS", LHS);
    sub(/^[ 	]*INPUT/, "MTTsimpar.input", LHS);
    LHS = tolower(LHS);
    RHS = tolower(RHS);
    sub(/["]*euler["]*/, 1, RHS);   
    sub(/["]*implicit["]*/, 2, RHS);  
    statement = sprintf("%s= %s",LHS,RHS);
    if ( (match(statement,";")==0)&&\
         ((match(statement,"if ")==0))&&\
         ((match(statement,"for ")==0)) )
      statement = sprintf("%s;", statement);
  }
  else if (match($1,"global")==1) {
    statement = tolower($1); # Lower case globals as well
  }
  else
    statement = $1;

  if (NF<2) print "  " statement
  if (NF>1)  print statement " # " $2
}' | sed\
     -e 's/\[\([0-9]*\)\]/(\1)/g' \
     -e 's/\([^a-zA-Z_0-9]\)t\([^a-zA-Z_0-9]\)/\1mttt\2/g' \
     -e 's/\([^a-zA-Z_0-9]\)x(/\1mttx(/g' \
     -e 's/\([^a-zA-Z_0-9]\)u(/\1mttu(/g' \
     -e 's/mttmtt/mtt/g' \
| tolower >> $outfile

if [ -n "$arraycode" ]; then
  new_style=`strip_comments < $1_$2.txt| grep "$name(">/dev/null; echo $?`

  if [ "$new_style" = "1" ]; then
    echo >> $outfile
    echo "  ## Set up the $name vector"  >> $outfile
    ## echo "  $name = []; # Default to empty matrix (Remove in mtt_m2p)"  >> $outfile
    mtt_name2array $1 $arraycode set   >> $outfile
  else
    echo "Old-style file detected: not creating array translations"  
  fi
fi

## Special for logic rep
if [ "$representation" = "logic" ]; then
  echo >> $outfile
  echo "## Open switches" >> $outfile
  switch_txt2m $system | tolower >> $outfile
fi

# End of the function
echo '## END Code' >> $outfile
echo 'endfunction' >> $outfile

Deleted mttroot/mtt/bin/trans/mtt_uncompress.sh version [164628bbec].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

file=$1

gzip --test --quiet $file 2> /dev/null ; file_is_uncompressed=$?

if [ $file_is_uncompressed -eq 0 ]; then
    gz=`mktemp $file.gz.tmpXXXXXX`
    mv $file $gz
    zcat $gz > $file
fi

Deleted mttroot/mtt/bin/trans/mtt_units.sh version [40d4f9eae3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## MTT units script - wrapper for the units program.

# Copyright (C) 2000 by Peter J. Gawthrop

# Arguments
sys=$1
port=$2
domain=$3
effort=$4
flow=$5

case ${domain} in
    electrical)
	base_effort=volt
	base_flow=amp
	;;
    translational)
	base_effort='newton'
	base_flow='m/s'
	;;
    rotational)
	base_effort='newton*m'
	base_flow='radian/s'
	;;
    fluid)
	base_effort='Pa'
	base_flow='m^3/s'
	;;
    thermal)
	base_effort='degK'
	base_flow='watt/degK'

	;;
    *)
	echo ${sys} ${port} DOMAIN_ERROR invalid domain ${domain}
	exit 1
esac

get_unit()
{
  if [ "$2" == "none" ]; then
      echo 1
  else
      factor=`units $2 $3 | head -1 | sed 's/\*//'`
      if [ `echo $factor | wc -w` = "1" ]; then
	  echo $factor
      else
	  echo $1_UNIT_ERROR unit $2 not compatible with domain ${domain}
      fi
  fi
}
## Check effort and flow for comptability + find factor
effort_factor=`get_unit EFFORT $effort $base_effort`
flow_factor=`get_unit FLOW $flow $base_flow`

echo ${sys} ${port} ${effort_factor} ${flow_factor}

Deleted mttroot/mtt/bin/trans/mtt_update version [62e70479ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309





















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_update
# Generates Updates core representations
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.23  2005/02/17 18:54:23  geraint
## Fixed a bash-sim: replaced let with $(( ))
##
## Revision 1.22  2003/08/19 13:08:44  gawthrop
## Ingnore if/endif
##
## Revision 1.21  2003/08/14 10:33:46  gawthrop
## Ignore if and endif
##
## Revision 1.20  2003/08/13 15:49:39  gawthrop
## Don't sort the states when defaulting - leave in implied order
##
## Revision 1.19  2003/08/05 15:29:36  gawthrop
## Now handles ss.r files with implicit zero values
##
## Revision 1.18  2003/08/04 09:10:30  gawthrop
## Now handles steady-state computation for _state.txt.
##
## Revision 1.17  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.16  2000/10/17 13:45:18  peterg
## split up state and input - different defaults
##
## Revision 1.15  2000/10/17 09:53:05  peterg
## More on logic rep
##
## Revision 1.14  2000/10/17 08:36:56  peterg
## Included logic rep.
##
## Revision 1.13  2000/10/15 09:27:13  peterg
## Better way of generating $infofile
##
## Revision 1.12  2000/10/14 16:11:00  peterg
## Made all variables, states etc lower case
##
## Revision 1.11  2000/10/13 11:07:00  peterg
## Added initialisation for state and input
##
## Revision 1.10  2000/10/13 10:56:07  peterg
## Now uses the full name from the struc file - no need to recreate.
##
## Revision 1.9  2000/10/13 09:55:09  peterg
## Changed state/input name to $4_$3
##
## Revision 1.8  2000/10/13 09:28:16  peterg
## Changed regexp to /\(.*$old.*=\)/
##
## Revision 1.7  2000/10/13 08:56:51  peterg
## Output variables as column, not row.
##
## Revision 1.6  2000/10/13 08:07:24  peterg
## Added state and input - it checks against sympar as well so that
## defined variables may be used here.
##
## Revision 1.5  2000/10/12 19:24:55  peterg
## Corrected output message
##
## Revision 1.4  2000/10/12 17:57:34  peterg
## Fixed header typos
##
## Revision 1.3  2000/10/12 15:11:30  peterg
## Added the update switch
##
## Revision 1.2  2000/10/12 13:45:13  peterg
## Put in the no-file version
##
## Revision 1.1  2000/10/12 12:32:23  peterg
## Initial revision
##
##
###############################################################


sys=$1 # System name
rep=$2 # System representation
update=$3 # Update or not
date=`date`

if [ -z "$2" ]; then
  echo Usage mtt_update system representation [update]    
  exit
fi

## Extract initial value from steady-state information
initial_value() {
    i=$1
    default=$2
    ssfile=${sys}_ss.r
    if [ "${rep}" = "state" ]; then
       if [ -f "${ssfile}" ]; then
	count=`grep -c "^MTTx($i" ${ssfile}`; # See if its there
	if [ $count = "1" ]; then
	    value=`grep "^MTTx($i" ${ssfile}| sed 's/ //g' | gawk -F '=' '{print substr($2,1,length($2)-2)}'`	    
	else
	    value="0.0"
	fi
       else
	value=${default}   
       fi 
    else
	value=${default}
    fi
}

## Remove if, end and endif from list
remove_if() {
    file=$1
    if [ -f ${file} ]; then
      tmpfile="$1_tmp"
    
      mv ${file} ${tmpfile}
      grep -v 'if[ (]\|endif;' <${tmpfile} > ${file} 

      ## Delete empty file
      size=`ls -s ${file} | awk '{print $1}'`
      if [ "${size}" = "0" ]; then
	  rm $file
      fi
    fi
 }
 rm -f mtt_empty
 touch mtt_empty

 case $rep in
     numpar)
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=$1_sympar.$lang
	     moreinfofile=$infofile
	     default='1.0'
	 ;;
     input)
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=mtt_list.$lang
	     moreinfofile=mtt_list_numpar.$lang
	     gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
	     <$1_struc.txt >$infofile
	     cat $infofile $1_sympar.$lang> $moreinfofile  
	     default='1.0'
	  ;;
     state)
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=mtt_list.$lang
	     moreinfofile=mtt_list_numpar.$lang
	     gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
	     <$1_struc.txt >$infofile
	     cat $infofile $1_sympar.$lang> $moreinfofile  
	     default='0.0'
	  ;;
     logic) 
	     lang=txt
	     textfile=$1_$2.$lang
	     infofile=mtt_list.$lang
	     moreinfofile=mtt_list_numpar.$lang
	     gawk '{if ($3=="MTT_SWITCH") printf("%s_logic\n", $4)}' rep=$2 \
	     <$1_struc.txt >$infofile
	     cat $infofile $1_sympar.$lang> $moreinfofile  
	     default='1.0'
	 ;;
     *)
	     echo Representation $rep not implemented
	     exit
 esac

 # Create a string containing the variables
 if [ -f "$textfile" ]; then
   # Inform User
   echo Checking $textfile
 else
   echo Creating $textfile
   mtt_header $sys $rep $lang > $textfile 
     if [ "${rep}" = "state" ]; then
	 info=`cut -f1 $infofile` # No sort
     else
	 info=`cut -f1 $infofile | sort` # Sort
     fi
   i=0;
   for new in $info; do
     i=$(( $i + 1 ));
     initial_value $i ${default}
     echo $new $value  |\
     gawk '{printf("%s\t= %s; # Default\n",$1,$2)}' >> $textfile
   done
   exit    
 fi

 # Remove tmp files
 rm -f mtt_in_text mtt_in_info

 # Strip files
 strip_comments <$textfile | tr 'A-Z' 'a-z' >mtt_text
 strip_comments <$infofile | tr 'A-Z' 'a-z' >mtt_info
 strip_comments <$moreinfofile  | tr 'A-Z' 'a-z' >mtt_moreinfo

 # Use awk to check file
 gawk '{
   if (FILENAME=="mtt_text") {
     gsub("[\t ]" ,""); # Remove whitespace
     split($0,a,"=");
     text[a[1]] = a[2];
   }
   if (FILENAME=="mtt_info"){
      info[$1] = Default;
   }
   if (FILENAME=="mtt_moreinfo"){
      moreinfo[$1] = Default;
   }
   }
 END{
   # for (iname in info) print iname
   for (tname in text) {
     if (!(tname in moreinfo)) print tname >> "mtt_in_text"
   }
   for (iname in info) {
     if (!(iname in text)) print iname >> "mtt_in_info"
   }
   }'  Default=$default mtt_text mtt_info mtt_moreinfo

 ## Remove if, end and endif from list
 remove_if mtt_in_text

if [ -z "$update" ]; then
  if [ -f "mtt_in_text" ]; then
    echo "The following variables are defined in $textfile, but do not exist:"
    sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  if [ -f "mtt_in_info" ]; then
    echo "The following variables exist, but are not defined in $textfile:"
    sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'
    echo Use mtt $sys $rep $lang to update
  fi
  exit    
fi
answered=''
if [ -f "mtt_in_text" ]; then
  in_text=`sort mtt_in_text`
  echo "The following variables are defined in $textfile, but do not exist:"
  sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'


  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)
	    answered=yes
 	    for old in $in_text; do
              echo Commenting out $old
	      sed "s/\(.*$old.*=\)/## Removed by MTT on $date: \1/I"\
               <$textfile > mtt_tmp
              mv mtt_tmp $textfile
              changed=yes
	    done
	    ;;
	n)
	    answered=yes
	    ;;
	*)
    esac
  done      
fi

answered=''
if [ -f "mtt_in_info" ]; then
  echo "The following variables exist, but are not defined in $textfile:"
  sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'

  while [ -z "$answered" ]; do
    echo "Update $textfile (y/n)?"
    read answer < /dev/tty
    case $answer in
	y)
	    answered=yes
            in_info=`sort mtt_in_info`
 	    for new in $in_info; do
                echo Adding $new
                echo $new $default  |\
                gawk '{printf("%s\t= %s; # Added by MTT on %s\n",$1,$2,strftime())}'\
                >> $textfile
                changed=yes
	    done
	    ;;
	n)
	    answered=yes
	    ;;
	*)
    esac
  done      
fi

Deleted mttroot/mtt/bin/trans/mtt_vectorise version [637c205a0e].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
#!/bin/sh
# Vectorises the matrix output of reduce ie converts (n,1) to (n)
# Copyright (C) 2000 by Peter J. Gawthrop

sed 's/mtt\([a-z]*\)(\([0-9]*\),1)/mtt\1(\2)/g'


Deleted mttroot/mtt/bin/trans/multi_command version [b29c24f12c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: multi_command

# Copyright (c) P.J.Gawthrop 1996.

# creates a list of commands - one for each file matching $2_*_$3
# Each command is of the form $1 $2_*_$3 &

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2.4.1  2001/06/28 22:58:27  geraint
## Using mtt_xargs.sh to prevent Arg list too long error.
##
## Revision 1.2  1996/11/09 21:16:06  peterg
## *** empty log message ***
##
# Revision 1.1  1996/10/21  12:31:40  peterg
# Initial revision
#
###############################################################


(mtt_xargs.sh "ls" "$2*_$3" \
| sed "s/\(.*_*\)$3/$1 \1$3 \&/")

Deleted mttroot/mtt/bin/trans/n2m version [408bb45747].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: n2m
# Gives sting of integers from n to m (n<=m)
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

i=`expr $1 - 1`

while [ "$i" != "$2" ]; do
    i=`expr $i + 1`
    echo $i
done

Deleted mttroot/mtt/bin/trans/name2index version [f7933c91d6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: name2index

# Converts names to array index

# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/11/27 18:06:33  peterg
## *** empty log message ***
##
## Revision 1.4  1997/12/04 22:10:18  peterg
## Handles argument list - variable names.
##
## Revision 1.3  1997/05/22 09:42:48  peterg
## Returns 0 if no names.
##
## Revision 1.2  1997/05/22 09:28:22  peterg
## Removed trailing , in output.
##
## Revision 1.1  1997/05/22 08:48:21  peterg
## Initial revision
##
###############################################################

gawk '
{
  name_index[$4]=$2;
}
END{
  M=split(names,xynames,":");
  if (M==0)
    printf("0\n")
  else
    {
    if (M==1) 
      printf("1,");
    else {  
        printf("%i,",name_index[xynames[1]]+1);
        names=xynames[2]
       }

    N=split(names,Names,",");
    for (i=1; i<N; i++)
      printf("%i,",name_index[Names[i]]+1);
  printf("%i\n",name_index[Names[N]]+1);
  }
}'  names=$2 < $1_struc.txt

  

Deleted mttroot/mtt/bin/trans/numpar2subs_txt2r version [7658495930].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
## Makes algebraic substitution file from numpar file.
## Omitting all parameter in 2nd argument

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  2002/11/14 05:48:53  gawthrop
  ## Useful utility not yet in mtt
  ##
  ###############################################################

# Copyright (C) 2002 by Peter J. Gawthrop

sys=$1
pars=$2

outfile=${sys}_subs.r
infile=${sys}_numpar.txt

echo Creating ${outfile} from ${infile}
cat<<EOF > ${outfile}_1
%% File ${outfile} generated on `date` from  ${infile}
%% All parameters replaced by numbers except for:
%%   ${pars}

EOF

sed 's/#/%/g' < ${infile} | sed 's/=/:=/' >> ${outfile}_1

cat >> ${outfile}_1 <<EOF
ON ROUNDED; %% Floating point
END;
EOF

gawk '
{
N=split(pars,par);
matched=0;
for (i=1;i<=N;i++)
  if ($1==par[i]) 
    matched=1;

if (!matched) print $0
}' pars="$pars" < ${outfile}_1 > ${outfile}

rm ${outfile}_1

Deleted mttroot/mtt/bin/trans/numpar_txt2c version [c7bf2ec183].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: numpar_txt2c

# Numerical parameters to c format
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2000/12/28 12:52:13  peterg
## *** empty log message ***
##
## Revision 1.5  1997/06/13 09:42:25  peterg
## Auto change of () to []
##
# Revision 1.4  1997/05/15  08:33:07  peterg
# Declare state array (x).
#
# Revision 1.3  1997/05/03  15:01:42  peterg
# Don't write out RCS headers.
#
# Revision 1.2  1997/05/01  08:35:18  peterg
# # is now the comment symbol in the .txt file
#
# Revision 1.1  1997/05/01  08:25:31  peterg
# Initial revision
#
###############################################################

system=$1
representation = $2

# Inform user
echo "Creating $1_numpar.c"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_numpar.c
echo "Parameter file for system $1 ($1_numpar.c)"   >> $1_numpar.c
echo "This file provides the system numerical parameters in c form"  >> $1_numpar.c
echo "Generated by MTT at `date`"  >> $1_numpar.c
echo '*/' >> $1_numpar.c
echo  >> $1_numpar.c

echo "extern double x[MTTNX1];"  >> $1_numpar.c
echo "#include \"$1_sympar.c\""  >> $1_numpar.c
echo "$1_numpar()" >> $1_numpar.c
echo '{' >> $1_numpar.c

#Write out the variables in c format.
sed 's/#C-CODE //'< $1_numpar.txt |\
gawk -F#  '{
  if (NF<2) print $1
  if (NF>1)  print $1 "/* " $2 " */"
}' | sed 's/(\([0-9]*\))/[\1]/'  >> $1_numpar.c

echo '}'  >> $1_numpar.c


Deleted mttroot/mtt/bin/trans/numpar_txt2m version [73ccf44327].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: numpar_txt2m
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:52:22  peterg
## *** empty log message ***
##
## Revision 1.3  1998/07/25 18:26:33  peterg
## *** empty log message ***
##
# Revision 1.2  1997/05/01  08:24:38  peterg
# Now uses # as the comment symbol in the .txt file
#
# Revision 1.1  1997/05/01  07:45:17  peterg
# Initial revision
#
###############################################################

# Inform user
echo Creating $1_numpar.m

#Create the numpar file complete with headers.
lang_header $1 numpar m '' MTTpar > $1_numpar.m

# Global variable list
#echo  >>  $1_numpar.m
#echo "# Global variable list" >>  $1_numpar.m
#sympar2global_txt2m $1 >> $1_numpar.m

#Write out the variables in m format.
gawk -F#  '{
  if (NF==1) print $1
  if (NF==2)  print $1 "# " $2
}' $1_numpar.txt |\
sed 's/double/global/' >> $1_numpar.m


Deleted mttroot/mtt/bin/trans/obs_r2m version [1411db277c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136








































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: obs_r2m
# Reduce GPC obs function to matlab
# P.J.Gawthrop 18 May 1991, 12 Jan 1994, April 1994, Dec 1994, July 1995
# Copyright (c) P.J.Gawthrop 1991, 1994.

# Inform user
echo Creating $1_obs.m

# Remove the old log file
rm -f obs_r2m.log
rm -f $1_obs.m?
rm -f $1_obsa.m

# Is the system affine (look in the _obs.r file
affine=`grep 'affine :=' $1_obs.r | gawk '{print $3}' | sed 's/;//'`


# Use reduce to accomplish the transformation
$SYMBOLIC >obs_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Set default values - reset by obspar file.
MTTGPCNy := 2;
MTTGPCNu := 0;

%Read the parameters file
in "$1_obspar.r";

%Read the simplification file
in "$1_simp.r";

%Read the reduce state-space equations   file
in "$1_obs.r";


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
OFF Nat;

ON NERO;        % Suppress zero elements

% Matrix output function
in"$MTTPATH/trans/matlab_matrix.r";

OUT "$1_obs.m2";

write "% Set up the State variables";
FOR i := 1:MTTNx DO
BEGIN
  write "mttx", i, " = x(", i, ");";
END;

IF affine=0 THEN 
BEGIN
write "%"; 
write "% Set up the inputs and input derivatives";
FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ",1);";
    FOR j := 1:MTTGPCNu DO
    BEGIN
      write "mttu", i,j, " = u(", i, ",", j+1, ");";
    END;
  END;

%write "%"; 
%write "% Set up the Y matrix";
%write "Y = zeros(", mtt_matrix_n, ",1);";
END;


SHUT "$1_obs.m2";

IF affine=1 THEN 
BEGIN
  GENTRANOUT "$1_obs.m3";
  MTT_Matrix := MTTObs_o$ 
  MTT_Matrix_name := "MTTO_o"$
  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN O_o := mtt_matrix;

  MTT_Matrix := MTTObs_h$ 
  MTT_Matrix_name := "MTTO_h"$
  MTT_Matrix_n := (MTTGPCNy+1)*MTTNy$
  MTT_Matrix_m := (MTTGPCNu+1)*MTTNu$
  matlab_Matrix()$
  GENTRAN O_h := mtt_matrix;

  GENTRANSHUT "$1_obs.m3";
END
ELSE
BEGIN
  GENTRANOUT "$1_obs.m3";
  mtt_matrix := MTTYY$
  mtt_matrix_n := MTTNY*(MTTGPCNy+1)$
  mtt_matrix_m := 1$
  mtt_matrix_name := Y$
  matlab_matrix(); 
  GENTRAN YY := mtt_matrix;
  GENTRANSHUT "$1_obs.m3";
END;

EOF

if [ "$affine" = "1" ]; then
    lang_header $1 obs m x [o_o,o_h] > $1_obs.m1
else
    lang_header $1 obs m x,u yy > $1_obs.m1
fi

# Put together the pieces
matlab_tidy $1_obs.m2
matlab_tidy $1_obs.m3
cat   $1_obs.m? >$1_obs.m

rm -f $1_obs.m?







Deleted mttroot/mtt/bin/trans/obs_r2tex version [f36c171b61].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: obs_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/04/07 08:30:20  peterg
## Initial revision
##
# Revision 1.3  1997/06/13  13:50:11  peterg
# Matrices in amstex format
#
# Revision 1.2  1997/04/18  12:54:00  peterg
# No longer does labels.
#
# Revision 1.1  1996/08/19  15:19:23  peter
# Initial revision
#
###############################################################


# Inform user
echo Creating $1_obs.tex

# Remove the old log file
rm -f obs_r2tex.log

# Use reduce to accomplish the transformation
reduce >obs_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the obs file
in "$1_obs.r";

%Read the Obs function parameters
in "$1_obspar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification parameters
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;

OUT "$1_obs.tex";

% Write the affine form
IF affine=1 THEN 
BEGIN
  MTT_Matrix := MTTObs_o$ 
  MTT_Matrix_name := "MTTO_o"$
  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
  MTT_Matrix_m := 1$
  LaTeX_Matrix()$

  MTT_Matrix := MTTObs_h$ 
  MTT_Matrix_name := "MTTO_h"$
  MTT_Matrix_n := (MTTGPCNy+1)*MTTNy$
  MTT_Matrix_m := (MTTGPCNu+1)*MTTNu$
  LaTeX_Matrix()$
END
ELSE
BEGIN
% Write the obs vector (YY)
  MTT_Matrix := MTTYY$ 
  MTT_Matrix_name := "MTTO"$
  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
  MTT_Matrix_m := 1$
  LaTeX_Matrix()$
END;

SHUT "$1_obs.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/octave_ode2odes version [abe17462de].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: octave_ode2odes
# Runs the Octave script $1_ode2odeso.m
# Copyright (c) P.J.Gawthrop 1999

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2005/04/26 22:52:26  geraint
## The Octave load/save -ascii option is deprecated in favour of -text
##
## Revision 1.5  2002/05/07 10:13:48  gawthrop
## Files marked by update as out of sync
##
## Revision 1.4  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.3  2000/05/19 17:47:56  peterg
## Agument to state
##
## Revision 1.2  2000/05/11 13:43:14  peterg
## No change
##
## Revision 1.1  1999/03/15 23:27:16  peterg
## Initial revision
##
###############################################################


echo Creating $1_odes.dat2
$MATRIX  <<EOF >octave_ode2odes.log 2>mtt_error.txt
  ## Set up the simulation parameters
  par = $1_numpar; 
  x_0  =  $1_state(par);
  simpar = $1_simpar
  mtt_data = $1_ode2odes(x_0,par,simpar); 
  if iscomplex(mtt_data)
    mtt_error("octave_ode2odes: Simulated data is complex - something is wrong!");
    mtt_data = real(mtt_data);
  endif;
  save -text $1_odes.dat2 mtt_data
EOF

mtt_error mtt_error.txt

Deleted mttroot/mtt/bin/trans/ode2obs_r version [117332d406].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253





























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2obs_r
# Odrinary differential equations to observer function equations
# P.J.Gawthrop 14 June 1991, 8 Aug 1991, 2 April 1992, 14 April 1994, 28 Dec 94,
#               12th July 1995, April 1996
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1998/04/07 08:12:12  peterg
## Added affine form.
##
## Revision 1.4  1998/04/07 05:45:12  peterg
## Reverted to an older version due to untraceable bug in new version
##
## Revision 1.3  1996/08/25 10:07:05  peter
## Remove a du state ment causaing touble
##      - but needs more work.
##
## Revision 1.2  1996/08/25 08:38:14  peter
## Error handling added.
##
## Revision 1.1  1996/08/25 08:37:44  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_obs.r

# Remove the old log file
rm -f ode2obs_r.log

# Use reduce to accomplish the transformation
reduce >ode2obs_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;
ON NERO;

in "$1_def.r";
MTTdxs := MTTdX;  %Save the symbolic form of dX

%Set default values - reset by obspar file.
MTTGPCNy := 2;
MTTGPCNu := 0;

%%in "$1_sympar.r";
in "$1_ode.r";
%%in "$1_simp.r";

% Read the obs form parameters.
in "$1_obspar.r";

%Create the U vector of input derivatives.
MTTNuu := (MTTGPCNu+1)*MTTNu;
MTTNuu1 := MTTGPCNu*MTTNu;


%FOR i := 1:MTTNu DO
%  MTTUU(i,1) := MTTU(i,1);
%END;
%
%IF MTTGPCNu>0 THEN
%BEGIN
%  FOR i := 1:MTTNu DO
%    MTTUU(i+MTTNu,1) := MTTdU(i,1);
%  END;
%END;

MTTU := MTTU;
MTTdU := MTTdU; % ---- removed temporarily, needs def file change? 

%Create the Y vector of output derivatives.
MTTNyy := (MTTGPCNy+1)*MTTNy;
Matrix MTTYY(MTTNyy,1);

FOR i := 1:MTTNy DO
  MTTYY(i,1) := MTTY(i,1);
END;

l := MTTNy;
FOR i := 1:MTTGPCNy DO
    FOR j := 1:MTTNy DO
    BEGIN
      l := l+1;
      MTTYY(l,1) := 0;
      FOR k := 1:MTTNx DO %Derivatives wrt x
      BEGIN
        xk := MTTX(k,1);
        MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l-MTTNy,1), xk, 1)*MTTdX(k,1);
      END;
      IF MTTGPCNu>0 THEN
      FOR k := 1:MTTGPCNu DO %Non-zero derivatives of u
      BEGIN
        FOR kk := 1:MTTNu DO
        BEGIN
          uk := MTTUU(kk,k);
          MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l,1), uk, 1)*MTTUU(1,k+1);
        END;
      END;
    END;
END;

%%Create O_x - derivative of YY wrt x
%Matrix MTTO_x(MTTNyy,MTTNx);
%FOR j := 1:MTTNx DO
%  BEGIN
%  xj := MTTX(j,1);
%  FOR i := 1:MTTNyy DO
%    BEGIN
%    MTTO_x(i,j) := df(MTTYY(i,1), xj);
%    END;
%  END;

%%Create O_u - derivative of YY wrt u (Assumes GPC Nu = 0)
%MTTNNu := (MTTGPCNu+1)*MTTNu;
%Matrix MTTO_u(MTTNyy,MTTNNu);
%FOR j := 1:MTTNNu DO
%  BEGIN
%  uj := MTTu(j,1);     
%  FOR i := 1:MTTNyy DO
%    BEGIN
%    MTTO_u(i,j) := df(MTTYY(i,1), uj);
%    END;
%  END;


%%Create O_uu - derivative of O_u wrt u (Assumes GPC Nu = 0)
%%This is a multi-dimensional matrix kth elements stacked sideways.
%Matrix MTTO_uu(MTTNyy,MTTNNu*MTTNNu);
%FOR k := 1:MTTNNu DO
%  BEGIN
%  uk := MTTu(k,1);     
%  FOR j := 1:MTTNNu DO
%    BEGIN
%    FOR i := 1:MTTNyy DO
%      BEGIN
%      jk := j+(k-1)*MTTNu;
%      MTTO_uu(i,jk) := df(MTTO_u(i,j), uk);
%      END;
%    END;
%  END;

%%Create O_ux - derivative of O_u wrt x 
%%This is a multi-dimensional matrix kth elements stacked sideways.
%Matrix MTTO_ux(MTTNyy,MTTNu*MTTNx);
%FOR k := 1:MTTNx DO
%  BEGIN
%  xk := MTTx(k,1);     
%  FOR j := 1:MTTNu DO
%    BEGIN
%    FOR i := 1:MTTNyy DO
%      BEGIN
%      jk := j+(k-1)*MTTNu;
%      MTTO_ux(i,jk) := df(MTTO_u(i,j), xk);
%      END;
%    END;
%  END;


% Try and split the obs function into affine form (O(x,u) = o(x) + h(x)u)
affine := 1;
MTTNuu := (MTTGPCNu+1)*MTTNu;
write "1 affine := ", affine, ";";

%IF (affine=1) THEN
%BEGIN
  MATRIX MTTObs_o(MTTNyy,1);
  MATRIX MTTObs_h(MTTNyy,MTTNuu);
write "2 affine := ", affine, ";";
  FOR i := 1:MTTNyy DO
  BEGIN
write "3 affine := ", affine, ";";
    MTTObs_o(i,1) := MTTYY(i,1);
    k := 0;
    FOR j := 1:MTTNu DO
    FOR jj := 0:MTTGPCNu DO
    BEGIN
      k := k+1;
      %Expand as polynomial in u_j^[jj]
      coeffs := coeff(MTTObs_o(i,1), MTTUU(j,jj+1));
      MTTObs_o(i,1) := first(coeffs);
      IF length(coeffs)>1 THEN
        MTTObs_h(i,k) := second(coeffs);
      IF length(coeffs)>2 THEN 
        affine := -1;
    END;
  END;
%END;


%%Create the _obs.r file
OUT "$1_obs.r";

IF affine=1 THEN
  write "affine := 1; % The O function is affine in u"
ELSE
  write "affine := 0; % The O function is not affine in u";


write "% The matrix sizes";
write "MTTNyy := ", MTTNyy, ";";
write "MTTNuu := ", MTTNuu, ";";

mtt_matrix := MTTYY$
mtt_matrix_n := MTTNyy$
mtt_matrix_m := 1$
mtt_matrix_name := "MTTYY"$
reduce_matrix();

IF affine=1 THEN
BEGIN
  mtt_matrix := MTTObs_o$
  mtt_matrix_n := MTTNyy$
  mtt_matrix_m := 1$
  mtt_matrix_name := "MTTObs_o"$
  reduce_matrix();

  mtt_matrix := MTTObs_h$
  mtt_matrix_n := MTTNyy$
  mtt_matrix_m := MTTNuu$
  mtt_matrix_name := "MTTObs_h"$
  reduce_matrix();
END;

%MTTO_x := MTTO_x;
%MTTO_u := MTTO_u;
%MTTO_uu := MTTO_uu;
%MTTO_ux := MTTO_ux;

write ";END;";

SHUT "$1_obs.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r ode2obs_r.log

Deleted mttroot/mtt/bin/trans/ode2odes_m version [e593903528].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229





































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odes_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  1998/06/27 14:49:16  peterg
## No change
##
## Revision 1.16  1998/06/25 08:47:23  peterg
## Put correct arguments for _input -- (x,t)
##
## Revision 1.15  1998/05/21 16:20:27  peterg
## Modified to include explicit algebraic loop solution
##
## Revision 1.14  1998/05/19 19:48:02  peterg
## Read the simpar file now.
##
## Revision 1.13  1998/05/14 08:05:10  peterg
## Put back under RCS
##
## Revision 1.12  1998/02/25 18:02:39  peterg
## Removed the argument passing stuff .
## Replaced by the simpar.m method.
##
## Revision 1.11  1997/08/29 07:56:54  peterg
## Minor updates
##
# Revision 1.10  1997/01/07  09:16:03  peterg
# Added step_factor parameter - gives that number of integration steps
# per sample.
#
## Revision 1.9  1997/01/06 21:36:44  peterg
## Fixed bug mtt_error --> mtt_error.txt
## Replaced lsode by Euler integration.
##
## Revision 1.8  1996/09/13 17:54:08  peter
## Now writes default $PARAMS to $1_args.m - $1_ode may use it.
##
## Revision 1.7  1996/09/12 18:41:48  peter
## Standard error handling added.
##
## Revision 1.6  1996/08/24 14:11:04  peter
## Global parameter passing.
##
## Revision 1.5  1996/08/18 12:01:26  peter
## Unified format of time responses.
##
## Revision 1.4  1996/08/16 13:04:46  peter
## Fixed problem with more than one output (y vector).
##
## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odes.m
echo Creating $1_odeso.m

rm -f ode2odes_m.log
rm -f mtt_error.txt

#if [ "$2" = "" ]; 
#then
#  PARAMS='T=[0:0.1:10]; x0=zeros(nx,1);'
#  echo Using default parameter $PARAMS
#  echo $PARAMS>$1_args.m
#else
#  PARAMS=$2;
#fi

# PARAMS="$PARAMS ;"


$MATRIX --verbose << EOF > ode2odes_m.log 2>mtt_error.txt

  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;

  %Read in parameters
  $1_numpar; 

  %Read in state
  x = $1_state;

  %Set the initial output
  %if ny>0
  %  y = $1_odeo(x,0);
  %end; 
 
  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:1:100]
  end;

  if exist('METHOD')==0
    METHOD = 'Euler'
  end;

  if exist('x')==0
    x = zeros(nx,1);
   end;

  % xx is the composite vector containing x and the internal inputs.
  xx = [x; zeros(nyz,1)];

  [n,m]=size(T);
  if m>n
    T=T';
  end;

method = tolower(METHOD)

if nx>0
  if strcmp(method,'lsode')
    X = lsode('$1_ode', x, T);
  elseif strcmp(method,'euler')
    %Euler integration
    disp("Euler")
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    for t=T'
      X = [X; xx'];
      ts = t;
      for i=1:STEPFACTOR
        x = xx(1:nx);
        u = $1_input(xx,ts);
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = x + dx*dt;
        xx(1:nx) = x;
      end;
    end;
  elseif strcmp(method,'implicitl')
    %Euler integration
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    u = $1_input(x,u,t);
    A = $1_smx(x,u); 
    inverse = inv(eye(nx) - dt*A);
    for t=T'
      X = [X; xx'];
      ts = t;
      u = $1_input(x,t);
      for i=1:STEPFACTOR
        x = xx(1:nx);
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = inverse*(x + dt*(dx - A*x));
        xx(1:nx) = x;
      end;
    end;
  elseif strcmp(method,'implicit')
    %Euler integration
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    One = eye(nx);
    for t=T'
      X = [X; xx'];
      ts = t;
      for i=1:STEPFACTOR
        x = xx(1:nx);
        u = $1_input(x,t);
    	A = $1_smx(x,u); 
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = (One-A*dt)\(x + dt*(dx - A*x));
        xx(1:nx) = x;
      end;
    end;
  else
    error('Method %s not available here', METHOD);
    return;
  end;
  write_matrix([T,X], '$1_odes');
else
  X = zeros(size(T));
end;

if ny>0 % compute y and print it
  i = 0; Y=[];
  for t=T'
    i = i+1; X(i,:);
    u = $1_input(x,t);
    y = $1_odeo(X(i,:)',u,t);
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_odeso');
end;


EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt







Deleted mttroot/mtt/bin/trans/ode2odes_r2c version [3539b59c2d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269













































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odes_r2c
# Reduce ordinary differential equations to  differential-algebraic 
# equations solution in the form of a c program.

# Euler integration of the state is included.

# NB Arrays should are  defined to be one larger than expected 
# - the 0 element is not used.

# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  1998/05/15 07:47:23  peterg
## Includes sign.c by default
##
## Revision 1.16  1998/05/14 08:25:52  peterg
## Corrected time skew.
##
## Revision 1.15  1998/05/14 08:20:29  peterg
## Start time at DT - the result at time zero is computed outside the
## loop
##
## Revision 1.14  1998/05/13 08:57:27  peterg
## Now uses simpar.h in place of odes.h
##
## Revision 1.13  1998/02/24 13:34:45  peterg
## Back under RCS
##
# Revision 1.12  1997/05/15  08:39:56  peterg
# Don't initialise states - now done in numpar file.
#
# Revision 1.11  1997/05/12  16:00:54  peterg
# Removed itime again.,
#
# Revision 1.10  1997/05/10  10:05:15  peterg
# Put _input in inner loop in front of call to _ode
#
## Revision 1.9  1997/05/10 09:54:34  peterg
## Moved _input call to after the inner integration loop.
##
## Revision 1.8  1997/05/10 08:12:23  peterg
## Put second argument into _input.
##
## Revision 1.7  1997/05/10 07:01:15  peterg
## _input called in outer loop only.
## time updated in outer loop only.
## Integer time (itime) introduced and updated in outer loop - maybe
## useful for discrete events.
## Integer time (itime) passed to _input.
##
## Revision 1.6  1997/05/06 13:53:32  peterg
## Now uses the preprocessor to declare sizes -- MTTNX etc
##
# Revision 1.5  1997/05/01  13:50:11  peterg
# Replaced float by double.
#
# Revision 1.4  1997/05/01  13:43:44  peterg
# Changed double to float.
#
# Revision 1.3  1997/05/01  11:15:33  peterg
# Back under RCS
#
# Revision 1.2  1997/03/20  14:36:56  peterg
# Includes the sympar.h file
#
## Revision 1.1  1997/01/21 22:54:54  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_odes.c

# Remove the old log file
rm -f ode_r2c.log

# Use reduce to accomplish the transformation
reduce >ode2odes_r2c.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
%%in "$1_sympar.r";

ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
%OFF Nat;

ON NERO;        % Suppress zero elements

%Generate the Header part
OUT "$1_odes.c";

write "/*"$
write "Program to solve ode for system $1"$
write "NB Arrays are defined to be one larger than expected"$
write " - the 0 element is not used."$

write "File $1_odes.c"$
write "Generated by MTT"$
write "*/"$
write " "$


%Program heading
write "#define MTTNX ", MTTNx $
write "#define MTTNY ", MTTNy $
write "#define MTTNU ", MTTNu $
write "#define MTTNX1 ", MTTNx+1 $
write "#define MTTNY1 ", MTTNy+1 $
write "#define MTTNU1 ", MTTNu+1 $
write "#define MTTNX2 ", MTTNx+2 $
write "#define MTTNY2 ", MTTNy+2 $
write "#define MTTNU2 ", MTTNu+2 $

write "#include <stdio.h>"$
write "#include <math.h>"$
write "#include ""sign.c"" "$
write "#include ""$1_simpar.h"" "$
write "#include ""$1_ode.c"" "$
write "#include ""$1_input.c"" "$
write "#include ""$1_numpar.c"" "$
write "#include ""$1_state.c"" "$

%External (global) variable list
write "#include ""$1_sympar.h"" "$


write "/* Declare standard arrays */"$
write "double y[MTTNY1]; /* $1_ode output */"$
write "double dx[MTTNX1]; /* $1_ode state derivative */"$ 
write "double x[MTTNX1]; /* $1_ode state */"$ 
write "double u[MTTNU1]; /* $1_ode input */"$


write "/* Files */ "$
write "  FILE *fopen(), *fps, *fpso;"$

write "main()"$
write "  "$
write "{"$



write "/* Counters etc*/ "$
write "  double time;"$
write "  double dt;"$
write "  int i;"$
write "  int k;"$

write "/*functions */ "$
write "  extern  $1_numpar();"$

%Open the output files
write "/* %Open the output file */"$
write "fps = fopen(""$1_odes.m"", ""w"");  "$
write "fpso = fopen(""$1_odeso.m"", ""w"");  "$

%Set up user-defined constants
write "/* Set up user-defined constants */"$
write "  $1_numpar();"$

%Set up initial state
write "/* Set up initial state */"$
write "  $1_state();"$

%Initialise main (Euler) integration loop
write "/* Initialise main (Euler) integration loop */"$
write "  time = 0;"$
write "  dt = DT/STEPFACTOR;"$
%% write "  for (i=1; i<=MTTNX; i++)"$
%% write "      x[i] = 0.0;"$

%Set up system inputs
write "/* Set up system inputs */"$
write "  for (i=1; i<=", MTTNu, "; i++)"$
write "      u[i] = 1.0;"$

write "  $1_input(0.0);"$

write "    fprintf(fps, ""function data = ", "$1_odes \n"");"$
write "    fprintf(fps, ""data = [\n"");"$
write "    fprintf(fpso, ""function data = ", "$1_odeso \n"");"$
write "    fprintf(fpso, ""data = [\n"");"$

% Compute the first output
write "/* Compute the first output */"$
write "  $1_ode(y,dx,x,u);"$

%Main (Euler) integration loop
write "/* Main (Euler) integration loop */"$

write "  while (time<(LAST-DT))"$
write "  {"$

%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$
write "      fprintf(fpso, ""%5.4g "", y[i]);"$
write "    fprintf(fpso, ""\n"");"$

%Write to state to file
write "/* Write to state file */"$
write "    fprintf(fps, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNX; i++)"$
write "      fprintf(fps, ""%5.4g "", x[i]);"$
write "    fprintf(fps, ""\n"");"$

write "      time = time + DT;"$

write "/* Inner integration loop */"$
write "    for (k=1; k<=STEPFACTOR; k++)"$
write "    {"$
write "      for (i=1; i<=MTTNX; i++)"$
write "        x[i] = x[i] + dx[i]*dt;"$

write "      /* Set up system inputs */"$
write "      $1_input(time);"$
write "      $1_ode();"$
write "    }"$

write "  }"$

%Write to files
%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$
write "      fprintf(fpso, ""%5.4g "", y[i]);"$
write "    fprintf(fpso, ""\n"");"$

%Write to state to file
write "/* Write to state file */"$
write "    fprintf(fps, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNX; i++)"$
write "      fprintf(fps, ""%5.4g "", x[i]);"$
write "    fprintf(fps, ""\n"");"$


write "  fprintf(fps, ""];\n"");"$
write "  fprintf(fpso, ""];\n"");"$

write "  return 0;"$
write "}"$


SHUT "$1_odes.c";


EOF



Deleted mttroot/mtt/bin/trans/ode2odess_m version [4c1d52ada1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odess_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/10/17 11:07:59  peterg
## *** empty log message ***
##
## Revision 1.3  1998/05/19 19:27:04  peterg
## Zapped all the parameter stuff
##
## Revision 1.2  1996/09/13 19:40:51  peter
## Fixed problem with default paramaters.
##
## Revision 1.1  1996/09/12 19:26:57  peter
## Initial revision
##
## Revision 1.4  1996/08/16 13:04:46  peter
## Fixed problem with more than one output (y vector).
##
## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odess.m
rm -f ode2odess_m.log

Nx=`mtt_getsize $1 x` # States
Nxx=`mtt_getsize $1 xx` # States x States
Nu=`mtt_getsize $1 u` # Inputs 
Ny=`mtt_getsize $1 y` # Inputs 

$MATRIX << EOF >  ode2odess_m.log 2>mtt_error.txt

  %Read in parameters
  par = $1_numpar;

   %Read in simulation parameters
  simpar=$1_simpar;
  T = [0:simpar.dt:simpar.last];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:0.1:1]
  end;

  if exist('x0')==0
    x0 = zeros($Nx,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

global t;
function dx=f(x)
  global t
  par = $1_numpar;
  u = $1_input(x,zeros($Ny,1),t,par);
  dx = $1_ode(x,u,t,par);;
endfunction;

i=0;
x = x0;
for t=T'
  u = $1_input(x,zeros($Ny,1),t,par);
  y(i) = $1_odeo(x,u,t,par)';
  mtt_write(t,x,y,$Nx,$Ny);   # Write it out
  x = fsolve('f',x)';
end;

i=0;
for t=T'
  i=i+1;
end;

write_matrix([T,x], '$1_odess');
write_matrix([T,y], '$1_odesso');

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt





Deleted mttroot/mtt/bin/trans/ode2odess_m2dat2 version [13554ba921].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odess_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/10/17 12:55:29  peterg
## Initial revision
##
## Revision 1.4  2000/10/17 11:07:59  peterg
## *** empty log message ***
##
## Revision 1.3  1998/05/19 19:27:04  peterg
## Zapped all the parameter stuff
##
## Revision 1.2  1996/09/13 19:40:51  peter
## Fixed problem with default paramaters.
##
## Revision 1.1  1996/09/12 19:26:57  peter
## Initial revision
##
## Revision 1.4  1996/08/16 13:04:46  peter
## Fixed problem with more than one output (y vector).
##
## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odess.dat2
rm -f ode2odess_m.log

Nx=`mtt_getsize $1 x` # States
Nxx=`mtt_getsize $1 xx` # States x States
Nu=`mtt_getsize $1 u` # Inputs 
Ny=`mtt_getsize $1 y` # Inputs 

$MATRIX << EOF  >ode2odess_m2dat2.log 2>mtt_error.txt

   global MTT_data # Where mtt_write puts its stuff
  %Read in parameters
  par = $1_numpar;

   %Read in simulation parameters
  simpar=$1_simpar;
  T = [0:simpar.dt:simpar.last];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:0.1:1]
  end;

  if exist('x0')==0
    x0 = zeros($Nx,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

global t;
function dx=f(x)
  global t
  par = $1_numpar;
  u = $1_input(x,zeros($Ny,1),t,par);
  dx = $1_ode(x,u,t,par);;
endfunction;

x = x0;
for t=T'
  u = $1_input(x,zeros($Ny,1),t,par);
  x = fsolve('f',x);
  y = $1_odeo(x,u,t,par);
  mtt_write(t,x,y,$Nx,$Ny);   # Write it out
end; 

save -text $1_odess.dat2 MTT_data

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt





Deleted mttroot/mtt/bin/trans/ode2smx_lang version [564d3a89c6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218


























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2smx_lang
# ODE to state matrix (with explicit state values) conversion
# P.J.Gawthrop  6th September 1991, May 1994, July 1998
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  1998/11/26 10:32:34  peterg
## Include subs.r
##
## Revision 1.10  1998/11/17 17:10:22  peterg
## Read in the constitutive relationship file as well
##
## Revision 1.9  1998/08/27 07:06:25  peterg
## Just genrate xj once.
##
## Revision 1.8  1998/08/27 07:04:44  peterg
## Cleared out mttx array ans use mkid instead.
##
## Revision 1.7  1998/08/27 06:48:20  peterg
## Changed mttxx to mttx - in implicit integration smx is called once
## with x in the linearisation the same as x in the current state
##
## Revision 1.6  1998/08/26 18:25:45  peterg
## SMX now generates both A and Ax
##
## Revision 1.5  1998/08/15 13:51:56  peterg
## smx is now I-Adt NOT A
##
## Revision 1.4  1998/08/13 09:03:35  peterg
## *** empty log message ***
##
## Revision 1.3  1998/07/30 10:49:55  peterg
## Removed zeroing.
##
## Revision 1.2  1998/07/30 10:49:02  peterg
## Put [] round output of zeros.
##
## Revision 1.1  1998/07/19 16:59:56  peterg
## Initial revision
##
###############################################################

# Language
if [ -n "$2" ]; then
    lang=$2
else
    lang="r"
fi


# Inform user
echo Creating $1_smx.$lang
#echo Creating $1_smxx.$lang
#echo Creating $1_smxtx.$lang

# Remove the old log file
rm -f ode2smx_r.log

rm -f $1_smx.$lang
rm -f $1_smxx.$lang
rm -f $1_smxtx.$lang

# Use reduce to accomplish the transformation
reduce << EOF  >ode2smx_lang.log

lang := $lang;

in "$1_subs.r";
in "$1_def.r";
in "$1_ode.r";
in "$1_cr.r";

clear mttx; % Dont need this now - use mkid instead

OFF Echo;

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'Pascal;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_t;

% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";


%Set up output according to the language.
 OFF NAT;
 GENTRANOUT "$1_smx.$lang";

% Set up output according to the language.
    IF (lang = r) THEN 
    BEGIN
      write "matrix mtta(", mttnx, ",", mttnx, ");";    
      write "matrix mttb(", mttnx, ",", mttnu, ");";    
      write "matrix mttc(", mttny, ",", mttnx, ");";    
      write "matrix mttd(", mttny, ",", mttnu, ");";    
    END;

% find MTTA : the A matrix
  FOR i := 1:MTTNx DO
  BEGIN
    mttAAx_i := 0;
%%    xi := mkid(mttx,i);
    FOR j := 1:MTTNx DO
    BEGIN
      xj := mkid(mttx,j);
      a_ij := df(MTTdx(i,1), xj, 1);
%%      a_ji := df(MTTdx(j,1), xi, 1);
      IF i=j THEN
      BEGIN
        aa_ij := 1 - mttdt*a_ij;
%%        aa_ji := aa_ij;
      END
      ELSE
      BEGIN
        aa_ij := -mttdt*a_ij;
%%        aa_ji := -mttdt*a_ji;
      END;
      IF (aa_ij NEQ 0) THEN
        GENTRAN mtta(i,j) ::=: aa_ij;
      mttAAx_i := mttAAx_i + aa_ij*xj;
      %%%mttAAtx(i,1) := mttAAtx(i,1) + aa_ji*mkid(mttx,j);
    END;
    IF (mttAAx_i NEQ 0) THEN
      GENTRAN mttax(i) ::=: mttAAx_i;
  END;



%% Find MTTB : the B matrix
%  FOR j := 1:MTTNu DO
%    BEGIN
%    uj := MTTU(j,1);
%    FOR i := 1:MTTNx DO
%      WriteElement("mttb",i,j,df(MTTdx(i,1), uj, 1));
%    END;
%
%% Find MTTC : the C matrix
%  FOR i := 1:MTTNy DO
%    FOR j := 1:MTTNx DO
%    BEGIN
%      xj := MTTX(j,1);
%      WriteElement("mttc",i,j,df(MTTY(i,1), xj, 1));
%    END;
%
%% Find MTTD : the D matrix
%  FOR i := 1:MTTNy DO
%    FOR j := 1:MTTNu DO
%    BEGIN
%      xj := MTTU(j,1);
%      WriteElement("mttd",i,j,df(MTTY(i,1), xj, 1));
%    END;

%Shut the  output according to the language.
 GENTRANSHUT "$1_smx.$lang";


%% The AAx matrix;
%GENTRANOUT "$1_smxx.$lang";
%FOR i := 1:MTTNx DO
%BEGIN
%  ax_i := mttAAx(i,1);
%  IF (ax_i NEQ 0) THEN
%    GENTRAN mttax(i) ::=: ax_i;
%END
%GENTRANSHUT "$1_smxx.$lang";
%
%% The AAtx matrix;
%GENTRANOUT "$1_smxtx.$lang";
%FOR i := 1:MTTNx DO
%BEGIN
%  atx_i := mttAAtx(i,1);
%  IF (atx_i NEQ 0) THEN
%    GENTRAN mttax(i) ::=: atx_i;
%END
%GENTRANSHUT "$1_smxtx.$lang";

EOF

if [ "$lang" = "m" ]; then
  mv $1_smx.$lang  mtt_junk
#  lang_header $1 smx m 'mttx,mttu,mttdt' '[mtta,mttax]' > $1_smx.m
  mtt_header $1 $2 m
  cat mtt_junk | mtt_p2m >> $1_smx.m
  rm -f mtt_junk

#  mv $1_smxx.$lang  mtt_junk
#  lang_header $1 smxx m 'mttx,mttu,mttxx,mttdt' '[mttax]' > $1_smxx.m
#  cat mtt_junk | mtt_p2m >> $1_smxx.m
#  rm -f mtt_junk
#
#  mv $1_smxtx.$lang  mtt_junk
#  lang_header $1 smxtx m 'mttx,mttu,mttxx,mttdt' '[mttax]' > $1_smxtx.m
#  cat mtt_junk | mtt_p2m >> $1_smxtx.m
#  rm -f mtt_junk
#
#
fi

# Now invoke the standard error handling.
mtt_error_r ode2smx_lang.log




Deleted mttroot/mtt/bin/trans/ode_r2c version [572667c334].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189





























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2c
# Reduce ordinary differential equations to c differential-algebraic 
# equations

# Euler integration of the state is included.

# NB Arrays should be defined to be one larger than expected 
# - the 0 element is not used.

# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1997/05/01 13:50:55  peterg
## Replaced float by double.
##
# Revision 1.4  1997/05/01  13:44:19  peterg
# Changed double to float.
#
# Revision 1.3  1997/03/20  14:51:11  peterg
# Includes the sympar.c file.
#
# Revision 1.2  1997/01/21  22:57:17  peterg
# Various bug fixes.
#
## Revision 1.1  1997/01/21 10:52:23  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_ode.c

# Remove the old  files
rm -f  $1_ode.c1 $1_ode.c2 $1_ode.c

# Remove the old log file
rm -f ode_r2c.log

# Use reduce to accomplish the transformation
reduce >ode_r2c.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the reduce state-space equations   file
in "$1_ode.r";


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
%OFF Nat;

ON NERO;        % Suppress zero elements


%Generate the Header part
OUT "$1_ode.c1";

write "/*"$
write "Differential algebraic eqns in c form for system $1"$
write "NB Arrays should be defined to be one larger than expected"$
write " - the 0 element is not used."$

write "File $1_ode.c"$
write "Generated by MTT"$
write "*/"$
write " "$


%Function heading - c style

write "void $1_ode()"$

write "  "$
write "{"$

write "/* Declare standard arrays */"$
write "  extern double y[", MTTNy+1, "]; /* $1_ode output */"$
write "  extern double dx[", MTTNx+1, "]; /* $1_ode state derivative */"$ 
write "  extern double x[", MTTNx+1, "]; /* $1_ode state */"$ 
write "  extern double u[", MTTNu+1, "]; /* $1_ode input */"$

%Declare the dummy variables t0--t9
write "/* Dummy variable list */ "$
write "  double t0;"$
FOR i := 1:9 DO
BEGIN
  write "  double t", i, ";"$
END$

%Declarations$
write "/* State variable list */ "$
FOR i := 1:MTTNx DO
BEGIN
  write "  double mttx", i, ";"$
END$

write "/* Input variable list */ "$
FOR i := 1:MTTNu DO
BEGIN
  write "  double mttu", i, ";"$
END$

write "/* Counter */ "$
write "  int i;"$

write "/* Parameter  list */ "$
write "#include ", """$1_sympar.c"""$

write "  "$
write "    /*====== Set up the state variables ======*/"$
FOR i := 1:MTTNx DO
BEGIN
  write "    mttx", i, " = x[", i, "];"$
END$

write "  "$
write "    /*====== Set up the input variables ======*/"$
IF MTTNu>0 THEN
BEGIN
  FOR i := 1:MTTNu DO
  BEGIN
    write "    mttu", i, " = u[", i, "];"$
  END$
END$


write "  "$
write "    /*====== Compute the state derivative and output ======*/"$

SHUT "$1_ode.c1";

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'C;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;
ON DOUBLE;

% let it know that sign is a function
GENTRAN DECLARE sign : function;
GENTRAN DECLARE r_switch : function;
GENTRAN DECLARE i_switch : function;

GENTRANOUT "$1_ode.c2";
%Do the translation
%State
IF MTTNx>0 THEN
BEGIN
  FOR i := 1:MTTNx DO
  BEGIN
        GENTRAN dx(i) ::=: mttdx(i,1)$
  END
END$

%Output
IF MTTNy>0 THEN
BEGIN
  FOR i := 1:MTTNy DO
  BEGIN
        GENTRAN y(i) ::=: mtty(i,1)$
  END
END$


GENTRANSHUT "$1_ode.c2";

EOF

echo '}' > $1_ode.c3
cat $1_ode.c1 $1_ode.c2 $1_ode.c3> $1_ode.c


Deleted mttroot/mtt/bin/trans/ode_r2lang version [7b0000767e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245





















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2lang
# Reduce ODE to general language ODE
# Based on obsolete ode_r2m  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95, May 1998
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/07/19 16:22:29  peterg
## Changed header to inculde mttu
##
## Revision 1.2  1998/06/21 10:40:58  peterg
## Added fsolve error message.
##
## Revision 1.1  1998/05/23 16:17:14  peterg
## Initial revision
##
###############################################################

# Set up the language specific stuff
language=$2

case $language in
    m)
	ext='m';
	codegenerator='PASCAL'
	Lc='#';
	Rc='#';
	Lb='(';
	Rb=')';
	;;
    c)
	ext='c';
	codegenerator='C'
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    java)
	ext='java';
	codegenerator='C'
	Lc='/*';
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
       *)
       echo Language $2 not supported - sorry; exit 1
esac

#Inform user
echo Creating $1_ode.$ext
echo Creating $1_odea.$ext
echo Creating $1_odeo.$ext


# Remove the old log file
rm -f ode_r2lang.log

#Remove the temporary files
rm -f $1_ode.$ext.1
rm -f $1_odea.$ext.1
rm -f $1_odeo.$ext.1

# Use reduce to accomplish the transformation
$SYMBOLIC  << EOF #>ode_r2lang.log

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  ODE   file
in "$1_ode.r";


% Set up the code generator
% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := '$codegenerator;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_temp;

% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
in "$1_sympar.r";

% The body of the ode function
  GENTRANOUT "$1_ode.$ext.1";
  mtt_matrix := MTTdX$
  mtt_matrix_n := MTTNx$
  mtt_matrix_m := 1$
  mtt_matrix_name := 'MTTdX$
  lang_matrix()$ 
  GENTRANSHUT "$1_ode.$ext.1";
  
% The algebraic equations (if any)
  GENTRANOUT "$1_odea.$ext.1";
  mtt_matrix := MTTYz$
  mtt_matrix_n := MTTNYz$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTYz$
  lang_matrix()$ 
  GENTRANSHUT "$1_odea.$ext.1";


% Now do the y = g(x,t) function.
% The body of the odeo function
  GENTRANOUT "$1_odeo.$ext.1";
  mtt_matrix := MTTy$
  mtt_matrix_n := MTTNy$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTy$
  lang_matrix()$ 
  GENTRANSHUT "$1_odeo.$ext.1";

EOF

# Create the ode.$ext function
lang_header $1 ode $ext 'mttx,mttu,t' mttdx > $1_ode.$ext

# Algebraic bits
$MATRIX -q  <<EOF  >> $1_ode.$ext
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
if nyz>0
  printf("global mttxx mttt;\n");
  printf("mttxx = mttx; mttt=t;\n");

  printf("$Lc====== Extract the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx);
  end;
  printf("\n");

  printf("[mttui,info] = fsolve('$1_odea',mttui);\n");
  printf("if (info!=1)\n"); 
  printf("  error('fsolve has not converged')\n");
  printf("end\n");
  printf("\n");

  printf("$Lc====== Set up the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");

  printf("$Lc====== Put internal input variables at end of state derivative ======$Rc\n");
  for i = 1:nyz
    printf(" mttdx$Lb%i$Rb = mttui%i;\n",i+nx,i);
  end;
  printf("\n");
end;

EOF

cat <<EOF >> $1_ode.$ext

$Lc The differential equations $Rc
EOF

sed 's/mtt_matrix/mttdx/' $1_ode.$ext.1 >> $1_ode.$ext

# Java terminating }
if [ "$language" = "java" ]; then
cat <<EOF     >> $1_ode.$ext
}
EOF
fi


# Create the odea.$ext function
lang_header $1 odea $ext 'mttui' mttyz 'global mttxx mttt; mttx = mttxx; t=mttt;' > $1_odea.$ext

$MATRIX -q  <<EOF  >> $1_odea.$ext
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
if nyz>0
  printf("$Lc====== Set up the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");
end;
EOF

cat <<EOF >> $1_odea.$ext

% The algebraic equations
EOF
sed 's/mtt_matrix/mttyz/' $1_odea.$ext.1 >> $1_odea.$ext


# Create the odeo.$ext function
lang_header $1 odeo $ext 'mttx,mttu,t' mtty > $1_odeo.$ext

$MATRIX -q  <<EOF  >> $1_odeo.$ext
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;
if nyz>0
  printf("$Lc====== Extract the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx);
  end;
  printf("\n");

  printf("$Lc====== Set up the internal input variables ======$Rc\n");
  for i = 1:nyz
    printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");
end;

EOF


cat <<EOF >> $1_odeo.$ext

% The output equations
EOF
sed 's/mtt_matrix/mtty/' $1_odeo.$ext.1 >> $1_odeo.$ext

# Convert from Pascal syntax to Octave syntax
mv $1_ode.m mtt_junk; mtt_p2m<mtt_junk > $1_ode.m
mv $1_odeo.m mtt_junk; mtt_p2m<mtt_junk > $1_odeo.m
mv $1_odea.m mtt_junk; mtt_p2m<mtt_junk > $1_odea.m




Deleted mttroot/mtt/bin/trans/ode_r2m version [574a94f900].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314


























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2m
# Reduce ODE to matlab  ODE  
# P.J.Gawthrop 14 June 1991, 12 Jan 1994, April 1994, Jan 95.
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.13  1998/05/21 16:19:54  peterg
## Modified to include explicit algebraic loop solution
##
## Revision 1.12  1998/05/21 12:55:48  peterg
## Put in algebraic equation stuff
##
## Revision 1.11  1998/05/21 08:05:23  peterg
## Back under RCS
##
## Revision 1.10  1998/04/14 07:25:02  peterg
## _input now has arguments (x,t)
##
## Revision 1.9  1998/03/30 14:18:07  peterg
## Removed NERO command
##
## Revision 1.8  1998/02/25 18:03:49  peterg
## Removed the argument reading bits.
##
## Revision 1.7  1997/08/29 07:58:17  peterg
## Changed MTT to mtt in the .m files.
##
# Revision 1.6  1997/01/05  19:34:35  peterg
# Don't write globals which are already assigned to a number.
#
## Revision 1.5  1996/09/13 19:41:39  peter
## *** empty log message ***
##
## Revision 1.4  1996/09/12 18:33:32  peter
## Put back under rcs
##
## Revision 1.3  1996/08/30 11:04:28  peter
## Changed line length to 500.
##
## Revision 1.2  1996/08/24 14:09:41  peter
## Global parameter passing.
##
## Revision 1.1  1996/08/18 12:03:49  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_ode.m
echo Creating $1_odea.m
echo Creating $1_odeo.m


# Remove the old log file
rm -f ode_r2m.log

#Remove the temporary files
rm -f $1_ode.mc
rm -f $1_ode.m1
rm -f $1_ode.m2
rm -f $1_ode.m3
rm -f $1_ode.m4
rm -f $1_odea.m1;
rm -f $1_odeo.m1;

# Use reduce to accomplish the transformation
reduce >ode_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Read the reduce  ODE   file
in "$1_ode.r";

% Matrix output function
in"$MTTPATH/trans/matlab_matrix.r";


%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
in "$1_sympar.r";

%ON NERO;        % Suppress zero elements

%Define the common part of the functions.

PROCEDURE common;
BEGIN
  write "% Read in the input";
  write "u = $1_input(x,t)";

  write "% Read in the definitions";
  write "[nx,ny,nu,nz,nyz] = $1_def";

%  write "% Read in the arguments";
%  write "$1_args";
  
  write "% Set up the State variables";
  FOR i := 1:MTTNx DO
  BEGIN
    write "mttx", i, " = x(", i, ");";
  END;
  
  write "% Set up the Input variables";
  IF MTTNu>0 THEN
  FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ");";
  END;

END;

% The common part
OUT "$1_ode.mc";
common();
SHUT "$1_ode.mc";

% Set up internal inputs (if any)
OUT "$1_ode.m3";
  write "% Set up the Internal Input variables";
  IF MTTNyz>0 THEN
  FOR i := 1:MTTNyz DO
  BEGIN
    write "mttui", i, " = mttui(", i, ");";
  END;
SHUT "$1_ode.m3";

OUT "$1_ode.m4";
  write "% Set up the Internal Input variables (saved in the state vector)";
  IF MTTNyz>0 THEN
  FOR i := 1:MTTNyz DO
  BEGIN
    write "mttui(", i, ") = x(", i+MTTNx, ");";
  END;
SHUT "$1_ode.m4";

% The body of the ode function
  GENTRANOUT "$1_ode.m1";
  mtt_matrix := MTTdX$
  mtt_matrix_n := MTTNx$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTdX$
  matlab_matrix(); 
  GENTRAN MTTdx := mtt_matrix;
  GENTRANSHUT "$1_ode.m1";
  
% The algebraic equations (if any)
  GENTRANOUT "$1_odea.m1";
  mtt_matrix := MTTYz$
  mtt_matrix_n := MTTNYz$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTYz$
  matlab_matrix(); 
  GENTRAN MTTYz := mtt_matrix;
  GENTRANSHUT "$1_odea.m1";

 
%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 10000$
OFF period$

MTTdx := MTTdx;


SHUT "$1_ode.m";

OUT "$1_odea.m";
write "function zero = $1_odea(x,t);";
write "% zero = $1_odea(x,t);";
write "%Algebraic equations in octave form for system $1;;";
write "%File $1_odea.m;;";
write "%Generated by MTT;;";

%Write algebraic equations if any ...
zero := MTTYz;
SHUT "$1_odea.m";

% Now do the y = g(x,t) function.
% The body of the odeo function
  GENTRANOUT "$1_odeo.m1";
  mtt_matrix := MTTy$
  mtt_matrix_n := MTTNy$
  mtt_matrix_m := 1$
  mtt_matrix_name := MTTy$
  matlab_matrix(); 
  GENTRAN MTTy := mtt_matrix;
  GENTRANSHUT "$1_odeo.m1";


EOF

# Create the ode.m function
cat <<EOF > $1_ode.m
function mttdx = $1_ode(x,t);
% mttdx = $1_ode(x,t);
%ODE in Octave form for system $1;
%File $1_ode.m;
%Generated by MTT on `date`;
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_ode.m

#Common bit
cat $1_ode.mc >> $1_ode.m

#Extract internal input from state vector
cat $1_ode.m4 >> $1_ode.m

cat <<EOF >> $1_ode.m
% Solve the algebraic equations (if any)
if nyz>0
  global xx tt;
  xx = x; tt=t;
  MTTui = fsolve('$1_odea',mttui);
else
 mttui = [];
end
EOF

cat $1_ode.m3 >> $1_ode.m

cat <<EOF >> $1_ode.m

% The differential equations
EOF
cat $1_ode.m1 >> $1_ode.m

cat <<EOF >> $1_ode.m

% Append the internal inputs to the state derivative
mttdx = [mttdx; mttui];
EOF


# Create the odea.m function
cat <<EOF > $1_odea.m
function mttyz = $1_odea(mttui);
% mttyz = $1_odea(mttui);
%Algebraic equations in Octave form for system $1;
%File $1_odea.m;
%Generated by mtt on `date`;
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_odea.m

cat <<EOF >> $1_odea.m

global xx tt;
x = xx; t=tt;
EOF

#Common bit
cat $1_ode.mc >> $1_odea.m

# Internal inputs
cat $1_ode.m3 >> $1_odea.m

cat <<EOF >> $1_odea.m

% The algebraic equations
EOF
cat $1_odea.m1 >> $1_odea.m

# Create the odeo.m function
cat <<EOF > $1_odeo.m
function mtty = $1_odeo(x,t);
% mtty = $1_odeo(x,t);
%Algebraic equations in Octave form for system $1;
%File $1_odeo.m;
%Generated by MTT  on `date`;
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_odeo.m


#Common bit
cat $1_ode.mc >> $1_odeo.m

#Extract internal input from state vector
cat $1_ode.m4 >> $1_odeo.m

# Internal inputs
cat $1_ode.m3 >> $1_odeo.m

cat <<EOF >> $1_odeo.m

% The output equations
EOF
cat $1_odeo.m1 >> $1_odeo.m







Deleted mttroot/mtt/bin/trans/ode_r2tex version [d72a266090].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode_r2tex
# Reduce differential-algebraic to LaTex differential-algebraic equations.
# P.J.Gawthrop 10th May 1991, April 1994
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/01/23 15:51:01  peterg
## Repleace eqnarray by equation + aligned -- this works with Latex2html
##
## Revision 1.2  1996/12/20 08:59:10  peterg
## Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
## conversion.
##
## Revision 1.1  1996/12/20 08:53:57  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_ode.tex

# Remove the old log file
rm -f ode_r2tex.log

# Use reduce to accomplish the transformation
reduce >ode_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the differential-algebraic equations file
in "$1_ode.r";

%Read the symbolic parameter file
%%in "$1_sympar.r";



OFF Echo;
OFF Nat;

%Read the substitution file
IN "$1_subs.r";

%Read the simplifying expressions file
IN "$1_simp.r";

OUT "$1_ode.tex";

%Write out the  differential-algebraic equations.

write "%File: $1_ode.tex";

write "%ordinary differential equations";
write "% Generated by MTT";

IF MTTNx>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_ode_x}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNx DO
  BEGIN
	write "\dot MTTX", Row, " &= ";
	write "{";
	write MTTdx(Row,1);
	write "}";
        IF Row<MTTNx THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;

IF MTTNyz>0 THEN
BEGIN
  write"\begin{equation}";
  write"\begin{aligned}";
FOR Row := 1:MTTNyz DO
  BEGIN
	write "0 &= ";
	write "{";
	write MTTyz(Row,1);
	write "}";
        IF Row<MTTNyz THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;

IF MTTNy>0 THEN
BEGIN
  write"\begin{equation} \label{eq_$1_ode_y}";
  write"\begin{aligned}";
  FOR Row := 1:MTTNy DO
  BEGIN
	write "MTTy", Row, " &= ";
	write "{";
	write MTTy(Row,1);
	write "}";
        IF Row<MTTNy THEN write "\cr";
  END;
  write"\end{aligned}";
  write"\end{equation}";
END;





SHUT "$1_ode.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/odes_dat2sdat version [10897a37e0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: odeso_dat2sdat

# Structure file - dat to sdat conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/12/28 12:38:24  peterg
## Put under RCS
##
## Revision 1.1  1999/03/28 21:29:40  peterg
## Initial revision
##
###############################################################



# Inform user
echo "Creating $1_odeso.sdat"

dat2sdat $1 odes | dat2siag > $1_odes.sdat

Deleted mttroot/mtt/bin/trans/odeso_dat2sdat version [055c2bffbd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: odeso_dat2sdat

# Structure file - dat to sdat conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/03/28 21:29:40  peterg
## Initial revision
##
###############################################################



# Inform user
echo "Creating $1_odeso.sdat"

dat2sdat $1 odeso | dat2siag > $1_odeso.sdat

Deleted mttroot/mtt/bin/trans/p/README version [4d29246b85].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Some of the files in this directory are derived from the NUMERICAL
RECIPES PASCAL SHAREWARE DISKETTE. Please note that any use of these
filse may be subject to the following notice:


             NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE

The entire contents of this diskette are
Copyright (C) 1986 by Numerical Recipes Software.

HERE ARE ANSWERS TO YOUR IMMEDIATE QUESTIONS:

** What is this diskette?  ** This NUMERICAL  RECIPES PASCAL SHAREWARE
DISKETTE contains Pascal procedures originally published as the Pascal
Appendix to the FORTRAN book NUMERICAL RECIPES: THE  ART OF SCIENTIFIC
COMPUTING (Cambridge University Press, 1986), and test driver programs
originally published as the  NUMERICAL  RECIPES EXAMPLE BOOK  (PASCAL)
(Cambridge University Press, 1986).

** What kinds of procedures  are these Numerical Recipes? **  They are
practically a complete library for  scientific computation.  Numbering
more than  200,  their scope  includes   integration,  linear algebra,
differential  equations, Fourier methods,  data analysis,  statistics,
lots of special functions, random   numbers,  sorting, root   finding,
optimization, and much more.

** Do I really get this whole library for FREE? ** Yes, providing that
you follow these  simple  rules:   (1) You must   read and accept  the
disclaimer of warranty at the end of this  document.  (2) You must not
expect any  user support from  Numerical Recipes Software,   Cambridge
University Press, or the authors of  the Numerical Recipes books.  (3)
You must not copy  or redistribute any  of  the programs or procedures
for commercial purposes.  You CAN make copies of the programs for your
friends  and    colleagues, providing   that you  include   this  file
(especially its copyright notice and  disclaimer of warranty) with any
copy that you make.

** What's  the  catch, then?  **    None at  all.   Many  thousands of
satisfied users paid more than $20 to purchase exactly the programs on
this disk,  which were sold   by Cambridge  University  Press (C.U.P.)
between 1986 and 1989.  C.U.P.  now sells a  revised  version  of  the
Numerical  Recipes program library,  whose   Pascal  style   is   much
improved, but whose basic algorithmic  workings are identical  to this
disk.  Rather  than  let  the older version go  to waste,  its authors
decided to make it available to the shareware community of users.

** How can I figure out what the procedures do? ** One way is  to read
the brief descriptions of all the programs in the  file NRINFO.DOC.  A
better  way is to  look  at the  book   Numerical Recipes: The  Art of
Scientific Computing  in   any  one of its  three  editions  (FORTRAN,
Pascal, or  C).  If you  don't  want to buy this book   from Cambridge
University Press   (see the file  NRINFO.DOC),  you  can  find   it in
libraries.  Or, take  a pencil and   a small  piece  of paper  into  a
bookstore that carries the book and take  notes  on which programs you
might find interesting.

** How do I figure out how to use  the procedures? **  Again, you have
several  options.   All  the   procedures  (named   *.PAS)  come  with
demonstration  programs  (named *.DEM).   These demonstration programs
are included on this shareware diskette.  (When sold, they are sold as
a separate  diskette.)  Usually  you can figure    out how  to   use a
procedure by figuring out its .DEM program.  Another way is to look at
the Numerical Recipes book in a library or bookstore.

** Aren't you just trying to get me to  buy the book?  **  Think of it
this way: Most shareware comes with the requirement that if you use it
more than casually, you are  required to become  a registered user and
pay a fee.  We are not requiring any  fee at all.   We think that  you
will  be able to  use MOST of the procedures  on this diskette without
the Numerical Recipes book.  If you become a more-than-casual user, or
if you look at the book in a bookstore, we  are betting  that you will
WANT to buy it,  and  perhaps  then  want to purchase  the revised and
improved versions of the programs, also.   But it is completely  up to
you.

** OK, what if I do want to get the book? ** Call Cambridge University
Press at their  toll-free  number,  800-872-7423.  (In  New York  call
800-227-0247 or 914-937-9600.)  Ask for "Numerical Recipes in Pascal",
ISBN  number  0-521-37516-9.  We think  you'll like it.  (Over 100,000
copies of the book are in print, in FORTRAN, Pascal, and C.)

** What  are the files  on this diskette? **  All  the  procedures, in
Pascal source  code, are  in   the ZIP   file NRPAS13.ZIP.   You   use
PKUNZIP.EXE to decompress them.  (For  info  just execute PKUNZIP with
no  command  line  arguments.)  All  the  demonstration  programs  are
similarly in NRPEX10.ZIP (PEX means Pascal EXamples).  Some data files
used by the procedures and demonstrations programs are in NRPDATA.ZIP.
The files NRPAS13.LST and NRPEX10.LST each list the names of the files
in their corresponding ZIP file.   The short file  MODFILE.PAS is used
by many of the  procedures to customize  to your particular variety of
Pascal  compiler; feel free to modify  it, if  you need to.  The  file
NRINFO.DOC tells about the book Numerical Recipes in Pascal and  gives
a   brief description of  all the  procedures.   The  file you are now
reading is NRREADME.DOC.

Good luck, and happy number-crunching!

                       DISCLAIMER OF WARRANTY
                       ---------- -- -------- 
THE PROGRAMS AND  PROCEDURES  ON  THIS DISKETTE  ARE PROVIDED "AS  IS"
WITHOUT  WARRANTY OF  ANY KIND.   WE  MAKE NO  WARRANTIES, EXPRESS  OR
IMPLIED, THAT THE PROGRAMS  AND PROCEDURES ARE FREE  OF ERROR, OR  ARE
CONSISTENT WITH ANY  PARTICULAR  STANDARD OF MERCHANTABILITY,  OR THAT
THEY WILL MEET YOUR REQUIREMENTS FOR ANY PARTICULAR APPLICATION.  THEY
SHOULD NOT BE RELIED ON FOR SOLVING A PROBLEM WHOSE INCORRECT SOLUTION
COULD RESULT IN INJURY TO A PERSON OR LOSS OF PROPERTY.  IF YOU DO USE
THE PROGRAMS OR PROCEDURES IN SUCH A MANNER, IT  IS AT YOUR OWN  RISK.
THE AUTHORS   AND  PUBLISHER   DISCLAIM ALL LIABILITY    FOR   DIRECT,
INCIDENTAL, OR  CONSEQUENTIAL DAMAGES RESULTING FROM YOUR  USE  OF THE
PROGRAMS OR PROCEDURES ON THIS DISKETTE.  ANY LIABILITY  OF THE PERSON
OR PERSONS FROM WHOM YOU DIRECTLY OR INDIRECTLY OBTAINED THIS DISKETTE
WILL BE LIMITED EXCLUSIVELY  TO PRODUCT REPLACEMENT OF DISKETTES  WITH
MANUFACTURING DEFECTS.

Deleted mttroot/mtt/bin/trans/p/mtt_euler.p version [6de6bf5883].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_euler(VAR x_out, x,dx : StateVector;
			dt	    : REAL;
			Nx	    : INTEGER;
			Open	    : StateVector);

VAR i : INTEGER;
   
BEGIN{mtt_euler}
   FOR i := 1 TO Nx DO
   BEGIN
      IF Open[i]>0.5 THEN{Open switch}
	 x_out[i] := 0.0
      ELSE
	 x_out[i] := x[i] + dx[i]*dt;
   END;
END;{mtt_euler}

Deleted mttroot/mtt/bin/trans/p/mtt_getargs.p version [8b9348a180].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{ Substitute for p2c PASCAL_MAIN
   Copies pogramme arguments in to mtt_parameters array
   This c code is embedded in a pascal routine in a p2c compatible way
}

{EMBED
Static Void  PASCAL_MAIN(argc, argv)
int argc;
char *argv[];

\[
 int i;
 mttnpar = argc-1;
 if (mttnpar>0) \[
   for (i=0;i<MTT_Nx;i++)\[
     x[i] = strtod(argv[i+1],0);
  \]
   for (i=0;i<MTT_Npar;i++)\[
     par[i] = strtod(argv[i+MTT_Nx+1],0);
  \]
 simpar.first=strtod(argv[MTT_Nx+MTT_Npar+1],0);
 simpar.dt=strtod(argv[MTT_Nx+MTT_Npar+2],0);
 simpar.last=strtod(argv[MTT_Nx+MTT_Npar+3],0);
 \]
\]
}

Deleted mttroot/mtt/bin/trans/p/mtt_implicit.p version [e4c58449c4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_implicit(VAR xnew	: StateVector;
			   x,dx	: StateVector;
			   AA	: StateMatrix;
			   AAx	: StateVector;
			   dt	: REAL;
			   Nx	: INTEGER;
			   open	: StateVector);

VAR
   i,ii,j,jj,Nxsub : INTEGER;
   BB,xsub   : StateVector;
   AAsub     : StateMatrix;
   
(*$I $MTTPATH/trans/p/mtt_solve.p *)

BEGIN{mtt_implicit}
   ii := 0;
   FOR i := 1 TO  Nx DO {BB is (1-A*dt)*x +dx*dt}
   BEGIN
      IF open[i]<0.5 THEN
      BEGIN
	 ii := ii+1; jj := 0;
	 BB[ii] := AAx[i] + dt*dx[i];
	 FOR j := 1 TO Nx DO
	    IF open[j]<0.5 THEN
	    BEGIN
	       jj := jj+1;
	       AAsub[ii,jj] := AA[i,j];
	    END;
      END;
   END;

   Nxsub := ii; {New size}
   mtt_solve(xsub,AAsub,BB,Nxsub); {Solve AAx=BB}

   ii := 0;
   FOR i := 1 TO Nx DO
      BEGIN
	 IF open[i]<0.5 THEN
	 BEGIN
	    ii := ii+1; 
	    xnew[i] := xsub[ii];
	 END
	 ELSE
	 xnew[i] := 0.0;
      END;
END;{mtt_implicit}			  

Deleted mttroot/mtt/bin/trans/p/mtt_lubksb.p version [c3d7f1be65].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_lubksb(a: StateMatrix; n: INTEGER; indx: StateVector; VAR b: StateVector);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }

{
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/08/17 12:58:16  peterg
## Initial revision
##
###############################################################
}


(* Programs using LUBKSB must define the types
TYPE
   glnarray = ARRAY [1..n] OF real;
   glindx = ARRAY [1..n] OF integer;
   glnpbynp = ARRAY [1..np,1..np] OF real;
in the main routine *)
VAR
   j,ip,ii,i: integer;
   sum: real;
BEGIN
   ii := 0;
   FOR i := 1 TO n DO BEGIN
      ip := indx[i];
      sum := b[ip];
      b[ip] := b[i];
      IF  (ii <> 0) THEN BEGIN
         FOR j := ii TO i-1 DO BEGIN
            sum := sum-a[i,j]*b[j]
         END
      END ELSE IF (sum <> 0.0) THEN BEGIN
         ii := i
      END;
      b[i] := sum
   END;
   FOR i := n DOWNTO 1 DO BEGIN
      sum := b[i];
      IF (i < n) THEN BEGIN
         FOR j := i+1 TO n DO BEGIN
            sum := sum-a[i,j]*b[j]
         END
      END;
      b[i] := sum/a[i,i]
   END
END;

Deleted mttroot/mtt/bin/trans/p/mtt_ludcmp.p version [46fed2d80a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_ludcmp(VAR a: StateMatrix; n: integer;
		     VAR indx: StateVector; VAR d: real);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }

{
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/08/14 07:58:13  peterg
## Initial revision
##
###############################################################
}

(* Programs using LUDCMP must define the types
TYPE
   glnpbynp = ARRAY [1..np,1..np] OF real;
   glnarray = ARRAY [1..n] OF real;
   glindx = ARRAY [1..n] OF integer;
in the main routine. *)

CONST
   tiny=1.0e-20;

VAR
   k,j,imax,i: integer;
   sum,dum,big: real;
   vv: glnarray;

BEGIN
   d := 1.0;
   FOR i := 1 TO n DO BEGIN
      big := 0.0;
      FOR j := 1 TO n DO IF (abs(a[i,j]) > big) THEN big := abs(a[i,j]);
      IF (big = 0.0) THEN BEGIN
         writeln('pause in LUDCMP - singular matrix'); readln
      END;
      vv[i] := 1.0/big
   END;
   FOR j := 1 TO n DO BEGIN
      FOR i := 1 TO j-1 DO BEGIN
         sum := a[i,j];
         FOR k := 1 TO i-1 DO BEGIN
            sum := sum-a[i,k]*a[k,j]
         END;
         a[i,j] := sum
      END;
      big := 0.0;
      FOR i := j TO n DO BEGIN
         sum := a[i,j];
         FOR k := 1 TO j-1 DO BEGIN
            sum := sum-a[i,k]*a[k,j]
         END;
         a[i,j] := sum;
         dum := vv[i]*abs(sum);
         IF (dum > big) THEN BEGIN
            big := dum;
            imax := i
         END
      END;
      IF (j <> imax) THEN BEGIN
         FOR k := 1 TO n DO BEGIN
            dum := a[imax,k];
            a[imax,k] := a[j,k];
            a[j,k] := dum
         END;
         d := -d;
         vv[imax] := vv[j]
      END;
      indx[j] := imax;
      IF (a[j,j] = 0.0) THEN a[j,j] := tiny;
      IF (j <> n) THEN BEGIN
         dum := 1.0/a[j,j];
         FOR i := j+1 TO n DO BEGIN
            a[i,j] := a[i,j]*dum
         END
      END
   END;
END;

Deleted mttroot/mtt/bin/trans/p/mtt_par_update.p version [5ebd9ad207].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_numpar_update(VAR new_numpar : ParameterVector;
				   old_numpar : ParameterVector);
VAR i : INTEGER;
   
BEGIN {mtt_numpar_update}

   for i:=1 TO MTT_Npar DO {copy values}
      new_numpar[i] := old_numpar[i];
   
   WHILE NOT eof(numparfile) DO {read and update values}
      IF NOT (numparfile^ = chr("#")) THEN
      BEGIN
	 read(numparfile,i); read(numparfile,new_numpar[i]);
      END
      ELSE
	 readln(numparfile);
   
END {mtt_numpar_update};

PROCEDURE mtt_state_update(VAR new_state : StateVector;
			       old_state : StateVector);

VAR i : INTEGER;
   
BEGIN {mtt_state_update}

   for i:=1 TO MTT_Nx DO {copy values}
      new_state[i] := old_state[i];

   WHILE NOT eof(statefile) DO {read and update values}
      IF NOT (statefile^ = chr("#")) THEN
      BEGIN
	 read(statefile,i); read(statefile,new_state[i]);
      END
      ELSE
	 readln(statefile);
      
END {mtt_state_update};

PROCEDURE mtt_simpar_update(VAR dt : REAL);
BEGIN {mtt_simpar_update}

   WHILE NOT eof(simparfile) DO {read and update values}
   BEGIN
      IF NOT (simparfile^ = chr("#")) THEN
	 read(simparfile,dt);
      readln(simparfile); 
   END
END {mtt_simpar_update};

Deleted mttroot/mtt/bin/trans/p/mtt_solve.p version [284b083bf3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_solve(VAR x : StateVector;
			A : StateMatrix;
			B : StateVector;
			n : integer);

{

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.3  1999/10/26 23:44:36  peterg
% % Now packages up mtt_solve_lud OR mtt_solve_svd
% %
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

VAR
   i	     : integer;
   wmax,wmin : real;
   w	     : StateVector ;
   v	     : StateMatrix;


(*$I $MTTPATH/trans/p/mtt_solve_lud.p *)
(* I $MTTPATH/trans/p/mtt_solve_svd.p *)

BEGIN{mtt_solve}
      mtt_solve_lud(x,A,B,N);
      (*** mtt_solve_svd(x,A,B,N); ***)
END{mtt_solve};

Deleted mttroot/mtt/bin/trans/p/mtt_solve_lu.p version [a11985cf48].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_solve_lu.p(VAR x     : StateVector;
			A     : StateMatrix;
		    VAR B     : StateVector;
			n     : integer;
			Small : real);

{
Linear equation solution via LU factorisation}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

VAR
   i	     : integer;
   wmax,wmin : real;
   w	     : StateVector ;
   v	     : StateMatrix;

(*$I svdcmp.p *)
(*$I svbksb.p *)

BEGIN{mtt_solve}
(* decompose matrix A using SVD *)
   svdcmp(A,n,n,w,v);
   
(* find maximum singular value *)
   wmax := 0.0;
   FOR i := 1 to n DO BEGIN
      IF  (w[i] > wmax) THEN  wmax := w[i]
   END;
   
(* define "small" *)
   wmin := wmax*Small;
   
(* zero the "small" singular values *)
   FOR i := 1 to n DO BEGIN
      IF  (w[i] < wmin) THEN  w[i] := 0.0
   END;
   
(* backsubstitute for B *)
      svbksb(A,w,v,n,n,B,x);
   
END{mtt_solve};

Deleted mttroot/mtt/bin/trans/p/mtt_solve_lud.p version [ec0698602b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_solve_lud(VAR x     : StateVector;
			A     : StateMatrix;
		        B     : StateVector;
			n     : integer);

{
Linear equation solution via LU factorisation

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.3  1999/10/26 23:37:20  peterg
% % Put include files here.
% %
% % Revision 1.2  1998/08/17 15:56:10  peterg
% % Uses LU decomposition - much faster than SVD when N>100
% %
% % Revision 1.1  1998/08/17 12:52:16  peterg
% % Initial revision
% %
% % Revision 1.1  1998/08/17 12:41:37  peterg
% % Initial revision
% %
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

VAR
   i	 : integer;
   d	 : real;
   Index : StateVector;


(*$I $MTTPATH/trans/p/mtt_ludcmp.p *)
(*$I $MTTPATH/trans/p/mtt_lubksb.p *)

BEGIN{mtt_solve_lud}
   (* decompose matrix A using LU decomposition *)
   mtt_ludcmp(A,n,Index,d);
   
   (* backsubstitute for B *)
   mtt_lubksb(A,n,Index,B);

   (* x now lives in B *)
   FOR i := 1 TO n DO
      x[i] := B[i];
   
END{mtt_solve_lud};






Deleted mttroot/mtt/bin/trans/p/mtt_solve_svd.p version [4ad1314c58].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_solve_svd(VAR x : StateVector;
			    A : StateMatrix;
			VAR B : StateVector;
			    n : integer);

{Solve linear equation via svd}

{

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  1998/08/17 12:40:25  peterg
% % Renamed mtt_solve to mtt_solve_svd
% % -- now also have mtt_solve_lu
% %
% % Revision 1.1  1998/08/17 12:38:52  peterg
% % Initial revision
% %
% % Revision 1.2  1998/08/14 12:09:13  peterg
% % A passed by value - its destroyed by SVDcm
% %
% % Revision 1.1  1998/08/13 08:51:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }

CONST
   Small =  1e-6; (* Criteroion for small svd *)
VAR
   i	     : integer;
   wmax,wmin : real;
   w	     : StateVector ;
   v	     : StateMatrix;

(*$I svdcmp.p *)
(*$I svbksb.p *)

BEGIN{mtt_solve}
(* decompose matrix A using SVD *)
   svdcmp(A,n,n,w,v);
   
(* find maximum singular value *)
   wmax := 0.0;
   FOR i := 1 to n DO BEGIN
      IF  (w[i] > wmax) THEN  wmax := w[i]
   END;
   
(* define "small" *)
   wmin := wmax*Small;
   
(* zero the "small" singular values *)
   FOR i := 1 to n DO BEGIN
      IF  (w[i] < wmin) THEN  w[i] := 0.0
   END;
   
(* backsubstitute for B *)
      svbksb(A,w,v,n,n,B,x);
   
END{mtt_solve};

Deleted mttroot/mtt/bin/trans/p/mtt_sparse.p version [c94532268f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_sparse(	 b	 : glnarray;
			 n,iters : INTEGER;
		     VAR x	 : glnarray);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }
{*
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1998/08/15 13:49:19  peterg
## iters now passed as an argument.
##
## Revision 1.4  1998/08/15 09:33:25  peterg
## Deleted the commented out stuff
##
## Revision 1.3  1998/08/15 09:30:05  peterg
## Commented out the cariabel iteration stuff
##
## Revision 1.2  1998/08/15 08:26:30  peterg
## This is variable interations version - now going on to fixed
## iterations
##
## Revision 1.1  1998/08/13 14:58:35  peterg
## Initial revision
##
## Revision 1.1  1998/08/13 08:40:40  peterg
## Initial revision
##
###############################################################
*}

(* Programs using routine SPARSE must define the type
TYPE
   glnarray = ARRAY [1..n] OF real;
in the main routine. They must also provide two routines,
PROCEDURE asub(x: glnarray; VAR y: glnarray; n: integer);
and
PROCEDURE atsub(x: glnarray; VAR z: glnarray; n: integer);
which calculate A*x and (A transpose)*x *)
   
VAR
   j,iter,irst: integer;
   rp,gg,gam,eps2,dgg,bsq,anum,aden: real;
   g,h,xi,xj: glnarray;
   
BEGIN {mtt_sparse}
   mtt_asub(x,xi,n);
   rp := 0.0;
   bsq := 0.0;
   FOR j := 1 TO n DO BEGIN
      xi[j] := xi[j]-b[j];
   END;
   mtt_atsub(xi,g,n);
   FOR j := 1 TO n DO BEGIN
      g[j] := -g[j];
      h[j] := g[j]
   END;
   FOR iter := 1 TO iters DO BEGIN
      mtt_asub(h,xi,n);
      anum := 0.0;
      aden := 0.0;
      FOR j := 1 TO n DO BEGIN
         anum := anum+g[j]*h[j];
         aden := aden+sqr(xi[j])
      END;
      anum := anum/aden;
      FOR j := 1 TO n DO BEGIN
         xi[j] := x[j];
         x[j] := x[j]+anum*h[j]
      END;
      mtt_asub(x,xj,n);
      FOR j := 1 TO n DO BEGIN
         xj[j] := xj[j]-b[j];
      END;
      mtt_atsub(xj,xi,n);
      gg := 0.0;
      dgg := 0.0;
      FOR j := 1 TO n DO BEGIN
         gg := gg+sqr(g[j]);
         dgg := dgg+(xi[j]+g[j])*xi[j]
      END;
      gam := dgg/gg;
      FOR j := 1 TO n DO BEGIN
         g[j] := -xi[j];
         h[j] := g[j]+gam*h[j]
      END
   END;
END {mtt_sparse};

Deleted mttroot/mtt/bin/trans/p/mtt_update.p version [36e3f6e075].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_update(VAR xnew	    : StateVector;
		         dx,x,AAx   : StateVector;
		     VAR AA	    : StateMatrix;
			 DT	    : REAL;
			 STEPFACTOR : INTEGER;
			 Nx	    : INTEGER;
			 METHOD	    : IntegrationMethod);

{
 ###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1998/08/15 13:48:35  peterg
## New update methods
##
## Revision 1.4  1998/08/14 10:54:58  peterg
## Use sparse computation where possible
##
###############################################################
}

CONST
   Small = 0.000001;
   
VAR
   i,j : INTEGER;
   BB  : StateVector;
   DDT : REAL;
   
(*$I mtt_solve_lud.p *)
(*$I mtt_sparse.p *)
   
BEGIN{mtt_update}
   
   IF Method=1 THEN {Euler}
   BEGIN{Euler}
      DDT := DT/STEPFACTOR;
	 FOR i := 1 TO  Nx DO
	    xnew[i] := xnew[i] + dx[i]*DDT;
   END {Euler}
   ELSE IF (Method=2) OR (METHOD=3) OR (METHOD=4) THEN {Implicit}
      BEGIN {Implicit methods}
	 
	 FOR i := 1 TO  Nx DO {BB is (1-A*dt)*x +dx*dt}
	    BB[i] := AAx[i] + DT*dx[i];

	 {Solve the equation AAx = B}
	 IF (Method=2) OR (METHOD=3) THEN {Use SVD}
	    mtt_solve_lud(xnew,AA,BB,Nx)
	 ELSE {Sparse CG solution}
	    mtt_sparse(BB,Nx,STEPFACTOR,xnew);
      END{Implicit methods}
      ELSE
	 Writeln("Method >4 is not defined");
   
END{mtt_update};




Deleted mttroot/mtt/bin/trans/p/mtt_write.p version [0a11e8a899].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE mtt_write(t	  : REAL;
		    x	  : StateVector;
		    y	  : OutputVector;
		    nx,ny : INTEGER);

{*
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
      Pascal function mtt_write
      P.J. Gawthrop July 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1999/03/15 21:57:38  peterg
## Removed the # symbol
##
## Revision 1.4  1998/11/26 13:31:30  peterg
## Put missing space after 2nd t
##
## Revision 1.3  1998/07/25 20:41:38  peterg
## Spaces between numbers
##
## Revision 1.2  1998/07/25 14:04:14  peterg
## Changed format
##
## Revision 1.1  1998/07/25 09:47:25  peterg
## Initial revision
##
###############################################################


*}

CONST TAB=9;
 
VAR
   i : INTEGER;
   
BEGIN
   write(t,chr(TAB));
   FOR i := 1 TO ny DO
      write(y[i],chr(TAB));

   write(t,chr(TAB));
   FOR i := 1 TO nx DO
      write(x[i],chr(TAB));
   writeln;
END;
   

Deleted mttroot/mtt/bin/trans/p/sign.p version [52b4a0069f].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
FUNCTION sign(x	: REAL) : REAL;
{ This useful function is missing from Pascal }

BEGIN
   IF X>=0 THEN
      sign := 1
   ELSE
      sign := -1;
END; { sign }

Deleted mttroot/mtt/bin/trans/p/sparse.p version [a1c1b1b77d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE sparse(b: glnarray; n: integer; VAR x: glnarray; VAR rsq: real);
{*
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################
*}

(* Programs using routine SPARSE must define the type
TYPE
   glnarray = ARRAY [1..n] OF real;
in the main routine. They must also provide two routines,
PROCEDURE asub(x: glnarray; VAR y: glnarray; n: integer);
and
PROCEDURE atsub(x: glnarray; VAR z: glnarray; n: integer);
which calculate A*x and (A transpose)*x *)
LABEL 1,99;
CONST
   eps=1.0e-6;
VAR
   j,iter,irst: integer;
   rp,gg,gam,eps2,dgg,bsq,anum,aden: real;
   g,h,xi,xj: glnarray;
BEGIN
   eps2 := n*sqr(eps);
   irst := 0;
1:   irst := irst+1;
   asub(x,xi,n);
   rp := 0.0;
   bsq := 0.0;
   FOR j := 1 TO n DO BEGIN
      bsq := bsq+sqr(b[j]);
      xi[j] := xi[j]-b[j];
      rp := rp+sqr(xi[j])
   END;
   atsub(xi,g,n);
   FOR j := 1 TO n DO BEGIN
      g[j] := -g[j];
      h[j] := g[j]
   END;
   FOR iter := 1 TO 10*n DO BEGIN
      asub(h,xi,n);
      anum := 0.0;
      aden := 0.0;
      FOR j := 1 TO n DO BEGIN
         anum := anum+g[j]*h[j];
         aden := aden+sqr(xi[j])
      END;
      IF (aden = 0.0) THEN BEGIN
         writeln('pause in routine SPARSE');
         writeln('very singular matrix'); readln
      END;
      anum := anum/aden;
      FOR j := 1 TO n DO BEGIN
         xi[j] := x[j];
         x[j] := x[j]+anum*h[j]
      END;
      asub(x,xj,n);
      rsq := 0.0;
      FOR j := 1 TO n DO BEGIN
         xj[j] := xj[j]-b[j];
         rsq := rsq+sqr(xj[j])
      END;
      IF ((rsq = rp) OR (rsq <= bsq*eps2)) THEN GOTO 99;
      IF (rsq > rp) THEN BEGIN
         FOR j := 1 TO n DO BEGIN
            x[j] := xi[j]
         END;
         IF (irst >= 3) THEN GOTO 99;
         GOTO 1
      END;
      rp := rsq;
      atsub(xj,xi,n);
      gg := 0.0;
      dgg := 0.0;
      FOR j := 1 TO n DO BEGIN
         gg := gg+sqr(g[j]);
         dgg := dgg+(xi[j]+g[j])*xi[j]
      END;
      IF (gg = 0.0) THEN GOTO 99;
      gam := dgg/gg;
      FOR j := 1 TO n DO BEGIN
         g[j] := -xi[j];
         h[j] := g[j]+gam*h[j]
      END
   END;
   writeln('pause in routine SPARSE');
   writeln('too many iterations'); readln;
99:   END;

Deleted mttroot/mtt/bin/trans/p/svbksb.p version [d97150a209].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE svbksb(u: glmpbynp; w: glnparray; v: glnpbynp;
       m,n: integer; b: glmparray; VAR x: glnparray);
{

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  1998/08/12 11:09:54  peterg
% % Taken from NR share library nrpas13 as  SVBKSB.PAS
% % and renamed  svbksb.p
% %
% % Revision 1.1  1998/08/12 11:09:02  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }


(* Programs using SVBKSB must define the types
TYPE
   glnparray = ARRAY [1..np] OF real;
   glmparray = ARRAY [1..mp] OF real;
   glnpbynp = ARRAY [1..np,1..np] OF real;
   glmpbynp = ARRAY [1..mp,1..np] OF real;
in the main routine. *)
VAR
   jj,j,i: integer;
   s: real;
   tmp: glnparray;
BEGIN
   FOR j := 1 TO n DO BEGIN
      s := 0.0;
      IF (w[j] <> 0.0) THEN BEGIN
         FOR i := 1 TO m DO BEGIN
            s := s+u[i,j]*b[i]
         END;
         s := s/w[j]
      END;
      tmp[j] := s
   END;
   FOR j := 1 TO n DO BEGIN
      s := 0.0;
      FOR jj := 1 TO n DO BEGIN
         s := s+v[j,jj]*tmp[jj];
      END;
      x[j] := s
   END
END;

Deleted mttroot/mtt/bin/trans/p/svdcmp.p version [33402da454].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCEDURE svdcmp(VAR a: glmpbynp; m,n: integer;
		 VAR w: glnparray; VAR v: glnpbynp);

{ This file is derived from the NUMERICAL RECIPES PASCAL SHAREWARE DISKETTE.
 Please read the README file in $MTTPATH/trans/p
 }

{
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.4  1998/08/12 11:26:39  peterg
% % Zapped unnecessary np and mp arguments
% %
% % Revision 1.3  1998/08/12 11:08:03  peterg
% % Put in pythag routine to compute z = sqrt(y^2 + z^2) (as in book)
% % Save loop index l as ll when jumping from loop - using l itself is
% % undefined
% %
% % Revision 1.2  1998/08/12 11:05:33  peterg
% % Taken from NR share library nrpas13 as SVDCMP.PAS
% % and renamed svdcmp.p
% %
% % Revision 1.1  1998/08/12 11:03:57  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}


(* Programs using routine SVDCMP must define the types
TYPE
   glnparray = ARRAY [1..np] OF real;
   glmpbynp = ARRAY [1..mp,1..np] OF real;
   glnpbynp = ARRAY [1..np,1..np] OF real;
in the main routine. *)
LABEL 1,2,3;
CONST
   nmax=100;
VAR
   nm,l,k,j,jj,its,i,ll	       : integer;
   z,y,x,scale,s,h,g,f,c,anorm : real;
   rv1			       : ARRAY [1..nmax] OF real;
			  
FUNCTION pythag(a,b : real): real;
VAR p,at,bt : REAL;
BEGIN
   at:=abs(a);
   bt:=abs(b);
   IF at>bt THEN
      p:= at*sqrt(1.0+sqr(bt/at))
   ELSE
      IF bt=0.0 THEN
	 p := 0.0
      ELSE
	 p := bt*sqrt(1.0+sqr(at/bt));
   pythag := p;
END{pythag};
			   
   
FUNCTION sign(a,b : real): real;
   BEGIN
      IF (b >= 0.0) THEN sign := abs(a) ELSE sign := -abs(a)
   END;
FUNCTION max(a,b: real): real;
   BEGIN
      IF (a > b) THEN max := a ELSE max := b
   END;
BEGIN
   g := 0.0;
   scale := 0.0;
   anorm := 0.0;
   FOR i := 1 TO n DO BEGIN
      l := i+1;
      rv1[i] := scale*g;
      g := 0.0;
      s := 0.0;
      scale := 0.0;
      IF (i <= m) THEN BEGIN
         FOR k := i TO m DO BEGIN
            scale := scale+abs(a[k,i])
         END;
         IF (scale <> 0.0) THEN BEGIN
            FOR k := i TO m DO BEGIN
               a[k,i] := a[k,i]/scale;
               s := s+a[k,i]*a[k,i]
            END;
            f := a[i,i];
            g := -sign(sqrt(s),f);
            h := f*g-s;
            a[i,i] := f-g;
            IF (i <> n) THEN BEGIN
               FOR j := l TO n DO BEGIN
                  s := 0.0;
                  FOR k := i TO m DO BEGIN
                     s := s+a[k,i]*a[k,j]
                  END;
                  f := s/h;
                  FOR k := i TO m DO BEGIN
                     a[k,j] := a[k,j]+
                        f*a[k,i]
                  END
               END
            END;
            FOR k := i TO m DO BEGIN
               a[k,i] := scale*a[k,i]
            END
         END
      END;
      w[i] := scale*g;
      g := 0.0;
      s := 0.0;
      scale := 0.0;
      IF ((i <= m) AND (i <> n)) THEN BEGIN
         FOR k := l TO n DO BEGIN
            scale := scale+abs(a[i,k])
         END;
         IF (scale <> 0.0) THEN BEGIN
            FOR k := l TO n DO BEGIN
               a[i,k] := a[i,k]/scale;
               s := s+a[i,k]*a[i,k]
            END;
            f := a[i,l];
            g := -sign(sqrt(s),f);
            h := f*g-s;
            a[i,l] := f-g;
            FOR k := l TO n DO BEGIN
               rv1[k] := a[i,k]/h
            END;
            IF (i <> m) THEN BEGIN
               FOR j := l TO m DO BEGIN
                  s := 0.0;
                  FOR k := l TO n DO BEGIN
                     s := s+a[j,k]*a[i,k]
                  END;
                  FOR k := l TO n DO BEGIN
                     a[j,k] := a[j,k]
                        +s*rv1[k]
                  END
               END
            END;
            FOR k := l TO n DO BEGIN
               a[i,k] := scale*a[i,k]
            END
         END
      END;
      anorm := max(anorm,(abs(w[i])+abs(rv1[i])));
   END;
   FOR i := n DOWNTO 1 DO BEGIN
      IF (i < n) THEN BEGIN
         IF (g <> 0.0) THEN BEGIN
            FOR j := l TO n DO BEGIN
	       v[j,i] := (a[i,j]/a[i,l])/g;
	    END;
            FOR j := l TO n DO BEGIN
               s := 0.0;
               FOR k := l TO n DO BEGIN
                  s := s+a[i,k]*v[k,j]
               END;
               FOR k := l TO n DO BEGIN
                  v[k,j] := v[k,j]+s*v[k,i]
               END
            END
         END;
         FOR j := l TO n DO BEGIN
            v[i,j] := 0.0;
            v[j,i] := 0.0
         END
      END;
      v[i,i] := 1.0;
      g := rv1[i];
      l := i
   END;
   FOR i := n DOWNTO 1 DO BEGIN
      l := i+1;
      g := w[i];
      IF (i < n) THEN BEGIN
         FOR j := l TO n DO BEGIN
            a[i,j] := 0.0
         END
      END;
      IF (g <> 0.0) THEN BEGIN
         g := 1.0/g;
         IF (i <> n) THEN BEGIN
            FOR j := l TO n DO BEGIN
               s := 0.0;
               FOR k := l TO m DO BEGIN
                  s := s+a[k,i]*a[k,j]
               END;
               f := (s/a[i,i])*g;
               FOR k := i TO m DO BEGIN
                  a[k,j] := a[k,j]+f*a[k,i]
               END
            END
         END;
         FOR j := i TO m DO BEGIN
            a[j,i] := a[j,i]*g
         END
      END ELSE BEGIN
         FOR j := i TO m DO BEGIN
            a[j,i] := 0.0
         END
      END;
      a[i,i] := a[i,i]+1.0
   END;
   FOR k := n DOWNTO 1 DO BEGIN
      FOR its := 1 TO 30 DO BEGIN
         FOR l := k DOWNTO 1 DO BEGIN
            nm := l-1;
            IF ((abs(rv1[l])+anorm) = anorm) THEN
	       BEGIN
		  ll:=l;
		  GOTO 2;
	       END;
	    IF nm>0 THEN {* Put in by me - see book *}
	       IF ((abs(w[nm])+anorm) = anorm) THEN
		  BEGIN
		     ll:=l;
		     GOTO 1
		  END;
         END;
1:         c := 0.0;
         s := 1.0;
         FOR i := ll TO k DO BEGIN
            f := s*rv1[i];
            IF ((abs(f)+anorm) <> anorm) THEN BEGIN
	       g := w[i];
	       {**h := sqrt(f*f+g*g);**}
	       h := pythag(f,g);
               w[i] := h;
               h := 1.0/h;
               c := (g*h);
               s := -(f*h);
               FOR j := 1 TO m DO BEGIN
                  y := a[j,nm];
                  z := a[j,i];
                  a[j,nm] := (y*c)+(z*s);
                  a[j,i] := -(y*s)+(z*c)
               END
            END
         END;
2:         z := w[k];
         IF (ll = k) THEN BEGIN
            IF (z < 0.0) THEN BEGIN
               w[k] := -z;
               FOR j := 1 TO n DO BEGIN
               v[j,k] := -v[j,k]
            END
         END;
         GOTO 3
         END;
         IF (its = 30) THEN BEGIN
            writeln ('no convergence in 30 SVDCMP iterations'); readln
	 END;
         x := w[l];
         nm := k-1;
         y := w[nm];
         g := rv1[nm];
         h := rv1[k];
         f := ((y-z)*(y+z)+(g-h)*(g+h))/(2.0*h*y);
	 {***g := sqrt(f*f+1.0); writeln(g);***}
	 g := pythag(f,1.0);
         f := ((x-z)*(x+z)+h*((y/(f+sign(g,f)))-h))/x;
         c := 1.0;
         s := 1.0;
         FOR j := ll TO nm DO BEGIN
            i := j+1;
            g := rv1[i];
            y := w[i];
            h := s*g;
            g := c*g;
            {**z := sqrt(f*f+h*h);**}
	    z := pythag(f,h);
            rv1[j] := z;
            c := f/z;
            s := h/z;
            f := (x*c)+(g*s);
            g := -(x*s)+(g*c);
            h := y*s;
            y := y*c;
            FOR jj := 1 TO n DO BEGIN
               x := v[jj,j];
               z := v[jj,i];
               v[jj,j] := (x*c)+(z*s);
               v[jj,i] := -(x*s)+(z*c)
            END;
            {**z := sqrt(f*f+h*h);**}
	    z := pythag(f,h);
            w[j] := z;
            IF (z <> 0.0) THEN BEGIN
               z := 1.0/z;
               c := f*z;
               s := h*z
            END;
            f := (c*g)+(s*y);
            x := -(s*g)+(c*y);
            FOR jj := 1 TO m DO BEGIN
               y := a[jj,j];
               z := a[jj,i];
               a[jj,j] := (y*c)+(z*s);
               a[jj,i] := -(y*s)+(z*c)
            END
         END;
         rv1[l] := 0.0;
         rv1[k] := f;
         w[k] := x
      END;
3:   END
END;

Deleted mttroot/mtt/bin/trans/p/zero_input.p version [c982d1d936].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
PROCEDURE zero_input(VAR x : InputVector;
			 N : INTEGER);
VAR i : INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      x[i] := 0.0;
END;


Deleted mttroot/mtt/bin/trans/p/zero_matrix.p version [799bc2655a].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
PROCEDURE zero_matrix(VAR A : StateMatrix;
			  N : INTEGER);
VAR i,j	:  INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      FOR j:=1 TO N DO
	 A[i,j] := 0.0;
END;


Deleted mttroot/mtt/bin/trans/p/zero_state.p version [e67a8f8538].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
PROCEDURE zero_state(VAR x : StateVector;
			 N : INTEGER);
VAR i : INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      x[i] := 0.0;
END;


Deleted mttroot/mtt/bin/trans/p/zero_vector.p version [51fb965f2c].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
PROCEDURE zero_vector(VAR x : StateVector;
			  N : INTEGER);
VAR i : INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      x[i] := 0.0;
END;


Deleted mttroot/mtt/bin/trans/p/zeros.p version [e8ec334d34].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
PROCEDURE zeros(VAR A	: StateMatrix;
		    N	: INTEGER);
VAR i,j	:  INTEGER;
   
BEGIN
   FOR i:=1 TO N DO
      FOR j:=1 TO N DO
	 A[i,j] = 0.0;
END;


Deleted mttroot/mtt/bin/trans/p2oct version [3ed0dbadda].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2cr_txt2txt

# Label file to constitutive relationship conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/02/07 15:48:33  peterg
## Initial revision
##
## Revision 1.3  1998/07/29 11:09:39  peterg
## Now matches ^$1$ not $1!
##
## Revision 1.2  1998/03/08 21:02:55  peterg
## Now does multiple crs.
##
# Revision 1.1  1997/03/20  12:23:21  peterg
# Initial revision
#
###############################################################



# Inform user
echo "Creating $1_cr.txt"

rm -f mtt_error


# This is the main transformation using gawk 
# And remove crs with same name as system
gawk -f $MTTPATH/trans/awk/lbl2cr.awk $1_lbl.txt  2>mtt_error.txt |\
grep -v "^$1$" \
> $1_cr.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/rbg2abg_m version [94d244aa2c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246






















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg2abg_m
#
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.21  2004/09/12 22:27:27  geraint
## Appended 't' to fopen mode string to open in text mode.
##
## Revision 1.20  2004/02/19 12:05:49  gawthrop
## Fix prob. when no bonds
##
## Revision 1.19  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.18  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.17  2000/12/05 12:04:03  peterg
## Changed function name to name()
##
## Revision 1.16  2000/12/05 09:04:08  peterg
## Fixed function () compatibility problem.
##
## Revision 1.15  2000/11/03 14:53:33  peterg
## Copy NOTPAR as well
##
## Revision 1.14  2000/09/14 08:41:35  peterg
## Strip off the additional direction info from rbonds
##
## Revision 1.13  2000/03/16 12:53:26  peterg
## Added copy of the %VAR declarations
## Put in the endfunction statement
##
## Revision 1.12  1998/07/28 19:07:48  peterg
## Writes out N_ports as well as n_ports
##
## Revision 1.11  1998/07/25 16:14:44  peterg
## *** empty log message ***
##
## Revision 1.10  1998/07/08 15:34:56  peterg
## Sorted out error exit status
##
## Revision 1.9  1998/07/08 08:24:26  peterg
## Added -I option -- if set prints out the indormation messages
##
## Revision 1.8  1998/02/19 08:57:02  peterg
## Fixed mtt-info bug -- confused filename with number
##
## Revision 1.7  1997/08/05 08:38:23  peterg
## Added n-ports to the argument list in the comment.
##
## Revision 1.6  1996/12/04 21:52:01  peterg
## Uses filenum and fopen instead of filename.
##
## Revision 1.5  1996/08/25 09:20:32  peter
## General error handling.
##
## Revision 1.4  1996/08/24 17:57:41  peter
## Removed `touch mtt_info.txt'
##
## Revision 1.3  1996/08/24 14:58:56  peter
## Fixed missprint - mtt_err --> mtt_error
##
## Revision 1.2  1996/08/24 14:33:07  peter
## Error handling included.
##
## Revision 1.1  1996/08/05 12:22:16  peter
## Initial revision
##
###############################################################

# Raw bond graph to structured acausal bond graph: mfile format
# The structured BG is described by four matrices:
#   junctions: describes the junctions -
#     Column 1   Index of component (see components)
#     Column 2.. Indices of bonds on junction (see jbonds)
#                  rows may be padded with zeros
#
#   jbonds:    describes the true bonds -
#     Column 1     Index of component (see components)
#     Column 2     Direction
#                    1 away from junction
#                   -1 towards junction
#     Column 3     Causality 
#                     1 stroke at arrow end
#                    -1 stroke at other end
#                     0 no stroke (ie acausal)
#     Columns 4:5  x,y coordinates of non-arrow end (in Fig)
#     Columns 6:7  x,y coordinates of arrow end (in Fig)
#
#   mbonds:    describes the modulation bonds -
#     Column 1     Index of component at non-arrow end
#     Column 2     Index of component at arrow end
#     Columns 4:5  x,y coordinates of non-arrow end (in Fig)
#     Columns 6:7  x,y coordinates of arrow end (in Fig)
#
#   components: describes the comonents -
#     Column 1     Type of component
#                    0  0-junction
#                    1  1-junction
#                    2  R component
#                    3  C component
#                    4  I component
#                    11 TF component
#                    12 GY component
#                    13 A  component
#     Column 2     Flag for explicit junction
#                    4  Explicit component (4 means text type)
#                    0  Implicit component
#     Column 3-14    fig file information (see fig documentation)
#
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.

while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-nounits )
                units=no;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

## Set up some vars
sys=$1
lbl_file=${sys}_lbl.txt
abg_file=${sys}_abg.m

# Remove the old log file
rm -f rbg2abg_m.log
rm -f ${abg_file}

#Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log  2>mtt_error.txt << EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');

  %Convert from the fig version of the bonds to a structured version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg
  [n_ports, junk] = size(port_list)
 
  N_ports = 0;
  for i=1:n_ports		# Count the true number of ports.
    [subport,n_sub] = split_port(port_list(i,:), ',');
    N_ports = N_ports+n_sub;
  end;
 
  [n_bonds,m_bonds] = size(rbonds);
  if n_bonds>0
    rbonds = rbonds(:,1:6);  # Strip  the directional information
  endif

  [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, ...
                               infofile,errorfile);

  %Write the function m-file for the causal bond graph
  write_abg(name,bonds,components,n_vector_bonds);    
EOF

## Sets the units for the abg file
test_units()
{ 
  grep '^[\s]*[#|%]UNITS' < ${lbl_file} >/dev/null
  if [ $? = "0" ]; then 
    grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
    gawk '{
      printf("mtt_units.sh %s %s %s %s %s\n", sys, $2, $3, $4, $5)
    }' sys=${sys}  | sh | grep ERROR
    if [ $? = "0" ]; then
      echo "    " *MTT_ERRROR: domains and units are not OK - exiting
      exit 1  
    else
      echo "    " domains and units are OK 
    fi
  else
    echo "  no domains or units declared"
  fi
} 

check_ports_exist()
{
 declared_ports=`grep '^[\s]*[#|%]UNITS' < ${lbl_file} | gawk '{print $2}'`
  for declared_port in $declared_ports; do
    grep "${sys}\.ports\.${declared_port}\.type" ${abg_file} >/dev/null
    if [ $? = "1" ]; then
      echo "*MTT_ERRROR: Units declared for non-existent port ${declared_port}"
      exit 1
    fi
  done
}

set_units()
{ 
  grep '^[\s]*[#|%]UNITS' < ${lbl_file} |\
  gawk '{
    printf("  %s.ports.%s.domain = \"%s\";\n", sys, $2, $3);
    printf("  %s.ports.%s.units.effort = \"%s\";\n", sys, $2, $4);
    printf("  %s.ports.%s.units.flow = \"%s\";\n", sys, $2, $5);
  }' sys=${sys}
} 

if [ -z "$units" ]; then
  echo Checking port domains and units
  check_ports_exist;
  test_units;
  echo "## Port domain and units" >> ${abg_file}
  set_units >> ${abg_file}
fi

# Append any VAR declarations
if [ -f "$1_lbl.txt" ]; then
  echo "## Explicit variable declarations" >> ${abg_file}
  grep '^[\s]*[%|#][V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
  grep '^[\s]*[%|#]NOT[V|P]AR' $1_lbl.txt | tr '%' '#' >> ${abg_file}    
fi

## Close off the function
echo "endfunction" >> ${abg_file}

## Errors and info
if [ "$info" = "info" ]; then
  cat mtt_info.txt    
fi

if mtt_error mtt_error.txt
then
    exit 0
else
    exit 1
fi

Deleted mttroot/mtt/bin/trans/rbg2ibg_m version [22334b9ac4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg2ibg_m
# Based on rbg2abg_m

while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-I)
	    info=info;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

# Set up some vars
sys=$1
ibg=${sys}_ibg.m
err=mtt_error.txt
log=rbg2ibg_m.log

# Remove the old log file
rm -f ${ibg}
rm -f ${log}

# Inform user
echo Creating ${ibg}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');
  
  ## Interpret the connections from the fig version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg;
  [n_ports, junk] = size(port_list);
  
  ## Strip the directional information
  rbonds = rbonds(:,1:6);
  
  [bonds] = ...
      rbg2ibg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, ...
	      infofile,errorfile);
  
  ## Write the intermediate bond graph m-file
  write_ibg(name,bonds);
EOF

# Errors and info
if [ "$info" = "info" ]; then
    cat mtt_info.txt
fi

if mtt_error mtt_error.txt; then
    exit 0
else
    exit 1
fi

Deleted mttroot/mtt/bin/trans/rbg_fig2m version [fe3a6b77ac].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213





















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg_fig2m
# Raw  bond-graph conversion from fig to matlab
# P.J.Gawthrop May 1996
# Modified June 1996 to handle xfig version 3
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2005/08/05 15:35:17  gawthrop
## Fixed _ in ports
##
## Revision 1.13  2005/03/15 15:03:55  gawthrop
## Now works for Hierarchical systems
##
## Revision 1.12  2005/03/15 12:49:28  gawthrop
## Handle descriptive (inc maths) text as well
##
## Revision 1.11  2005/03/15 12:03:48  gawthrop
## New labg.fig rep - pretty LaTeX figures.
##
## Revision 1.10  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.9  2002/01/11 03:44:19  geraint
## Breaks compounds objects into individual components. Eliminates "incorrect object code error" in cbg.ps when component is not causally complete.
##
## Revision 1.8  2001/10/15 14:25:44  gawthrop
## Now handles white space at the end of component names
## Converts ports lables [1:5] into [1,2,3,4,5]
##
## Revision 1.7  2001/07/24 22:42:59  geraint
## Fixes problem when lbl.txt does not end with newline.
##
## Revision 1.6  2001/05/24 07:48:17  gawthrop
## Include artwork in the cbg.fig file
##
## Revision 1.5  2001/03/23 14:56:21  gawthrop
## Now puts space after header fields + write _port.fig
##
## Revision 1.4  2000/09/14 08:41:51  peterg
## *** empty log message ***
##
## Revision 1.3  1997/03/19 09:50:24  peterg
## Now creates the sabg (stripped abg) file.
##
# Revision 1.2  1996/08/30  10:17:41  peter
# New path for awk script.
#
## Revision 1.1  1996/08/05 20:13:33  peter
## Initial revision
##
###############################################################

cmp2latex() {
  gawk '{
  ## 
  ## Zap trailing \001
  A = substr($0,1,length($0)-4);

  ## Find before and after:
  N=split(A,B,":");

  ## Split into fields
  M=split(B[1],C);

  ## Dont modify port labels (except for _ -> \_)
  if(index(C[M],"[")==1){
       for (i=1;i<M;i++){
         if (C[i]=="_")
           C[i] = "\\\\_";
         printf("%s ",C[i]);
       }
       printf("%s\\001\n",C[M]);
   }
  else{
     ## Set special flag
     FlagCol = 9
     C[FlagCol] = 6;

     ## Write out modified version
     for (i=1;i<M;i++)
       printf("%s ",C[i]);

    if (N==1)
      printf("\\\\B{%s}\\001\n",C[M]);
    if (N==2)
      if(index(B[2],"[")==1){
        gsub(/_/,"\\\\_",B[2]);
        printf("\\\\B{%s}:%s\\001\n",C[M],B[2]);
      }
      else
        printf("\\\\BB{%s}{%s}\\001\n",C[M],B[2]);
   }
  }'  
}

art2latex() {
  gawk '{
  ## Is it text?
  is_text="4";
  if ($1!=is_text)
    print $0
  else
  {
  ## Zap trailing \001
  B = substr($0,1,length($0)-4);

  ## Split into fields
  M=split(B,C);

  ## Set special flag
  FlagCol = 9
  C[FlagCol] = 6;

  ## Write out modified version
  N = 14;
  for (i=1;i<N;i++)
    printf("%s ",C[i]);

  for (i=N;i<=M;i++) {
    if ( (index(C[i],"_")>0)&&(index(C[i],"$")==0) )
      C[i] = sprintf("$%s$", C[i]);
    printf(" %s",C[i]);
  }

  printf("\\001\n");

  }
  }'  
}


# Inform user
echo "Creating $1_rbg.m"
echo "Creating $1_cmp.m"
echo "Creating $1_head.fig"
echo "Creating $1_fig.fig"
echo "Creating $1_cmp.fig"
echo "Creating $1_port.fig"
echo "Creating $1_sabg.fig"
echo "Creating $1_art.fig"
echo "Creating $1_labg.fig"


# Remove some files that I'm going to append to.
rm -f $1_fig.fig
rm -f $1_head.fig
rm -f $1_cmp.fig
rm -f $1_port.fig
rm -f $1_bnd.fig
rm -f $1_art.fig

# Create blank files
touch $1_fig.fig
touch $1_head.fig
touch $1_cmp.fig
touch $1_port.fig
touch $1_bnd.fig
touch $1_art.fig

# Deletes trailing white space in component names
# and break compound objects
sed 's/[	 ]*\\001/\\001/' < $1_abg.fig |\
grep -v "^6 [0-9 ]*" | grep -v "^-6$" >$1_abg.mtt1

# Replace [1:5] with [1,2,3,4,5]
gawk '{
   if (match($14, /\[1:[0-9]*\]/)){
    range = substr($14,2,length($14)-6);
    split(range,a,":");
    str = "1";
    for (i=2;i<=a[2];i++) str = sprintf("%s,%i", str, i);
    sub(/1:[0-9]*/, str, $14);
   }
    print $0
}' < $1_abg.mtt1 > $1_abg.mtt2


# The following horrible sed thing is to replace tab by ----
# this is because I can't get sed to recognise tabs even if FS=" ".
echo "" > $1_abg.mtt3
sed 's/	/---- /'<$1_abg.mtt2 >> $1_abg.mtt3

# This is the main transformation using awk
cat $1_lbl.txt $1_abg.mtt3 |  gawk -f $MTTPATH/trans/awk/rbg_fig2m.awk $1 no_alpha_sort=$2

rm -f $1_abg.mtt

#Create the stripped abg file
cat $1_head.fig $1_bnd.fig $1_cmp.fig> $1_sabg.fig

#Create the latexed abg file
##latex_tidy $1_art.fig
art2latex< $1_art.fig  >$1_lart.fig
cmp2latex<$1_cmp.fig  >$1_lcmp.fig
cat $1_head.fig $1_bnd.fig $1_lcmp.fig | sed 's/---- /	/' > $1_labg.fig
strip_comments < $1_lart.fig | sed 's/---- /	/' >> $1_labg.fig






Deleted mttroot/mtt/bin/trans/rcs_header.m version [48ce935dee].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Deleted mttroot/mtt/bin/trans/rcs_header.sh version [0521c8429a].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

Deleted mttroot/mtt/bin/trans/rdae2dae_r version [96eb754660].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251



























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rdae2dae_r
# Reduce equations to raw differential-algebraic equation conversion
# P.J.Gawthrop  8th May 1991, May 1994, June 1996
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2001/04/11 09:44:26  gawthrop
## Fixed cc and c problems to do with pow(x,y) and integers
## mtt/lib/reduce/fix_c.r is included in rdae2dae and cse2smx_lang for
## -c, -cc and -oct options
##
## Revision 1.6  2001/02/03 13:40:45  gawthrop
## Added explicit MTTNu
##
## Revision 1.5  2000/12/28 12:39:02  peterg
## Put under RCS
##
## Revision 1.4  2000/09/04 08:42:53  peterg
## Put in extra echo to space output
##
## Revision 1.3  2000/09/02 15:55:11  peterg
## Now doesn't include def files in da files
##
## Revision 1.2  2000/09/01 13:36:15  peterg
## Added -partition option
##
## Revision 1.1  2000/09/01 12:14:44  peterg
## Initial revision
##
## Revision 1.3  1998/03/07 12:57:19  peterg
## Fixed logname bug
##
## Revision 1.2  1998/03/07 12:51:20  peterg
## This is the new version of ese2dae - it does not do the CRs at this
## stage to give reduce an easier time.
##
## rese2ese_r does the constitutive relationship bit
##
## Revision 1.1  1998/03/07 12:49:31  peterg
## Initial revision
##
## Revision 1.12  1998/01/31 16:22:59  peterg
## Added IF MTTNx>0 THEN and IF MTTNy>0 THEN before the relevant
## assignements of MTTdX and MTTY to themselves.
##
## Revision 1.11  1997/09/18 09:45:08  peterg
## Canged the comment about linux reduce -- reduce reads this for some
## reason.
##
## Revision 1.10  1997/09/15 14:21:18  peterg
## Reads ese file twice to avoid a bug in Linux reduce !!!???
##
## Revision 1.9  1997/08/30 09:59:31  peterg
## Changed mehtod of writing out mtty to avoid a strange segmentation violation.
## Now uses MTTY := MTTY; approach.
##
## Revision 1.8  1997/04/23 09:31:20  peterg
## Now reads in the (top level) def file in the generated reduce code.
##
# Revision 1.7  1997/04/23  09:23:15  peterg
# Two argument version in preparation for heirarchical version
#
# Revision 1.6  1996/11/21  15:47:48  peterg
# Now inputs _params.r not _sympar.r
#
## Revision 1.5  1996/11/02 10:17:35  peterg
## Removed default constitutive relationship input.
##
# Revision 1.4  1996/09/12  12:10:05  peter
# Now reads the default constitutive relationship file.
#
## Revision 1.3  1996/08/25 09:43:26  peter
## General error handling.
##
## Revision 1.2  1996/08/25 08:31:28  peter
## Error handling added.
##
###############################################################


while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;;
	-partition )
                partition=yes;
                blurb='with partitioning';
		;;
	-fixcc )
                include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'`
                blurb2='fixing c and cc code';
		;;
	*)
		echo "$1 is an invalid argument - ignoring";
                exit ;;
  esac
  shift
done

#Create the top-level system name
topname=$1

#Create the system names
if [ -z "$2" ]; 
    then
	sysname=$topname;
    else
	sysname=$1_$2;
fi

defname=$topname"_def.r"
crname=$topname"_cr.r"
subsname=$topname"_subs.r"
rdaename=$sysname"_rdae.r"
daename=$sysname"_dae.r"
logname="rdae2dae.log"

# Inform user
echo Creating $daename $blurb $blurb2

# Remove the old log file
rm -f $logname

# Use symbolic algebra to accomplish the transformation
$SYMBOLIC >$logname  << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

% CRs
in "$crname";

% Raw dae
in "$rdaename";

% Substitution
in "$subsname";

% Fix c code if required
$include


OFF Echo;
OFF Nat;

%Create the output file
OUT "$daename";

%write "in ""$defname""";

write "MTTNu := ", MTTNu;
write "MTTNx := ", MTTNx;
write "MTTNz := ", MTTNz;
write "MTTNy := ", MTTNy;
write "MTTNyz := ", MTTNyz;

% State
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Nonstate
MTT_Matrix := MTTZ$ 
MTT_Matrix_name := "MTTZ"$
MTT_Matrix_n := MTTNz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTy$ 
MTT_Matrix_name := "MTTy"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Zero outputs
MTT_Matrix := MTTYz$ 
MTT_Matrix_name := "MTTYz"$
MTT_Matrix_n := MTTNyz$
MTT_Matrix_m := 1$
Reduce_Matrix()$
SHUT "$daename";
quit;

EOF

#if [ -n "$partition" ]; then
#  rm -f mtt_junk
#  # Now for the subsystems
#  # Find subsystems
#  subsystems=`mtt_get_subsystems $1`
#
#  for subsystem in $subsystems; do
#  echo Doing $subsystem
#  ucname="MTT_"$subsystem"_uc"
#
#  Nu=`mtt_getsize -internal $subsystem u`
#  echo Nu $Nu
#
#  # Use symbolic algebra to accomplish the transformation
#  $SYMBOLIC >$logname  << EOF
#
#  %Read the formatting function
#  in "$MTTPATH/trans/reduce_matrix.r";
#
#  % Definitions
#  in "$defname";
#
#  % Elementary system equations
#  in "$rdaename";
#
#  OFF Echo;
#  OFF Nat;
# 
#  %Create the output file
#  OUT "mtt_junk";
#  % Connecting inputs
#  MTT_Matrix := $ucname $
#  MTT_Matrix_name := "$ucname" $
#  MTT_Matrix_n := $Nu $
#  MTT_Matrix_m := 1$
#  Reduce_Matrix()$
#
#  shut "mtt_junk";
#EOF
#  echo >> $1_dae.r
#  echo %Connections for subsystem $subsystem  >> $1_dae.r
#  echo >> $1_dae.r
#
#  cat mtt_junk >> $1_dae.r
#  rm -rf mtt_junk
#  done
#fi

echo "END;" >> $1_dae.r

# Now invoke the standard error handling.
mtt_error_r $logname

Deleted mttroot/mtt/bin/trans/reduce_matrix.r version [80a2f375d5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in reduce form
% P.J.Gawthrop  January 22 1998
% Copyright (c) P.J.Gawthrop, 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/01/22 10:39:01  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




PROCEDURE Reduce_Matrix;
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
     write "clear ", MTT_Matrix_name, ";";
     write "MATRIX ", MTT_Matrix_name, "(", MTT_Matrix_n, ",",
                                            MTT_Matrix_m, ");";
    
    FOR i := 1:MTT_Matrix_n DO
      FOR j := 1:MTT_Matrix_m DO IF MTT_Matrix(i,j) NEQ 0 THEN
        write MTT_Matrix_name, "(", i, ",", j, ") := ",
                                            MTT_Matrix(i,j), ";";
    END;
END;

END;;

Deleted mttroot/mtt/bin/trans/rep_txt2sh version [6825c9a064].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rep_txt2sh
# Executes shell commands for report.

# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  2002/05/01 14:07:44  gawthrop
## Added -dr foo (reads files from foo) dir.
##
## Revision 1.6  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.5  2000/11/27 10:13:25  peterg
## Now passes though options as second argument
##
## Revision 1.4  1998/04/14 18:17:15  peterg
## More messages about Makefile
##
## Revision 1.3  1998/04/14 18:01:04  peterg
## Now executes a Makefile (if it exists)
##
# Revision 1.2  1997/12/06  14:27:53  peterg
# No changes.
#
## Revision 1.1  1997/08/26 09:06:11  peterg
## Initial revision
##
###############################################################

# Execute a make if Makefile exists
if [ -f Makefile ]; then
  echo Executing the Makefile
  make    
  echo Done executing the Makefile
  echo
fi

## Get switches (if any)
mtt_switches=$2

# Inform user
echo "Creating representations for $1_rep.tex"

# Check for old (2 arg) version and update if necessary
mtt_count=`strip_comments < $1_rep.txt | grep -c 'mtt '`
if [ "$mtt_count" = "0" ]; then
  echo 'Hmm .. seems to be an old format. creating new file'
  echo "Old version saved as $1_rep.txt.SAVE"
  mv $1_rep.txt $1_rep.txt.SAVE
  strip_comments < $1_rep.txt.SAVE |\
  gawk '{print "mtt", sys, $1, $2}' sys="$1" >$1_rep.txt
fi


# Execute the commands - quietly and untidily!
# But use switches
# | sed "s/mtt /mtt -q -u $mtt_switches /" #| tee -a JUNK  | sh

strip_comments< $1_rep.txt | gawk '
{
  ## Add in the external switches
  sub("mtt", sprintf("mtt %s", mtt_switches));
      
  ## Count the switches (noting that -i -dr -dw and -de have an argument)
  ## and make up a string (switches) containing them
  Switches=0; switches = "";
  for (i=2;i<=NF;i++) {
    if (match($i,"-")==1) {
      Switches++;
      switches=sprintf("%s%s", switches, $i);
    }
    if (match($i,"-i")==1) {
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dr")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dw")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-de")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
  }
  System = $(Switches+2)
  Representation = $(Switches+3);
  Multiple = "odes odeso sms smso daes daeso";
  Language = $(Switches+4);

  args = $(Switches+5);
  if ( (length(args)>0)&&(match(Language,"ps")>0)) {
    __Args = sprintf("-%s", gensub(/_/, "-", "g", args) );
  }
  else
  {
  __Args = "";
  }

  ## mtt command
  printf("%s\n", $0);

  ## Add in the main mtt switches
  __Args = sprintf("%s%s", switches, __Args);
 
  ## Zap -q -u
  gsub("-[qu]","", __Args);

  ## Zap blanks
  gsub(" ","", __Args);

  ## copy result to long name file
  SysRepLang = sprintf("%s_%s.%s", System, Representation, Language);
  if (length(__Args)==0)
    __Args = "-noargs";
  SysRepArgLang = sprintf("%s_%s%s.%s", System, Representation, __Args, Language);
  printf("echo Creating %s\n", SysRepArgLang);
  printf("cp %s %s\n", SysRepLang, SysRepArgLang);

}' mtt_switches="${mtt_switches}"  | sh

echo "Done creating representations for $1_rep.tex"




Deleted mttroot/mtt/bin/trans/rep_txt2tex version [a95f4950eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254






























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rep_txt2tex
# Converts the text file dercribing a report to a report.
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2003/08/19 15:40:25  gawthrop
## Fix _ prob in section headers.
##
## Revision 1.5  2003/08/19 13:10:47  gawthrop
## More arg stuff
##
## Revision 1.4  2002/05/09 16:07:54  gawthrop
## Now handles multiple options whis .tex files as well
##
## Revision 1.3  2002/05/01 14:07:05  gawthrop
## Added -dr foo (reads files from foo) dir.
##
## Revision 1.2  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.1  2000/12/27 15:57:31  peterg
## Initial revision
##
## Revision 1.15  2000/04/06 10:57:12  peterg
## Removed debug line
##
## Revision 1.14  2000/04/06 10:51:14  peterg
## replaces $PWD by `pwd` for sh compatibility
##
## Revision 1.13  1999/10/19 23:47:27  peterg
## Rewrote for the extra representations - but with .ps at the end
## Need to retrofit old desc files using multiple figures
##
## Revision 1.12  1999/10/19 03:33:01  peterg
## Temporaraly removed argument stripping
##
## Revision 1.11  1999/02/17 02:00:29  peterg
## Absolute pathname for files.
## Indirect include via \input
##
## Revision 1.10  1998/08/25 12:45:27  peterg
## Added icad to languages
##
## Revision 1.9  1998/03/09 13:26:22  peterg
## Removed `system' from part and section headers.
##
## Revision 1.8  1998/02/09 08:59:35  peterg
## Minor debugging lines removed.
##
## Revision 1.7  1998/01/29 19:32:33  peterg
## Removed a spurious X from the file -- tried to run  the X server !!!
##
## Revision 1.6  1997/12/04 22:08:52  peterg
## Handles multiple odes.ps files
##
## Revision 1.5  1997/12/04 17:05:57  peterg
## Now handles multiple odeso.ps files
##
## Revision 1.4  1997/08/25 09:15:48  peterg
## Don't do sections for unrecognised languages.
##
# Revision 1.3  1997/06/27  13:28:25  peterg
# New version using explicit command line arguments in the text file
#
## Revision 1.2  1997/05/19 16:11:36  peterg
## Modified section headers.
##
# Revision 1.1  1996/08/18  20:00:38  peter
# Initial revision
#
###############################################################

documenttype=$2; 
mtt_switches=$4

## Remove -u and -q
mtt_switches=`echo ${mtt_switches} | sed 's/-[qu]//g'`

if [  "$documenttype" = "book" ]; then # do book version
  # Inform user
  echo "Creating $1_rep.tex (directory version)"
  strip_comments < $1_rep.txt|\
  gawk '
BEGIN{
oldpart = ""
}
{
  # Find directory name.
  for (i=1;i<NF;i++){
    if ($i=="-d") 
       directory=$(i+1);
  }
  # Find next to last name
  N=split(directory,a,"/");
  if (N>1) 
    part = a[N-1];
  if (length(part)>0)
    if (part!=oldpart)
      printf("\\part{\\textbf{%s}}\n", part);
  oldpart=part;
  printf("\\chapter{\\textbf{%s}}\n", $(NF-2));
  printf("\\label{chap:%s(%s)}\n", $(NF-2), directory);
  printf("\\input{%s/%s_rep}\n\n", directory, $(NF-2));
  }' > $1_rep.tex


else # do article and section version

if [ -z "$3" ]; then
  directory="";
else
  directory=$3/;
fi

# Inform user
echo "Creating $1_rep.tex"

# Create the LaTeX file
strip_comments <$1_rep.txt |\
gawk '
{
  ## Add in the external switches
  sub("mtt", sprintf("mtt %s", mtt_switches));
  
  ## Count the switches (noting that -i -dr -dw and -de have an argument)
  ## and make up a string (switches) containing them
  Switches=0; switches = "";
  for (i=2;i<=NF;i++) {
    if (match($i,"-")==1) {
      Switches++;
      switches=sprintf("%s%s", switches, $i);
    }
    if (match($i,"-i")==1) {
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dr")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dw")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-de")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
  }
  print "%%%" switches
  System = $(Switches+2)
  Representation = $(Switches+3);
  Multiple = "odes odeso sms smso daes daeso";
  Language = $(Switches+4);
  Languages = "tex txt r m c h ps icad";
  args = $(Switches+5);
  quote = "\047";
  args = gensub(quote, "", "g",  args);
  args = gensub(/"/, "", "g",  args);
#  args = substr(Args,2,length(Args)-2);
#  if ( (length(Args)>0)&&(match(Multiple,Representation)>0)) {
  if ( (length(args)>0)&&(match(Language,"ps")>0)) {
    _Args = sprintf("-%s", args); 
    __Args = sprintf("-%s", gensub(/_/, "_", "g", args) );
    ___Args = sprintf("-%s", gensub(/,/, "-", "g", args) );
  }
  else
  {
  _Args = "";
  __Args = "";
  ___Args = "";
  }

  ## Add in the mtt args
  __Args = sprintf("%s%s", switches, __Args);

  ## Treat no arguments as -noargs
  if (length(__Args)==0){
    __Args = "-noargs";
    header_args = "";
  }
  else {
    header_args = __Args;
    gsub("-", " -", header_args);
    gsub(/_/, "\\_", header_args);
    header_args = sprintf("(%s)", header_args); 
  }

print "%%" __Args "%%"
#  print "DEBUG", Language, args, _Args, __Args
  RepLang = sprintf("%s%s.%s", Representation, __Args, Language);
  SysRepLang = sprintf("%s_%s", System, RepLang);
  SysRepLangArgs = sprintf("%s_%s", System, RepLang, __Args);
  SysRep = sprintf("%s_%s%s", System, Representation, __Args);
  filename = gensub(/,/, "-", "g", SysRep);
  FileName = sprintf("%s/%s", PWD, filename);
  section_head = sprintf("\\textbf{%s\\_%s.%s} \\emph{%s}",
   System,Representation,Language, header_args);
   
# section headings
    if (match(Languages,Language)>0) {
    print "\n\n\\section{" section_head "}";
    print "\\label{sec:" SysRepLangArgs "}";
    print "\\index{\\textbf{" System "} -- " Representation "}";
    
    print "\n\nMTT command:";
    print "\\begin{verbatim}";
      for (i=1;i<=NF;i++) printf("%s ", $i);
    print "\n\\end{verbatim}";
    }

# tex files
    if( match("tex",Language)>0) {
      printf("  \\input{%s}\n", FileName);
#      command = sprintf("sed s!fig{!fig{%s! < %s_%s.%s", Directory, System, Representation, Language);
#      system(command);    
}

# text files
    if( match("txt r m c h icad",Language)>0) {
      print "  \\begin{verbatim}";
      command = sprintf("cat %s.txt", filename);
      system(command);
      print "  \\end{verbatim}";  
    }
# ps files
    if( match("ps",Language)>0) {
      printf("This representation is given as Figure \\Ref{fig:%s}.\n", SysRepLangArgs);
      Label = sprintf("%s", SysRepLangArgs);
      Caption = sprintf("System \\textbf{%s}, representation %s (%s)", System, Representation, __Args);
      printf("\\fig{%s}\n    {%s}\n    {0.9}\n    {%s}\n",FileName,Label,Caption);
  }
}
END {

}' mtt_switches="${mtt_switches}" System=$1 Directory=$directory PWD=`pwd` > $1_rep.tex

fi

Deleted mttroot/mtt/bin/trans/reps_txt2tk version [05813b0e5a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: reps_txt2tk
# Creates tk/tcl file for xmtt.
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/12/28 12:39:34  peterg
## Put under RCS
##
## Revision 1.4  2000/04/05 07:37:27  peterg
## *** empty log message ***
##
## Revision 1.3  1999/08/18 06:15:48  peterg
## Stripped down to just representations menu - see mtt_make_menu
##
## Revision 1.2  1999/03/09 00:03:19  peterg
## Revisions for xmtt
##
## Revision 1.1  1998/10/20 08:13:14  peterg
## Initial revision
##
###############################################################

sep='|'; # Separates the languages from the rest.

# Create reps menu
gawk --field-separator=$sep '{
  
# Find the rep and the title
  split($1,REP," ");
  rep=REP[1];
# find the languages
  N=split($2,LANG," ");

# Important representation?
 if (index(rep,"*")) {
    # Zap *
    rep=substr(rep,1,length(rep)-1);
    sub(/\*/,"",$1);
    printf("\n# Menus for representation %s\n", rep)
    printf(".rep.rep add  cascade -label \"%s\" -menu .rep.rep.%s\n", $1, rep);
    printf("menu .rep.rep.%s\n", rep);
    for (i=1;i<=N;i++) {
      lang = LANG[i];
      printf(" set mtt {mtt_pause $args $system %s %s} \n", rep, lang); 
      title = sprintf("Output_log_for_representation_%s_(language_%s)", rep, lang);
      printf(".rep.rep.%s add  command -label  \"%s\" ", rep, lang);
      printf(" -command  \"exec xterm -title %s -e $mtt  &\" \n", title); 
   }
 }
 else {
    printf("\n# Menus for representation %s\n", rep)
    printf(".repall.repall add  cascade  -label \"%s\" -menu .repall.repall.%s\n", $1, rep);
    printf("menu .repall.repall.%s\n", rep);
    for (i=1;i<=N;i++) {
      printf(" set mtt {mtt $args $system %s %s; mtt_pause} \n", rep, LANG[i]); 
      printf(".repall.repall.%s add  command -label  \"%s\" ", rep, LANG[i]);
      printf(" -command  \"exec echo $mtt &; exec $mtt &\" \n"); 
   }
 }
}'

Deleted mttroot/mtt/bin/trans/rest version [2530ab00f0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rest
# Gives remainder of space seperated string
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/10/10 07:44:20  peterg
## Initial revision
##
###############################################################

echo $1 | cut -d ' ' -f 2-

Deleted mttroot/mtt/bin/trans/simpar_txt2h version [fe5f9ab6b8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: simpar_txt2h

# Numerical parameters to c format
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/05/13 08:56:28  peterg
## Initial revision
##
###############################################################


system=$1


# Inform user
echo "Creating $1_simpar.h"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_simpar.h
echo "Simulation parameter file for system $1 ($1_simpar.h)"   >> $1_simpar.h
echo "This file provides the system simulation parameters in c form"  >> $1_simpar.h
echo "Generated by MTT at `date`"  >> $1_simpar.h
echo "from $1_simpar.txt"  >> $1_simpar.h
echo '*/' >> $1_simpar.h
echo  >> $1_simpar.h

# Now do the parameters

sed 's/ //g' $1_simpar.txt |\
 gawk -F '=' '/=/ {print "#define", $1, $2}'   >> $1_simpar.h






Deleted mttroot/mtt/bin/trans/sm2can_r version [27a5fb1925].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372




















































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2can_r
# state matrices to various canonical forms.
# P.J.Gawthrop  12 Jan 1997
# Copyright (c) P.J.Gawthrop 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Inform user
echo Creating $1_can.r -- NOTE this is for SISO systems only.

# Remove the old log file
rm -f sm2can_r.log

# Use reduce to accomplish the transformation
reduce >sm2can_r.log << EOF

in "$1_def.r";
in "$1_sm.r";
in "$1_tf.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;

% Find the controllability and observibility matrices.
MATRIX MTTCon(MTTNx,MTTNX);
MTTAB := MTTB;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon(i,j) := MTTAB(i,1);
   MTTAB := MTTA*MTTAB;
  END;

MATRIX MTTObs(MTTNx,MTTNX);
MTTCA := MTTC;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA;
  END;

%Canonical forms:
% This statement makes Gs a scalar transfer function
Gs := MTTtf(1,1);

% Numerator and denominator polynomials
bs := num(gs);
as := den(gs);

% extract coeficients and divide by coeff of s^n
% reverse operator puts list with highest oder coeffs first
ai := reverse(coeff(as,s));
a0 := first(ai);
MTTn := length(ai) - 1;


% Normalised coeficients;
ai := reverse(coeff(as/a0,s));
bi := reverse(coeff(bs/a0,s));
MTTm := length(bi)-1;

% Zap the (unity) first element of ai list;
ai := rest(ai);

% System in controller form
% MTTA_c matrix
matrix MTTA_c(MTTn,MTTn);

% First row is ai coefficients
for i := 1:MTTn do
  MTTA_c(1,i) := -part(ai,i);

% (MTTn-1)x(MTTn-1) unit matrix in lower left-land corner (if n>1)
if MTTn>1 then
  for i := 1:MTTn-1 do
    MTTA_c(i+1,i) := 1;

% B_c vector;
matrix MTTB_c(MTTn,1);
MTTB_c(1,1) := 1;

% C_c vector;
matrix MTTC_c(1,MTTn);
for i := 1:MTTm+1 do
  MTTC_c(1,i+MTTn-MTTm-1) := part(bi,i);

% D_c
MTTD_c := MTTD;

%Observable form.
MTTA_o := tp(MTTA_c);
MTTB_o := tp(MTTC_c);
MTTC_o := tp(MTTB_c);
MTTD_o := MTTD;

%Controllability matrix of controllable form
MATRIX MTTCon_c(MTTNx,MTTNX);
MTTAB := MTTB_c;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon_c(i,j) := MTTAB(i,1);
   MTTAB := MTTA_c*MTTAB;
  END;

% Transformation matrix;
MTTT_c := MTTCon_c*MTTCon^(-1);

%Observability matrix of observer form
MATRIX MTTObs_o(MTTNx,MTTNX);
MTTCA := MTTC_o;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs_o(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA_o;
  END;

% Transformation matrix;
MTTT_o := MTTObs^(-1)*MTTObs_o;

%%%%  Controller design %%%%%

% gain in controller form:
matrix MTTk_c(1,mttn);
matrix alpha_c(9,1);
alpha_c(1,1) := alpha_c1;
alpha_c(2,1) := alpha_c2;
alpha_c(3,1) := alpha_c3;
alpha_c(4,1) := alpha_c4;
alpha_c(5,1) := alpha_c5;
alpha_c(6,1) := alpha_c6;
alpha_c(7,1) := alpha_c7;
alpha_c(8,1) := alpha_c8;
alpha_c(9,1) := alpha_c9;


for i := 1:MTTNx do
 MTTk_c(1,i) := alpha_c(i,1) - part(ai,i);

% Gain in physical form
MTTk := MTTk_c*MTTT_c;

%%%%  Observer design %%%%%
% gain in Observer form:
matrix MTTl_o(MTTn,1);
matrix alpha_o(9,1);
alpha_o(1,1) := alpha_o1;
alpha_o(2,1) := alpha_o2;
alpha_o(3,1) := alpha_o3;
alpha_o(4,1) := alpha_o4;
alpha_o(5,1) := alpha_o5;
alpha_o(6,1) := alpha_o6;
alpha_o(7,1) := alpha_o7;
alpha_o(8,1) := alpha_o8;
alpha_o(9,1) := alpha_o9;

for i := 1:MTTNx DO
 MTTL_o(i,1) := alpha_o(i,1) - part(ai,i);

% Gain in physical form
MTTL := MTTT_o*MTTL_o;

% Steady-state stuff
% Create the matrix [A B; C D];
matrix ABCD(MTTn+1,MTTn+1);
for i := 1:MTTNx do
  for j := 1:MTTNx do
    ABCD(i,j) := MTTA(i,j);

for i :=1:MTTNx do
  ABCD(i,MTTNx+1) := MTTB(i,1);

for j := 1:MTTNx do
  ABCD(MTTNx+1,j) := MTTC(1,j);

ABCD(MTTNx+1,MTTNx+1) := MTTD(1,1);

matrix zero_one(MTTNx+1,1);
zero_one(MTTNx+1,1) := 1;

%Find N vector
Nxu := ABCD^(-1)*zero_one;

%Extract the parts
MATRIX MTTX_r(MTTNx,1);
FOR i := 1:MTTNx DO
  MTTX_r(i,1) := Nxu(i,1);

MTTu_r := Nxu(MTTNx+1,1);


% Compensator

matrix zero(MTTNx,1);
%State matrices
MTTA_comp := MTTA - MTTL*MTTC - MTTB*MTTK;
MTTB_comp := -MTTL;
MTTC_comp := -MTTK;

%Transfer function
%Ds := C_d*((s*MTTI - A_d)^(-1))*B_d;
%MTTTFC := Ds;

%Create the output file
OUT "$1_can.r";

%Write out the matrices.

% Controllable form
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
Reduce_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
Reduce_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  -Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Observer Gain matrix - observer form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$


% Controllable form
MTT_Matrix := MTTA_comp$ 
MTT_Matrix_name := "MTTA_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_comp$ 
MTT_Matrix_name := "MTTB_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
Reduce_Matrix()$

MTT_Matrix := MTTC_comp$ 
MTT_Matrix_name := "MTTC_comp"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


KX := MTTK*MTTX_r;
MTTu_r := MTTu_r + KX(1,1);



MTTu_r := MTTu_r;
write "END;";

SHUT "$1_can.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r sm2can_r.log

Deleted mttroot/mtt/bin/trans/sm2ir_m version [1eb0d56a1a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2ir_m

# Transforms descriptor matrix rep to step response


# Copyright (c) P.J.Gawthrop, 1996.


echo Creating $1_ir.m
echo Creating $1_iro.m
rm -f sm2ir_m.log
rm -f $1_ir.m
rm -f $1_iro.m
rm -f mtt_error

# if [ "$2" = "" ]; 
# then
#   PARAMS='T=[0:0.1:10];u0=ones(nu,1);x0=zeros(nx,1);'
#   echo Using default parameter $PARAMS
# else
#   PARAMS=$2;
# fi

# PARAMS="$PARAMS ;"

$MATRIX << EOF > sm2ir_m.log 2>mtt_error.txt

  % Read in the numeric system parameters
  mttpar = $1_numpar;

 % Read in the simulation parameters
  simpar = $1_simpar;

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  T=[0:simpar.dt:simpar.last]';

  if exist('u0')==0
    u0 = ones(nu,1);
  end;

  if exist('x0')==0
    x0 = zeros(nx,1);
  end;


  [n,m]=size(T);
  if m>n
    T=T';
  end;

  [A,B,C,D] = $1_sm(mttpar);
  [y,x] = sm2ir(A,B,C,D,T,u0,x0);

  if nx>0
    write_matrix([T x], '$1_ir');
  end;
  if ny>0
    write_matrix([T y], '$1_iro');
  end;

EOF

# Write info
touch mtt_info.txt
cat mtt_info.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sm2smc_r version [78545ed4d4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195



































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2smc_r
# state matrices to controller canonical form + related matrices
# P.J.Gawthrop  12 Jan 1997
# Copyright (c) P.J.Gawthrop 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/22 13:17:37  peterg
## Initial revision
##
###############################################################
Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi


# Inform user
echo Creating $1_smc.r $blurb

# Remove the old log file
rm -f sm2smc_r.log

# Use reduce to accomplish the transformation
reduce >sm2smc_r.log << EOF

in "$1_def.r";
in "$1_sm.r";
in "$1_tf.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;

% Find the controllability matrix
MATRIX MTTCon(MTTNx,MTTNX);
MTTAB := MTTB;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon(i,j) := MTTAB(i,1);
   MTTAB := MTTA*MTTAB;
  END;


%Canonical forms:
% This statement makes Gs a scalar transfer function
Gs := MTTtf(1,1);

% Numerator and denominator polynomials
bs := num(gs);
as := den(gs);

% extract coeficients and divide by coeff of s^n
% reverse operator puts list with highest oder coeffs first
ai := reverse(coeff(as,s));
a0 := first(ai);
MTTn := length(ai) - 1;


% Normalised coeficients;
ai := reverse(coeff(as/a0,s));
bi := reverse(coeff(bs/a0,s));
MTTm := length(bi)-1;

% Zap the (unity) first element of ai list;
ai := rest(ai);

% System in controller form
% MTTA_c matrix
matrix MTTA_c(MTTn,MTTn);

% First row is ai coefficients
for i := 1:MTTn do
  MTTA_c(1,i) := -part(ai,i);

% (MTTn-1)x(MTTn-1) unit matrix in lower left-land corner (if n>1)
if MTTn>1 then
  for i := 1:MTTn-1 do
    MTTA_c(i+1,i) := 1;

% B_c vector;
matrix MTTB_c(MTTn,1);
MTTB_c(1,1) := 1;

% C_c vector;
matrix MTTC_c(1,MTTn);
for i := 1:MTTm+1 do
  MTTC_c(1,i+MTTn-MTTm-1) := part(bi,i);

% D_c
MTTD_c := MTTD;

%Controllability matrix of controllable form
MATRIX MTTCon_c(MTTNx,MTTNX);
MTTAB := MTTB_c;
FOR j := 1:MTTNx DO
  BEGIN
   FOR i := 1:MTTNx DO 
      MTTCon_c(i,j) := MTTAB(i,1);
   MTTAB := MTTA_c*MTTAB;
  END;

% Transformation matrix;
MTTT_c := MTTCon_c*MTTCon^(-1);



%Create the output file
OUT "$1_smc.r";

%Write out the matrices.

% Controllable form
write "%  - Controller form";
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTD_c$ 
MTT_Matrix_name := "MTTD_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := 1$
Reduce_Matrix()$


write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "END;";

SHUT "$1_smc.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r sm2smc_r.log

Deleted mttroot/mtt/bin/trans/sm2smo_r version [f17cab7b54].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196




































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2smo_r
# state matrices to cobserver form
# P.J.Gawthrop  12 Jan 1997
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/09/11 10:53:54  peterg
## Uses 1st io of mimo to create siso
##
## Revision 1.2  1998/01/22 13:25:22  peterg
## Added END;; to output file.
##
## Revision 1.1  1998/01/22 13:16:43  peterg
## Initial revision
##
###############################################################

Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi
# Inform user
echo Creating $1_smo.r $blurb

# Remove the old log file
rm -f sm2smo_r.log

# Use reduce to accomplish the transformation
reduce >sm2smo_r.log << EOF

in "$1_def.r";
in "$1_sm.r";
in "$1_tf.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;

% Find  observibility matrix.
MATRIX MTTObs(MTTNx,MTTNX);
MTTCA := MTTC;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA;
  END;

%Canonical forms:
% This statement makes Gs a scalar transfer function
Gs := MTTtf(1,1);

% Numerator and denominator polynomials
bs := num(gs);
as := den(gs);

% extract coeficients and divide by coeff of s^n
% reverse operator puts list with highest oder coeffs first
ai := reverse(coeff(as,s));
a0 := first(ai);
MTTn := length(ai) - 1;


% Normalised coeficients;
ai := reverse(coeff(as/a0,s));
bi := reverse(coeff(bs/a0,s));
MTTm := length(bi)-1;

% Zap the (unity) first element of ai list;
ai := rest(ai);

% System in observer form
% MTTA_o matrix
matrix MTTA_o(MTTNx,MTTNx);

% First column is ai coefficients
for i := 1:MTTNx do
  MTTA_o(i,1) := -part(ai,i);

% (MTTNx-1)x(MTTNx-1) unit matrix in upper right-hand corner (if n>1)
if MTTNx>1 then
  for i := 1:MTTNx-1 do
    MTTA_o(i,i+1) := 1;

% C_o vector;
matrix MTTC_o(1,MTTNx);
  MTTC_o(1,1) := 1;
MTTC_o;
% B_o vector;
matrix MTTB_o(MTTNx,1);
for i := 1:MTTm+1 do
  MTTB_o(i+MTTNx-MTTm-1,1) := part(bi,i);

% D_o
MTTD_o := MTTD;

%Observability matrix of observer form
MATRIX MTTObs_o(MTTNx,MTTNX);
MTTCA := MTTC_o;
FOR i := 1:MTTNx DO
  BEGIN
   FOR j := 1:MTTNx DO 
      MTTObs_o(i,j) := MTTCA(1,j);
   MTTCA := MTTCA*MTTA_o;
  END;

% Transformation matrix;
MTTT_o := MTTObs^(-1)*MTTObs_o;


%Create the output file
OUT "$1_smo.r";

%Write out the matrices.

% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

MTT_Matrix := MTTD_o$ 
MTT_Matrix_name := "MTTD_o"$
MTT_Matrix_n := 1$
MTT_Matrix_m := 1$
Reduce_Matrix()$

write "%  -Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$


write "END;;";
SHUT "$1_smo.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r sm2smo_r.log

Deleted mttroot/mtt/bin/trans/sm2sr_m version [9750108aef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2sr_m

# Transforms descriptor matrix rep to step response


# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.16  1998/08/11 13:31:05  peterg
## Lowercase mttLAST etc
##
## Revision 1.15  1998/07/27 20:31:40  peterg
## New simpar version
##
## Revision 1.14  1998/07/25 10:00:48  peterg
## *** empty log message ***
##
## Revision 1.13  1997/06/13 12:52:18  peterg
## Removed extra ; from $PARAMS
##
# Revision 1.12  1996/09/12  18:45:31  peter
# Back to rcs.
#
# Revision 1.11  1996/08/24  14:02:39  peter
# Included glabal parameter passing.
# Proper error handling.
#
## Revision 1.10  1996/08/19 15:34:14  peter
## Now based on state - not descriptor matrices.
##
## Revision 1.9  1996/08/18 12:01:45  peter
## Unified format of time responses.
##
## Revision 1.8  1996/08/15 16:23:39  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.7  1996/08/15 11:54:32  peter
## Now has optional initial condition.
##
## Revision 1.6  1996/08/14 09:15:02  peter
## Now encapsulates the data into an m file
## Name changed
##
## Revision 1.5  1996/08/12 20:19:06  peter
## Fiddled about with parameter passing - still not right
##
## Revision 1.4  1996/08/11 19:48:04  peter
## Parameter passing added.
##
## Revision 1.3  1996/08/11 10:38:30  peter
## Minor debugging changes.
##
## Revision 1.2  1996/08/11 10:06:50  peter
## Now allows e format and NaN numbers.
##
## Revision 1.1  1996/08/11 09:45:46  peter
## Initial revision
##
###############################################################

echo Creating $1_sr.m
echo Creating $1_sro.m
rm -f sm2sr_m.log
rm -f $1_sr.m
rm -f $1_sro.m
rm -f mtt_error


# PARAMS="$PARAMS ;"

$MATRIX << EOF > sm2sr_m.log 2>mtt_error.txt

  % Read in the numeric system parameters
  mttpar = $1_numpar;

  % Read in the simulation parameters
  simpar = $1_simpar;

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.

  T=[0:simpar.dt:simpar.last]'

  if exist('u0')==0
    u0 = ones(nu,1);
  end;

  if exist('x0')==0
    x0 = zeros(nx,1);
  end;


  [n,m]=size(T);
  if m>n
    T=T';
  end;

  [A,B,C,D] = $1_sm(mttpar);
  [y,x] = sm2sr(A,B,C,D,T,u0,x0);

  if nx>0
    write_matrix([T x], '$1_sr');
  end;
  if ny>0
    write_matrix([T y], '$1_sro');
  end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt

Deleted mttroot/mtt/bin/trans/sm_r2m version [30c0587225].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm_r2m
# Reduce constained state-space A,B,C,D and E matrices to Matlab
# P.J.Gawthrop July 1990, Feb 1991, May 1991, Sep 91, Dec 93, Jan 94, May 94.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1998/06/23 19:18:33  peterg
## Added optional state argument.
##
# Revision 1.6  1997/02/24  14:43:21  peterg
# Now ignores parameters that are numerical.
#
## Revision 1.5  1996/09/12 18:34:44  peter
## Back under rcs.
##
# Revision 1.4  1996/08/24  14:12:26  peter
# Global parameter passing.
#
## Revision 1.3  1996/08/19 18:38:43  peter
## Read in the numerical params etc ...
##
## Revision 1.2  1996/08/19 16:25:18  peter
## Fixed bug when Nx=0.
##
## Revision 1.1  1996/08/19 15:14:51  peter
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_sm.m

# Remove the old log file
rm -f sm_r2m.log

#Header
lang_header $1 sm m '' '[mtta,mttb,mttc,mttd]' >$1_sm.m

# Use reduce to accomplish the transformation
$SYMBOLIC >sm_r2m.log << EOF

%Read in the definitions file
IN "$1_def.r";

%Read the reduce state-space A,B,C and D matrices file
IN "$1_sm.r";

%Read in the parameter file
IN "$1_sympar.r";

OUT "$1_sm.m1";

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "mtta = zeros(", MTTNx, ",", MTTNx, ");";
write "mttb = zeros(", MTTNx, ",", MTTNu, ");";
write "mttc = zeros(", MTTNy, ",", MTTNx, ");";
write "mttd = zeros(", MTTNy, ",", MTTNu, ");";

ON NERO;	% Suppress zero elements.
mtta := mtta;
mttb := mttb;
mttc := mttc;
mttd := mttd;

OFF FORT;
write "";

SHUT "$1_sm.m1";
EOF

cat $1_sm.m1 >> $1_sm.m
#rm -f $1_sm.m1

Deleted mttroot/mtt/bin/trans/sm_r2tex version [5fd0381795].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100




































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/27 16:01:35  peterg
## Initial revision
##
## Revision 1.4  1998/02/18 08:25:36  peterg
## Now uses latex_matrix for formatting
##
## Revision 1.3  1997/06/13 13:50:11  peterg
## Matrices in amstex format
##
# Revision 1.2  1997/04/18  12:54:00  peterg
# No longer does labels.
#
# Revision 1.1  1996/08/19  15:19:23  peter
# Initial revision
#
###############################################################


# Inform user
echo Creating $1_$2.tex

# Remove the old log file
rm -f sm_r2tex.log

# Use reduce to accomplish the transformation
reduce >sm_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the constrained-state matrices file
in "$1_$2.r";

%Read the symbolic parameters file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;

MATRIX MTT_Matrix(MTTNx,MTTNx);

OUT "$1_$2.tex";

%Write out the state matrices.
write "%state  matrices $1";
write "%File: $1_$2.tex";
write"";

MTT_Matrix := MTTA$ 
MTT_Matrix_name := "MTTA"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB$ 
MTT_Matrix_name := "MTTB"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC$ 
MTT_Matrix_name := "MTTC"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD $
MTT_Matrix_name := "MTTD"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

SHUT "$1_$2.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/smc2ssk_r version [06844ee033].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117





















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smc2ssk_r
# controller-form state matrices to controller gain k
# P.J.Gawthrop  Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/02/09 14:16:52  peterg
## Writes end statement to the o/p file
##
## Revision 1.2  1998/01/23 09:30:36  peterg
## Fixed a sign error - the coeficients of a(s) appear with - signs in
## the A_c matrix!
##
## Revision 1.1  1998/01/22 13:16:16  peterg
## Initial revision
##
###############################################################

Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi

# Inform user
echo Creating $1_ssk.r $blurb

# Remove the old log file
rm -f smc2ssk_r.log

# Use reduce to accomplish the transformation
reduce >smc2ssk_r.log << EOF

in "$1_def.r";
in "$1_smc.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;


%%%%  Controller design %%%%%

% gain in controller form:
matrix MTTk_c(1,MTTNx);

matrix alpha_c(9,1);
alpha_c(1,1) := alpha_c1;
alpha_c(2,1) := alpha_c2;
alpha_c(3,1) := alpha_c3;
alpha_c(4,1) := alpha_c4;
alpha_c(5,1) := alpha_c5;
alpha_c(6,1) := alpha_c6;
alpha_c(7,1) := alpha_c7;
alpha_c(8,1) := alpha_c8;
alpha_c(9,1) := alpha_c9;


for i := 1:MTTNx do
 MTTk_c(1,i) := alpha_c(i,1) + MTTA_c(1,i);

% Gain in physical form
MTTk := MTTk_c*MTTT_c;


%Create the output file
OUT "$1_ssk.r";

%Write out the matrices.

write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Reduce_Matrix()$

write "END;";

SHUT "$1_ssk.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r smc2ssk_r.log

Deleted mttroot/mtt/bin/trans/smc_r2tex version [0a9685fd8a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smc_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/08/24 11:43:42  peterg
## Include subs file
##
## Revision 1.1  1998/01/22 13:25:55  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_smc.tex

# Remove the old log file
rm -f smc_r2tex.log

# Use reduce to accomplish the transformation
$SYMBOLIC >smc_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the smconical-form matrices file
in "$1_smc.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_smc.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_smc.tex";
write"";


% Controllable form
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD_c$ 
MTT_Matrix_name := "MTTD_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


SHUT "$1_smc.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/smo2ssl_r version [a8920b8d83].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107











































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smo2ssl_r
# observer-form state matrices to Kobserver gain
# P.J.Gawthrop  Jan 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/23 09:31:03  peterg
## Initial revision
##
###############################################################

Nu=`mtt_getsize $1 u`
Ny=`mtt_getsize $1 y`

if [ "$Nu" = "1" ]; then
  if [ "$Ny" = "1" ]; then
    blurb=' for this siso system'    
  else
    blurb=" using first output of $Ny"
  fi
else
  if [ "$Ny" = "1" ]; then
    blurb=" using first input of $Nu"
  else
    blurb=" using first input of $Nu and using first output of $Ny"
  fi
fi


# Inform user
echo Creating $1_ssl.r $blurb

# Remove the old log file
rm -f smo2ssl_r.log

# Use reduce to accomplish the transformation
reduce >smo2ssl_r.log << EOF

in "$1_def.r";
in "$1_smo.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

OFF Echo;
OFF Nat;


%%%%  Observer design %%%%%
% gain in Observer form:
matrix MTTl_o(MTTNx,1);
matrix alpha_o(9,1);
alpha_o(1,1) := alpha_o1;
alpha_o(2,1) := alpha_o2;
alpha_o(3,1) := alpha_o3;
alpha_o(4,1) := alpha_o4;
alpha_o(5,1) := alpha_o5;
alpha_o(6,1) := alpha_o6;
alpha_o(7,1) := alpha_o7;
alpha_o(8,1) := alpha_o8;
alpha_o(9,1) := alpha_o9;

for i := 1:MTTNx DO
 MTTL_o(i,1) := alpha_o(i,1) + MTTA_o(i,1);

% Gain in physical form
MTTL := MTTT_o*MTTL_o;

%Create the output file
OUT "$1_ssl.r";

%Write out the matrices.


write "%  - Observer Gain matrix - observer form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$

write "END;";

SHUT "$1_ssl.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r smo2ssl_r.log

Deleted mttroot/mtt/bin/trans/smo_r2tex version [b9ffb95882].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smo_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/22 13:17:14  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_smo.tex

# Remove the old log file
rm -f smo_r2tex.log

# Use reduce to accomplish the transformation
reduce >smo_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the observer-form matrices file
in "$1_smo.r";


%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_smo.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_smo.tex";
write"";


% Observable form
MTT_Matrix := MTTA_o$ 
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_o$ 
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

MTT_Matrix := MTTC_o$ 
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD_o$ 
MTT_Matrix_name := "MTTD_o"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

write "%  - Observability matrix";
MTT_Matrix := MTTObs$ 
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$ 
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$ 
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


SHUT "$1_smo.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/sort_sympar version [7f751591a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sort_sympar
# Sorts the symbolic parameters in a nice way.
# P.J.Gawthrop March 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/03/07 15:15:53  peterg
## Initial revision
##
###############################################################


# Step 1: sort by variable name
# Step 2: put all varables with same name on same line


sort -k 1,1  | \
gawk '{
    var = $1; sys = $2;
    if (var==oldvar) {
      oldsys=sprintf("%s,%s",oldsys,sys)
    }
    else{
      if (length(oldvar)>0) print oldvar "\t" oldsys;
      oldvar=var; oldsys=sys
    }
}
END{
    print oldvar "\t" oldsys;
}' 

Deleted mttroot/mtt/bin/trans/ss_r2m version [dec8c0a922].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ss_r2m
# Reduce steady-state values to Fortran
# P.J.Gawthrop 10 July 1990, Dec 1993, Jan 1994, May 1994.
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1993, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

#Inform user
echo Creating $1_ss.m
# Remove the old log file
rm -f ss_r2m.log

# Usv reduce to accomplish the transformation
reduce >ss_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the reduce steady-state values file
in "$1_ss.r";

%Read in the parameter file
in "$1_sympar.r";

ON BigFloat, numval;
PRECISION 16; %Compatible with Matlab

OUT "$1_ss.m";
%Headings - Matlab style
%(Note. The ;; are deleted by for2mat)

IF MTTNvar>0 THEN
BEGIN
  write "function [MTTX0,MTTY0,MTTU0] = $1_ss(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
                  ELSE write MTTVar(i,1), ");;";
  END;
END
ELSE write "function [MTTX0,MTTY0,MTTU0] = $1_ss;;";


IF MTTNvar>0 THEN
BEGIN
  write "%function [MTTX0,MTTY0,MTTU0] = $1_ss(...";
  FOR i := 1:MTTNvar DO
  BEGIN
     IF i<MTTNvar THEN write "%", MTTVar(i,1), ",..."
                  ELSE write "%", MTTVar(i,1), ");;";
  END;
END
ELSE write "%function [MTTX0,MTTY0,MTTU0] = $1_ss;;";


write "%Steady-state values for system $1";
write "%File $1_ss.m";
write "%Generated by MTT";


ON NERO;	% Suppress zero elements.

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$

write "MTTX0 = zeros(", MTTNx, ",1)";
write "MTTy0 = zeros(", MTTNy, ",1)";
write "MTTu0 = zeros(", MTTNu, ",1)";


MTTX0 := MTTX0;
MTTY0 := MTTY0;
MTTU0 := MTTU0;

SHUT "$1_ss.m";

Deleted mttroot/mtt/bin/trans/ss_r2tex version [5d4b26acd7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ss_r2tex
# Reduce transfer-function matrices to LaTex transfer-function matrices.
# P.J.Gawthrop 9 June 1990, 8 July 1990, May 1994
# Copyright (c) P.J.Gawthrop, 1990, 1994.



# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  1998/02/24 09:21:36  peterg
# %% Put under rcs
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


#Unform user
echo Creating $1_ss.tex

# Remove the old log file
rm -f ss_r2tex.log

# Use reduce to accomplish the transformation
reduce >ss_r2tex.log << EOF


%Read the definitions file
in "$1_def.r";

%Read the parameter file
%%in "$1_sympar.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplifiy file
in "$1_simp.r";

%Read the CR file
in "$1_cr.r";

%Read the steady-state file
in "$1_ss.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
%ON Rounded;
%Precision 5;

OUT "$1_ss.tex";
write "%  - X0";
MTT_Matrix := MTTX$ 
MTT_Matrix_name := "MTTX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

write "%  - U";
MTT_Matrix := MTTU$ 
MTT_Matrix_name := "MTTU"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := 1$
LaTeX_Matrix()$


write "%  - Y";
MTT_Matrix := MTTY$ 
MTT_Matrix_name := "MTTY"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

write "%  - dX";
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

SHUT "$1_ss.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/ssk2ctf_r version [5b4425092f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh 
     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ssk2ctf_r
# Controller gain k and observer gain l to controller TF
# P.J.Gawthrop  Feb 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/02/09 14:04:00  peterg
## Renamed matrix to cTF;
##
## Revision 1.1  1998/02/09 13:54:34  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_ctf.r

# Remove the old log file
rm -f ssk2ctf_r.log

# Use reduce to accomplish the transformation
reduce >ssk2ctf_r.log << EOF

in "$1_def.r";
in "$1_ssk.r";
in "$1_ssl.r";
in "$1_sm.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";


OFF Echo;
OFF Nat;



%State matrices of the compensator
A_d := MTTA - MTTL*MTTC - MTTB*MTTK;
B_d := -MTTL;
C_d := -MTTK;
D_d := 0;

%Transfer function
MTTcTF := C_d*((s*MTTI - A_d)^(-1))*B_d;

%Create the output file
OUT "$1_ctf.r"; 
%Write out the matrices.

write "%  - Compensator TF";
MTT_Matrix := MTTcTF$
MTT_Matrix_name := "MTTcTF"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNy$
Reduce_Matrix()$


SHUT "$1_ctf.r";
quit;

EOF

# Now invoke the standard error handling.
mtt_error_r ssk2ctf_r.log

Deleted mttroot/mtt/bin/trans/ssk_r2tex version [ef5e08d779].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ssk_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/08/24 11:42:46  peterg
## Read subs file
##
## Revision 1.1  1998/01/22 13:16:30  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_ssk.tex

# Remove the old log file
rm -f ssk_r2tex.log

# Use reduce to accomplish the transformation
reduce >ssk_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the smconical-form matrices file
in "$1_ssk.r";


%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_ssk.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_ssk.tex";
write"";


write "%  - Gain matrix - controller form";
MTT_Matrix := MTTK_c$ 
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Latex_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTK$ 
MTT_Matrix_name := "MTTK"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
Latex_Matrix()$

SHUT "$1_ssk.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/ssl_r2tex version [81b2f09222].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ssl_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/01/22 13:16:30  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_ssl.tex

# Remove the old log file
rm -f ssl_r2tex.log

# Use reduce to accomplish the transformation
reduce >ssl_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the obsever gains file
in "$1_ssl.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_ssl.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_ssl.tex";
write"";


write "%  - Gain matrix - controller form";
MTT_Matrix := MTTL_o$ 
MTT_Matrix_name := "MTTL_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Latex_Matrix()$

write "%  - Gain matrix - physical form";
MTT_Matrix := MTTL$ 
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Latex_Matrix()$

SHUT "$1_ssl.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/sspar2ss_r version [a39bc5aea4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sspar2ss_r
# Reduce steady steady-state parameter file to reduce steady-state:
#	X0, and Y0 and U0;
# P.J.Gawthrop 10 July 1990, 22 April 1991, Dec 1993, April 1994
# Copyright (c) P.J.Gawthrop, 1990, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/11/18 11:42:55  peterg
## Added "IF MTTNx>0 THEN" to avoid error message when no states
##
## Revision 1.2  1998/07/22 15:47:28  peterg
## Now operates on ordinary differential equation file.
##
## Revision 1.1  1996/08/25 09:52:20  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_ss.r

# Remove the old log file
rm -f sspar2ss_r.log

# Use reduce to accomplish the transformation
$SYMBOLIC >sspar2ss_r.log << EOF

%Read the definition file
in "$1_def.r";

%Read the constitutive relationships (May be used in rss file). 
%in "$1_cr.r";

%Read the steady-state values 
in "$1_sspar.r";

%Read in the constrained-state equation
%in "$1_cse.r";

%Read in the ode
in "$1_ode.r";

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

OFF Echo;
OFF Nat;
OUT "$1_ss.r";

IF MTTNx>0 THEN
  MTTdx:= MTTdx;

%Write out the steady-state values (if any)
write "%Steady-state values";


% State
MTT_Matrix := MTTX$ 
MTT_Matrix_name := "MTTx"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% State derivative
MTT_Matrix := MTTdX$ 
MTT_Matrix_name := "MTTdX"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Nonstate
MTT_Matrix := MTTZ$ 
MTT_Matrix_name := "MTTZ"$
MTT_Matrix_n := MTTNz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Output
MTT_Matrix := MTTy$ 
MTT_Matrix_name := "MTTy"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Zero outputs
MTT_Matrix := MTTYz$ 
MTT_Matrix_name := "MTTYz"$
MTT_Matrix_n := MTTNyz$
MTT_Matrix_m := 1$
Reduce_Matrix()$

% Input
MTT_Matrix := MTTu$ 
MTT_Matrix_name := "MTTu"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := 1$
Reduce_Matrix()$


%Write them out by component - but only if values have been set
%(This assumes that if element 1 not set then the rest aren't either)
%ON Rounded; %Make numbers have dec. points-- nice for c
%
%clear MTTx1;
%IF MTTNx>0 THEN
%IF MTTX0(1,1) NEQ MTTX1 THEN
%FOR i := 1:MTTNx DO
%BEGIN
%  write "MTTx", i, " := ", MTTX0(i,1);
%END;
%
%clear MTTu1;
%IF MTTNu>0 THEN
%IF MTTu0(1,1) NEQ MTTu1 THEN
%FOR i := 1:MTTNu DO
%BEGIN
%  write "MTTu", i, " := ", MTTu0(i,1);
%END;
%
%%Derivatives are zero in the steady-state
%IF MTTNz>0 THEN
%FOR i := 1:MTTNz DO
%BEGIN
%  write "MTTdz", i, " := 0";
%END;

write "END;";

SHUT "$1_ss.r";
quit;
EOF

# Now invoke the standard error handling.
mtt_error_r sspar2ss_r.log

Deleted mttroot/mtt/bin/trans/strip_comments version [429b584b4b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################


# Bourne shell script: strip_comments
# Strips comments from mtt text files
# P.J.Gawthrop July 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/11/18 11:30:19  peterg
## Now strips blank lines as well
##
###############################################################


sed 's/%/#/' |\
gawk --field-separator '#' '{if (length($1)>0) print $1}'  |\
gawk '{if (NF>0) print $0}'

Deleted mttroot/mtt/bin/trans/strip_notvars.sh version [898b1963cb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

type=$1
name=$2
file=$3

notvar="[%|#]NOT[V|P]AR"
grep ${notvar} ${type}_lbl.txt |\
    gawk '{ printf ("%s\t%s\n", $2, name) }' name=${name} \
    >> ${file}
 
grep -i pi ${type}_lbl.txt |\
    gawk '{ printf ("pi\t%s\n", name) }' name=${name} \
    >> ${file}

Deleted mttroot/mtt/bin/trans/strip_pars.sh version [7d64e8b718].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#! /bin/sh
infile=$1
name=$2



var="[%|#][V|P]AR"
grep ${var} ${infile} |\
    gawk '{ printf ("%s\t%s\n", $2, name) }' name=${name} \
 

Deleted mttroot/mtt/bin/trans/struc2gnuplot_txt2wish version [1d1598cc62].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585









































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# -*-tcl-*-

sys=$1

out=${sys}_gnuplot.wish

struc=${sys}_struc.txt
dat2=${sys}_odes.dat2

Nx=`mtt_getsize ${sys} x`
Ny=`mtt_getsize ${sys} y`

## write header
cat <<EOF > ${out}
#!/bin/sh
# -*-tcl-*- Next line replaces shell with wish\\
exec wish "\$0" "\$@"

## main window
wm title . "MTT: ${sys}"

# menu bar
canvas .menubar

menubutton .menubar.file -text "File" -underline 0 -menu .menubar.file.menu
menu .menubar.file.menu
.menubar.file.menu add command -label "Open    (Gnuplot template)" -underline 0   -command open_plotfile
.menubar.file.menu add command -label "Save    (Gnuplot template)" -underline 0   -command save_plotfile
.menubar.file.menu add separator
.menubar.file.menu add command -label "Print     (PostScript)"   -underline 0   -command print_postscript
.menubar.file.menu add separator
.menubar.file.menu add command -label "Quit"			  -underline 0   -command exit

menubutton .menubar.edit -text "Edit" -underline 0 -menu .menubar.edit.menu
menu .menubar.edit.menu
.menubar.edit.menu add cascade -label "Axes"         -underline 0 -menu .menubar.edit.menu.axes
.menubar.edit.menu add cascade -label "Contour (3D)" -underline 0 -menu .menubar.edit.menu.contour
.menubar.edit.menu add cascade -label "Data style"   -underline 0 -menu .menubar.edit.menu.datastyle
.menubar.edit.menu add cascade -label "Grid"         -underline 0 -menu .menubar.edit.menu.grid
.menubar.edit.menu add cascade -label "Key"          -underline 0 -menu .menubar.edit.menu.key
.menubar.edit.menu add cascade -label "Timestamp"    -underline 0 -menu .menubar.edit.menu.time

menu .menubar.edit.menu.axes
.menubar.edit.menu.axes add command -label "Cartesian" -underline 0 -command { do_cmd "set nopolar ; replot" }
.menubar.edit.menu.axes add command -label "Polar"     -underline 0 -command { do_cmd "set   polar ; replot" }
.menubar.edit.menu.axes add cascade -label "Ranges"    -underline 0 -menu .menubar.edit.menu.axes.range

menu .menubar.edit.menu.axes.range
.menubar.edit.menu.axes.range add command -label "Set X"   -underline 4 -command { do_cmd "set xrange \[[get_value "X axis range? min:max" "*:*"]\] ; replot" }
.menubar.edit.menu.axes.range add command -label "Set Y"   -underline 4 -command { do_cmd "set yrange \[[get_value "Y axis range? min:max" "*:*"]\] ; replot" }
.menubar.edit.menu.axes.range add command -label "Set Z"   -underline 4 -command { do_cmd "set zrange \[[get_value "Z axis range? min:max" "*:*"]\] ; replot" }

menu .menubar.edit.menu.contour
.menubar.edit.menu.contour add command -label "Show Contour" -underline 0 -command { do_cmd "set   dgrid3d ; set   contour ; replot" }
.menubar.edit.menu.contour add command -label "Hide Contour" -underline 0 -command { do_cmd "set nodgrid3d ; set nocontour ; replot" }
.menubar.edit.menu.contour add cascade -label "Surface"      -underline 0 -menu .menubar.edit.menu.contour.surface

menu .menubar.edit.menu.contour.surface
.menubar.edit.menu.contour.surface add command -label "Show Surface" -underline 0 -command { do_cmd "set   surface ; replot" }
.menubar.edit.menu.contour.surface add command -label "Hide Surface" -underline 0 -command { do_cmd "set nosurface ; replot" }

menu .menubar.edit.menu.datastyle
.menubar.edit.menu.datastyle add command -label "Dots"    -underline 0 -command { do_cmd "set data style dots   ; replot" }
.menubar.edit.menu.datastyle add command -label "Lines"   -underline 0 -command { do_cmd "set data style lines  ; replot" }
.menubar.edit.menu.datastyle add command -label "Points"  -underline 0 -command { do_cmd "set data style points ; replot" }

menu .menubar.edit.menu.grid
.menubar.edit.menu.grid add cascade -label "Show Grid" -underline 0 -menu .menubar.edit.menu.grid.show
.menubar.edit.menu.grid add cascade -label "Hide Grid" -underline 0 -menu .menubar.edit.menu.grid.hide

menu .menubar.edit.menu.grid.show
.menubar.edit.menu.grid.show add command -label "Show all ticks" -underline 5 -command { do_cmd "set grid xtics ytics ztics ; replot" }
.menubar.edit.menu.grid.show add command -label "Show X ticks" -underline 5 -command { do_cmd "set grid xtics ; replot" }
.menubar.edit.menu.grid.show add command -label "Show Y ticks" -underline 5 -command { do_cmd "set grid ytics ; replot" }
.menubar.edit.menu.grid.show add command -label "Show Z ticks" -underline 5 -command { do_cmd "set grid ztics ; replot" }

menu .menubar.edit.menu.grid.hide
.menubar.edit.menu.grid.hide add command -label "Hide all ticks" -underline 5 -command { do_cmd "set grid noxtics noytics noztics ; replot" }
.menubar.edit.menu.grid.hide add command -label "Hide X ticks" -underline 5 -command { do_cmd "set grid noxtics ; replot" }
.menubar.edit.menu.grid.hide add command -label "Hode Y ticks" -underline 5 -command { do_cmd "set grid noytics ; replot" }
.menubar.edit.menu.grid.hide add command -label "Hide Z ticks" -underline 5 -command { do_cmd "set grid noztics ; replot" }

menu .menubar.edit.menu.key
.menubar.edit.menu.key add command -label "Show Key"   -underline 0 -command { do_cmd "set   key ; replot" }
.menubar.edit.menu.key add command -label "Hide Key"   -underline 0 -command { do_cmd "set nokey ; replot" }
.menubar.edit.menu.key add cascade -label "Position"   -underline 0 -menu .menubar.edit.menu.key.posn

menu .menubar.edit.menu.key.posn
.menubar.edit.menu.key.posn add command -label "Left"    -underline 0 -command { do_cmd "set key left    ; replot" }
.menubar.edit.menu.key.posn add command -label "Right"   -underline 0 -command { do_cmd "set key right   ; replot" }
.menubar.edit.menu.key.posn add command -label "Top"     -underline 0 -command { do_cmd "set key top     ; replot" }
.menubar.edit.menu.key.posn add command -label "Bottom"  -underline 0 -command { do_cmd "set key bottom  ; replot" }
.menubar.edit.menu.key.posn add command -label "Outside" -underline 0 -command { do_cmd "set key outside ; replot" }
.menubar.edit.menu.key.posn add command -label "Below"   -underline 3 -command { do_cmd "set key below   ; replot" }

menu .menubar.edit.menu.time
.menubar.edit.menu.time add command -label "Show Timestamp"   -underline 0 -command { do_cmd "set   timestamp ; replot" }
.menubar.edit.menu.time add command -label "Hide Timestamp"   -underline 0 -command { do_cmd "set notimestamp ; replot" }

menubutton .menubar.tool -text "Tools" -underline 0 -menu .menubar.tool.menu
menu .menubar.tool.menu
.menubar.tool.menu add cascade -label "gnuplot command" -underline 0 -menu .menubar.tool.menu.gcmd
.menubar.tool.menu add cascade -label "Sort List" -underline 0 -menu .menubar.tool.menu.sort
.menubar.tool.menu add command -label "X-MTT"     -underline 0 -command { exec xmtt & }

menu .menubar.tool.menu.gcmd
.menubar.tool.menu.gcmd add command -label "Show Command" -underline 0 -command show_gnuplot_prompt
.menubar.tool.menu.gcmd add command -label "Hide Command" -underline 0 -command hide_gnuplot_prompt

menu .menubar.tool.menu.sort
.menubar.tool.menu.sort add command -label "Left to Right" -underline 0 -command {
    set sortorder "normal"
    set xl [sort_list \$xl \$sortorder ]
    set yl [sort_list \$yl \$sortorder ]
}
.menubar.tool.menu.sort add command -label "Right to Left" -underline 0 -command {
    set sortorder "reverse"
    set xl [sort_list \$xl \$sortorder]
    set yl [sort_list \$yl \$sortorder]
}

button .menubar.quit  -text "Quit" -relief flat -command exit 

pack .menubar.file    -expand false -fill x -side left
pack .menubar.edit    -expand false -fill x -side left
pack .menubar.tool    -expand false -fill x -side left
pack .menubar.quit    -expand false -fill x -side right

# list bar
canvas .listbar

radiobutton .listbar.states  -text "States"   -value states  -variable view -command { .parameters.list configure -listvar xl }
radiobutton .listbar.outputs -text "Outputs"  -value outputs -variable view -command { .parameters.list configure -listvar yl }

checkbutton .listbar.sort -text "Toggle Sort" -relief flat -indicatoron false -onvalue "reverse" -offvalue "normal" -variable sortorder -command {    
    set xl [sort_list \$xl \$sortorder ]
    set yl [sort_list \$yl \$sortorder ]
}

pack .listbar.states  -expand false -fill x -side left
pack .listbar.outputs -expand false -fill x -side left
pack .listbar.sort    -expand false -fill x -side right

# side bar
canvas .plotbar

tk_optionMenu .plotbar.select select  "Select X" "Select Y" "Select Z"

tk_optionMenu .plotbar.dim   dimension "2D" "3D"

tk_optionMenu .plotbar.plot  plottype "Single" "Multi"

pack .plotbar.dim     -expand true -fill x -side right
pack .plotbar.plot    -expand true -fill x -side right
pack .plotbar.select  -expand true -fill x -side right

# button bar
canvas .buttonbar

button .buttonbar.replot -text "Refresh"   -relief raised -command { do_cmd "replot" }

button .buttonbar.newwin -text "New Plot"  -relief raised -command {
    set windownum [expr 1 + \$windownum]
    do_cmd "set term x11 \$windownum"
}

pack .buttonbar.newwin  -expand true -side right -fill x
pack .buttonbar.replot  -expand true -side right -fill x

# rotation bar
canvas .rotationbar
scale .rotationbar.xrot  -label "Rotate X" -orient h -from "0" -to "180" -command { do_rotate_3d "xrot" }
scale .rotationbar.zrot  -label "Rotate Z" -orient h -from "0" -to "360" -command { do_rotate_3d "zrot" }
pack .rotationbar.xrot  -side left -fill x -expand true
pack .rotationbar.zrot  -side left -fill x -expand true
.rotationbar.xrot set 30
.rotationbar.zrot set 60


proc "enable_rotationbar" "" {
}
proc "disable_rotationbar" "" {
}

## parameter list canvas
canvas		.parameters
listbox		.parameters.list -background oldlace -foreground black
scrollbar	.parameters.yscrollbar	-orient v

## configure scrollbars
.parameters.yscrollbar configure -command ".parameters.list yview"
.parameters.list configure -yscrollcommand ".parameters.yscrollbar set"

## bind lists
bind .parameters.list <<ListboxSelect>> {
    set parameter [ .parameters.list get anchor ]
    plot \$parameter
    set select "Select Y"
}

proc "reverse_name" "name" {
    set delim "_"
    set split_name [split \$name \$delim]
    set reversed_name [lindex \$split_name 0]
    for {set i 1} {\$i<[llength \$split_name]} {incr i} {
        set reversed_name [lindex \$split_name \$i]\$delim\$reversed_name
    }
    return \$reversed_name
}

proc "reverse_sort" "list" {
    set temp_list {}
    set delim " "
    foreach name [split \$list \$delim] {
	set temp_list \$temp_list\$delim[reverse_name \$name]
    }
    set temp_list [lsort -ascii \$temp_list]
    set list {}
    foreach name [split \$temp_list \$delim] {
	set list \$list\$delim[reverse_name \$name]
    }
    return \$list
}

proc "sort_list" "list sortorder" {
    switch -- \$sortorder {
	normal	{ return [lsort -ascii \$list] }
	reverse { return [reverse_sort \$list] }
    }
}

EOF

## create states and outputs lists
gawk '
($1 == "state") {
    name=sys"__";
    label=$4;
    sub (name, "", label);
    printf "lappend xl %s\n", label
}
($1 == "output") {
    name=sys"__";
    label=$4;
    sub (name, "", label);
    printf "lappend yl %s\n", label
}' sys=${sys} ${struc} >> ${out}

cat <<EOF >> ${out}
lappend xl Time
lappend yl Time
.parameters.list configure -listvar yl

pack .menubar			-expand false -fill x    -side top
pack .listbar			-expand false -fill x    -side top
pack .rotationbar		-expand false -fill x    -side bottom
pack .plotbar			-expand false -fill x    -side bottom
pack .buttonbar			-expand false -fill x    -side bottom
pack .parameters.yscrollbar	-expand false -fill y    -side right
pack .parameters.list		-expand true  -fill both -side left
pack .parameters		-expand true  -fill both

## map names to column numbers
proc "get_state_column" "title" {
    switch -- \$title {
EOF

	gawk '($1 == "state") {
	    name=sys"__";
	    label=$4;
	    sub (name, "", label);
	    printf "\t\t%s\t{ return %d }\n", label, $2+2+Ny;
	}
	' Ny=${Ny} sys=${sys} ${struc} >> ${out}
	
cat <<EOF >> ${out}
    }
}
    
proc "get_output_column" "title" {
    switch -- \$title {
EOF

	gawk '($1 == "output") {
	    name=sys"__";
	    label=$4;
	    sub (name, "", label);
	    printf "\t\t%s\t{ return %d }\n", label, $2+1;
	}    
	' Ny=${Ny} sys=${sys} ${struc} >> ${out}

cat <<EOF >> ${out}
    }
}

proc "plot" "title" {
    global dimension
    global select
    global view
    global xcolumn
    global ycolumn
    global zcolumn
    global xtitle
    global ytitle
    global ztitle
    if {"\$title" == "Time"} {
	set column 1
    } else {
	switch -- \$view {
	    states	{ set column [get_state_column  \$title] }
	    outputs	{ set column [get_output_column \$title] }
	}
    } 
    switch -- \$select {
	"Select X" {
	    set xcolumn \$column
	    set xtitle  \$title
	}
	"Select Y" {
	    set ycolumn \$column
	    set ytitle  \$title
	}
	"Select Z" {
	    set zcolumn \$column
	    set ztitle  \$title
	    set dimension "3D"
	}
    }
    plot_var
}

## call gnuplot
proc "plot_var" "" {
    global xcolumn
    global ycolumn
    global zcolumn
    global xtitle
    global ytitle
    global ztitle
    global dimension
    global plottype
    global lastplot
    switch -- \$dimension {
	2D	{
	    disable_rotationbar
	    switch -- \$plottype {
		Single	{
		    do_cmd "set xlabel '\$xtitle'"
		    do_cmd "set ylabel '\$ytitle'"
		    do_cmd "set nokey"
		    do_cmd "plot '${dat2}' using \$xcolumn:\$ycolumn title 'y:\$ytitle  x:\$xtitle' "
		}
		Multi	{
		    do_cmd "set xlabel ''"
		    do_cmd "set ylabel ''"
		    do_cmd "set key"
		    if {"\$lastplot" != "2D"} {
			do_cmd "plot '${dat2}' using \$xcolumn:\$ycolumn title 'y:\$ytitle  x:\$xtitle' "
		    } else {
			do_cmd "replot '${dat2}' using \$xcolumn:\$ycolumn title 'y:\$ytitle  x:\$xtitle' "	    
		    }
		}
	    }
	}
	3D	{
	    enable_rotationbar
	    switch -- \$plottype {
		Single	{
		    do_cmd "set xlabel '\$xtitle'"
		    do_cmd "set ylabel '\$ytitle'"
		    do_cmd "set zlabel '\$ztitle'"
		    do_cmd "set nokey"
		    do_cmd "splot '${dat2}' using \$xcolumn:\$ycolumn:\$zcolumn title 'z:\$ztitle  y:\$ytitle  x:\$xtitle' "
		}
		Multi	{
		    do_cmd "set xlabel ''"
		    do_cmd "set ylabel ''"
		    do_cmd "set zlabel ''"
		    do_cmd "set key"
		    if {"\$lastplot" != "3D"} {
			do_cmd "splot '${dat2}' using \$xcolumn:\$ycolumn:\$zcolumn title 'z:\$ztitle  y:\$ytitle  x:\$xtitle' "
		    } else {
			do_cmd "replot '${dat2}' using \$xcolumn:\$ycolumn:\$zcolumn title 'z:\$ztitle  y:\$ytitle  x:\$xtitle' "
		    }
		}
	    }
	}
    }
    set lastplot \$dimension
}
## open gnuplot plot file
proc "open_plotfile" "" {
    global parameter
    if {"\$parameter"==""} {
	set name "${sys}.plt"
    } else {
	set name "\$parameter.plt"
    }
    set filename [tk_getOpenFile\
	-initialdir ".."\
	-initialfile "\$name"\
	-defaultextension ".plt"\
	-filetypes {
	    {{Gnuplot} {.plt}}
	    {{All files} {*}}
	}
    ]
    do_cmd "load '\$filename'"
}

## save gnuplot plot file
proc "save_plotfile" "" {
    global parameter
    if {"\$parameter"==""} {
	set name "${sys}.plt"
    } else {
	set name "\$parameter.plt"
    }
    set filename [tk_getSaveFile\
	-initialdir ".."\
	-initialfile "\$name"\
	-defaultextension ".plt"\
	-filetypes {
	    {{Gnuplot} {.plt}}
	    {{All files} {*}}
	}
    ]
    do_cmd "save '\$filename'"
}

## print output to postscript
proc "print_postscript" "" {
    global parameter
    global windownum
    set filename [tk_getSaveFile\
		      -initialdir ".."\
		      -initialfile "\$parameter.ps"\
		      -defaultextension ".ps"\
		      -filetypes {
			  {{Postscript} {.ps}}
			  {{All files} {*}}
		      }
		 ]
    if {\$filename != ""} {
	do_cmd "set term postscript"
	do_cmd "set output '\$filename'"
	do_cmd "replot"
	do_cmd "set term x11 \$windownum"
	tk_dialog ".printed" "Graph Printed!" "PostScript saved as \$filename" "" "0" "Close"
    }
}

proc "get_value" "string initial" {
    frame .f
    frame .f.buttons
    global get_value_retval
    global get_value_status
    set get_value_retval ""
    set get_value_status ""

    button	.f.buttons.ok		-text "ok"	-command {
	set get_value_status "ok"
	set get_value_retval [.f.entry get ]
	destroy .f
    }
    button	.f.buttons.cancel	-text "Cancel"	-command {
	set get_value_status "cancel"
	destroy .f
    }
    entry	.f.entry
    label	.f.label	-text "\$string"

    .f.entry insert 0 "\$initial"
    bind .f.entry <<Return>> {
	set get_value_status "ok"
	set get_value_retval [.f.entry get ]
	destroy .f
    }

    pack .f.buttons.ok		-side left   -expand false
    pack .f.buttons.cancel	-side left   -expand false
    pack .f.label		-side top    -expand false
    pack .f.entry		-side top    -expand false
    pack .f.buttons		-side top    -expand false
    place .f -in .parameters -relx 0 -rely 0 -relwidth 1 -relheight 1 -anchor nw -bordermode outside
    tkwait variable get_value_retval
    if {"\$get_value_status" == "ok"} {
	return "\$get_value_retval"
    } else {
	return ""
    }
}

proc "get_scale" "string min max" {
    frame .f
    frame .f.buttons
    global get_scale_retval
    global get_scale_status
    set get_scale_retval ""
    set get_scale_status ""

    button	.f.buttons.ok		-text "ok"	-command {
	set get_scale_status "ok"
	set get_scale_retval [.f.scale get ]
	destroy .f
    }
    button	.f.buttons.cancel	-text "Cancel"	-command {
	set get_scale_status "cancel"
	destroy .f
    }
    scale	.f.scale	-orient h	-label "\$string"	-from "\$min"	-to "\$max"

    pack .f.buttons.ok		-side left   -expand false
    pack .f.buttons.cancel	-side left   -expand false
    pack .f.scale		-side top    -expand false
    pack .f.buttons		-side top    -expand false
    place .f -in .parameters -relx 0 -rely 0 -relwidth 1 -relheight 1 -anchor nw -bordermode outside
    tkwait variable get_value_retval
    if {"\$get_scale_status" == "ok"} {
	return "\$get_scale_retval"
    } else {
	return ""
    }
}

proc "do_rotate_3d" "var val" {
    switch -- \$var {
	xrot	{
	    do_cmd "set view \$val,,, ; replot"
	}
	zrot	{
	    do_cmd "set view ,\$val,, ; replot"
	}
    }
}

proc "show_gnuplot_prompt" "" {
    global gnuplot_command
    destroy .gcmd
    canvas .gcmd
    label .gcmd.l -text ">"
    entry .gcmd.e -textvariable gnuplot_command
    button .gcmd.b -text "<-" -relief flat -command { set gnuplot_command "" }
    pack .gcmd.b -side right
    pack .gcmd.l -side left
    pack .gcmd.e -side top    -fill x -expand true
    pack .gcmd -expand false -fill x -side bottom -before .rotationbar
    focus .gcmd.e
    bind .gcmd.e <<Return>> {
	do_cmd "[.gcmd.e get]"
    }
}
proc "hide_gnuplot_prompt" "" {
    destroy .gcmd
}

proc "do_cmd" "string" {
    global gnuplot_command
    set gnuplot_command "\$string"
    puts "\$string"
}

event add <<Return>> <Return>
    
# Defaults
set parameter ""
set windownum 0
set view outputs
set lastplot ""
set select "Select Y"
set xcolumn 1 ; set xtitle "Time"
set ycolumn 1 ; set ytitle "Time"
set zcolumn 1 ; set ztitle "Time"

do_cmd "set mouse"
do_cmd "set timestamp"
do_cmd "set grid"
do_cmd "set nopolar"
do_cmd "set term X11 0"
do_cmd "set key"
do_cmd "set data style lines"

EOF
chmod +x ${out}

Deleted mttroot/mtt/bin/trans/struc2input_txt2txt version [016a2f4250].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130


































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2input_txt2txt
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15  2000/12/28 12:44:31  peterg
## *** empty log message ***
##
## Revision 1.14  2000/10/16 08:28:56  peterg
## Tidied up:
## SS broken due to incorrect ss.r file
## Switches??
##
## Revision 1.13  2000/03/03 11:33:19  peterg
## *** empty log message ***
##
## Revision 1.12  1998/08/10 14:29:05  peterg
## Removed -s (switches) stuff
##
## Revision 1.11  1998/08/10 14:23:58  peterg
## Added -ss option
##
## Revision 1.10  1998/07/27 11:10:38  peterg
## Put in octave-mode line for Emacs
##
## Revision 1.9  1998/07/25 20:10:37  peterg
## lower case mttu
##
## Revision 1.8  1998/07/25 09:42:09  peterg
## Just sets finrst input to 1 - rest to zero
##
## Revision 1.7  1998/07/25 08:05:41  peterg
## Reverted to original default - not using SS mechanism
##
## Revision 1.6  1998/02/24 10:14:56  peterg
## Now defaults to the steady-state values
##
## Revision 1.5  1998/02/04 12:26:47  peterg
## Simplified output format
##
## Revision 1.4  1998/02/04 11:45:05  peterg
## Less verbose comments.
##
## Revision 1.3  1998/01/29 17:06:21  peterg
## Better annotation of each input
##
## Revision 1.2  1997/05/15 09:44:12  peterg
## Put switches into the input file.
##
# Revision 1.1  1997/05/03  14:55:17  peterg
# Initial revision
#
###############################################################

#Look for a command line argument
# By default, don't look for BG switches

while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-ss )
		steadystate_computation=yes ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Default input
default='1.0'

#Create the input file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_input.txt
echo "# Input specification ($1_input.txt)" >> $1_input.txt
echo "# Generated by MTT at `date`" >> $1_input.txt
cat $MTTPATH/trans/rcs_header.sh  >> $1_input.txt
echo "# Set the inputs"  >> $1_input.txt

if [ -n "$steadystate_computation" ]; then 
# Compute inputs from ss.r file
# Inform user
echo Creating $1_input.txt - compute from steady-state information

cat $1_ss.r  $1_struc.txt | sed 's/\$//' |\
gawk '{
  if(match($1,"MTTu")>0) {
    j++
    split($0,a,"=");
    u[j]=a[2];
  }
    
  if($1=="input") {
    i++; 
    if (length(u[i])==0) u[i]="0.0;";
    # print  "u(" i ") =\t", u[i], " \# " $4 " (" $3 ")"
    printf("%s =\t%s # MTT initial value from steady state\n", $4, u[i]);
  }
}'  >> $1_input.txt
else
#Write out the defaults -- unit inputs
echo Creating $1_input.txt - using defaults

gawk '{
  if ($1=="input") {
      if ($2==1)
        printf("%s = \t%s; # MTT initial value\n", $4, default)
      else
        printf("%s = \t%s; # MTT initial value\n", $4, "0.0")
  }
}' Nu=$Nu  default=$default <$1_struc.txt >> $1_input.txt
fi

#Set some switches
#  echo  >> $1_input.txt
#  echo "# Set the switches"  >> $1_input.txt
#  strip_comments<$1_switch.txt |\
#  gawk '{if (length($1)>0) print  tolower($1) "= (t>=0);"}'  >> $1_input.txt



Deleted mttroot/mtt/bin/trans/struc2sspar_txt2r version [81e9931607].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2sspar_txt2txt
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1998


# Inform user
echo Creating $1_sspar.r


#Write out the default ss values (0)
#Create the sspar file complete with headers.
echo "% Steady-state parameter file ($1_sspar.r)" > $1_sspar.r
echo "% Generated by MTT at `date`" >> $1_sspar.r
cat $MTTPATH/trans/rcs_header.m  >> $1_sspar.r

echo  >> $1_sspar.r

echo "% Steady-state states" >> $1_sspar.r
gawk '{
  if ($1=="state") 
    print "MTTX" $2 " := \t0; % " $4 " (" $3 ")"
}' \
 $1_struc.txt >> $1_sspar.r


echo "% Steady-state inputs" >> $1_sspar.r
gawk '{
  if ($1=="input") 
    print "MTTU" $2 " := \t0; % " $4 " (" $3 ")"
}' \
 $1_struc.txt >> $1_sspar.r


echo ";;END;" >> $1_sspar.r


Deleted mttroot/mtt/bin/trans/struc2state_txt2txt version [5418171295].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104








































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2state_txt2txt
# Creates the default state file for the system (txt)

# Copyright (c) P.J.Gawthrop 1998


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.10  2000/10/16 08:20:23  peterg
# %% New version with direct naming.
# %% Note ss version is broken - ss.r file in wrong format
# %%
# %% Revision 1.9  2000/10/10 21:03:06  peterg
# %% *** empty log message ***
# %%
# %% Revision 1.8  1998/08/10 13:57:33  peterg
# %% Removed debugging lines
# %%
# %% Revision 1.7  1998/08/10 13:55:11  peterg
# %% Added option of computing from ss values
# %%
# %% Revision 1.6  1998/07/27 20:32:11  peterg
# %% Octave mode forced
# %%
# %% Revision 1.5  1998/07/25 20:10:01  peterg
# %% Lower case mttx
# %%
# %% Revision 1.4  1998/07/25 09:42:37  peterg
# %% Now writes out an array
# %%
# %% Revision 1.3  1998/07/25 08:11:35  peterg
# %% No longer used the SS method - just sets zero states
# %%
# %% Revision 1.2  1998/07/21 16:54:15  peterg
# %% Changed erroneous header
# %%
# %% Revision 1.1  1998/06/27 15:06:40  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-ss )
		steadystate_computation=yes ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Default state
default='0.0'

#Create the state file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_state.txt
echo "# Initial state  file ($1_state.txt)" >> $1_state.txt
echo "# Generated by MTT at `date`" >> $1_state.txt
cat $MTTPATH/trans/rcs_header.sh  >> $1_state.txt

#Write out the defaults -- states to steady-state values
echo "# Set the states"  >> $1_state.txt

if [ -n "$steadystate_computation" ]; then 
# Compute state from ss.r file
# Inform user
echo Creating $1_state.txt - compute from steady-state information

cat $1_ss.r  $1_struc.txt | sed 's/\$//' |\
gawk '{
  if(match($1,"MTTx")>0) {
    j++
    split($0,a,"=");
    x[j]=a[2];
  }
    
  if($1=="state") {
    i++; 
    # print  "x(" i ") =\t", x[i], " \# " $4 " (" $3 ")"
    printf("%s =\t%s; # MTT initial value\n", $4, x[i]);
  }
}'  >> $1_state.txt
else
# Set states to zero
# Inform user
echo Creating $1_state.txt - default states to $default

gawk '{
  if ($1=="state") printf("%s \t= %s; # MTT initial value\n", $4, default)
}' default=$default <$1_struc.txt >> $1_state.txt
    
fi


Deleted mttroot/mtt/bin/trans/struc2switch_txt version [05163357ae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc2switch_txt

# Structure file - generate a file for switching on states
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2001/08/02 03:01:08  geraint
## Stopped initialisation of mttopen from over-writing logic.txt contents.
##  - comment removed from "sort" input (which put it last) because
## initialisation is inserted in place of the comment by switch_txt2m.
##
## Revision 1.5  2000/10/17 09:20:00  peterg
## *** empty log message ***
##
## Revision 1.4  1998/07/26 10:28:30  peterg
## Added a header line to avoid empty file and to trigger
## switch_txt2m to write initial stuff.
##
## Revision 1.3  1998/07/25 18:50:53  peterg
## Lower case names
##
## Revision 1.2  1997/06/03 15:17:09  peterg
## Changed label to MTT_SWITCH
##
# Revision 1.1  1997/05/13  16:58:59  peterg
# Initial revision
#
###############################################################




echo Creating  $1_switch.txt

rm -f $1_switch.txt
echo "# These are the switches deduced from ISW and CSW components"\
 > $1_switch.txt

# This is the main transformation using awk
gawk '{ 
   if ($1=="state") {i++; if ($3=="MTT_SWITCH")  print tolower($4) "\t" i};
}
END{
}
' < $1_struc.txt| sort >> $1_switch.txt

strip_comments < $1_switch.txt | wc -l | gawk '{print $1 " switches found"}'








Deleted mttroot/mtt/bin/trans/struc_txt2m version [a49d581f14].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2m

# Structure file - txt to m conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.3  2001/10/15 14:20:27  gawthrop
## Now handles the cases where ny or nx or nu are zero
##
## Revision 1.2  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.1.2.1  2001/03/06 03:52:15  geraint
## Put back struc_txt2m - required by mtt2sys.
##
###############################################################



# Inform user
echo "Creating $1_struc.m"

rm -f mtt_error

#Write some file headers
echo "function [input_name,output_name,state_name] = $1_struc" > $1_struc.m
echo "%% Usage: [input_name,output_name,state_name] = $1_struc" >> $1_struc.m
echo "%% Structure file ($1_struc.m)" >> $1_struc.m
echo "%% Generated by MTT at `date`" >> $1_struc.m

cat  >> $1_struc.m <<EOF

## Default to null strings
 input_name = "";
 output_name = "";
 state_name  = "";
EOF



# This is the main transformation using awk
gawk '
function header(what){
  print what "_name = [";
}

function footer(what){
  print "];";
}

BEGIN{
Which="";
apostrophe = "\047";
}
{
  if ($1!=Which) {
    if (Which!="") footer(Which);
    header($1);
  }
  print  apostrophe $4 "_" $3 apostrophe;
  Which = $1;
}
END{
  footer(Which)
}
'  SYSTEM=$1  < $1_struc.txt >> $1_struc.m 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/struc_txt2mstruc version [501cce0f76].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2m

# Structure file - txt to m-structure conversion
# Copyright (C) 2003 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

sys=$1
infile=${sys}_struc.txt
fun=${sys}_mstruc
outfile=${fun}.m

#Inform user
echo Creating ${outfile}

create_header() {
    cat <<EOF
function [struc] = ${fun};
## Usage [struc] = ${fun};
## Created by mtt on `date`
EOF
}
create_structure() {
cat ${infile} | strip_comments | gawk 'BEGIN{
printf("  struc.input.name = \"\";\n");
printf("  struc.output.name = \"\";\n");
printf("  struc.state.name = \"\";\n");

printf("  struc.input.full_name = \"\";\n");
printf("  struc.output.full_name = \"\";\n");
printf("  struc.state.full_name = \"\";\n");

printf("  struc.input.causality = \"\";\n");
printf("  struc.output.causality = \"\";\n");
printf("  struc.state.causality = \"\";\n");
}
{
printf("  struc.%s.name = [ struc.%s.name; \"%s\"];\n", $1, $1, $3)
printf("  struc.%s.full_name = [ struc.%s.full_name; \"%s\"];\n", $1, $1, $4)
printf("  struc.%s.causality = [ struc.%s.causality; \"%s\"];\n", $1, $1, $6)
printf("  struc.repetitions(%i) = %i;\n", $2, $5)

}'
}

create_footer() {
    cat<<EOF
endfunction
EOF
}


create_header     >${outfile}
create_structure >>${outfile}
create_footer    >>${outfile}

Deleted mttroot/mtt/bin/trans/struc_txt2tex version [d8af09e179].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2tex

# Structure file - text to TeX table conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2000/12/28 12:46:59  peterg
## Put under RCS
##
# Revision 1.3  1997/12/06  19:10:41  peterg
# Reverted to tabular --- from supertabular
#
# Revision 1.2  1997/04/15  11:17:58  peterg
# Uses supertabular for long tables.
#
# Revision 1.1  1997/04/15  09:49:04  peterg
# Initial revision
#
###############################################################


# Inform user
echo "Creating $1_struc.tex"

rm -f mtt_error

#Write some file headers
echo "%% Structure file ($1_struc.txt)" > $1_struc.tex
echo "%% Generated by MTT at `date`" >> $1_struc.tex

# This is the main transformation using awk
sed 's/_/\\_/g' < $1_struc.txt |  gawk '
function header(what){
  print "  \\centering";
 print "  \\tablefirsthead{\\hline %";
  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM "} \\\\";
  print "    \\hline";
  print "     & Component & System & Repetition \\\\";
  print "    \\hline}";

  print "  \\tablehead{\\hline %";
  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM " (continued)} \\\\";
  print "    \\hline";
  print "     & Component & System & Repetition \\\\";
  print "    \\hline}";

  print "  \\tabletail{\\hline}";
  print "  \\begin{supertabular}{|l|l|l|l|}";
}
#function header(what){
#  print "\\begin{table}[htbp]";
#  print "  \\centering";
#  print "  \\begin{tabular}{|l|l|l|l|}";  print "    \\hline";
#  print "     & Component & System & Repetition \\\\";
#  print "    \\hline";
#}
function footer(what){
  print "    \\hline";
  print "  \\end{supertabular}";
#  print "  \\end{tabular}";
#  print "  \\caption{" what "}";
#  print "\\end{table}";
  print "   \\bigskip";
  print "   \\bigskip";
}

BEGIN{
Which=""
}
{
  if ($1!=Which) {
    if (Which!="") footer(Which);
    header($1);
  }
  print $2, "&", $3,"&", $4, "&", $5, "\\\\";
  Which = $1;
}
END{
  footer(Which)
}
'  SYSTEM=$1  >> $1_struc.tex 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sub2subs version [41189e212e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sub2subs
# Generates a list of all subsystems associated with system $1

# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

# echo the name of the subsystems one level down
sh $1\_sub.sh "echo  " 

# Create the corresponding subsystems --  quietly!
#(sh $1\_sub.sh "mtt -q  " " sub sh") #>/dev/null
(sh $1\_sub.sh " cmp2sub_m2sh  " " ") >/dev/null


# Recursively execute the subsystem files
sh $1\_sub.sh "sub2subs " 







Deleted mttroot/mtt/bin/trans/sub_sh2tex version [664edf4220].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sub_sh2tex
# Converts _sub_sh files to a latex itemized list.
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  2004/08/26 16:15:40  geraint
## Counts abg.m instead of fig files so that dia models are also included.
##
## Revision 1.5  2004/02/10 16:11:01  gawthrop
## Removed debug
##
## Revision 1.4  2004/02/10 10:22:10  gawthrop
## Do proper arithmetic via let
## Three levels of output
## enumerate, not itemize
##
## Revision 1.3  2004/02/10 10:13:05  gawthrop
## Handles #SUMMARY correctely
## Refined count of subsystems within fig file (avoilds ports with same
## name as system
##
## Revision 1.2  2004/02/10 09:51:07  gawthrop
## Updated obsolete path name.
##
## Revision 1.1  2000/12/27 16:04:08  peterg
## Initial revision
##
## Revision 1.7  1998/02/04 10:59:37  peterg
## Tidied up.
##
# Revision 1.6  1997/09/08  19:42:37  peterg
# Replaced copy by compcopy
#
## Revision 1.5  1997/08/15 11:20:13  peterg
## Explicitly copies compound components (if not already there)
##
# Revision 1.4  1997/06/24  08:28:26  peterg
# Now takes %SUMMARY description from the label file
# Appends count of number of subsystems at that level
#
## Revision 1.3  1997/05/21 10:07:36  peterg
## Fixed \ probs for GNU sh/echo
##
## Revision 1.2  1997/05/19 16:46:17  peterg
## *** empty log message ***
##
# Revision 1.1  1997/05/19  11:29:44  peterg
# Initial revision
#
###############################################################


#Useful strings
quote="'";
listtype="enumerate"

# Maximum list depth 
# Just go to 3 levels
maxlevel=3; 

#Look for a command line argument
labels=''; arg='';
while [ -n "`echo $1 | grep '-'`" ]; do
  case $1 in
	-l )
		labels='yes'; arg='-l' ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


system=$1
filename=$2 


if [ -z "$3" ]; then
    level=0;
else
    level=$4;
fi
echo "level: $level"
#Top-level commands
if [ -z "$2" ]; then
  filename="$1_sub.tex"

  # Inform user
  echo "Creating $filename"

  #Write some file headers
  echo "% Subsystem file for system $system ($filename)"   > $filename
  echo "% Generated by MTT at `date`"  >> $filename
  echo  >> $filename
fi

# Write list item if not at the top level.
if [ -n "$2" ]; then
  #Set up some names
  filename=$2
  abgfile=$3_abg.m
  lblfile=$1_lbl.txt
  summary='[%|#]SUMMARY'

  #Get the system description, copying where necesary
  mtt -q -u compcopy $system $MTT_LIB/comp/compound
  # mtt -q -u $system lbl txt
  desc=`grep $summary $lblfile | sed "s/$summary//"`

  #Count the number of subsystems
  subs=`grep -c " $system" $abgfile`

  if [ "$labels" = "yes" ]; then
    echo '  \item '$desc ' ('$subs') Section \Ref{sec:'$system'}' >> $filename
  else
    echo '  \item' $desc ' ('$subs')'   >> $filename
  fi
fi

# Create the subsystem sh files (if not too deep)
if [ "$level" != "$maxlevel" ]; then
    mtt -q -u  -l 1 $system sub sh

    # Write the list of subsystems (if they exist).
    n_subsystems=`grep -c '$1' $1_sub.sh`

    if [ "$n_subsystems" != "0" ]; then
	cat <<EOF >> $filename
	    \begin{$listtype}
EOF
	# Recursively generate the subsystems
        level1=$(( $level + 1 ))
	sh $system\_sub.sh "sub_sh2tex $arg " " $filename $system $level1" 
	cat <<EOF >> $filename
	    \end{$listtype}
EOF
#else
#    cat  <<EOF >> $filename
#         No subsystems.
#EOF
fi
fi








Deleted mttroot/mtt/bin/trans/switch_txt2m version [1b58ea9614].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: switch_txt2m

# Convert switch file from txt to m
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15  2000/12/04 08:23:25  peterg
## Put logic in-line - avoids the if statements
##
## Revision 1.14  2000/11/09 10:29:21  peterg
## open --> mtt_open
##
## Revision 1.13  2000/11/09 10:19:12  peterg
## Explicitly write out the open switches ....
##
## Revision 1.12  2000/11/09 09:52:07  peterg
## Removed [] from zero_state output
##
## Revision 1.11  2000/10/17 09:55:55  peterg
## Now writes to standard output
## Write the name, not the array
##
## Revision 1.10  2000/10/17 09:04:12  peterg
## *** empty log message ***
##
## Revision 1.9  1999/08/02 12:44:21  peterg
## zero_vector --> zero_state.
##
## Revision 1.8  1999/04/20 00:55:40  peterg
## Changed <= to < in switchopen.m
## Removed switch.m generation - redundant
##
## Revision 1.7  1999/04/02 06:30:37  peterg
## New _switchopen
## Removed switcha
##
## Revision 1.6  1998/10/01 18:20:50  peterg
## Split up the three if conditions on the switch and state value into
## three separate ifs. This is because p2c seems to generate incorrect
## code id just the one if is used (???).
##
## Revision 1.5  1998/10/01 16:05:34  peterg
## Separate switch.m file for euler and implicit integration
##
###############################################################


# Find system constants
Nx=`mtt_getsize $1 x` # States

#Write some file headers
#lang_header $1 switch m 'mttx' '[mttx]' > $1_switch.m

#echo Creating  $1_switch.m
# Set states to zero
# gawk '{
#   if ($1=="#"){
#     printf("#== Switches set element of state vector to zero ==#\n")
#   }
#   else{
#   printf("\n#== Switch: %s ==#\n",$1)
#   printf("if (%s==0.0) \n", $1);
#   printf("  mttx(%s)=0.0;\n", $2);
#   printf("end;\n");
#   printf("if (%s<0.0)\n",$1);
#   printf("  if (mttx(%s)<=0.0)\n",$2);
#   printf("    mttx(%s)=0.0;\n", $2);
#   printf("  end;\n");
#   printf("end;\n");

#   }
# }' Nx=$Nx < $1_switch.txt >> $1_switch.m

## Set index version
#echo Creating  $1_switchopen.m

#Write some file headers
#lang_header $1 switchopen m 'mttx' '[open]' > $1_switchopen.m

## Add the switching logic
#cat  >> $1_switchopen.m <<EOF

## User defined logic (from $1_logic.m)

#EOF
#cat $1_logic.txt >> $1_switchopen.m

# Set states to zero
gawk '{
  if ($1=="#"){
    printf("#== mttopen - boolean vector of open switches ==#\n")
    for (i=1;i<=Nx;i++)
     printf("mttopen(%i) = 0; # Default to not open\n", i);
  }
  else{
  printf("\n#== Switch: %s ==#\n",$1)
   printf("mttopen(%s) = (abs(%s_logic)<0.5)||((%s_logic<0.0)&&(%s<0.0));\n", $2, $1, $1, $1);
#   printf("if (%s_logic==0.0) \n", $1);
#   printf("  mttopen(%s) = 1;\n", $2);
#   printf("end;\n");
#   printf("if (%s_logic<0.0)\n",$1);
#   printf("  if (%s<0.0)\n",$1);
#   printf("    mttopen(%s) = 1;\n", $2);
#   printf("  end;\n");
#   printf("end;\n");

  }
}' Nx=$Nx < $1_switch.txt #>> $1_switchopen.m

#echo Creating  $1_switcha.m

# Implicit integration version
#Write some file headers
# lang_header $1 switcha m 'mttAA,mttx' '[mttAA]' > $1_switcha.m
# gawk '{
#   if ($1=="#"){
#     printf("#== Switches set row and column of A matrix to zero ==#\n")
#   }
#   else{
#   printf("#== Switch: %s ==#\n",$1)
#   printf("if (%s==0.0) \n", $1);
#   printf("  for  MTTi=1:%s\n",Nx)
#   printf("    mttAA(MTTi,%s)=0.0;\n", $2)
#   printf("    mttAA(%s,MTTi)=0.0;\n", $2)
#   printf("  end;\n");
#   printf("  mttAA(%s,%s) = 1.0;\n", $2,$2);
#   printf("end;\n\n")
# 
#   printf("if (%s<0.0)\n",$1);
#   printf("  if (mttx(%s)<=0.0)\n",$2);
#   printf("    for  MTTi=1:%s\n",Nx)
#   printf("      mttAA(MTTi,%s)=0.0;\n", $2)
#   printf("      mttAA(%s,MTTi)=0.0;\n", $2)
#   printf("    end;\n");
#   printf("    mttAA(%s,%s) = 1.0;\n", $2,$2);
#   printf("  end;\n");
#   printf("end;\n");
# 
#   }
# }' Nx=$Nx < $1_switch.txt >> $1_switcha.m



Deleted mttroot/mtt/bin/trans/sympar2global_txt2lang version [3d88bdddde].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2global_txt2lang

# Symbolic parameters to default paramers in computer language
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/11/18 11:55:51  peterg
## Now uses sympar2global_txt2m for the m bit
##
## Revision 1.5  1998/07/26 11:00:18  peterg
## Put in exits-- this all needs a good clean
##
## Revision 1.4  1998/07/26 10:50:30  peterg
## Corrected bug.
##
## Revision 1.3  1998/07/26 10:48:18  peterg
## Now strips comments
##
## Revision 1.2  1998/07/25 18:49:00  peterg
## Now uses extended sympars -- sympar + switches
##
## Revision 1.1  1998/06/15 15:24:33  peterg
## Initial revision
##
###############################################################

# Set up language stuff.
language=$2

case $language in
    m)
	Lc='#';
	Rc='#';
	;;
    c)
	Lc='/*';
	Rc='*/';
	;;
    java)
	Lc='/*';
	Rc='*/';
	;;
    *)
	echo Language $2 not supported - sorry; exit 1
esac

cat <<EOF

$Lc====== Set up the global variables ======$Rc
EOF
# Matlab bit
#Write out the variables in matlab global format
if [ "$language" = "m" ]; then
  sympar2global_txt2m $1
exit
fi

if [ "$language" = "c" ]; then
  strip_comments <$1_sympars.txt  |\
    gawk '{
      i++; print "extern double", tolower($1) ";";
    }'
exit
fi

if [ "$language" = "java" ]; then
cat <<EOF
    $1_numpar p;
    private p = new $1_numpar();
EOF 
  strip_comments <$1_sympars.txt  |\
      gawk '{
        i++; print "  float " tolower($1) " = p." tolower($1) ";";
      }'
fi

echo

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sympar2global_txt2m version [e8df2e195f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2global_txt2m

# Symbolic parameters to default paramers (m)
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/11/18 15:07:37  peterg
## Space after all globals
##
## Revision 1.5  1998/11/18 11:34:24  peterg
## Cleaned up to:
##   work properly for no globals
##   no need to repeat las global
##
## Revision 1.4  1998/07/26 10:44:08  peterg
## Now strips comment lines first
##
## Revision 1.3  1998/07/25 18:27:45  peterg
## now uses the (extended with switch) sympars.txt file
##
## Revision 1.2  1998/03/22 11:13:27  peterg
## Back under RCS
##
# Revision 1.1  1997/04/16  11:37:22  peterg
# Initial revision
#
###############################################################


#Write out the variables in matlab global format
strip_comments <$1_sympars.txt  |\
gawk '
{i++; 
  if ((i==1)&&(NF>0)) {
    printf ("global");
    globals_exist=1
  }
  if (NF>0)
    printf (" ...\n     %s", tolower($1));
}
END{
  if (globals_exist)
    print " ;"
}' 

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sympar2numpar_r2c version [d052149f27].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2numpar_r2m
# Creates the deafault numerical parameters file for the system

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1997/01/21 11:36:26  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_numpar.c

# Remove the old log file
rm -f sympar2numpar_r2c.log

# Use reduce to accomplish the transformation
reduce >sympar2numpar_r2c.log 2>mtt_error.txt << EOF

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
IN "$1_sympar.r";

OUT "$1_numpar1.c";

IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE  
      BEGIN
        write "extern float ", MTTVar(i,1)$
      END;
END; 


IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
    THEN 
    BEGIN
     write "/* Variable ", i, " has already been set to ",   MTTVar(i,1), "*/";
    END
    ELSE
    BEGIN
      write MTTVar(i,1), "  = 1;	/* Default value */";
    END;
END;


SHUT "$1_numpar1.c";

EOF

matlab_tidy $1_numpar1.c

#Create the numpar file complete with headers.
echo "/*" > $1_numpar.c
echo "%% Numerical parameter file ($1_numpar.c)" >> $1_numpar.c
echo "%% Generated by MTT at `date`" >> $1_numpar.c
echo "*/" >> $1_numpar.c

echo "$1_numpar()"  >> $1_numpar.c
echo "{" >> $1_numpar.c
echo "  extern $1_params();" >> $1_numpar.c

cat $1_numpar1.c >> $1_numpar.c

echo "/*" >> $1_numpar.c
echo '%% Input the user-defined parameters'  >> $1_numpar.c
echo "*/" >> $1_numpar.c

echo "$1_params;"   >> $1_numpar.c
echo "};" >> $1_numpar.c

rm $1_numpar1.c

# Now invoke the standard error handling.
mtt_error_r sympar2numpar_r2c.log

Deleted mttroot/mtt/bin/trans/sympar2numpar_r2m version [0368596f7d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137









































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2numpar_r2m
# Creates the deafault numerical parameters file for the system

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.9  1996/09/12 19:26:05  peter
## Input _params file.
##
## Revision 1.8  1996/08/30 19:37:43  peter
## Moved headers in shell script.
##
## Revision 1.7  1996/08/24 14:11:56  peter
## Global parameter passing.
##
## Revision 1.6  1996/08/20 08:21:24  peter
## *** empty log message ***
##
## Revision 1.5  1996/08/16 14:27:25  peter
## Make a dummy function when no parameters (MTTNVar=0).
##
## Revision 1.4  1996/08/15 12:46:59  peter
## Removed a spuriuos echo.
##
## Revision 1.3  1996/08/12 20:20:59  peter
## Explicit parameters via out put list.
## Parameter conversion stuff deleted.
##
## Revision 1.2  1996/08/11 10:41:52  peter
## Fixed various bugs.
##
## Revision 1.1  1996/08/11 08:48:07  peter
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_numpar.m

# Remove the old log file
rm -f sympar2numpar_r2m.log

# Use reduce to accomplish the transformation
reduce >sympar2numpar_r2m.log << EOF

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the symbolic parameters file
IN "$1_sympar.r";

OUT "$1_numpar1.m";

IF MTTNvar>0 THEN
BEGIN
  write "global ...;;";
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE  
      BEGIN
       IF i<MTTNvar THEN write MTTVar(i,1), " ..."
                    ELSE write MTTVar(i,1), ";";
      END;
END; 


IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
    THEN 
    BEGIN
     write "% Variable ", i, " has already been set to ",   MTTVar(i,1);
    END
    ELSE
    BEGIN
      write MTTVar(i,1), "  = 1;	% Default value";
    END;
END;

if MTTNVar=0 THEN
  write "foo=0";

SHUT "$1_numpar1.m";

EOF

matlab_tidy $1_numpar1.m

#Create the numpar file complete with headers.
echo "%% Numerical parameter file ($1_numpar.m)" > $1_numpar.m
echo "%% Generated by MTT at `date`" >> $1_numpar.m
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_numpar.m
cat $1_numpar1.m >> $1_numpar.m

echo '%% Input the user-defined parameters'  >> $1_numpar.m
echo "$1_params;"   >> $1_numpar.m


rm $1_numpar1.m


# Now invoke the standard error handling.
mtt_error_r sympar2numpar_r2m.log



















Deleted mttroot/mtt/bin/trans/sympar2numpar_txt2txt version [6787c03295].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2numpar_txt2txt
# Creates the deafault numerical parameters file for the system (txt)

# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.13  2000/10/16 08:09:25  peterg
## Tidied up.
##
## Revision 1.12  1999/03/02 22:01:21  peterg
## *** empty log message ***
##
## Revision 1.11  1998/06/15 15:14:46  peterg
## Don't print if blank line
##
## Revision 1.10  1998/03/07 15:27:20  peterg
## Don't do initial states.
##
## Revision 1.9  1998/02/04 12:24:35  peterg
## Simplified output format
##
## Revision 1.8  1998/01/29 17:06:36  peterg
## Better annotation
##
## Revision 1.7  1997/09/18 17:10:18  peterg
## Changed comments pertaining to the parameters to use the new column 2
## of the sympar file (the system type).
## Added blank line to separate parmeters from states.
## (Done in the Chester Court Hotel).
##
## Revision 1.6  1997/06/13 09:34:39  peterg
## changed [] to ()
##
# Revision 1.5  1997/05/15  08:30:14  peterg
# Now write default states (using _struc file).
#
# Revision 1.4  1997/05/15  07:19:19  peterg
# Put back "tolower"
#
# Revision 1.3  1997/05/15  07:13:31  peterg
# Removed "tolower" function.
#
# Revision 1.2  1997/05/01  08:19:04  peterg
# # is now used as the comment symbol
#
# Revision 1.1  1997/05/01  07:35:48  peterg
# Initial revision
#
###############################################################

# Inform user
echo Creating $1_numpar.txt

#Create the numpar file complete with headers.
echo '# -*-octave-*- Put Emacs into octave-mode' > $1_numpar.txt
echo "# Numerical parameter file ($1_numpar.txt)" >> $1_numpar.txt
echo "# Generated by MTT at `date`" >> $1_numpar.txt
cat $MTTPATH/trans/rcs_header.txt  >> $1_numpar.txt

#Write out the variables
echo "# Parameters" >> $1_numpar.txt
strip_comments <$1_sympar.txt |\
gawk '{i++; if (NF>0) print tolower($1) " = \t1.0; \# " $2}'\
  >> $1_numpar.txt

#Write out the initial states
#echo  >> $1_numpar.txt
#echo "# Initial states" >> $1_numpar.txt
#gawk '{
#  if ($1=="state") 
#    print "x(" $2 ") = \t0.0; \# " $4 " (" $3 ")"
#}' \
# $1_struc.txt >> $1_numpar.txt





Deleted mttroot/mtt/bin/trans/sympar2par_txt2m version [ea07b68f51].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2par_txt2m

# Symbolic parameters parameter conversion
# Used in lang_header
# Copyright (C) 2000 by Peter J. Gawthrop

Lb=${5:-'('}
Rb=${6:-')'}

case $2 in
    zero)
	  strip_comments <$1_sympar.txt  |\
          gawk '{
          i++; printf("  %s %s = 0.0;\n",  tolower($1));
          }' 
	;;
    set)
	  strip_comments <$1_sympar.txt  |\
         gawk '{
           i++; printf("  %s mttpar(%i) \t= %s;\n", i, tolower($1));
         }' 
        ;;
    *)
         strip_comments <$1_sympar.txt  |\
         gawk '{
           i++; printf("  %s %s \t= mttpar%c%i%s%c;\n", decl, tolower($1), Lb, i, minusone, Rb);
         }' decl="$3" minusone="$4" Lb=$Lb Rb=$Rb
	;;
esac




Deleted mttroot/mtt/bin/trans/sympar2params_txt2c version [b4d5f24a4d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2params_txt2c

# Symbolic parameters to default paramers (c)
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1997/03/20 15:17:45  peterg
## All variables are in lower case.
##
# Revision 1.1  1997/03/20  10:25:55  peterg
# Initial revision
#
###############################################################



# Inform user
echo "Creating $1_params.c"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_params.c
echo "Parameter file for system $1 ($1_params.c)"   >> $1_params.c
echo "This file provides the system params for simulation:"  >> $1_params.c
echo "Generated by MTT at `date`"  >> $1_params.c
echo "These default parameters should be changed by the user"  >> $1_params.c
echo '*/' >> $1_params.c
echo  >> $1_params.c


cat $MTTPATH/trans/rcs_header.c >> $1_params.c
echo  >> $1_params.c


echo "#include \"$1_sympar.c\""  >> $1_params.c
echo "$1_params()" >> $1_params.c
echo '{' >> $1_params.c

#Write out the variables in c format.
gawk '{i++; print tolower($1) " = \t1.0;"}' $1_sympar.txt  >> $1_params.c
echo '}' >> $1_params.c

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sympar2params_txt2m version [cb4bac324f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar2params_txt2m

# Symbolic parameters to default paramers (m)
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1997/04/17 11:18:34  peterg
## Write out the RCS header first!
##
# Revision 1.2  1997/04/16  11:40:31  peterg
# Added global variables.
#
# Revision 1.1  1997/04/16  11:31:41  peterg
# Initial revision
#
###############################################################



# Inform user
echo "Creating $1_params.m"

rm -f mtt_error

#Write some file headers
echo "% Parameter file for system $1 ($1_params.m)"   > $1_params.m
echo "% This file provides the system params for simulation:"  >> $1_params.m
echo "% Generated by MTT at `date`"  >> $1_params.m
echo "% These default parameters should be changed by the user"  >> $1_params.m
echo  >> $1_params.m

cat $MTTPATH/trans/rcs_header.m >> $1_params.m
echo  >> $1_params.m


#Write out the global variables
sympar2global_txt2m $1 >> $1_params.m


#Write out the variables in c format.
gawk '{i++; print tolower($1) " = \t1.0;"}' $1_sympar.txt  >> $1_params.m

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sympar2rtxi_txt2cc version [163d3be99c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

sys=$1
struc=${sys}_struc.txt
sympar=${sys}_sympar.txt
RTXI_H="${sys}_rtxi.h"
RTXI_CC="${sys}_rtxi.cc"
program=$(basename $0)
date=$(date)

cat <<EOF > ${RTXI_CC}
// -*-c++-*- Put Emacs into c++-mode

// Generated from $sympar and $struc by MTT
// using $program
// at $date

#include <${RTXI_H}>

extern "C" Plugin::Object *createRTXIPlugin(void) {
  return new ${sys}();
}

static DefaultGUIModel::variable_t vars[] = {
EOF

gawk '
  ($1=="input") {
    printf("  {\n");
    printf("    \"%s\",\n", $3);
    printf("    \"%s\",\n", $6);
    printf("    DefaultGUIModel::INPUT,\n");
    printf("  },\n");
  }
  ($1=="output") {
    printf("  {\n");
    printf("    \"%s\",\n", $3);
    printf("    \"%s\",\n", $6);
    printf("    DefaultGUIModel::OUTPUT,\n");
    printf("  },\n");
  }
' ${struc} >> ${RTXI_CC}

gawk '
  {
    printf("  {\n");
    printf("    \"%s\",\n", $1);
    printf("    \"\",\n");
    printf("    DefaultGUIModel::PARAMETER |");
    printf(" DefaultGUIModel::DOUBLE,\n");
    printf("  },\n");
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
};

static size_t num_vars = sizeof(vars)/sizeof(DefaultGUIModel::variable_t);
// TODO: initialise from numpar
static double
EOF

gawk '
  { printf("  %s=0.0,", $1); }
  END { printf ";" }
' $sympar |\
    sed -e 's/,;/;\n/' |\
    sed -e 's/,/,\n/' >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
static long i_count = 0;

${sys}::${sys}(void)
  : DefaultGUIModel("${sys}",::vars,::num_vars),
EOF

gawk '
  { printf("  %s(0.0),", $1); }
  END { printf ";" }
' $sympar |\
    sed -e 's/,;/\n/' |\
    sed -e 's/,/,\n/' >> ${RTXI_CC}


cat <<EOF >> ${RTXI_CC}
{
  doUpdate(INIT);
  refresh();
}

${sys}::~${sys}(void) {}

// ${sys}::execute(void) is defined in ${sys}_ode2odes.cc

void ${sys}::update(DefaultGUIModel::update_flags_t flag) {
  setCaption("${sys}");
  switch(flag) {
    case INIT:
EOF

gawk '
  {
    printf("      setParameter(\"%s\",QString::number(%s));\n",
	 $1, $1);
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
      break;
    case MODIFY:
EOF

gawk '
  {
    printf("      getParameter(\"%s\").toDouble();\n", $1);
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
      break;
    default:
      break;
  }
}
EOF

Deleted mttroot/mtt/bin/trans/sympar2rtxi_txt2h version [7eba5b84fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

sys=$1
sympar=${sys}_sympar.txt
RTXI_H="${sys}_rtxi.h"
program=$(basename $0)
date=$(date)

cat <<EOF > ${RTXI_H}
// -*-c++-*- Put Emacs into c++-mode

// Generated from $sympar by MTT
// using $program
// at $date

#include <rt.h>
#include <default_gui_model.h>

class $sys : public DefaultGUIModel
{

public:
  
  $sys(void);
  virtual ~$sys(void);
  
  virtual void execute(void);

protected:

  virtual void update(DefaultGUIModel::update_flags_t);

private:

EOF

gawk '
	{ printf("  double %s;\n", $1); }
' $sympar >> ${RTXI_H}

cat <<EOF >> ${RTXI_H}
};
EOF

Deleted mttroot/mtt/bin/trans/sympar_r2c version [4377d90700].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_r2c
# Convert symbolic parameters to a c declaration list

# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.1  1997/03/01  11:20:36  peterg
# Initial revision
###############################################################

# Inform user
echo Creating $1_sympar.c

# Remove the old log file
rm -f sympar_r2c.log

# Use reduce to accomplish the transformation
reduce >sympar_r2c.log << EOF


%Read the symbolic parameters file
in "$1_sympar.r";


%Generate the global variable list.
OUT "$1_sympar.c";
%External (global) variable list

write "/* Symbolic paramaters for system $1 */ "$
write "/* Generated by MTT */ "$
write "/* External (global) variable list */ "$

IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE
      BEGIN
         write "extern double ", MTTVar(i,1), ";"$
      END$
END$
SHUT "$1_sympar.c";


EOF

Deleted mttroot/mtt/bin/trans/sympar_txt2c version [8c103e49d4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2c

# Label file to symbolic parameters conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1997/05/15 07:19:56  peterg
## Put back "tolower"
##
# Revision 1.2  1997/05/15  07:10:56  peterg
# removed "tolower" function
#
# Revision 1.1  1997/05/15  07:10:09  peterg
# Initial revision
#
# Revision 1.3  1997/03/19  16:39:12  peterg
# Put in the correct date.
#
# Revision 1.2  1997/03/18  17:56:35  peterg
# Cosmetic changes.
#
###############################################################


# Inform user
echo "Creating $1_sympar.c"

rm -f mtt_error

#Write some file headers
echo '/*' > $1_sympar.c
echo "Symbolic parameter file ($1_sympar.c)" >> $1_sympar.c
echo "Generated by MTT at `date`"  >> $1_sympar.c
echo '*/' >> $1_sympar.c
echo  >> $1_sympar.c


#Write out the variables in c format.
gawk '{i++; print "extern double", tolower($1) ";"}' $1_sympar.txt \
      >> $1_sympar.c


# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sympar_txt2declare version [1d77607037].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2declare

# Symbolic parameters to variable declaration
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/10/11 09:08:20  peterg
## Initial revision
##

###############################################################

sys=$1
language=$2

case $language in
    p)
        first="VAR";
        delim=", ";
        last=': REAL;';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

# Start
cat<<EOF
$first
EOF
#Write out the variables 
strip_comments < $sys"_sympar.txt" |\
gawk '{
  i++; 
  var[i] = tolower($1);
}
END{
  n = i;
  for (i=1; i<n; i++){
    printf("%s%s",var[i], delim);
    j++; 
    if (j>10){
    printf("\n"); j=0;
    }
  }
  printf("%s%s\n",var[n], last);

}' "delim=$delim" "last=$last" 


Deleted mttroot/mtt/bin/trans/sympar_txt2m version [c51bec0783].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
## Converts sympar.txt to an m file which provides indices in the form
##  sympar.name = i


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Copyright (C) 2000 by Peter J. Gawthrop

echo Creating $1_sympar.m

lang_header -noglobals $1 sympar m "" sympar > $1_sympar.m

gawk '{
  printf("  sympar.%s \t= %i; # %s\n", $1, ++i, $2); 
}' < $1_sympar.txt >> $1_sympar.m

Deleted mttroot/mtt/bin/trans/sympar_txt2r version [48a0e2e4e2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2r

# Label file to symbolic parameters conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/02/17 17:03:54  peterg
## Fixed bug in writing out matrix declaration
##
## Revision 1.5  1998/02/16 12:14:21  peterg
## Corrected writing out of MTTVAR matrix - now does this id non-zero
## number of variables - not vv!
##
## Revision 1.4  1997/05/09 14:20:49  peterg
## Dont declare MTTVAR array when there are no variables.
##
# Revision 1.3  1997/03/19  16:39:12  peterg
# Put in the correct date.
#
# Revision 1.2  1997/03/18  17:56:35  peterg
# Cosmetic changes.
#
###############################################################


# Inform user
echo "Creating $1_sympar.r"

rm -f mtt_error

#Write some file headers
echo "%% Symbolic parameter file ($1_sympar.r)"  > $1_sympar.r
echo "%% Generated by MTT at `date`"  >> $1_sympar.r
echo  >> $1_sympar.r

#Count the lines in the file
lines=`grep -c  '.' $1_sympar.txt`

if [ "$lines" != "0" ]; then
    echo "MATRIX MTTVAR($lines,1);"   >> $1_sympar.r
fi
echo "MTTNVAR := $lines;"   >> $1_sympar.r
echo   >> $1_sympar.r

#Write out the variables in reduce format.
gawk '{i++; print "MTTVAR(" i ",1) := " $1 ";"}' $1_sympar.txt  >> $1_sympar.r

echo 'END;'  >> $1_sympar.r

# Now invoke the standard error handling.
# mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/sympar_txt2tex version [937e1d805d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2tex

# Sympar file - text to TeX table conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/27 16:04:46  peterg
## Initial revision
##
## Revision 1.2  1998/01/19 14:17:26  peterg
## Modified struc_txt2tex to make this.
##
## Revision 1.1  1998/01/19 14:16:39  peterg
## Initial revision
##
# Revision 1.3  1997/12/06  19:10:41  peterg
# Reverted to tabular --- from supertabular
#
# Revision 1.2  1997/04/15  11:17:58  peterg
# Uses supertabular for long tables.
#
# Revision 1.1  1997/04/15  09:49:04  peterg
# Initial revision
#
###############################################################


# Inform user
echo "Creating $1_sympar.tex"

rm -f mtt_error

#Write some file headers
echo "%% Parameter file ($1_sympar.txt)" > $1_sympar.tex
echo "%% Generated by MTT at `date`" >> $1_sympar.tex

# This is the main transformation using awk
sed 's/_/\\_/g' < $1_sympar.txt |  gawk '
#function header(what){
#  print "  \\centering";
# print "  \\tablefirsthead{\\hline %";
#  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM "} \\\\";
#  print "    \\hline";
#  print "     & Component & System & Repetition \\\\";
#  print "    \\hline}";
#
#  print "  \\tablehead{\\hline %";
#  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM " (continued)} \\\\";
#  print "    \\hline";
#  print "     & Component & System & Repetition \\\\";
#  print "    \\hline}";
#
#  print "  \\tabletail{\\hline}";
#  print "  \\begin{supertabular}{|l|l|l|l|}";
#}
function header(what){
  print "\\begin{table}[htbp]";
  print "  \\centering";
  print "  \\begin{tabular}{|l|l|}";  print "    \\hline";
  print "     Parameter & System\\\\";
  print "    \\hline";
}
function footer(what){
  print "    \\hline";
  print "  \\end{tabular}";
  print "  \\caption{" what "}";
  print "\\end{table}";
  print "   \\bigskip";
  print "   \\bigskip";
}
BEGIN{
  header($1);
}
{
  print $1, "&", $2, "\\\\";
}
END{
  footer("Parameters")
}
'  SYSTEM=$1  >> $1_sympar.tex 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Deleted mttroot/mtt/bin/trans/tex2doc version [378ed3e3b7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: tex2doc
# Encapsulates a tex file in a document.

# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2000/12/28 12:48:53  peterg
## Put under RCS
##
# Revision 1.2  1996/08/30  10:19:11  peter
# New path for awk script.
#
## Revision 1.1  1996/08/18 20:00:20  peter
## Initial revision
##
###############################################################

# Inform user
echo "Creating $1_$2.doc"

# This is the main transformation using awk
gawk -f $MTTPATH/trans/awk/tex2doc.awk \
system_name=$1 representation=$2  > $1_$2.doc

Deleted mttroot/mtt/bin/trans/tf_r2m version [2cb9afaa60].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: tf_r2m
# Reduce transfer-function matrices to Matlab MV toolbox matrices.
# P.J.Gawthrop 9 June 1990, 8 July 1990, Dec 993
# Copyright (c) P.J.Gawthrop, 1990, 1993.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/05/24 07:42:12  gawthrop
## Included and updated the missing tf_r2m
##
## Revision 1.1  1996/09/18 14:05:31  peter
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_tf.m

# Remove the old log file
rm -f tf_r2m.log

# Use reduce to accomplish the transformation
reduce >tf_r2m.log << EOF

%Read the definitions file
in "$1_def.r";

%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;

%Read the parameter file
%%in "$1_sympar.r";

%Read the transfer-function matrices file
OFF Exp; ON GCD; 
in "$1_tf.r";

OFF Echo;
%OFF Nat;
OFF factor;

%Find the largest degree numerator polynomial
NnMax := 0;
  FOR Row := 1:MTTNy DO
  BEGIN
    FOR Col := 1:MTTNu DO
    BEGIN
    Nn := length(coeff(num(MTTtf(Row,Col)),s));
    IF Nn>NnMax THEN NnMax := Nn;
    END;
  END;

NnMax;

%Find the largest degree denominator polynomial, and corresp indices
NdMax := 0;
  FOR Row := 1:MTTNy DO
  BEGIN
    FOR Col := 1:MTTNu DO
    BEGIN
    Nd := length(coeff(den(MTTtf(Row,Col)),s));
    IF Nd>NdMax THEN 
                BEGIN
                  NdMax := Nd; MaxRow := Row; MaxCol := Col;
                END
    END;
  END;

NdMax; MaxRow; MaxCol;

IF NnMax>NdMax THEN NMax := NnMax ELSE NMax := NdMax;
Nmax;

%Use any denominator with maximum degree as the common denominator
MTTden := den(MTTtf(MaxRow,MaxCol));

%Find the corresponding numerator
matrix MTTnum(MTTNy,MTTNu);
  FOR Row := 1:MTTNy DO
  BEGIN
    FOR Col := 1:MTTNu DO
    MTTnum(Row,Col) := num(MTTtf(Row,Col))*(MTTden/den(MTTtf(Row,Col)));
  END;
MTTnum := MTTnum;

%Put coefficients into matrices
matrix MTTdenco(1,Nmax);
MTTCoeff := Coeff(MTTden,s);
FOR i := 1:Nmax DO
BEGIN
  j := Nmax-i+1;
  IF j>length(MTTCoeff) THEN MTTdenco(1,i) := 0 
                        ELSE MTTdenco(1,i) := part(MTTCoeff,j);
END; 
MTTdenco := MTTdenco;

matrix MTTnumco(MTTNy,MTTNu*Nmax);
FOR MTTRow := 1:MTTNy DO
BEGIN
  FOR MTTCol := 1:MTTNu DO
  BEGIN
    MTTCoeff := Coeff(MTTnum(MTTRow,MTTCol),s);
    FOR MTTi := 1:Nmax DO
    BEGIN
      MTTj := Nmax-MTTi+1;
      MTTk := MTTi + (MTTCol-1)*Nmax;
      IF MTTj>length(MTTCoeff) THEN MTTnumco(MTTRow, MTTk) := 0 
                            ELSE MTTnumco(MTTRow, MTTk) := part(MTTCoeff,MTTj);
    END;
  END;
END;



OUT "$1_tf.m1";

write "mttden = zeros(1,", Nmax, ");";
write "mttnum =    zeros(", MTTNy, ",", Nmax*MTTNu, ");";

%Suppress zeros
ON NERO;

%Fortran switches - one line expressions
ON fort;
cardno!* := 1\$
fortwidth!* := 100\$
OFF period;

%Write out the matlab code
mttden := MTTdenco;
mttnum    := MTTnumco;
SHUT "$1_tf.m1";
quit;
EOF

#Headers
mtt_header $1 tf m > $1_tf.m

#Body
cat $1_tf.m1  >> $1_tf.m
echo '## END Code' >> $1_tf.m
rm -f $1_tf.m1

Deleted mttroot/mtt/bin/trans/tf_r2tex version [f44882531a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139











































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: tf_r2tex
# Reduce transfer-function matrices to LaTex transfer-function matrices.
# P.J.Gawthrop 9 June 1990, 8 July 1990, April 1994.
# Copyright (c) P.J.Gawthrop, 1990, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2014/04/18 00:36:40  gawthrop
## No parentheses.
##
## Revision 1.1  2000/12/27 16:05:29  peterg
## Initial revision
##
## Revision 1.2  1996/12/20 08:59:40  peterg
## Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
## conversion.
##
## Revision 1.1  1996/11/05 11:01:51  peterg
## Initial revision
##
###############################################################

#Inform user
echo Creating $1_tf.tex

# Remove the old log file
rm -f tf_r2tex.log

# Use reduce to accomplish the transformation
reduce >tf_r2tex.log << EOF

%Read the definitions file
in "$1_def.r";

%Read the parameter file
%%in "$1_sympar.r";

%Read the formatting function
IF MTTNy=1 AND MTTNu=1 
  THEN
    in "$MTTPATH/trans/latex_matrix_no.r"
  ELSE
    in "$MTTPATH/trans/latex_matrix.r";

%Read the transfer-function matrices file
in "$1_tf.r";

%Read the substitution file
IN "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

OFF Echo;
OFF Nat;

OUT "$1_tf.tex";
MTT_Matrix := MTTTF$ 
MTT_Matrix_name := "MTTG"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$

%%  FOR Row := 1:MTTNy DO
%%  BEGIN
%%    FOR Col := 1:MTTNu DO
%%    BEGIN
%%      numerator := num(MTTtf(Row,Col));
%%      denominator := den(MTTtf(Row,Col));
%%      cnumerator := coeff(numerator, s);
%%      cdenominator := coeff(denominator, s);
%%      write "!begin{equation} !label{eq_$1_tf", Row, Col, "}";
%%      IF MTTNy=1 AND MTTNu=1 
%%                          THEN
%%                          write "MTTTF(s) =  {"
%%                          ELSE
%%                          write "MTTTF", Row, Col, "(s) =  {";
%%      IF numerator = 0
%%       THEN write "0"
%%       ELSE 
%%       BEGIN
%%           FOR i := 1:Length(cnumerator) DO
%%           BEGIN
%%             cof := part(cnumerator,i);
%%               IF cof NEQ 0 THEN 
%%               BEGIN
%%                IF i>1 THEN write " + ";
%%                IF cof NEQ 1 THEN 
%%                 BEGIN
%%                 IF Terms(cof)>1 THEN write "(", cof, ")"
%%                                 ELSE write cof; 
%%                 END
%%                 ELSE IF i=1 THEN Write "1";
%%
%%               IF i=2 THEN write "s";
%%               IF i>2 THEN write "s^", i-1;
%%               END;
%%           END;
%%       END;
%%
%%       IF denominator NEQ 1 THEN
%%       BEGIN
%%       Write "!over";
%%           FOR i := 1:Length(cdenominator) DO
%%           BEGIN
%%           cof := part(cdenominator,i);
%%               IF cof NEQ 0 THEN 
%%               BEGIN
%%               IF i>1 THEN write " + ";
%%               IF cof NEQ 1 THEN 
%%               BEGIN
%%                 IF Terms(cof)>1 THEN write "(", cof, ")"
%%                                 ELSE write cof; 
%%               END
%%               ELSE IF i=1 THEN Write "1";
%%
%%             IF i=2 THEN write "s";
%%             IF i>2 THEN write "s^", i-1;
%%             END;
%%           END;
%%       END;
%%       write "}";
%%       write "!end{equation}";
%%    END;
%%  END;
%%
SHUT "$1_tf.tex";
quit;
EOF

Deleted mttroot/mtt/bin/trans/tidy version [5d66b20135].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
mv $1 $1.old

cat $1.old |
#Clear out all (and extraneous) new lines
tr -d '\012'  |\

#Squash blanks
tr -s '\040' '\040' |\

#Put in new lines to replace $
tr '\044' '\012' |\

#Remove blanks after E
sed "s/E /E/g"  |\

#Put in $ at end of each line
sed "s/$/\$/" >$1

Deleted mttroot/mtt/bin/trans/txt2m version [75f1960eab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186


























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: txt2m
# Converts txt file to matlab file (for numpar and state)

# Copyright (c) P.J.Gawthrop 1998


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.19  2000/02/11 13:35:16  peterg
# %% Added the new MTTpar generation
# %%
# %% Revision 1.18  1999/11/14 22:22:17  peterg
# %% Removed checks for implicit - now done at command-line level.
# %%
# %% Revision 1.17  1999/11/04 04:54:24  peterg
# %% Removed recreation of smx file.
# %%
# %% Revision 1.16  1999/03/06 02:18:10  peterg
# %% Changed argument list.
# %%
# %% Revision 1.15  1999/02/16 21:44:38  peterg
# %% Revised smx generation
# %%
# %% Revision 1.14  1999/02/16 04:38:22  peterg
# %% Now forces creation of _smx file if METHOD=IMPLICIT in simpar.txt
# %%
# %% Revision 1.13  1998/08/31 11:43:37  peterg
# %% Now lower cases globals in numpar files
# %%
# %% Revision 1.12  1998/08/14 10:47:31  peterg
# %% Put ImplicitS sub before Implicit!!
# %%
# %% Revision 1.11  1998/08/14 10:43:44  peterg
# %% Added ImplicitS - sparse integration
# %%
# %% Revision 1.10  1998/08/11 13:27:51  peterg
# %% Lowercase mttLAST etc
# %%
# %% Revision 1.9  1998/07/30 15:07:17  peterg
# %% Added _ to the disallowed chars around t
# %%
# %% Revision 1.8  1998/07/30 12:52:38  peterg
# %% Adds ; to end of statements
# %% Translates ' to " before removal
# %%
# %% Revision 1.7  1998/07/30 09:32:33  peterg
# %% Replaces:
# %% 	euler by 1
# %% 	implicitl by 1
# %% 	implicit  by 3
# %%
# %% Revision 1.6  1998/07/27 18:59:11  peterg
# %% Added WMIN etc
# %%
# %% Revision 1.5  1998/07/26 11:54:20  peterg
# %% Added  mtt to variables
# %%
# %% Revision 1.4  1998/07/26 09:50:12  peterg
# %% More forgiving of txt sytax.
# %%
# %% -- can use () or ()
# %% -- can use mttx() or x()
# %% -- can use mttu() or u()
# %%
# %% Revision 1.3  1998/07/25 20:40:35  peterg
# %% All vars in lower case now
# %%
# %% Revision 1.2  1998/07/25 09:48:31  peterg
# %% Tidied up for Pascal version
# %%
# %% Revision 1.1  1998/02/25 22:10:25  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

system=$1
representation=$2

if [ "$representation" = "state" ]; then
    name='mttx';
    arg='';
fi
if [ "$representation" = "input" ]; then
    name='mttu';
    arg='(mttt,mttx,mtty)'
fi

# Inform user
echo Creating $1_$2.m

#Create the $2 file complete with headers.
case $representation in
    simpar)
      echo "% Script file  $1_$2.m" > $1_$2.m
      echo "%% $2 file ($1_$2.m)" >> $1_$2.m
      echo "%% Generated by MTT at `date`" >> $1_$2.m
      echo '% Dummy globals' >>  $1_$2.m
      echo 'global ...' >>  $1_$2.m
      echo 'mtt_dummy_global;' >>  $1_$2.m
      ;;
    numpar)
      echo "% Script file  $1_$2.m" > $1_$2.m
      echo "%% $2 file ($1_$2.m)" >> $1_$2.m
      echo "%% Generated by MTT at `date`" >> $1_$2.m
      echo "% Global variable list" >>  $1_$2.m
      sympar2global_txt2m $1 >> $1_$2.m
      ;;
    *)
      echo "function $name = $1_$2$arg" > $1_$2.m
      echo "%% $2 file ($1_$2.m)" >> $1_$2.m
      echo "%% Generated by MTT at `date`" >> $1_$2.m
      echo "% Global variable list" >>  $1_$2.m
      sympar2global_txt2m $1 >> $1_$2.m
      ;;
esac

#Write out the variables in m format.
cat  $1_$2.txt | grep -v METHOD |\
gawk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");
  if (N==2) {
    LHS = a[1];
    RHS = a[2];
    gsub(quote, doublequote, RHS);
    sub(/^[ 	]*LAST/, "mttLAST", LHS);
    sub(/^[ 	]*DT/, "mttDT", LHS);
    sub(/^[ 	]*STEPFACTOR/, "mttSTEPFACTOR", LHS);
    sub(/^[ 	]*METHOD/, "mttMETHOD", LHS);
    sub(/^[ 	]*WMIN/, "mttWMIN", LHS);
    sub(/^[ 	]*WMAX/, "mttWMAX", LHS);
    sub(/^[ 	]*WSTEPS/, "mttWSTEPS", LHS);
    sub(/^[ 	]*INPUT/, "mttinput", LHS);
    LHS = tolower(LHS);
    RHS = tolower(RHS);
    sub(/["]*euler["]*/, 1, RHS);   
    sub(/["]*implicit["]*/, 2, RHS);  
    statement = sprintf("%s= %s",LHS,RHS);
    if ( (match(statement,";")==0)&&\
         ((match(statement,"if ")==0))&&\
         ((match(statement,"for ")==0)) )
      statement = sprintf("%s;", statement);
  }
  else if (match($1,"global")==1) {
    statement = tolower($1); # Lower case globals as well
  }
  else
    statement = $1;

  if (NF<2) print statement
  if (NF>1)  print statement " # " $2
}' | sed\
     -e 's/\[\([0-9]*\)\]/(\1)/g' \
     -e 's/\([^a-zA-Z_]\)t\([^a-zA-Z_]\)/\1mttt\2/g' \
     -e 's/x(/mttx(/g' \
     -e 's/u(/mttu(/g' \
     -e 's/mttmtt/mtt/g' \
     -e 's/#/%/g' \
>> $1_$2.m


if [ "$2" = "numpar" ]; then
    gawk '{
       printf("  MTTpar(%i) \t= %s;\n",++i, tolower($1));
     }'< $1_sympar.txt  >>$1_numpar.m
fi








Deleted mttroot/mtt/bin/trans/txt2tex version [18a439014a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: txt2tex

# Generic textual inclusion as verbatim tex.

# P.J.Gawthrop March 1998
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

if [ -z "$3" ]; then
   echo Usage: txt2tex system representation language
   exit 1
fi
# Inform user
echo "Creating $1_$2.tex"

rm -f mtt_error

#Write some file headers
echo "%% Tex file ($1_$2.txt)" > $1_$2.tex
echo "%% Generated by MTT at `date`" >> $1_$2.tex

cat <<EOF        >> $1_$2.tex
\begin{verbatim}
EOF
cat $1_$2.$3     >> $1_$2.tex
cat<<EOF         >> $1_$2.tex
\end{verbatim}
EOF




Deleted mttroot/mtt/bin/trans/txt_matrix.r version [920388fb07].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     %%%%% Model Transformation Tools %%%%%
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reduce function to write matrices in text form
% P.J.Gawthrop  Febrauary 1998
% Copyright (c) P.J.Gawthrop, 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


PROCEDURE txt_Matrix;
BEGIN
  IF MTT_Matrix_n>0 THEN
    IF MTT_Matrix_m>0 THEN
    BEGIN
    FOR i := 1:MTT_Matrix_n DO
      IF MTT_Matrix_m>1 THEN
        BEGIN
        FOR j := 1:MTT_Matrix_m DO 
          write MTT_Matrix_name, "(", i, ",", j, ") = ",
                                            MTT_Matrix(i,j), ";";
        END
      ELSE
         write MTT_Matrix_name, "(", i, ") = ",
                                            MTT_Matrix(i,1), ";";
    END;
END;

END;;

Deleted mttroot/mtt/bin/xmtt version [026c569d97].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: xmtt
#
# x-window version of MTT

# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/09/14 07:50:08  peterg
## *** empty log message ***
##
## Revision 1.4  1999/10/19 00:34:10  peterg
## *** empty log message ***
##
## Revision 1.3  1999/08/18 06:17:55  peterg
## Modular form
##
## Revision 1.2  1999/03/09 00:03:55  peterg
## Major revisions for release 3.5
##
## Revision 1.1  1998/10/20 08:15:17  peterg
## Initial revision
##
###############################################################

#Basic paths
dotfile="$HOME/.mtt"
xdotfile="${dotfile}/xmtt"

repfile="${xdotfile}/reps"
exfile="${xdotfile}/examples"
menufile=".xmtt_menu"

#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	--help|-h ) echo "usage:"
                    echo "  xmtt"
	            echo "  xmtt --update"
	            echo "  xmtt --example example_name"
	            echo "  xmtt --help"
		    exit;;

	--update|-u )    echo Creating representation list for mtt;
		         mtt2reps_txt> ${repfile};
		         echo Creating examples list for mtt;
		         mtt -q help examples> ${exfile};
                         exit;;

        --example|-e )   shift; example=$1;; 
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

if [ -n "${example}" ]; then
    mtt -q  copy ${example}; 
    cd ${example}; 
    xmtt
    exit
fi

## Make sure files exist
if [ -e "${xdotfile}" ]; then
    echo ${xdotfile} exists >/dev/null
else 
    echo Creating ${xdotfile}
    mkdir --parents ${xdotfile}
fi

if [ -e "${repfile}" ]; then
    echo ${repfile} exists >/dev/null
else 
    echo Creating ${repfile} and ${exfile}
    xmtt --update
    echo done.
fi

## Create the menu
mtt_make_menu > ${menufile}

## Use tk shell (wish)
name=`basename $PWD`
wish ${menufile} -name $name

Deleted mttroot/mtt/cc/Makefile version [943d4cbedc].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-

CXX ?= g++

build: parse_m2cc.exe

.PHONY: FORCE
clean: FORCE
	@-rm -f parse_m2cc.exe

parse_m2cc.exe: parse_m2cc.cc
	@$(CXX) $< $(CFLAGS) -o $@ -I./include
	@strip $@

Deleted mttroot/mtt/cc/def_m2h.sh version [e00c7a936e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# $Id$
# $Log$
# Revision 1.3  2002/05/15 14:22:25  geraint
# Code for Simulink S-function target written direct to sfun.cc instead of
# calling .mexglx files. This eliminates the sfun dependency on Octave
# ColumnVectors. sys_sfun.cc should build directly on a MS Windows machine
# (can't test this yet).
#
# added sfun.zip target to create source code to export.
#
# Revision 1.2  2002/04/28 18:58:06  geraint
# Fixed [ 549658 ] awk should be gawk.
# Replaced calls to awk with call to gawk.
#
# Revision 1.1  2000/12/28 09:46:05  peterg
# put under RCS
#
# Revision 1.3  2000/12/05 12:13:52  peterg
# Changed function name to name()
#
# Revision 1.2  2000/12/04 12:04:46  peterg
# Changed $() to `` for sh compatibility -- geraint
#
# Revision 1.1  2000/12/04 12:02:23  peterg
# Initial revision
#
# Revision 1.1  2000/10/31 04:32:28  geraint
# Initial revision
#

SYS=$1
IN=${SYS}_def.m
SYM=${SYS}_sympar.txt
OUT=${SYS}_def.h

get_array_size ()
{
vec=$1
gawk -v vec=${vec} '($1 == vec && $2 == "=") { print $3 }' | sed s/\;//
}

 echo "/* ${SYS}_def.h, generated by MTT on `date` */"			>  ${OUT}
 echo ""								>> ${OUT}
 echo "#ifndef HAVE_${SYS}_DEF_H"					>> ${OUT}
 echo "#define HAVE_${SYS}_DEF_H"					>> ${OUT}
 echo ""								>> ${OUT}
 echo "const int MTTNU   = `cat ${IN} | get_array_size nu`;"		>> ${OUT}
 echo "const int MTTNX   = `cat ${IN} | get_array_size nx`;"		>> ${OUT}
 echo "const int MTTNY   = `cat ${IN} | get_array_size ny`;"		>> ${OUT}
 echo "const int MTTNZ   = `cat ${IN} | get_array_size nz`;"		>> ${OUT}
 echo "const int MTTNYZ  = `cat ${IN} | get_array_size nyz`;"		>> ${OUT}
 echo "const int MTTNPAR = `wc -l ${SYM} | gawk '{ print $1 }'`;"      	>> ${OUT}
 echo ""								>> ${OUT}
 echo "static int mttnu, mttnx, mttny, mttnyz, mttnz;"		       	>> ${OUT}
 echo ""								>> ${OUT}
 echo "#endif"								>> ${OUT}



Deleted mttroot/mtt/cc/include/Bracket.hh version [5787729a17].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222






























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* $Id$
 * $Log$
 * Revision 1.1.4.1  2001/06/30 03:26:20  geraint
 * gcc-3.0 compatibility.
 *
 * Revision 1.1  2000/12/28 09:47:29  peterg
 * put under RCS
 *
 * Revision 1.1  2000/10/31 04:29:11  geraint
 * Initial revision
 *
 */



#include <iostream>
#include <string>


using namespace std;

class Bracket
{
public:
  friend ostream &operator<< (ostream &str, Bracket *b);
  friend string  &operator<< (string  &str, Bracket *b);
  friend string  &operator+= (string  &str, Bracket *b);
  friend string   operator+  (string  &str, Bracket *b);
  virtual int get_nesting_depth (void)		= 0;

protected:
  Bracket (char left, char right)	  	{ _l = left; _r = right; }
  ostream &open  (ostream &str)			{ this->increment_nesting (); return str << this->_l; }
  string  &open  (string  &str)			{ this->increment_nesting (); return str += this->_l; }
  ostream &close (ostream &str)			{ this->decrement_nesting (); return str << this->_r; }
  string  &close (string  &str)			{ this->decrement_nesting (); return str += this->_r; }

protected:
  virtual int increment_nesting (void)		= 0;
  virtual int decrement_nesting (void)		= 0;
  virtual ostream &display (ostream &str)	= 0;
  virtual string  &display (string  &str)	= 0;

private:
  char _l, _r;
};



class Brace : public Bracket
{
public:
  int get_nesting_depth (void)			{ return   (this->nesting_depth);}
  string indentation (int n = nesting_depth)
  {
    string s = "";
    int i;
    for (i = 0; i < n; i++)
      s += "   ";
    return s;
  }

protected:
  Brace () : Bracket ('{', '}')			{ ; }
  int increment_nesting (void)			{ return ++(this->nesting_depth); }
  int decrement_nesting (void)			{ return --(this->nesting_depth); }
  ostream &open (ostream &str)
  {
    str << endl << this->indentation ();
    this->Bracket::open (str);
    str << endl << this->indentation ();
    return str;
  }
  string &open (string &str)
  {
    str += '\n' + this->indentation ();
    this->Bracket::open (str);
    str += '\n' + this->indentation ();
    return str;
  }
  ostream &close (ostream &str)
  {
    str << endl << this->indentation (nesting_depth - 1);
    this->Bracket::close (str);
    str << endl << this->indentation ();
    return str;
  }
  string &close (string &str)
  {
    str += '\n' + this->indentation (nesting_depth - 1);
    this->Bracket::close (str);
    str += '\n' + this->indentation ();
    return str;
  }

private:
  static int nesting_depth;
};
int Brace::nesting_depth;



class Paren : public Bracket
{
public:
  int get_nesting_depth (void)			{ return   (this->nesting_depth);}

protected:
  Paren () : Bracket ('(', ')')			{ ; }
  int increment_nesting (void)			{ return ++(this->nesting_depth); }
  int decrement_nesting (void)			{ return --(this->nesting_depth); }

private:
  static int nesting_depth;
};
int Paren::nesting_depth;



class SquareBracket : public Bracket
{
public:
  int get_nesting_depth (void)			{ return   (this->nesting_depth);}

protected:
  SquareBracket () : Bracket ('[', ']')	       	{ ; }
  int increment_nesting (void)			{ return ++(this->nesting_depth); }
  int decrement_nesting (void)			{ return --(this->nesting_depth); }

private:
  static int nesting_depth;
};
int SquareBracket::nesting_depth;



class LeftBrace : public Brace
{
public:
  ostream &display (ostream &str)		{ return this->open  (str); }
  string  &display (string  &str)		{ return this->open  (str); }
};



class RightBrace : public Brace
{
public:
  ostream &display (ostream &str)		{ return this->close (str); }
  string  &display (string  &str)		{ return this->close (str); }
};



class LeftParen : public Paren
{
public:
  ostream &display (ostream &str)		{ return this->open  (str); }
  string  &display (string  &str)		{ return this->open  (str); }
};



class RightParen : public Paren
{
public:
  ostream &display (ostream &str)		{ return this->close (str); }
  string  &display (string  &str)		{ return this->close (str); }
};



class LeftSquareBracket : public SquareBracket
{
public:
  ostream &display (ostream &str)		{ return this->open  (str); }
  string  &display (string  &str)		{ return this->open  (str); }
};



class Rightbrace : public SquareBracket
{
public:
  ostream &display (ostream &str)		{ return this->close (str); }
  string  &display (string  &str)		{ return this->close (str); }
};



ostream &operator<< (ostream &str, Bracket *b)
{
  b->display (str);
  return str;
}



string  &operator<< (string  &str, Bracket *b)
{
  string s;
  b->display (s);
  str += s;
  return str;
}



string  &operator+= (string  &str, Bracket *b)
{
  b->display (str);
  return str;
}



string   operator+  (string  &str, Bracket *b)
{
  string s;
  b->display (s);
  return (str + s);
}

Deleted mttroot/mtt/cc/include/useful-functions.hh version [039f409770].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef HAVE_USEFUL_FUNCTIONS_HH
#define HAVE_USEFUL_FUNCTIONS_HH

/* Code generation directives */
#define STANDALONE 0
#define OCTAVEDLD  1
#define MATLABMEX  2
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET -1
#endif /* (! defined (CODEGENTARGET)) */

#ifndef __cplusplus
#define inline			/* strip */
#define cast_to_double	(double)
/*
typedef unsigned int bool;
const bool true = 1;
const bool false = 0;
*/
#else
#include <cmath>
#define cast_to_double	static_cast<double>
using std::pow;
#endif /* ! __cplusplus */

#ifdef M_PI
static double pi = M_PI;
static double Pi = M_PI;
static double PI = M_PI;
#else
static double pi = 3.1416;
static double Pi = pi;
static double PI = pi;
#endif

static inline double
max (const double x1, const double x2)
{
  return cast_to_double ((x1 >= x2) ? x1 : (x1 < x2) ? x2 : 0);
}

static inline double
min (const double x1, const double x2)
{
  return cast_to_double ((x1 <= x2) ? x1 : (x1 > x2) ? x2 : 0);
}

static inline double
nonsingular (const double x)
{
  return cast_to_double ((x == 0) ? 1.0e-30 : x);
}

static inline double
sign (const double x)
{
  return cast_to_double ((x > 0) ? +1 : (x < 0) ? -1 : 0);
}


/* Octave functions */
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == OCTAVEDLD))
#ifdef __cplusplus
static Matrix
ones (const int r = 1, const int c = 1)
{
  Matrix m (r, c, 1.0);
  return m;
}

static ColumnVector
nozeros (const ColumnVector v0, const double tol = 0.0)
{
  ColumnVector v (v0.length ());
  register int i, j;
  for (i = j = 0; i < v.length (); i++)
    if (tol < std::abs (v0 (i)))
      {
	v (j) = v0 (i);
	j++;
      }
  if (0 == j)
    {
      return *new ColumnVector ();
    }
  else
    {
      return (v.extract (0, --j));
    }
}

static ColumnVector
zeros (const int r)
{
  ColumnVector v (r, 0.0);
  return v;
}

static Matrix
zeros (const int r, const int c)
{
  Matrix m (r, c, 0.0);
  return m;
}
#endif /* __cplusplus */
#endif /* ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == OCTAVEDLD)) */



#endif /* HAVE_USEFUL_FUNCTIONS_HH */

Deleted mttroot/mtt/cc/mtt_m2cc.sh version [d022332fbb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213





















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

SYS=$1
REP=$2
TARGET=${3:-cc}
PARSER=${4:-indent}

IN=${SYS}_${REP}.m
OUT=${SYS}_${REP}.${TARGET}
TMP=${SYS}_${REP}_m2cc.tmp

rep_declarations ()
{
(case ${REP} in
    simpar)
	cat <<EOF
  struct {
    double first;
    double dt;
    double last;
    int    stepfactor;
    int    wmin;
    int    wmax;
    int    wsteps;
    int    input;
  } mttsimpar;

EOF
	;;
    *)
	;;
esac)
echo ""
};

rep_footer ()
{
(case ${REP} in
    simpar)
	cat <<EOF
  mttsimpar_map(0)	= (double) mttsimpar.first;
  mttsimpar_map(1)	= (double) mttsimpar.last;
  mttsimpar_map(2)	= (double) mttsimpar.dt;
  mttsimpar_map(3)	= (double) mttsimpar.stepfactor;
  mttsimpar_map(4)	= (double) mttsimpar.wmin;
  mttsimpar_map(5)	= (double) mttsimpar.wmax;
  mttsimpar_map(6)	= (double) mttsimpar.wsteps;
  mttsimpar_map(7)	= (double) mttsimpar.input;
EOF
	;;
    *)
	;;
esac)
};

find_code ()
{
    file_in=${1:-${IN}}
    portion=${2:-"body"}
    head=`cat ${file_in} | gawk '($2 == "BEGIN" && $3 == "Code") { print NR }'`
    foot=`cat ${file_in} | gawk '($2 == "END"   && $3 == "Code") { print NR }'`
    case ${portion} in
	head)
	    start=0
	    end=${head}
	    ;;
	body)
	    start=${head}
	    end=${foot}
	    ;;
	foot)
	    start=${foot}
	    end=end
	    ;;
	*)
	    echo "Error in find_code: portion unknown"
	    return -1
	    ;;
    esac
    cat ${file_in} |\
    gawk --assign start=${start} --assign end=${end} '
	(start < NR && NR < end) { print $0 }'
};


strip_junk ()
{
case ${REP} in
    numpar)
	grep -v "mttpar = \[\]"
	;;
    switchopen)
	grep -v "\[open\] = zero"
	;;
    *)
	cat
	;;
esac
};

fix_comment_delimiter ()
{
    language=${1:-cc}
    case $language in
    # it would be preferable if we didn't use '%' as a delimiter
    # (a % b) gives the remainder of ((int)a / (int)b) in C/C++
	c)
	    sed 's/[%#]\(.*\)/\/* \1 *\//'
	    ;;
	cc | *)
	    sed 's/[%#]/\/\//g' | sed 's/\/\/\/\//\/\//g'
	    ;;
    esac
};

decrement_indices ()
{    
    # first section appends '-1' to container indices
    # to convert from FORTRAN-type numbering to C-type numbering
    # and C-type indices () to FORTRAN-type []
    sed 's/mtta(\([0-9][0-9]*\),\([0-9][0-9]*\))/mtta[\1-1,\2-1]/g'	|\
    sed 's/mttax(\([0-9][0-9]*\))/mttax[\1-1]/g'			|\
    sed 's/mttdx(\([0-9][0-9]*\))/mttdx[\1-1]/g'			|\
    sed 's/mttedx(\([0-9][0-9]*\))/mttedx[\1-1]/g'			|\
    sed 's/mttpar(\([0-9][0-9]*\))/mttpar[\1-1]/g'			|\
    sed 's/mttu(\([0-9][0-9]*\))/mttu[\1-1]/g'				|\
    sed 's/mttx(\([0-9][0-9]*\))/mttx[\1-1]/g'				|\
    sed 's/mtty(\([0-9][0-9]*\))/mtty[\1-1]/g'				|\
    sed 's/mttyz(\([0-9][0-9]*\))/mttyz[\1-1]/g'			|\
    sed 's/mttz(\([0-9][0-9]*\))/mttz[\1-1]/g'				|\
    sed 's/mttopen(\([0-9][0-9]*\))/mttopen[\1-1]/g'				|\
									 \
    # next sections tidy the code up a bit, but are not necessary
    sed 's/1\-1\([],]\)/0\1/g'       			       		|\
    sed 's/2\-1\([],]\)/1\1/g'       			       		|\
    sed 's/3\-1\([],]\)/2\1/g'       			       		|\
    sed 's/4\-1\([],]\)/3\1/g'       			       		|\
    sed 's/5\-1\([],]\)/4\1/g'       			       		|\
    sed 's/6\-1\([],]\)/5\1/g'       			       		|\
    sed 's/7\-1\([],]\)/6\1/g'       			       		|\
    sed 's/8\-1\([],]\)/7\1/g'       			       		|\
    sed 's/9\-1\([],]\)/8\1/g'       			       		|\
									 \
    sed 's/\([0-9]\)10\-1\([],]\)/\109\2/g'		       		|\
    sed 's/10\-1\([],]\)/9\1/g'     			       		|\
    sed 's/20\-1\([],]\)/19\1/g'	       		       		|\
    sed 's/30\-1\([],]\)/29\1/g'		       	       		|\
    sed 's/40\-1\([],]\)/39\1/g'			       		|\
    sed 's/50\-1\([],]\)/49\1/g'		               		|\
    sed 's/60\-1\([],]\)/59\1/g'		      	       		|\
    sed 's/70\-1\([],]\)/69\1/g'		       	       		|\
    sed 's/80\-1\([],]\)/79\1/g'		       	       		|\
    sed 's/90\-1\([],]\)/89\1/g'		       	       		|\
									 \
    sed 's/\([0-9]\)100\-1\([],]\)/\199\2/g'		       		|\
    sed 's/100\-1\([],]\)/99\1/g'   			       		|\
    sed 's/200\-1\([],]\)/199\1/g'	       		       		|\
    sed 's/300\-1\([],]\)/299\1/g'		       	       		|\
    sed 's/400\-1\([],]\)/399\1/g'			       		|\
    sed 's/500\-1\([],]\)/499\1/g'			       		|\
    sed 's/600\-1\([],]\)/599\1/g'			       		|\
    sed 's/700\-1\([],]\)/699\1/g'			       	       	|\
    sed 's/800\-1\([],]\)/799\1/g'			       		|\
    sed 's/900\-1\([],]\)/899\1/g'			       		|\
    sed 's/\([(,]\)0\([0-9]\)/\1\2/g'
};

c_to_fortran_paren ()
{
    tr "[]" "()"
}
	
fix_pow ()
{
    # matches number^number where number is one or more digits and one or zero decimal points
    # converts to pow (number, number)
    sed 's/\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)\^\([0-9]*\)\(\.\)\{0,1\}\([0-9]*\)/pow \(\1\2\3,\4\5\6\)/g'
};


echo Creating ${OUT}

case ${TARGET} in
    c)
	mtt_header ${SYS} ${REP} "c"	>  ${TMP}
	find_code ${TMP} head		>  ${OUT}
	find_code ${IN} body		|\
	    decrement_indices		|\
	    fix_comment_delimiter c	|\
	    fix_pow			|\
	    strip_junk			|\
	    ${PARSER}			>> ${OUT}
	find_code ${TMP} foot		>> ${OUT}
	rm ${TMP}
	;;
    cc | *)
	mtt_header ${SYS} ${REP} "oct"	>  ${TMP}
	find_code ${TMP} head		>  ${OUT}
	rep_declarations		>> ${OUT}
	find_code ${IN} body   		|\
	    decrement_indices		|\
	    c_to_fortran_paren		|\
	    fix_comment_delimiter cc	|\
	    fix_pow			|\
	    strip_junk			|\
	    ${PARSER}			>> ${OUT}
	rep_footer			>> ${OUT}
	find_code ${TMP} foot		>> ${OUT}
	rm ${TMP}
	;;
esac


Deleted mttroot/mtt/cc/parse_m2cc.cc version [b1b04bdad9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392








































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* $Id$
 * $Log$
 * Revision 1.4  2002/05/01 12:54:55  geraint
 * Now recognises keywords terminated with ; as well as ws.
 * Now recognises # as a comment when not terminated by ws.
 * i.e. CarnotCycle_input.txt now gets translated correctly!
 *
 * Revision 1.3  2001/07/13 04:54:04  geraint
 * Branch merge: numerical-algebraic-solution back to main.
 *
 * Revision 1.2.2.1  2001/06/30 03:26:17  geraint
 * gcc-3.0 compatibility.
 *
 * Revision 1.2  2001/03/19 02:28:53  geraint
 * Branch merge: merging-ode2odes-exe back to MAIN.
 *
 * Revision 1.1.2.2  2001/03/09 04:01:20  geraint
 * \ escapes newline.
 *
 * Revision 1.1.2.1  2001/03/09 02:59:26  geraint
 * got_comment: (char)c no longer compared to (int)EOF.
 *
 * Revision 1.1  2000/12/28 09:46:05  peterg
 * put under RCS
 *
 * Revision 1.1  2000/10/31 04:29:50  geraint
 * Initial revision
 *
 */


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <stack>
#include <string>



/*
 * Bracket.hh deals with nesting levels of parenthesis
 * just add Bracket pointer to string / stream
 */
#include "Bracket.hh"



using namespace std;

/*
 * use lbrace, etc. in expressions to automate nesting calculations
 */
LeftBrace	*lbrace = new LeftBrace;
RightBrace	*rbrace = new RightBrace;

LeftParen	*lparen = new LeftParen;
RightParen	*rparen = new RightParen;



/*
 * use brace nesting depth to determine indentation
 */
string indent (void) { return lbrace->indentation (); }



/*
 * map contains keyword to look for and function to call when found
 */
map <string, void (*)(void)> keyword;




/*
 * stack records current nest type
 * so that "end" can be handled correctly
 */
enum nest_type
{
  null,
  if_statement,
  switch_statement,
  while_statement
};

stack <enum nest_type> current_nest;



/*
 * assuming cin has '(' as next character
 * find the matching ')' and return the string contained within
 */
string get_test (void)
{
  const int entry_nesting = lparen->get_nesting_depth ();
  char c;
  string buf = "";
  cin.setf (ios::skipws);
  cin >> c;
  if ('(' != c)
    {
      cerr << "Sorry, test must be enclosed in ( )" << endl;
      cerr << "current character is " << c << endl;
      /*
       * replace this with a call to get_expression maybe?
       */
      exit (-1);
    }
  else
    {
      buf += lparen;
    }
  cin.unsetf (ios::skipws);
  while (entry_nesting != lparen->get_nesting_depth ()) {
    cin >> c;
    switch (c)
      {	
      case '(':
	buf += lparen;
	break;
      case ')':
	buf += rparen;
	break;
      case EOF:
	cerr << "Oops! EOF reached" << endl;
	exit (-1);
      default:
	buf += c;
	break;
      }
  }
  return buf;
}



/*
 * functions to be called upon detection of keyword
 */
void got_if (void)
{
  current_nest.push (if_statement);
  cout << "if ";
  cout << get_test ();
  cout << lbrace;
}

void got_else (void)
{
  cout << rbrace;
  cout << "else";
  cout << lbrace;
}

void got_elseif (void)
{
  cout << rbrace;
  got_if ();
} 

void got_switch (void)
{
  current_nest.push (switch_statement);
  cout << "switch ";
  cout << get_test ();
  cout << lbrace;
  /*
   * open a second brace so that each "case" can be enclosed
   */
  cout << lbrace;
}

void got_case (void)
{
  cout << rbrace;
  cout << "case ";
  cout << get_test ();
  cout << ':';
  cout << lbrace;
}

void got_otherwise (void)
{
  cout << rbrace;
  cout << "default:";
  cout << lbrace;
}

void got_while (void)
{
  current_nest.push (while_statement);
  cout << "while ";
  cout << get_test ();
  cout << lbrace;
}

void got_end (void)
{
  enum nest_type n = current_nest.top ();
  switch (n)
    {
    case if_statement:
    case while_statement:
      cout << rbrace;      
      break;
    case switch_statement:
      cout << rbrace
	   << rbrace;
      break;
    default:
      cerr << "Oops! Unmatched end ... aborting" << endl;
      exit (-1);
      break;
    }
  current_nest.pop ();
}

void got_comment (void)
{
  /*
   * get remainder of line in case there are any commented keywords
   */
  char c;
  cout << " // ";
  cin >> c;
  do {
    cout << c;
  } while (c != '\n' && cin >> c);
  cout << endl
       << indent () << ';' << endl
       << indent ();
}
  


/*
 * map contains keyword to look for and functions to call when found
 * functions must be of the form "void f (void) {...;}"
 * new structures should also be added to enum nest_type
 */
void set_keyword (void)
{
  // if
  keyword ["if"]		= got_if;
  keyword ["else"]		= got_else;
  keyword ["elseif"]		= got_elseif;
  keyword ["endif"]		= got_end;

  // switch
  keyword ["switch"]		= got_switch;
  keyword ["case"]		= got_case;
  keyword ["otherwise"] 	= got_otherwise;
  keyword ["endswitch"] 	= got_end;

  // while
  keyword ["while"]		= got_while;
  keyword ["endwhile"]		= got_end;

  // general
  keyword ["end"]		= got_end;

  /*
   * this won't work inside a string
   * or if there is no space around the delimiter
   */
  keyword ["#"]			= got_comment;
  keyword ["//"]		= got_comment;
  
/*
 * unimplemented keywords
 *
 keyword ["for"]		= got_for;
 keyword ["endfor"]		= got_end;
 keyword ["break"]		= got_break;
 keyword ["continue"]		= got_continue;
*/
}



/* read in one character at a time looking for tokens (delimited by whitespace)
 * if the token is a keyword, call the appropriate function
 */
int main (void)
{
  set_keyword ();
  string buf = "";
  char c;
  cin.unsetf (ios::skipws);
  while (cin >> c)
    {
      switch (c)
	{
	case EOF:
	  return 0;
	case ' ':
	case '\t':
	  if (keyword [buf])
	    {
	      keyword [buf]();
	    }
	  else
	    {
	      if (! lbrace->get_nesting_depth ())
		{
		  buf += c;
		}
	      cout << buf;
	    }
	  buf = "";
	  break;
	case ';':
	case '\n':
	  if (keyword [buf])
	    {
	      /*
	       * keyword found, call function
	       */
	      keyword [buf] ();
	    }
	  else
	    {
	      cout << buf
		/*
		 * keep newline in case this line has an EOL-comment
		 */
		   << endl
		/*
		 * EOL is end-of-statement in Octave, add ;
		 */
		   << indent () << ';' << endl
		   << indent ();
	    }
	  buf = "";
	  break;
	case '#':
	  if (keyword [buf])
	    {
	      /*
	       * keyword found, call function
	       */
	      keyword [buf] ();
	    }
	  else
	    {
	      cout << buf
		/*
		 * keep newline in case this line has an EOL-comment
		 */
		   << endl
		/*
		 * EOL is end-of-statement in Octave, add ;
		 */
		   << indent () << ';' << endl
		   << indent ();
	    }
	  keyword ["#"] ();
	  buf = "";
	  break;

	case '\\':
	  cin >> c;
	  if ('\n' == c)
	    {
	      buf += '\n';
	    }
	  else
	    {
	      buf += '\\';
	      buf += c;
	    }
	  break;
	default:
	  buf += c;
	}
      if (lbrace->get_nesting_depth ())
	{
	  cout.setf (ios::skipws);
	}
      else
	{
	  cout.unsetf (ios::skipws);
	}
    }
  return 0;
}


Deleted mttroot/mtt/cc/sympar_txt2h.sh version [b45a52ff91].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# $Id$
# $Log$
# Revision 1.9  2004/08/29 03:18:11  geraint
# Do not write temporary variables if NUM_OF_TMP_VAR = 0.
#
# Revision 1.8  2002/09/16 08:08:01  geraint
# Merged changes from global-optimisation branch.
#
# Revision 1.7.2.1  2002/09/04 10:44:59  geraint
# Added option to specify number of tmp variables declared (-ntmpvar <N>).
#
# Revision 1.7  2002/07/10 11:53:32  geraint
# Replaced shell loop with template expansion - perceptibly quicker generation of sympar.h.
#
# Revision 1.6  2002/05/19 13:01:22  geraint
# Numerical solution of algebraic equations implemented for S-function target.
#
# Equation solving requires the Matlab Optimization Toolbox to be installed.
#
# Code has been changed from C++ to C to allow mex files to be built with LCC,
# the compiler bundled with Matlab.
#
# Parameters are now obtained from numpar.c instead of a dialogue box.
#
# `mtt <sys> sfun zip` creates all necessary files for building the model mex files.
#
# Revision 1.5  2002/04/28 18:58:06  geraint
# Fixed [ 549658 ] awk should be gawk.
# Replaced calls to awk with call to gawk.
#
# Revision 1.4  2001/08/24 21:41:04  geraint
# Fixed problem with declaration when there are no numerical parameters.
#
# Revision 1.3  2001/03/19 02:28:53  geraint
# Branch merge: merging-ode2odes-exe back to MAIN.
#
# Revision 1.2.2.1  2001/03/16 03:56:54  geraint
# Convert variable names to lower case.
#
# Revision 1.2  2001/02/05 13:03:19  geraint
# Restrict scope of variables to file (static).
# Warn GCC that variables may be unused.
#
# Revision 1.7  2001/01/09 15:43:50  geraint
# Warn gcc that variables may be unused.
#
# Revision 1.6  2001/01/08 05:47:56  geraint
# Restrict scope of variables to file (static)
#
# Revision 1.5  2000/12/05 12:44:55  peterg
# Changed $() to ``
#
# Revision 1.4  2000/12/05 12:16:02  peterg
# Changed function name to name()
#
# Revision 1.3  2000/12/04 11:05:01  peterg
# Removed () -- geraint
#
# Revision 1.2  2000/11/07 17:29:27  peterg
# Changed echo
#
# Revision 1.1  2000/11/07 17:28:53  peterg
# Initial revision
#
# Revision 1.1  2000/10/31 04:32:02  geraint
# Initial revision
#

SYS=$1

if [ $# -gt 1 ]
then
  NUM_OF_TMP_VAR=$2;
  shift; shift;
else
  NUM_OF_TMP_VAR=500
  shift;
fi
TMP_VAR_NAMES="mtt_tmp mtt_o $*"

IN=${SYS}_sympar.txt
OUT=${SYS}_sympar.h

declare_sys_param ()
{
cat ${IN} | gawk '(NF>0){printf ("static double %s MTT_UNUSED;\t/* %s\t*/\n", tolower($1), $2)}'
}

declare_temp_vars ()
{
for name in ${TMP_VAR_NAMES}
do
    echo ""

    cat <<EOF | head -$(expr ${NUM_OF_TMP_VAR} + 1)
static double ${name}0 MTT_UNUSED;
static double ${name}1 MTT_UNUSED;
static double ${name}2 MTT_UNUSED;
static double ${name}3 MTT_UNUSED;
static double ${name}4 MTT_UNUSED;
static double ${name}5 MTT_UNUSED;
static double ${name}6 MTT_UNUSED;
static double ${name}7 MTT_UNUSED;
static double ${name}8 MTT_UNUSED;
static double ${name}9 MTT_UNUSED;
static double ${name}10 MTT_UNUSED;
static double ${name}11 MTT_UNUSED;
static double ${name}12 MTT_UNUSED;
static double ${name}13 MTT_UNUSED;
static double ${name}14 MTT_UNUSED;
static double ${name}15 MTT_UNUSED;
static double ${name}16 MTT_UNUSED;
static double ${name}17 MTT_UNUSED;
static double ${name}18 MTT_UNUSED;
static double ${name}19 MTT_UNUSED;
static double ${name}20 MTT_UNUSED;
static double ${name}21 MTT_UNUSED;
static double ${name}22 MTT_UNUSED;
static double ${name}23 MTT_UNUSED;
static double ${name}24 MTT_UNUSED;
static double ${name}25 MTT_UNUSED;
static double ${name}26 MTT_UNUSED;
static double ${name}27 MTT_UNUSED;
static double ${name}28 MTT_UNUSED;
static double ${name}29 MTT_UNUSED;
static double ${name}30 MTT_UNUSED;
static double ${name}31 MTT_UNUSED;
static double ${name}32 MTT_UNUSED;
static double ${name}33 MTT_UNUSED;
static double ${name}34 MTT_UNUSED;
static double ${name}35 MTT_UNUSED;
static double ${name}36 MTT_UNUSED;
static double ${name}37 MTT_UNUSED;
static double ${name}38 MTT_UNUSED;
static double ${name}39 MTT_UNUSED;
static double ${name}40 MTT_UNUSED;
static double ${name}41 MTT_UNUSED;
static double ${name}42 MTT_UNUSED;
static double ${name}43 MTT_UNUSED;
static double ${name}44 MTT_UNUSED;
static double ${name}45 MTT_UNUSED;
static double ${name}46 MTT_UNUSED;
static double ${name}47 MTT_UNUSED;
static double ${name}48 MTT_UNUSED;
static double ${name}49 MTT_UNUSED;
static double ${name}50 MTT_UNUSED;
static double ${name}51 MTT_UNUSED;
static double ${name}52 MTT_UNUSED;
static double ${name}53 MTT_UNUSED;
static double ${name}54 MTT_UNUSED;
static double ${name}55 MTT_UNUSED;
static double ${name}56 MTT_UNUSED;
static double ${name}57 MTT_UNUSED;
static double ${name}58 MTT_UNUSED;
static double ${name}59 MTT_UNUSED;
static double ${name}60 MTT_UNUSED;
static double ${name}61 MTT_UNUSED;
static double ${name}62 MTT_UNUSED;
static double ${name}63 MTT_UNUSED;
static double ${name}64 MTT_UNUSED;
static double ${name}65 MTT_UNUSED;
static double ${name}66 MTT_UNUSED;
static double ${name}67 MTT_UNUSED;
static double ${name}68 MTT_UNUSED;
static double ${name}69 MTT_UNUSED;
static double ${name}70 MTT_UNUSED;
static double ${name}71 MTT_UNUSED;
static double ${name}72 MTT_UNUSED;
static double ${name}73 MTT_UNUSED;
static double ${name}74 MTT_UNUSED;
static double ${name}75 MTT_UNUSED;
static double ${name}76 MTT_UNUSED;
static double ${name}77 MTT_UNUSED;
static double ${name}78 MTT_UNUSED;
static double ${name}79 MTT_UNUSED;
static double ${name}80 MTT_UNUSED;
static double ${name}81 MTT_UNUSED;
static double ${name}82 MTT_UNUSED;
static double ${name}83 MTT_UNUSED;
static double ${name}84 MTT_UNUSED;
static double ${name}85 MTT_UNUSED;
static double ${name}86 MTT_UNUSED;
static double ${name}87 MTT_UNUSED;
static double ${name}88 MTT_UNUSED;
static double ${name}89 MTT_UNUSED;
static double ${name}90 MTT_UNUSED;
static double ${name}91 MTT_UNUSED;
static double ${name}92 MTT_UNUSED;
static double ${name}93 MTT_UNUSED;
static double ${name}94 MTT_UNUSED;
static double ${name}95 MTT_UNUSED;
static double ${name}96 MTT_UNUSED;
static double ${name}97 MTT_UNUSED;
static double ${name}98 MTT_UNUSED;
static double ${name}99 MTT_UNUSED;
static double ${name}100 MTT_UNUSED;
static double ${name}101 MTT_UNUSED;
static double ${name}102 MTT_UNUSED;
static double ${name}103 MTT_UNUSED;
static double ${name}104 MTT_UNUSED;
static double ${name}105 MTT_UNUSED;
static double ${name}106 MTT_UNUSED;
static double ${name}107 MTT_UNUSED;
static double ${name}108 MTT_UNUSED;
static double ${name}109 MTT_UNUSED;
static double ${name}110 MTT_UNUSED;
static double ${name}111 MTT_UNUSED;
static double ${name}112 MTT_UNUSED;
static double ${name}113 MTT_UNUSED;
static double ${name}114 MTT_UNUSED;
static double ${name}115 MTT_UNUSED;
static double ${name}116 MTT_UNUSED;
static double ${name}117 MTT_UNUSED;
static double ${name}118 MTT_UNUSED;
static double ${name}119 MTT_UNUSED;
static double ${name}120 MTT_UNUSED;
static double ${name}121 MTT_UNUSED;
static double ${name}122 MTT_UNUSED;
static double ${name}123 MTT_UNUSED;
static double ${name}124 MTT_UNUSED;
static double ${name}125 MTT_UNUSED;
static double ${name}126 MTT_UNUSED;
static double ${name}127 MTT_UNUSED;
static double ${name}128 MTT_UNUSED;
static double ${name}129 MTT_UNUSED;
static double ${name}130 MTT_UNUSED;
static double ${name}131 MTT_UNUSED;
static double ${name}132 MTT_UNUSED;
static double ${name}133 MTT_UNUSED;
static double ${name}134 MTT_UNUSED;
static double ${name}135 MTT_UNUSED;
static double ${name}136 MTT_UNUSED;
static double ${name}137 MTT_UNUSED;
static double ${name}138 MTT_UNUSED;
static double ${name}139 MTT_UNUSED;
static double ${name}140 MTT_UNUSED;
static double ${name}141 MTT_UNUSED;
static double ${name}142 MTT_UNUSED;
static double ${name}143 MTT_UNUSED;
static double ${name}144 MTT_UNUSED;
static double ${name}145 MTT_UNUSED;
static double ${name}146 MTT_UNUSED;
static double ${name}147 MTT_UNUSED;
static double ${name}148 MTT_UNUSED;
static double ${name}149 MTT_UNUSED;
static double ${name}150 MTT_UNUSED;
static double ${name}151 MTT_UNUSED;
static double ${name}152 MTT_UNUSED;
static double ${name}153 MTT_UNUSED;
static double ${name}154 MTT_UNUSED;
static double ${name}155 MTT_UNUSED;
static double ${name}156 MTT_UNUSED;
static double ${name}157 MTT_UNUSED;
static double ${name}158 MTT_UNUSED;
static double ${name}159 MTT_UNUSED;
static double ${name}160 MTT_UNUSED;
static double ${name}161 MTT_UNUSED;
static double ${name}162 MTT_UNUSED;
static double ${name}163 MTT_UNUSED;
static double ${name}164 MTT_UNUSED;
static double ${name}165 MTT_UNUSED;
static double ${name}166 MTT_UNUSED;
static double ${name}167 MTT_UNUSED;
static double ${name}168 MTT_UNUSED;
static double ${name}169 MTT_UNUSED;
static double ${name}170 MTT_UNUSED;
static double ${name}171 MTT_UNUSED;
static double ${name}172 MTT_UNUSED;
static double ${name}173 MTT_UNUSED;
static double ${name}174 MTT_UNUSED;
static double ${name}175 MTT_UNUSED;
static double ${name}176 MTT_UNUSED;
static double ${name}177 MTT_UNUSED;
static double ${name}178 MTT_UNUSED;
static double ${name}179 MTT_UNUSED;
static double ${name}180 MTT_UNUSED;
static double ${name}181 MTT_UNUSED;
static double ${name}182 MTT_UNUSED;
static double ${name}183 MTT_UNUSED;
static double ${name}184 MTT_UNUSED;
static double ${name}185 MTT_UNUSED;
static double ${name}186 MTT_UNUSED;
static double ${name}187 MTT_UNUSED;
static double ${name}188 MTT_UNUSED;
static double ${name}189 MTT_UNUSED;
static double ${name}190 MTT_UNUSED;
static double ${name}191 MTT_UNUSED;
static double ${name}192 MTT_UNUSED;
static double ${name}193 MTT_UNUSED;
static double ${name}194 MTT_UNUSED;
static double ${name}195 MTT_UNUSED;
static double ${name}196 MTT_UNUSED;
static double ${name}197 MTT_UNUSED;
static double ${name}198 MTT_UNUSED;
static double ${name}199 MTT_UNUSED;
static double ${name}200 MTT_UNUSED;
static double ${name}201 MTT_UNUSED;
static double ${name}202 MTT_UNUSED;
static double ${name}203 MTT_UNUSED;
static double ${name}204 MTT_UNUSED;
static double ${name}205 MTT_UNUSED;
static double ${name}206 MTT_UNUSED;
static double ${name}207 MTT_UNUSED;
static double ${name}208 MTT_UNUSED;
static double ${name}209 MTT_UNUSED;
static double ${name}210 MTT_UNUSED;
static double ${name}211 MTT_UNUSED;
static double ${name}212 MTT_UNUSED;
static double ${name}213 MTT_UNUSED;
static double ${name}214 MTT_UNUSED;
static double ${name}215 MTT_UNUSED;
static double ${name}216 MTT_UNUSED;
static double ${name}217 MTT_UNUSED;
static double ${name}218 MTT_UNUSED;
static double ${name}219 MTT_UNUSED;
static double ${name}220 MTT_UNUSED;
static double ${name}221 MTT_UNUSED;
static double ${name}222 MTT_UNUSED;
static double ${name}223 MTT_UNUSED;
static double ${name}224 MTT_UNUSED;
static double ${name}225 MTT_UNUSED;
static double ${name}226 MTT_UNUSED;
static double ${name}227 MTT_UNUSED;
static double ${name}228 MTT_UNUSED;
static double ${name}229 MTT_UNUSED;
static double ${name}230 MTT_UNUSED;
static double ${name}231 MTT_UNUSED;
static double ${name}232 MTT_UNUSED;
static double ${name}233 MTT_UNUSED;
static double ${name}234 MTT_UNUSED;
static double ${name}235 MTT_UNUSED;
static double ${name}236 MTT_UNUSED;
static double ${name}237 MTT_UNUSED;
static double ${name}238 MTT_UNUSED;
static double ${name}239 MTT_UNUSED;
static double ${name}240 MTT_UNUSED;
static double ${name}241 MTT_UNUSED;
static double ${name}242 MTT_UNUSED;
static double ${name}243 MTT_UNUSED;
static double ${name}244 MTT_UNUSED;
static double ${name}245 MTT_UNUSED;
static double ${name}246 MTT_UNUSED;
static double ${name}247 MTT_UNUSED;
static double ${name}248 MTT_UNUSED;
static double ${name}249 MTT_UNUSED;
static double ${name}250 MTT_UNUSED;
static double ${name}251 MTT_UNUSED;
static double ${name}252 MTT_UNUSED;
static double ${name}253 MTT_UNUSED;
static double ${name}254 MTT_UNUSED;
static double ${name}255 MTT_UNUSED;
static double ${name}256 MTT_UNUSED;
static double ${name}257 MTT_UNUSED;
static double ${name}258 MTT_UNUSED;
static double ${name}259 MTT_UNUSED;
static double ${name}260 MTT_UNUSED;
static double ${name}261 MTT_UNUSED;
static double ${name}262 MTT_UNUSED;
static double ${name}263 MTT_UNUSED;
static double ${name}264 MTT_UNUSED;
static double ${name}265 MTT_UNUSED;
static double ${name}266 MTT_UNUSED;
static double ${name}267 MTT_UNUSED;
static double ${name}268 MTT_UNUSED;
static double ${name}269 MTT_UNUSED;
static double ${name}270 MTT_UNUSED;
static double ${name}271 MTT_UNUSED;
static double ${name}272 MTT_UNUSED;
static double ${name}273 MTT_UNUSED;
static double ${name}274 MTT_UNUSED;
static double ${name}275 MTT_UNUSED;
static double ${name}276 MTT_UNUSED;
static double ${name}277 MTT_UNUSED;
static double ${name}278 MTT_UNUSED;
static double ${name}279 MTT_UNUSED;
static double ${name}280 MTT_UNUSED;
static double ${name}281 MTT_UNUSED;
static double ${name}282 MTT_UNUSED;
static double ${name}283 MTT_UNUSED;
static double ${name}284 MTT_UNUSED;
static double ${name}285 MTT_UNUSED;
static double ${name}286 MTT_UNUSED;
static double ${name}287 MTT_UNUSED;
static double ${name}288 MTT_UNUSED;
static double ${name}289 MTT_UNUSED;
static double ${name}290 MTT_UNUSED;
static double ${name}291 MTT_UNUSED;
static double ${name}292 MTT_UNUSED;
static double ${name}293 MTT_UNUSED;
static double ${name}294 MTT_UNUSED;
static double ${name}295 MTT_UNUSED;
static double ${name}296 MTT_UNUSED;
static double ${name}297 MTT_UNUSED;
static double ${name}298 MTT_UNUSED;
static double ${name}299 MTT_UNUSED;
static double ${name}300 MTT_UNUSED;
static double ${name}301 MTT_UNUSED;
static double ${name}302 MTT_UNUSED;
static double ${name}303 MTT_UNUSED;
static double ${name}304 MTT_UNUSED;
static double ${name}305 MTT_UNUSED;
static double ${name}306 MTT_UNUSED;
static double ${name}307 MTT_UNUSED;
static double ${name}308 MTT_UNUSED;
static double ${name}309 MTT_UNUSED;
static double ${name}310 MTT_UNUSED;
static double ${name}311 MTT_UNUSED;
static double ${name}312 MTT_UNUSED;
static double ${name}313 MTT_UNUSED;
static double ${name}314 MTT_UNUSED;
static double ${name}315 MTT_UNUSED;
static double ${name}316 MTT_UNUSED;
static double ${name}317 MTT_UNUSED;
static double ${name}318 MTT_UNUSED;
static double ${name}319 MTT_UNUSED;
static double ${name}320 MTT_UNUSED;
static double ${name}321 MTT_UNUSED;
static double ${name}322 MTT_UNUSED;
static double ${name}323 MTT_UNUSED;
static double ${name}324 MTT_UNUSED;
static double ${name}325 MTT_UNUSED;
static double ${name}326 MTT_UNUSED;
static double ${name}327 MTT_UNUSED;
static double ${name}328 MTT_UNUSED;
static double ${name}329 MTT_UNUSED;
static double ${name}330 MTT_UNUSED;
static double ${name}331 MTT_UNUSED;
static double ${name}332 MTT_UNUSED;
static double ${name}333 MTT_UNUSED;
static double ${name}334 MTT_UNUSED;
static double ${name}335 MTT_UNUSED;
static double ${name}336 MTT_UNUSED;
static double ${name}337 MTT_UNUSED;
static double ${name}338 MTT_UNUSED;
static double ${name}339 MTT_UNUSED;
static double ${name}340 MTT_UNUSED;
static double ${name}341 MTT_UNUSED;
static double ${name}342 MTT_UNUSED;
static double ${name}343 MTT_UNUSED;
static double ${name}344 MTT_UNUSED;
static double ${name}345 MTT_UNUSED;
static double ${name}346 MTT_UNUSED;
static double ${name}347 MTT_UNUSED;
static double ${name}348 MTT_UNUSED;
static double ${name}349 MTT_UNUSED;
static double ${name}350 MTT_UNUSED;
static double ${name}351 MTT_UNUSED;
static double ${name}352 MTT_UNUSED;
static double ${name}353 MTT_UNUSED;
static double ${name}354 MTT_UNUSED;
static double ${name}355 MTT_UNUSED;
static double ${name}356 MTT_UNUSED;
static double ${name}357 MTT_UNUSED;
static double ${name}358 MTT_UNUSED;
static double ${name}359 MTT_UNUSED;
static double ${name}360 MTT_UNUSED;
static double ${name}361 MTT_UNUSED;
static double ${name}362 MTT_UNUSED;
static double ${name}363 MTT_UNUSED;
static double ${name}364 MTT_UNUSED;
static double ${name}365 MTT_UNUSED;
static double ${name}366 MTT_UNUSED;
static double ${name}367 MTT_UNUSED;
static double ${name}368 MTT_UNUSED;
static double ${name}369 MTT_UNUSED;
static double ${name}370 MTT_UNUSED;
static double ${name}371 MTT_UNUSED;
static double ${name}372 MTT_UNUSED;
static double ${name}373 MTT_UNUSED;
static double ${name}374 MTT_UNUSED;
static double ${name}375 MTT_UNUSED;
static double ${name}376 MTT_UNUSED;
static double ${name}377 MTT_UNUSED;
static double ${name}378 MTT_UNUSED;
static double ${name}379 MTT_UNUSED;
static double ${name}380 MTT_UNUSED;
static double ${name}381 MTT_UNUSED;
static double ${name}382 MTT_UNUSED;
static double ${name}383 MTT_UNUSED;
static double ${name}384 MTT_UNUSED;
static double ${name}385 MTT_UNUSED;
static double ${name}386 MTT_UNUSED;
static double ${name}387 MTT_UNUSED;
static double ${name}388 MTT_UNUSED;
static double ${name}389 MTT_UNUSED;
static double ${name}390 MTT_UNUSED;
static double ${name}391 MTT_UNUSED;
static double ${name}392 MTT_UNUSED;
static double ${name}393 MTT_UNUSED;
static double ${name}394 MTT_UNUSED;
static double ${name}395 MTT_UNUSED;
static double ${name}396 MTT_UNUSED;
static double ${name}397 MTT_UNUSED;
static double ${name}398 MTT_UNUSED;
static double ${name}399 MTT_UNUSED;
static double ${name}400 MTT_UNUSED;
static double ${name}401 MTT_UNUSED;
static double ${name}402 MTT_UNUSED;
static double ${name}403 MTT_UNUSED;
static double ${name}404 MTT_UNUSED;
static double ${name}405 MTT_UNUSED;
static double ${name}406 MTT_UNUSED;
static double ${name}407 MTT_UNUSED;
static double ${name}408 MTT_UNUSED;
static double ${name}409 MTT_UNUSED;
static double ${name}410 MTT_UNUSED;
static double ${name}411 MTT_UNUSED;
static double ${name}412 MTT_UNUSED;
static double ${name}413 MTT_UNUSED;
static double ${name}414 MTT_UNUSED;
static double ${name}415 MTT_UNUSED;
static double ${name}416 MTT_UNUSED;
static double ${name}417 MTT_UNUSED;
static double ${name}418 MTT_UNUSED;
static double ${name}419 MTT_UNUSED;
static double ${name}420 MTT_UNUSED;
static double ${name}421 MTT_UNUSED;
static double ${name}422 MTT_UNUSED;
static double ${name}423 MTT_UNUSED;
static double ${name}424 MTT_UNUSED;
static double ${name}425 MTT_UNUSED;
static double ${name}426 MTT_UNUSED;
static double ${name}427 MTT_UNUSED;
static double ${name}428 MTT_UNUSED;
static double ${name}429 MTT_UNUSED;
static double ${name}430 MTT_UNUSED;
static double ${name}431 MTT_UNUSED;
static double ${name}432 MTT_UNUSED;
static double ${name}433 MTT_UNUSED;
static double ${name}434 MTT_UNUSED;
static double ${name}435 MTT_UNUSED;
static double ${name}436 MTT_UNUSED;
static double ${name}437 MTT_UNUSED;
static double ${name}438 MTT_UNUSED;
static double ${name}439 MTT_UNUSED;
static double ${name}440 MTT_UNUSED;
static double ${name}441 MTT_UNUSED;
static double ${name}442 MTT_UNUSED;
static double ${name}443 MTT_UNUSED;
static double ${name}444 MTT_UNUSED;
static double ${name}445 MTT_UNUSED;
static double ${name}446 MTT_UNUSED;
static double ${name}447 MTT_UNUSED;
static double ${name}448 MTT_UNUSED;
static double ${name}449 MTT_UNUSED;
static double ${name}450 MTT_UNUSED;
static double ${name}451 MTT_UNUSED;
static double ${name}452 MTT_UNUSED;
static double ${name}453 MTT_UNUSED;
static double ${name}454 MTT_UNUSED;
static double ${name}455 MTT_UNUSED;
static double ${name}456 MTT_UNUSED;
static double ${name}457 MTT_UNUSED;
static double ${name}458 MTT_UNUSED;
static double ${name}459 MTT_UNUSED;
static double ${name}460 MTT_UNUSED;
static double ${name}461 MTT_UNUSED;
static double ${name}462 MTT_UNUSED;
static double ${name}463 MTT_UNUSED;
static double ${name}464 MTT_UNUSED;
static double ${name}465 MTT_UNUSED;
static double ${name}466 MTT_UNUSED;
static double ${name}467 MTT_UNUSED;
static double ${name}468 MTT_UNUSED;
static double ${name}469 MTT_UNUSED;
static double ${name}470 MTT_UNUSED;
static double ${name}471 MTT_UNUSED;
static double ${name}472 MTT_UNUSED;
static double ${name}473 MTT_UNUSED;
static double ${name}474 MTT_UNUSED;
static double ${name}475 MTT_UNUSED;
static double ${name}476 MTT_UNUSED;
static double ${name}477 MTT_UNUSED;
static double ${name}478 MTT_UNUSED;
static double ${name}479 MTT_UNUSED;
static double ${name}480 MTT_UNUSED;
static double ${name}481 MTT_UNUSED;
static double ${name}482 MTT_UNUSED;
static double ${name}483 MTT_UNUSED;
static double ${name}484 MTT_UNUSED;
static double ${name}485 MTT_UNUSED;
static double ${name}486 MTT_UNUSED;
static double ${name}487 MTT_UNUSED;
static double ${name}488 MTT_UNUSED;
static double ${name}489 MTT_UNUSED;
static double ${name}490 MTT_UNUSED;
static double ${name}491 MTT_UNUSED;
static double ${name}492 MTT_UNUSED;
static double ${name}493 MTT_UNUSED;
static double ${name}494 MTT_UNUSED;
static double ${name}495 MTT_UNUSED;
static double ${name}496 MTT_UNUSED;
static double ${name}497 MTT_UNUSED;
static double ${name}498 MTT_UNUSED;
static double ${name}499 MTT_UNUSED;
static double ${name}500 MTT_UNUSED;
static double ${name}501 MTT_UNUSED;
static double ${name}502 MTT_UNUSED;
static double ${name}503 MTT_UNUSED;
static double ${name}504 MTT_UNUSED;
static double ${name}505 MTT_UNUSED;
static double ${name}506 MTT_UNUSED;
static double ${name}507 MTT_UNUSED;
static double ${name}508 MTT_UNUSED;
static double ${name}509 MTT_UNUSED;
static double ${name}510 MTT_UNUSED;
static double ${name}511 MTT_UNUSED;
static double ${name}512 MTT_UNUSED;
static double ${name}513 MTT_UNUSED;
static double ${name}514 MTT_UNUSED;
static double ${name}515 MTT_UNUSED;
static double ${name}516 MTT_UNUSED;
static double ${name}517 MTT_UNUSED;
static double ${name}518 MTT_UNUSED;
static double ${name}519 MTT_UNUSED;
static double ${name}520 MTT_UNUSED;
static double ${name}521 MTT_UNUSED;
static double ${name}522 MTT_UNUSED;
static double ${name}523 MTT_UNUSED;
static double ${name}524 MTT_UNUSED;
static double ${name}525 MTT_UNUSED;
static double ${name}526 MTT_UNUSED;
static double ${name}527 MTT_UNUSED;
static double ${name}528 MTT_UNUSED;
static double ${name}529 MTT_UNUSED;
static double ${name}530 MTT_UNUSED;
static double ${name}531 MTT_UNUSED;
static double ${name}532 MTT_UNUSED;
static double ${name}533 MTT_UNUSED;
static double ${name}534 MTT_UNUSED;
static double ${name}535 MTT_UNUSED;
static double ${name}536 MTT_UNUSED;
static double ${name}537 MTT_UNUSED;
static double ${name}538 MTT_UNUSED;
static double ${name}539 MTT_UNUSED;
static double ${name}540 MTT_UNUSED;
static double ${name}541 MTT_UNUSED;
static double ${name}542 MTT_UNUSED;
static double ${name}543 MTT_UNUSED;
static double ${name}544 MTT_UNUSED;
static double ${name}545 MTT_UNUSED;
static double ${name}546 MTT_UNUSED;
static double ${name}547 MTT_UNUSED;
static double ${name}548 MTT_UNUSED;
static double ${name}549 MTT_UNUSED;
static double ${name}550 MTT_UNUSED;
static double ${name}551 MTT_UNUSED;
static double ${name}552 MTT_UNUSED;
static double ${name}553 MTT_UNUSED;
static double ${name}554 MTT_UNUSED;
static double ${name}555 MTT_UNUSED;
static double ${name}556 MTT_UNUSED;
static double ${name}557 MTT_UNUSED;
static double ${name}558 MTT_UNUSED;
static double ${name}559 MTT_UNUSED;
static double ${name}560 MTT_UNUSED;
static double ${name}561 MTT_UNUSED;
static double ${name}562 MTT_UNUSED;
static double ${name}563 MTT_UNUSED;
static double ${name}564 MTT_UNUSED;
static double ${name}565 MTT_UNUSED;
static double ${name}566 MTT_UNUSED;
static double ${name}567 MTT_UNUSED;
static double ${name}568 MTT_UNUSED;
static double ${name}569 MTT_UNUSED;
static double ${name}570 MTT_UNUSED;
static double ${name}571 MTT_UNUSED;
static double ${name}572 MTT_UNUSED;
static double ${name}573 MTT_UNUSED;
static double ${name}574 MTT_UNUSED;
static double ${name}575 MTT_UNUSED;
static double ${name}576 MTT_UNUSED;
static double ${name}577 MTT_UNUSED;
static double ${name}578 MTT_UNUSED;
static double ${name}579 MTT_UNUSED;
static double ${name}580 MTT_UNUSED;
static double ${name}581 MTT_UNUSED;
static double ${name}582 MTT_UNUSED;
static double ${name}583 MTT_UNUSED;
static double ${name}584 MTT_UNUSED;
static double ${name}585 MTT_UNUSED;
static double ${name}586 MTT_UNUSED;
static double ${name}587 MTT_UNUSED;
static double ${name}588 MTT_UNUSED;
static double ${name}589 MTT_UNUSED;
static double ${name}590 MTT_UNUSED;
static double ${name}591 MTT_UNUSED;
static double ${name}592 MTT_UNUSED;
static double ${name}593 MTT_UNUSED;
static double ${name}594 MTT_UNUSED;
static double ${name}595 MTT_UNUSED;
static double ${name}596 MTT_UNUSED;
static double ${name}597 MTT_UNUSED;
static double ${name}598 MTT_UNUSED;
static double ${name}599 MTT_UNUSED;
static double ${name}600 MTT_UNUSED;
static double ${name}601 MTT_UNUSED;
static double ${name}602 MTT_UNUSED;
static double ${name}603 MTT_UNUSED;
static double ${name}604 MTT_UNUSED;
static double ${name}605 MTT_UNUSED;
static double ${name}606 MTT_UNUSED;
static double ${name}607 MTT_UNUSED;
static double ${name}608 MTT_UNUSED;
static double ${name}609 MTT_UNUSED;
static double ${name}610 MTT_UNUSED;
static double ${name}611 MTT_UNUSED;
static double ${name}612 MTT_UNUSED;
static double ${name}613 MTT_UNUSED;
static double ${name}614 MTT_UNUSED;
static double ${name}615 MTT_UNUSED;
static double ${name}616 MTT_UNUSED;
static double ${name}617 MTT_UNUSED;
static double ${name}618 MTT_UNUSED;
static double ${name}619 MTT_UNUSED;
static double ${name}620 MTT_UNUSED;
static double ${name}621 MTT_UNUSED;
static double ${name}622 MTT_UNUSED;
static double ${name}623 MTT_UNUSED;
static double ${name}624 MTT_UNUSED;
static double ${name}625 MTT_UNUSED;
static double ${name}626 MTT_UNUSED;
static double ${name}627 MTT_UNUSED;
static double ${name}628 MTT_UNUSED;
static double ${name}629 MTT_UNUSED;
static double ${name}630 MTT_UNUSED;
static double ${name}631 MTT_UNUSED;
static double ${name}632 MTT_UNUSED;
static double ${name}633 MTT_UNUSED;
static double ${name}634 MTT_UNUSED;
static double ${name}635 MTT_UNUSED;
static double ${name}636 MTT_UNUSED;
static double ${name}637 MTT_UNUSED;
static double ${name}638 MTT_UNUSED;
static double ${name}639 MTT_UNUSED;
static double ${name}640 MTT_UNUSED;
static double ${name}641 MTT_UNUSED;
static double ${name}642 MTT_UNUSED;
static double ${name}643 MTT_UNUSED;
static double ${name}644 MTT_UNUSED;
static double ${name}645 MTT_UNUSED;
static double ${name}646 MTT_UNUSED;
static double ${name}647 MTT_UNUSED;
static double ${name}648 MTT_UNUSED;
static double ${name}649 MTT_UNUSED;
static double ${name}650 MTT_UNUSED;
static double ${name}651 MTT_UNUSED;
static double ${name}652 MTT_UNUSED;
static double ${name}653 MTT_UNUSED;
static double ${name}654 MTT_UNUSED;
static double ${name}655 MTT_UNUSED;
static double ${name}656 MTT_UNUSED;
static double ${name}657 MTT_UNUSED;
static double ${name}658 MTT_UNUSED;
static double ${name}659 MTT_UNUSED;
static double ${name}660 MTT_UNUSED;
static double ${name}661 MTT_UNUSED;
static double ${name}662 MTT_UNUSED;
static double ${name}663 MTT_UNUSED;
static double ${name}664 MTT_UNUSED;
static double ${name}665 MTT_UNUSED;
static double ${name}666 MTT_UNUSED;
static double ${name}667 MTT_UNUSED;
static double ${name}668 MTT_UNUSED;
static double ${name}669 MTT_UNUSED;
static double ${name}670 MTT_UNUSED;
static double ${name}671 MTT_UNUSED;
static double ${name}672 MTT_UNUSED;
static double ${name}673 MTT_UNUSED;
static double ${name}674 MTT_UNUSED;
static double ${name}675 MTT_UNUSED;
static double ${name}676 MTT_UNUSED;
static double ${name}677 MTT_UNUSED;
static double ${name}678 MTT_UNUSED;
static double ${name}679 MTT_UNUSED;
static double ${name}680 MTT_UNUSED;
static double ${name}681 MTT_UNUSED;
static double ${name}682 MTT_UNUSED;
static double ${name}683 MTT_UNUSED;
static double ${name}684 MTT_UNUSED;
static double ${name}685 MTT_UNUSED;
static double ${name}686 MTT_UNUSED;
static double ${name}687 MTT_UNUSED;
static double ${name}688 MTT_UNUSED;
static double ${name}689 MTT_UNUSED;
static double ${name}690 MTT_UNUSED;
static double ${name}691 MTT_UNUSED;
static double ${name}692 MTT_UNUSED;
static double ${name}693 MTT_UNUSED;
static double ${name}694 MTT_UNUSED;
static double ${name}695 MTT_UNUSED;
static double ${name}696 MTT_UNUSED;
static double ${name}697 MTT_UNUSED;
static double ${name}698 MTT_UNUSED;
static double ${name}699 MTT_UNUSED;
static double ${name}700 MTT_UNUSED;
static double ${name}701 MTT_UNUSED;
static double ${name}702 MTT_UNUSED;
static double ${name}703 MTT_UNUSED;
static double ${name}704 MTT_UNUSED;
static double ${name}705 MTT_UNUSED;
static double ${name}706 MTT_UNUSED;
static double ${name}707 MTT_UNUSED;
static double ${name}708 MTT_UNUSED;
static double ${name}709 MTT_UNUSED;
static double ${name}710 MTT_UNUSED;
static double ${name}711 MTT_UNUSED;
static double ${name}712 MTT_UNUSED;
static double ${name}713 MTT_UNUSED;
static double ${name}714 MTT_UNUSED;
static double ${name}715 MTT_UNUSED;
static double ${name}716 MTT_UNUSED;
static double ${name}717 MTT_UNUSED;
static double ${name}718 MTT_UNUSED;
static double ${name}719 MTT_UNUSED;
static double ${name}720 MTT_UNUSED;
static double ${name}721 MTT_UNUSED;
static double ${name}722 MTT_UNUSED;
static double ${name}723 MTT_UNUSED;
static double ${name}724 MTT_UNUSED;
static double ${name}725 MTT_UNUSED;
static double ${name}726 MTT_UNUSED;
static double ${name}727 MTT_UNUSED;
static double ${name}728 MTT_UNUSED;
static double ${name}729 MTT_UNUSED;
static double ${name}730 MTT_UNUSED;
static double ${name}731 MTT_UNUSED;
static double ${name}732 MTT_UNUSED;
static double ${name}733 MTT_UNUSED;
static double ${name}734 MTT_UNUSED;
static double ${name}735 MTT_UNUSED;
static double ${name}736 MTT_UNUSED;
static double ${name}737 MTT_UNUSED;
static double ${name}738 MTT_UNUSED;
static double ${name}739 MTT_UNUSED;
static double ${name}740 MTT_UNUSED;
static double ${name}741 MTT_UNUSED;
static double ${name}742 MTT_UNUSED;
static double ${name}743 MTT_UNUSED;
static double ${name}744 MTT_UNUSED;
static double ${name}745 MTT_UNUSED;
static double ${name}746 MTT_UNUSED;
static double ${name}747 MTT_UNUSED;
static double ${name}748 MTT_UNUSED;
static double ${name}749 MTT_UNUSED;
static double ${name}750 MTT_UNUSED;
static double ${name}751 MTT_UNUSED;
static double ${name}752 MTT_UNUSED;
static double ${name}753 MTT_UNUSED;
static double ${name}754 MTT_UNUSED;
static double ${name}755 MTT_UNUSED;
static double ${name}756 MTT_UNUSED;
static double ${name}757 MTT_UNUSED;
static double ${name}758 MTT_UNUSED;
static double ${name}759 MTT_UNUSED;
static double ${name}760 MTT_UNUSED;
static double ${name}761 MTT_UNUSED;
static double ${name}762 MTT_UNUSED;
static double ${name}763 MTT_UNUSED;
static double ${name}764 MTT_UNUSED;
static double ${name}765 MTT_UNUSED;
static double ${name}766 MTT_UNUSED;
static double ${name}767 MTT_UNUSED;
static double ${name}768 MTT_UNUSED;
static double ${name}769 MTT_UNUSED;
static double ${name}770 MTT_UNUSED;
static double ${name}771 MTT_UNUSED;
static double ${name}772 MTT_UNUSED;
static double ${name}773 MTT_UNUSED;
static double ${name}774 MTT_UNUSED;
static double ${name}775 MTT_UNUSED;
static double ${name}776 MTT_UNUSED;
static double ${name}777 MTT_UNUSED;
static double ${name}778 MTT_UNUSED;
static double ${name}779 MTT_UNUSED;
static double ${name}780 MTT_UNUSED;
static double ${name}781 MTT_UNUSED;
static double ${name}782 MTT_UNUSED;
static double ${name}783 MTT_UNUSED;
static double ${name}784 MTT_UNUSED;
static double ${name}785 MTT_UNUSED;
static double ${name}786 MTT_UNUSED;
static double ${name}787 MTT_UNUSED;
static double ${name}788 MTT_UNUSED;
static double ${name}789 MTT_UNUSED;
static double ${name}790 MTT_UNUSED;
static double ${name}791 MTT_UNUSED;
static double ${name}792 MTT_UNUSED;
static double ${name}793 MTT_UNUSED;
static double ${name}794 MTT_UNUSED;
static double ${name}795 MTT_UNUSED;
static double ${name}796 MTT_UNUSED;
static double ${name}797 MTT_UNUSED;
static double ${name}798 MTT_UNUSED;
static double ${name}799 MTT_UNUSED;
static double ${name}800 MTT_UNUSED;
static double ${name}801 MTT_UNUSED;
static double ${name}802 MTT_UNUSED;
static double ${name}803 MTT_UNUSED;
static double ${name}804 MTT_UNUSED;
static double ${name}805 MTT_UNUSED;
static double ${name}806 MTT_UNUSED;
static double ${name}807 MTT_UNUSED;
static double ${name}808 MTT_UNUSED;
static double ${name}809 MTT_UNUSED;
static double ${name}810 MTT_UNUSED;
static double ${name}811 MTT_UNUSED;
static double ${name}812 MTT_UNUSED;
static double ${name}813 MTT_UNUSED;
static double ${name}814 MTT_UNUSED;
static double ${name}815 MTT_UNUSED;
static double ${name}816 MTT_UNUSED;
static double ${name}817 MTT_UNUSED;
static double ${name}818 MTT_UNUSED;
static double ${name}819 MTT_UNUSED;
static double ${name}820 MTT_UNUSED;
static double ${name}821 MTT_UNUSED;
static double ${name}822 MTT_UNUSED;
static double ${name}823 MTT_UNUSED;
static double ${name}824 MTT_UNUSED;
static double ${name}825 MTT_UNUSED;
static double ${name}826 MTT_UNUSED;
static double ${name}827 MTT_UNUSED;
static double ${name}828 MTT_UNUSED;
static double ${name}829 MTT_UNUSED;
static double ${name}830 MTT_UNUSED;
static double ${name}831 MTT_UNUSED;
static double ${name}832 MTT_UNUSED;
static double ${name}833 MTT_UNUSED;
static double ${name}834 MTT_UNUSED;
static double ${name}835 MTT_UNUSED;
static double ${name}836 MTT_UNUSED;
static double ${name}837 MTT_UNUSED;
static double ${name}838 MTT_UNUSED;
static double ${name}839 MTT_UNUSED;
static double ${name}840 MTT_UNUSED;
static double ${name}841 MTT_UNUSED;
static double ${name}842 MTT_UNUSED;
static double ${name}843 MTT_UNUSED;
static double ${name}844 MTT_UNUSED;
static double ${name}845 MTT_UNUSED;
static double ${name}846 MTT_UNUSED;
static double ${name}847 MTT_UNUSED;
static double ${name}848 MTT_UNUSED;
static double ${name}849 MTT_UNUSED;
static double ${name}850 MTT_UNUSED;
static double ${name}851 MTT_UNUSED;
static double ${name}852 MTT_UNUSED;
static double ${name}853 MTT_UNUSED;
static double ${name}854 MTT_UNUSED;
static double ${name}855 MTT_UNUSED;
static double ${name}856 MTT_UNUSED;
static double ${name}857 MTT_UNUSED;
static double ${name}858 MTT_UNUSED;
static double ${name}859 MTT_UNUSED;
static double ${name}860 MTT_UNUSED;
static double ${name}861 MTT_UNUSED;
static double ${name}862 MTT_UNUSED;
static double ${name}863 MTT_UNUSED;
static double ${name}864 MTT_UNUSED;
static double ${name}865 MTT_UNUSED;
static double ${name}866 MTT_UNUSED;
static double ${name}867 MTT_UNUSED;
static double ${name}868 MTT_UNUSED;
static double ${name}869 MTT_UNUSED;
static double ${name}870 MTT_UNUSED;
static double ${name}871 MTT_UNUSED;
static double ${name}872 MTT_UNUSED;
static double ${name}873 MTT_UNUSED;
static double ${name}874 MTT_UNUSED;
static double ${name}875 MTT_UNUSED;
static double ${name}876 MTT_UNUSED;
static double ${name}877 MTT_UNUSED;
static double ${name}878 MTT_UNUSED;
static double ${name}879 MTT_UNUSED;
static double ${name}880 MTT_UNUSED;
static double ${name}881 MTT_UNUSED;
static double ${name}882 MTT_UNUSED;
static double ${name}883 MTT_UNUSED;
static double ${name}884 MTT_UNUSED;
static double ${name}885 MTT_UNUSED;
static double ${name}886 MTT_UNUSED;
static double ${name}887 MTT_UNUSED;
static double ${name}888 MTT_UNUSED;
static double ${name}889 MTT_UNUSED;
static double ${name}890 MTT_UNUSED;
static double ${name}891 MTT_UNUSED;
static double ${name}892 MTT_UNUSED;
static double ${name}893 MTT_UNUSED;
static double ${name}894 MTT_UNUSED;
static double ${name}895 MTT_UNUSED;
static double ${name}896 MTT_UNUSED;
static double ${name}897 MTT_UNUSED;
static double ${name}898 MTT_UNUSED;
static double ${name}899 MTT_UNUSED;
static double ${name}900 MTT_UNUSED;
static double ${name}901 MTT_UNUSED;
static double ${name}902 MTT_UNUSED;
static double ${name}903 MTT_UNUSED;
static double ${name}904 MTT_UNUSED;
static double ${name}905 MTT_UNUSED;
static double ${name}906 MTT_UNUSED;
static double ${name}907 MTT_UNUSED;
static double ${name}908 MTT_UNUSED;
static double ${name}909 MTT_UNUSED;
static double ${name}910 MTT_UNUSED;
static double ${name}911 MTT_UNUSED;
static double ${name}912 MTT_UNUSED;
static double ${name}913 MTT_UNUSED;
static double ${name}914 MTT_UNUSED;
static double ${name}915 MTT_UNUSED;
static double ${name}916 MTT_UNUSED;
static double ${name}917 MTT_UNUSED;
static double ${name}918 MTT_UNUSED;
static double ${name}919 MTT_UNUSED;
static double ${name}920 MTT_UNUSED;
static double ${name}921 MTT_UNUSED;
static double ${name}922 MTT_UNUSED;
static double ${name}923 MTT_UNUSED;
static double ${name}924 MTT_UNUSED;
static double ${name}925 MTT_UNUSED;
static double ${name}926 MTT_UNUSED;
static double ${name}927 MTT_UNUSED;
static double ${name}928 MTT_UNUSED;
static double ${name}929 MTT_UNUSED;
static double ${name}930 MTT_UNUSED;
static double ${name}931 MTT_UNUSED;
static double ${name}932 MTT_UNUSED;
static double ${name}933 MTT_UNUSED;
static double ${name}934 MTT_UNUSED;
static double ${name}935 MTT_UNUSED;
static double ${name}936 MTT_UNUSED;
static double ${name}937 MTT_UNUSED;
static double ${name}938 MTT_UNUSED;
static double ${name}939 MTT_UNUSED;
static double ${name}940 MTT_UNUSED;
static double ${name}941 MTT_UNUSED;
static double ${name}942 MTT_UNUSED;
static double ${name}943 MTT_UNUSED;
static double ${name}944 MTT_UNUSED;
static double ${name}945 MTT_UNUSED;
static double ${name}946 MTT_UNUSED;
static double ${name}947 MTT_UNUSED;
static double ${name}948 MTT_UNUSED;
static double ${name}949 MTT_UNUSED;
static double ${name}950 MTT_UNUSED;
static double ${name}951 MTT_UNUSED;
static double ${name}952 MTT_UNUSED;
static double ${name}953 MTT_UNUSED;
static double ${name}954 MTT_UNUSED;
static double ${name}955 MTT_UNUSED;
static double ${name}956 MTT_UNUSED;
static double ${name}957 MTT_UNUSED;
static double ${name}958 MTT_UNUSED;
static double ${name}959 MTT_UNUSED;
static double ${name}960 MTT_UNUSED;
static double ${name}961 MTT_UNUSED;
static double ${name}962 MTT_UNUSED;
static double ${name}963 MTT_UNUSED;
static double ${name}964 MTT_UNUSED;
static double ${name}965 MTT_UNUSED;
static double ${name}966 MTT_UNUSED;
static double ${name}967 MTT_UNUSED;
static double ${name}968 MTT_UNUSED;
static double ${name}969 MTT_UNUSED;
static double ${name}970 MTT_UNUSED;
static double ${name}971 MTT_UNUSED;
static double ${name}972 MTT_UNUSED;
static double ${name}973 MTT_UNUSED;
static double ${name}974 MTT_UNUSED;
static double ${name}975 MTT_UNUSED;
static double ${name}976 MTT_UNUSED;
static double ${name}977 MTT_UNUSED;
static double ${name}978 MTT_UNUSED;
static double ${name}979 MTT_UNUSED;
static double ${name}980 MTT_UNUSED;
static double ${name}981 MTT_UNUSED;
static double ${name}982 MTT_UNUSED;
static double ${name}983 MTT_UNUSED;
static double ${name}984 MTT_UNUSED;
static double ${name}985 MTT_UNUSED;
static double ${name}986 MTT_UNUSED;
static double ${name}987 MTT_UNUSED;
static double ${name}988 MTT_UNUSED;
static double ${name}989 MTT_UNUSED;
static double ${name}990 MTT_UNUSED;
static double ${name}991 MTT_UNUSED;
static double ${name}992 MTT_UNUSED;
static double ${name}993 MTT_UNUSED;
static double ${name}994 MTT_UNUSED;
static double ${name}995 MTT_UNUSED;
static double ${name}996 MTT_UNUSED;
static double ${name}997 MTT_UNUSED;
static double ${name}998 MTT_UNUSED;
static double ${name}999 MTT_UNUSED;
static double ${name}1000 MTT_UNUSED;
EOF

    if [ ${NUM_OF_TMP_VAR} -gt 1000 ]; then
	i=1001
	while [ ${i} -le ${NUM_OF_TMP_VAR} ]
	do
	  echo "static double ${name}${i} MTT_UNUSED;"
	  i=`expr ${i} + 1`
	done
    fi
done
}

echo Creating ${OUT}
cat <<EOF > ${OUT}
#ifndef MTT_UNUSED
#ifdef __GNUC__
#define MTT_UNUSED __attribute__ ((__unused__))
#else
#define MTT_UNUSED
#endif
#endif

EOF

declare_sys_param	>> ${OUT}
if [ ${NUM_OF_TMP_VAR} -gt 0 ]; then
    declare_temp_vars	>> ${OUT}
fi


Deleted mttroot/mtt/debian/README.Debian version [6a919df6b7].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
mtt for Debian
--------------

Model Transformation Tools is hosted on Sourceforge
http://sourceforge.net/projects/mtt

 -- Geraint <geraint@users.sf.net>, Sun, 28 Apr 2002 00:11:29 +0000

Deleted mttroot/mtt/debian/changelog version [ece406bdfc].

1
2
3
4
5
6






-
-
-
-
-
-
mtt (4.9+2002.04.27-1) unstable; urgency=low

  * Initial Release.

 -- Geraint <geraint@users.sf.net>  Sun, 28 Apr 2002 00:11:29 +0000

Deleted mttroot/mtt/debian/compat version [607ad8c0db].

1

-
7

Deleted mttroot/mtt/debian/conffiles version [a332b076b5].

1

-
/etc/mtt.conf

Deleted mttroot/mtt/debian/conffiles.ex version [b3b38e0609].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
#
# If you want to use this conffile, remove all comments and put files that
# you want dpkg to process here using their absolute pathnames.
# See the policy manual
#
# for example:
# /etc/mtt/mtt.conf

Deleted mttroot/mtt/debian/control version [cf54707222].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Source: mtt
Section: contrib/math
Priority: optional
Maintainer: Geraint <geraint@users.sourceforge.net>
Build-Depends: debhelper (>> 3.0.0)
Standards-Version: 3.5.2

Package: mtt
Architecture: all
Depends: gawk, octave, units, xfig, perl
Recommends: mtt-examples, blas-dev, fftw-dev, c-compiler, dia, g++, gnuplot, info-browser, lapack-dev, latex2html, libkpathsea-dev, libncurses5-dev, libreadline4-dev, libxml-dom-perl, pdf-viewer, postscript-viewer, octave-pkg-dev, octave-info, texlive, texlive-latex-extra, transfig, xterm, www-browser, wish
Suggests: scigraphica, zip
Description: Model Transformation Tools.
 A set of tools for modelling dynamic physical systems using the bond-graph methodology and transforming these models into representations suitable for analysis, control and simulation. These tools use, and generate m files for, GNU Octave.
 .
 The MTT homepage is located at http://mtt.sourceforge.net. An on-line manual is available at http://mtt.sourceforge.net/doc.
 .
 MTT uses the non-free symbolic algebra tool Reduce to perform some transformations and it is highly recommended that this software is installed. Details of Reduce can be found at http://www.reduce-algebra.com
 .

Deleted mttroot/mtt/debian/copyright version [b94b7f6de3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
This package was debianized by Geraint <geraint@users.sf.net> on
Sun, 28 Apr 2002 00:11:29 +0000.

It was downloaded from http://sourceforge.net/projects/mtt

Upstream Author(s): Peter Gawthrop <mtt@gawthrop.net>

Copyright:

mtt is copyright (c) 1989-2004 by Peter J. Gawthrop.

You are free to distribute this software under the terms of the
GNU General Public License (GPL).

On Debian systems, the complete text of the GNU General Public License
can be found in /usr/share/common-licenses/GPL.

Deleted mttroot/mtt/debian/cron.d.ex version [daf97cc67d].

1
2
3
4




-
-
-
-
#
# Regular cron jobs for the mtt package
#
0 4	* * *	root	mtt_maintenance

Deleted mttroot/mtt/debian/dirs version [b541042ac0].

1
2


-
-
usr/bin

Deleted mttroot/mtt/debian/docs version [a7ffc6f8bf].

Deleted mttroot/mtt/debian/emacsen-install.ex version [40ed5db3df].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh -e
# /usr/lib/emacsen-common/packages/install/mtt

# Written by Jim Van Zandt <jrv@vanzandt.mv.com>, borrowing heavily
# from the install scripts for gettext by Santiago Vila
# <sanvila@ctv.es> and octave by Dirk Eddelbuettel <edd@debian.org>.

FLAVOR=$1
PACKAGE=mtt

if [ ${FLAVOR} = emacs ]; then exit 0; fi

echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}

#FLAVORTEST=`echo $FLAVOR | cut -c-6`
#if [ ${FLAVORTEST} = xemacs ] ; then
#    SITEFLAG="-no-site-file"
#else
#    SITEFLAG="--no-site-file"
#fi
FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}

# Install-info-altdir does not actually exist. 
# Maybe somebody will write it.
if test -x /usr/sbin/install-info-altdir; then
    echo install/${PACKAGE}: install Info links for ${FLAVOR}
    install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/info/${PACKAGE}.info.gz
fi

install -m 755 -d ${ELCDIR}
cd ${ELDIR}
FILES=`echo *.el`
cp ${FILES} ${ELCDIR}
cd ${ELCDIR}

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF
${FLAVOR} ${FLAGS} ${FILES}
rm -f *.el path.el

exit 0

Deleted mttroot/mtt/debian/emacsen-remove.ex version [b07e6b425f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh -e
# /usr/lib/emacsen-common/packages/remove/mtt

FLAVOR=$1
PACKAGE=mtt

if [ ${FLAVOR} != emacs ]; then
    if test -x /usr/sbin/install-info-altdir; then
        echo remove/${PACKAGE}: removing Info links for ${FLAVOR}
        install-info-altdir --quiet --remove --dirname=${FLAVOR} /usr/info/mtt.info.gz
    fi

    echo remove/${PACKAGE}: purging byte-compiled files for ${FLAVOR}
    rm -rf /usr/share/${FLAVOR}/site-lisp/${PACKAGE}
fi

Deleted mttroot/mtt/debian/emacsen-startup.ex version [50263110bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
;; -*-emacs-lisp-*-
;;
;; Emacs startup file for the Debian GNU/Linux mtt package
;;
;; Originally contributed by Nils Naumann <naumann@unileoben.ac.at>
;; Modified by Dirk Eddelbuettel <edd@debian.org>
;; Adapted for dh-make by Jim Van Zandt <jrv@vanzandt.mv.com>

;; The mtt package follows the Debian/GNU Linux 'emacsen' policy and
;; byte-compiles its elisp files for each 'emacs flavor' (emacs19,
;; xemacs19, emacs20, xemacs20...).  The compiled code is then
;; installed in a subdirectory of the respective site-lisp directory.
;; We have to add this to the load-path:
(setq load-path (cons (concat "/usr/share/"
                              (symbol-name flavor)
			      "/site-lisp/mtt") load-path))


Deleted mttroot/mtt/debian/ex.package.doc-base version [8bae181fd3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Document: mtt
Title: Debian mtt Manual
Author: <insert document author here>
Abstract: This manual describes what mtt is
 and how it can be used to
 manage online manuals on Debian systems.
Section: unknown

Format: debiandoc-sgml
Files: /usr/share/doc/mtt/mtt.sgml.gz

Format: postscript
Files: /usr/share/doc/mtt/mtt.ps.gz

Format: text
Files: /usr/share/doc/mtt/mtt.text.gz

Format: HTML
Index: /usr/share/doc/mtt/html/index.html
Files: /usr/share/doc/mtt/html/*.html

  

Deleted mttroot/mtt/debian/init.d.ex version [8fc1c7354e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#
# This file was automatically customized by dh-make on Sun, 28 Apr 2002 00:11:29 +0000

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mtt
NAME=mtt
DESC=mtt

test -f $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo "$NAME."
	;;
  #reload)
	#
	#	If the daemon can reload its config files on the fly
	#	for example by sending it SIGHUP, do it here.
	#
	#	If the daemon responds to changes in its config file
	#	directly anyway, make this a do-nothing entry.
	#
	# echo "Reloading $DESC configuration files."
	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
	#	/var/run/$NAME.pid --exec $DAEMON
  #;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0

Deleted mttroot/mtt/debian/manpage.1.ex version [f2432fd683].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MTT SECTION "April 28, 2002"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mtt \- program to do something
.SH SYNOPSIS
.B mtt
.RI [ options ] " files" ...
.br
.B bar
.RI [ options ] " files" ...
.SH DESCRIPTION
This manual page documents briefly the
.B mtt
and
.B bar
commands.
This manual page was written for the Debian distribution
because the original program does not have a manual page.
Instead, it has documentation in the GNU Info format; see below.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
.\" respectively.
\fBmtt\fP is a program that...
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH SEE ALSO
.BR bar (1),
.BR baz (1).
.br
The programs are documented fully by
.IR "The Rise and Fall of a Fooish Bar" ,
available via the Info system.
.SH AUTHOR
This manual page was written by Geraint <geraint@users.sf.net>,
for the Debian GNU/Linux system (but may be used by others).

Deleted mttroot/mtt/debian/manpage.sgml.ex version [92a84a8c20].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Process this file with docbook-to-man to generate an nroff manual
     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
     less'.  A typical entry in a Makefile or Makefile.am is:

manpage.1: manpage.sgml
	docbook-to-man $< > $@

    
	The docbook-to-man binary is found in the docbook-to-man package.
	Please remember that if you create the nroff version in one of the
	debian/rules file targets (such as build), you will need to include
	docbook-to-man in your Build-Depends control field.

  -->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
  <!ENTITY dhsurname   "<surname>SURNAME</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>April 28, 2002</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>SECTION</manvolnum>">
  <!ENTITY dhemail     "<email>geraint@users.sf.net</email>">
  <!ENTITY dhusername  "Geraint">
  <!ENTITY dhucpackage "<refentrytitle>MTT</refentrytitle>">
  <!ENTITY dhpackage   "mtt">

  <!ENTITY debian      "<productname>Debian</productname>">
  <!ENTITY gnu         "<acronym>GNU</acronym>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2001</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>&dhpackage;</refname>

    <refpurpose>program to do something</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&dhpackage;</command>

      <arg><option>-e <replaceable>this</replaceable></option></arg>

      <arg><option>--example <replaceable>that</replaceable></option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>This manual page documents briefly the
      <command>&dhpackage;</command> and <command>bar</command>
      commands.</para>

    <para>This manual page was written for the &debian; distribution
      because the original program does not have a manual page.
      Instead, it has documentation in the &gnu;
      <application>Info</application> format; see below.</para>

    <para><command>&dhpackage;</command> is a program that...</para>

  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <para>These programs follow the usual GNU command line syntax,
      with long options starting with two dashes (`-').  A summary of
      options is included below.  For a complete description, see the
      <application>Info</application> files.</para>

    <variablelist>
      <varlistentry>
        <term><option>-h</option>
          <option>--help</option>
        </term>
        <listitem>
          <para>Show summary of options.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-v</option>
          <option>--version</option>
        </term>
        <listitem>
          <para>Show version of program.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>bar (1), baz (1).</para>

    <para>The programs are documented fully by <citetitle>The Rise and
      Fall of a Fooish Bar</citetitle> available via the
      <application>Info</application> system.</para>
  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (but may be used by others).  Permission is
      granted to copy, distribute and/or modify this document under
      the terms of the <acronym>GNU</acronym> Free Documentation
      License, Version 1.1 or any later version published by the Free
      Software Foundation; with no Invariant Sections, no Front-Cover
      Texts and no Back-Cover Texts.</para>

  </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->


Deleted mttroot/mtt/debian/menu version [a9480c714d].

1
2
3
4
5
6






-
-
-
-
-
-
?package(mtt):needs="X11"\
	section="Apps/Math"\
	title="Xmtt"\
	longtitle="Model Transformation Tools for X"\
	hint="Model Transformation Tools for X"\
	command="x-terminal-emulator -e /usr/bin/xmtt"

Deleted mttroot/mtt/debian/menu.ex version [5506fac571].

1
2
3
4




-
-
-
-
?package(mtt):needs=X11|text|vc|wm section=Apps/see-menu-manual\
  title="mtt" command="/usr/bin/mtt"
?package(mtt):needs=X11|text|vc|wm section=Apps/see-menu-manual\
  title="xmtt" command="/usr/bin/xmtt"

Deleted mttroot/mtt/debian/mtt.1 version [acff8162e2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147



















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MTT 1 "April 27, 2002"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mtt \- Model Transformation Tools
.SH SYNOPSIS
.B mtt
.RI [ options ] " system representation language" 
.br
.B xmtt
.RI [ --update ]
.SH DESCRIPTION
This manual page documents briefly the
.B mtt
and
.B xmtt
commands.
Detailed documentation is available in info or html format by issuing
the command
.B mtt info
for info format or
.B mtt hinfo
for html.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
.\" respectively.
\fBmtt\fP is a  set of tools for modelling dynamic physical systems using the bond-graph methodology and transforming these models into representations suitable for analysis, control and simulation. These tools use, and generate m files for, GNU Octave. 
.SH OPTIONS
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-q
quiet mode -- suppress MTT banner
.TP
.B \-A
solve algebraic equations symbolically
.TP
.B \-D
debug -- leave log files etc
.TP
.B \-I
prints more information
.TP
.B \-abg
start at abg.m representation
.TP
.B \-c
c-code generation
.TP
.B \-cc
C++ code generation
.TP
.B \-cr
Use cr before resolving equations
.TP
.B \-d  <dir>
use directory <dir>
.TP
.B \-dc
Maximise derivative (not integral) causality
.TP
.B \-dc
Maximise derivative (not integral) causality
.TP
.B \-i <implicit|euler|rk4|dassl>
Use implicit, euler, rk4 or dassl integration
.TP
.B \-ae <reduce|hybrd|dassl|hooke>
Solve algebraic equations with specified solver
.TP
.B \-o
ode is same as dae
.TP
.B \-oct
use oct files in place of m files where appropriate
.TP
.B \-opt
optimise code generation
.TP
.B \-p
print environment variables
.TP
.B \-partition
 partition hierachical system
.TP
.B \-pdf
generate pdf in place of ps
.TP
.B \-r
reset time stamp on representation
.TP
.B \-s
generate sensitivity BG (use mtt -s sSys rep lang)
.TP
.B \-ss
use steady-state info to initialise simulations
.TP
.B \-stdin
read input data from standard input for  simulations
.TP
.B \-sub <subsystem>
operate on this subsystem
.TP
.B \-t
tidy mode (default)
.TP
.B \-trace
Just indicate what mtt will do - but do not do it
.TP
.B \-u
untidy mode (leaves files in current dir)
.TP
.B \-v
verbose mode (multiple uses of -v increase the verbosity level)
.TP
.B \-viewlevel <N>
View N levels of hierachy
.TP
.B \-\-version
print version and exit
.TP
.B \-\-versions
print version of mtt and components and exit

The programs are documented fully by
.IR "mtt: Model Transformation Tools" ,
available via the Info system.
.SH FILES
/etc/mtt.conf
.SH AUTHOR
This manual page was written by Geraint <geraint@users.sf.net>,
for the Debian GNU/Linux system (but may be used by others).

Deleted mttroot/mtt/debian/mtt.doc-base version [3073d9efcc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Document: mtt
Title: Model Transformation Tools (MTT) Manual
Author: Peter Gawthrop, Geraint Bevan
Abstract: This manual describes Model Transformation Tools (MTT),
 a set of tools for modelling dynamic physical systems using the bond-graph
 methodology and transforming these models into representations suitable for
 analysis, control and simulation.
 These tools use, and generate m files for, GNU Octave.
Section: Apps/Math

Format: postscript
Files: /usr/share/doc/mtt/mtt.ps.gz

Format: PDF
Files: /usr/share/doc/mtt/mtt.pdf.gz

Format: HTML
Index: /usr/share/doc/mtt/mtt.html
Files: /usr/share/doc/mtt/*.html

  

Deleted mttroot/mtt/debian/package.doc-base version [483b9b6fed].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Document: mtt
Title: Debian mtt Manual
Author: Peter Gawthrop
Abstract: This manual describes mtt,
 a set of tools for modelling dynamic physical systems
 using the bond-graph methodology and transforming these
 models into representations suitable for analysis, control
 and simulation. These tools use, and generate m files for,
 GNU Octave. 
Section: math

Format: postscript
Files: /usr/share/doc/mtt/mtt.ps.gz

Format: HTML
Index: /usr/share/doc/mtt/html/mtt.html
Files: /usr/share/doc/mtt/html/*.html

  

Deleted mttroot/mtt/debian/postinst version [9236a7d0d3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# postinst script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

case "$1" in
    configure)
	install-info --menuentry=MTT \
	    --description="Model Transformation Tools" \
	    --section "[Mm]ath" Mathematics \
	    /usr/share/info/mtt.info.gz
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/debian/postinst.ex version [6ec4ce5c20].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# postinst script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

case "$1" in
    configure)

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/debian/postrm.ex version [c13738ff9e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# postrm script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
       purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)


        ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

Deleted mttroot/mtt/debian/preinst.ex version [73f98ab897].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# preinst script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
#
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    install|upgrade)
#        if [ "$1" = "upgrade" ]
#        then
#            start-stop-daemon --stop --quiet --oknodo  \
#                --pidfile /var/run/mtt.pid  \
#                --exec /usr/sbin/mtt 2>/dev/null || true
#        fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/debian/prerm version [a145bc4b8a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# prerm script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    remove|upgrade|deconfigure)
	install-info --quiet --remove /usr/share/info/mtt.info.gz
        ;;
    failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/debian/prerm.ex version [4a73a2963c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# prerm script for mtt
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    remove|upgrade|deconfigure)
#       install-info --quiet --remove /usr/info/mtt.info.gz
        ;;
    failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/debian/rules version [e44338ab99].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This is the debhelper compatibility version to use.
export DH_COMPAT=3



ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.

	touch configure-stamp


build: build-stamp

build-stamp: configure-stamp 
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE) build build-doc
	#/usr/bin/docbook-to-man debian/mtt.sgml > mtt.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/mtt.
	$(MAKE) install install-doc install-xfig DESTDIR=$(CURDIR)/debian/mtt


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installcron
	dh_installman debian/mtt.1
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs 
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
#	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

Deleted mttroot/mtt/debian/watch.ex version [5598e47ae1].

1
2
3
4
5





-
-
-
-
-
# Example watch control file for uscan
# Rename this file to "watch" and then you can run the "uscan" command
# to check for upstream updates and more.
# Site		Directory		Pattern			Version	Script
sunsite.unc.edu	/pub/Linux/Incoming	mtt-(.*)\.tar\.gz	debian	uupdate

Deleted mttroot/mtt/doc/Makefile version [1980671319].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#Makefile for MTT documentation

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/04/26 17:17:20  geraint
## Allow variables to be set outside Makefile.
##
## Revision 1.1  2001/06/04 08:18:52  gawthrop
## Putting documentation under CVS
##
## Revision 1.2  1998/07/02 18:40:07  peterg
## More on install option
##
## Revision 1.1  1998/05/14 09:19:52  peterg
## Initial revision
##
###############################################################


#MTTPATH = /home/peterg/mtt_new/mtt
#DOCPATH = /home/peterg/web-docs/software/MTT/doc
#INFOPATH = /usr/info

MTTPATH ?= /home/peterg/mtt_new/mtt
MTT_COMPONENTS ?= /home/eng4/peterg/mtt_new/mtt/lib/comp
MTT_EXAMPLES ?= /home/eng4/peterg/mtt_new/mtt/lib/examples
DOCPATH ?= /home/peterg/web-docs/software/MTT/doc
#INFOPATH = $(DOCPATH)
INFOPATH ?= /usr/info

all: mtt.info  mtt.html mtt.pdf mtt.ps.gz 

mtt.info: mtt.texi
	echo "Making info manual. Please wait ..."; makeinfo mtt.texi

mtt.dvi: mtt.texi
	echo "Making dvi manual. Please wait ..."; tex mtt.texi; tex mtt.texi

mtt.html: mtt.texi
	echo "Making html manual. Please wait ..."; texi2html -glossary  mtt.texi

mtt.ps.gz: mtt.dvi
	echo "Making ps manual. Please wait ..."; dvips -o mtt.ps mtt; gzip -f mtt.ps

mtt.pdf: mtt.texi
	echo "Making pdf manual. Please wait ..."; texi2pdf mtt.texi

Compound-Components_rep.ps: 
	(cd $(MTT_COMPONENTS); mtt Compound-Components rep ps)
	mv $(MTT_COMPONENTS)/Compound-Components_rep.ps .

Compound-Components_rep: 
	(cd $(MTT_COMPONENTS); mtt Compound-Components rep html)
	mv $(MTT_COMPONENTS)/Compound-Components_rep .

Examples_rep.ps: 
	(cd $(MTT_EXAMPLES); mtt Examples rep ps)
	mv $(MTT_EXAMPLES)/Examples_rep.ps .

Examples_rep: 
	(cd $(MTT_EXAMPLES); mtt Examples rep html)
	mv $(MTT_EXAMPLES)/Examples_rep .

clean:
	rm -f mtt.aux	    mtt.fns	  mtt.pg	mtt.tp
	rm -f mtt.cp	    mtt.pgs	  mtt.vr	mtt.ps
	rm -f mtt.cps	    mtt.vrs	  mtt.dvi       mtt.ps.gz
	rm -f mtt.ky	    mtt.fn	  mtt.log	mtt.toc	
	rm -f 		    mtt.ps        mtt.info-*    mtt.pdf
	rm -f mtt.html	    mtt_toc.html  mtt.info
	rm -f mtt.log       mtt.ky        mtt.toc

tidy:
	rm -f mtt.aux	    mtt.fns	  mtt.pg	mtt.tp
	rm -f mtt.cp	    mtt.pgs	  mtt.vr	
	rm -f mtt.cps	    mtt.vrs	  mtt.dvi       
	rm -f mtt.log       mtt.ky        mtt.toc


install-doc: mtt.html mtt.ps.gz  mtt.info
	cp mtt.info* $(INFOPATH)
	cp mtt*.html mtt.ps.gz  $(DOCPATH)
	chmod -R a+r $(DOCPATH)
	chmod a+x  $(DOCPATH)

install-components:  Compound-Components_rep.ps Compound-Components_rep
	mv Compound-Components_rep.ps $(DOCPATH)/../components
	mv Compound-Components_rep    $(DOCPATH)/../components
	chmod -R a+r $(DOCPATH)/../components
	chmod -R a+x $(DOCPATH)/../components/Compound-Components_re




Deleted mttroot/mtt/doc/mtt.texi version [66bf14f795].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\input texinfo  
@c %**start of header
@setfilename mtt.info
@settitle MTT: Model Transformation Tools
@c %**end of header

@finalout

@c Here is what I use in the Info `dir' file:
@c * Mtt: (mtt).                Model transformation tools.



@comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@comment  Version control history
@comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@comment  $Id$
@comment  $Log$
@comment  Revision 1.32  2014/07/12 19:56:27  geraint
@comment  Fixed style of NO WARRANTY from @heading to @strong because texi2html complained about having a heading in an enumerate environment
@comment
@comment  Revision 1.31  2014/07/10 23:13:27  geraint
@comment  Fixed mtt.texi missing arguments and subsection level
@comment
@comment  Revision 1.30  2005/03/15 12:04:15  gawthrop
@comment  New labg.fig rep - pretty LaTeX figures.
@comment
@comment  Revision 1.29  2005/01/19 09:45:15  geraint
@comment  Fixed whitespace.
@comment
@comment  Revision 1.28  2005/01/06 16:03:55  geraint
@comment  Updated options list.
@comment
@comment  Revision 1.27  2005/01/06 14:42:33  geraint
@comment  Fixed explicit/implicit descriptions of forward/backward Euler.
@comment  Replaced -c examples with -cc.
@comment
@comment  Revision 1.26  2005/01/06 12:28:36  geraint
@comment  Minor typos.
@comment
@comment  Revision 1.25  2004/08/27 20:12:34  geraint
@comment  Added note about "none" as an option for units.
@comment
@comment  Revision 1.24  2004/08/13 01:39:24  geraint
@comment  Fixed variable names in diy makefile example (again)
@comment
@comment  Revision 1.23  2004/08/11 08:24:28  geraint
@comment  Replaced "gnuplot view" with "odeso gnuplot" in examples.
@comment
@comment  Revision 1.21  2004/07/23 11:05:26  geraint
@comment  Updated Reduce URL: http://www.reduce-algebra.com
@comment
@comment  Revision 1.20  2003/10/23 18:14:43  geraint
@comment  Added subsection with script for model-specific options.
@comment  Fixed typo in url to mtt.sf.net.
@comment
@comment  Revision 1.19  2003/10/10 22:22:18  geraint
@comment  typo.
@comment
@comment  Revision 1.18  2003/09/07 20:41:19  geraint
@comment  *** empty log message ***
@comment
@comment  Revision 1.17  2003/08/19 14:20:38  gawthrop
@comment  Version 5.0 of MTT
@comment  Remove xref errors (spurious spaces)
@comment
@comment  Revision 1.16  2003/08/19 14:11:23  gawthrop
@comment  Links to legal stuff
@comment
@comment  Revision 1.15  2003/08/19 14:01:45  gawthrop
@comment  Added legal appendices
@comment
@comment  Revision 1.14  2003/08/06 14:50:56  gawthrop
@comment  Describe the alias mechanism for invoking mtt options
@comment
@comment  Revision 1.13  2002/12/13 10:07:07  gawthrop
@comment  Added example in sh section of DIY reps
@comment
@comment  Revision 1.12  2002/09/19 08:09:31  gawthrop
@comment  Updated documentation documentation
@comment
@comment  Revision 1.11  2002/08/20 15:51:17  gawthrop
@comment  Update to work with ident DIY rep
@comment
@comment  Revision 1.10  2002/07/22 10:45:22  geraint
@comment  Fixed gnuplot rep so that it correctly re-runs the simulation if input files have changed.
@comment
@comment  Revision 1.9  2002/07/05 13:29:34  geraint
@comment  Added notes about generating dynamically linked functions for Octave and Matlab.
@comment
@comment  Revision 1.8  2002/07/04 21:34:12  geraint
@comment  Updated gnuplot view description to describe Tcl/Tk interface instead of obsolete txt method.
@comment
@comment  Revision 1.7  2002/04/23 09:51:54  gawthrop
@comment  Changed incorrect statement about searching for components.
@comment
@comment  Revision 1.6  2001/10/15 14:29:50  gawthrop
@comment  Added documentaton on  [1:N] style port labels
@comment
@comment  Revision 1.5  2001/07/23 03:35:29  geraint
@comment  Updated file structure (mtt/bin).
@comment
@comment  Revision 1.4  2001/07/23 03:25:02  geraint
@comment  Added notes on -ae hybrd, rk4, ode2odes.cc, .oct dependencies.
@comment
@comment  Revision 1.3  2001/07/13 03:02:38  geraint
@comment  Added notes on #ICD, gnuplot.txt and odes.sg rep.
@comment
@comment  Revision 1.2  2001/07/03 22:59:10  gawthrop
@comment  Fixed problems with argument passing for CRs
@comment
@comment  Revision 1.1  2001/06/04 08:18:52  gawthrop
@comment  Putting documentation under CVS
@comment
@comment  Revision 1.66  2000/12/05 14:20:55  peterg
@comment  Added the c++  anf m CR info.
@comment
@comment  Revision 1.65  2000/11/27 15:36:15  peterg
@comment  NOPAR --> NOTPAR
@comment
@comment  Revision 1.64  2000/11/16 14:22:48  peterg
@comment  added UNITS declaration
@comment
@comment  Revision 1.63  2000/11/03 14:41:08  peterg
@comment  Added PAR and NOPAR stuff
@comment
@comment  Revision 1.62  2000/10/17 17:53:34  peterg
@comment  Added some simulation details
@comment
@comment  Revision 1.61  2000/09/14 17:13:06  peterg
@comment  New options table
@comment
@comment  Revision 1.60  2000/09/14 17:09:20  peterg
@comment  Tidied up valid name sections
@comment  Tidied up defining represnetations table
@comment  Verion 4.6
@comment
@comment  Revision 1.59  2000/08/30 13:09:00  peterg
@comment  Updated option table
@comment
@comment  Revision 1.58  2000/08/01 13:30:19  peterg
@comment  Version 4.4
@comment  updated STEPFACTOR info
@comment  describes octave and OCST interfaces
@comment
@comment  Revision 1.57  2000/07/20 07:55:44  peterg
@comment  Version 4.3
@comment
@comment  Revision 1.56  2000/05/19 17:49:17  peterg
@comment  Extended the user defined representation section -- new nppp rep.
@comment
@comment  Revision 1.55  2000/03/16 13:53:31  peterg
@comment  Correct date
@comment
@comment  Revision 1.54  2000/03/15 21:22:57  peterg
@comment  Updated to 4.1 -- old style SS no longer supported
@comment
@comment  Revision 1.53  1999/12/22 05:33:10  peterg
@comment  Updated for 4.0
@comment
@comment  Revision 1.52  1999/11/23 00:25:11  peterg
@comment  Added the sensitivity reps
@comment
@comment  Revision 1.51  1999/11/16 04:43:47  peterg
@comment  Added start of sensitivity section
@comment
@comment  Revision 1.50  1999/11/16 00:30:35  peterg
@comment  Updated simulation section
@comment  Added vector components
@comment
@comment  Revision 1.49  1999/07/20 23:44:58  peterg
@comment  V 3.8
@comment
@comment  Revision 1.48  1999/07/19 03:08:33  peterg
@comment  Added documentation for (new) SS lbl fields
@comment
@comment  Revision 1.47  1999/03/09 01:42:22  peterg
@comment  Rearranged the User interface section
@comment
@comment  Revision 1.46  1999/03/09 01:18:01  peterg
@comment  Updated for 3.5 including xmtt
@comment
@comment  Revision 1.45  1999/03/03 02:39:26  peterg
@comment  Minor updates
@comment
@comment  Revision 1.44  1999/02/17 06:52:14  peterg
@comment  New level formula dor artwork
@comment
@comment  Revision 1.43  1998/11/25 16:49:24  peterg
@comment  Put in subs.r documentation (was called params.r)
@comment
@comment  Revision 1.42  1998/11/24 12:24:59  peterg
@comment  Added section on simulation output
@comment  Version 3.4
@comment
@comment  Revision 1.41  1998/09/02 12:04:15  peterg
@comment  Version 3.2
@comment
@comment  Revision 1.40  1998/08/27 08:36:39  peterg
@comment  Removed in. methods except Euler anf implicit
@comment
@comment  Revision 1.39  1998/08/18 10:44:28  peterg
@comment  Typo
@comment
@comment  Revision 1.38  1998/08/18 09:16:38  peterg
@comment  Version 3.1
@comment
@comment  Revision 1.37  1998/08/17 16:14:30  peterg
@comment  Version 3.1 - includes documentation on METHOD=IMPLICIT
@comment
@comment  Revision 1.36  1998/07/30 17:33:15  peterg
@comment  VERSION 3.0
@comment
@comment  Revision 1.35  1998/07/22 11:00:53  peterg
@comment  Correct date!
@comment
@comment  Revision 1.34  1998/07/22 11:00:13  peterg
@comment  Version to BAe
@comment
@comment  Revision 1.33  1998/07/17 19:32:19  peterg
@comment  Added more about aliases
@comment
@comment  Revision 1.32  1998/07/05 14:21:56  peterg
@comment  Further additions (Carlisle-Glasgow)
@comment
@comment  Revision 1.31  1998/07/04 11:35:57  peterg
@comment  Strarted new lbl description
@comment
@comment  Revision 1.30  1998/07/02 18:39:20  peterg
@comment  Started 3.0
@comment  Added alias and default sections.
@comment
@comment  Revision 1.29  1998/05/19 19:46:58  peterg
@comment  Added the odess description
@comment
@comment  Revision 1.28  1998/05/14 09:17:22  peterg
@comment  Added METHOD variable to the simpar file
@comment
@comment  Revision 1.27  1998/05/13 10:03:09  peterg
@comment  Added unknown/zero SS label documentation.
@comment
@comment  Revision 1.26  1998/04/29 15:12:46  peterg
@comment  Version 2.9.
@comment
@comment  Revision 1.25  1998/04/12 17:00:26  peterg
@comment  Added new port features: coerced direction and top-level behaviour.
@comment
@comment  Revision 1.24  1998/04/05 18:27:20  peterg
@comment  This was the 2.6 version
@comment
@comment Revision 1.23  1997/08/24  11:17:51  peterg
@comment This is the released  version 2.5
@comment
@comment  Revision 1.22  1997/08/23 19:38:53  peterg
@comment  Added simulation chapter.
@comment
@comment  Revision 1.21  1997/08/23 16:50:10  peterg
@comment  Added desc section.
@comment  Included named and vector ports
@comment  Completed list of representations.
@comment
@comment Revision 1.20  1997/06/16  15:39:24  peterg
@comment THis is the released 2.4 document.
@comment
@comment Revision 1.19  1997/06/16  09:48:23  peterg
@comment Back under revision control (elm)
@comment
@comment  Revision 1.18  1997/06/14 20:27:41  peterg
@comment  Added complex example section.
@comment
@comment  Revision 1.18  1997/06/13  14:51:07  peterg
@comment  Added report section
@comment 
@comment  Revision 1.17  1997/05/09 15:06:02  peterg
@comment  Changed to version 2.4.
@comment
@comment  Revision 1.16  1996/12/05 10:06:25  peterg
@comment  Modified .octaverc : 'true' --> 1
@comment
@comment  Revision 1.15  1996/11/20 19:02:28  peterg
@comment  Added some system admin stuff.
@comment  Added section on simple models.
@comment
@comment Revision 1.14  1996/11/12  13:19:04  peterg
@comment Put paths as section, not subsection.
@comment
@comment Revision 1.13  1996/11/11  16:53:14  peterg
@comment Added params documentation
@comment Sorted out table bug.
@comment
@comment  Revision 1.12  1996/11/10 20:29:31  peterg
@comment  Added section on help -- needs more
@comment
@comment  Revision 1.11  1996/11/09 21:15:28  peterg
@comment  Rewrite of quick start.
@comment  Update of file structure.
@comment
@comment  Revision 1.10  1996/11/09 20:25:54  peterg
@comment  Final v2.0.
@comment
@comment  Revision 1.9  1996/10/01 10:33:02  peter
@comment  Cleaned up cross references.
@comment
@comment  Revision 1.8  1996/10/01 09:31:00  peter
@comment  Added sections written in Hong Kong.
@comment
@comment  Revision 1.7  1996/09/16 09:49:47  peter
@comment  Added ese section
@comment
@comment  Revision 1.6  1996/09/16 08:33:53  peter
@comment  Added constitutive relationship section etc.
@comment
@comment  Revision 1.5  1996/09/15 20:20:56  peter
@comment  Added abg and rbg stuff
@comment
@comment  Revision 1.4  1996/08/30 19:07:40  peter
@comment  Added some admin stuff.
@comment
@comment  Revision 1.3  1996/08/30 07:50:16  peter
@comment  Added file structure section.
@comment
@comment  Revision 1.2  1996/08/22 14:28:50  peter
@comment  Added stuff about labels.
@comment
@comment  Revision 1.1  1996/08/22 11:52:59  peter
@comment  Initial revision
@comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


@ifinfo
This file documents MTT, a set of Model Transformation Tools.


Copyright (C) Peter J. Gawthrop 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
section entitled ``GNU General Public License'' is included exactly as
in the original, and provided that the entire resulting derived work is
distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that the section entitled ``GNU General Public License'' may be
included in a translation approved by the author instead of in the
original English.
@end ifinfo


@titlepage
@title MTT: Model Transformation Tools
@subtitle August 2003
@subtitle For version 5.0.
@author Peter Gawthrop, Geraint Bevan
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1996,1997,1998,1999,2000,2001,2002,2003 Peter J. Gawthrop

      Permission is granted to copy, distribute and/or modify this document
      under the terms of the GNU Free Documentation License, Version 1.2
      or any later version published by the Free Software Foundation;
      with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
	 Texts.  A copy of the license is included in the section entitled "GNU
      Free Documentation License".

General information about MTT is available at URL www.sf.net.  MTT is distributed
under the GNU GENERAL PUBLIC LICENSE (@pxref{Copying}). This manual is
distributed under the GNU Free Documentation License (@pxref{GNU Free
Documentation License}).

@example
http://mtt.sourceforge.net
@end example
@ifhtml
<A
HREF="http://mtt.sourceforge.net"> here</A>.
@end ifhtml

@end titlepage


@ifinfo
@node Top, Introduction, (dir), (dir)
@top MTT
@strong{MTT} is a set of Model Transformation Tools based on bond graphs.
@strong{MTT} implements the theory to be found in the book ``Metamodelling: Bond
Graphs and Dynamic Systems'' by Peter Gawthrop and Lorcan Smith
published by Prentice Hall in 1996 (ISBN 0-13-489824-9).

It implements two features not discussed in that book:
@itemize @bullet
@item 
bicausal bond graphs and
@item
hierarchical bond graphs.
@end itemize



@contents

@end ifinfo


@c @include intro.texi
@c Copyright (C) 1996 Peter J. Gawthrop
@c This is part of the MTT manual.
@c For copying conditions, see the file MTT.texi.

@menu
* Introduction::                
* User interface::              
* Creating Models::             
* Simulation::                  
* Sensitivity models::          
* Representations::             
* Extending MTT::               
* Documentation::               
* Languages::                   
* Language tools::              
* Administration::              
* Glossary::                    
* Index::                       

@detailmenu
 --- The Detailed Node Listing ---

Introduction

* What is a Representation?::   
* What is a Transformation?::   
* Bond graphs::                 What is a bond graph?                
* Variables::                   
* Bonds::                       
* Components::                  
* Algebraic loops::             
* Switched systems::            

Components

* Ports::                       
* Constitutive relationship::   
* Symbolic parameters::         
* Numeric parameters::          

User interface

* Menu-driven interface::       
* Command line interface::      
* Options::                     
* Utilities::                   

Options

* Available options::           
* Model-specific options::      

Available options

* Experimental options::        
* Deprecated options::          

Utilities

* Help::                        
* Copy::                        
* Clean::                       
* Version control::             

Help

* help representations::        
* help components::             
* help examples::               
* help crs::                    
* help <name>::                 

Creating Models

* Quick start::                 
* Creating simple models::      
* Creating complex models::     

Creating complex models

* Top level::                   

Simulation

* Steady-state solutions::      
* Simulation parameters::       
* Simulation input::            
* Simulation logic::            
* Simulation initial state::    
* Simulation code::             
* Simulation output::           

Steady-state solutions 

* Steady-state solutions - numerical(odess)::  
* Steady-state solutions - symbolic (ss)::  

Simulation parameters

* Euler integration::           
* Implicit integration::        
* Runge Kutta IV integration::  
* Hybrd algebraic solver::      

Simulation code

* Dynamically linked functions::  

Simulation output

* Viewing results with gnuplot::  
* Exporting results to SciGraphica::  

Representations

* Representation summary::      
* Defining representations::    
* Verbal description (desc)::   
* Acausal bond graph (abg)::    
* Acausal bond graph - LaTeX ready (labg)::  
* Stripped acausal bond graph (sabg)::  
* Labels (lbl)::                
* Structure (struc)::           
* Constitutive Relationship (cr)::  
* Parameters::                  
* Causal bond graph (cbg)::     
* Elementary system equations::  
* Differential-Algebraic Equations::  
* Constrained-state Equations::  
* Ordinary Differential Equations::  
* Descriptor matrices::         
* Report::                      

Acausal bond graph (abg)

* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      

Acausal bond graph - LaTeX ready (labg)

* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      

Language fig (abg.fig) 

* icon library::                
* bonds::                       
* strokes::                     
* components::                  
* Simple components::           
* SS components::               
* Simple components - implementation::  
* Compound components::         
* Named SS components::         
* Coerced bond direction::      
* Port labels::                 
* Vector port labels::          
* Port label defaults::         
* Vector components::           
* artwork::                     
* Valid names::                 

Simple components

* SS components::               
* Simple components - implementation::  

Compound components

* Named SS components::      

Language m (rbg.m)

* Transformation abg2rbg_fig2m::  

Language m (abg.m)

* Arrow-orientated causality::  
* Component-orientated causality::  
* Transformation rbg2abg_m::    

Stripped acausal bond graph (sabg)

* Language fig (sabg.fig)::     
* Stripped acausal bond graph (view)::  

Labels (lbl)

* SS component labels::         
* Other component labels::      
* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Parameter declarations::      
* Units declarations::          
* Interface Control Definition::  
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      
* Language tex (desc.tex)::     

Other component labels 

* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      

Aliases

* Port aliases::                
* Parameter aliases::           
* CR aliases::                  
* Component aliases::           

Old-style labels (lbl)

* SS component labels (old-style)::  
* Other component labels (old-style)::  
* Parameter passing (old-style)::  

Parameter passing (old-style)

* Language tex (desc.tex)::     

Structure (struc)

* Language txt (struc.txt)::    
* Language tex (struc.tex)::    
* Structure (view)::            

Constitutive relationship (cr)

* Predefined constitutive relationships::  
* DIY constitutive relationships::  
* Unresolved constitutive relationships::  
* Unresolved constitutive relationships - Octave::  
* Unresolved constitutive relationships - c++::  

Predefined constitutive relationships

* lin::                         
* exotherm::                    

Parameters

* Symbolic parameters (subs.r)::  
* Symbolic parameters for simplification (simp.r)::  
* Numeric parameters (numpar)::  

Numeric parameters (numpar)

* Text form (numpar.txt)::      

Causal bond graph (cbg)

* Language fig (cbg.fig)::      
* Language m (cbg.m)::          

Language m (cbg.m)

* Transformation abg2cbg_m::    

Elementary system equations (ese)

* Transformation cbg2ese_m2r::  

Differential-Algebraic Equations (dae)

* Differential-Algebraic Equations (reduce)::  
* Differential-Algebraic Equations (m)::  

Language reduce (dae.r)

* Transformation ese2dae_r::    

Language m (dae.m)

* Transformation dae_r2m::      

Constrained-state Equations (cse)

* Constrained-state Equations (reduce)::  
* Constrained-state Equations (view)::  

Language reduce (cse.r)

* Transformation dae2cse_r::    

Ordinary Differential Equations

* Ordinary Differential Equations (reduce)::  
* Ordinary Differential Equations (m)::  
* Ordinary Differential Equations (view)::  

Language reduce (ode.r)

* Transformation cse2ode_r::    

Language m (ode.m)

* Transformation ode_r2m::      

Descriptor matrices (dm)

* Descriptor matrices (reduce)::  
* Descriptor matrices (m)::     

Report (rep)

* Report (text)::               
* Report (view)::               

Extending MTT

* Makefiles::                   
* New (DIY) representations::   
* Component library::           

New (DIY) representations

* Makefile (DIY representations)::  
* Shell-script (DIY representations)::  
* Documentation (DIY representations)::  

Documentation

* Manual (Documentation)::      
* On-line documentation::       

On-line documentation

* Brief::                       
* Detailed::                    

Languages

* Fig::                         r
* m::                           
* Reduce::                      
* c::                           

Language tools

* Views::                       
* Xfig::                        
* Text editors::                
* Octave::                      
* LaTeX::                       

Octave

* Octave control system toolbox (OCST)::  
* Creating GNU Octave .oct files::  
* Creating Matlab .mex files::  
* Embedding MTT models in Simulink::  

Administration

* Software components::         
* REDUCE setup::                
* Octave setup::                
* Paths::                       
* File structure::              
* GNU Free Documentation License::  
* Copying::                     

Octave setup

* .octaverc::                   
* .oct file dependencies::      

Paths

* $MTTPATH::                    
* $MTT_COMPONENTS::             
* $MTT_CRS::                    
* $MTT_EXAMPLES::               
* $OCTAVE_PATH::                

@end detailmenu
@end menu

@node Introduction, User interface, Top, Top
@chapter Introduction

@cindex MTT, purpose of

@pindex MTT

@strong{MTT} is a set of Model Transformation Tools based on bond
graphs.  @strong{MTT} implements the theory to be found in the book
``Metamodelling: Bond Graphs and Dynamic Systems'' by Peter Gawthrop and
Lorcan Smith published by Prentice Hall in 1996 (ISBN 0-13-489824-9).

It implements two features not discussed in that book:
@itemize @bullet
@item 
bicausal bond graphs and
@item
hierarchical bond graphs.
@end itemize

In the context of software, it has been said that one good tool is worth many
packages. UNIX is a good example of this philosophy: the user can put together
applications from a range of ready made tools.
This manual describes the application of this philosophy to dynamic
system modeling embodied in @strong{MTT} - a set of Model Transformation Tools
each of which implements a single transformation between system
representations.


System representations have two attributes. 
@itemize @bullet
@item
 A Form: e.g. acausal bond graph, differential algebraic, linear
                state-space etc.
@item
A Language: e.g. Fig, Matlab, LaTeX, Reduce, postscript etc.
@end itemize

Transformations in @strong{MTT} are accomplished using appropriate software (e.g.
Octave/Matlab, Reduce) encapsulated in UNIX Bourne shell scripts. The
relationships between the tools are encoded in a Make File; thus the
user can specify a final representation and all the necessary
intermediate transformations are automatically generated.

@menu
* What is a Representation?::   
* What is a Transformation?::   
* Bond graphs::                 What is a bond graph?                
* Variables::                   
* Bonds::                       
* Components::                  
* Algebraic loops::             
* Switched systems::            
@end menu


@node What is a Representation?, What is a Transformation?, Introduction, Introduction
@section What is a representation?

@cindex Representations, what are they?

@pindex Representations

Physical systems have many representations. These include
@itemize @bullet
@item
a schematic diagram,
@item
a block diagram,
@item
a bunch of equations,
@item
a single differential(-algebraic) equation,
@item
simulation code,
@item
linearised state-space (or descriptor) equations,
@item
transfer function (of the linearised system),
@item
frequency response  (of the linearised system),
@item
etc...
@end itemize

Each of these representations is related to other representations by an
appropriate transformation (@pxref{What is a Transformation?}. In many cases, a
modeler is presented with a physical system and needs to make a
model. In particular, a model, in this context, is a representation of
the system appropriate to a particular use, for example:
@itemize @bullet
@item
simulation,
@item
control system design,
@item
optimisation
@item
etc.
@end itemize

Indeed, for a given physical system, the modeler would need to derive
a number of models. This process can be viewed as a series of steps;
each involving a transformation between representations (@pxref{What is a Transformation?}.


In this context, the following considerations are relevant.
@itemize @bullet
@item
There is a unique `core' representation of any system.
There are many routes  from this core representation, each leading to
an appropriate model.
There are many possible routes  to this core representation
from the physical system: the route chosen is a matter of convenience.
@item
Because the core representation is unique, it is easy to expand the
tool-box to include additional transformations from the physical system
to the core representation and additional transformations from the core
representation to the mode.
@item
Transformation_1 probably cannot, and certainly should not, be
completely automated.  Engineering insight, knowledge and experience is
essential to capture the essence (with respect to the particular use) of
the physical system whilst discarding irrelevant form.
@item
Representation_1 should be `close' in some sense to the Physical system.
@item
The core representation, and hence the representations leading to it,
must contain enough information to generate all of the required models.
@item
Representations must be easily extensible: it must be possible to add
extra components or attributes without restructuring the representation.
@end itemize

I happen to believe that Bond graphs (@pxref{Bond graphs}) provide the
most convenient and powerful basis for the core representation.

@node What is a Transformation?, Bond graphs, What is a Representation?, Introduction
@comment  node-name,  next,  previous,  up
@section What is a transformation?
@cindex Transformations


Each system representation  (@pxref{What is a Representation?} is related to other representations by an
appropriate transformation as follows:
@itemize @bullet 
@item
 Physical system
@item
 Transformation_1 ---> Representation_1
@item
 Transformation_2 ---> Representation_2
@item
 ...
@item
 Transformation_N ---> Core representation
@item
 Transformation_N+1 ---> Representation_N+1
@item
 Transformation_N+2 ---> Representation_N+2
@item
 ...
@item
 Transformation_N+M ---> Model
@end itemize
Thus modeling is seen as a sequence of transformations between
representations.



@node Bond graphs, Variables, What is a Transformation?, Introduction
@section What is a bond graph?

@cindex Bond graphs, what are they?

@pindex Bond graphs

Bond graphs provide a graphical high-level language for describing
dynamic systems in a precise and unambiguous fashion. 
They make a clear distinction between structure (how components are
connected together), and behavior (the particular constitutive
relationships, or physical laws, describing each component.

They can describe a range of physical systems including:
@itemize @bullet
@item
Electrical systems
@item
Mechanical systems
@item
Hydraulic systems
@item
Chemical process systems
@end itemize

More importantly, they can describe systems which contain subsystems
drawn from all of these domains in a uniform manner.

Bond graphs are made up of components (@pxref{Components}) connected by
bonds (@pxref{Bonds}) which define the relationship between
variables (@pxref{Variables}).

@node Variables, Bonds, Bond graphs, Introduction
@comment  node-name,  next,  previous,  up
@section Variables
@cindex Variables
In bond graph terminology there are four sorts of variables:
@itemize @bullet
@item  @emph{effort} variables
@item  @emph{flow} variables
@item  @emph{integrated effort} variables
@item  @emph{integrated flow} variables
@end itemize

Examples of  @emph{effort} variables are
@itemize @bullet
@item 
voltage
@item 
pressure
@item
force
@item
torque
@item
temperature
@end itemize

Examples of  @emph{flow} variables are
@itemize @bullet
@item 
current
@item 
volumetric flow rate
@item
velocity
@item
angular velocity
@item
heat flow
@end itemize



Examples of integrated  @emph{flow} variables are
@itemize @bullet
@item 
charge
@item 
volume
@item
momentum
@item
angular momentum
@item
heat
@end itemize



@node Bonds, Components, Variables, Introduction
@comment  node-name,  next,  previous,  up
@section Bonds
@cindex Bonds
Bonds connect components (@pxref{Components}) together. Each bond
carries two variables:
@itemize @bullet
@item an effort (@pxref{Variables}) variable and 
@item a flow (@pxref{Variables}) variable.
@end itemize
Each bond has three notations associated with it:
@itemize @bullet
@item a half-arrow,
@item a causal stroke and
@item a causal half-stroke.
@end itemize

The half-arrow indicates two things:
@itemize @bullet
@item the direction of power (or pseudo power) flow and
@item the side of the bond associated with the flow variable.
@end itemize

The causal stroke indicates two things:
@itemize @bullet
@item the effort variable is imposed at the same end as the stroke and
@item the flow variable is imposed at the opposite end to the stroke.
@end itemize

The causal half-stoke indicates one thing:
@itemize @bullet
@item if it is on the effort side of the bond, the effort variable is 
imposed at the same end as the stroke or
@item if it is on the flow side of the bond, the flow variable is 
imposed at the opposite end to the stroke.
@end itemize



@node Components, Algebraic loops, Bonds, Introduction
@comment  node-name,  next,  previous,  up
@section  Components
@cindex Components

Components provide the building blocks of a dynamic system when
connected by bonds (@pxref{bonds}).
Components have the following attributes:
@vtable @code
@item ports 
        provide the connections to other components (@pxref{Ports})
@item constitutive relationships
        define how the port-variables are related (@pxref{Constitutive
relationship})
@end vtable


@menu
* Ports::                       
* Constitutive relationship::   
* Symbolic parameters::         
* Numeric parameters::          
@end menu

@node Ports, Constitutive relationship, Components, Components
@comment  node-name,  next,  previous,  up
@subsection Ports
@cindex ports
Components have one or more ports. Each port carries two variables,
and effort and a flow variable (@pxref{Variables}). Any pair of ports
can be connected by a bond (@pxref{Bonds}); this connection is
equivalent to saying that the effort variables at each port are
identical and that the flow variables at each port are
identical.

Ports are implemented in @strong{MTT} using named SS components.
(@pxref{Named SS components}).

The direction of the named SS components.
(@pxref{Named SS components}) 
is coerced (@pxref{Coerced bond direction}) to have the same direction
as the bons connected to the corresponding port. Thus the direction of
the  direction of the named SS components has no significance unless the
component is at the top level.

@node Constitutive relationship, Symbolic parameters, Ports, Components
@comment  node-name,  next,  previous,  up
@subsection  Constitutive relationship
@cindex Constitutive Relationship

The constitutive relationship of a component defines how the port
variables are related. This relationship may be linear
or non-linear. This typically contains symbolic parameters
(@pxref{Symbolic parameters}) which may be replaced, for the purposes
of numerical analysis by numeric parameters
(@pxref{Numeric parameters}).

@node Symbolic parameters, Numeric parameters, Constitutive relationship, Components
@comment  node-name,  next,  previous,  up
@subsection Symbolic parameters
@cindex Symbolic parameters
The constitutive relationship of a system component (@pxref{Components})
typically contains  symbolic parameters. For example a resistor may have
a symbolic resistance r. It is convenient to leave such parameters as
symbols when viewing equations or when performing symbolic analysis such
as differentiation.

However, @strong{MTT} allows replacement of symbolic parameters by
numeric parameters (@pxref{Numeric parameters}) when appropriate.

@node Numeric parameters,  , Symbolic parameters, Components
@comment  node-name,  next,  previous,  up
@subsection Numeric parameters
@cindex Numeric parameters
Numerical parameters are needed to give specific values to symbolic
parameters (@pxref{Symbolic parameters}) for the purposes of numeric
analysis;
for example: simulation, graph plotting or use within a numerical
package such as Octave (@pxref{Octave}).


@node Algebraic loops, Switched systems, Components, Introduction
@section Algebraic loops
@cindex Algebraic loops
Following Chapter 3 of the book, algebraic loops appear as under-causal
components in the bond graph. It is up to the modeler to indicate how these loops
are to be resolved by adding appropriate SS elements.

In particular if zero junction is undercausal an SS:loop component (with
effort output indicated by a causal stroke) with the following label
file entry:
@example
  loop SS unknown,zero
@end example

For more information, refer to:
``Metamodelling: Bond Graphs and Dynamic Systems'' by Peter Gawthrop and
Lorcan Smith published by Prentice Hall in 1996 (ISBN 0-13-489824-9).

@node Switched systems,  , Algebraic loops, Introduction
@comment  node-name,  next,  previous,  up
@section Switched systems
@cindex Switched systems
@cindex Hybrid systems
@cindex logic

Some systems contain switch-like components. For example an electrical
system may contain on-off switches and diodes and a hydraulic system may
shut-off valves and non-return valves. 

Such systems are sometimes called hybrid systems. The modelling an
simulation of such systems is the subject of current research.
@strong{MTT} implements a simple pragmatic approach to the modelling and
simulation of such systems via two new Bond Graph components:
@vtable @code
@item ISW     
        a switched @code{I} component
@item CSW     
        a switched @code{C} component
@end vtable

These switches are user controlled through the logic representation
(@pxref{Simulation logic}).

@node User interface, Creating Models, Introduction, Top
@comment  node-name,  next,  previous,  up
@chapter User interface
@cindex User interface
@pindex User interface
There are two user interfaces to  @strong{MTT}: a command line interface
(@pxref{Command line interface}) and a menu-driven interface
(@pxref{Menu-driven interface}).

@menu
* Menu-driven interface::       
* Command line interface::      
* Options::                     
* Utilities::                   
@end menu

@node Menu-driven interface, Command line interface, User interface, User interface
@comment  node-name,  next,  previous,  up
@section Menu-driven interface
@cindex Menu-driven interface
@pindex Menu-driven interface
The Menu-driven interface for @strong{MTT} is invoked as:
@example
xmtt
@end example
This will bring up a menu which should be self explanatory :-).
Various messages will be echoed in the window from whence @strong{xMTT}
was invoked.

@node Command line interface, Options, Menu-driven interface, User interface
@comment  node-name,  next,  previous,  up
@section Command line interface
@cindex Command line interface
@pindex Command line interface
The command line interface for @strong{MTT} is of the form:
@example
mtt [options] <system_name> <representation> <language>
@end example
@vtable @code
@item [options]
        the (optional) option switches  (@pxref{Options})
@item <system_name>    
        the name of the system being transformed 
@item <representation>    
        the mnemonic for the system representation (@pxref{Representation summary})
@item <language>    
        the mnemonic for language for the representation (@pxref{Languages})
@end vtable
for example
@example
mtt rc rep view
@end example
creates a view of the report describing system rc and
@example
mtt rc sm m
@end example
creates an m file (suitlable for Octave or Matlab) containing state
matrices describing the system rc.
@node Options, Utilities, Command line interface, User interface
@comment  node-name,  next,  previous,  up
@section Options
@cindex options
@cindex alias options

@strong{MTT} has a number of optional switches to control its
operation. These are invoked immediately after `mtt' on the command
line; for example:
@example
mtt -o -ss -cc syst cbg view
@end example
invokes the @code{-o}, @code{-ss}, and @code{-cc} options.

If you wish to use an option  all the time, use the
alias function appropriate to the shell you are using. For example,
using bash:
@example
alias mtt='mtt -o -ss -cc'
@end example
Means that the previous example can be executed using
@example
mtt syst cbg view
@end example

@menu
* Available options::           
* Model-specific options::      
@end menu

@node Available options, Model-specific options, Options, Options
@comment  node-name,  next,  previous,  upThe available options are:
@subsection Available options
@vtable @code
@item 	-A
		solve algebraic equations symbolically
@item	-abg
		start at abg.m representation
@item	-ae <method>
	algebraic equation solver: reduce|hybrd|dassl|hooke
@item	-cc
		C++ code generation
@item	-cr
		use cr before resolving equations
@item	-D
		debug -- leave log files etc
@item	-d <dir>
	use directory <dir>
@item	-dc
		maximise derivative (not integral) causality
@item	-dr <dir>
	use files contained in <dir>
@item	-I
		prints more information
@item	-i <method>
	integration method: implicit|euler|rk4|dassl
@item	-o
		ode is same as dae
@item	-oct
		use oct files in place of m files where appropriate
@item	-opt
		optimise code generation (equivalent to -optl)
@item	-optl
		locally optimise code generation (line-by-line)
@item	-ntmpvar <N>
	declare <N> temporary variables (default=$num_tmp_var)
@item	-p
		print environment variables
@item	-partition
	partition hierachical system
@item	-pdf
		generate pdf in place of ps
@item	-q
		quiet mode -- suppress MTT banner
@item	-r
		reset time stamp on representation
@item	-s
		generate sensitivity BG (use mtt -s sSys rep lang)
@item	-ss
		use steady-state info to initialise simulations
@item	-stdin
		read input data from standard input for  simulations
@item	-sub <subsys>
	operate on subsystem <subsys>
@item	-t
		tidy mode (default)
@item	-trace
		just indicate what mtt will do - but do not do it
@item	-u
		untidy mode (leaves files in current dir)
@item	-v
		verbose mode (multiple uses increment the verbosity)
@item	--version
	print version and exit
@item	--versions
	print version of mtt and components and exit
@item	-viewlevel <N>
	view <N> levels of hierachy
@end vtable

@menu
* Experimental options::        
* Deprecated options::          
@end menu

@node Experimental options, Deprecated options, Available options, Available options
@comment  node-name,  next,  previous,  up
@subsubsection Experimental options
There are some experimental options. These have not yet been heavily tested and should be used with caution.
@vtable @code
@item	-optg
		globally optimise code generation (full vector)
@item	-make-sort
	use sorted equations (sese, generated by make)
@item	-no-reduce
	try not to use symbolic algebra
@item	-sort
		use sorted equations (sese, generated by seqn)
@end vtable

@node Deprecated options,  , Experimental options, Available options
@comment  node-name,  next,  previous,  up
@subsubsection Deprecated options
C code generation is now deprecated in favour of C++ generation
@vtable @code
@item	-c
		c-code generation
@end vtable

@node Model-specific options,  , Available options, Options
@subsection Model specific options
@cindex Model-specific options
It is often desirable to keep the options used to build a model associated with the directory in which the model is contained, along with information about compiler options or paths to component libraries. In these cases, it is convenient to create an executable shell script, say @code{call_mtt} which sets environment variables and options before calling mtt proper, for example:
@example
@verbatim
#! /bin/sh
# call_mtt: sets model specific environment and options

## Processor flags

# use 32 bit Reduce
export SYMBOLIC="reduce"

# set compiler debug and optimization options
export MTT_CXXFLAGS="${MTT_CXXFLAGS}\
        -Wall-Wno-unused -Wuninitialized\
        -O1 -march=pentiumpro -save-temps"

## Model flags

# use directory ../.. as base directory
export DIR=${DIR:-${PWD}/../..}

# additional components are in directory ../comp
export MTT_COMPONENTS="${MTT_COMPONENTS}:${DIR}/comp"

# additional constitutive relationships are in ../cr
export MTT_CRS="${MTT_CRS}:${DIR}/cr"

# C header files in ../cr/h
export MTT_CXXINCS="${MTT_CXXINCS} -I${DIR}/cr/h"

# call mtt with model specific options
exec ${MTTPATH}/mtt -cc -cr -i euler -D -optl -ntmpvar 1200 $*
@end verbatim
@end example

which may then be used in place of mtt on the command line,

@example
./call_mtt sys odeso gnuplot
@end example

@node Utilities,  , Options, User interface
@comment  node-name,  next,  previous,  up
@section Utilities
@cindex Utilities
@pindex Utilities
@strong{MTT} provides some utilities to help you keep track of model
building and to keep things clean and tidy. The commands, and there
purpose are:
@ftable @code
@item mtt help
        Lists the help/browser commands
@item mtt copy <system>
        Copies the system (ie directory and enclosed files) to the
current working directory.
@item mtt rename <old_name> <new_name>
        Renames all of the defining representations (@pxref{Defining
representations}) and textually changes each file appropriately.
@item mtt <system> clean
        Remove all files generated by @strong{MTT} associated with
system `system'.
@item mtt clean
        Remove all files generated by @strong{MTT} associated with
all systems within the current directory.
@item mtt system representation vc
        Apply version control to representation `representation' of
system `system'.
@item mtt system vc
        Apply version control to all representations (under version control)
system `system'.
@end ftable
These are described in more detail in the following sections.

@menu
* Help::                        
* Copy::                        
* Clean::                       
* Version control::             
@end menu

@node Help, Copy, Utilities, Utilities
@comment  node-name,  next,  previous,  up
@subsection Help
@cindex Help
@cindex browser
@strong{MTT} implements a browser to keep track of all the systems,
subsystems and constitutive relationships that you, and others may
write. It is invoked in the following ways:
@example
       mtt help representations
       mtt help components
       mtt help examples 
       mtt help crs
       mtt help representations <match_string>
       mtt help components <match_string>
       mtt help examples  <match_string>
       mtt help crs <match_string>
       mtt help <component_or_example_or_CR_name>
@end example

@menu
* help representations::        
* help components::             
* help examples::               
* help crs::                    
* help <name>::                 
@end menu

@node help representations, help components, Help, Help
@comment  node-name,  next,  previous,  up
@subsubsection help representations
@cindex help
@cindex representations

The command 
@example
mtt help representations
@end example
lists all of the representations  (@pxref{Representations}) available in
@strong{MTT}. These may change as the version number of @strong{MTT}
increases.

The command 
@example
mtt help representations <match_string>
@end example
lists those representation which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help representations descriptor
@end example
gives all representations containing the word @code{descriptor}.

@node help components, help examples, help representations, Help
@comment  node-name,  next,  previous,  up
@subsubsection help components
@cindex help
@cindex components

The command 
@example
mtt help components
@end example
lists all of the components  (@pxref{Components}) available in
@strong{MTT}. These may change as the version number of @strong{MTT}
increases.

The command 
@example
mtt help components <match_string>
@end example
lists those component which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help components source
@end example
gives all components containing the word @code{component}.

@node help examples, help crs, help components, Help
@comment  node-name,  next,  previous,  up
@subsubsection help examples
@cindex help
@cindex examples

This command provides a good way to get started in @strong{MTT}. having
found an interesting example, copy it to your working directory using
@example
mtt copy <example_name>
@end example
(@pxref{Copy})

@example
mtt help examples
@end example
lists all of the examples  available in
@strong{MTT}. 
This list will change as more examples are added.

The command 
@example
mtt help examples <match_string>
@end example
lists those component which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help examples pharmokinetic
@end example
gives all examples containing the word @code{pharmokinetic}.

@node help crs, help <name>, help examples, Help
@comment  node-name,  next,  previous,  up
@subsubsection help crs
@cindex help
@cindex crs

The command 
@example
mtt help crs
@end example
lists all of the constitutive relationships   (@pxref{Constitutive
relationship}) available in
@strong{MTT}. These may change as the version number of @strong{MTT}
increases.

The command 
@example
mtt help crs <match_string>
@end example
lists those constitutive relationships which contain the string @code{match_string}.
This string can be any regular expression  (see standard Linux
documentation under @code{awk}).
For example
@example
mtt help crs sin
@end example
gives all crs containing the word @code{sin}.

@node help <name>,  , help crs, Help
@comment  node-name,  next,  previous,  up
@subsubsection help <name>
@cindex help
@cindex <name>

The command 
@example
mtt help <name>
@end example
gives a detailed description of the entity called @code{name}.

@node Copy, Clean, Help, Utilities
@comment  node-name,  next,  previous,  up
@subsection Copy
@cindex Copy

@strong{MTT} provides a way of copying examples to your working directory:
@example
mtt copy <example_name>
@end example

Use the  command
@example
mtt help examples
@end example
(@pxref{help examples}) to find something of interest.

Note that components and constitutive relationships are automatically
copied when required.

@node Clean, Version control, Copy, Utilities
@comment  node-name,  next,  previous,  up
@subsection Clean
@cindex Clean
@strong{MTT} generates a lot of representations in a number of
languages.
Some of these you will edit yourself; others can always be recreated by
@strong{MTT}. It makes sense, therefore to have a utility that removes
all of these other files when you have finished actively working with a
particular system. These are two versions:
@enumerate
@item
@code{mtt system clean}
@item
@code{mtt clean}
@end enumerate
The first removes all files that can be regenerated with @strong{MTT}
associated with system `system'; the second removes all such files
associated with all systems in the current working directory.

The files which remain after such a clean are the Defining
representations (@pxref{Defining representations}).

@node Version control,  , Clean, Utilities
@comment  node-name,  next,  previous,  up
@subsection Version control
@cindex Version control

When you are working on a modeling project, it is easy to forget what
changes you made to a system and why you made them. Sometimes, you may
regret some changes and wish to revert to an earlier version: even if
you use .old files this may be difficult to achieve safely.

These are very similar problems to those faced by software developers
and can be solved in the same way: using version control.@strong{MTT}
provides version control using the standard GNU Revision Control System
(RCS). This is hidden from the user, but is fully complementary to
direct use of RCS (e.g. via emacs vc commands) to the more experienced
user who wishes to do so.

The only files that you should ever change (i.e. the ones never
overwritten by @strong{MTT}) are the Defining representations
(@pxref{Defining representations}).

All of the files, with the exception of @code{system_abg.fig}, 
are initially created by @strong{MTT} and contain the RCS header for
version control.


The @strong{MTT} version control will automatically expand this part of
the text to include all change comments that you give it -- so will
direct use of RCS (e.g. via emacs vc commands)

The @strong{MTT} version commands are as follows:
@ftable @code
@item mtt system representation vc
        Apply version control to representation `representation' of
system `system'.
@item mtt system vc
        Apply version control to all representations (under version control)
system `system'.
@end ftable

The first is appropriate after you have made a revision to a single
file.  It will prompt you for a change comment; this will be
automatically included in the file header. In addition, enough
information will be saved to enable any  version to be retrieved via
RCS.

The second is appropriate to record the state of the entire model. This
assumes that all relevant files have been recorded by the first version
of the command.  Once again, old versions of the entire model can be
retrieved using the relevant RCS commands.

A subdirectory `RCS' is created to hold this information. You need not
bother about the contents, except that you must not delete any files
within `RCS'.

@node Creating Models, Simulation, User interface, Top
@comment  node-name,  next,  previous,  up
@chapter Creating Models
@cindex  Creating Models

@strong{MTT} helps you to analyse and transform system models --
ultimately the process of capturing the real world in a model is up to
you.  This chapter discusses the @strong{MTT} aspects of creating a
model. For convenience, this is divided into creating simple models and
creating complex models.

@menu
* Quick start::                 
* Creating simple models::      
* Creating complex models::     
@end menu

@node Quick start, Creating simple models, Creating Models, Creating Models
@section Quick start
@cindex Quick start
@pindex Quick start

It is probably worth a quick skim though @strong{MTT} to get a flavour of
what it can do before plunging into the detail of the rest of this
document. Here is a series of commands to do this.

Copy an initial set of files describing the bond graph.
@example
mtt copy rc
@end example
@noindent 
Move to it.
@example
cd rc
@end example
@noindent 
@noindent 
View the acausal bond graph (the system is called ``rc'').
@example
mtt rc abg view
@end example
@noindent 
View the causal bond graph of the system.
@example
mtt rc cbg view
@end example
@noindent 
View the corresponding ordinary differential equations (ode).
@example
mtt rc ode view
@end example
@noindent 
View the system (output) step response
@example
mtt rc sro view
@end example

@noindent 
An alternative (but more general) way of achieving the same result is
@example
mtt -cc rc odeso view
@end example

@noindent 
View the system transfer function
@example
mtt rc tf view
@end example
@noindent 
View the log modulus frequency response of the system.
@example
mtt rc lmfr view
@end example

@noindent 
View the log modulus frequency response of the system for 100
logarithmically spaced frequencies in the range 0.1 to 10
radians per second.
@example
mtt rc lmfr view 'W=logspace(-1,1,100);'
@end example

@strong{MTT} has a report generation ((@pxref{Report}) facility which
can generate a hypertext description of the system.
@example
mtt rc rep hview
@end example

The report contents are specified by the rep representation
(@pxref{Report}), in this case the corresponding file is:
@example
% %% Outline report file for system rc (rc_rep.txt)

mtt rc abg tex
mtt rc struc tex
mtt rc cbg ps
mtt rc ode tex
mtt rc ode dvi
mtt rc sm tex
mtt rc tf tex
mtt rc tf dvi
mtt rc sro ps
mtt rc lmfr ps
mtt rc odes h
mtt rc numpar txt
mtt rc input txt
mtt -cc rc odeso ps
mtt rc rep txt
@end example
A non-hypertext version can be viewed using:
@example
mtt rc rep view
@end example

Now have a go at modifying the bond graph.
@example
mtt rc abg fig
@end example
This brings up the bond graph in Xfig (@pxref{Xfig}).  Try creating a
system with two rs and 2 cs.

More examples can be found using
@example
mtt help examples
@end example
Details of an example can be found using
@example
mtt help <example_name>
@end example
and copied using
@example
mtt copy <example_name>
@end example

Lots of examples are available.
@example
mtt help examples
@end example
lists them and
@example
mtt copy <name>
@end example
gets you an example.

@ifhtml
A number of examples are to be found
<A
HREF="http://www.mech.gla.ac.uk/~peterg/software/MTT/examples/Examples/Examples.html"> here</A>.
@end ifhtml

@node Creating simple models, Creating complex models, Quick start, Creating Models
@comment  node-name,  next,  previous,  up
@section Creating simple models
@cindex Creating simple models

For then purposes of this section, simple models are those which are
built up from bond graphs involving predefined components. In contrast,
more complex systems (@pxref{Creating complex models}) need to be built
up hierarchically.

The recommended sequence of steps to create a simple model is:
@enumerate
@item Decide on a name for the system; let us call it `syst' for the
  purposes of this discussion. 
@item Invoke the Bond Graph editor to draw the acausal Bond Graph.
@example
  mtt syst abg fig
@end example
@item Draw the Bond Graph  (@pxref{Language fig (abg.fig)}), including
  the bonds (@pxref{Bonds}), the components (@pxref{Components}) and any
  artwork (@pxref{artwork}) to make the Bond Graph more readable. The
  graphical editor xfig is (@pxref{Xfig}) is self-explanatory.
  The icon library is helpful here (see @pxref{icon library}).
@item Add causal strokes (@pxref{strokes}) where needed to define
  causality. As a general rule, use the minimum number of strokes needed
  to define the problem; this will often be only on the @code{SS} components.
  (@pxref{SS components}).
  
  Save the bond graph.
  
@item View the corresponding causal bond graph.
@example
  mtt syst cbg view
@end example
@enumerate
@item 
    At this stage, @strong{MTT} will warn you that the labeled components do
    not appear in the label file - this can safely be ignored.
@item
  @strong{MTT} will indicate the percentage of components which are
    causally complete -- ideally this will be 100%. Components which are
    not causally complete will be listed.
@item
    A view of the causal bond graph will be created. The added causal
    strokes are indicated in blue, undercausal components in green and
    overcausal components in red.
@item
    If the bond graph is causally complete, proceed to the next step,
    otherwise think hard and return to the first step.
@end enumerate

@item
At this stage, no constitutive relationships have been
defined. Nevertheless, @strong{MTT} will proceed in a semi-qualitative
fashion by assuming that all constitutive relationships are unity (and
therefore linear). It may be useful at this stage to view various
derived representations to check the overall model properties before
proceeding further. For example:
@enumerate
@item
View the system Differential-algebraic equations
@example
mtt syst dae view
@end example
@item
View the system state matrices
@example
mtt syst sm view
@end example
@item
View the system transfer function
@example
mtt syst tf view
@end example
@item
View the system step response
@example
mtt syst sro view
@end example
@end enumerate

@item
As well as creating the causal bond graph, @strong{MTT} has also
generated templates for other text files 
(@pxref{Defining representations})
used to further specify the
system.
These can now be edited using your favorite text editor (@pxref{Text
editors}).

@item @strong{MTT} will now generate the representations
(@pxref{Representation summary})that you desire.
For example the system can be simulated by
@example
mtt syst odeso view
@end example
@strong{MTT} will complain if a component is named in the bond graph but
not in the label file and vice versa. This mainly to catch typing errors.

@end enumerate

@node Creating complex models,  , Creating simple models, Creating Models
@comment  node-name,  next,  previous,  up
@section Creating complex models
@cindex Creating complex models

Complex models -- in distinction to simple models (@pxref{Creating
simple models}) -- have a hierarchical structure. In particular, bond
graph components can be created by specifying their bond
graph. Typically, such components will have more than one port
(@pxref{Ports}); within each component, ports are represented by
named SS components (@pxref{Named SS components}); outwith
each component, ports are unambiguously identified by 
labels (@pxref{Port labels}) and vector labels (@pxref{Vector port labels}).

Complex models are thus created by conceptually decomposing the system
into simple subsystems, and then creating the corresponding bond graphs.
The procedure for simple systems (@pxref{Creating simple models}) is
then followed using the top level system (@pxref{Top level}); @strong{MTT} then recursively
operates on the lower level systems.

The report representation (@pxref{Report}) provides a convenient way of
viewing a complex system.

An example of such a system can be created as follows:
@example
mtt copy twolink
mtt twolink rep hview
@end example

@ifhtml
The result is <A
HREF="./examples/twolink/twolink_rep/twolink_rep.html"> here</A>.
@end ifhtml

@menu
* Top level::                   
@end menu

@node Top level,  , Creating complex models, Creating complex models
@comment  node-name,  next,  previous,  up
@subsection Top level
@cindex Top level
The top level of a complex model contains subsystems but is not, itself,
contained by other systems. 
It has the following special features:
@itemize @bullet
@item
its name is used in the mtt command as the system name.
@item
all named SS componenents (@pxref{Named SS components}) are treated as
ordinary SS components (@pxref{SS components}).
@end itemize



@c      node   next  prev  up
@node Simulation, Sensitivity models, Creating Models, Top
@chapter Simulation
@cindex Simulation
@pindex Simulation
One purpose of modelling is to simulate the modeled dynamic
system. Although this is just another transformation (@pxref{What is a
Transformation?}) and therefore is covered in the appropriate chapter
(@pxref{Representations}), it is important enough to be given its own
chapter.

Simulation is typically performed using an appropriate simulation
language (which is often inappropriately conflated with modelling
tools). @strong{MTT} provides a number of alternative routes to
simulation based on the following representations (@pxref{Representations}):
@ftable @code
@item cse
        constrained-state differential equation form
@item ode
        ordinary differential (or state-space) equations
@c  @item dae
@c          differential-algebraic (or generalised state-space) equations --
@c  these may be linear or nonlinear.
@end ftable
in each case these equations may be
linear or nonlinear.

Special cases of numerical simulation, appropriate to @emph{linear}
systems, are:
@ftable @code
@item   ir
        impulse response - state 
@item   iro
        impulse response - output 
@item   sr
        impulse response - state 
@item   sro
        impulse response - output 
@end ftable

There are a number of languages (@pxref{Languages}) which can be used to describe these
representations for the purposes of numerical simulation:
@ftable @code
@item m
        @code{octave} a high-level interactive language for numerical
        computation.
@item c
        @code{gcc} a c compiler.
@item cc
        @code{g++} a C++ front-end to gcc.
@end ftable

There are a number solution algorithms available:
@itemize @bullet
@item
explicit solution via the matrix exponential
@item
backward Euler integration (implicit)
@item
forward Euler integration (explicit)
@item
Runge Kutta IV integration (explicit, fixed step)
@item
Hybrd algebraic solver (MINPACK, Octave fsolve)
@c  @item
@c  LSODE (Hindmarsh's ODE solver as implemented in Octave)
@c  @item
@c  DASSL (Petzold's DAE solver as implemented in Octave) (Unavailable just now)
@end itemize

 However, all combinations of representation, language and solution
method are not supported by @strong{MTT} at the moment. Given a system
`system', some recommended commands are:
@ftable @code
@item mtt system iro view
        creates the impulse response of a @emph{linear} system via the
system_sm.m representation using explicit solution via the matrix exponential.
@item mtt system sro view
        creates the step response of a @emph{linear} system via the system_sm.m
representation using explicit solution via the matrix exponential.
@c  @item mtt system odeso view
@c          creates the step response of a @emph{nonlinear} system via the
@c  system_ode.m representation using either METHOD=Euler or
@c  METHOD=LSODE in the parameter file (@pxref{Simulation parameters}).
@item mtt -cc system odeso view
        creates the response of a @emph{nonlinear} system via the
system_ode.cc representation using implicit integration.
@item mtt -cc -i euler system odeso view
        creates the response of a @emph{nonlinear} system via the
system_ode.cc representation using euler integration.
@end ftable

Simulation parameters are described in the system_simpar.txt file
(@pxref{Simulation parameters}).

The steady-state solution of a system can also be
``simulated''(@pxref{Steady-state solutions}).
@menu
* Steady-state solutions::      
* Simulation parameters::       
* Simulation input::            
* Simulation logic::            
* Simulation initial state::    
* Simulation code::             
* Simulation output::           
@end menu

@node Steady-state solutions, Simulation parameters, Simulation, Simulation
@comment  node-name,  next,  previous,  up
@section Steady-state solutions 
@cindex Steady-state solutions

@menu
* Steady-state solutions - numerical(odess)::  
* Steady-state solutions - symbolic (ss)::  
@end menu

@node Steady-state solutions - numerical(odess), Steady-state solutions - symbolic (ss), Steady-state solutions, Steady-state solutions
@comment  node-name,  next,  previous,  up
@subsection Steady-state solutions (odess)
@cindex Steady-state solutions - numerical

@strong{MTT} can compute the steady-state solutions of an ordinary
differential equation; this used the octave function `fsolve'. The
solution is computed as a function of time using the input specified in
the input file. The simulation parameter file (@pxref{Simulation
parameters}) is used to provide the time scales.

For example
@example
mtt copy rc
cd rc
mtt rc odess view
@end example

@node Steady-state solutions - symbolic (ss),  , Steady-state solutions - numerical(odess), Steady-state solutions
@comment  node-name,  next,  previous,  up
@subsection Steady-state solutions (ss) 
@cindex Steady-state solutions - symbolic
A rudimentary form of steady-state solution exists in mtt.
The steady states and inouts are supplied by the user in the file
system_simpar.r and the corresponding output and sate derivative
computed by @strong{MTT} using
@example
mtt system ss view
@end example

For example
@example
mtt copy rc
cd rc
mtt rc sspar view
mtt rc ss view
@end example


@node Simulation parameters, Simulation input, Steady-state solutions, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation parameters
@cindex Simulation parameters

Simulation parameters are set in the system_simpar.txt file. At the
moment this sets the following variables:
@itemize @bullet
@item LAST
        the last simulation time
@item DT
        the incremental time (for plotting)
@item STEPFACTOR
        the number of integration steps per DT -- thus the integration
        interval is DT/STEPFACTOR
@c ; for sparse implicit integration (@pxref{Sparse
@c implicit integration}) the number of conjugate-gradient minimisation
@c steps.
@c  @item METHOD
@c          The integration methods available appear in the following table
@item WMIN
        Minimum frequency = 10^WMIN
@item WMAX
        Maximum frequency = 10^WMAX
@item WSTEPS
        Number of Frequency steps.
@item INPUT
        The input index for frequency response
@end itemize

There are a number of solution algorithms
@itemize @bullet
@item Euler
        basic Euler integration (@pxref{Euler integration}). This method
is simple, but not recommended for stiff systems.
@item Implicit
        semi-implicit integration  (@pxref{Implicit integration}) - uses the smx representation to give
        stability.
@item Runge Kutta IV
        fixed step Runge Kutta fourth order integration (@pxref{Runge Kutta IV integration}).
@item Hybrd
        numerical algebraic equation solver
        

@c @item ImplicitS
@c         Sparse semi-implicit integration  (@pxref{Sparse implicit integration})
@c -- takes advantage of the sparsity of the A matrix.
@c @item LSODE
@c         the variable step-size method that comes with Octave (@pxref{Octave}).
@end itemize

@menu
* Euler integration::           
* Implicit integration::        
* Runge Kutta IV integration::  
* Hybrd algebraic solver::      
@end menu

@node Euler integration, Implicit integration, Simulation parameters, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Euler integration
@cindex Euler integration
Euler integration approximates the solution of the Ordinary Differential Equation 
@example
dx/dt = f(x,u)
@end example
by
@example
x := x + f(x,u)*DDT
@end example
where
@example
DDT = DT/STEPFACTOR
@end example
If the system is linear, stability is ensured if the integer STEPFACTOR
is chosen to be greater than the real number
@example
(maximum eigenvalue of -A)*DT/2
@end example
where A is the nxn matrix appearing in
@example
f(x,u) = Ax + Bu
@end example
If the system is non linear, the linearised system matrix A should act
as a guide to the choice of STEPFACTOR.

@node Implicit integration, Runge Kutta IV integration, Euler integration, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Implicit integration
@cindex Implicit integration
Implicit integration approximates the solution of the Ordinary Differential Equation 
@example
dx/dt = f(x,u)
@end example
by
@example
(I-A*DT)x := (I-A*DT)x + f(x,u)DT
@end example
where A is the linearised system matrix. This implies the solution of N
(=number of states) linear equations at each sample interval. The OCTAVE
version used the `\' operator to solve the set of linear equations, the
C version uses LU decomposition.

If the system is linear, stability is ensured unconditionaly. If the
system is non-linear, then the method still works well.

This method is nice in that choice of DT trades of accuracy against
computation time without compromising stability. In addition, the
correct stready-state values are achieved.

This approach can also be used for constrained state equations of the
form:
@example
E(x) dx/dt = f(x,u)
@end example
where E(x) is a state-dependent matrix. The approximate solution is then
given by:
@example
(E(x)-A*DT)x := (E(x)-A*DT)x + f(x,u)DT
@end example
which reduces to the ordinary differential equation case when E(x)=I.

The _smx representation includes the E matrix.

@node Runge Kutta IV integration, Hybrd algebraic solver, Implicit integration, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Runge Kutta IV integration
Runge Kutta IV approximates the solution of the Ordinary Differential Equation

@example
dx/dt = f(x,t)
@end example

by

@example
x := x + (DT/6)*(k1 + 2*k2 + 2*k3 + k4)
@end example

where

@example
k1 := f(x,t)
k2 := f(x+(1/2)*k1,t+(1/2)*DT)
k3 := f(x+(1/2)*k2,t+(1/2)*DT)
k4 := f(x+k3,t+DT)
@end example

The @strong{MTT} implementation of Runge-Kutta integration
is a fourth order, fixed-step, explicit integration method.

For some systems of equations, the increased accuracy of using a fourth order
method can allow larger step-lengths to be used than would allowed by the
 lower order Euler integration method.

It should be noted that during the interemediate calculations (k1...k4),
 the input vector @code{u} is not advanced w.r.t. time; the system inputs are
assumed to be constant over the period of the integration step-length.

@node Hybrd algebraic solver,  , Runge Kutta IV integration, Simulation parameters
@comment  node-name,  next,  previous,  up
@subsection Hybrd algebraic solver

The hybrd algebraic solver of @uref{http://www.netlib.org/minpack/hybrd.f,MINPACK},
which is used by Octave in the @code{fsolve} routine, may be used in conjunction
with one of the other integration methods to solve semi-explicit, index 1, differential
algebraic equations; these may be generated in @strong{MTT} models by use of 
@code{unknown} SS Components @pxref{SS component labels}.

This method requires that compiled simulation code is used; either -cc or -oct.
To perform a simulation based on a model @code{sys},

@example
mtt -cc -ae hybrd -i euler sys odeso view
@c XXX: should be daeso view?
@end example

@strong{MTT} will attempt to minimise the residual error at each integration time-step
using the hybrd routine.

This method of simulation is particularly well suited to stiff systems where very fast
dynamics are of little interest. Care must be taken to ensure that an acceptable level
of convergence is achieved by the solver for the system under investigation.
@c XXX: tolerance option

@c @node Sparse implicit integration,  , Implicit integration, Simulation parameters
@c @comment  node-name,  next,  previous,  up
@c @subsection Sparse implicit integration
@c @cindex Sparse implicit integration
@c This is an experimental approach for large (N>50) systems.

@c Implicit integration (@pxref{Implicit integration}) requires the
@c solution of N linear equations at each step. This is an O(N^3) operation
@c which can be time consuming for large (N>50) systems. However, the A
@c matrix (and hence the (I-A*DT) matrix) is often sparse - most elements
@c are zero.

@c This method uses a conjugate-gradient optimisation method to solve the
@c linear equations
@c @example
@c (I-A*DT)x := (I-A*DT)x + f(x,u)DT
@c @end example
@c by recasting them as the minimisation of the quadratic function
@c @example
@c [(I-A*DT)x_new - (I-A*DT)x_old + f(x,u)DT]^2
@c @end example
@c with respect to x_new. This is solved by the conjugate gradient method.
@c MTT generates two representations _smxx.m and _smxtx to compute
@c (I-A*DT)x and (I-A*DT)'x respectively making full use of the sparsity of
@c the (I-A*DT) matrices to speed up the minimisation procedure.

@c A fixed number of iterations (STEPFACTOR) are used in each optimisation
@c to give a fixed simulation time. This must be chosen by the user, but
@c between 5N and 10N seems ok. Note that the initial value of the
@c optimisation is x_old.

@node Simulation input, Simulation logic, Simulation parameters, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation input
@cindex Simulation input
This is defined in the system_input.txt file. A default file is created
automatically by @strong{MTT}. This is done explicitly by
@example
mtt system input txt
@end example
If the file already exists, the same command checks that all inputs are
defined and that all defined inputs exist in the system and promts the
user to correct discrepancies.

Inputs are defined by the full system name appearing in the structure
file (@pxref{Structure (struc)}). They can depend on states (again defined by
name), time (defined by t) and parameters

For example:
@example
system_pump_l_1_u       = 4e5*atm;
system_pump_r_1_u       = 4e5*(t<10)*atm;
system_ss_i             = 0*kg;
system_ss_o             = 3e-3*kg;
system_v_1_u            = (t>10);
system_v_ll_1_u         = 1;
system_v_lr_1_u         = (t<10);
system_v_ul_1_u         = 0;
system_v_ur_1_u         = (t>10);
@end example

@node Simulation logic, Simulation initial state, Simulation input, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation logic
@cindex Simulation logic
This is defined in the system_logic.txt file. A default file is created
automatically by @strong{MTT}. This is done explicitly by
@example
mtt system logic txt
@end example
If the file already exists, the same command checks that the logic
corresponding to all switch states (@pxref{Switched systems}) are
defined and that all defined logic exists in the system and promts the
user to correct discrepancies.

Logical inputs are defined by the full system name corresponding to
MTT_switch components appearing in the structure file (@pxref{Structure
(struc)}) @emph{with `_logic' appended}. They can depend on states (again defined by name), time
(defined by t) and parameters

For example:
@example
bounce_ground_1_mtt_switch_logic	= bounce_intf_1_mtt3<0;
@end example

@node Simulation initial state, Simulation code, Simulation logic, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation initial state
@cindex Simulation initial state
This is defined in the system_state.txt file. A default file is created
automatically by @strong{MTT}. This is done explicitly by
@example
mtt system state txt
@end example
If the file already exists, the same command checks that all states are
defined and that all defined states exist in the system and prompts the
user to correct discrepancies.

States are defined by the full system name appearing in the structure
file (@pxref{Structure (struc)}). They can depend on parameters.
For example
@example
system_c_l	= (1e4/k_l)/kg;
system_c_ll	= (1e4/k_s)/kg;
system_c_lr	= (1e4/k_s)/kg;
system_c_u	= (1e4/k_l)/kg;
@end example


@c  The initial state of a simulation of is set in the @code{state}
@c  representation with the language @code{txt}.

@c  As usual, @strong{MTT} defaults this for you. There are two
@c  possibilities
@c  @itemize @bullet
@c  @item
@c  The -ss switch is not present: the states default to zero
@c  @item
@c  The -ss switch is present: the states default to those set in the
@c  sspar.r file.
@c  @end itemize

@node Simulation code, Simulation output, Simulation initial state, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation code
simulation code can be generated by @strong{MTT} in the form
of the @code{ode2odes} transformation. This can be produced in a number
of languages, including .m, .oct, C and C++ @pxref{Languages}.

To generate simulation code in C (deprecated):
@example
mtt -c [options] sys ode2odes c
@end example

Similarly, to generate C++ code:
@example
mtt -cc [options] sys ode2odes cc
@end example

To generate an executable based on the C++ representation:
@example
mtt -cc [options] sys ode2odes exe
@end example

@menu
* Dynamically linked functions::  
@end menu

@node Dynamically linked functions,  , Simulation code, Simulation code
@comment  node-name,  next,  previous,  up
@subsection Dynamically linked functions
@cindex Compiling C++ files
@cindex mex files
@cindex oct files
Some model representations can be compiled into dynamically loaded
code (shared objects) which are compiled prior to use in other
modelling and simulation environments; in particular, .oct files can
be generated for use in GNU Octave (@pxref{Creating GNU Octave .oct
files}) and .mex files can be generated for use in Matlab
(@pxref{Creating Matlab .mex files}) or Simulink (@pxref{Embedding MTT
models in Simulink}).  The use of compiled (and possibly
compiler-optimised) code can offer significant processing speed
advantages over equivalent interpreted functions (e.g. .m files) for
computationally intensive procedures.

The C++ code generated by @strong{MTT} allows the same code to be
generated as standalone code, Octave .oct files or Matlab .mexglx
files. Although @strong{MTT} usually takes care of the compilation
options, if it is necessary to compile the code on a machine on which
@strong{MTT} is not installed, the appropriate flag should be passed
to the compiler pre-processor:
@itemize @bullet
@item
@code{-DCODEGENTARGET=STANDALONE}
@item
@code{-DCODEGENTARGET=OCTAVEDLD}
@item
@code{-DCODEGENTARGET=MATLABMEX}
@end itemize

@node Simulation output,  , Simulation code, Simulation
@comment  node-name,  next,  previous,  up
@section Simulation output
@cindex Simulation output
The view (@pxref{Views}) representation provides a graphical
representation of the results of a simulation; the postscript language
provides the same thing in a form that can be included in a document.

These are two simulation output representations
@ftable @code
@item odes 
        ordinary differential equation solution (states)
@item odeso
         ordinary differential equation solution (output)
@end ftable    

Particular output variables can be selected by adding a fourth argument
in one of 2 forms
@ftable @code
@item 'name1;name2;..;namen' 
        plot the variables with names na1 .. namen against time
@item 'name1:name2'
                plot the variable with  name2 against that with name 1
@end ftable    

An example of plotting a single variable against time is:
@example
mtt -o -cc -ss OttoCycle odeso ps 'OttoCycle_cycle_V'
@end example
An example of plotting one variable against another is:
@example
mtt -o -cc -ss OttoCycle odeso ps 'OttoCycle_cycle_V:OttoCycle_cycle_P'
@end example

@menu
* Viewing results with gnuplot::  
* Exporting results to SciGraphica::  
@end menu

@node Viewing results with gnuplot, Exporting results to SciGraphica, Simulation output, Simulation output
@comment  node-name,  next,  previous,  up@subsection
@subsection Viewing results with gnuplot
@cindex gnuplot

Simulation plots may be conveniently selected, viewed with
@uref{http://www.gnuplot.org,gnuplot} 
and saved to file (in PostScript format) using the command

@example
mtt [options] rc odeso gnuplot
@end example

This will cause a menu to be displayed, from which states and outputs may be selected for viewing. Clicking on a @emph{parameter name} will, by default, cause the time history of the selected parameter to be displayed.

As with @strong{xMTT} (@pxref{Menu-driven interface}), the Wish Tcl/Tk interpreter must be installed to make use of this feature.

@node Exporting results to SciGraphica,  , Viewing results with gnuplot, Simulation output
@comment  node-name,  next,  previous,  up
@subsection Exporting results to SciGraphica
@cindex SciGraphica

Simulation results can be converted into an XML-format
@uref{http://scigraphica.sourceforge.net,SciGraphica} (version 0.61)
@emph{.sg} file with the command

@example
mtt [options] sys odes sg
@end example

The SciGraphica file will contain two worksheets, X_sys and Y_sys, containing
the state and output time-histories from the simulation.

@c      node   next  prev  up
@node   Sensitivity models, Representations, Simulation, Top
@chapter Sensitivity models
@cindex Sensitivity models
@pindex Sensitivity models

The sensitivity model of a system is a set of equations giving the
sensitivity of the system outputs with respect to system parameters.
@strong{MTT} has built in methods for assisting with the development of
such models.

This feature is experimental at the moment, but the following example
gives an idea of what can be achieved.
@example
mtt copy rc
cd rc
mtt -s src ode view
mtt -s src odeso view
@end example
The sensitivity system src is automatically created from the system rc
using the predefined sR and sC components together with vector junctions
(@pxref{Vector components}).  The four outputs are the two system
outputs plus the two sensitivity functions.

An alternative route is to create the sensitivity functions by symbolic
differentiation.
The following sensitivity representations are available:
@ftable @code
@item   scse
        sensitivity constrained-state equations
@item   sm
        sensitivity state matrices
@item   scsm
        sensitivity constrained-state matrices
@end ftable



@c      node   next  prev  up
@node   Representations, Extending MTT, Sensitivity models, Top
@chapter Representations
@cindex Representations
@pindex Representations
@cindex Defining representations
@cindex Representations, defining

As discussed in @ref{What is a Representation?}, a system has many
representations. The purpose of @strong{MTT} is to provide an easy way to
generate such representation by applying the appropriate sequence of 
transformations. The representations supported by @strong{MTT} are
summarised in @ref{Representation summary}.

There is a two-fold division of representations into those with which the user
defines the system and its various attributes, and those which are
derived from these. The @emph{defining representations} are listed in
@ref{Defining representations}. 

Each representation is implemented in one or more languages depending on
its use. These languages are discussed in @ref{Languages} and are
associated with appropriate tools for modifying or viewing the
representations. 

@menu
* Representation summary::      
* Defining representations::    
* Verbal description (desc)::   
* Acausal bond graph (abg)::    
* Acausal bond graph - LaTeX ready (labg)::  
* Stripped acausal bond graph (sabg)::  
* Labels (lbl)::                
* Structure (struc)::           
* Constitutive Relationship (cr)::  
* Parameters::                  
* Causal bond graph (cbg)::     
* Elementary system equations::  
* Differential-Algebraic Equations::  
* Constrained-state Equations::  
* Ordinary Differential Equations::  
* Descriptor matrices::         
* Report::                      
@end menu

@node Representation summary, Defining representations, Representations, Representations
@comment  node-name,  next,  previous,  up
@section Representation summary
@cindex Representation summary

Some of the the representations 
available in @strong{MTT} are (in alphabetical order):
@ftable @code
@item   abg
        acausal bond graph 
@item   cbg
        causal bond graph 
@item   cr
        constitutive relationship for each subsystem 
@item   cse
        constrained-state equations 
@item   csm
        constrained-state matrices 
@item   dae
        differential-algebraic equations 
@item   daes
        dae solution - state 
@item   daeso
        dae solution - output 
@item   def
        definitions - system orders etc. 
@item   desc
        Verbal description of system 
@item   dm
        descriptor matrices 
@item   ese
        elementary system equations 
@item   fr
        frequency response 
@item   input        
        numerical input declaration 
@item   ir
        impulse response - state 
@item   iro
        impulse response - output 
@item   lbl
        label file 
@item   lmfr
        loglog modulus frequency response 
@item   lpfr
        semilog phase frequency response 
@item   nifr
        Nichols style frequency response 
@item   numpar
        numerical parameter declaration 
@item   nyfr
        Nyquist style frequency response 
@item   obs
        observer equations for CGPC 
@item   ode
        ordinary differential equations 
@item   odes
        ode solution - state 
@item   odes
        ODE simulation header file 
@item   odeso
        ode solution - output 
@item   odess
        ode numerical steady-states - states 
@item   odesso
        ode numerical steady-states - outputs 
@item   rbg
        raw bond graph 
@item   rep
        report 
@item   rfe
        robot-form equations 
@item   sabg
        stripped acausal bond graph 
@item   simp
        simplification information 
@item   sm
        state matrices 
@item   smx
        state matrices containing explicit states and inputs
@item   sms
        ode 
@item   smss
        SM simulation header file 
@item   sr
        step response - state 
@item   sro
        step response - output 
@item   ss
        steady-state equations 
@item   sspar
        steady-state definition 
@item   struc
        structure - list of inputs, outputs and states 
@item   sub
        Executable subsystem list 
@item   sub
        LaTeX subsystem list 
@item   sympar
        symbolic parameters 
@item   tf
        transfer function 
@end ftable
A complete list can be found via the @code{help representations} command
(@pxref{help representations}). 

Many of these representations have more than one language (@pxref{Representations}) associated
with them.

Some of these representations define the system (@pxref{Defining
representations}).

@node Defining representations, Verbal description (desc), Representation summary, Representations
@comment  node-name,  next,  previous,  up
@section Defining representations
@cindex Defining representations

The following representations define the system and therefore must,
ultimately, be defined by the user. However, all of these are assigned
default values by @strong{MTT} and may then be subsequently edited
(@pxref{Text editors}) viewed or operated on by the appropriate tools
(@pxref{Language tools}).
@vtable @code
@item system_abg.fig
        the acausal bond graph (@pxref{Acausal bond graph (abg)})
@item system_lbl.txt
        the label file (@pxref{Labels (lbl)})
@item system_desc.tex
        the description file (@pxref{Detailed})
@item system_simp.r
        algebraic simplifications to make output more readable
        (@pxref{Symbolic parameters for simplification (simp.r)})
@item system_subs.r
        algebraic substitutions to resolve, eq trig. identities
        (@pxref{Symbolic parameters (subs.r)})
@item system_simpar.txt
        simulation parameters (@pxref{Simulation parameters})
@item system_numpar.txt
        numerical parameters (@pxref{Numeric parameters (numpar)})
@item system_input.txt
        the system input for simulations (@pxref{Simulation input})
@item system_logic.txt
        the  switching logic for simulations (@pxref{Simulation logic})
@item system_sspar.r
        defines the system steady-state (@pxref{Steady-state solutions - symbolic (ss)})
@end vtable

@node Verbal description (desc), Acausal bond graph (abg), Defining representations, Representations
@comment  node-name,  next,  previous,  up
@section Verbal description (desc)
@cindex Verbal description (desc)

Systems can be documented in LaTeX using the _desc.tex file. This file
is included in the report (@pxref{Report}) if the abg tex option
is included in the rep.txt file.  As usual, @strong{MTT} provides a
default text file to be edited by the user (@pxref{Text editors}).


@c      node   next  prev  up
@node   Acausal bond graph (abg), Acausal bond graph - LaTeX ready (labg), Verbal description (desc), Representations
@section Acausal bond graph (abg)
@cindex Acausal bond graph (abg)
@pindex Acausal bond graph (abg)

The acausal bond graph is the main input to @strong{MTT}. It is up to you, as a
system modeler, to distill the essential aspects of the system that you
wish to model and capture this information in the form of a bond graph.

The inexperienced modeler may wish to look in one of the standard
textbooks and copy some bond graphs of  systems to get going.


To create the acausal bond graph of system `sys' in language fig type:
@example
mtt sys abg fig
@end example
To create the acausal bond graph of system `sys' in language m type:
@example
mtt sys abg m
@end example
To view the acausal bond graph of system `sys' type:
@example
mtt sys abg view
@end example

@menu
* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      
@end menu

@node Acausal bond graph - LaTeX ready (labg), Stripped acausal bond graph (sabg), Acausal bond graph (abg), Representations
@section Acausal bond graph - LaTeX ready (labg)
@cindex Acausal bond graph - LaTeX ready (labg) 
@pindex Acausal bond graph - LaTeX ready (labg)
This representation exists in the fig  (@pxref{Language fig (abg.fig)})
only. It is used for high-quality figures generated using fig2dev with
the -Lpstex option.

@menu
* Language fig (abg.fig)::      
* Language m (rbg.m)::          
* Language m (abg.m)::          
* Language tex (abg.tex)::      
@end menu

@node Language fig (abg.fig), Language m (rbg.m), Acausal bond graph - LaTeX ready (labg), Acausal bond graph - LaTeX ready (labg)
@subsection Language fig (abg.fig) 
@cindex Language fig (abg.fig) 
@pindex Language fig (abg.fig) 

A bond graph is made up of:
@ftable @code
@item bonds
        To connect components together.
@item strokes
        To indicate causality.
@item components
        Either simple or compound.
@item artwork
        Irrelevant to the system but useful to the user.
@end ftable

An icon library of bonds, components and other symbols is available
within xfig (@pxref{icon library}).




@menu
* icon library::                
* bonds::                       
* strokes::                     
* components::                  
* Simple components::           
* SS components::               
* Simple components - implementation::  
* Compound components::         
* Named SS components::         
* Coerced bond direction::      
* Port labels::                 
* Vector port labels::          
* Port label defaults::         
* Vector components::           
* artwork::                     
* Valid names::                 
@end menu

@node icon library, bonds, Language fig (abg.fig), Language fig (abg.fig)
@subsubsection Icon library
@cindex Icon
@cindex library
A number of predefined iconic symbols are available within xfig. 
@example
Click onto the library icon
Click onto the library pull-down menu and select BondGraph
Select iconic symbols from the presented list
@end example

@node bonds, strokes, icon library, Language fig (abg.fig)
@subsubsection Bonds
@cindex bonds
@pindex bonds

Bonds are represented by polylines with two segments. They must be the
default style (i.e. plain not dashed or dotted). The shortest segment is
taken to be the half-arrow. its positioning is significant because:
@itemize @bullet
@item
It points in the direction of power flow; thus a bond normally points
towards C, I and R components.
@item
the corresponding side of the bond indicates flow causality; the other
side represents effort causality. This is significant when using causal
half-strokes (@pxref{strokes}). Please adopt the convention of having
the half-arrows below horizontal bonds and to the right of vertical bonds.
@end itemize



@c      node   next  prev  up
@node strokes, components, bonds, Language fig (abg.fig)
@subsubsection Strokes
@cindex strokes
@pindex strokes

Causal strokes are represented by single-segment polylines.
There are two sorts of strokes:
@itemize @bullet
@item
@emph{Full} strokes: these are the usual bond-graph strokes and determine
both the effort and flow causality in the usual way. The @emph{centre} of the
stroke should be at about one end of the bond and be at right angles to
it.
@item
@emph{Half} strokes: these are an innovation in @strong{MTT} and allow you to
specify the effort and flow causality independently. The @emph{end} of the
stroke should be at about one end of the bond and be at right angles to
it. If the causal half-stroke is on the @emph{same} side as the half-arrow
(@pxref{bonds}) then it determines @emph{flow} causality; if, on the other
hand, it is on the @emph{opposite} side to the half-arrow
(@pxref{bonds}) then it determines @emph{effort} causality.
Two half strokes on the @emph{same}, but on @emph{opposite} sides of the
bond are equivalent to a a full stroke at the same end of the bond.
@end itemize

@strong{MTT} is reasonably forgiving; but a neat diagram will be less ambiguous to
you as well as to @strong{MTT}.

Causality is indicated as follows:
@itemize @bullet
@item 
@emph{Effort} is imposed at the @emph{same} end as the stroke.
@item 
@emph{Flow} is imposed at the @emph{opposite} end as the stroke.
@end itemize



@c      node   next  prev  up
@node components, Simple components, strokes, Language fig (abg.fig)
@subsubsection Components
@cindex components
@pindex components

Components are represented by a text string in fig.  The recommended
style is: 20pt, Times-Roman and centre justified.

The component text string can be of the following forms:
@ftable @code
@item type
Just the type of the component is indicated. Components may be either
Simple components (@pxref{Simple components}) or Compound components
(@pxref{Compound components}).  For example:
@example
R
@end example
@item type:label
Both the type and the label of the component are given. The type must be
a valid name (@pxref{Valid names}.The name provides a link to more
information to be found in @xref{Labels (lbl)}. For example:
@example
R:r
@end example
@item type:label:cr
Not only are the type and the label of the component given, but also the
component cr argument. The type must be
a valid name (@pxref{Valid names}.The name provides a link to more
information to be found in @xref{Labels (lbl)}. For example:
@example
R:r:flow,r
@end example
@item type:label:expression
Expression is a mathematical expression relating the effort (called
mtt_e) to the flow (called mtt_f).
For example the following three forms are equivalent
@example
R:r:mtt_e=r*mtt_f
R:r:mtt_e-r*mtt_f=0
R:r:mtt_f=mtt_e/r
@end example
A non-linear example is:
@example
R:r:mtt_e = sin(mtt_f)
@end example

@item type*n
The name, together with the number @samp{n} of repetitions of the
component, are given. This repetition only makes sense if the component
has an even number of ports (@pxref{Port labels}); n copies of the component
are concatenated with odd Named ports (@pxref{Port labels}) of the
component being connected to the even Named ports of the previous
component in the chain in numerical order.  This feature is particularly
useful if the component is compound and can be used for, example to give
a lumped approximation of a distributed system. For example:
@example
MySystem*25
@end example
@item type:label*n
This complete form and is a combination of the simpler forms. For
example:
@example
MySystem:MyLabel*25
@end example

@end ftable

@node Simple components, SS components, components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Simple components
@cindex Simple components

The following simple components are defined in MTT.

@ftable @code
@item R
         Standard one-port R
@item C
         Standard one-port C
@item I
         Standard one-port I
@item SS
        Source-sensor
@item TF
        Transformer
@item GY
        Gyrator
@item AE
        Effort amplifier
@item AF
        Flow amplifier
@item CSW
         Switched one-port C
@item ISW
         Switched one-port I
@end ftable

@menu
* SS components::               
* Simple components - implementation::  
@end menu

@node SS components, Simple components - implementation, Simple components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection SS components
@cindex SS components

@iftex
$$

@end iftex


@code{SS} components provide input and output variables for a system;
Named SS components (@pxref{Named SS components}) provide this for
subsystems.

@node Simple components - implementation, Compound components, SS components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Simple components - implementation
@cindex  Simple components - implementation

Each simple component, with name NAME, is defined by two m files:
@ftable @code
@item NAME_cause.m
        defines the possible causal patterns for the component
@item NAME_eqn.m
        defines the equations generated 
@end ftable
Only the experienced user would normally define simple components -
Compound components (@pxref{Compound components}) are recommended for
DIY components.

@node Compound components, Named SS components, Simple components - implementation, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Compound components
@cindex  Compound components
@cindex Named SS
Compound components are systems described by bond graphs and implemented
by MTT. They have special SS components, Named SS components
(@pxref{Named SS components}), to indicate connections to the
encapsulating system.

Like any other system, they are described by a graphical Bond Graph description
(@pxref{Language fig (abg.fig)}), and a label file (@pxref{Labels (lbl)}).

By convention, all of the files describing a component live in a
directory with the same name as the component.

@menu
* Named SS components::      
@end menu

@node Named SS components, Coerced bond direction, Compound components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Named SS components
@cindex Named SS components

Named SS components provide the link from the system which @emph{defines} 
compound component to the system which @emph{uses} a compound
component @pxref{Compound components}.
A named SS components is of the form
@code{SS:[name]};

Where `name' is a name consisting of alphanumeric characters and
underscore; for example:
@example
SS:[Mechanical_1]
@end example
Each such named SS provides one of the ports
(@pxref{Ports}).
The direction of the named SS components.
(@pxref{Named SS components}) 
is coerced (@pxref{Coerced bond direction}) to have the same direction
as the bond connected to the corresponding port. Thus the direction of
the  direction of the named SS components has no significance unless the
component is at the top level of a system.

If a named SS component exists at the top level (@pxref{Top level})
and is treated as an
ordinary SS component with the given direction and with the attributes
specified in the label file (@pxref{Labels (lbl)}).

@node Coerced bond direction, Port labels, Named SS components, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Coerced bond direction
@cindex Coerced bond direction
@pindex Coerced bond direction
Named SS components (@pxref{Named SS components}) provide the mechanism
for declaring the ports (@pxref{Ports}) of a component. The
corresponding bond has a direction. However, under some circumstances,
it may be useful to reverse this direction. @strong{MTT} provides a
coercion mechanism for this: the the direction of the bond attached to
the named SS component (@pxref{Named SS components}) is replaced by the
direction of the bond attached to the component port.

@node Port labels, Vector port labels, Coerced bond direction, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Port labels
@cindex ports
@pindex ports
Most multi-port components have ports 
@pxref{Ports})which display different
behaviors; the exception to this is the junction (@code{0} and @code{1})
components. For this reason, @strong{MTT} provides a method for unambiguously
identifying the ports of a multi-port component by port labels.

A port label is indicated by a name within parentheses of the form
@code{[name]}, where `name' is a name consisting of alphanumeric
characters and underscore; for example:
@example
[Mechanical_1]
@end example
This provides a label for corresponding to the component to which the
nearest bond-end is attached.

The following rules must be be obeyed:
@itemize @bullet
@item
If a component has any port labels at all, there must be one for each
port of the component.
@c @item
@c If a component is to be used repetitively (see @ref{components}), it
@c must have an even number of ports and the odd ports are connected to the
@c even points within the chain of components.
@end itemize

Port labels may be grouped into vector port labels (@pxref{Vector port
labels}). Components with compatible (ie containing the same number of ports)
vector ports may be connected by a @emph{single} bond
(@pxref{Bonds}); such a bond implies the corresponding number of bonds
(one for each element of the vector port label). All such bonds inherit
the same direction and any @emph{explicit} causal strokes (@pxref{strokes})

@node Vector port labels, Port label defaults, Port labels, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Vector port labels
@cindex vector port labels
@cindex port labels
Port labels (@pxref{Port labels}) may be grouped into vector port
labels of the form @code{[name1,name2,name3]}. 
@example
[Mechanical_1,Electrical,Hydraulic_5]
@end example

@node Port label defaults, Vector components, Vector port labels, Language fig (abg.fig)
@comment  node-name,  next,  previous,  up
@subsubsection Port label defaults
@cindex Port label defaults
@pindex Port label defaults
Whether impicitly or explicity, all ports of components (with the
exception of 0 and 1 junctions) must have labels  (@pxref{Port
labels}). However, these can be omitted from the bond graph in the
following circumstances and default labels are supplied by @strong{MTT}.
@enumerate
@item A single unlabled inport defaults to [in]
@item A single unlabled outport defaults to [out]
@end enumerate

These defaults may, in turn be aliases (@pxref{Aliases}) for port labels
(@pxref{Port labels}) or vector port labels (@pxref{Vector port
labels}).  Combining the default and alias mechanism is a powerful tool
for creating uncluttered, yet complex, bond graph models.

@node Vector components, artwork, Port label defaults, Language fig (abg.fig)
@subsubsection Vector Components
@cindex Vector components
@pindex Vector components
Vectors of components can be created in four cases:
@code{0} junctions,
@code{1} junctions,
@code{SS} components and
@code{SS} port components.


In each case, the presence of a vector component is indicated by a
single port label  (@pxref{Port labels}) of one of two forms:
@enumerate
@item containing numerals from 1 to
the order of the vector. Thus a vector of 3 components is indicated by a
port label of the form [1,2,3].
@item  1: followed by
the order of the vector. Thus a vector of 3 components is indicated by a
port label of the form [1:3].
@end enumerate


Within the corresponding label file (@pxref{Labels (lbl)}), the
components of a vector port can be accessed using _i where i is the
corresponding index. Thus a port SS:[Electrical] appearing near the port
label  [1,2,3] could contain the port alias (@pxref{Port aliases})
@example
%ALIAS  in Electrical_1,Electrical_2,Electrical_3
@end example

@node artwork, Valid names, Vector components, Language fig (abg.fig)
@subsubsection Artwork
@cindex artwork
@pindex artwork
You are encouraged to annotate your bond graphs extensively - this makes
them an immediately readable document whilst retaining the precise and
unambiguous expressive power of the bond graph.

You may add any Fig (@pxref{Fig}) object to the bond graph as long as it
will not be interpreted as part of the bond graph.  
The reccommended way to acheive this is to put the  Bond Graph at depth
0,10,20 etc (ie depth modulo 10 is zero) and artwork at any other depth. 
@c  The recommended way to do this is to @emph{put all artwork at or below
@c  Depth 1} in the figure. @strong{MTT} ignores all objects not at depth 0.


For compatibility with earlier versions of @strong{MTT}, the following
objects are ignored even at level 0. However, their use is strongly
discouraged.
@itemize @bullet
@item
Adding text is OK as long as it cannot be confused with components
(@pxref{components}). In particular, you can include invalid component
characters such as white space, @code{"}, @code{'}, @code{!} etc.
@item
Adding boxes, arcs etc is always OK.
@item
Adding dotted or dashes lines is always OK.
@end itemize

The stripped abg file (sabg) (@pxref{Stripped acausal bond graph
(sabg)})
shows only those parts of the diagram recognised by @strong{MTT} and is
therefore useful for distinguishing artwork.
 
@node Valid names,  , artwork, Language fig (abg.fig)
@subsubsection Valid Names
@cindex valid name
@pindex valid name
A valid name is a text string containing alphanumeric characters.  It
must @strong{NOT} contain underscore @samp{_}, hyphen @samp{-}, @samp{:}
or @samp{*}.

The following names should be avoided
@example
if endif
@end example


The following reserved words in reduce should also be avoided (with any case)
@example
Commands ALGEBRAIC ANTISYMMETRIC ARRAY BYE CLEAR CLEARRULES COMMENT
CONT DECOMPOSE DEFINE DEPEND DISPLAY ED EDITDEF END EVEN FACTOR FOR
FORALL FOREACH GO GOTO IF IN INDEX INFIX INPUT INTEGER KORDER LET
LINEAR LISP LISTARGP LOAD LOAD PACKAGE MASS MATCH MATRIX MSHELL
NODEPEND NONCOM NONZERO NOSPUR ODD OFF ON OPERATOR ORDER OUT PAUSE
PRECEDENCE PRINT PRECISION PROCEDURE QUIT REAL REMFAC REMIND RETRY
RETURN SAVEAS SCALAR SETMOD SHARE SHOWTIME SHUT SPUR SYMBOLIC
SYMMETRIC VECDIM VECTOR WEIGHT WRITE WTLEVEL

Boolean Operators EVENP FIXP FREEOF NUMBERP ORDP PRIMEP

Infix Operators := = >= > <= < => + * / ^ ** . WHERE SETQ OR AND
MEMBER MEMQ EQUAL NEQ EQ GEQ GREATERP LEQ LESSP PLUS DIFFERENCE MINUS
TIMES QUOTIENT EXPT CONS Numerical Operators ABS ACOS ACOSH ACOT ACOTH
ACSC ACSCH ASEC ASECH ASIN ASINH ATAN ATANH ATAN2 COS COSH COT COTH
CSC CSCH EXP FACTORIAL FIX FLOOR HYPOT LN LOG LOGB LOG10 NEXTPRIME
ROUND SEC SECH SIN SINH SQRT TAN TANH

Prefix Operators APPEND ARGLENGTH CEILING COEFF COEFFN COFACTOR CONJ
DEG DEN DET DF DILOG EI EPS ERF FACTORIZE FIRST GCD G IMPART INT
INTERPOL LCM LCOF LENGTH LHS LINELENGTH LTERM MAINVAR MAT MATEIGEN MAX
MIN MKID NULLSPACE NUM PART PF PRECISION RANDOM RANDOM NEW SEED RANK
REDERR REDUCT REMAINDER REPART REST RESULTANT REVERSE RHS SECOND SET
SHOWRULES SIGN SOLVE STRUCTR SUB SUM THIRD TP TRACE VARNAME

Reserved Variables CARD NO E EVAL MODE FORT WIDTH HIGH POW I INFINITY
K!* LOW POW NIL PI ROOT MULTIPLICITY T

Switches ADJPREC ALGINT ALLBRANCH ALLFAC BFSPACE COMBINEEXPT
COMBINELOGS COMP COMPLEX CRAMER CREF DEFN DEMO DIV ECHO ERRCONT
EVALLHSEQP EXP EXPANDLOGS EZGCD FACTOR FORT FULLROOTS GCD IFACTOR INT
INTSTR LCM LIST LISTARGS MCD MODULAR MSG MULTIPLICITIES NAT NERO
NOSPLIT OUTPUT PERIOD PRECISE PRET PRI RAT RATARG RATIONAL RATIONALIZE
RATPRI REVPRI RLISP88 ROUNDALL ROUNDBF ROUNDED SAVESTRUCTR
SOLVESINGULAR TIME TRA TRFAC TRIGFORM TRINT

Other Reserved Ids BEGIN DO EXPR FEXPR INPUT LAMBDA LISP MACRO PRODUCT
REPEAT SMACRO SUM UNTIL WHEN WHILE WS


@end example



@node Language m (rbg.m), Language m (abg.m), Language fig (abg.fig), Acausal bond graph - LaTeX ready (labg)
@comment  node-name,  next,  previous,  up
@subsection Language m (rbg.m)
The raw bond graph of system `sys' is represented as
 an m file with heading:
@example
function [rbonds, rstrokes,rcomponents,rports,n_ports] = sys_rbg
@end example
This representation is a half-way house between the fig 
(@pxref{Language fig (abg.fig)}) and m 
(@pxref{Language m (abg.m)}) representations. It contains the
geometric information from the fig file in a form digestible by Octave
(@pxref{Octave}).

The five outputs of this function are:
@itemize @bullet
@item
rbonds
@item
rstrokes
@item
rcomponents
@item
rports
@item
n_ports
@end itemize

@emph{rbonds} is  a matrix with
@itemize @bullet
@item
one row for each bond (@pxref{bonds})
@item
columns 1 and 2 containing the x,y coordinates for one end of the bond
@item
columns 3 and 4 containing the x,y coordinates for the corner of the bond
@item
columns 5 and 6 containing the x,y coordinates for the other end of the bond
@end itemize

@emph{rstrokes} is  a matrix with (@pxref{strokes})
@itemize @bullet
@item
one row for each stroke or half-stroke
@item
columns 1 and 2 containing the x,y coordinates for one end of the stroke
@item
columns 3 and 4 containing the x,y coordinates for the other end of the stroke
@end itemize

@emph{rcomponents} is  a matrix with (@pxref{components})
@itemize @bullet
@item
one row for each component
@item
columns 1 and 2 containing the x,y coordinates of the component
@item
the remaining columns containing fig file information
@end itemize

@emph{rports} is  a matrix with (@pxref{Port labels})
@itemize @bullet
@item
one row for each component port that is explicitly labeled
@item
columns 1 and 2 containing the x,y coordinates of the port label
@item
column 3 contains the port number.
@end itemize

@emph{n_ports} is the number of ports associated with the system -- i.e. the
number of Named SS components (@pxref{Named SS components}).

@menu
* Transformation abg2rbg_fig2m::  
@end menu

@node Transformation abg2rbg_fig2m,  , Language m (rbg.m), Language m (rbg.m)
@comment  node-name,  next,  previous,  up
@subsubsection Transformation abg2rbg_fig2m
@cindex Transformation abg2rbg_fig2m

This transformation takes the acausal bond graph as a fig file 
(@pxref{Language fig (abg.fig)}) and transforms it into a raw bond graph in
m-file format (@pxref{Language m (rbg.m)}).

This transformation is implemented in GNU awk (gawk).
It scans both the fig file (@pxref{Language fig (abg.fig)})
and the label file (@pxref{Labels (lbl)}) and generates the rbg
 (@pxref{Language m (rbg.m)}) with components sorted according to the
label file.
It also generates a file sys_fig.fig containing details of the bond
graph with the components removed.


@node Language m (abg.m), Language tex (abg.tex), Language m (rbg.m), Acausal bond graph - LaTeX ready (labg)
@comment  node-name,  next,  previous,  up
@subsection Language m (abg.m)
@cindex Language m (abg.m) 
@cindex bonds
@cindex components
@cindex n_ports

The acausal bond graph of system `sys' is represented as
 an m file with heading:
@example
function [bonds,components,n_ports] = sys_abg
@end example
The three outputs of this function are:
@itemize @bullet
@item
bonds
@item
components
@item
n_ports
@end itemize

@emph{bonds} is  a matrix with
@itemize @bullet
@item
one row for each bond
@item
the first column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{effort} variable.
@item
the second column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{flow} variable.
@end itemize

@emph{components} is  a matrix with
@itemize @bullet
@item
one row for each component
@item
one column for each bond impinging on the component. The
@emph{magnitude} of each entry corresponds to the bond number (the
appropriate row index of` bonds'); the sign is positive if the bond
arrow points into the component and negative otherwise.
@end itemize

@emph{n_ports} is the number of ports associated with the system -- i.e. the
number of Named SS components (@pxref{Named SS components}).

@menu
* Arrow-orientated causality::  
* Component-orientated causality::  
* Transformation rbg2abg_m::    
@end menu

@node  Arrow-orientated causality, Component-orientated causality, Language m (abg.m), Language m (abg.m)
@comment  node-name,  next,  previous,  up
@subsubsection  Arrow-orientated causality
@cindex Arrow-orientated causality

The  arrow-orientated causality convention assigns -1, 0 or 1 
to both the effort and flow (@pxref{Variables}) sides of a bond 
to represent the causal stroke (@pxref{strokes})
as follows:
@vtable @code
@item 0
        if there is no causality set.
@item 1
       if the causal stroke is at the arrow end of the bond.
@item -1 
     if the causal stroke is at the other end of the bond.
@end vtable
@pxref{Component-orientated causality}.

@node  Component-orientated causality, Transformation rbg2abg_m, Arrow-orientated causality, Language m (abg.m)
@comment  node-name,  next,  previous,  up
@subsubsection  Component-orientated causality
@cindex Component-orientated causality

The  component-orientated causality convention assigns -1, 0 or 1 
to both the effort and flow (@pxref{Variables}) sides of a bond 
to represent the causal stroke (@pxref{strokes})
as follows:
@vtable @code
@item 0
        if there is no causality set.
@item 1 
      if the causal stroke is at the component end of the bond.
@item -1
      if the causal stroke is at the other end of the bond.

@end vtable
@pxref{Arrow-orientated causality}.

@node Transformation rbg2abg_m,  , Component-orientated causality, Language m (abg.m)
@comment  node-name,  next,  previous,  up
@subsubsection Transformation rbg2abg_m
@cindex Transformation rbg2abg_m
This transformation takes the raw bond graph and, by doing some
geometrical computation, determines the topology of the bond graph -- ie
what is close to what.

@node Language tex (abg.tex),  , Language m (abg.m), Acausal bond graph - LaTeX ready (labg)
@comment  node-name,  next,  previous,  up
@subsection Language tex (abg.tex)
@cindex Language tex (abg.tex)

For the purpose of producing a report (@pxref{Report}), @strong{MTT}
generates a LaTeX (@pxref{LaTeX}) file describing the bond graph and its
subsystems. Additional information may be supplied using the description
representation (@pxref{Detailed}).

@c      node   next  prev  up
@node   Stripped acausal bond graph (sabg), Labels (lbl), Acausal bond graph - LaTeX ready (labg), Representations
@section Stripped acausal bond graph (sabg)
@cindex Stripped acausal bond graph (sabg)
@pindex Stripped acausal bond graph (sabg)
The stripped acausal bond graph is the acausal bond graph representation
(@pxref{Acausal bond graph (abg)}) without the artwork
(@pxref{artwork}). It is useful to check for mistakes by showing
precisely what is recognised by @strong{MTT}.

@menu
* Language fig (sabg.fig)::     
* Stripped acausal bond graph (view)::  
@end menu

@node Language fig (sabg.fig), Stripped acausal bond graph (view), Stripped acausal bond graph (sabg), Stripped acausal bond graph (sabg)
@subsection Language fig (sabg.fig) 
@cindex Language fig (sabg.fig) 
@pindex Language fig (sabg.fig) 
The stripped acausal bond graph can be generated as a fig (@pxref{Fig})
file using
@example
mtt syst sabg fig
@end example

@node Stripped acausal bond graph (view),  , Language fig (sabg.fig), Stripped acausal bond graph (sabg)
@subsection Stripped acausal bond graph (view)
@cindex Language m (view)
@cindex view  Constrained-state Equations
This representation has the standard text view
(@pxref{Views}).


@node Labels (lbl), Structure (struc), Stripped acausal bond graph (sabg), Representations
@comment  node-name,  next,  previous,  up
@section Labels (lbl)
@cindex Labels
@cindex lbl
Bond graph components have optional labels. These provide pointers to
further information relating to the component; this avoids clutter on
the bond graph.

The label file contains the following non-blank lines (blank lines are ignored)
@itemize @bullet
@item Summary - lines beginning with #SUMMARY
@item Description - lines beginning with #DESCRIPTION
@item Alias - lines beginning with #ALIAS
@item Comments - lines beginning with # 
@item Labels - other non-blank lines
@end itemize

Note, for compatability with old versions, % may be used in place of
#; but the use of % is deprecated.
Each label contains three fields (in the following order) separated by
white space and on one line:
@enumerate
@item The component name @pxref{Component names}. This must be a valid
name  (@pxref{Valid names}.
@item The component constitutive relationship @pxref{Component constitutive relationship}
@item The component arguments @pxref{Component arguments}
@end enumerate

Not each component @pxref{components} needs a label, only those which are explicitly
labeled on the Bond Graph @pxref{Acausal bond graph (abg)}.
@strong{MTT} checks whether all  components labelled on the bond graph
have labels and vice versa.

If no lbl file exists, @strong{MTT} will create a valid one for you;
including a default set of arguments and crs for both simplae and
compound components.

If wish to create one to edit yourself, type
@example
mtt system_name lbl txt
@end example
An example lbl file (for the RC system is):
@example
%% Label file for system RC (RC_lbl.txt)
%SUMMARY RC
%DESCRIPTION <Detailed description here>
% Port aliases
%ALIAS  in      in
%ALIAS  out     out

% Argument aliases
%ALIAS  $1      c
%ALIAS  $2      r

%% Each line should be of one of the following forms:
%            a comment (ie starting with %)
%            component-name     cr_name arg1,arg2,..argn
%            blank

% ---- Component labels ----

% Component type C
        c               lin     effort,c

% Component type R
        r               lin     flow,r

% Component type SS
        [in]    SS              external,external
        [out]   SS              external,external

@end example


The old-style lbl files (@pxref{Old-style labels (lbl)}) are NO LONGER
supported -- you are encouraged to convert them ASAP.

@menu
* SS component labels::         
* Other component labels::      
* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Parameter declarations::      
* Units declarations::          
* Interface Control Definition::  
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      
* Language tex (desc.tex)::     
@end menu

@node SS component labels, Other component labels, Labels (lbl), Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection SS component labels 
@cindex SS component labels 
In addition to the label there are two information fields, @pxref{Labels
(lbl)}. The first must be `SS', the second contains two information
fields of the form info_field_1,info_field_2.

These two information
fields correspond to the effort and flow variables of the of the SS components as follows
@vtable @code
@item info_field_1
        effort
@item info_field_2
        flow
@end vtable
Each of these two fields contains one of the following @emph{attributes}:
@vtable @code
@item external
        indicates that the corresponding variable is a system input or
output
@item internal
        indicates that the variable does not appear as a system output;
        it is an error to label an input in this way.
@item a number
        the value of the input; or the value of the (imposed) output
@item a symbol
        the symbolic value of the input; or the value of the (imposed) output
@item unknown
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system input (SS output) is to
        be chosen to set the corresponding system output (SS input) to zero.
@item zero
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system output (SS input) is to
        be set to zero using the variable indicted by the corresponding
        `unknown' label.
@end vtable

Some examples are:
@example
%% ss1 is both a source and sensor
ss1     SS              external,external
%% ss1 acts as a flow sensor - it imposes zero effort.
ss2     SS              0,external
@end example


@node Other component labels, Component names, SS component labels, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Other component labels 
@cindex Other component labels 

In addition to the label there are two information fields,
@pxref{Labels (lbl)}.
They correspond to the constitutive relationship 
(see @pxref{Constitutive relationship} and arguments of the
component as follows
@vtable @code
@item info_field_1
        constitutive relationship 
@item info_field_2
        parameters
@end vtable

Some examples are:
@example
%Armature resistance
r_a     lin     effort,r_a

%Gearbox ratio
n       lin     effort,n
@end example

@strong{MTT} supports parameter-passing to  (@pxref{Parameter passing})
subsystems.

@menu
* Component names::             
* Component constitutive relationship::  
* Component arguments::         
* Aliases::                     
* Parameter passing::           
* Old-style labels (lbl)::      
@end menu

@node Component names, Component constitutive relationship, Other component labels, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Component names
@cindex  Component names
The component name field must contain a valid name  (@pxref{Valid names} corresponding to the
name (the bit after the :) of each named component (@pxref{components})
on  the bond graph (@pxref{Acausal bond graph (abg)}).

@node Component constitutive relationship, Component arguments, Component names, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Component constitutive relationship
@cindex  Component constitutive relationship
The constitutive relationship field contains the name of a constitutive
relationship for the component. There are three sorts of constitutive
relationship recognised by @strong{MTT}:
@enumerate
@item A generic constitutive relationship such as @var{lin} (the generic
linear constitutive relationship.
@item A local constitutive relationship with the same name as the
component type
@item The @var{SS} constitutive relationship reserved for @var{SS}
components.
All labels for @var{SS} components must contain SS in this field.
@end enumerate


@node Component arguments, Parameter declarations, Component constitutive relationship, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Component arguments
@cindex  Component arguments

@node Parameter declarations, Units declarations, Component arguments, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Parameter declarations
@cindex parameter declarations
@pindex parameter declarations
@pindex PAR 
@pindex NOTPAR 
@pindex VAR 
@pindex NOTVAR 

It is sometimes useful to use parameters (in addition to those implied by
the Component arguments @pxref{Component arguments}) to compute values
in, for example the numpar file. These can be declared in the label
file;
for examples , the two parameters par1 and par 2 can be declared as:
@example
#PAR par1
#PAR par2
@end example

On the other hand, some CR arguments (eg foo and bar) may not correspond to
parameters. These can be excluded from the sympar list  using
the NOTPAR declaration
@example
#NOTPAR foo
#NOTPAR bar
@end example

For comapability with old code, VAR may be used in place of PAR, but
this usage is deprecated.

@node Units declarations, Interface Control Definition, Parameter declarations, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Units declarations
@cindex units declarations
@pindex units declarations
@pindex UNITS
The units and domains of ports (@pxref{Ports}) are declared as:
@example
#UNITS Port_name domain effort_units flow_units
@end example
where "Port_name" is the name of the port, domain is one of:
@vtable @code
@item electrical
         the electrical domain
@item translational
         the translational mechanical domain
@item rotational
         the rotational mechanical domain
@item fluid
         the fluid domain
@item thermal
         the thermal domain 
@end vtable
and effort_units and flow_units are corresponding units for the effort
and the flow.

Allowed units are those defined in the @strong{units} package.



@strong{MTT} checks that units are 
@itemize  @bullet
@item defined consistently with the domain
@item the same for connected ports when both ports have defined units.
@end itemize
No checks are done if one or both ends of a bond are not connected to a
port with defined units.

The word ``none'' can be specified in place of a unit to prevent
@strong{MTT} from checking the corresponding effort or flow while
still checking the units of the other variable, if it is specified.
This can be used to force checking of either the effort or flow on 
signal bonds or in pseudo-bond graphs where the domain of the two
variables may not be identical.


@node Interface Control Definition, Aliases, Units declarations, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Interface Control Definition
@cindex ICD (label file directive)
It is sometimes useful to be able to automatically generate a set of 
assignments mapping @strong{MTT} inputs and outputs to an external interface
definition. This can be achieved with use of the @emph{#ICD} directive.

@example
#ICD    PressureSensor		PUMP1_PRESSURE_SENSOR,Pa;null,none
#ICD    Electrical		PUMP1_VOLTAGE,volt;PUMP1_CURRENT,amp

% Component type De
	PressureSensor	SS      external

% Component type SS
	Electrical	SS	external,external
@end example


The ICD directive consists of 3 whitespace delimited fields:

@enumerate
@item [%|#]ICD
@item component name
@item Four comma (,) or semi-colon (;) delimited fields:

@enumerate
@item name of effort parameter
@item unit of effort parameter
@item name of flow parameter
@item unit of flow parameter
@end enumerate
@end enumerate

If no parameter name is required, a value of "null" should be used.
If the parameter does not have any units, a value of "none" should be used.

ICD parameters may be aliased @pxref{Aliases} in the same way as normal
parameters, thus it is possible to define some or all of the ICD in higher
level components.

The command

@example
mtt sys ICD txt
@end example

will generate a text file containing a list of mappings:

@example
## Interface Control Definition for System sys
## sys_ICD.txt: Generated by MTT Thu Jul 12 21:21:21 CDT 2001

Input:  PUMP1_VOLTAGE           sys_P1_1_Electrical      Causality: Effort   Units: volt
Output: PUMP1_CURRENT           sys_P1_1_Electrical      Causality: Flow     Units: amp
Output: PUMP1_PRESSURE_SENSOR   sys_P1_1_PressureSensor  Causality: Effort   Units: Pa
@end example

A set of assignments can be generated with the command
@example
mtt sys ICD m
@end example

resulting in:

@example
# Interface Control Definition mappings for system sys
# sys_ICD.m: Generated by MTT Thu Jul 12 21:26:56 CDT 2001

# Inputs

        mttu(1) = PUMP1_VOLTAGE;

# Outputs

        PUMP1_CURRENT                  = mtty(1);
        PUMP1_PRESSURE_SENSOR          = mtty(2);
@end example

A similar file will be generated by the command
@example
mtt sys ICD cc
@end example



@node Aliases, Parameter passing, Interface Control Definition, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Aliases
@cindex aliases
@pindex aliases

Aliases provide a convenient mechanism for relabelling words appearing
in the label file (@pxref{Labels (lbl)}). There are three contexts in
which the alias mechanism is used:

@enumerate
@item renaming ports (@pxref{Port aliases}),
@item renaming parameters (@pxref{Parameter aliases}) and
@item renaming components (@pxref{Component aliases}).
@end enumerate

All three mechanisms use the same form of statement within the label
file
@example
%ALIAS short_label       real_label
@end example

@strong{MTT} distinguishes between the three forms as follows:

@itemize @bullet
@item Parameter aliases: `short_label' starts with a `$'
@item Component aliases: `real_label' contains the directory separator
`/'
@item Port aliases: neither of the above
@end itemize

@menu
* Port aliases::                
* Parameter aliases::           
* CR aliases::                  
* Component aliases::           
@end menu


@node Port aliases, Parameter aliases, Aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection Port aliases
@cindex port aliases
@pindex port aliases
Aliases provide a way of refering to (@pxref{Port labels}) or vector port labels (@pxref{Vector
port labels}) on the bond graph using a short-hand notation. With in a
component label file (@pxref{Labels (lbl)}) statements of the following
forms can occur 

@example
%ALIAS short_label       real_label
@end example

When the component is used within another component, the short_lable may
be used in place of the real_label.
More than one alias per label can be used, for example

@example
%ALIAS short_label_1       real_label
%ALIAS short_label_2       real_label
%ALIAS short_label_3       real_label
@end example

The port can then be refered to in four ways: as real_label,
short_label_1, short_label_2 or short_label_3.
An alternative notation for the ALIAS statement in this case is

@example
%ALIAS short_label_1|short_label_2|short_label_3       real_label
@end example

The alias feature is particularly powerful in conjunction with vector
port labels (@pxref{Vector port labels}) and the port label default 
(@pxref{Port label defaults}) mechanisms. For example, a component with
5 ports appearing in the lbl file as:

@example
        [Hydraulic_in]  external        external
        [Hydraulic_out] external        external
        [Power_Shaft]           external        external
        [Thermal_in]    external        external
        [Thermal_out]   external        external
@end example

together with the following statements in the label file:

@example
%ALIAS  in              Thermal_in,Hyydraulic_in
%ALIAS  out             Thermal_out,Hydraulic_out
%ALIAS  shaft|power     Power_Shaft
@end example

can appear in the bond graph containing that component with one bond
labeled either [shaft] or [power] or [Power_Shaft], one unlabeled vector
bond pointing in and one unlabeled vector bond pointing out.

@node Parameter aliases, CR aliases, Port aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection Parameter aliases
@cindex parameter aliases
@pindex parameter aliases

Parameter aliases are of the form
@example
%ALIAS $n       actual parameter
@end example
where n is an integer (unique within the label file).
For example

@example
%ALIAS  $1              c_v
%ALIAS  $2              density,ideal_gas,r
%ALIAS  $3              alpha
%ALIAS  $4              flow,k_p
@end example

Assigns four symbolic parameters to the corresponding strings These four
parameters (@code{$1}--@code{$4}) can then be used for parameter
passing(@pxref{Parameter passing}).

@node CR aliases, Component aliases, Parameter aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection CR aliases
@cindex CR aliases
@pindex CR aliases

CR aliases are of the form
@example
%ALIAS $an       actual parameter
@end example
where n is an integer (unique within the label file).
For example
@example
%ALIAS  $a1  lin           
@end example
assigns the symbolic parameter to be lin. This parameter @code{$1} can
then be used for passing a diofferent cr to the
component (@pxref{Parameter passing}).

@node Component aliases,  , CR aliases, Aliases
@comment  node-name,  next,  previous,  up
@subsubsection Component aliases
@cindex component aliases
@pindex component aliases

Component aliases are of the form
@example
%ALIAS Component_name   Component_location       
@end example

An example appears in the following label file fragment
@example
...
%ALIAS  wPipe   CompressibleFlow/wPipe
%ALIAS  Poly    CompressibleFlow/Poly
....

@end example
The two components `wPipe' and `Poly' are both to be found within the
library `Compressible flow' and the respective subdirectories. This
follows the @strong{MTT} convention that compound components
(@pxref{Compound components}) live within a directory of the same name.
 

@node Parameter passing, Old-style labels (lbl), Aliases, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Parameter passing
@cindex Parameter passing
@strong{MTT} supports parameter-passing to subsystems within label files
(@pxref{Labels (lbl)}). Within a subsystem, explicit constitutive
relationships and parameters (or groups thereof) can be replaced by
postitional parameters such as @code{$1}, @code{$2} etc.  Although this
can be done directly, it is recommended that this is done via the alias
mechanism (@pxref{Parameter aliases}).

In a subsystem
@code{$i}, is replaced by the ith field of a colon @code{;} separated
field in the calling label file. This field may include commas @code{,}
and the four arithmetic operators @code{+}, @code{-}, @code{*} and
@code{/}.

For example, consider the following example label file fragment (associated with a
component called Pump:
@example
...

%ALIAS  $1              c_v
%ALIAS  $2              density,ideal_gas,r
%ALIAS  $3              alpha
%ALIAS  $4              flow,k_p

%ALIAS  wPipe   CompressibleFlow/wPipe
%ALIAS  Poly    CompressibleFlow/Poly

% Component type wPipe
        pipe    none                    c_v;density,ideal_gas,r

% Component type Poly
        poly            Poly            alpha

@end example

The 4 parameters @code{$1}, @code{$2}, @code{$3}, and @code{$4} can be
passed from a higher level component as in the following label file
fragment:

@example
% Component type Pump
        comp            none            c_v;rho,ideal_gas,r;alpha;effort,k_c
        turb            none            c_v;rho,ideal_gas,r;alpha;effort,k_t
@end example

Thus in component `comp':
@itemize @bullet
@item @code{$1} is replaced by c_v
@item @code{$2} is replaced by rho,ideal_gas
@item @code{$3} is replaced by alpha
@item @code{$4} is replaced by effort,k_c
@end itemize
whereas in component `turb' the first three parameters are the same but
@itemize @bullet
@item @code{$4} is replaced by effort,k_t
@end itemize



@node Old-style labels (lbl), Language tex (desc.tex), Parameter passing, Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Old-style labels (lbl)
@cindex Old-style labels
@cindex lbl

Old syle labels (mtt version 2.x) are supported by mtt version
3.x. However, you are advised to use the new form (@pxref{Labels
(lbl)}).

Each line of the @code{_label.txt} file is of one of three forms:
@enumerate
@item
Contains three fields (separated by white space) of the form
@example
label   field_1   field_2
@end example
@item
Blank
@item
Preceded by %
@end enumerate
Only the first is noticed by @strong{MTT}; the second and third are for
providing helpful commenting.

The role of the two information fields depends on the component with the
corresponding label. In particular the classes of components are:
@itemize @bullet
@item
SS components, @pxref{SS components}.
@item
Other components,  @pxref{components}.
@end itemize
Named SS component, @pxref{Named SS components} never have labels.
@menu
* SS component labels (old-style)::  
* Other component labels (old-style)::  
* Parameter passing (old-style)::  
@end menu


@node SS component labels (old-style), Other component labels (old-style), Old-style labels (lbl), Old-style labels (lbl)
@comment  node-name,  next,  previous,  up
@subsubsection SS component labels (old-style)
@cindex SS component labels (old-style)
In addition to the label there are two information fields,
@pxref{Labels (lbl)}.
They correspond to the effort and flow of the components as follows
@vtable @code
@item info_field_1
        effort
@item info_field_2
        flow
@end vtable
Each of these two fields contains one of the following @emph{attributes}:
@vtable @code
@item external
        indicates that the corresponding variable is a system input or
output
@item internal
        indicates that the variable does not appear as a system output;
        it is an error to label an input in this way.
@item a number
        the value of the input; or the value of the (imposed) output
@item a symbol
        the symbolic value of the input; or the value of the (imposed) output
@item unknown
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system input (SS output) is to
        be chosen to set the corresponding system output (SS input) to zero.
@item zero
        used for the SS method of solving algebraic loops. This
        indicates that the corresponding system output (SS input) is to
        be set to zero using the variable indicted by the corresponding
        `unknown' label.
@end vtable

Some examples are:
@example
%Label  field1          field2
ss1     external        external
ss2     0               external
@end example


@node Other component labels (old-style), Parameter passing (old-style), SS component labels (old-style), Old-style labels (lbl)
@comment  node-name,  next,  previous,  up
@subsubsection Other component labels (old-style)
@cindex Other component labels (old-style)

In addition to the label there are two information fields,
@pxref{Labels (lbl)}.
They correspond to the constitutive relationship 
(see @pxref{Constitutive relationship} and arguments of the
component as follows
@vtable @code
@item info_field_1
        constitutive relationship 
@item info_field_2
        parameters
@end vtable

Some examples are:
@example
%Armature resistance
r_a     lin     effort,r_a

%Gearbox ratio
n       lin     effort,n
@end example

@strong{MTT} supports parameter-passing to  (@pxref{Parameter passing (old-style)})
subsystems.


@node Parameter passing (old-style),  , Other component labels (old-style), Old-style labels (lbl)
@comment  node-name,  next,  previous,  up
@subsubsection Parameter passing (old-style)
@cindex Parameter passing (old-style)
@strong{MTT} supports parameter-passing to  (@pxref{Parameter passing (old-style)})
subsystems within label files (@pxref{Labels (lbl)}). Within a subsystem,
explicit constitutive relationships and parameters (or groups thereof)
can be replaced by 
@code{$1}, @code{$2}, etc.

In a subsystem
@code{$i}, is replaced by the ith field of a colon @code{;} separated
field in the calling label file. This field may include commas @code{,}.

For example subsystem ROD contains the following lines in the label
file:
@example

%DESCRIPTION    Parameter 1:    length from end 1 to mass centre
%DESCRIPTION    Parameter 2:    length from end 2 to mass centre
%DESCRIPTION    Parameter 3:    inertia about mass centre
%DESCRIPTION    Parameter 4:    mass
%DESCRIPTION    See Section 10.2 of "Metamodelling"


%Inertias
J       lin     flow,$3
m_x     lin     flow,$4
m_y     lin     flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1      lsin    flow,$1
s2      lsin    flow,$2
c1      lcos    flow,$1
c2      lcos    flow,$2

@end example

This can be used in a higher-level lbl (@pxref{Labels (lbl)}) file as:
@example
%SUMMARY Pendulum example from Section 10.3 of "Metamodelling"

%Rod parameters
rod     none    l;l;j;m

@end example


@menu
* Language tex (desc.tex)::     
@end menu

@node Language tex (desc.tex),  , Old-style labels (lbl), Labels (lbl)
@comment  node-name,  next,  previous,  up
@subsection Language tex (desc.tex)
@cindex Language tex (desc.tex)
This file may contain any LaTeX compatible commands. Any mathematics
should conform to the AMSmath package.

@node Structure (struc), Constitutive Relationship (cr), Labels (lbl), Representations
@comment  node-name,  next,  previous,  up
@section Structure (struc)
@cindex Structure
@cindex struc

The causal bond graph implies a set of equations describing the
system. The Structure (struc) representation describes the structure of
these equations in terms of the input, outputs, states and non-states of
the system.

@menu
* Language txt (struc.txt)::    
* Language tex (struc.tex)::    
* Structure (view)::            
@end menu

@node Language txt (struc.txt), Language tex (struc.tex), Structure (struc), Structure (struc)
@comment  node-name,  next,  previous,  up
@subsection Language txt (struc.txt)
@cindex Language txt (struc.txt)
This text tile contains a description of the system structure
(@pxref{Structure (struc)} with 5 tab-separated columns containing the
following information:
@vtable @code
@item type
        input, output state or nonstate
@item index
        an integer corresponding to the array index
@item component name
        the name of the component corresponding to the variable
@item system name
        the name of the system containing the component
@item repetition
        an integer corresponding to the repetition of a repeated subsystem.
@end vtable

An example of such a file (corresponding to rc) (@pxref{Quick start}) is:
@example
input           1       e1      rc      1
output          1       e2      rc      1
state           1       c       rc      1
@end example


@node Language tex (struc.tex), Structure (view), Language txt (struc.txt), Structure (struc)
@comment  node-name,  next,  previous,  up
@subsection Language tex (struc.tex)
@cindex Language tex (struc.tex)
This LaTeX  (@pxref{LaTeX}) file contains  a description of the system structure
(@pxref{Structure (struc)} in @code{longtable} format. It is a useful
item to include in a report(@pxref{Report}).

@node Structure (view),  , Language tex (struc.tex), Structure (struc)
@subsection Language tex (view)
@cindex Structure (view)
@cindex view Structure
This representation has the standard text view
(@pxref{Views}).

@node Constitutive Relationship (cr), Parameters, Structure (struc), Representations
@comment  node-name,  next,  previous,  up
@section Constitutive relationship (cr)
@cindex Constitutive relationship

The constitutive relationship (@pxref{Constitutive relationship})
of a simple component (@pxref{Simple components} is
defined in the symbolic algebra language Reduce (@pxref{Reduce}).
The constitutive relationship of a compound components 
(@pxref{Compound components})
is implied by the constitutive relationships of its constituent components.

@menu
* Predefined constitutive relationships::  
* DIY constitutive relationships::  
* Unresolved constitutive relationships::  
* Unresolved constitutive relationships - Octave::  
* Unresolved constitutive relationships - c++::  
@end menu

@node Predefined constitutive relationships, DIY constitutive relationships, Constitutive Relationship (cr), Constitutive Relationship (cr)
@comment  node-name,  next,  previous,  up
@subsection  Predefined constitutive relationships
@cindex Predefined constitutive relationships

Some common cr's are predefined by MTT; these are:
@vtable @code
@item lin
        a linear constitutive relationship   
@item exotherm
        an exothermic reaction
@end vtable

@menu
* lin::                         
* exotherm::                    
@end menu

@node lin, exotherm, Predefined constitutive relationships, Predefined constitutive relationships
@comment  node-name,  next,  previous,  up
@subsubsection lin
@findex lin
The constitutive relationship @code{lin} is predefined for the following
components.
@vtable @code
@item R
        (one-port) R component
@item TF
        transformer
@item GY
        gyrator
@item MTF
        modulated transformer
@item MGY
        modulated gyrator
@item FMR
        flow-modulated resistor
@end vtable
Lin takes two arguments in the form causality,gain
@vtable @code
@item causality
        the causality (effort or flow) of the @emph{input} to the
constitutive relationship
@item gain
        the gain of the component when the input causality is as
specified in the first argument.
@end vtable
For example the arguments
@example
flow,r
@end example
given to an R component corresponds to
@example
e = rf
@end example
if if the input causality is flow
or
@example
f = e/r
@end example
if if the input causality is effort.

@node exotherm,  , lin, Predefined constitutive relationships
@comment  node-name,  next,  previous,  up
@subsubsection exotherm
@findex exotherm

@node DIY constitutive relationships, Unresolved constitutive relationships, Predefined constitutive relationships, Constitutive Relationship (cr)
@comment  node-name,  next,  previous,  up
@subsection  DIY constitutive relationships
@cindex DIY constitutive relationships
You can write your own constitutive relationships using Reduce
(@pxref{Reduce}). This requires some understanding as to how
@strong{MTT} represent the elementary system equations
(@pxref{Elementary system equations}). Looking at the predefined
constitutive relationships is a good way to get started
(@pxref{File structure}).

@node Unresolved constitutive relationships, Unresolved constitutive relationships - Octave, DIY constitutive relationships, Constitutive Relationship (cr)
@subsection Unresolved constitutive relationships
@cindex Unresolved constitutive relationships

Consider the following CR file.
@example
FOR ALL rho,g,vol,h,topt,bott,flowin,press
LET tktf2(rho,g,vol,h,topt,bott,effort,2,press,effort,1)
        = tank(rho,g,vol,h,topt,bott,press);      
@end example
Assuming that `tank' is not defined in a
reduce file, MTT will leave it unresolved when generating m or c code.

The resulting function can then be expressed as octave
(@pxref{Unresolved constitutive relationships - Octave}) or c++ code as
(@pxref{Unresolved constitutive relationships - c++}) appropriate.

@node Unresolved constitutive relationships - Octave, Unresolved constitutive relationships - c++, Unresolved constitutive relationships, Constitutive Relationship (cr)
@subsection  Unresolved constitutive relationships - Octave
@cindex Unresolved constitutive relationships - Octave
Following the example of the previous section, the unresolved CR `tank'
can be expressed as an Octave m-file. For example:
@example
function p = tank (rho,g,vol,h,topt,bott,press)

  ## usage:  p = tank (vol,h,topt,bott,press)
  ##
  ## 

   val = press; zt = topt; zb = bott; 
   zval = 0.5*(abs(zb+(zt-zb)*val-h)+(zb+(zt-zb)*val-h));

   p = rho*g*zval + 0.5*(1+tanh((press-0.98)*500))*100000;

endfunction
@end example
This will be automatically loaded into octave.

@node Unresolved constitutive relationships - c++,  , Unresolved constitutive relationships - Octave, Constitutive Relationship (cr)
@subsection  Unresolved constitutive relationships - c++
@cindex Unresolved constitutive relationships - Octave
Following the example of the previous section, the unresolved CR `tank'
can be expressed in c++ code. For example:
@example
inline double tank(const double rho, 
		   const double g, 
		   const double vol, 
		   const double h, 
		   const double topt, 
		   const double bott, 
		   const double press)


  /*  ## usage:  p = tank (vol,h,topt,bott,press)
    ##
    ##
  */
  double p, val, zval, zt, zb;

  val = press;
  zt = topt;
  zb = bott;
  zval = 0.5 * (abs(zb + (zt - zb) * val - h) + zb + (zt - zb) * val - h);

  p = rho * g * zval + 0.5 * (1 + tanh((press - 0.98) * 500)) * 100000L;

  return p;

@end example

To make sure that this is used in system `model', the model_cr.h file
must be as follows:
@example
// CR headers for system model
#include "tank.c"
@end example

@node Parameters, Causal bond graph (cbg), Constitutive Relationship (cr), Representations
@comment  node-name,  next,  previous,  up
@section Parameters
@cindex Parameters

In general, lbl (@pxref{Labels (lbl)}) files contain symbolic
parameters. @strong{MTT} provides three ways of substituting for these
parameters:
@itemize @bullet
@item
symbolic substitution
@item
symbolic substitution for simplification of displayed equations
@item
numeric
@end itemize

@menu
* Symbolic parameters (subs.r)::  
* Symbolic parameters for simplification (simp.r)::  
* Numeric parameters (numpar)::  
@end menu

@node Symbolic parameters (subs.r), Symbolic parameters for simplification (simp.r), Parameters, Parameters
@comment  node-name,  next,  previous,  up
@subsection Symbolic parameters (subs.r)
@cindex  Symbolic parameters
@vindex subs.r
This file contains reduce statements to symbolically change the
expressions describing the system.
For example, a useful set of trig substitutions is:
@example
LET cos(~x)*cos(~y) = (cos(x+y)+cos(x-y))/2;
LET cos(~x)*sin(~y) = (sin(x+y)-sin(x-y))/2;
LET sin(~x)*sin(~y) = (cos(x-y)-cos(x+y))/2;
LET cos(~x)^2       = (1+cos(2*x))/2;
LET sin(~x)^2       = (1-cos(2*x));
@end example

@node Symbolic parameters for simplification (simp.r), Numeric parameters (numpar), Symbolic parameters (subs.r), Parameters
@comment  node-name,  next,  previous,  up
@subsection Symbolic parameters for simplification  (simp.r)
@cindex  Symbolic parameters for simplification 
@vindex simp.r
This file contains reduce statements to symbolically change the
expressions describing the system. Unlike the subs.r file
(@pxref{Symbolic parameters (subs.r)}) it does not affect all system
transformations; only those converting to LaTeX form.

@node Numeric parameters (numpar),  , Symbolic parameters for simplification (simp.r), Parameters
@comment  node-name,  next,  previous,  up
@subsection Numeric parameters (numpar)
@cindex  Numeric parameters

When computing time and frequency responses; or when evaluating
functions in Octave (@pxref{Octave}); symbolic parameters need numerical
instantiations. 

The numpar representation provides the relevant @emph{numerical}
information. It comes in a number of languages:
@ftable @code
@item txt
        a textual description of the parameter values -- this is the
defining representation (@pxref{Defining representations}).
@item m
        readable by @code{octave} a high-level interactive language for numerical
        computation -- translated by @strong{mtt} from the txt version.
@item c
        readable by @code{gcc} a c compiler -- translated by @strong{mtt} from the txt version.

@end ftable

@menu
* Text form (numpar.txt)::      
@end menu

@node Text form (numpar.txt),  , Numeric parameters (numpar), Numeric parameters (numpar)
@comment  node-name,  next,  previous,  up
@subsubsection Text form (numpar.txt)
@cindex  Numeric parameters
This is the textual form of the numerical parameters representation
(@pxref{Numeric parameters (numpar)}). Lines are either
@ftable @code
@item assignment statements
        variable = value
@item comments
        lines beginning with #
@item commented assignment statements
        variable = value # comments
@end ftable
An example file is:
@example
# Numerical parameter file (rc_numpar.txt)
# Generated by MTT at Mon Jun 16 15:10:17 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.32  2014/07/12 19:56:27  geraint
# %% Fixed style of NO WARRANTY from heading to strong because texi2html complained about having a heading in an enumerate environment
# %%
# %% Revision 1.31  2014/07/10 23:13:27  geraint
# %% Fixed mtt.texi missing arguments and subsection level
# %%
# %% Revision 1.30  2005/03/15 12:04:15  gawthrop
# %% New labg.fig rep - pretty LaTeX figures.
# %%
# %% Revision 1.29  2005/01/19 09:45:15  geraint
# %% Fixed whitespace.
# %%
# %% Revision 1.28  2005/01/06 16:03:55  geraint
# %% Updated options list.
# %%
# %% Revision 1.27  2005/01/06 14:42:33  geraint
# %% Fixed explicit/implicit descriptions of forward/backward Euler.
# %% Replaced -c examples with -cc.
# %%
# %% Revision 1.26  2005/01/06 12:28:36  geraint
# %% Minor typos.
# %%
# %% Revision 1.25  2004/08/27 20:12:34  geraint
# %% Added note about "none" as an option for units.
# %%
# %% Revision 1.24  2004/08/13 01:39:24  geraint
# %% Fixed variable names in diy makefile example (again)
# %%
# %% Revision 1.23  2004/08/11 08:24:28  geraint
# %% Replaced "gnuplot view" with "odeso gnuplot" in examples.
# %%
# %% Revision 1.21  2004/07/23 11:05:26  geraint
# %% Updated Reduce URL: http://www.reduce-algebra.com
# %%
# %% Revision 1.20  2003/10/23 18:14:43  geraint
# %% Added subsection with script for model-specific options.
# %% Fixed typo in url to mtt.sf.net.
# %%
# %% Revision 1.19  2003/10/10 22:22:18  geraint
# %% typo.
# %%
# %% Revision 1.18  2003/09/07 20:41:19  geraint
# %% *** empty log message ***
# %%
# %% Revision 1.17  2003/08/19 14:20:38  gawthrop
# %% Version 5.0 of MTT
# %% Remove xref errors (spurious spaces)
# %%
# %% Revision 1.16  2003/08/19 14:11:23  gawthrop
# %% Links to legal stuff
# %%
# %% Revision 1.15  2003/08/19 14:01:45  gawthrop
# %% Added legal appendices
# %%
# %% Revision 1.14  2003/08/06 14:50:56  gawthrop
# %% Describe the alias mechanism for invoking mtt options
# %%
# %% Revision 1.13  2002/12/13 10:07:07  gawthrop
# %% Added example in sh section of DIY reps
# %%
# %% Revision 1.12  2002/09/19 08:09:31  gawthrop
# %% Updated documentation documentation
# %%
# %% Revision 1.11  2002/08/20 15:51:17  gawthrop
# %% Update to work with ident DIY rep
# %%
# %% Revision 1.10  2002/07/22 10:45:22  geraint
# %% Fixed gnuplot rep so that it correctly re-runs the simulation if input files have changed.
# %%
# %% Revision 1.9  2002/07/05 13:29:34  geraint
# %% Added notes about generating dynamically linked functions for Octave and Matlab.
# %%
# %% Revision 1.8  2002/07/04 21:34:12  geraint
# %% Updated gnuplot view description to describe Tcl/Tk interface instead of obsolete txt method.
# %%
# %% Revision 1.7  2002/04/23 09:51:54  gawthrop
# %% Changed incorrect statement about searching for components.
# %%
# %% Revision 1.6  2001/10/15 14:29:50  gawthrop
# %% Added documentaton on  [1:N] style port labels
# %%
# %% Revision 1.5  2001/07/23 03:35:29  geraint
# %% Updated file structure (mtt/bin).
# %%
# %% Revision 1.4  2001/07/23 03:25:02  geraint
# %% Added notes on -ae hybrd, rk4, ode2odes.cc, .oct dependencies.
# %%
# %% Revision 1.3  2001/07/13 03:02:38  geraint
# %% Added notes on #ICD, gnuplot.txt and odes.sg rep.
# %%
# %% Revision 1.2  2001/07/03 22:59:10  gawthrop
# %% Fixed problems with argument passing for CRs
# %%
# %% Revision 1.1  2001/06/04 08:18:52  gawthrop
# %% Putting documentation under CVS
# %%
# %% Revision 1.66  2000/12/05 14:20:55  peterg
# %% Added the c++  anf m CR info.
# %%
# %% Revision 1.65  2000/11/27 15:36:15  peterg
# %% NOPAR --> NOTPAR
# %%
# %% Revision 1.64  2000/11/16 14:22:48  peterg
# %% added UNITS declaration
# %%
# %% Revision 1.63  2000/11/03 14:41:08  peterg
# %% Added PAR and NOTPAR stuff
# %%
# %% Revision 1.62  2000/10/17 17:53:34  peterg
# %% Added some simulation details
# %%
# %% Revision 1.61  2000/09/14 17:13:06  peterg
# %% New options table
# %%
# %% Revision 1.60  2000/09/14 17:09:20  peterg
# %% Tidied up valid name sections
# %% Tidied up defining represnetations table
# %% Verion 4.6
# %%
# %% Revision 1.59  2000/08/30 13:09:00  peterg
# %% Updated option table
# %%
# %% Revision 1.58  2000/08/01 13:30:19  peterg
# %% Version 4.4
# %% updated STEPFACTOR info
# %% describes octave and OCST interfaces
# %%
# %% Revision 1.57  2000/07/20 07:55:44  peterg
# %% Version 4.3
# %%
# %% Revision 1.56  2000/05/19 17:49:17  peterg
# %% Extended the user defined representation section -- new nppp rep.
# %%
# %% Revision 1.55  2000/03/16 13:53:31  peterg
# %% Correct date
# %%
# %% Revision 1.54  2000/03/15 21:22:57  peterg
# %% Updated to 4.1 -- old style SS no longer supported
# %%
# %% Revision 1.53  1999/12/22 05:33:10  peterg
# %% Updated for 4.0
# %%
# %% Revision 1.52  1999/11/23 00:25:11  peterg
# %% Added the sensitivity reps
# %%
# %% Revision 1.51  1999/11/16 04:43:47  peterg
# %% Added start of sensitivity section
# %%
# %% Revision 1.50  1999/11/16 00:30:35  peterg
# %% Updated simulation section
# %% Added vector components
# %%
# %% Revision 1.49  1999/07/20 23:44:58  peterg
# %% V 3.8
# %%
# %% Revision 1.48  1999/07/19 03:08:33  peterg
# %% Added documentation for (new) SS lbl fields
# %%
# %% Revision 1.47  1999/03/09 01:42:22  peterg
# %% Rearranged the User interface section
# %%
# %% Revision 1.46  1999/03/09 01:18:01  peterg
# %% Updated for 3.5 including xmtt
# %%
# %% Revision 1.45  1999/03/03 02:39:26  peterg
# %% Minor updates
# %%
# %% Revision 1.44  1999/02/17 06:52:14  peterg
# %% New level formula dor artwork
# %%
# %% Revision 1.43  1998/11/25 16:49:24  peterg
# %% Put in subs.r documentation (was called params.r)
# %%
# %% Revision 1.42  1998/11/24 12:24:59  peterg
# %% Added section on simulation output
# %% Version 3.4
# %%
# %% Revision 1.41  1998/09/02 12:04:15  peterg
# %% Version 3.2
# %%
# %% Revision 1.40  1998/08/27 08:36:39  peterg
# %% Removed in. methods except Euler anf implicit
# %%
# %% Revision 1.39  1998/08/18 10:44:28  peterg
# %% Typo
# %%
# %% Revision 1.38  1998/08/18 09:16:38  peterg
# %% Version 3.1
# %%
# %% Revision 1.37  1998/08/17 16:14:30  peterg
# %% Version 3.1 - includes documentation on METHOD=IMPLICIT
# %%
# %% Revision 1.36  1998/07/30 17:33:15  peterg
# %% VERSION 3.0
# %%
# %% Revision 1.35  1998/07/22 11:00:53  peterg
# %% Correct date!
# %%
# %% Revision 1.34  1998/07/22 11:00:13  peterg
# %% Version to BAe
# %%
# %% Revision 1.33  1998/07/17 19:32:19  peterg
# %% Added more about aliases
# %%
# %% Revision 1.32  1998/07/05 14:21:56  peterg
# %% Further additions (Carlisle-Glasgow)
# %%
# %% Revision 1.31  1998/07/04 11:35:57  peterg
# %% Strarted new lbl description
# %%
# %% Revision 1.30  1998/07/02 18:39:20  peterg
# %% Started 3.0
# %% Added alias and default sections.
# %%
# %% Revision 1.29  1998/05/19 19:46:58  peterg
# %% Added the odess description
# %%
# %% Revision 1.28  1998/05/14 09:17:22  peterg
# %% Added METHOD variable to the simpar file
# %%
# %% Revision 1.27  1998/05/13 10:03:09  peterg
# %% Added unknown/zero SS label documentation.
# %%
# %% Revision 1.26  1998/04/29 15:12:46  peterg
# %% Version 2.9.
# %%
# %% Revision 1.25  1998/04/12 17:00:26  peterg
# %% Added new port features: coerced direction and top-level behaviour.
# %%
# %% Revision 1.24  1998/04/05 18:27:20  peterg
# %% This was the 2.6 version
# %%
# Revision 1.23  1997/08/24  11:17:51  peterg
# This is the released  version 2.5
#
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c =     1.0; # Default value
r =     1.0; # Default value
# Initial states
x(1) =  0.0; # Initial state for rc (c)
@end example
As usual, @strong{MTT} provides a default text file to be edited by the
user (@pxref{Text editors}).

@node Causal bond graph (cbg), Elementary system equations, Parameters, Representations
@comment  node-name,  next,  previous,  up
@section Causal bond graph (cbg)
@cindex Causal bond graph (cbg)
The causal bond graph is the causally complete version of the
Acausal bond graph (@pxref{Acausal bond graph (abg)}).

To create the causal bond graph of system `sys' in language fig type:
@example
mtt sys cbg fig
@end example
To create the causal bond graph of system `sys' in language m type:
@example
mtt sys cbg m
@end example
To view the causal bond graph of system `sys' type:
@example
mtt sys cbg view
@end example

@menu
* Language fig (cbg.fig)::      
* Language m (cbg.m)::          
@end menu

@node Language fig (cbg.fig), Language m (cbg.m), Causal bond graph (cbg), Causal bond graph (cbg)
@subsection Language fig (cbg.fig) 
@cindex Language fig (cbg.fig) 
@pindex Language fig (cbg.fig) 
The fig file is created by @strong{MTT}. It is identical to the
corresponding acausal representation (@pxref{Language fig (abg.fig)})
except that
@itemize @bullet
@item
the new causal strokes are added (using a double thickness line in blue)
@item
components that are undercausal are bold and green
@item
components that are overcausal are bold and red
@end itemize

@node Language m (cbg.m),  , Language fig (cbg.fig), Causal bond graph (cbg)
@comment  node-name,  next,  previous,  up
@subsection Language m (cbg.m)
@cindex Language m (cbg.m) 
@cindex cbonds
@cindex status


The causal bond graph of system `sys' is represented as
 an m file with heading:
@example
function [cbonds,status] = sys_cbg
@end example
The two outputs of this function are:
@itemize @bullet
@item
cbonds
@item
status
@end itemize

@emph{cbonds} is  a matrix with
@itemize @bullet
@item
one row for each bond
@item
the first column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{effort} variable.
@item
the second column contains the arrow-orientated 
(@pxref{Arrow-orientated causality}) 
causality of the @emph{flow} variable.
@end itemize

@emph{status} is  a matrix with
@itemize @bullet
@item
one row for each component
@item
the first column contains 1 if the component is overcausal; 0 if the
component is causally complete and -1 if the component is undercausal.
@end itemize
A successful model would therefore have all zeros in the status matrix.

@menu
* Transformation abg2cbg_m::    
@end menu

@node Transformation abg2cbg_m,  , Language m (cbg.m), Language m (cbg.m)
@comment  node-name,  next,  previous,  up
@subsubsection Transformation abg2cbg_m
@cindex Transformation abg2cbg_m

This transformation takes the acausal bond graph as an m file 
(@pxref{Language m (abg.m)}) and transforms it into a causal bond graph in
m-file format (@pxref{Language m (cbg.m)}).

It is based on the m-function abg2cbg.m which iteratively tries to
complete causality whilst recursively searching the bond graph
structure.
If causality is incomplete, it picks the first acausal dynamic (C or I)
component, asserts integral causality, and tries again.

This is essentially the sequential causality assignment procedure of
Karnopp and Rosenberg.

The transformation informs the user of the final status in terms of the
percentage of causally complete components; a successful model will
yield 100% here.

@node Elementary system equations, Differential-Algebraic Equations, Causal bond graph (cbg), Representations
@comment  node-name,  next,  previous,  up
@section Elementary system equations (ese)
@cindex Elementary system equations

The elementary system equations are a complete set of assignment statements
describing the dynamic system corresponding to the bond graph.
They are in the Reduce (@pxref{Reduce}) language.

Because these are based on a causally complete system, these assignment
statements are directly soluble by substitution.

Unlike early versions of @strong{MTT}, @strong{MTT} does @emph{not} sort
the equations in order of solution, but rather leaves them sorted by
component and subsystem.

These are not supposed to be read by the user, so there is no view
facility as such. However, you may read these with your favourite text
editor and, to this end,  helpful comment lines have been added.

Wherever components have an explicit constitutive relationship, the
corresponding RHS of the equation has a standard form.

@example
cr(arguments,out_causality,outport,
        input_1, causality_1, port_1,
        ....
        input_i, causality_i, port_i,
        ....
        input_n, causality_n, port_n
        );
@end example
where the symbols have the following meaning
@vtable @code
@item arguments
        the constitutive relationship arguments
@item out_causality
        the causality (effort or flow) of the output variable
        (@pxref{Variables})
@item outport
        the number (integer) of the output port of the system
@item input_i
        the ith input to the component
@item causality_i
        the causality (effort or flow) of the ith input variable
        (@pxref{Variables})
@item port_i
        the number (integer) of the ith input port of the system
@end vtable

An example for a resistor with linear constitutive relationship is:
@example
rc_1_bond4_flow := lin(flow,r,flow,1,
        rc_1_bond4_effort,effort,1
        );
@end example

@menu
* Transformation cbg2ese_m2r::  
@end menu

@node Transformation cbg2ese_m2r,  , Elementary system equations, Elementary system equations
@comment  node-name,  next,  previous,  up
@subsection Transformation cbg2ese_m2r
@cindex Transformation cbg2ese_m2r
@cindex Structure
@cindex def.r
This transformation takes the causal bond graph as an m file 
(@pxref{Language m (cbg.m)}) and transforms it into elementary system
equations
in Reduce (@pxref{Reduce})
form.

It is based on the m-function cbg2ese.m which iteratively traverses the
causal bond graph writing equations as it goes.

It also writes out the system structure as the file @file{sys_def.r}.


@node Differential-Algebraic Equations, Constrained-state Equations, Elementary system equations, Representations
@section Differential-Algebraic Equations (dae)
@cindex Differential-Algebraic Equations
@cindex DAE

The system differential algebraic equations describe the system dynamics together 
together with any algebraic constraints. 

They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys dae lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable


There are five sets of variables describing the system:
@vtable @code
@item x
        the system states (corresponding to C and I components with integral
        causality.
@item z
        the system nonstates (corresponding to C and I components with derivative
        causality.
@item u
        the system inputs  (corresponding to SS components
        with external attribute).
@item ui
        the @emph{internal} system inputs (corresponding to SS components
        with internal attribute) used to solve algebraic loops
        (@pxref{Algebraic loops}).
@item y
        the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

In general there are four sets of equations. The right-hand side of
 each is a function of x, dz/dt,  u and ui and the left hand sides are:
@enumerate
@item
the derivative of x (dx/dt)
@item
z
@item
w=0 (the algebraic equations)
@item
y
@end enumerate

@menu
* Differential-Algebraic Equations (reduce)::  
* Differential-Algebraic Equations (m)::  
@end menu

@node Differential-Algebraic Equations (reduce), Differential-Algebraic Equations (m), Differential-Algebraic Equations, Differential-Algebraic Equations
@subsection Language reduce (dae.r)
@cindex Differential-Algebraic Equations (reduce)
@cindex dae.r 

The system DAEs (@pxref{Differential-Algebraic Equations})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the algebraic expressions for the 
right hand sides of each set of equations. The arrays are:
@vtable @code
@item MTTx
        x -- the system states (corresponding to C and I components with integral
        causality.

@item MTTz
        z -- the system nonstates (corresponding to C and I components with derivative
        causality.
@item MTTu
        u -- the system inputs  (corresponding to SS components
        with external attribute).
@item mttv
        ui -- the @emph{internal} system inputs (corresponding to SS components
        with internal attribute) used to solve algebraic loops
        (@pxref{Algebraic loops}).
@item MTTy
        y -- the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

@menu
* Transformation ese2dae_r::    
@end menu

@node Transformation ese2dae_r,  , Differential-Algebraic Equations (reduce), Differential-Algebraic Equations (reduce)
@subsubsection Transformation ese2dae_r
@cindex Transformation ese2dae_r
@pindex  ese2dae_r

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to combine the elementary system
equations (@pxref{Elementary system equations}) with the
constitutive relationships (@pxref{Constitutive relationship})
and simplify the result. 

@node Differential-Algebraic Equations (m),  , Differential-Algebraic Equations (reduce), Differential-Algebraic Equations
@subsection Language m (dae.m)
@cindex Differential-Algebraic Equations (m)
@cindex dae.m
The system DAEs (@pxref{Differential-Algebraic Equations})
are represented in the m (@pxref{m}) language as  
two m-functions of the form:

@example
function resid = sys_dae(dx,x,t)
function y  = sys_dae(dx,x,t)
@end example
Where x is the dae @emph{descriptor} vector and dx its 
time derivative; t is the time.
The first function is of a form suitable for solution by DASSL;  
the second function can then be used to find the coresponding system
output.

@menu
* Transformation dae_r2m::      
@end menu

@node Transformation dae_r2m,  , Differential-Algebraic Equations (m), Differential-Algebraic Equations (m)
@subsubsection Transformation dae_r2m
@cindex Transformation dae_r2m
@pindex  dae_r2m

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to rewrite the elementary system
equations (@pxref{Elementary system equations}) in m-file 
format  (@pxref{m}) . Numerical parameters are declared as global.


@node Constrained-state Equations, Ordinary Differential Equations, Differential-Algebraic Equations, Representations
@section Constrained-state Equations (cse)
@cindex Constrained-state Equations
@cindex ODE

The system constrained-state equations describe the system dynamics for
a special class of systems (see the book for details). The resuting
equations are of the form:
@example
E(x) dx/dt = f(x,u)
y = g(x,u)
@end example
They typically occure where two or more states are constrained to be equal, or
proportional, to each other. For example, two capacitors in parallel or
two inertias connected by a stiff shaft.


They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys cse lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable

There are three sets of variables describing the system:
@vtable @code
@item x
        the system states (corresponding to C and I components with integral
        causality.
@item u
        the system inputs  (corresponding to SS components
        with external attribute).
@item y
        the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

In general there are two sets of equations. The right-hand side of
 each is a function of x and  u  and the left hand sides are:
@enumerate
@item
the derivative of x (dx/dt)
y
@end enumerate

@menu
* Constrained-state Equations (reduce)::  
* Constrained-state Equations (view)::  
@end menu

@node Constrained-state Equations (reduce), Constrained-state Equations (view), Constrained-state Equations, Constrained-state Equations
@subsection Language reduce (cse.r)
@cindex Constrained-state Equations (reduce)
@cindex cse.r 

The system CSEs (@pxref{Constrained-state Equations})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the algebraic expressions for the 
right hand sides of each set of equations. The arrays are:
@vtable @code
@item MTTx
        x -- the system states (corresponding to C and I components with integral
        causality.
@item MTTu
        u -- the system inputs  (corresponding to SS components
        with external attribute).
@item MTTy
        y -- the  system outputs (corresponding to SS components
        with external attribute).
@end vtable
together with the array containing the elements of the E matrix.
@menu
* Transformation dae2cse_r::    
@end menu

@node Transformation dae2cse_r,  , Constrained-state Equations (reduce), Constrained-state Equations (reduce)
@subsubsection Transformation dae2cse_r
@cindex Transformation dae2cse_r
@pindex  dae2cse_r

This transformation (@pxref{What is a Transformation?}) 
Reduce (@pxref{Reduce}) to find various Jacobians which are combined to
find the E matrix and the
constrained-state equations (@pxref{Constrained-state Equations}).

@node Constrained-state Equations (view),  , Constrained-state Equations (reduce), Constrained-state Equations
@subsection Language m (view)
@cindex Constrained-state Equations (view)
@cindex view Constrained-state Equations
This representation has the standard text view
(@pxref{Views}).

@node Ordinary Differential Equations, Descriptor matrices, Constrained-state Equations, Representations
@section Ordinary Differential Equations
@cindex Ordinary Differential Equations
@cindex ODE

The system ordinary differential equations describe the system dynamics.

They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys ode lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable

There are three sets of variables describing the system:
@vtable @code
@item x
        the system states (corresponding to C and I components with integral
        causality.
@item u
        the system inputs  (corresponding to SS components
        with external attribute).
@item y
        the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

In general there are two sets of equations. The right-hand side of
 each is a function of x and  u  and the left hand sides are:
@enumerate
@item
the derivative of x (dx/dt)
y
@end enumerate

@menu
* Ordinary Differential Equations (reduce)::  
* Ordinary Differential Equations (m)::  
* Ordinary Differential Equations (view)::  
@end menu

@node Ordinary Differential Equations (reduce), Ordinary Differential Equations (m), Ordinary Differential Equations, Ordinary Differential Equations
@subsection Language reduce (ode.r)
@cindex Ordinary Differential Equations (reduce)
@cindex ode.r 

The system ODEs (@pxref{Ordinary Differential Equations})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the algebraic expressions for the 
right hand sides of each set of equations. The arrays are:
@vtable @code
@item MTTx
        x -- the system states (corresponding to C and I components with integral
        causality.
@item MTTu
        u -- the system inputs  (corresponding to SS components
        with external attribute).
@item MTTy
        y -- the  system outputs (corresponding to SS components
        with external attribute).
        @end vtable

@menu
* Transformation cse2ode_r::    
@end menu

@node Transformation cse2ode_r,  , Ordinary Differential Equations (reduce), Ordinary Differential Equations (reduce)
@subsubsection Transformation cse2ode_r
@cindex Transformation cse2ode_r
@pindex  cse2ode_r

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to invert the E matrix of the 
constrained-state equations (@pxref{Constrained-state Equations})
and simplify the result. 

@node Ordinary Differential Equations (m), Ordinary Differential Equations (view), Ordinary Differential Equations (reduce), Ordinary Differential Equations
@subsection Language m (ode.m)
@cindex Ordinary Differential Equations (m)
@cindex ode.m
The system ODEs (@pxref{Ordinary Differential Equations})
are represented in the m (@pxref{m}) language as  
two m-functions of the form:

@example
function dx = sys_ODE(x,t)
function y  = sys_ODE(dx,x,t)
@end example
Where x is the ODE @emph{state} vector and dx its 
time derivative; t is the time.
The first function is of a form suitable for solution by odesol;  
the second function can then be used to find the corresponding system
output.

@menu
* Transformation ode_r2m::      
@end menu

@node Transformation ode_r2m,  , Ordinary Differential Equations (m), Ordinary Differential Equations (m)
@subsubsection Transformation ode_r2m
@cindex Transformation ode_r2m
@pindex  ode_r2m

This transformation (@pxref{What is a Transformation?}) 
uses Reduce (@pxref{Reduce}) to rewrite the
ordinary differential equations
(@pxref{Ordinary Differential Equations}) in m-file 
format  (@pxref{m}) . Numerical parameters are declared as global.

@node Ordinary Differential Equations (view),  , Ordinary Differential Equations (m), Ordinary Differential Equations
@subsection Language m (view)
@cindex Ordinary Differential Equations (view)
@cindex view Ordinary Differential Equations
This representation has the standard text view
(@pxref{Views}).

@node Descriptor matrices, Report, Ordinary Differential Equations, Representations
@section Descriptor matrices (dm)
@cindex Descriptor matrices
@cindex dm

The system descriptor matrices A, B, C, D and E describe the 
@emph{linearised} system dynamics in the form
@example
E dx/dt = Ax + Bu
y = Cx + Du
@end example

They are generated in language @code{lang} for system 
@code{sys} by:
@example
mtt sys dm lang
@end example
Valid languages are:
@vtable @code
@item r
        reduce (@pxref{Reduce}).
@item m
        m  (@pxref{m}).
@item view
        reduce (@pxref{Views}).
@end vtable


@menu
* Descriptor matrices (reduce)::  
* Descriptor matrices (m)::     
@end menu

@node Descriptor matrices (reduce), Descriptor matrices (m), Descriptor matrices, Descriptor matrices
@subsection Language reduce (dm.r)
@cindex Descriptor matrices (reduce)
@cindex dm.r 

The system  descriptor matrices (@pxref{Descriptor matrices})
are represented in the reduce  (@pxref{Reduce}) language as 
arrays containing the four matrices. The arrays are:
@vtable @code
@item MTTA
        A 
@item MTTB
        B 
@item MTTA
        C
@item MTTD
        D
@item MTTE
        E
@end vtable

@node Descriptor matrices (m),  , Descriptor matrices (reduce), Descriptor matrices
@subsection Language m (dm.m)
@cindex Descriptor matrices (m)
@cindex dm.m
The system descriptor matrices (@pxref{Descriptor matrices})
are represented in the m (@pxref{m}) language as  
an m-function of the form:

@example
function [A,B,C,D,E] = sys_dm
@end example

System numeric parameters (@pxref{Numeric parameters})
are passed via global variables defined in the _numpar.m file.
@c (@pxref{numpar.m}). 
Thus the system descriptor matrices are
typically generated in Octave (@pxref{Octave}) as follows:

@example
sys_numpar
[A,B,C,D,E] = sys_dm
@end example

Parameters can be changed from their default values by entering
their values directly into Octave (@pxref{Octave})  and then invoking
@code{sys_dm}; for example
@example
sys_numpar
par_1 = 25
par_2 = par_1 + 3
[A,B,C,D,E] = sys_dm
@end example


@node Report,  , Descriptor matrices, Representations
@section Report (rep)
@cindex Report
@cindex rep

@strong{MTT} has a report-generator feature. The user specifies the
report contents in a text file (@pxref{Report (text)}) using an
appropriate text editor (@pxref{Text editors}).

For example, the report can be viewed by typing
@example
mtt system rep view
@end example


@menu
* Report (text)::               
* Report (view)::               
@end menu

@node Report (text), Report (view), Report, Report
@subsection Language text (rep.txt)
@cindex Report (text)
@cindex rep.txt 

The user specifies the report contents in a text file (@pxref{Report
(text)}) using an appropriate text editor (@pxref{Text editors}).
The text file contains lines which are either comments (indicated by %)
or valid @strong{MTT} commands. The report will then contain appropriate
sections. The following languages are supported by the report generator:
@ftable @code
@item m
        @code{octave} a high-level interactive language for numerical
        computation.
@item r
        @code{reduce}  a high-level interactive language for symbolic
        computation.
@item tex
        @code{latex} a text processor.
@item ps
        @code{ghostview} another document viewer.
@item c
        @code{gcc} a c compiler.
@end ftable
For example:
@example
mtt rc abg tex
mtt rc cbg ps
mtt rc struc tex
mtt rc ode tex
mtt rc sro ps
mtt rc tf tex
mtt rc lmfr ps
@end example

The acausal bond graph (abg) (@pxref{Acausal bond graph (abg)}) with the
tex language is handled in a special way: the acausal Bond Graph  in
fig format (@pxref{Language fig (abg.fig)}), the label file (@pxref{Labels (lbl)})
the description file (@pxref{Detailed}), together with
corresponding subsystems are included in the report. It is recommended
that the first (non-comment line) in the file should be:
@example
mtt <system> abg tex
@end example
where @code{<system>} is the name of the (top-level) system.

As usual, @strong{MTT} provides a default text file to be edited by the
user (@pxref{Text editors}).

In the special case that the first argument to mtt (normally the system)
is a directory, a default text file is provided which generates a report
for all systems to be found in that directory tree.

@node Report (view),  , Report (text), Report
@subsection Language view
@cindex Report (view)
@cindex view Report
This representation has the standard text view
(@pxref{Views}).

@node Extending MTT, Documentation, Representations, Top
@comment  node-name,  next,  previous,  up
@chapter Extending MTT
@cindex Extending MTT
@cindex Make

@strong{MTT} has a number of built-in mechanisms for the user to extend
its capabilities. As @strong{MTT} is based on `Make' it is unsurprising
that some of these  involve the creation of `make files'. 

@menu
* Makefiles::                   
* New (DIY) representations::   
* Component library::           
@end menu

@node Makefiles, New (DIY) representations, Extending MTT, Extending MTT
@comment  node-name,  next,  previous,  up
@section Makefiles
@cindex Makefiles

If a file called `Makefile' exists in the current directory,
@strong{MTT} executes it using make before doing anything else. This is
useful if one of the .txt files contains a reference to, for example, an
octave function of which @strong{MTT} unaware. Such a function can be
created using the makefile. An example `Makefile' is
@example
# Makefile for the Two link GMV example

all: msdP_tf.m TwoLinkP_obs.m TwoLinkP_sm.m twolinkp_sm.m TwoLinkGMV_numpar.m 

msdP_tf.m: msdP_abg.fig 
        mtt -q msdP tf m

TwoLinkP_obs.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
        mtt -q TwoLinkP obs m

TwoLinkP_sm.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
        mtt -q TwoLinkP sm m

twolinkp_sm.m: TwoLinkP_sm.m
        cp -v TwoLinkP_sm.m twolinkp_sm.m

TwoLinkGMV_numpar.m: TwoLinkGMV_numpar.txt
        mtt -q TwoLinkGMV numpar m
@end example
All of the files in the line stating `all:' are created when
@strong{MTT} is executed (if they don't already exist).

@node New (DIY) representations, Component library, Makefiles, Extending MTT
@comment  node-name,  next,  previous,  up
@section New (DIY) representations
@cindex New representations
@cindex DIY representations

It may be convenient to create new representations for @strong{MTT}; in
particular, it is nice to be able to include the result of some
numerical or symbolic computations within an @strong{MTT} report
(@pxref{Report}). Therefore @strong{MTT} provides a mechanism for doing
this.

Future extensions of @strong{MTT} will use such representations stored
in $MTT_REP.

There are three parts to creating a DIY representation called myrep
@enumerate
@item Creating a make file in Make format called myrep_rep.make
@item Optionally creating a shell script called myrep_rep.sh
@item Optionally creating a documentation file in LaTeX format called myrep_rep.tex
@end enumerate

@menu
* Makefile (DIY representations)::  
* Shell-script (DIY representations)::  
* Documentation (DIY representations)::  
@end menu

@node Makefile (DIY representations), Shell-script (DIY representations), New (DIY) representations, New (DIY) representations
@comment  node-name,  next,  previous,  up
@subsection Makefile
@cindex New representations
@cindex DIY representations
@cindex Makefile

To create a new representation `myrep' in a language `mylang', create a
file with the name
@example
myrep_rep.make
@end example
This file must contain text in `make' syntax. It is executed by
@strong{MTT} and the two arguments `SYS' (the system name) and `LANG'
(the language) are passed to it by @strong{MTT}. Note that @strong{MTT}
cannot know of any prerequisites, but these can be explicitly included in
the makefile (which may include execution of @strong{MTT} itself.

The following example declares the new representation `ident' which is
created in conjunction with the shell-script ident_rep.sh (@pxref{Shell-script (DIY
representations)}).

@verbatim
# -*-makefile-*-

#SUMMARY 	Identification
#DESCRIPTION 	Partially know system identification using
#DESCRIPTION    using bond graphs

# Makefile for representation ident
# File ident_rep.make

#Copyright (C) 2000,2001,2002 by Peter J. Gawthrop

## Model targets
model_reps =  ${MTT_SYS}_sympar.m ${MTT_SYS}_simpar.m ${MTT_SYS}_state.m 
model_reps += ${MTT_SYS}_numpar.m ${MTT_SYS}_input.m ${MTT_SYS}_ode2odes.m  
model_reps += ${MTT_SYS}_def.m 

## Prepend s to get the sensitivity targets
sensitivity_reps = ${model_reps:%=s%}

## Model prerequisites
model_pre =  ${MTT_SYS}_abg.fig ${MTT_SYS}_lbl.txt 
model_pre += ${MTT_SYS}_rdae.r ${MTT_SYS}_numpar.txt

## Prepend s to get the sensitivity targets
sensitivity_pre = ${model_pre:%=s%}


## Simulation targets
sims = ${MTT_SYS}_sim.m s${MTT_SYS}_ssim.m

## m-files needed for ident
ident_m = ${MTT_SYS}_ident.m ${MTT_SYS}_ident_numpar.m 

## Targets for the ident simulation
ident_reps = ${ident_m} ${sims} ${model_reps} ${sensitivity_reps}

## ps output files etc
psfiles = ${MTT_SYS}_ident.ps ${MTT_SYS}_ident.comparison.ps
figfiles = ${psfiles:%.ps=%.fig}
gdatfiles = ${psfiles:%.ps=%.gdat}
datfiles = ${psfiles:%.ps=%.dat2}

## LaTeX files etc
latexfiles = ${MTT_SYS}_ident_par.tex

all: ${MTT_SYS}_ident.${MTT_LANG}

echo:
	echo "sims: ${sims}"
	echo "model_reps: ${model_reps}"
	echo "sensitivity_reps: ${sensitivity_reps}"
	echo "ident_reps: ${ident_reps}"

${MTT_SYS}_ident.view: ${psfiles}
	ident_rep.sh ${MTT_SYS} view

${psfiles}: ${figfiles}
	ident_rep.sh ${MTT_SYS} ps

${figfiles}: ${gdatfiles}
	ident_rep.sh ${MTT_SYS} fig

${gdatfiles}: ${datfiles}
	ident_rep.sh ${MTT_SYS} gdat

${datfiles} ${latexfiles}: ${ident_reps}
	ident_rep.sh ${MTT_SYS} dat2

${MTT_SYS}_ident.m: 
	ident_rep.sh ${MTT_SYS} m

${MTT_SYS}_ident_numpar.m:
	ident_rep.sh ${MTT_SYS} numpar.m

## System model reps
## Generic txt files 
${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* txt

## Specific m files
${MTT_SYS}_ode2odes.m: ${model_pre}
	mtt -q -stdin ${MTT_OPTS} ${MTT_SYS} ode2odes m

${MTT_SYS}_sim.m: ${MTT_SYS}_ode2odes.m
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} sim m

## Numpar files
${MTT_SYS}_numpar.m:
	mtt ${MTT_SYS} numpar m

## Sympar files
${MTT_SYS}_sympar.m:
	mtt ${MTT_SYS} sympar m

## Generic txt to m
${MTT_SYS}_%.m: ${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* m

## r files
${MTT_SYS}_def.r: ${MTT_SYS}_abg.fig
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} def r

${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} rdae r

## Sensitivity model reps
## Generic txt files 
s${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} $* txt

## Specific m files
## Numpar files
s${MTT_SYS}_numpar.m:
	mtt -s s${MTT_SYS} numpar m

## Sympar files
s${MTT_SYS}_sympar.m:
	mtt -s s${MTT_SYS} sympar m

s${MTT_SYS}_ode2odes.m: ${sensitivity_pre}
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ode2odes m

s${MTT_SYS}_ssim.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ssim m

s${MTT_SYS}_def.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} def m


## Generic txt to m
s${MTT_SYS}_%.m: s${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* m

## r files
s${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} rdae r

@end verbatim

@node Shell-script (DIY representations), Documentation (DIY representations), Makefile (DIY representations), New (DIY) representations
@comment  node-name,  next,  previous,  up
@subsection Shell-script
@cindex New representations
@cindex DIY representations
@cindex Shell-script

For more complex DIY representations, it is convenient to define new
commands to be used by the Makefile (@pxref{Makefile (DIY
representations)}).

The following example shows this in the context of the DIY
representation `ident' used as an example in the previous section
(@pxref{Makefile (DIY representations)}).


@verbatim
#! /bin/sh

## ident_rep.sh
## DIY representation "ident" for mtt
# Copyright (C) 2002 by Peter J. Gawthrop

ps=ps

sys=$1
rep=ident
lang=$2
mtt_parameters=$3
rep_parameters=$4

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_ident.dat2
dat2s_file=${sys}_idents.dat2
ident_numpar_file=${sys}_ident_numpar.m
option_file=${sys}_ident_mtt_options.txt

## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

check_new_options() {
    if [ -f "${option_file}" ]; then
	old_options=`cat ${option_file}`
        if [ "${mtt_options}" != "${old_options}" ]; then
	   echo ${mtt_options} > ${option_file}
	fi
    else
	echo ${mtt_options} > ${option_file}
    fi
}

## Make the _ident.m file
make_ident() {
filename=${sys}_${rep}.m
date=`date`
echo Creating ${filename}

cat > ${filename} <<EOF    
function [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)

  ## usage:  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)
  ##
  ## last      last time in run
  ## ppp_names Column vector of names of ppp params
  ## par_names Column vector of names of estimated params
  ## extras    Structure containing additional info
  ##
  ## Created by MTT on ${date}
 
  ## Sensitivity system name
  system_name = "s${sys}"

  ##Sanity check
  if nargin<3
    printf("Usage: [y,u,t] = ${sys}_ident(y,u,t,par_names,Q,extras);");
    return
  endif

  if nargin<6
    ## Set up optional parameters
    extras.criterion = 1e-3;
    extras.emulate_timing = 0;
    extras.max_iterations = 10;
    extras.simulate = 2;
    extras.v =  1e-2;
    extras.verbose = 1;
    extras.visual = 1;
  endif
  
  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  sympar  = ${sys}_sympar;
  simpar  = ${sys}_simpar;
  sympars  = s${sys}_sympar;
  simpars  = s${sys}_simpar;

  ## Parameter indices
  i_par = ppp_indices (par_names,sympar,sympars);

  ## Initial model state
  x_0 = zeros(2*n_x,1);

  ## Initial model parameters
  par_0 = s${sys}_numpar;

  ## Reset simulation parameters
  [n_data,m_data] = size(y);
  dt = t(2)-t(1);
  simpars.last = (n_data-1)*dt;
  simpars.dt = dt;

  ## Identification
  [epar,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpars,u,y,i_par,Q,extras);
  
  ## Do some plots
  figure(1);
  title("Comparison of data");
  xlabel("t");
  ylabel("y");
  [N,M] = size(Y);
  plot(t,Y(:,M-n_y+1:M),"1;Estimated;", t,y,"3;Actual;");
  figfig("${sys}_ident_comparison");

  ## Create a table of the parameters
  [n_par,m_par] = size(i_par);
  fid = fopen("${sys}_ident_par.tex", "w");
  fprintf(fid,"\\\\begin{table}[htbp]\\n");
  fprintf(fid," \\\\centering\\n");
  fprintf(fid," \\\\begin{tabular}{|l|l|}\\n");
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"  Name & Value \\\\\\\\ \\n");
  fprintf(fid,"  \\\\hline\\n");
  for i = 1:n_par
    fprintf(fid,"$%s$ & %4.2f \\\\\\\\ \\n", par_names(i,:), epar(i_par(i,1)));
  endfor
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"\\\\end{tabular}\\n");
  fprintf(fid,"\\\\caption{Estimated Parameters}\\n");
  fprintf(fid,"\\\\end{table}\\n");
  fclose(fid);

endfunction
EOF
}

make_ident_numpar() {
echo Creating ${ident_numpar_file}
cat > ${sys}_ident_numpar.m <<EOF
function [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;

  ## usage: [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  ## Edit for your own requirements
  ## Created by MTT on ${date}

    
  ## This section sets up the data source
  ## simulate = 0  Real data (you supply ${sys}_ident_data.dat)
  ## simulate = 1  Real data input, simulated output
  ## simulate = 2  Unit step input, simulated output
  simulate = 2;
  

  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  simpars = s${sys}_simpar;

  ## Access or create data
  if (simulate<2)		# Get the real data
    if (exist("${sys}_ident_data.dat")==2)
      printf("Loading ${sys}_ident_data.dat\n");
      load ${sys}_ident_data.dat
    else
      printf("Please create a loadable file ${sys}_ident_data.dat containing y,u and t\n");
      return
    endif
  else 
    switch simulate
      case 2			# Step simulation
	t = [0:simpars.dt:simpars.last]';
	u = ones(size(t));
      otherwise
	error(sprintf("simulate = %i not implemented", simulate));
    endswitch
  endif
  
  if (simulate>0)
    par = ${sys}_numpar();
    x_0 = ${sys}_state(par);
    dt = t(2)-t(1);
    simpars.dt = dt;
    simpars.last = t(length(t));
    y =  ${sys}_sim(zeros(n_x,1), par, simpars, u);
  endif

  ## Default parameter names - Put in your own here
  sympar = ${sys}_sympar;	# Symbolic params as structure
  par_names = struct_elements (sympar);	# Symbolic params as strings
  [n,m] = size(par_names);	# Size the string list

  ## Sort by index
  for [i,name] = sympar
    par_names(i,:) = sprintf("%s%s",name, blanks(m-length(name)));
  endfor
  
  ## Output weighting vector
  Q = ones(n_y,1);
  
  ## Extra parameters
  extras.criterion = 1e-5;
  extras.emulate_timing = 0;
  extras.max_iterations = 10;
  extras.simulate = simulate;
  extras.v =  1e-2;
  extras.verbose = 1;
  extras.visual = 1;

endfunction
EOF
}

make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras);
  [N,M] = size(Y);
  y_est = Y(:,M);
  data = [t,y_est,u];
  save -ascii ${dat2_file} data
EOF

## Tidy up the latex stuff - convert foo_123 to foo_{123}
cat ${sys}_ident_par.tex > mtt_junk
sed  -e "s/_\([a-z0-9,]*\)/_{\1}/g" < mtt_junk >${sys}_ident_par.tex
rm mtt_junk
}

case ${lang} in
    numpar.m)
        ## Make the numpar stuff
        make_ident_numpar;
	;;
    m)
        ## Make the code
        make_ident;
	;;
    dat2)
        ## The dat2 language (output data) & fig file
	make_dat2; 
	;;
    gdat)
        cp ${dat2_file} ${dat2s_file} 
	dat22dat ${sys} ${rep} 
        dat2gdat ${sys} ${rep}
	;;
    fig)
        gdat2fig ${sys}_${rep}
	;;
    ps)
        figs=`ls ${sys}_ident*.fig | sed -e 's/\.fig//'`
	for fig in ${figs}; do
            fig2dev -Leps ${fig}.fig > ${fig}.ps
	done
	texs=`ls ${sys}_ident*.tex | sed -e 's/\.tex//'`
	for tex in ${texs}; do
          makedoc "" "${sys}" "ident_par" "tex" "" "" "$ps"
          doc2$ps ${sys}_ident_par "$documenttype"
	done
	;;
    view)
	pss=`ls ${sys}_ident*.ps` 
        echo Viewing ${pss}
        for ps in ${pss}; do
          gv ${ps}&
	done
	;;
    *)
	echo Language ${lang} not supported by ${rep} representation
        exit 3
esac



@end verbatim

@node Documentation (DIY representations),  , Shell-script (DIY representations), New (DIY) representations
@comment  node-name,  next,  previous,  up
@subsection Documentation
@cindex New representations
@cindex DIY representations
@cindex Documentation


@node Component library,  , New (DIY) representations, Extending MTT
@comment  node-name,  next,  previous,  up
@section Component library
@cindex Component library
@cindex component
@cindex Component library

If @strong{MTT} does not recognise a component (eg named MyComponent) as
a simple component (@pxref{Simple components}) or as already existing,
it searches the library search path $MTT_COMPONENTS
(@pxref{$MTT_COMPONENTS}) for a directory called MyComponent containing
MyComponent_lbl.txt. It then copies the @emph{entire} directory into the
current working directory. Thus, for example, the directory could
contain MyComponent_desc.tex MyComponent_abg.fig MyComponent_lbl.txt and MyComponent_cr.r in
addition to MyComponent_lbl.txt.

@c      node   next  prev  up
@node   Documentation, Languages, Extending MTT, Top
@chapter Documentation
@cindex Documentation

@menu
* Manual (Documentation)::      
* On-line documentation::       
@end menu

@node   Manual (Documentation), On-line documentation, Documentation, Documentation
@section Manual
@cindex Manual

MTT is documented in this manual. The manual can be invoked in various
ways:

@vtable @code
@item mtt manual
      Brings up a pdf version of the manual
@item mtt info
      Brings up an xterm containing an info version of the manual
@item mtt hinfo
      Brings up an html browser containing the manual
@item emacs
      type ^h^i followed by mmtt in the command window
@item browser
      point browser to http://mtt.sf.net
@end vtable

@node On-line documentation,  , Manual (Documentation), Documentation
@section On-line documentation
@cindex Components 
@cindex Examples
@cindex Documentation
@cindex On-line documentation

@strong{MTT} components, constitutive relations, examples and representations in libraries
(@pxref{Component library}) are documented in two ways:

@enumerate 
@item brief 
@item verbose
@end enumerate

@menu
* Brief::                       
* Detailed::                    
@end menu

@node Brief, Detailed, On-line documentation, On-line documentation
@subsection Brief on-line documentation
@cindex Brief documentation

Documentation of DIY components, examples, constitutive relationships
and representations is provides by the programmer by inserting code of
the form

@example
#SUMMARY     One line summary
#DESCRIPTION Multi-line
#DESCRIPTION More detailed description
@end example

within the appropriate file (usually at or near the top):
@vtable @code
@item components
      _lbl.txt (@pxref{Labels (lbl)})
@item examples
      _lbl.txt (@pxref{Labels (lbl)})
@item constitutive relations
      _cr.r (@pxref{DIY constitutive relationships})
@item representations
      _rep.make (@pxref{Makefile (DIY representations)})
@end vtable

This documentation is accessed by the user in various ways
@vtable @code
@item mtt help name
      prints basic information on the screen
@item mtt system lbl view
      gives formatted information about the component or example
@item Including mtt system abg tex in the _rep.txt file
      gives formatted information about the component or example
      within the report
@end vtable

@node Detailed,  , Brief, On-line documentation
@subsection Detailed on-line documentation
@cindex Detailed documentation
@cindex Description
@cindex desc

DIY components, examples, constitutive relationships can be described
textually in LaTeX (.tex) description file; this is the only language
for this representation. This representation is used by the LaTeX
language version (@pxref{Language tex (abg.tex)}) of the acausal bond
graph representation (@pxref{Acausal bond graph (abg)}).

The file may contain any  LaTeX commands
valis for the ``article'' document type but must @strong{not} contain:
@itemize @bullet
@item documentclass commands
@item document environments
@end itemize

@c      node   next  prev  up
@node   Languages, Language tools, Documentation, Top
@chapter Languages
@cindex Languages
@pindex Languages


@c      node   next  prev  up
@menu
* Fig::                         r
* m::                           
* Reduce::                      
* c::                           
@end menu

These are a number of languages used by @strong{MTT} to implement the
various representations.
Each has associated Language tools (@pxref{Language tools}) to
manipulate and/or view the representation.

@ftable @code
@item fig
        @code{Fig} a graphical description language.
@item m
        @code{octave} a high-level interactive language for numerical
        computation.
@item r
        @code{reduce}  a high-level interactive language for symbolic
        computation.
@item tex
        @code{latex} a text processor.
@item dvi
        @code{xdvi} a document viewer.
@item ps
        @code{ghostview} another document viewer.
@item gdat
        @code{gnuplot} a data viewer.
@item c
        @code{gcc} a c compiler.
@item sg
	@code{scigraphica} a plotting package.
@end ftable

These tools are automatically invoked as appropriate by @strong{MTT};
but for more advanced use, these tools can be used directly on files
(with the appropriate suffix) generated by @strong{MTT}.



@node   Fig, m, Languages, Languages
@section Fig
@cindex Fig
@pindex Fig
Please see xfig documentation.

@node   m, Reduce, Fig, Languages
@section m
@cindex m
@pindex m
Please see Octave documentation 
@ifhtml
<A HREF="http://www.che.wisc.edu/octave/">Octave</A> documentation.
<A HREF="http://www.mathworks.com/homepage.html">Matlab</A> documentation.
@end ifhtml


@node   Reduce, c, m, Languages
@section Reduce
@cindex Reduce
@pindex Reduce
Please see the reduce documentation.

@node c,  , Reduce, Languages
@comment  node-name,  next,  previous,  up
@section c
@cindex c
@pindex c
Please see the gcc documentation.
@node Language tools, Administration, Languages, Top
@comment  node-name,  next,  previous,  up
@chapter Language tools
@cindex  Language tools

@menu
* Views::                       
* Xfig::                        
* Text editors::                
* Octave::                      
* LaTeX::                       
@end menu

@node Views, Xfig, Language tools, Language tools
@comment  node-name,  next,  previous,  up
@section Views
@cindex views

A number of representations (@pxref{Representations}) have a language
representation which is particularly useful for viewing by the
user. These views are
invoked, where appropriate by the command:
@example
mtt sys rep view
@end example
where @code{sys} is the system name and @code{rep} a corresponding representation.

@node Xfig, Text editors, Views, Language tools
@comment  node-name,  next,  previous,  up
@section Xfig
@cindex Xfig

@node Text editors, Octave, Xfig, Language tools
@comment  node-name,  next,  previous,  up
@section Text editors
@cindex Text editors
All representations live in text files and thus may be edited using your
favourite text editor; however, the Fig (@pxref{Fig}) representation is
pretty meaningless in this form and so you should use Xfig
(@pxref{Xfig}) for representation in this language.

Its up to you which text editor to use. I recommend emacs, but simpler
(and less powerful) editors such as xedit, textedit and vi are also ok.

I usually run @strong{MTT} out of an emacs shell window and keep the
rest of the files in emacs buffers.

@node Octave, LaTeX, Text editors, Language tools
@comment  node-name,  next,  previous,  up
@section Octave
@cindex Octave
@cindex Matlab
@cindex m-files
@cindex Octave interface
@cindex mtt.m

Octave is a numerical matrix-based language @xref{Top,
,Octave,Octave,Octave}.  It is similar to Matlab in many ways. In most
cases, m-files generated by @strong{MTT} can be understood by both
Matlab and Octave (and no doubt other Matlab lookalikes).

 @strong{MTT} provides the octave function @code{mtt}. The octave
 command
@example
help mtt
@end example
gives the following information:
@example
 usage:  mtt (system[,representation,language])

 Invokes mtt from octave to generate system_representation.language
 Ie equivalent to "mtt system representation language" at the shell
 Representation and language defualt to "sm" and "m" respectively

@end example

Thus for example, if octave is in the directory containing the system
rc the following session generates the state matrices of the system "rc"
with the defaut capacitance but resitance r=0.1.
@example
octave> mtt("rc");
Creating rc_rbg.m
Creating rc_cmp.m
Creating rc_fig.fig
Creating rc_sabg.fig
Creating rc_alias.txt
Creating rc_alias.m
Creating rc_sub.sh
Creating rc_abg.m
Creating rc_cbg.m (maximise integral causality)
Creating rc_type.sh
Creating rc_ese.r
Creating rc_def.r
Creating rc_struc.txt
Creating rc_rdae.r
Creating rc_subs.r
Creating rc_cr.txt
Creating rc_cr.r
Copying CR SS to here from
Copying CR lin to here from
Creating rc_dae.r
Creating rc_sympar.txt
Creating rc_sympar.r
Creating rc_cse.r
Creating rc_sspar.r
Creating rc_csm.r
Creating rc_ode.r
Creating rc_ss.r
Creating rc_sm.r
Creating rc_switch.txt
0 switches found
Creating rc_sympars.txt
Creating rc_sm.m
Copying rc_sm.m
octave> mtt("rc","numpar");
Creating rc_numpar.txt
Creating rc_numpar.m
Copying rc_numpar.m
octave> mtt("rc","sympar");
Creating rc_sympar.m
Copying rc_sympar.m
octave> par = rc_numpar
par =

  1
  1

octave> sym = rc_sympar;

octave> par(sym.r) = 0.1;
octave> [A,B,C,D] = rc_sm(par)
A = -10

B = 10

C = 1

D = 0

octave> 
@end example
generates the data structure rc corresponding the the bond graph of the
system called `rc'.
The following octave commands then generate the step reponse and bode
diagram respectively:
@example
step(rc);
bode(rc);
@end example


@menu
* Octave control system toolbox (OCST)::  
* Creating GNU Octave .oct files::  
* Creating Matlab .mex files::  
* Embedding MTT models in Simulink::  
@end menu

@node Octave control system toolbox (OCST), Creating GNU Octave .oct files, Octave, Octave
@comment  node-name,  next,  previous,  up
@subsection Octave control system toolbox (OCST)
@cindex Octave
@cindex toolbox
@cindex OCST
@cindex control systems
@cindex mtt2sys

@strong{MTT} provides an interface to the Octave control system toolbox
(OCST) using the mfile @code{mtt2sys}. the octave command
@example
help mtt2sys
@end example
gives the following information.
@example
 usage:  sys = mtt2sys (Name[,par])

 Creates a sys structure for the Octave Control Systems Toolbox
 from an MTT system with name "Name"
 Optional second argument is system parameter list
 Assumes that Name_sm.m, Name_struc.m and Name_numpar.m exist
@end example

Thus for example, if octave is in the directory containing the system
rc:
@example
rc = mtt2sys("rc");
@end example
generates the data structure rc corresponding the the bond graph of the
system called `rc'.
The following octave commands then generate the step reponse and bode
diagram respectively:
@example
step(rc);
bode(rc);
@end example

@node Creating GNU Octave .oct files, Creating Matlab .mex files, Octave control system toolbox (OCST), Octave
@comment  node-name,  next,  previous,  up
@subsection Creating GNU Octave .oct files
@cindex Creating GNU Octave .oct files

GNU Octave dynamically loaded functions (.oct files) can be created by
instructing @strong{MTT} to create the ``oct'' representation:

@example
  mtt [options] sys ode oct
@end example

This will cause @strong{MTT} to create the C++ representation of the system
(sys_ode.cc) and to then compile it as a shared object suitable for
use within Octave. The resultant file may be used in an identical
manner to the equivalent, but generally slower, interpreted .m file.

Usage information for the function may be obtained within Octave in the usual manner:

@example
  octave:1> help rc_ode

  rc_ode is the dynamically-linked function from the file
  /home/mttuser/rc/rc_ode.oct

  Usage: [mttdx] = rc_ode(mttx,mttu,mttt,mttpar)
  Octave ode representation of system rc
  Generated by MTT on Fri Jul  5 11:23:08 BST 2002
@end example

Note that the first line of output from Octave identifies whether the
compiled or interpreted function is being used.

Alternatively, standard representations may be generated using the
Octave DLDs by use of the ``-oct'' switch:

@example
  mtt -oct rc odeso view
@end example

In order to successfully generate .oct files, Octave must be correctly
configured prior to compilation and certain headers and libraries must
be correctly installed on the system (@pxref{.oct file dependencies}).

@node  Creating Matlab .mex files, Embedding MTT models in Simulink, Creating GNU Octave .oct files, Octave
@comment  node-name,  next,  previous,  up
@subsection Creating Matlab .mex files
@cindex Creating Matlab .mex files

On GNU/Linux systems, Matlab dynamically linked executables (.mexglx
files) can created by instructing @strong{MTT} to create the
``mexglx'' representation:

@example
  mtt [options] sys ode mexglx
@end example

This will cause @strong{MTT} to create the C++ representation of the
system (sys_ode.cc) and to then compile it as a shared object suitable
for use within Matlab.

If it is necessary to compile mex files for another platform, then the
usual C++ representation (generated with the -cc flag) can be created
and the resultant file compiled with the -DCODEGENTARGET=MATLABMEX
flag on the target platform.

@example
  mtt_machine:
  mtt -cc rc ode cc

  matlab_machine:
  matlab> mex -DCODEGENTARGET=MATLABMEX rc_ode.cc
@end example

@node  Embedding MTT models in Simulink,  , Creating Matlab .mex files, Octave
@comment  node-name,  next,  previous,  up
@subsection Embedding MTT models in Simulink
@cindex Embedding MTT models in Simulink

It is possible to embed @strong{MTT} functions or entire @strong{MTT}
models within Simulink simulations as Sfun blocks. If the zip package
is installed on the system, the command

@example
  mtt sys sfun zip
@end example

will create a compressed archive containing sys.mdl, which may be
embedded into a larger Simulink model. Also contained within the
archive will be four sys_sfun*.c files,

@itemize @bullet
@item
sys_sfun.c
model state and output equations
@item
sys_sfun_ae.c
model algebraic equations
@item
sys_sfun_input.c
model inputs
@item
sys_sfun_interface.c
interface between MTT model and Simulink
@end itemize

The last of these files must be edited to correctly map the inputs and
outputs between the @strong{MTT} and Simulink models. The two sections
to edit are clearly marked with

@example
  @code{/* Start EDIT */}
  @code{....}
  @code{/* End EDIT */}
@end example

These four files should then be compiled with the Matlab ``mex''
compiler as described in the @emph{README} file in the archive.

If it is desired to compile the .mex files directly from within
@strong{MTT} on a machine which has the Matlab header files installed,
this may be done with the command

@example
  mtt sys sfun mexglx 
@end example

which will generated the four .mex files and the .mdl file. In this
case, the user must ensure that @emph{sys_sfun_interface.c} has been
correctly edited prior to compilation.

Note that solution of algebraic equations within Simulink is not
possible unless the @emph{Matlab Optimisation Toolbox} is installed.

@node LaTeX,  , Octave, Language tools
@comment  node-name,  next,  previous,  up
@section LaTeX
@cindex LaTeX

LaTeX is a powerful text processor which @strong{MTT} uses to provide
visual output.

@node Administration, Glossary, Language tools, Top
@comment  node-name,  next,  previous,  up
@chapter  Administration
@cindex  Administration

@menu
* Software components::         
* REDUCE setup::                
* Octave setup::                
* Paths::                       
* File structure::              
* GNU Free Documentation License::  
* Copying::                     
@end menu

@node Software components, REDUCE setup, Administration, Administration
@comment  node-name,  next,  previous,  up
@section  Software components
@cindex  Software components

@strong{MTT} is built from a set of readily-available  software tools.
These are:
@itemize @bullet
@item General purpose software tools.
@item Octave (@pxref{Octave setup})
@item REDUCE  (@pxref{REDUCE setup})
@end itemize

The General purpose tools are (these will all be available with a
standard Linux distribution):
@vtable @code
@item sh
        Bourne shell
@item gmake
        Gnu make
@item gawk
        Gnu awk
@item sed
        Gnu sed
@item grep
        Gnu grep
@item comm
        Gnu Compare sorted files by line
@item xfig
        Figure editor, version 3 or greater.        
@item fig2dev
        Fig file conversion, version 3 or greater. 
@item ghostview
        postscript viewer
@item xdvi
        dvi viewer
@item dvips
        dvi to postscript conversion
@item latex
        the text processor (LaTeX2e needed)
@item latex2html
        converts latex to html
@item perl
        needed for latex2html
@item gnuplot
        a graph plotting program
@item gnuscape
        or other web/html browser such as netscape, Red Baron etc.
@item gcc
        GNU c compiler
@end vtable

@ifhtml
<A HREF="http://home.pages.de/~GNU/">GNU</A> documentation.
@end ifhtml



@node REDUCE setup, Octave setup, Software components, Administration
@comment  node-name,  next,  previous,  up
@section  REDUCE setup
@cindex REDUCE setup

Symbolic algebra is performed by REDUCE, which although not free
software is the the result of international collaboration. The version I
use is obtained from:
@quotation
ZIB ( http://www.zib.de )
@end quotation
@ifhtml
<A HREF="http://www.reduce-algebra.com">REDUCE</A> documentation.
<A HREF="http://www.zib.de">ZIB</A> documentation.
@end ifhtml

@node Octave setup, Paths, REDUCE setup, Administration
@comment  node-name,  next,  previous,  up
@section Octave setup
@cindex  Octave setup

Octave is available at various web sites including:
@uref{http://www.octave.org}

@menu
* .octaverc::                   
* .oct file dependencies::      
@end menu

@node .octaverc, .oct file dependencies, Octave setup, Octave setup
@comment  node-name,  next,  previous,  up
@subsection .octaverc
@vindex  .octaverc


The @file{.octaverc} file should contain the following lines:
@example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Startup file for Octave for use with MTT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

implicit_str_to_num_ok = 1;
empty_list_elements_ok = 1;

@end example

@node .oct file dependencies,  , .octaverc, Octave setup
@comment  node-name,  next,  previous,  up Additionally, it is necessary to
@subsection .oct file dependencies
Successful compilation of .oct code requires that Octave has been
configured to use dynamically linked libraries and that the Octave
libraries @code{liboctave}, @code{libcruft} and @code{liboctinterp}
are available on the system.

This can be acheived by compiling Octave from the source code, configured
with the options @code{--enable-shared} and @code{--enable-dl}.

A number of additional libraries and headers are also required to be
installed on a system. These include,
@itemize @bullet
@item
@emph{ncurses} and @emph{readline}
               terminal control routines
@item
@emph{blas} or @emph{altas}
            basic linear algebra subprograms, usually optimised for the specific processor
@item
@emph{fftw}
        fast Fourier transform routines
@item
@emph{g2c}
        GNU Fortran to C conversion routines
@item
@emph{kpathsea}
        TeX path search routines
@end itemize

Note that on many GNU/Linux distributions, the necessary headers are
contained in development packages which must be installed in addition
to the standard library package.

Further information on configuring and installing Octave to handle dynamic
libraries (DLDs) can be found in the
@uref{http://www.octave.org/docs.html,Octave documentation}.


@node Paths, File structure, Octave setup, Administration
@comment  node-name,  next,  previous,  up
@section Paths
@cindex paths
@cindex mttrc

There are a number of paths that must be set correctely for @strong{MTT}
to work. These are normally set up by sourcing the file @code{mttrc} that
lives in the @strong{MTT} home directory.

@menu
* $MTTPATH::                    
* $MTT_COMPONENTS::             
* $MTT_CRS::                    
* $MTT_EXAMPLES::               
* $OCTAVE_PATH::                
@end menu

@node $MTTPATH, $MTT_COMPONENTS, Paths, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTTPATH
@vindex $MTTPATH
The environment variable $MTTPATH points to the mtt home directory.
This is usually @code{/usr/local/lib/mtt}.

@node $MTT_COMPONENTS, $MTT_CRS, $MTTPATH, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTT_COMPONENTS
@vindex $MTT_COMPONENTS
The environment variable $MTT_COMPONENTS is a colon-separated path
pointing to directories containing components and subsystems.
By default
@example
MTT_COMPONENTS=.:$MTT_LIB/lib/comp/
@end example
but you may wish to add your own component libraries:
@example
MTT_COMPONENTS=my_library_path:$MTT_COMPONENTS
@end example

@node $MTT_CRS, $MTT_EXAMPLES, $MTT_COMPONENTS, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTT_CRS
@vindex $MTT_CRS
The environment variable $MTT_CRS is a colon-separated path
pointing to directories containing constitutive relationships.
By default
@example
MTT_CRS=$MTTPATH/lib/cr
@end example
but you may wish to add your own component libraries:
@example
MTT_CRS=my_cr_path:$MTT_CRS
@end example

@node $MTT_EXAMPLES, $OCTAVE_PATH, $MTT_CRS, Paths
@comment  node-name,  next,  previous,  up
@subsection $MTT_EXAMPLES
@vindex $MTT_EXAMPLES
The environment variable $MTT_EXAMPLES is a colon-separated path
pointing to directories containing EXAMPLES and subsystems.
By default
@example
MTT_EXAMPLES=$MTTPATH/lib/examples
@end example
but you may wish to add your own component libraries:
@example
MTT_EXAMPLES=my_examples_path:$MTT_EXAMPLES
@end example

@node $OCTAVE_PATH,  , $MTT_EXAMPLES, Paths
@comment  node-name,  next,  previous,  up
@subsection $OCTAVE_PATH
@vindex $OCTAVE_PATH

The @code{$OCTAVE_PATH} path must include the relevant paths for mtt to
work properly. In particular, it must include:
@example
$MTTPATH/trans/m
$MTTPATH/lib/comp/simple
$MTTPATH/lib/comp/compound
@end example

@node File structure, GNU Free Documentation License, Paths, Administration
@comment  node-name,  next,  previous,  up
@section  File structure
@cindex File structure
The recommended installation of @strong{MTT} uses the following
directory structure with corresponding contents. Normally, each of the
listed directories is a subdirectory of @file{/usr/local}. The directory
@code{mtt} is pointed to by $MTTPATH (@pxref{$MTTPATH}).

@vtable @file
@item mtt/bin
        This is the home directory for @strong{MTT}. @strong{MTT}  itself lives
        here along with @file{mttrc}.
@item mtt/bin/trans
        The transformations executed by @strong{MTT}.
@item mtt/bin/trans/m
        The  @code{m-files} associated with the transformations.
@item mtt/bin/trans/awk
        The  @code{awk} scripts associated with the transformations.
@item mtt/lib
        The place for components, examples and CRs which will be updated.
@item mtt/lib/comp/simple
@cindex simple components
        The  @code{m-files} defining the simple components.
@cindex compound components
@item mtt/lib/comp/compound
        The  @code{m-files} defining the compound components.
@item mtt/lib/cr/r
        constitutive relationship definitions
@item mtt/lib/examples
        Some examples. 
@item mtt/examples/metamodelling
        Examples from the book.
@item mtt/doc
        The  documentation files for @strong{MTT}.
@item mtt/doc/Examples
        Examples used in the documentation.
@end vtable

@appendix Legal stuff
@node GNU Free Documentation License, Copying, File structure, Administration
@appendixsec GNU Free Documentation License

@cindex FDL, GNU Free Documentation License
@center Version 1.2, November 2002

@display
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA  02111-1307, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display

@enumerate 0
@item
PREAMBLE

The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.

This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense.  It
complements the GNU General Public License, which is a copyleft
license designed for free software.

We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does.  But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book.  We recommend this License
principally for works whose purpose is instruction or reference.

@item
APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License.  Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein.  The ``Document'', below,
refers to any such manual or work.  Any member of the public is a
licensee, and is addressed as ``you''.  You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.

A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.

A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject.  (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.)  The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.

The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.  If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant.  The Document may contain zero
Invariant Sections.  If the Document does not identify any Invariant
Sections then there are none.

The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.  A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.

A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters.  A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text.  A copy that is not ``Transparent'' is called ``Opaque''.

Examples of suitable formats for Transparent copies include plain
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
format, @acronym{SGML} or @acronym{XML} using a publicly available
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
PostScript or @acronym{PDF} designed for human modification.  Examples
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
@acronym{JPG}.  Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, @acronym{SGML} or
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
not generally available, and the machine-generated @acronym{HTML},
PostScript or @acronym{PDF} produced by some word processors for
output purposes only.

The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page.  For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.

A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language.  (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.)  To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.

The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document.  These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.

@item
VERBATIM COPYING

You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License.  You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute.  However, you may accept
compensation in exchange for copies.  If you distribute a large enough
number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and
you may publicly display copies.

@item
COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover.  Both covers must also clearly and legibly identify
you as the publisher of these copies.  The front cover must present
the full title with all words of the title equally prominent and
visible.  You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.

If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.

It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.

@item
MODIFICATIONS

You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it.  In addition, you must do these things in the Modified Version:

@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document).  You may use the same title as a previous version
if the original publisher of that version gives permission.

@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.

@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.

@item
Preserve all the copyright notices of the Document.

@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.

@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.

@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.

@item
Include an unaltered copy of this License.

@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page.  If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.

@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on.  These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.

@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.

@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles.  Section numbers
or the equivalent are not considered part of the section titles.

@item
Delete any section Entitled ``Endorsements''.  Such a section
may not be included in the Modified Version.

@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.

@item
Preserve any Warranty Disclaimers.
@end enumerate

If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant.  To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.

You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.

You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version.  Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity.  If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.

@item
COMBINING DOCUMENTS

You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy.  If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''.  You must delete all
sections Entitled ``Endorsements.''

@item
COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.

@item
AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.

@item
TRANSLATION

Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections.  You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers.  In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.

If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.

@item
TERMINATION

You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License.  Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License.  However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.

@item
FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time.  Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.  See
@uref{http://www.gnu.org/copyleft/}.

Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation.  If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
@end enumerate

@page
@appendixsubsec ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:

@smallexample
@group
  Copyright (C)  @var{year}  @var{your name}.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.2
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.
@end group
@end smallexample

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with...Texts.'' line with this:

@smallexample
@group
    with the Invariant Sections being @var{list their titles}, with
    the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
    being @var{list}.
@end group
@end smallexample

If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.

@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

@page
@node Copying,  , GNU Free Documentation License, Administration
@appendixsec GNU GENERAL PUBLIC LICENSE
@center Version 2, June 1991

@c This file is intended to be included in another file.

@display
Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display

@page
@appendixsubsec Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software---to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

@iftex
@appendixsubsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end ifinfo

@enumerate 0
@item
This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The ``Program'', below,
refers to any such program or work, and a ``work based on the Program''
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term ``modification''.)  Each licensee is addressed as ``you''.

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

@item
You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

@item
You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

@enumerate a
@item
You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

@item
You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

@item
If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License.  (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
@end enumerate

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

@item
You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

@enumerate a
@item
Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

@item
Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

@item
Accompany it with the information you received as to the offer
to distribute corresponding source code.  (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
@end enumerate

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

@item
You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

@item
You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

@item
Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

@item
If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

@item
If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

@item
The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and ``any
later version'', you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

@item
If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

@iftex
@strong{NO WARRANTY}
@end iftex
@ifinfo
@center NO WARRANTY
@end ifinfo

@item
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

@item
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
@end enumerate

@iftex
@heading END OF TERMS AND CONDITIONS
@end iftex
@ifinfo
@center END OF TERMS AND CONDITIONS
@end ifinfo

@page
@appendixsubsec Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the ``copyright'' line and a pointer to where the full notice is found.

@smallexample
@var{one line to give the program's name and a brief idea of what it does.}
Copyright (C) @var{yyyy}  @var{name of author}

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@end smallexample

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

@smallexample
Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@end smallexample

The hypothetical commands @samp{show w} and @samp{show c} should show
the appropriate parts of the General Public License.  Of course, the
commands you use may be called something other than @samp{show w} and
@samp{show c}; they could even be mouse-clicks or menu items---whatever
suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a ``copyright disclaimer'' for the program, if
necessary.  Here is a sample; alter the names:

@example
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

@var{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
@end example

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

@node Glossary, Index, Administration, Top
@comment  node-name,  next,  previous,  up
@unnumbered Glossary
@printindex fn

@node Index,  , Glossary, Top
@comment      node-name, next,       previous, up
@unnumbered Index
@printindex cp

@contents

@bye


Deleted mttroot/mtt/doc/mtt_banner.sh version [369093538c].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

Deleted mttroot/mtt/doc/mtt_make_examples version [ac977b6bd2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
## This makes all of the standard examples
## It takes a few hours.
## Copyright (C) 2003 by Peter J. Gawthrop

exampledir="$MTT_EXAMPLES"
dirname=`basename ${exampledir}`

tmpbase="$HOME/JUNK"
tmpdir="${tmpbase}/${dirname}"

first() {
    cat<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>MTT Examples</title>
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#ff0000" bgcolor="#ffff33" link="#000099" vlink="#990099" alink="#ff0000">

<h1 align="center"><font color="#ff0000">MTT Examples</font></h1>
   
<hr width="100%" size="2">
<ul>
EOF
}

entry() {
    cat<<EOF
<li>$1: <a href="./$1_rep/index.html">html, </a><a href="$1_rep.pdf">pdf.</a> 
EOF
}

last() {
    cat<<EOF
</ul>
<hr width="100%" size="2">     
Created on `date` by mtt_make_examples
<hr width="100%" size="2">     
</body>
</html>
EOF
}

## File start
first > index.html

if [ -d "${tmpdir}" ]; then
    echo "${tmpdir} exists -- using"
else
    echo "${tmpdir} does not exist -- copy from ${exampledir}"
    ## Create tmp dir
    mkdir -pv ${tmpdir}
    ## Copy to tmp
    cp -r ${exampledir} ${tmpbase}
fi

## Go to tmp and list DIRS
pushd ${tmpdir}
dirs=`ls | grep -v CVS | grep -v '\.' | grep -v _`

echo Making examples for ${dirs} in ${tmpdir}
for dir in ${dirs}; do
    echo Making examples in $dir
    mtt -q $dir rep pdf
    mtt -q $dir rep html
    entry $dir >> index.html
done

## File end
last>>index.html
popd

Deleted mttroot/mtt/doc/reduce_reserved.tex version [b5fa8cdbe2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\documentclass[12pt,a4paper]{book}
\newcommand{\REDUCE}{REDUCE}
\begin{document}


\appendix
\chapter{Reserved Identifiers}

We list here all identifiers that are normally reserved in \REDUCE{}
including names of commands, operators and switches initially in the system.
Excluded are words that are reserved in specific implementations of the
system.

\vspace{13pt}
\begin{list}{}{\renewcommand{\makelabel}[1]{#1\hspace{\fill}}%
               \settowidth{\labelwidth}{Numerical Operators}%
               \setlength{\labelsep}{1em}%
               \settowidth{\leftmargin}{Numerical Operators\hspace*{\labelsep}}%
               \sloppy}

\item[Commands] {\tt ALGEBRAIC} {\tt ANTISYMMETRIC}
{\tt ARRAY} {\tt BYE} {\tt CLEAR} \linebreak
{\tt CLEARRULES} {\tt COMMENT} {\tt
CONT} {\tt DECOMPOSE} {\tt DEFINE} {\tt DEPEND} {\tt DISPLAY} {\tt ED}
{\tt EDITDEF} {\tt END} {\tt EVEN} {\tt FACTOR} {\tt FOR} {\tt FORALL}
{\tt FOREACH} {\tt GO} {\tt GOTO} {\tt IF} {\tt IN} {\tt INDEX} {\tt INFIX}
{\tt INPUT} {\tt INTEGER} {\tt KORDER} {\tt LET} {\tt LINEAR} {\tt LISP}
{\tt LISTARGP} {\tt LOAD} {\tt LOAD\_PACKAGE} {\tt MASS} {\tt MATCH} {\tt
MATRIX} {\tt MSHELL} {\tt NODEPEND} {\tt NONCOM} {\tt NONZERO} {\tt NOSPUR}
{\tt ODD} {\tt OFF}
{\tt ON} {\tt OPERATOR} {\tt ORDER} {\tt OUT} {\tt PAUSE} {\tt PRECEDENCE}
{\tt PRINT\_PRECISION} {\tt PROCEDURE} {\tt QUIT} {\tt REAL} {\tt REMFAC}
{\tt REMIND} {\tt RETRY} {\tt RETURN} {\tt SAVEAS} {\tt SCALAR} {\tt
SETMOD} {\tt SHARE} {\tt SHOWTIME} {\tt SHUT} {\tt SPUR} {\tt SYMBOLIC}
{\tt SYMMETRIC} {\tt VECDIM} {\tt VECTOR} {\tt WEIGHT} {\tt WRITE} {\tt
WTLEVEL}

\item[Boolean Operators] {\tt EVENP} {\tt FIXP}
{\tt FREEOF} {\tt NUMBERP} {\tt ORDP} {\tt PRIMEP}

\item[Infix Operators]
 \verb|:=| \verb|=| \verb|>=| \verb|>| \verb|<=| \verb|<| \verb|=>|
 \verb|+| \verb|*| \verb|/| \verb|^| \verb|**| \verb|.| {\tt WHERE}
{\tt SETQ} {\tt OR} {\tt AND} {\tt MEMBER} {\tt MEMQ} {\tt
EQUAL} {\tt NEQ} {\tt EQ} {\tt GEQ} {\tt GREATERP} {\tt LEQ} {\tt LESSP}
{\tt PLUS} {\tt DIFFERENCE} {\tt MINUS} {\tt TIMES} {\tt QUOTIENT} {\tt
EXPT} {\tt CONS}

\item[Numerical Operators] {\tt ABS} {\tt ACOS}
{\tt ACOSH} {\tt ACOT} {\tt ACOTH} {\tt ACSC} {\tt ACSCH} {\tt ASEC} {\tt
ASECH} {\tt ASIN} {\tt ASINH} {\tt ATAN} {\tt ATANH} {\tt ATAN2} {\tt COS}
{\tt COSH} {\tt COT} {\tt COTH} {\tt CSC} {\tt CSCH} {\tt EXP} {\tt
FACTORIAL} {\tt FIX} {\tt FLOOR} {\tt HYPOT} {\tt LN} {\tt LOG} {\tt LOGB}
{\tt LOG10} {\tt NEXTPRIME} {\tt ROUND} {\tt SEC} {\tt SECH} {\tt SIN}
{\tt SINH} {\tt SQRT} {\tt TAN} {\tt TANH}

\item[Prefix Operators] {\tt APPEND} {\tt
ARGLENGTH} {\tt CEILING} {\tt COEFF} {\tt COEFFN} {\tt COFACTOR} {\tt
CONJ} {\tt DEG} {\tt DEN} {\tt DET} {\tt DF} {\tt DILOG} {\tt EI}
{\tt EPS} {\tt ERF} {\tt FACTORIZE} {\tt FIRST} {\tt GCD} {\tt G} {\tt
IMPART} {\tt INT} {\tt INTERPOL} {\tt LCM} {\tt LCOF} {\tt LENGTH} {\tt
LHS} {\tt LINELENGTH} {\tt LTERM} {\tt MAINVAR} {\tt MAT} {\tt MATEIGEN}
{\tt MAX} {\tt MIN} {\tt MKID} {\tt NULLSPACE} {\tt NUM} {\tt PART} {\tt
PF} {\tt PRECISION} {\tt RANDOM} {\tt RANDOM\_NEW\_SEED} {\tt RANK} {\tt
REDERR} {\tt REDUCT} {\tt REMAINDER} {\tt REPART} {\tt REST} {\tt
RESULTANT} {\tt REVERSE} {\tt RHS} {\tt SECOND} {\tt SET} {\tt SHOWRULES}
{\tt SIGN} {\tt SOLVE} {\tt STRUCTR} {\tt SUB} {\tt SUM} {\tt THIRD} {\tt
TP} {\tt TRACE} {\tt VARNAME}

\item[Reserved Variables] {\tt CARD\_NO} {\tt E} {\tt EVAL\_MODE}
{\tt FORT\_WIDTH} {\tt HIGH\_POW} {\tt I} {\tt INFINITY} {\tt K!*} {\tt
LOW\_POW} {\tt NIL} {\tt PI} {\tt ROOT\_MULTIPLICITY} {\tt T}

\item[Switches] {\tt ADJPREC} {\tt ALGINT} {\tt ALLBRANCH} {\tt ALLFAC}
{\tt BFSPACE} {\tt COMBINEEXPT} {\tt COMBINELOGS}
{\tt COMP} {\tt COMPLEX} {\tt CRAMER} {\tt CREF} {\tt DEFN} {\tt DEMO}
{\tt DIV} {\tt ECHO} {\tt ERRCONT} {\tt EVALLHSEQP} {\tt EXP} {\tt
EXPANDLOGS} {\tt EZGCD} {\tt FACTOR} {\tt FORT} {\tt FULLROOTS} {\tt GCD}
{\tt IFACTOR} {\tt INT} {\tt INTSTR} {\tt LCM} {\tt LIST} {\tt LISTARGS}
{\tt MCD} {\tt MODULAR} {\tt MSG} {\tt MULTIPLICITIES} {\tt NAT} {\tt
NERO} {\tt NOSPLIT} {\tt OUTPUT} {\tt PERIOD} {\tt PRECISE} {\tt PRET}
{\tt PRI} {\tt RAT} {\tt RATARG} {\tt RATIONAL} {\tt RATIONALIZE} {\tt
RATPRI} {\tt REVPRI} {\tt RLISP88} {\tt ROUNDALL} {\tt ROUNDBF} {\tt
ROUNDED} {\tt SAVESTRUCTR} {\tt SOLVESINGULAR} {\tt TIME} {\tt TRA} {\tt
TRFAC} {\tt TRIGFORM} {\tt TRINT}

\item[Other Reserved Ids] {\tt BEGIN} {\tt DO} {\tt
EXPR} {\tt FEXPR} {\tt INPUT} {\tt LAMBDA} {\tt
LISP} {\tt MACRO} {\tt PRODUCT} {\tt REPEAT} {\tt SMACRO} {\tt
SUM} {\tt UNTIL} {\tt WHEN} {\tt WHILE} {\tt WS}

\end{list}

\end{document}

Deleted mttroot/mtt/lib/cc/mtt_AlgebraicSolver.cc version [021b3b02c0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include "mtt_AlgebraicSolver.hh"

ColumnVector
MTT::AlgebraicSolver::solve (const ColumnVector	&x,
			     const ColumnVector	&u,
			     const double	&t,
			     const ColumnVector	&par)
{
  if (_nyz > 0)
    {
      _x = x;
      _uui.insert(u,0);
      _t = t;
      _par = par;
      Solve();
      _uui.insert(_ui,_nu);
    }
  else
    {
      _uui = u;
    }
  return _uui;
}

ColumnVector
MTT::AlgebraicSolver::eval (const ColumnVector	&ui)
{
  if (_nyz > 0)
    _uui.insert(ui,_nu);
  return mtt_ae(_x,_uui,_t,_par);
}

Deleted mttroot/mtt/lib/cc/mtt_AlgebraicSolver.hh version [83ec09b7aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef MTT_ALGEBRAICSOLVER
#define MTT_ALGEBRAICSOLVER


#include "mtt_Solver.hh"


namespace MTT
{
  class AlgebraicSolver : public MTT::Solver
  {
  public:

    AlgebraicSolver (const int npar,
		     const int nu,
		     const int nx,
		     const int ny,
		     const int nyz)
      : MTT::Solver (npar,nu,nx,ny,nyz)
    {;}

    ColumnVector
    solve (const ColumnVector	&x,
	   const ColumnVector	&u,
	   const double		&t,
	   const ColumnVector	&par);

    ColumnVector
    eval (const ColumnVector	&ui);

    virtual ~AlgebraicSolver (void) {};

  protected:

    virtual void
    Solve (void) = 0;
  };
}


extern ColumnVector
mtt_ae(const ColumnVector	&x,
       const ColumnVector	&u,
       const double		&t,
       const ColumnVector	&par);


#endif // MTT_ALGEBRAICSOLVER

Deleted mttroot/mtt/lib/cc/mtt_Dassl_Solver.cc version [d98f27dba0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include "mtt_Dassl_Solver.hh"


// used by "-ae dassl" NOT "-i dassl"


MTT::Dassl_Solver *MTT::Dassl_Solver::static_ptr;

ColumnVector
MTT::Dassl_Solver::f_dassl (const ColumnVector &tryUi,
			    const ColumnVector &tryUidot,
			    double t, int &ires)
{
  static MTT::Dassl_Solver *p = MTT::Dassl_Solver::static_ptr;

  ColumnVector residual = p->eval(tryUi);
  ColumnVector uidoterr = (tryUi - p->_ui) - tryUidot;  
  p->_yz = residual + uidoterr;
  return p->_yz;
}

void
MTT::Dassl_Solver::Solve (void)
{
  const double t0 = 0.0;
  const double t1 = 1.0;
  DAEFunc fcn(&MTT::Dassl_Solver::f_dassl);
  DASSL   eqn(AlgebraicSolver::_ui,t0,fcn);
  AlgebraicSolver::_ui = eqn.do_integrate (t1);
}

Deleted mttroot/mtt/lib/cc/mtt_Dassl_Solver.hh version [29e194ac39].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


#ifndef MTT_DASSLSOLVER
#define MTT_DASSLSOLVER


#include "mtt_AlgebraicSolver.hh"
#include <octave/DASSL.h>


#ifdef  OCTAVE_DEV
#include <octave/parse.h>
#define VECTOR_VALUE column_vector_value
#else   // !OCTAVE_DEV
#include <octave/toplev.h>
#define VECTOR_VALUE vector_value
#endif  // OCTAVE_DEV


// -ae dassl


namespace MTT
{
  class Dassl_Solver : public MTT::AlgebraicSolver {
    
    // used only when called because of "-ae dassl"
    // this is not used when called by "-i dassl"
    
  public:
    
    Dassl_Solver (const int npar,
		  const int nu,
		  const int nx,
		  const int ny,
		  const int nyz)
      : MTT::AlgebraicSolver (npar, nu, nx, ny, nyz)
    {
      static_ptr = this;
    }
    
    static ColumnVector
    f_dassl (const ColumnVector &tryUi,
	     const ColumnVector &tryUidot,
	     double t, int &ires);
    
    ~Dassl_Solver (void) {};
    
  protected:
    
    void
    Solve (void);
    
  public:
    
    static Dassl_Solver *static_ptr;
    
  };
}


#endif // MTT_DASSLSOLVER

Deleted mttroot/mtt/lib/cc/mtt_HJ_Solver.hh version [c5aaf93148].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef MTT_HJSOLVER
#define MTT_HJSOLVER


#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class HJ_Solver : public MTT::AlgebraicSolver
  {
    // http://www.netlib.org/opt/hooke.c
    // Hooke and Jeeves solution

  public:
  
    HJ_Solver (const int npar,
	       const int nu,
	       const int nx,
	       const int ny,
	       const int nyz)
      : MTT::AlgebraicSolver (npar,nu,nx,ny,nyz)
    {
      static_ptr = this;
      VARS = nyz;
    }
  
    static double
    f (double tryUi[], int nyz);
  
    ~HJ_Solver (void) {};

  protected:

    void
    Solve (void);

    double
    best_nearby (double    	delta[],
		 double   	point[],
		 double   	prevbest,
		 int      	nvars);
  
    int
    hooke (int		nvars,			  // MTTNYZ
	   double	startpt[],		  // user's initial guess
	   double	endpt[],		  // result
	   double	rho		= 0.05,	  // geometric shrink factor
	   double	epsilon		= 1e-3,	  // end value stepsize
	   int		itermax		= 5000);  // max # iterations 

  private:

    int VARS;
    
  public:

    static HJ_Solver *static_ptr;
    
  };
}


#endif // MTT_HJSOLVER

Deleted mttroot/mtt/lib/cc/mtt_Hybrd_Solver.cc version [0e7392017c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include "mtt_Hybrd_Solver.hh"

// http://www.netlib.org/minpack/hybrd.f
// used by Octave's fsolve

MTT::Hybrd_Solver *MTT::Hybrd_Solver::static_ptr;

ColumnVector
MTT::Hybrd_Solver::f_hybrd (const ColumnVector &tryUi)
{
  MTT::Hybrd_Solver::static_ptr->_yz = MTT::Hybrd_Solver::static_ptr->eval(tryUi);
  return MTT::Hybrd_Solver::static_ptr->_yz;
}

void
MTT::Hybrd_Solver::Solve (void)
{    
  static std::fstream ferr ("MTT.Hybrd_messages", std::ios::out | std::ios::trunc | std::ios::app);
  int info;
  static int input_errors;
  static int user_errors;
  static int convergences;
  static int progress_errors;
  static int limit_errors;
  static int unknown_errors;
  
  NLFunc fcn(&Hybrd_Solver::f_hybrd);
  NLEqn	 eqn(Solver::_ui,fcn);
  //  eqn.set_tolerance(1.0e-20);
  Solver::_ui = eqn.solve(info);

  switch (info)
    {
    case 1:
      convergences++;
      break;
    case -2:
      input_errors++;
      break;
    case -1:
      user_errors++;
      break;
    case 3:
      progress_errors++;
      break;
    case 4:
      limit_errors++;
      break;
    default:
      unknown_errors++;
      break;
    }
  std::clog.setf (std::ios::scientific);
  if (1 != info)
    {
      std::clog
	<< "\r"
	<< " time " << _t << " \t"
	<< " converge (" << convergences << ") "
	<< " limit (" << limit_errors << ")"
	<< " progress (" << progress_errors << ")"
	<< " other (" << input_errors + user_errors + unknown_errors << ") "
	<< " (max error = " << std::abs (eval(_ui).max()) << ")"
	<< std::endl;
    }
  else
    {
      std::clog
	<< "\r time " << _t << "\t max error = " << std::abs (eval(_ui).max());
    }
  ferr << info << " ";
}

Deleted mttroot/mtt/lib/cc/mtt_Hybrd_Solver.hh version [7dad372c91].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef MTT_HYBRDSOLVER
#define MTT_HYBRDSOLVER

#include <fstream>

#include <octave/NLEqn.h>
#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class Hybrd_Solver : public MTT::AlgebraicSolver
  {
    // http://www.netlib.org/minpack/hybrd.f
    // used by Octave's fsolve
    
  public:

    Hybrd_Solver (const int npar,
		  const int nu,
		  const int nx,
		  const int ny,
		  const int nyz)
      : MTT::AlgebraicSolver (npar,nu,nx,ny,nyz)
    {
      static_ptr = this;
    }

    static ColumnVector
    f_hybrd (const ColumnVector &tryUi);

    ~Hybrd_Solver (void) {};

  protected:

    void
    Solve (void);
    
  public:
    
    static Hybrd_Solver *static_ptr;
  };
}


#endif // MTT_HYBRDSOLVER

Deleted mttroot/mtt/lib/cc/mtt_Reduce_Solver.cc version [b7f38e13b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include "mtt_Reduce_Solver.hh"

void
MTT::Reduce_Solver::Solve (void)
{
  ;
}

ColumnVector
MTT::Reduce_Solver::solve (const ColumnVector	&x,
			   const ColumnVector	&u,
			   const double		&t,
			   const ColumnVector	&par)
{
  return u;
}

Deleted mttroot/mtt/lib/cc/mtt_Reduce_Solver.hh version [635ef51478].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef MTT_REDUCESOLVER
#define MTT_REDUCESOLVER


#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class Reduce_Solver : public MTT::AlgebraicSolver
  {
    // Dummy class
    // This will not be used unless the Reduce solver has failed earlier
    // in the model build process

  public:
    
    Reduce_Solver (const int npar,
		   const int nu,
		   const int nx,
		   const int ny,
		   const int nyz)
      : AlgebraicSolver (npar,nu,nx,ny,nyz)
    {;}
	
    void
    Solve (void);
    
    ColumnVector
    solve (const ColumnVector	&x,
	   const ColumnVector	&u,
	   const double		&t,
	   const ColumnVector	&par);
    
    ~Reduce_Solver (void) {};
  };
}


#endif // MTT_REDUCESOLVER 

Deleted mttroot/mtt/lib/cc/mtt_Solver.cc version [bc6c28056d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include "mtt_Solver.hh"

MTT::Solver::Solver (const int npar,
		     const int nu,
		     const int nx,
		     const int ny,
		     const int nyz)
{
  _np  = npar; 
  _nu  = nu;
  _nx  = nx;
  _ny  = ny;
  _nyz = nyz;
  _ui  = ColumnVector (_nyz,0.0);
  _uui = ColumnVector (_nu+_nyz);
};

Deleted mttroot/mtt/lib/cc/mtt_Solver.hh version [2a39ed71ca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef MTT_SOLVER
#define MTT_SOLVER


#include <cmath>
#include <cstdlib>
#include <iostream>

#include <octave/oct.h>


namespace MTT
{
  class Solver
  {
  public:

    Solver (const int npar,
	    const int nu,
	    const int nx,
	    const int ny,
	    const int nyz);

    virtual ~Solver (void) {};
  
  protected:
    
    ColumnVector       		_x;
    ColumnVector	       	_uui;
    double			_t;
    ColumnVector	       	_par;
    
    ColumnVector  		_ui;
    ColumnVector          	_yz;
    
    int   			_nu;
    int				_np;
    int				_nx;
    int				_ny;
    int				_nyz;
  };
}

  
#endif // MTT_SOLVER

Deleted mttroot/mtt/lib/cc/mtt_dassl.cc version [f033fc99ba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include <octave/oct.h>
#include <octave/DASSL.h>


#ifdef  OCTAVE_DEV
#include <octave/parse.h>
#define VECTOR_VALUE column_vector_value
#else   // !OCTAVE_DEV
#include <octave/toplev.h>
#define VECTOR_VALUE vector_value
#endif  // OCTAVE_DEV

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
extern ColumnVector
Fmtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires);
#endif // (CODEGENTARGET == STANDALONE)


ColumnVector
mtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires)
{
#if (CODEGENTARGET == STANDALONE)
  return Fmtt_residual (X, DX, t, ires);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args(0) = octave_value (X);
  args(1) = octave_value (DX);
  args(2) = octave_value (t);
  args(3) = octave_value (static_cast<double>(ires));
  f = feval ("mtt_residual", args, 1);
  return f(0).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)
}


#if (CODEGENTARGET == STANDALONE)
ColumnVector
Fmtt_dassl (	  ColumnVector	&x,
	    const ColumnVector	&u,
	    const double	&t,
	    const ColumnVector	&par,
	    const ColumnVector	&dx,
	    const double	&ddt,
	    const int		Nx,
	    const int		Nyz,
	    const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_dassl, args, ,
	   "dassl integration method")
{
  ColumnVector		x	= args(0).VECTOR_VALUE();
  const ColumnVector   	u	= args(1).VECTOR_VALUE();
  const double		t	= args(2).double_value();
  const ColumnVector	par	= args(3).VECTOR_VALUE();
  const ColumnVector	dx	= args(4).VECTOR_VALUE();
  const double		ddt	= args(5).double_value();
  const int		Nx	= static_cast<int> (args(6).double_value());
  const int		Nyz	= static_cast<int> (args(7).double_value());
  const ColumnVector	openx	= args(8).VECTOR_VALUE();
#endif // (CODEGENTARGET == STANDALONE)

  static DAEFunc fdae(mtt_residual);
  static ColumnVector XX (Nx+Nyz);
  XX.insert (x,0);

  for (register int i = Nx; i < Nx+Nyz; i++)
    XX(i) = 0.0;

  double tout = t + ddt;

  DASSL fdassl (XX, t, fdae);
  x = fdassl.do_integrate (tout).extract (0,Nx-1);

  for (register int i = 0; i < Nx; i++)
    if (openx (i) > 0.5)
      x (i) = 0.0;
      

#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Deleted mttroot/mtt/lib/cc/mtt_euler.cc version [94aa4f3270].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#include <octave/oct.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
ColumnVector Fmtt_euler (      ColumnVector	&x,
			 const ColumnVector	&dx,
			 const double		&ddt,
			 const int		&Nx,
			 const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_euler, args, ,
	   "euler integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  const ColumnVector	dx	= args(1).VECTOR_VALUE ();
  const double		ddt	= args(2).double_value ();
  const int		Nx	= static_cast<int> (args(3).double_value ());
  const ColumnVector   	openx	= args(4).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)

  register int i, n;
  
  n = Nx;
  for (i = 0; i < Nx; i++)
    {
      if (0 != openx (i))
	{
	  x (i) = 0.0;
	}
      else
	{
	  x (i) += dx (i) * ddt;
	}
    }
#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Deleted mttroot/mtt/lib/cc/mtt_implicit.cc version [c10762dcf4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#include <octave/oct.h>
#include <octave/xdiv.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#if (CODEGENTARGET == STANDALONE)
ColumnVector Fmtt_implicit (      ColumnVector	&x,
				  ColumnVector	&dx,
			          Matrix	&AA,
				  ColumnVector	&AAx,
			    const double	&t,
			    const int		&Nx,
			    const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_implicit, args, ,
	   "implicit integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  ColumnVector		dx	= args(1).VECTOR_VALUE ();
  Matrix		AA	= args(2).matrix_value ();
  ColumnVector		AAx	= args(3).VECTOR_VALUE ();
  const  double		t	= args(4).double_value ();
  const  int		Nx	= (int) (args(5).double_value ());
  const  ColumnVector	openx	= args(6).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)

  register int row, col;

  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{
	  AAx (row) = 0.0;
          dx (row) = 0.0;
	  for (col = 0; col < Nx; col++)
	    {
	      AA (row,col) = 0.0;
	      AA (col,row) = 0.0;
	    }
	}
    }

#ifdef OCTAVE_DEV
  x = xleftdiv (AA, Matrix(AAx + dx * t)).column (0);
#else // !OCTAVE_DEV
  Matrix tmp = xleftdiv (AA, static_cast<Matrix>(static_cast<ColumnVector>(AAx + dx * t)));
  for (row = 0; row < Nx; row++)
    {
      x (row) = tmp (row,0);
    }
#endif // OCTAVE_DEV
  
  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{
	  x (row) = 0.0;
	}
    }

#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Deleted mttroot/mtt/lib/cc/mtt_kpathsea.cc version [0b0240614b].

1
2
3
4




-
-
-
-

extern "C" {
  int kpse_clear_dir_cache (void) {return 0;}
}

Deleted mttroot/mtt/lib/cc/mtt_matlab_octave.cc version [b74de52abf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include <octave/oct.h>
#include <mex.h>


// conversions from Matlab mxArray* to Octave data types

Matrix
mtt_Matrix (const mxArray *m)
{
  const unsigned long int nrows = mxGetM (m);
  const unsigned long int ncols = mxGetN (m);
  Matrix o (nrows, ncols);
  const double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    for (unsigned long int col = 0; col < ncols; col++)
      o (row, col) = p[row + nrows*col];
  return (o);
}

ColumnVector
mtt_ColumnVector (const mxArray *m)
{
  const unsigned long int nrows = mxGetM (m);
  ColumnVector o (nrows);
  const double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    o (row) = p[row];
  return (o);
}

const double
mtt_double (const mxArray *m)
{
  const double *p = mxGetPr (m);
  return (*p);
}


// conversions from Octave data types to Matlab mxArray*

mxArray *
mtt_mxArray (const Matrix &o)
{
  const unsigned long int nrows = o.rows ();
  const unsigned long int ncols = o.columns ();
  mxArray *m;
  m = mxCreateDoubleMatrix (nrows, ncols, mxREAL);
  double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    for (unsigned long int col = 0; col < ncols; col++)
      p [row + nrows*col] = o (row, col);
  return (m);
}

mxArray *
mtt_mxArray (const ColumnVector &o)
{
  const unsigned long int nrows = o.length ();
  mxArray *m;
  m = mxCreateDoubleMatrix (nrows, 1, mxREAL);
  double *p = mxGetPr (m);
  for (unsigned long int row = 0; row < nrows; row++)
    p [row] = o (row);
  return (m);
}

Deleted mttroot/mtt/lib/cc/mtt_matlab_octave.hh version [7d4f1bcd2c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef MTT_MATLAB_OCTAVE_HH
#define MTT_MATLAB_OCTAVE_HH

#include <octave/oct.h>
#include <mex.h>

// conversions from Matlab mxArray* to Octave data types

extern Matrix
mtt_Matrix (const mxArray *m);

extern ColumnVector
mtt_ColumnVector (const mxArray *m);

extern const double
mtt_double (const mxArray *m);


// conversions from Octave data types to Matlab mxArray*

extern mxArray *
mtt_mxArray (const Matrix &o);

extern mxArray *
mtt_mxArray (const ColumnVector &o);

#endif // MTT_MATLAB_OCTAVE_HH

Deleted mttroot/mtt/lib/cc/mtt_noAlgebraicSolver.cc version [7c4f7ecef3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include "mtt_noAlgebraicSolver.hh"

void
MTT::noAlgebraicSolver::Solve (void)
{
  ;
}

ColumnVector
MTT::noAlgebraicSolver::solve (const ColumnVector	&x,
			       const ColumnVector	&u,
			       const double		&t,
			       const ColumnVector	&par)
{
  return u;
}

Deleted mttroot/mtt/lib/cc/mtt_noAlgebraicSolver.hh version [1076338af6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef MTT_REDUCESOLVER
#define MTT_REDUCESOLVER


#include "mtt_AlgebraicSolver.hh"


namespace MTT
{
  class noAlgebraicSolver : public MTT::AlgebraicSolver
  {
    // Dummy class

  public:
    
    noAlgebraicSolver (const int npar,
		   const int nu,
		   const int nx,
		   const int ny,
		   const int nyz)
      : AlgebraicSolver (npar,nu,nx,ny,nyz)
    {;}
	
    void
    Solve (void);
    
    ColumnVector
    solve (const ColumnVector	&x,
	   const ColumnVector	&u,
	   const double		&t,
	   const ColumnVector	&par);
    
    ~noAlgebraicSolver (void) {};
  };
}


#endif // MTT_REDUCESOLVER 

Deleted mttroot/mtt/lib/cc/mtt_simpar.hh version [867584b9ac].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#include <octave/oct.h>
#include <octave/oct-map.h>

static ColumnVector
mtt_simpar (Octave_map simpar)
{
  static ColumnVector retval (8);

  retval (0) = simpar.contents (simpar.seek ("first"     ))(0).double_value ();
  retval (1) = simpar.contents (simpar.seek ("last"      ))(0).double_value ();
  retval (2) = simpar.contents (simpar.seek ("dt"        ))(0).double_value ();
  retval (3) = simpar.contents (simpar.seek ("stepfactor"))(0).double_value ();
  retval (4) = simpar.contents (simpar.seek ("wmin"      ))(0).double_value ();
  retval (5) = simpar.contents (simpar.seek ("wmax"      ))(0).double_value ();
  retval (6) = simpar.contents (simpar.seek ("wsteps"    ))(0).double_value ();
  retval (7) = simpar.contents (simpar.seek ("input"     ))(0).double_value ();

  return retval;
}

static Octave_map
mtt_simpar (ColumnVector simpar)
{
  static Octave_map retval;

  retval.assign ("first"     , simpar (0));
  retval.assign ("last"      , simpar (1));
  retval.assign ("dt"        , simpar (2));
  retval.assign ("stepfactor", simpar (3));
  retval.assign ("wmin"      , simpar (4));
  retval.assign ("wmax"      , simpar (5));
  retval.assign ("wsteps"    , simpar (6));
  retval.assign ("input"     , simpar (7));

  return retval;
}

Deleted mttroot/mtt/lib/comp/compound/Bicausal/B2U/B2U_abg.fig version [309cefa6d9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 6525 2700 6525 2475 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 6300 2925 4950 3150 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 6525 4500 6525 4275 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 6300 4725 4950 4950 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 6525 6300 6525 6075 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 4500 2925 3150 3150 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 4500 4725 3150 4950 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1350 6525 1350 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 6300 2700 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 6525 3150 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 6300 4500 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4950 6525 4950 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 6300 6300 6525
4 2 4 100 0 18 18 0.0000 4 270 930 1260 6615 SS:[ef]\001
4 1 0 100 0 18 18 0.0000 4 195 150 2925 6615 0\001
4 1 0 100 0 18 18 0.0000 4 210 405 2925 4815 AE\001
4 1 0 100 0 18 18 0.0000 4 195 150 4725 6615 1\001
4 1 0 100 0 18 18 0.0000 4 210 390 4725 4815 AF\001
4 1 0 100 0 18 18 0.0000 4 210 630 6795 6615 SS:ii\001
4 1 4 100 0 18 18 0.0000 4 270 825 2925 3015 SS:[e]\001
4 1 4 100 0 18 18 0.0000 4 270 765 4680 3015 SS:[f]\001

Deleted mttroot/mtt/lib/comp/compound/Bicausal/B2U/B2U_lbl.txt version [33dba58bdb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY B2U: undoes a bicausal bond
#DESCRIPTION Takes e and f from bicausal bond at port [ef] 
#DESCRIPTION and gives corresponding unicausal bonds at ports [e] and [f]

## System B2U, representation lbl, language txt
## File B2U_lbl.txt
## Generated by MTT on Thu Jul  8 09:59:03 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	e	e
#ALIAS	ef	ef
#ALIAS	f	f

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type AE (anonymous => default parameters)
	# AE							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type SS
	[e]	SS		external,0
	[f]	SS		0,external		
	ii	SS		internal,internal		
	[ef]	SS		external,0

Deleted mttroot/mtt/lib/comp/compound/Bicausal/U2B/U2B_abg.fig version [753962dbb3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 1350 6975 1350 6750 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 2925 5400 1575 5625 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 3150 5175 3150 4950 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 1350 3150 1350 2925 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 1350 5175 1350 4950 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 4725 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 4725 5625 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 3375 5400 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 1575 5400 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2925 5625 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2925 3825 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 1125 5175 1575
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8550 5175 675 5175 675 675 8550 675 8550 5175
4 1 0 100 0 18 18 0.0000 4 210 390 3465 3240 AF\001
4 1 0 100 0 18 18 0.0000 4 195 150 5400 3240 0\001
4 2 4 100 0 18 18 0.0000 4 270 765 1710 3240 SS:[f]\001
4 1 0 100 0 18 18 0.0000 4 210 405 3465 1440 AE\001
4 1 0 100 0 18 18 0.0000 4 195 150 5400 1440 1\001
4 2 4 100 0 18 18 0.0000 4 270 825 1710 1440 SS:[e]\001
4 1 0 100 0 18 18 0.0000 4 210 780 5400 5085 SS:zz\001
4 0 4 100 0 18 18 0.0000 4 270 1095 7110 1440 SS:[ef]\001
4 1 1 101 0 3 20 0.0000 4 165 150 4500 1125 e\001
4 1 1 101 0 3 20 0.0000 4 165 150 6300 1125 e\001
4 1 1 101 0 3 20 0.0000 4 165 150 2475 1125 e\001
4 1 1 101 0 3 20 0.0000 4 315 105 2475 3510 f\001
4 1 1 101 0 3 20 0.0000 4 315 105 4500 3510 f\001
4 1 1 101 0 3 20 0.0000 4 315 105 6300 1710 f\001
4 1 1 101 0 3 20 0.0000 4 315 105 5625 2385 f\001
4 1 1 101 0 3 20 0.0000 4 225 165 2520 1665 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 2520 3015 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 5220 4140 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 5625 4140 0\001
4 1 1 101 0 3 20 0.0000 4 225 165 5220 2385 0\001

Deleted mttroot/mtt/lib/comp/compound/Bicausal/U2B/U2B_lbl.txt version [aa18514868].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY U2B: makes a bicausal bond
#DESCRIPTION Takes e and f from  ports [e] and [f] and gives corresponding
#DESCRIPTION bicausal bond at port [ef].

## System U2B, representation lbl, language txt
## File U2B_lbl.txt
## Generated by MTT on Thu Jul  8 08:38:15 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	e	e
#ALIAS	f	f
#ALIAS	out	ef

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[e]	SS		external,internal		
	[f]	SS		internal,external		
	[ef]	SS		internal,external		
	zz	SS		0,0

Deleted mttroot/mtt/lib/comp/compound/Bicausal/VJe/VJe_abg.fig version [3b654ab692].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3735 675 4455 990
4 1 1 101 0 3 20 0.0000 4 105 195 4095 855 =\001
4 1 1 101 0 3 20 0.0000 4 165 150 3847 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 3937 990 c\001
4 1 1 101 0 3 20 0.0000 4 165 150 4282 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 4372 990 s\001
-6
6 3915 1170 4185 1575
4 1 1 101 0 3 20 0.0000 4 315 105 3982 1440 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 4072 1575 c\001
-6
6 5940 1170 6210 1575
4 1 1 101 0 3 20 0.0000 4 315 105 6007 1440 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 6097 1575 c\001
-6
6 5715 2520 5985 2835
4 1 1 101 0 3 20 0.0000 4 165 150 5812 2700 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 5902 2835 s\001
-6
6 4590 1890 4860 2205
4 1 1 101 0 3 20 0.0000 4 165 150 4687 2070 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 4777 2205 s\001
-6
6 7110 3510 7380 3915
4 1 1 101 0 3 20 0.0000 4 315 105 7177 3780 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 7267 3915 c\001
-6
6 6075 3555 6795 3870
4 1 1 101 0 3 20 0.0000 4 105 195 6435 3735 =\001
4 1 1 101 0 3 20 0.0000 4 165 150 6187 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 6277 3870 c\001
4 1 1 101 0 3 20 0.0000 4 165 150 6622 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 6712 3870 s\001
-6
6 5715 4320 5985 4635
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4500 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 5902 4635 e\001
-6
6 5715 4815 5985 5220
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4995 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 5902 5130 f\001
-6
6 3240 4095 3510 4410
4 1 1 101 0 3 20 0.0000 4 180 180 3337 4275 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 3427 4410 e\001
-6
6 3240 4995 3510 5400
4 1 1 101 0 3 20 0.0000 4 180 180 3337 5175 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 3427 5310 f\001
-6
6 1755 2520 2025 2835
4 1 1 101 0 3 20 0.0000 4 165 150 1852 2700 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 1942 2835 s\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 4725 2925 4500 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5220 2925 6570 2925 6345 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 5175 1125 6975 1125 6975 2700 7200 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 2925 4500 3150 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4950 2925 4950 3150 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 2700 4725 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 4725 1125 4500 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1305 2925 2655 2925 2430 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 6975 4500 7200 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 4725 5175 4725 5400 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 4950 675 4950 900 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 7425 5625 -675 5625 -675 450 7425 450 7425 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 4500 675 4500 900 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 4950 1350 5175 1575
4 1 0 100 0 18 18 0.0000 4 195 150 4950 3015 0\001
4 1 0 100 0 18 18 0.0000 4 195 150 4950 1215 1\001
4 2 4 100 0 18 18 0.0000 4 270 1065 3285 1215 SS:[PC]\001
4 1 0 100 0 18 18 0.0000 4 210 570 6975 3015 U2B\001
4 1 0 100 0 18 18 0.0000 4 210 570 4725 4815 B2U\001
4 1 4 100 0 18 14 0.0000 4 225 285 6345 2790 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 225 6795 2520 [f]\001
4 1 4 100 0 18 14 0.0000 4 240 360 6750 3375 [ef]\001
4 1 4 100 0 18 14 0.0000 4 225 285 4050 4365 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 225 4050 5265 [f]\001
4 1 4 100 0 18 14 0.0000 4 240 360 5220 4545 [ef]\001
4 1 1 101 0 3 20 0.0000 4 225 165 6075 990 0\001
4 1 0 100 0 18 18 0.0000 4 195 540 6885 4815 tra:t\001
4 2 4 100 0 18 14 0.0000 4 225 360 6480 4995 [in]\001
4 2 4 100 0 18 14 0.0000 4 225 525 6840 4410 [out]\001
4 1 0 100 0 18 18 0.0000 4 210 750 2970 3015 AE:m\001
4 2 4 100 0 18 18 0.0000 4 270 900 1215 3015 SS:[in]\001
4 2 4 100 0 18 18 0.0000 4 270 1080 585 5085 SS:[u_f]\001
4 2 4 100 0 18 18 0.0000 4 270 1140 585 4590 SS:[u_e]\001
4 1 0 100 0 18 18 0.0000 4 210 660 2430 4590 AE:e\001
4 1 0 100 0 18 18 0.0000 4 210 585 2430 5040 AF:f\001

Deleted mttroot/mtt/lib/comp/compound/Bicausal/VJe/VJe_lbl.txt version [892d29c787].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY VJe  Virtual Junction - effort input
#DESCRIPTION Virtual junction with effort input
#DESCRIPTION User must supply the transfer system tra
#DESCRIPTION tra can have up to 9 parameters passed to it
#DESCRIPTION using parameters of VJe

## System VJe, representation lbl, language txt
## File VJe_lbl.txt
## Generated by MTT on Thu Jul  8 11:41:51 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases

## Argument aliases
#ALIAS	$1	p_1
#ALIAS	$2	p_2
#ALIAS	$3	p_3
#ALIAS	$4	p_4
#ALIAS	$5	p_5
#ALIAS	$6	p_6
#ALIAS	$7	p_7
#ALIAS	$8	p_8
#ALIAS	$9	p_9


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type AE/AF
        e       lin             -1
        f       lin             -1
        m       lin             -1

## Component type tra
	t	lin		p_1;p_2;p_3;p_4;p_5;p_6;p_7;p_8;p_9

## Component type SS
	[in]	SS		external,internal
	[u_e]	SS		external,0
	[u_f]	SS		0,external		
	[PC]	SS		external,external		



Deleted mttroot/mtt/lib/comp/compound/Bicausal/VJf/VJf_abg.fig version [6d4a8e35f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 7110 3510 7380 3915
4 1 1 101 0 3 20 0.0000 4 315 105 7177 3780 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 7267 3915 c\001
-6
6 6075 3555 6795 3870
4 1 1 101 0 3 20 0.0000 4 105 195 6435 3735 =\001
4 1 1 101 0 3 20 0.0000 4 165 150 6187 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 6277 3870 c\001
4 1 1 101 0 3 20 0.0000 4 165 150 6622 3735 e\001
4 1 1 101 0 3 20 0.0000 4 150 135 6712 3870 s\001
-6
6 5715 4320 5985 4635
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4500 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 5902 4635 e\001
-6
6 5715 4815 5985 5220
4 1 1 101 0 3 20 0.0000 4 180 180 5812 4995 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 5902 5130 f\001
-6
6 3240 4095 3510 4410
4 1 1 101 0 3 20 0.0000 4 180 180 3337 4275 u\001
4 1 1 101 0 3 20 0.0000 4 165 150 3427 4410 e\001
-6
6 3240 4995 3510 5400
4 1 1 101 0 3 20 0.0000 4 180 180 3337 5175 u\001
4 1 1 101 0 3 20 0.0000 4 315 105 3427 5310 f\001
-6
6 2160 3015 2385 3420
4 1 1 101 0 3 20 0.0000 4 315 105 2212 3285 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 2302 3420 s\001
-6
6 5715 3015 5940 3420
4 1 1 101 0 3 20 0.0000 4 315 105 5767 3285 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 5857 3420 s\001
-6
6 5085 1845 5310 2250
4 1 1 101 0 3 20 0.0000 4 315 105 5137 2115 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 5227 2250 s\001
-6
6 5940 675 6255 990
4 1 1 101 0 3 20 0.0000 4 165 150 6052 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 6142 990 c\001
-6
6 3645 1305 4320 1710
4 1 1 101 0 3 20 0.0000 4 105 195 3960 1575 =\001
4 1 1 101 0 3 20 0.0000 4 315 105 3712 1575 f\001
4 1 1 101 0 3 20 0.0000 4 150 150 3802 1710 c\001
4 1 1 101 0 3 20 0.0000 4 315 105 4147 1575 f\001
4 1 1 101 0 3 20 0.0000 4 150 135 4237 1710 s\001
-6
6 3825 675 4140 990
4 1 1 101 0 3 20 0.0000 4 165 150 3937 855 e\001
4 1 1 101 0 3 20 0.0000 4 150 150 4027 990 c\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 4725 2925 4500 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 4950 1350 5175 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2925 2925 2925 2700 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5220 2925 6570 2925 6345 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 5175 1125 6975 1125 6975 2700 7200 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 6975 4500 7200 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 4725 5175 4725 5400 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 2925 4500 3150 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4950 2925 4950 3150 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 7425 5625 450 5625 450 450 7425 450 7425 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 4725 1125 4500 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2700 3375 3150
4 1 0 100 0 18 18 0.0000 4 195 150 4950 1215 0\001
4 1 0 100 0 18 18 0.0000 4 210 390 3150 3015 AF\001
4 2 4 100 0 18 18 0.0000 4 270 900 1530 3015 SS:[in]\001
4 2 4 100 0 18 18 0.0000 4 270 1065 3285 1215 SS:[PC]\001
4 1 0 100 0 18 18 0.0000 4 210 570 6975 3015 U2B\001
4 1 0 100 0 18 18 0.0000 4 210 615 6975 4815 tra:t\001
4 2 4 100 0 18 18 0.0000 4 270 1140 2790 4545 SS:[u_e]\001
4 2 4 100 0 18 18 0.0000 4 270 1080 2790 5040 SS:[u_f]\001
4 1 0 100 0 18 18 0.0000 4 210 570 4725 4815 B2U\001
4 1 4 100 0 18 14 0.0000 4 240 225 6345 2790 [f]\001
4 1 4 100 0 18 14 0.0000 4 225 285 6795 2520 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 360 6750 3375 [ef]\001
4 1 4 100 0 18 14 0.0000 4 225 360 6300 4995 [in]\001
4 1 4 100 0 18 14 0.0000 4 225 285 4050 4365 [e]\001
4 1 4 100 0 18 14 0.0000 4 240 225 4050 5265 [f]\001
4 1 4 100 0 18 14 0.0000 4 240 360 5220 4545 [ef]\001
4 1 4 100 0 18 14 0.0000 4 225 525 6660 4365 [out]\001
4 1 0 100 0 18 18 0.0000 4 195 150 4950 3015 1\001
4 1 1 101 0 3 20 0.0000 4 225 165 6075 1530 0\001

Deleted mttroot/mtt/lib/comp/compound/Bicausal/VJf/VJf_lbl.txt version [d2153fa80a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY VJf  Virtual Junction - flow input
#DESCRIPTION Virtual junction with flow input
#DESCRIPTION User must supply the transfer system tra
#DESCRIPTION tra can have up to 9 parameters passed to it
#DESCRIPTION using parameters of VJf


## System VJf, representation lbl, language txt
## File VJf_lbl.txt
## Generated by MTT on Thu Jul  8 11:41:51 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	PC	PC
#ALIAS	in	in
#ALIAS	u_e	u_e
#ALIAS	u_f	u_f

## Argument aliases
#ALIAS	$1	p_1
#ALIAS	$2	p_2
#ALIAS	$3	p_3
#ALIAS	$4	p_4
#ALIAS	$5	p_5
#ALIAS	$6	p_6
#ALIAS	$7	p_7
#ALIAS	$8	p_8
#ALIAS	$9	p_9

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type tra
	t	lin		p_1;p_2;p_3;p_4;p_5;p_6;p_7;p_8;p_9

## Component type SS
	[in]	SS		internal,external
	[u_e]	SS		external,0
	[u_f]	SS		0,external		
	[PC]	SS		external,external		



Deleted mttroot/mtt/lib/comp/compound/Chemical/Cm/Cm_abg.fig version [a1eee8edbf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 4500 5625 4725 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 5175 4500 4500 4725 4725
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 6300 4725 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 7425 4500 6750 4725 6975
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 7425 4725 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 4050 4500 3375 4725 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 4275 5400 4275 5175 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 4275 6525 4275 6300 4500
4 1 0 100 0 18 18 0.0000 4 210 390 4500 5490 AF\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 4365 0\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 6615 1\001
4 1 4 100 0 18 18 0.0000 4 270 900 4500 7875 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 210 510 4500 3285 C:C\001
4 1 0 100 0 18 18 0.0000 4 210 405 5625 4365 AE\001
4 0 4 100 0 18 18 0.0000 4 270 1095 6750 4365 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/Chemical/Cm/Cm_lbl.txt version [3af097c4c8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Cm Integrates [in] flow to give [out] effort
 
#DESCRIPTION Zero effort imposed in [in]. Use with mC

## System Cm, representation lbl, language txt
## File Cm_lbl.txt
## Generated by MTT on Tue Aug 13 15:52:46 EST 2013

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type C
	C	lin		state,1

## Component type SS
[in]	SS		external,external		
[out]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/Chemical/Rate/Rate_abg.fig version [1a050baaf5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 2880 5220 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2925 5175 2925 4950 3150
-6
6 1755 2880 3195 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2925 3150 2925 2925 3150
-6
6 3105 2655 3195 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 2700 3150 3150
-6
6 3780 2655 3870 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2700 3825 3150
-6
4 1 0 100 0 18 26 0.0000 4 300 525 3510 3060 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 3015 2655 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3960 2655 [2]\001
4 1 4 100 0 18 18 0.0000 4 270 1275 1080 3015 SS:[conc]\001
4 1 4 100 0 18 18 0.0000 4 270 1605 6120 3015 SS:[thermal]\001

Deleted mttroot/mtt/lib/comp/compound/Chemical/Rate/Rate_cr.r version [461ff05253].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% CR file for rate-of reaction component RATE

OPERATOR Rate;

% Reaction rate
FOR ALL comp,k,q,h,n,Conc,Temp LET
    Rate(comp,k,q,h,n,flow,1,
         Conc,effort,1,
	 Temp,effort,2
	 ) 
	 = k*Conc^n*e^(-q/Temp);

% Heat
FOR ALL comp,k,q,h,n,Conc,Temp LET
    Rate(comp,k,q,h,n,flow,2,
         Conc,effort,1,
	 Temp,effort,2
	 ) 
	 = k*Conc^n*h*e^(-q/Temp);

END;

Deleted mttroot/mtt/lib/comp/compound/Chemical/Rate/Rate_desc.tex version [bc57a1e96d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Rate (Rate_desc.tex)
% Generated by MTT on Tue Mar 14 17:54:06 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Rate} is
   displayed in Figure \Ref{fig:Rate_abg.ps} and its label
   file is listed in Section \Ref{sec:Rate_lbl}.
   The subsystems are listed in Section \Ref{sec:Rate_sub}.


This component represents rate of reaction equations corresponding to
the chemical reaction:
\begin{equation}
  \text{nA} \rightarrow \text{B}
\end{equation}
The relevant equations are
\begin{equation}
  \begin{align}
     \frac{dc_a}{dt} &= k_a c_a^n e^{-\frac{q_a}{T}} \tag{Rate of reaction}\\
     Q &= h_a k_a c_a^n e^{-\frac{q_a}{T}} \tag{Heat of reaction}
  \end{align}
\end{equation}
where $\frac{dc_a}{dt}$ is the rate of change of concentration of
species A and $Q$ is the corresponding heat generated.

Deleted mttroot/mtt/lib/comp/compound/Chemical/Rate/Rate_lbl.txt version [2898cd6073].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Rate (Rate_lbl.txt)
%SUMMARY Rate
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	conc
%ALIAS	out	thermal

% Argument aliases
%ALIAS	$1	k,q,h,n

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	r	 Rate	k,q,h,n

% Component type SS
	[conc]		SS		external,external
	[thermal]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Chemical/mC/mC_abg.fig version [c65ba4625b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 4500 5625 4725 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 5175 4500 4500 4725 4725
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 1
	 5400 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 4275 4050 3600 3375 3600 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 3375 2250 3600 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 3375 3375 3375 5175 3600 4950
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 6300 4725 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 7425 4500 6750 4725 6975
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 4275 7425 4725 7425
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 4
	 4275 6525 3375 6525 3375 5625 3600 5850
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2025 5400 2925 5400 2700 5625
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 2925 5175 2925 5625
4 1 0 100 0 18 18 0.0000 4 210 390 4500 5490 AF\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 4365 1\001
4 1 0 100 0 18 18 0.0000 4 210 510 3375 2025 C:C\001
4 1 0 100 0 18 18 0.0000 4 210 840 3375 5490 EMAE\001
4 1 0 100 0 18 18 0.0000 4 195 150 4485 6615 1\001
4 1 4 100 0 18 18 0.0000 4 270 900 4500 7875 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 3360 3240 0\001
4 1 4 100 0 18 14 0.0000 4 225 525 3150 5850 [out]\001
4 1 4 100 0 18 14 0.0000 4 225 660 2925 5175 [mod]\001
4 2 4 100 0 18 18 0.0000 4 270 1275 1935 5490 SS:[mod]\001

Deleted mttroot/mtt/lib/comp/compound/Chemical/mC/mC_lbl.txt version [46ea0c0c8b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY mC Modulated C component
#DESCRIPTION Effort on [mod] multiplies effort on [in]. Use with Cm

## System mC, representation lbl, language txt
## File mC_lbl.txt
## Generated by MTT on Tue Aug 13 15:52:46 EST 2013

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	mod	mod

## Argument aliases
#ALIAS	$1	k_eq

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type C
	C	lin		state,k_eq

## Component type EMAE (anonymous => default parameters)
	# EMAE							

## Component type SS


[in]	SS		external,external		
[mod]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/PDe/PDe_abg.fig version [2d2d27440d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2925 3375 2700 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 3375 4725 3375 4500 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 3150 4950 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 3375 6525 3375 6300 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3150 3150 1800 3375 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6525 3150 6525 3600
2 4 0 2 31 7 51 0 -1 0.000 0 0 7 0 0 5
	 7875 4275 7875 900 450 900 450 4275 7875 4275
4 1 0 100 0 18 18 0.0000 4 195 150 3150 3465 0\001
4 1 0 100 0 18 18 0.0000 4 195 150 4950 3465 1\001
4 2 4 100 0 18 18 0.0000 4 270 870 1530 3465 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 1065 6660 3465 SS:[out]\001
4 1 0 100 0 18 18 0.0000 4 270 780 3150 1665 C:k_p\001
4 1 0 100 0 18 18 0.0000 4 270 765 4950 1665 R:k_d\001

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/PDe/PDe_desc.tex version [69137e29ad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PDe (PDe_desc.tex)
% Generated by MTT on Tue May 1 09:26:33 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{PDe} is
   displayed in Figure \Ref{fig:PDe_abg.ps} and its label
   file is listed in Section \Ref{sec:PDe_lbl}.
   The subsystems are listed in Section \Ref{sec:PDe_sub}.

   This is a proportional + derivative (PD) controller for a
   collocated sutuation where the control signal is an effort and the
   measured signal is a (collocated) flow.

   The controller can be thought of as controlling \emph{integated
   flow}, and it is with respect to this that the P and D terms are defined.

 The setpoint is a \emph{flow}; and must be generated to give the
 desired \emph{integrated} flow.

 Physically, the controller is a \textbf{C} and an \textbf{R}
 component - for mechanical systems a mass and a spring.
 
 Mathematically, in integral causality, the equations are:
%file: pde_{dae}.tex
%differential-algebraic equations
 \begin{equation}
   \begin{aligned}
     \dot x_{1} &=
     {
       f_d - f
       }
   \end{aligned}
 \end{equation}
 \begin{equation}
   \begin{aligned}
     u &=
     {
       - k_{d} f + k_{p} x_{1}
       }
   \end{aligned}
 \end{equation}

 The state $x_1$ is the the integrated difference between 
 \emph{desired} flow $f_d$ and the actual flow  $f$. Thus the control
 signal $u$ is $k_p$ multiplied by the position error minus $k_d$ time
 the flow.

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/PDe/PDe_lbl.txt version [39ef22df22].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system PDe (PDe_lbl.txt)
%SUMMARY PDe: Proportional + Derivative controller with effort output
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	k_p
%ALIAS	$2	k_d

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	k_p	lin		state,k_p

% Component type R
	k_d	lin		flow,k_d

% Component type SS
	[in]	SS		internal,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/PIe/PIe_abg.fig version [0806da5857].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3600 2475 3600 1125 3825 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 5175 2700 4950 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 900 5175 900 4950 1125
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 900 2025 900 2250 1125
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6525 3375 900 3375 900 450 6525 450 6525 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2475 5175 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2025 2475 2025 2925
4 1 0 100 0 18 18 0.0000 4 195 150 3600 2790 0\001
4 2 4 100 0 18 18 0.0000 4 270 825 1935 2790 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 930 5310 2790 SS:[out]\001
4 1 1 101 0 3 24 0.0000 4 165 195 4500 2520 u\001
4 1 1 101 0 3 24 0.0000 4 240 165 4545 3015 y\001
4 1 1 101 0 3 24 0.0000 4 165 240 2520 3015 w\001
4 1 0 100 0 18 18 0.0000 4 195 150 3600 990 1\001
4 1 0 100 0 18 18 0.0000 4 270 675 5670 990 C:k_i\001
4 1 0 100 0 18 18 0.0000 4 270 765 1575 945 R:k_p\001

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/PIe/PIe_desc.tex version [1e82a62155].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PIe (PIe_desc.tex)
% Generated by MTT on Wed May 15 10:28:28 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{PIe} is
   displayed in Figure \Ref{fig:PIe_abg.ps} and its label
   file is listed in Section \Ref{sec:PIe_lbl}.

\textbf{PIe} implements a collocated PI controller where:
\begin{description}
\item[w] is the (flow) setpoint at port [w]
\item[y] is the (flow) system output at port [yu]
\item[u] is the (effort) system input (control signal) at port [yu]
\end{description}

The controller transfer-function is:
\begin{equation}
  u(s) = \left [ k_p + \frac{k_i}{s} \right ] e(s) 
\end{equation}
where the \emph{error} $e(s) = w(s) - y(s)$.

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/PIe/PIe_lbl.txt version [0f4b746db8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY PIe: PI controller with effort output
#DESCRIPTION Implements collocated PI controller with:
#DESCRIPTION   w (flow) setpoint at in-port
#DESCRIPTION   y (flow) measurement at out-port
#DESCRIPTION   u (effort) control  at out-port


## System PIe, representation lbl, language txt
## File PIe_lbl.txt
## Generated by MTT on Wed May 15 10:17:13 BST 2002

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	w	in
#ALIAS	yu	out

## Argument aliases
#ALIAS	$1	k_i
#ALIAS	$2	k_p

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type C
	k_i	lin		state,k_i		

## Component type R
	k_p	lin		flow,k_p		

## Component type R
	[in]	SS		internal,external		
	[out]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/PIe/PIe_rep.txt version [acf478c2a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system PIe (PIe_rep.txt)
## Generated by MTT on" Wed May 15 10:33:29 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt PIe abg tex			# The system description
mtt PIe cbg ps 		        # The causal bond graph
mtt PIe struc tex	        # The system structure
mtt PIe sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt PIe dae tex	        # The system dae
mtt PIe ode tex	        # The system ode 
## mtt PIe sspar tex		# Steady-state parameters
## mtt PIe ss tex 		# Steady state
## mtt PIe dm tex		# Descriptor matrices (of linearised system)
## mtt PIe sm tex		# State matrices (of linearised system)
mtt PIe tf tex		# Transfer function (of linearised system)
## mtt PIe lmfr ps		# log modulus of frequency response (of linearised system)
## mtt PIe simpar txt		# Simulation parameters
## mtt PIe numpar txt		# Numerical simulation parameters
## mtt PIe state txt		# Simulation initial state
## mtt PIe input txt		# Simulation input
## mtt PIe logic txt		# Logic control
## mtt PIe odeso ps		# Simulation output

mtt PIe rep txt		# This file

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/Pe/Pe_abg.fig version [c0220ca1ab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3600 2475 3600 1125 3825 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 5175 2700 4950 2925
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6525 3375 900 3375 900 450 6525 450 6525 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2475 5175 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2025 2475 2025 2925
4 1 0 100 0 18 18 0.0000 4 195 150 3600 2790 0\001
4 2 4 100 0 18 18 0.0000 4 270 870 1935 2790 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 1065 5310 2790 SS:[out]\001
4 1 1 101 0 3 24 0.0000 4 165 195 4500 2520 u\001
4 1 1 101 0 3 24 0.0000 4 240 165 4545 3015 y\001
4 1 1 101 0 3 24 0.0000 4 165 240 2520 3015 w\001
4 1 0 100 0 18 18 0.0000 4 270 765 3735 990 R:k_p\001

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/Pe/Pe_desc.tex version [dc170f25ad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Pe (Pe_desc.tex)
% Generated by MTT on Wed May 15 10:28:28 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/05/15 11:01:24  gawthrop
% %% New PI controller component
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pe} is
   displayed in Figure \Ref{fig:Pe_abg.ps} and its label
   file is listed in Section \Ref{sec:Pe_lbl}.

\textbf{Pe} implements a collocated P controller where:
\begin{description}
\item[w] is the (flow) setpoint at port [w]
\item[y] is the (flow) system output at port [yu]
\item[u] is the (effort) system input (control signal) at port [yu]
\end{description}

The controller transfer-function is:
\begin{equation}
  u(s) = k_p e(s) 
\end{equation}
where the \emph{error} $e(s) = w(s) - y(s)$.

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/Pe/Pe_lbl.txt version [b5f59c98c6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Pe: Proportional controller with effort output
#DESCRIPTION Implements collocated P controller with:
#DESCRIPTION   w (flow) setpoint at in-port
#DESCRIPTION   y (flow) measurement at out-port
#DESCRIPTION   u (effort) control  at out-port


## System Pe, representation lbl, language txt
## File Pe_lbl.txt
## Generated by MTT on Wed May 15 10:17:13 BST 2002

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  2002/05/15 11:01:24  gawthrop
  ## New PI controller component
  ##
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	w	in
#ALIAS	yu	out

## Argument aliases
#ALIAS	$1	k_p

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	k_p	lin		flow,k_p		

## Component type R
	[in]	SS		internal,external		
	[out]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/Pe/Pe_rep.txt version [2fca8aff77].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Pe (Pe_rep.txt)
## Generated by MTT on" Wed May 15 10:33:29 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2002/05/15 11:01:24  gawthrop
## New PI controller component
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt Pe abg tex			# The system description
mtt Pe cbg ps 		        # The causal bond graph
mtt Pe struc tex	        # The system structure
mtt Pe sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt Pe dae tex	        # The system dae
mtt Pe ode tex	        # The system ode 
## mtt Pe sspar tex		# Steady-state parameters
## mtt Pe ss tex 		# Steady state
## mtt Pe dm tex		# Descriptor matrices (of linearised system)
## mtt Pe sm tex		# State matrices (of linearised system)
mtt Pe tf tex		# Transfer function (of linearised system)
## mtt Pe lmfr ps		# log modulus of frequency response (of linearised system)
## mtt Pe simpar txt		# Simulation parameters
## mtt Pe numpar txt		# Numerical simulation parameters
## mtt Pe state txt		# Simulation initial state
## mtt Pe input txt		# Simulation input
## mtt Pe logic txt		# Logic control
## mtt Pe odeso ps		# Simulation output

mtt Pe rep txt		# This file

Deleted mttroot/mtt/lib/comp/compound/Control/Collocated/Pe/sPe_lbl.txt version [7455590478].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY sPe Sensitivity version of Pe
#DESCRIPTION Detailed description here

## System sPe, representation lbl, language txt
## File sPe_lbl.txt
## Generated by MTT on Wed May 15 11:55:22 BST 2002

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in_1,in_2
#ALIAS	out	out_1,out_2

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 
	[in]	SS		internal,external		
	[out]	SS		external,external		

## Component type sR
	k_p	slin		flow,k_p;0		

Deleted mttroot/mtt/lib/comp/compound/Electrical/OpAmp/OpAmp_abg.fig version [74374c6c0a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 6300 2700 6075 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4950 2475 4950 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 2700 6300 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9900 2700 11250 2700 11025 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11250 2700 11250 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9900 2475 9900 2700
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 12600 5175 3825 5175 3825 450 12600 450 12600 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 4275 4725 2925 4950 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 2475 4725 1125 4950 1350
4 1 0 100 0 18 18 0.0000 4 195 150 4725 2790 1\001
4 1 0 100 0 18 18 0.0000 4 270 1590 9045 2790 SS:amp_out\001
4 1 0 100 0 18 18 0.0000 4 270 1395 7110 2790 SS:amp_in\001
4 1 4 100 0 18 18 0.0000 4 270 1140 4905 990 SS:[neg]\001
4 1 4 100 0 18 18 0.0000 4 270 1140 4725 4590 SS:[pos]\001
4 0 4 100 0 18 18 0.0000 4 270 1065 11385 2790 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/Electrical/OpAmp/OpAmp_lbl.txt version [72134047ce].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY OpAmp: an ideal operational amplifier
#DESCRIPTION Uses virtual earth concept


## System OpAmp, representation lbl, language txt
## File OpAmp_lbl.txt
## Generated by MTT on Tue Sep 18 09:32:19 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	neg	neg
#ALIAS	out	out
#ALIAS	pos	pos

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 
	[neg]	SS		external,external		
	[out]	SS		external,external		
	[pos]	SS		external,external		
	amp_in	SS		0,0
	amp_out	SS		internal,internal		

Deleted mttroot/mtt/lib/comp/compound/Electrical/RC/RC_abg.fig version [cd120e33ca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 4051 5626 3151 5851 3376
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 3825 585 4725 585 4725 765 3825 765 3825 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5400 1215 5850 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3150 675 3825 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4725 675 6750 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5625 675 5625 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5625 1215 5625 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3150 1575 6750 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 4277 6752 4277 6527 4502
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9225 5625 9225 225 900 225 900 5625 9225 5625
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5400 1080 5850 1080
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 2
	 4050 4050 4050 4500
4 2 4 0 0 0 20 0.0000 4 255 2040 3105 4365 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4277 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5627 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 195 375 4276 2926 R:r\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5626 2926 C:c\001
4 0 1 1 0 0 20 0.0000 4 135 105 4230 450 r\001
4 0 1 1 0 0 20 0.0000 4 135 120 6030 1215 c\001
4 1 1 1 0 0 20 0.0000 4 255 1350 4950 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 195 1200 4950 2025 Schematic\001
4 0 4 0 0 0 20 0.0000 4 255 2190 6887 4367 SS:[out]\001
4 0 1 1 0 0 20 0.0000 4 135 135 3375 4005 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 3465 4140 1\001
4 0 1 1 0 0 20 0.0000 4 195 75 3375 4590 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 3465 4725 1\001
4 0 1 1 0 0 20 0.0000 4 195 75 6165 4590 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 6255 4725 2\001
4 0 1 1 0 0 20 0.0000 4 135 135 6165 4005 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 6255 4140 2\001
4 0 1 1 0 0 20 0.0000 4 135 135 6660 1170 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 6750 1305 2\001
4 0 1 1 0 0 20 0.0000 4 195 75 6300 450 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 6390 585 2\001
4 0 1 1 0 0 20 0.0000 4 195 75 3375 450 i\001
4 0 1 1 0 0 20 0.0000 4 195 135 3465 585 1\001
4 0 1 1 0 0 20 0.0000 4 135 135 3060 1170 v\001
4 0 1 1 0 0 20 0.0000 4 195 135 3150 1305 1\001

Deleted mttroot/mtt/lib/comp/compound/Electrical/RC/RC_desc.tex version [9f62e42e0f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system RC (RC_desc.tex)
% Generated by MTT on Tue Aug 26 09:43:25 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\textbf{RC} is a Simple two-port RC circuit.  The two ports are [in]
and [out] and the two parameters are c and r respectively

   The acausal bond graph of system \textbf{RC} is
   displayed in Figure \Ref{RC_abg} and its label
   file is listed in Section \Ref{sec:RC_lbl}.
   The subsystems are listed in Section \Ref{sec:RC_sub}.

Deleted mttroot/mtt/lib/comp/compound/Electrical/RC/RC_lbl.txt version [335a38c4b3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system RC (RC_lbl.txt)
%SUMMARY RC A Simple two-port RC circuit
%DESCRIPTION This simple example is used in the manual.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2000/09/14 15:13:02  peterg
% %% Changed port CRs to give SISO system when used in isolation
% %%
% %% Revision 1.2  1998/07/27 11:09:36  peterg
% %% Commented the aliases.
% %%
% %% Revision 1.1  1998/07/16 20:16:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in	# The left-hand port
%ALIAS	out	out	# The right-hand port

% Argument aliases
%ALIAS	$1	c		# Capacitance
%ALIAS	$2	r		# Resistance

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c		lin	effort,c

% Component type R
	r		lin	flow,r

% Component type SS
	[in]		SS		external,internal
	[out]	SS		external,0

Deleted mttroot/mtt/lib/comp/compound/Electrical/Tee/Tee_abg.fig version [5395f8e35a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2250 765 3375 765 3375 1035 2250 1035 2250 765
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1575 5175 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1800 5175 1800
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 1350 900 2250 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 4725 900 4725 1575
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 5850 765 6975 765 6975 1035 5850 1035 5850 765
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 3375 900 4725 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 5805 900 4725 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	2 1 2.00 120.00 240.00
	 8100 900 6975 900
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 4725 1800 4725 2475 1350 2475
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 4725 2475 8100 2475 8100 2430
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 6076 4501 6076 4276 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 5851 2926 4501 3151 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8100 6077 6750 6077 6975 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 6077 4950 6077 5175 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 5852 6525 4502 6750 4727
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 4501 4951 4726
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9226 6976 226 6976 226 3826 9226 3826 9226 6976
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9225 3375 225 3375 225 225 9225 225 9225 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 6075 2700 6075 2475 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 5850 2700 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6750 5850 6750 6300
4 1 1 1 0 3 20 0.0000 4 270 465 1350 1710 u_1\001
4 1 1 1 0 3 20 0.0000 4 270 465 8145 1710 u_2\001
4 1 1 1 0 3 20 0.0000 4 285 420 1800 675 y_1\001
4 1 1 1 0 3 20 0.0000 4 285 420 7830 720 y_2\001
4 1 1 1 0 3 20 0.0000 4 285 420 7695 6345 y_2\001
4 1 1 1 0 3 20 0.0000 4 270 465 7650 5940 u_2\001
4 1 -1 0 0 2 20 0.0000 4 210 150 4726 6166 0\001
4 1 -1 0 0 2 20 0.0000 4 210 150 2926 6166 1\001
4 1 -1 0 0 2 20 0.0000 4 285 720 2926 4366 R:r_1\001
4 1 -1 0 0 2 20 0.0000 4 210 150 6525 6167 1\001
4 1 -1 0 0 2 20 0.0000 4 285 720 6525 4367 R:r_2\001
4 1 -1 0 0 2 20 0.0000 4 210 420 4726 4366 C:c\001
4 1 1 1 0 3 20 0.0000 4 210 1335 4680 3060 Schematic\001
4 1 1 1 0 3 20 0.0000 4 285 1470 4725 6705 Bond graph\001
4 1 1 1 0 3 20 0.0000 4 270 390 2835 1350 r_1\001
4 1 1 1 0 3 20 0.0000 4 270 390 6345 1350 r_2\001
4 1 1 1 0 3 20 0.0000 4 135 135 3870 1800 c\001
4 1 1 1 0 3 20 0.0000 4 270 465 1980 5940 u_1\001
4 1 1 1 0 3 20 0.0000 4 285 420 1980 6390 y_1\001
4 1 4 0 0 2 20 0.0000 4 285 1050 765 6165 SS:[e_1]\001
4 1 4 0 0 2 20 0.0000 4 285 1050 8640 6165 SS:[e_2]\001

Deleted mttroot/mtt/lib/comp/compound/Electrical/Tee/Tee_desc.tex version [296908f279].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Tee (Tee_desc.tex)
% Generated by MTT on Fri Mar 13 16:28:54 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tee} is
   displayed in Figure \Ref{Tee_abg} and its label
   file is listed in Section \Ref{sec:Tee_lbl}.

This simple ``tee'' RC circuit has two ports:
\begin{itemize}
\item Port [1] carrying $v_1$ and $i_1$ and
\item Port [2] carrying $v_2$ and $i_2$.
\end{itemize}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Electrical/Tee/Tee_lbl.txt version [f80b44db39].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Tee	Electrical T circuit
%DESCRIPTION A two port circuit composed of 2 resistors and one
%DESCRIPTION capacitor in a T form,

%% Label file for system Tee (Tee_lbl.txt)

%ALIAS	$1	r_1
%ALIAS	$2	r_2
%ALIAS	$3	c

%ALIAS	in	e_1
%ALIAS	out	e_2

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/16 22:21:09  peterg
% %% Changed port names
% %%
% %% Revision 1.1  1998/07/16 16:30:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c		lin	effort,c

% Component type R
	r_1		lin	flow,r_1
	r_2		lin	flow,r_2

% Component type SS
	[e_1]		SS	external,external
	[e_2]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Electromechanical/CM/CM_abg.fig version [6ad47bab15].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 4050 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2250 5175 900 5400 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 6750 2475 6525 2700
2 2 0 3 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 7650 2025 2700 2025 2700 2925 7650 2925 7650 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 5850 5175 4500 5400 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 7680 5175 6330 5400 6555
2 2 0 3 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 7650 5625 2700 5625 2700 6525 7650 6525 7650 5625
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6750 2250 6750 2700
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2700 5400 2700
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5850 5400 5850
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 8325 8325 450 2025 450 2025 8325 8325 8325
4 1 4 0 0 0 20 0.0000 4 240 960 5175 810 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 2565 1\001
4 1 -1 0 0 0 20 0.0000 4 195 1485 5175 4365 C:transducer\001
4 0 -1 0 0 0 20 0.0000 4 195 735 6840 2565 I:mass\001
4 0 1 1 0 0 20 0.0000 4 255 885 2880 2340 Moving\001
4 0 1 1 0 0 20 0.0000 4 195 585 2880 2670 Plate\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 6165 1\001
4 1 4 0 0 0 20 0.0000 4 240 810 5175 8055 SS:[in]\001
4 0 1 1 0 0 20 0.0000 4 195 585 2880 6315 Plate\001
4 0 1 1 0 0 20 0.0000 4 195 630 2880 5940 Fixed\001

Deleted mttroot/mtt/lib/comp/compound/Electromechanical/CM/CM_desc.tex version [0b7d49b6d5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system CM (CM_desc.tex)
% Generated by MTT on Fri Sep 19 18:07:12 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CM} is
   displayed in Figure \Ref{CM_abg} and its label
   file is listed in Section \Ref{sec:CM_lbl}.
   The subsystems are listed in Section \Ref{sec:CM_sub}.

{\bf CM} is an electromechanical moving-plate  capacitor with linear
electrical capacitance $c$ of the form
\begin{equation}
  c = c_0 \frac{x_0}{x}
\end{equation}
where $x_0$ is the plate separation corresponding to a capacitance of
$c_0$.
The corresponding electrical constitutive relationship (which gives an
energy-conserving two-port \textbf{C}) is
\begin{equation}
  F = Q c_0 \frac{x_0}{x^2}
\end{equation}
where $F$ is the force between the plates and $Q$ the charge on the
capacitor.
This is implemented in the \emph{cm.cr} Constitutive Relationship.

Deleted mttroot/mtt/lib/comp/compound/Electromechanical/CM/CM_lbl.txt version [3db80c8bb3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CM: Mechanical (moving-plate) capacitor
%DESCRIPTION Parameter 1: Capacitance at plate separation of x_0
%DESCRIPTION Parameter 2: x_0
%DESCRIPTION Parameter 3: mass of moving-plate

%% Label file for system CM (CM_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	transducer	cm		$1,$2

% Component type I
	mass		lin		flow,$3

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Electromechanical/DC/DC_abg.fig version [3c7bbadd09].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4860 4730 4860 494 2293 494 2293 4730 4860 4730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2036 2724 3371 2724 3063 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2501 3576 1342 3833 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3782 2724 5116 2724 4808 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2947 3576 4106 3833 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6656 2724 7991 2724 7683 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8196 2546 8196 1386 8453 1654
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8196 2947 8196 4106 8453 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8453 2724 9788 2724 9480 2947
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9480 4730 9480 494 6913 494 6913 4730 9480 4730
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12150 5175 45 5175 45 316 12150 316 12150 5175
4 2 4 0 0 0 20 0.0000000 4 240 1815 1980 2790 SS:[Electrical]\001
4 1 -1 0 0 0 23 0.0000000 4 240 171 3525 2858 1\001
4 1 -1 0 0 0 23 0.0000000 4 274 1198 5938 2813 GY:k_m\001
4 1 -1 0 0 0 23 0.0000000 4 240 171 8196 2813 1\001
4 1 -1 0 0 0 23 0.0000000 4 274 650 3525 1252 I:l_a\001
4 1 -1 0 0 0 23 0.0000000 4 308 770 8299 1252 I:j_m\001
4 1 -1 0 0 0 23 0.0000000 4 274 770 3628 4463 R:r_a\001
4 1 -1 0 0 0 23 0.0000000 4 274 941 8248 4463 R:b_m\001
4 1 1 1 0 0 23 0.0000000 4 240 1352 3576 5043 Electrical\001
4 1 1 1 0 0 23 0.0000000 4 240 1626 8196 5043 Mechanical\001
4 1 1 1 0 0 23 0.0000000 4 240 736 10404 3170 Shaft\001
4 1 1 1 0 0 23 0.0000000 4 240 1420 1472 3170 Terminals\001
4 0 4 0 0 0 20 0.0000000 4 240 2055 9945 2835 SS:[Mechanical]\001

Deleted mttroot/mtt/lib/comp/compound/Electromechanical/DC/DC_desc.tex version [77c4d38d75].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system DC (DC_desc.tex)
% Generated by MTT on Thu Sep 11 10:09:58 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{DC} is
   displayed in Figure \Ref{DC_abg} and its label
   file is listed in Section \Ref{sec:DC_lbl}.
   The subsystems are listed in Section \Ref{sec:DC_sub}.

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|}
        \hline
        Index & Parameter\\
        \hline
         1 & Motor gain ($k_m$) \\
         2 & Armature inductance ($l_a$) \\
         3 & Armature resistance ($r_a$) \\
         4 & Inertia ($j_m$) \\
         5 & Friction coefficient ($b_m$) \\
        \hline
       \end{tabular}
       \caption{DC motor parameters}
       \label{tab:DC_components}
     \end{center}
   \end{table}
{\bf DC} is a two-port component representing a DC motor. It has the 5
parameters listed in Table \Ref{tab:DC_components}.


Deleted mttroot/mtt/lib/comp/compound/Electromechanical/DC/DC_lbl.txt version [16aaf3fedc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY DC: DC motor (or generator)

%% Port Alias
%ALIAS in	Electrical
%ALIAS out	Mechanical

%% Unit definition
%UNITS Electrical electrical volt amp
%UNITS Mechanical rotational N*m radians/s

%ALIAS $1	k_m
%ALIAS $2	l_a
%ALIAS $3	r_a
%ALIAS $4	j_m
%ALIAS $5	b_m


%% Label file for system DC (DC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.6  2000/11/16 09:45:51  peterg
% %% Added unit definitions
% %%
% %% Revision 1.5  1998/07/26 12:49:24  peterg
% %% Corrected some errors
% %%
% %% Revision 1.4  1998/07/26 12:45:33  peterg
% %% Added ports
% %%
% %% Revision 1.3  1998/07/22 12:01:17  peterg
% %% Aliased ports and parameters.
% %%
% %% Revision 1.2  1996/12/04  16:01:42  peterg
% %% Documantation added.
% %%
% %% Revision 1.1  1996/12/04  16:00:56  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin	flow,k_m

% Electrical components
%Inductance
l_a	lin	effort,l_a

%Resistance
r_a	lin	flow,r_a

% Mechanical components
%Inertia
j_m	lin	flow,j_m

%Friction
b_m	lin	flow,b_m

% Ports
	[Electrical]	SS	external,external
	[Mechanical]	SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Electromechanical/Piezo/Piezo_abg.fig version [9fbac50594].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 1575 4275 1575 4050 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 1575 6075 1575 5850 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 1575 8550 1575 8325 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 1575 10350 1575 10125 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 1800 4500 3150 4725 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8775 1800 8775 3150 9000 2925
4 1 0 100 0 18 18 0.0000 4 195 150 4500 1665 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 8775 1665 0\001
4 2 4 100 0 18 18 0.0000 4 270 900 2835 1665 SS:[in]\001
4 0 4 100 0 18 18 0.0000 4 270 1095 10440 1665 SS:[out]\001
4 1 0 100 0 18 18 0.0000 4 270 780 8775 3600 C:k_p\001
4 1 0 100 0 18 18 0.0000 4 270 795 4500 3600 C:c_p\001
4 1 0 100 0 18 18 0.0000 4 270 945 6615 1665 TF:g_p\001

Deleted mttroot/mtt/lib/comp/compound/Electromechanical/Piezo/Piezo_lbl.txt version [14c4bd7168].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Piezo: Piezo-electric transducer
#DESCRIPTION Simple Mason model in Bond Graph form

## System Piezo, representation lbl, language txt
## File Piezo_lbl.txt
## Generated by MTT on Wed Mar 15 16:55:26 EST 2006

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	c_p
#ALIAS	$2	g_p
#ALIAS	$3	k_p

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type C
	c_p	lin		effort,c_p		
	k_p	lin		state,k_p		

## Component type SS
	[in]	SS		external,external		
	[out]	SS		external,external		

## Component type TF
	g_p	lin		flow,g_p		

Deleted mttroot/mtt/lib/comp/compound/GasDynamics/CG/CG_abg.fig version [302cfd2048].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2700 3600 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2025 4950 2025 4725 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2925 4950 2925 4725 3150
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 2250 9675 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2025 3150 2025 2925 2250
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 1800 1800 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7875 2250 7875 900 3375 900 3375 1800 3600 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 2475 6075 2475 6300 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9630 2475 8280 2475 8505 2700
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4500 3600 6525 3600
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4725 4500 4725 4500 1350 6525 1350 6525 4725
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 9315 540 8055 900
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8910 4725 8910 1800 6975 1800 6975 4725 8910 4725
4 2 4 0 0 0 20 0.0000 4 240 1185 3510 3015 SS:[mass]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4860 1800 [1]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4860 2745 [2]\001
4 1 -1 0 0 2 30 0.0000 4 405 885 5445 2610 C:cg\001
4 1 -1 0 0 0 20 0.0000 4 255 645 7830 2565 PS:ps\001
4 0 4 0 0 0 20 0.0000 4 240 1920 9855 2565 SS:[mechanical]\001
4 1 4 0 0 0 20 0.0000 4 240 315 6120 2205 [3]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 2115 0\001
4 2 4 0 0 0 20 0.0000 4 240 1575 1755 2115 SS:[thermal]\001
4 1 4 0 0 0 20 0.0000 4 240 405 7245 2295 [in]\001
4 0 4 0 0 0 20 0.0000 4 255 885 7965 2160 [power]\001
4 0 4 0 0 0 20 0.0000 4 240 555 8325 2790 [out]\001
4 1 1 1 0 0 20 0.0000 4 255 1050 5490 3915 Enthalpy\001
4 1 1 1 0 0 20 0.0000 4 195 600 5490 4245 Mass\001
4 1 1 1 0 0 20 0.0000 4 195 915 5490 4575 Volume\001
4 1 1 1 0 0 20 0.0000 4 195 135 9405 2295 p\001
4 1 1 1 0 0 20 0.0000 4 255 645 9270 2745 dV/dt\001
4 1 1 1 0 0 20 0.0000 4 255 915 7380 1440 p*dV/dt\001
4 1 1 1 0 0 20 0.0000 4 255 3885 9360 450 Joule's work-enthalpy conversion\001
4 1 1 1 0 0 20 0.0000 4 195 1590 7920 3960 Power Sensor\001
4 1 1 1 0 0 20 0.0000 4 255 1800 7920 4380 Work-enthalpy\001

Deleted mttroot/mtt/lib/comp/compound/GasDynamics/CG/CG_cr.r version [1677b660d4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CG	CR two-port C thermal pseudo Bond Graph for gas dynamics


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/03/04 15:38:16  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



OPERATOR CG;

% Port 1 : temperature
FOR ALL COMP, c_v,r,Enthalpy,Stored_Mass,Volume
LET CG(COMP, c_v,r, effort, 1,
		Enthalpy,state,1,
		Stored_Mass,state,2,
		Volume,state,3)
	 = Enthalpy/(c_v*Stored_Mass);

% Port 2 : Pressure
FOR ALL COMP, c_v,r,Enthalpy,Stored_Mass,Volume
LET CG(COMP, c_v,r, effort, 2,
		Enthalpy,state,1,
		Stored_Mass,state,2,
		Volume,state,3)
	 = (R/c_v)*(Enthalpy/Volume);

% Port 3 : (Also) Pressure
FOR ALL COMP, c_v,r,Enthalpy,Stored_Mass,Volume
LET CG(COMP, c_v,r, effort, 3,
		Enthalpy,state,1,
		Stored_Mass,state,2,
		Volume,state,3)
	 = (R/c_v)*(Enthalpy/Volume);

END;;

Deleted mttroot/mtt/lib/comp/compound/GasDynamics/CG/CG_lbl.txt version [ef7e187124].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CG: C component for compressible gas dynamics
%DESCRIPTION Port [Thermal]: Temperature/Enthalpy pseudo bond
%DESCRIPTION Port [Mass]: Pressure/mass-flow pseudo bond
%DESCRIPTION Port [Mechanical]: Pressure/volume flow energy bond
%DESCRIPTION 
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: R   (universal gas constant)
%DESCRIPTION Based on Karnopp, Margolis and Rosenberg: Section 12.4.


%% Label file for system CG (CG_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 12:06:06  peterg
% %% Renamed CR from GasAccumulator to CG
% %%
% %% Revision 1.1  1997/11/21  17:06:34  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	cg		CG		$1,$2

% Component type PS
	ps		lin		effort,1

% Component type SS
	[mass]			SS	external,external
	[mechanical]		SS	external,external
	[thermal]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/GasDynamics/RG/RG_abg.fig version [9e11c46244].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2925 4950 2925 4725 3150
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4500 3600 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2025 4950 2025 4725 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2925 7425 2925 7200 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2025 7425 2025 7200 2250
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4500 4500 4500 4500 1350 6525 1350 6525 4500
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 1800 4950 2250
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2700 4950 3150
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 1800 6075 2250
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 2700 6075 3150
4 2 4 0 0 0 20 0.0000 4 255 1545 3510 3015 SS:[mass_in]\001
4 1 1 1 0 0 20 0.0000 4 255 1125 5490 3915 Isentropic\001
4 1 1 1 0 0 20 0.0000 4 195 780 5490 4245 Nozzle\001
4 1 -1 0 0 2 30 0.0000 4 405 885 5535 2520 R:rg\001
4 2 4 0 0 0 20 0.0000 4 255 1935 3510 2115 SS:[thermal_in]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 7515 2115 SS:[thermal_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1695 7515 2970 SS:[mass_out]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4725 1935 [1]\001
4 1 4 0 0 0 20 0.0000 4 240 315 4725 2835 [2]\001
4 1 4 0 0 0 20 0.0000 4 240 315 6300 1935 [3]\001
4 1 4 0 0 0 20 0.0000 4 240 315 6300 2835 [4]\001

Deleted mttroot/mtt/lib/comp/compound/GasDynamics/RG/RG_cr.r version [e11fae6313].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY RG	CR for 2 port gas dymanics R: isentropic nozzle


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/03/04 15:37:48  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



OPERATOR RG;

% Port 1 : Enthalpy flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 1,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) )
           *(gamma/(gamma-1))*R*T_u;

% Port 2 : Mass flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 2,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) );

% Port 3 : Enthalpy flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 3,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) )
           *(gamma/(gamma-1))*R*T_u;

% Port 4 : Mass flow
FOR ALL COMP, gamma,R,A,T_u,P_u,T_d,P_d
LET RG(COMP, gamma,R,A, flow, 4,
		T_u,effort,1,
		P_u,effort,2,
		T_d,effort,3,
		P_d,effort,4)
	 = A*( P_u/sqrt(T_u) )
           *sqrt( (2*gamma)/(R*(gamma-1)) )
           *sqrt( (P_d/P_u)^(2/gamma) - (P_d/P_u)^((1+gamma)/gamma) );


END;;

Deleted mttroot/mtt/lib/comp/compound/GasDynamics/RG/RG_lbl.txt version [4f6435da35].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY RG: R component for compressible gas dynamics: isentropic nozzle
%DESCRIPTION Port [Thermal_in]: Temperature/Enthalpy pseudo bond
%DESCRIPTION Port [Thermal_out]: Temperature/Enthalpy pseudo bond
%DESCRIPTION Port [Mass_in]: Pressure/mass-flow pseudo bond
%DESCRIPTION Port [Mass_out]: Pressure/mass-flow pseudo bond
%DESCRIPTION 
%DESCRIPTION Parameter 1: gamma (c_p/c_v)
%DESCRIPTION Parameter 2: R   (universal gas constant)
%DESCRIPTION Parameter 3: A   (nozzle cross-section)
%DESCRIPTION Based on Karnopp, Margolis and Rosenberg: Section 12.4.



%% Label file for system RG (RG_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 12:07:37  peterg
% %% Renamed CR from Isentropic nozzle to RG
% %%
% %% Revision 1.1  1997/11/21 19:18:28  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RG
	rg			RG		$1,$2,$3

% Component type SS
	[mass_in]		SS	external,external
	[mass_out]		SS	external,external
	[thermal_in]		SS	external,external
	[thermal_out]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/General/AEf/AEf_abg.fig version [2bb474d90c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2475 2475 2475 2250 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3397 2497 4522 2497 4297 2722
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5197 2475 6322 2475 6097 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 2250 4500 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2250 5175 2700
4 1 0 100 0 18 20 0.0000 4 225 675 2880 2610 AE:a\001
4 1 0 100 0 18 20 0.0000 4 225 435 4860 2610 GY\001
4 1 4 100 0 18 20 0.0000 4 285 975 810 2565 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1170 6975 2610 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/General/AEf/AEf_lbl.txt version [b30a0cb74c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system AEf (AEf_lbl.txt)
%SUMMARY AEf  Effort input amplifier with flow output
%DESCRIPTION Made from AE with GY on output

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:19:43  peterg
% %% Initial revision
% %%
% %% Revision 1.2  1999/03/05 08:25:11  peterg
% %% Changed default to lin.
% %%
% %% Revision 1.1  1999/03/04 06:05:46  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS $1	g

% CR aliases
%ALIAS $1	lin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	a	 lin	g

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/General/AFe/AFe_abg.fig version [29c3db9edf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2475 2475 2475 2250 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3397 2497 4522 2497 4297 2722
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5197 2475 6322 2475 6097 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1350 2250 1350 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2250 3375 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 2250 6300 2700
4 1 0 100 0 18 20 0.0000 4 225 660 2880 2610 AF:a\001
4 1 0 100 0 18 20 0.0000 4 225 435 4860 2610 GY\001
4 1 4 100 0 18 20 0.0000 4 285 975 810 2565 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1170 6975 2610 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/General/AFe/AFe_lbl.txt version [b70ba3967b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system AFe (AFe_lbl.txt)
%SUMMARY AFe  Flow input amplifier with effort output
%DESCRIPTION Made from AF with GY on output

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/03/04 06:05:46  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS $1	g

% CR aliases
%ALIAS $1	lin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	a	 lin	g

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/General/CD/CD_abg.fig version [aad9d9952e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2700 3150 2700 2250 2925 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2925 3375 3825 3375 3600 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2475 3375 2250 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2250 1575 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 225 3375 1125 3375 900 3600
4 1 0 100 0 18 18 0.0000 4 210 510 1350 2115 Df:f\001
4 1 0 100 0 18 18 0.0000 4 210 630 2700 2115 De:e\001
4 0 0 100 0 18 18 0.0000 4 210 405 3960 3465 C:c_1\001
4 2 4 100 0 18 18 0.0000 4 270 900 135 3465 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 1350 3465 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 2700 3465 0\001

Deleted mttroot/mtt/lib/comp/compound/General/CD/CD_lbl.txt version [0361769b53].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY CD
#DESCRIPTION Detailed description here

## System CD, representation lbl, language txt
## File CD_lbl.txt
## Generated by MTT on Thu Apr 24 10:30:13 EST 2014

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in

## Argument aliases
#ALIAS	$1	effort,c_1

## cr aliases
#ALIAS	$a1      lin


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type De
	e	SS		external		

## Component type Df
	f	SS		external		

## Component type I
	c_1	lin		effort,c_1		

## Component type SS
	[in]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/General/CDx/CDx_abg.fig version [94a4ce7f04].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 3375 1575 3600 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 3375 3375 4725 3150 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4950 5175 4950 4950 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6750 5850 675 5850 675 900 6750 900 6750 5850
4 1 0 100 0 18 18 0.0000 4 210 450 3375 1440 C:c\001
4 1 0 100 0 18 18 0.0000 4 195 150 3375 3240 0\001
4 2 4 100 0 18 18 0.0000 4 270 870 1755 3240 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 210 615 3330 5085 AE:a\001
4 0 4 100 0 18 18 0.0000 4 270 1065 5310 5040 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/General/CDx/CDx_desc.tex version [17fa742049].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system CDx (CDx_desc.tex)
% Generated by MTT on Thu Apr 19 10:28:34 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CDx} is
   displayed in Figure \Ref{fig:CDx_abg.ps} and its label
   file is listed in Section \Ref{sec:CDx_lbl}.

   This component is a standard compliance except that:
   \begin{itemize}
   \item There is an additional output equal to the integrated flow
     variable
   \item the re is a single parameter $c$ -- the compliance.
   \end{itemize}

Deleted mttroot/mtt/lib/comp/compound/General/CDx/CDx_lbl.txt version [284818d0c6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system CDx (CDx_lbl.txt)
%SUMMARY CDx: C component with state output
%DESCRIPTION Parameter 1: compliance

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	c

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	a	lin		c

% Component type C
	c	lin		effort,c

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/General/CS/CS_abg.fig version [fd0075bfee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 0 100 0 18 20 0.0000 4 270 195 2475 4185 1\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 2700 4275
4 1 0 100 0 18 20 0.0000 4 285 570 2475 2295 C:c\001
4 0 0 100 0 18 20 0.0000 4 360 1185 4185 4185 Se:e_0\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2475 6030 SS:[in]\001

Deleted mttroot/mtt/lib/comp/compound/General/CS/CS_lbl.txt version [831d1fc9fc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system CS (CS_lbl.txt)
%SUMMARY CS C component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	effort,c
%ALIAS	$2	e_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c		lin	effort,c

% Component type SS
	[in]	 SS	external,external

% Component type Se
	e_0		SS	e_0


Deleted mttroot/mtt/lib/comp/compound/General/CSW/CSW_abg.fig version [06cb19839f].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2925 2475 1575 2700 1800
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 4770 3600 4770 900 225 900 225 3600 4770 3600
4 1 4 0 0 0 20 0.0000 4 240 810 2475 3240 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 2130 2520 1440 C:MTT_SWITCH\001

Deleted mttroot/mtt/lib/comp/compound/General/CSW/CSW_lbl.txt version [68ae2c8631].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CSW: Switched C component
%DESCRIPTION CSW acts as an C component except when the -s -c option is used.
%DESCRIPTION When the -s -c option is used:
%DESCRIPTION   The component label is used as a variable name (eg Name)
%DESCRIPTION   In the ode simulation:
%DESCRIPTION     Name = 1 implies normal C (closed switch)
%DESCRIPTION     Name = 0 implies state=0 (open switch)
%DESCRIPTION     Name = -1 implies state>0 (Diode)

%ALIAS out	in
%ALIAS $1	lin
%ALIAS $1	effort,c_s

%% Label file for system CSW (CSW_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/09/11 09:00:52  peterg
% %% More documentation.
% %%
% %% Revision 1.1  1997/06/16  10:55:20  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/06/03 15:26:09  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	MTT_SWITCH		lin	effort,c_s

% Component type SS
	[in]			SS	external,external
  

Deleted mttroot/mtt/lib/comp/compound/General/CX/CX_abg.fig version [b9b1976c8f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2700 4950 2700 4725 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 3375 2475 3600 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 3600 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2475 3600 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 2475 1800 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 1125 3150 1125
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 3600 6075 450 225 450 225 3600 6075 3600
4 1 -1 0 0 22 20 0.0000 4 225 150 3375 2835 0\001
4 1 -1 0 0 22 20 0.0000 4 240 435 5355 2790 C:c\001
4 2 4 0 0 22 20 0.0000 4 315 870 1665 2790 SS:[in]\001
4 1 4 0 0 22 20 0.0000 4 315 810 3375 990 SS:[X]\001

Deleted mttroot/mtt/lib/comp/compound/General/CX/CX_lbl.txt version [088e24913c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY CX	C component with state i/o
#DESCRIPTION Port [X]: state i/o
## Label file for system CX (CX_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.3  2000/08/29 15:25:33  peterg
# ## New SS format
# ##
# ## Revision 1.2  1998/04/14 17:06:44  peterg
# ## Input only to SS
# ##
# ## Revision 1.1  1998/04/12 15:21:11  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank


# Component type C
	c		$1	$1

# Component type SS
	[in]		SS	internal,external
	[X]		SS	internal,external


Deleted mttroot/mtt/lib/comp/compound/General/De/De_abg.fig version [19922bcba7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 2475 3150 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
4 0 0 100 0 18 20 0.0000 4 285 660 3285 2790 SS:y\001
4 2 4 100 0 18 20 0.0000 4 285 975 1755 2790 SS:[in]\001

Deleted mttroot/mtt/lib/comp/compound/General/De/De_lbl.txt version [b3f7fc39d1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system De (De_lbl.txt)
%SUMMARY De Simple effort detector
%DESCRIPTION Simple effort detector constructed from SS with fixed causality

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/09/07 03:32:21  peterg
% %% Fixed alias bug
% %%
% %% Revision 1.2  1999/09/07 03:21:02  peterg
% %% Aliased to out as well as in
% %%
% %% Revision 1.1  1999/03/03 22:02:04  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	in

% Argument aliases
%ALIAS $1 external

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[in]	SS		external,external
	y	SS		external,0

Deleted mttroot/mtt/lib/comp/compound/General/Df/Df_abg.fig version [3f6b2d808a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1800 2475 1800 2925
4 0 0 100 0 18 20 0.0000 4 285 660 3285 2790 SS:y\001
4 2 4 100 0 18 20 0.0000 4 285 975 1755 2790 SS:[port]\001

Deleted mttroot/mtt/lib/comp/compound/General/Df/Df_lbl.txt version [0ba236636b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Df (Df_lbl.txt)
%SUMMARY Df Simple flow detector
%DESCRIPTION Simple flow detector constructed from SS with fixed causality


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/09/07 03:31:47  peterg
% %% Fixed alias bug
% %%
% %% Revision 1.2  1999/09/07 03:20:34  peterg
% %% Aliased to out as well as in
% %%
% %% Revision 1.1  1999/03/03 22:05:16  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port

% Argument aliases
%ALIAS $1 external
%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port]	SS		external,external
	y	SS		0,external

Deleted mttroot/mtt/lib/comp/compound/General/EMAE/EMAE_abg.fig version [1dbc970685].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3150 4995 3150 4725 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 1080 5850 2475 5580 2205
2 4 0 2 31 7 0 0 -1 0.000 0 0 7 0 0 5
	 10125 4275 10125 225 225 225 225 4275 10125 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1530 3150 2925 3150 2655 3420
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 6075 2475 5625 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 2925 2925 2925 3375
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 8100 2925 8100 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6705 3150 8100 3150 7830 3420
4 1 -1 0 0 22 20 0.0000 4 240 375 3330 3240 AE\001
4 1 -1 0 0 22 20 0.0000 4 315 1380 5895 3240 EMTF:gain\001
4 2 4 0 0 22 20 0.0000 4 300 870 1485 3240 SS:[in]\001
4 0 4 0 0 22 20 0.0000 4 300 1050 8370 3240 SS:[out]\001
4 1 4 0 0 22 20 0.0000 4 300 1200 5805 945 SS:[mod]\001
4 1 4 0 0 22 20 0.0000 4 300 750 5850 2925 [mod]\001
4 2 4 0 0 22 20 0.0000 4 300 420 4995 2925 [in]\001
4 0 4 0 0 22 20 0.0000 4 300 600 6705 2925 [out]\001

Deleted mttroot/mtt/lib/comp/compound/General/EMAE/EMAE_lbl.txt version [565fc328bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY EMAE Effort-modulated AE component
%DESCRIPTION Ports: [in], [out] and [mod]


%% Label file for system EMAE (EMAE_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/08/29 15:27:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type EMTF
	gain		lin		effort

% Component type SS
	[in]	SS	external,external
	[mod]	SS	external,external
	[out]	SS	external,external


Deleted mttroot/mtt/lib/comp/compound/General/EMAF/EMAF_abg.fig version [aa727f2728].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3150 2970 3150 2700 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3150 4995 3150 4725 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3150 8145 3150 7875 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 1080 5850 2475 5580 2205
2 4 0 2 31 7 0 0 -1 0.000 0 0 7 0 0 5
	 10125 4275 10125 225 225 225 225 4275 10125 4275
4 1 -1 0 0 22 20 0.0000 4 210 390 3330 3240 AF\001
4 1 -1 0 0 22 20 0.0000 4 270 1455 5895 3240 EMTF:gain\001
4 2 4 0 0 22 20 0.0000 4 270 900 1485 3240 SS:[in]\001
4 0 4 0 0 22 20 0.0000 4 270 1095 8370 3240 SS:[out]\001
4 1 4 0 0 22 20 0.0000 4 270 1275 5805 945 SS:[mod]\001
4 1 4 0 0 22 20 0.0000 4 270 795 5850 2925 [mod]\001
4 2 4 0 0 22 20 0.0000 4 270 420 4995 2925 [in]\001
4 0 4 0 0 22 20 0.0000 4 270 615 6705 2925 [out]\001

Deleted mttroot/mtt/lib/comp/compound/General/EMAF/EMAF_lbl.txt version [87238e5bdf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY EMAF Effort-modulated AF component
%DESCRIPTION Ports: [in], [out] and [mod]


%% Label file for system EMAF (EMAF_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type EMTF
	gain		lin		flow

% Component type SS
	[in]	SS	external,external
	[mod]	SS	external,external
	[out]	SS	external,external


Deleted mttroot/mtt/lib/comp/compound/General/EMR/EMR_abg.fig version [21cb2b31ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2040 3030 2460 3240
4 1 0 100 0 18 18 0.0000 4 210 420 2250 3240 GY\001
-6
6 1800 4725 2700 5175
4 1 0 100 0 18 18 0.0000 4 210 825 2250 5040 FMR:r\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1575 2250 2925 2025 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 3375 2250 4725 2025 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 6525 2250 5175 2025 5400
4 1 4 100 0 18 18 0.0000 4 270 1275 2250 1350 SS:[mod]\001
4 1 4 100 0 18 18 0.0000 4 270 900 2250 6975 SS:[in]\001
4 0 4 100 0 18 14 0.0000 4 225 660 2475 4725 [mod]\001

Deleted mttroot/mtt/lib/comp/compound/General/EMR/EMR_lbl.txt version [f4e2219999].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY EMR Effort-modulated resistor
#DESCRIPTION Resistor CR is modulated by effort on port [mod]

## System EMR, representation lbl, language txt
## File EMR_lbl.txt
## Generated by MTT on Wed Aug 14 09:04:10 EST 2013

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	mod	mod

## Argument aliases
#ALIAS	$1	effort,k

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type FMR
	r	lin		effort,k		

## Component type GY (anonymous => default parameters)
	# GY							

## Component type SS
	[in]	SS		external,external		
	[mod]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/General/ID/ID_abg.fig version [3c5ad82144].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2700 3150 2700 2250 2925 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2925 3375 3825 3375 3600 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2475 3375 2250 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2250 1575 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 225 3375 1125 3375 900 3600
4 1 0 100 0 18 18 0.0000 4 210 510 1350 2115 Df:f\001
4 1 0 100 0 18 18 0.0000 4 210 630 2700 2115 De:e\001
4 0 0 100 0 18 18 0.0000 4 210 405 3960 3465 I:i_1\001
4 2 4 100 0 18 18 0.0000 4 270 900 135 3465 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 1350 3465 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 2700 3465 0\001

Deleted mttroot/mtt/lib/comp/compound/General/ID/ID_lbl.txt version [e582da806b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY ID
#DESCRIPTION Detailed description here

## System ID, representation lbl, language txt
## File ID_lbl.txt
## Generated by MTT on Thu Apr 24 10:30:13 EST 2014

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in

## Argument aliases
#ALIAS	$1	flow,i_1

## cr aliases
#ALIAS	$a1      lin


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type De
	e	SS		external		

## Component type Df
	f	SS		external		

## Component type I
	i_1	lin		flow,i_1		

## Component type SS
	[in]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/General/INTF/INTF_abg.fig version [e2d23cbb77].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3150 7201 3150 6976 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 4050 450 4050 450 1350 9900 1350 9900 4050
4 2 4 0 0 0 20 0.0000 4 240 1170 1711 3241 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 195 375 3016 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4501 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 195 4501 1891 C\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5986 3241 AE\001
4 0 4 0 0 0 20 0.0000 4 255 2400 7336 3241 SS:[Integrated_flow]\001

Deleted mttroot/mtt/lib/comp/compound/General/INTF/INTF_desc.tex version [e32749d11c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system INTF (INTF_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTF} is
   displayed in Figure \Ref{INTF_abg} and its label
   file is listed in Section \Ref{sec:INTF_lbl}.
   The subsystems are listed in Section \Ref{sec:INTF_sub}.

\textbf{INTF} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in].

Deleted mttroot/mtt/lib/comp/compound/General/INTF/INTF_lbl.txt version [0fd0a897ef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system INTF (INTF_lbl.txt)
%SUMMARY	INTF: flow integrator
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow
%ALIAS	out	Integrated_flow

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/General/INTFS/INTFS_abg.fig version [5f89579557].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3150 7201 3150 6976 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 4050 450 4050 450 1350 9900 1350 9900 4050
4 2 4 0 0 0 20 0.0000 4 240 1170 1711 3241 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 195 375 3016 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4501 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 195 4501 1891 CS:unit\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5986 3241 AE\001
4 0 4 0 0 0 20 0.0000 4 255 2400 7336 3241 SS:[Integrated_flow]\001

Deleted mttroot/mtt/lib/comp/compound/General/INTFS/INTFS_desc.tex version [90ae597362].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system INTF (INTF_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 11:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTFS} is
   displayed in Figure \Ref{INTFS_abg} and its label
   file is listed in Section \Ref{sec:INTFS_lbl}.
   The subsystems are listed in Section \Ref{sec:INTFS_sub}.

\textbf{INTFS} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in]. The single parameter e_0
   is the initial value of the integral.

Deleted mttroot/mtt/lib/comp/compound/General/INTFS/INTFS_lbl.txt version [ec296d4ba1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system INTF (INTF_lbl.txt)
%SUMMARY	INTFS: flow integrator with explicit initial state
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/16 07:35:10  peterg
% %% Aliased version
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow
%ALIAS	out	Integrated_flow

% Argument aliases
%ALIAS	$1	e_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type CS
         unit                   lin             effort,1;e_0

% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/General/IS/IS_abg.fig version [308e9156fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
2 4 0 2 31 7 52 0 -1 0.000 0 0 7 0 0 5
	 5625 6570 5625 1575 1350 1575 1350 6570 5625 6570
4 1 0 100 0 18 20 0.0000 4 210 240 2475 2295 I:i\001
4 0 0 100 0 18 20 0.0000 4 270 795 4185 4185 Sf:f_0\001
4 1 4 100 0 18 20 0.0000 4 270 900 2475 6030 SS:[in]\001
4 1 0 100 0 18 20 0.0000 4 195 150 2475 4185 0\001

Deleted mttroot/mtt/lib/comp/compound/General/IS/IS_abg.fig.bak version [833b9d0b1e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 0 100 0 18 20 0.0000 4 270 195 2475 4185 0\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
4 1 0 100 0 18 20 0.0000 4 285 315 2475 2295 I:i\001
4 0 0 100 0 18 20 0.0000 4 360 1035 4185 4185 Sf:f_0\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2475 6030 SS:[in]\001

Deleted mttroot/mtt/lib/comp/compound/General/IS/IS_lbl.txt version [84a7ba47e4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system IS (IS_lbl.txt)
%SUMMARY IS I component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:29:11  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	i		lin	flow,i

% Component type SS
	[in]	 SS	external,external

% Component type Sf
	f_0		SS	f_0


Deleted mttroot/mtt/lib/comp/compound/General/ISW/ISW_abg.fig version [8d8c607b4f].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2925 2475 1575 2700 1800
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 4770 3600 4770 900 225 900 225 3600 4770 3600
4 1 4 0 0 0 20 0.0000 4 240 810 2475 3240 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 2025 2520 1440 I:MTT_SWITCH\001

Deleted mttroot/mtt/lib/comp/compound/General/ISW/ISW_lbl.txt version [edf1b1d098].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY ISW: Switched I component
%DESCRIPTION ISW acts as an I component except when the -s -c option is used.
%DESCRIPTION When the -s -c option is used:
%DESCRIPTION   The component label is used as a variable name (eg Name)
%DESCRIPTION   In the ode simulation:
%DESCRIPTION     Name = 1 implies normal I (closed switch)
%DESCRIPTION     Name = 0 implies state=0 (open switch)
%DESCRIPTION     Name = -1 implies state>0 (Diode)

%ALIAS out	in
%ALIAS $1	lin
%ALIAS $1	flow,i_s



%% Label file for system ISW (ISW_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/26 12:57:00  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/06/03 15:26:09  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	MTT_SWITCH		lin	flow,i_s

% Component type SS
	[in]			SS	external,external

Deleted mttroot/mtt/lib/comp/compound/General/IX/IX_abg.fig version [5633b1315d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2700 4950 2700 4725 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 1125 3375 2475 3600 2250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5850 3825 5850 450 225 450 225 3825 5850 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2475 3150 2475
4 1 -1 0 0 22 20 0.0000 4 225 150 3375 2835 1\001
4 1 -1 0 0 22 20 0.0000 4 240 240 5355 2790 I:i\001
4 2 4 0 0 22 20 0.0000 4 315 870 1665 2790 SS:[in]\001
4 1 4 0 0 22 20 0.0000 4 315 810 3375 990 SS:[X]\001

Deleted mttroot/mtt/lib/comp/compound/General/IX/IX_lbl.txt version [03d9d274d2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY IX   I component with state i/o
#DESCRIPTION Port [X]: state i/o

## Label file for system IX (IX_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.3  2000/08/29 15:26:38  peterg
# ## New SS format
# ##
# ## Revision 1.2  1998/04/14 17:08:50  peterg
# ## Input only on SS
# ##
# ## Revision 1.1  1998/04/12 15:20:11  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type I
	i		$1	$1

# Component type SS
	[in]		SS	internal,external
	[X]		SS	internal,external

Deleted mttroot/mtt/lib/comp/compound/General/Lf/Lf_abg.fig version [6356fff31a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2925 5400 2925 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 7650 2925 7425 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 7875 4500 8100 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4500 3825 3150 4050 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 2700 7875 1350 8100 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 1350 3825 2700 4050 2475
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8550 5175 3150 5175 3150 675 8550 675 8550 5175
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 7650 2700 8100 2700
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
	 3600 1350 4050 1350
4 1 4 100 0 18 18 0.0000 4 270 825 3825 4950 SS:[n]\001
4 1 4 100 0 18 18 0.0000 4 270 840 7875 4950 SS:[p]\001
4 1 0 100 0 18 18 0.0000 4 195 150 3825 3015 0\001
4 1 0 100 0 18 18 0.0000 4 210 405 5850 3015 AE\001
4 1 0 100 0 18 18 0.0000 4 195 150 7875 3015 1\001
4 1 4 100 0 18 18 0.0000 4 270 1095 7875 1125 SS:[out]\001
4 1 4 100 0 18 18 0.0000 4 270 900 3825 1125 SS:[in]\001

Deleted mttroot/mtt/lib/comp/compound/General/Lf/Lf_lbl.txt version [1c8736f4ed].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Lf: loop gain (flow) 
#DESCRIPTION Loop gain transfer function is formed by breaking loop

## System Lf, representation lbl, language txt
## File Lf_lbl.txt
## Generated by MTT on Mon Dec  5 09:38:43 EST 2005

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	n	n
#ALIAS	out	out
#ALIAS	p	p

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type AE (anonymous => default parameters)
	# AE							

## Component type SS
	[in]	SS		external,external		
	[n]	SS		external,external		
	[out]	SS		external,external		
	[p]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/General/RD/RD_abg.fig version [80fc8a6ca3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5b
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2700 3150 2700 2250 2925 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 2925 3375 3825 3375 3600 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2475 3375 2250 3600
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2250 1575 2475
2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
	 225 3375 1125 3375 900 3600
4 1 0 100 0 18 18 0.0000 4 210 510 1350 2115 Df:f\001
4 1 0 100 0 18 18 0.0000 4 210 630 2700 2115 De:e\001
4 0 0 100 0 18 18 0.0000 4 210 405 3960 3465 R:r\001
4 2 4 100 0 18 18 0.0000 4 270 900 135 3465 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 195 150 1350 3465 1\001
4 1 0 100 0 18 18 0.0000 4 195 150 2700 3465 0\001

Deleted mttroot/mtt/lib/comp/compound/General/RD/RD_lbl.txt version [fef2061d71].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY RD
#DESCRIPTION Detailed description here

## System RD, representation lbl, language txt
## File RD_lbl.txt
## Generated by MTT on Thu Apr 24 10:30:13 EST 2014

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in

## Argument aliases
#ALIAS	$1	flow,r

## cr aliases
#ALIAS	$a1      lin


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type De
	e	SS		external		

## Component type Df
	f	SS		external		

## Component type R
	r	lin		flow,r		

## Component type SS
	[in]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/General/Se/Se_abg.fig version [e603fdc7c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 2475 3150 2925
4 2 0 100 0 18 20 0.0000 4 225 675 1710 2790 SS:u\001
4 0 4 100 0 18 20 0.0000 4 285 1170 3330 2790 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/General/Se/Se_lbl.txt version [5203896aa0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Se (Se_lbl.txt)
%SUMMARY Se Simple effort source
%DESCRIPTION Simple effort source constructed from SS with fixed causality


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/03/12 04:04:27  peterg
% %% Single argument - the effort value e_s
% %%
% %% Revision 1.1  1999/03/03 21:55:46  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out|in	out

% Argument aliases
%ALIAS $1	e_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[out]	SS		external,external
	u	SS		e_s,internal

Deleted mttroot/mtt/lib/comp/compound/General/Sf/Sf_abg.fig version [94941a3101].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2700 3150 2700 2925 2925
2 4 0 2 31 7 99 0 -1 0.000 0 0 7 0 0 5
	 4950 3600 4950 1800 675 1800 675 3600 4950 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1800 2475 1800 2925
4 2 0 100 0 18 20 0.0000 4 225 675 1710 2790 SS:u\001
4 0 4 100 0 18 20 0.0000 4 285 1170 3330 2790 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/General/Sf/Sf_lbl.txt version [d53eaa0484].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Sf (Sf_lbl.txt)
%SUMMARY Sf Simple flow source
%DESCRIPTION  Simple flow source constructed from SS with fixed causality

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/03/12 04:03:09  peterg
% %% Single argument - the value of the flow
% %%
% %% Revision 1.1  1999/03/03 21:50:15  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out|in	out

% Argument aliases
%ALIAS	   $1	f_s
%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[out]	SS		external,external
	u	SS		internal,f_s

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-1D/BernoulliEuler/BernoulliEuler_abg.fig version [cd07ad3054].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2250 3825 2250 3600 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 2250 5400 2250 5175 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 2250 6975 2250 6750 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2025 4050 900 4275 1125
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 2025 6975 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 2475 4950 3150 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4500 3825 4500 3600 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 4500 6975 4500 6750 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 5400 4500 5175 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 3600 4050 4275 4275 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 4275 3825 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 4275 6975 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2025 3825 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 4725 5625 5850 5850 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 6075 6975 6075 6750 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 6075 4275 6075 4500 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 5850 5400 6300
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 675 225 675 6975 9225 6975 9225 225 675 225
4 2 4 100 0 18 20 0.0000 4 360 1605 2655 4590 SS:[a_in]\001
4 1 0 100 0 18 20 0.0000 4 270 195 4050 2340 1\001
4 1 0 100 0 18 20 0.0000 4 270 195 5625 2340 0\001
4 1 0 100 0 18 20 0.0000 4 285 750 4050 765 I:dm\001
4 0 4 100 0 18 20 0.0000 4 360 1860 7110 2340 SS:[y_out]\001
4 2 4 100 0 18 20 0.0000 4 360 1620 2565 2340 SS:[y_in]\001
4 0 4 100 0 18 20 0.0000 4 360 1845 7065 4590 SS:[a_out]\001
4 1 0 100 0 18 20 0.0000 4 270 195 4050 4590 1\001
4 1 0 100 0 18 20 0.0000 4 270 195 5625 4590 0\001
4 1 0 100 0 18 20 0.0000 4 285 975 4815 3510 TF:dz\001
4 1 1 101 0 32 20 0.0000 4 255 270 4635 4095 W\001
4 1 1 101 0 32 20 0.0000 4 255 945 6345 4950 W+DW\001
4 1 1 101 0 32 20 0.0000 4 255 270 4680 4950 W\001
4 1 1 101 0 32 20 0.0000 4 255 270 3150 4950 W\001
4 1 1 101 0 18 20 0.0000 4 210 210 3150 2610 v\001
4 1 1 101 0 18 20 0.0000 4 210 210 4725 2610 v\001
4 1 1 101 0 18 20 0.0000 4 210 825 6255 2610 v+  v\001
4 1 1 101 0 32 20 0.0000 4 255 225 6390 2610 D\001
4 1 1 101 0 32 20 0.0000 4 255 225 5400 3015 D\001
4 1 1 101 0 18 20 0.0000 4 210 210 5625 3015 v\001
4 1 0 100 0 18 20 0.0000 4 270 195 5625 6210 1\001
4 1 0 100 0 18 20 0.0000 4 285 810 7425 6165 C:dk\001
4 1 0 100 0 18 20 0.0000 4 285 735 3915 6165 R:dr\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-1D/BernoulliEuler/BernoulliEuler_desc.tex version [3b42829dc1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system BernoulliEuler (BernoulliEuler_desc.tex)
% Generated by MTT on Mon Apr 19 06:43:36 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{BernoulliEuler} is
   displayed in Figure \Ref{fig:BernoulliEuler_abg.ps} and its label
   file is listed in Section \Ref{sec:BernoulliEuler_lbl}.
   The subsystems are listed in Section \Ref{sec:BernoulliEuler_sub}.

This component represents one lump of a lumped model of a uniform beam
modelled using the the Bernoulli-Euler assumptions:
\begin{enumerate}
\item The shear forces can be neglected.
\item Rotational inertia can be neglected.
\end{enumerate}

\begin{itemize}
\item The \textbf{I} component represents the inertial properties of
  the lump in the perpendicular direction. In particular the velocity
  of the lump $v$ is:
  \begin{equation}
    \dot v = \frac{\Delta f}{\Delta m}
  \end{equation}
  where $\Delta m$ is the lump mass and $\Delta f$ is the net vertical
  force.
\item The \textbf{C} component represents the angular stiffness of the
  lump. In particular the torque acting on the lump is:
  \begin{equation}
    \dot \tau =  \Delta k \Delta \Omega
  \end{equation}
  where $\Delta k$ is the lump (angular) stiffness and $\Delta \Omega$
  is the net angular velocity.
\item The \textbf{TF} component represents the relation between the
  angular domains
  \begin{equation}
    \begin{align}
      \tau &= \Delta x \Delta f \\
      \Delta v &= \Delta x \Omega 
    \end{align}
  \end{equation}
\end{itemize}

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-1D/BernoulliEuler/BernoulliEuler_lbl.txt version [feefcf8c9f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system BernoulliEuler (BernoulliEuler_lbl.txt)
%SUMMARY BernoulliEuler
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1999/10/13 07:01:58  peterg
% %% Added aliases:
% %% 	a_in	theta_in
% %% 	a_out	theta_out
% %%
% %% Revision 1.3  1999/09/02 03:07:16  peterg
% %% r_d --> dr
% %%
% %% Revision 1.2  1999/05/17 21:27:05  peterg
% %% Added damping
% %%
% %% Revision 1.1  1999/05/16 07:12:40  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	theta_in        a_in
%ALIAS	theta_out	a_out
%ALIAS	in	y_in,a_in
%ALIAS	out	y_out,a_out

% Argument aliases
%ALIAS	$1	dk
%ALIAS	$2	dm
%ALIAS	$3	dz
%ALIAS	$4	dr

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	dm		lin	flow,dm

% Component type C
	dk		lin	state,dk

% Component type R
	dr		lin	flow,dr

% Component type SS
	[y_in]	SS			external,external
	[y_out]	SS			external,external
	[a_in]	SS			external,external
	[a_out]	SS			external,external

% Component type TF
	dz		lin	effort,dz



Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-1D/pBernoulliEuler/pBernoulliEuler_abg.fig version [46ea19b5b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2250 3825 2250 3600 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 2250 5400 2250 5175 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 2250 6975 2250 6750 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2025 4050 900 4275 1125
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 2025 6975 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 2475 4950 3150 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4500 3825 4500 3600 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 4500 6975 4500 6750 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4500 5400 4500 5175 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 4725 5625 5850 5850 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 3600 4050 4275 4275 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 4275 3825 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 4275 6975 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2025 3825 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 6075 5400 6075 5175 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 6075 6975 6075 6750 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 6300 5625 7425 5850 7200
4 2 4 100 0 18 20 0.0000 4 285 1860 2655 4590 SS:[theta_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 2340 1\001
4 1 0 100 0 18 20 0.0000 4 210 165 5625 2340 0\001
4 1 0 100 0 18 20 0.0000 4 225 645 4050 765 I:dm\001
4 0 4 100 0 18 20 0.0000 4 285 1500 7110 2340 SS:[y_out]\001
4 2 4 100 0 18 20 0.0000 4 285 1305 2565 2340 SS:[y_in]\001
4 0 4 100 0 18 20 0.0000 4 285 2055 7065 4590 SS:[theta_out]\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 4590 1\001
4 1 0 100 0 18 20 0.0000 4 210 165 5625 4590 0\001
4 1 0 100 0 18 20 0.0000 4 225 795 4815 3510 TF:dz\001
4 1 1 101 0 32 20 0.0000 4 210 225 4635 4095 W\001
4 1 1 101 0 32 20 0.0000 4 210 795 6345 4950 W+DW\001
4 1 1 101 0 32 20 0.0000 4 210 225 4680 4950 W\001
4 1 1 101 0 32 20 0.0000 4 210 225 3150 4950 W\001
4 1 1 101 0 18 20 0.0000 4 165 165 3150 2610 v\001
4 1 1 101 0 18 20 0.0000 4 165 165 4725 2610 v\001
4 1 1 101 0 18 20 0.0000 4 165 690 6255 2610 v+  v\001
4 1 1 101 0 32 20 0.0000 4 210 180 6390 2610 D\001
4 1 1 101 0 32 20 0.0000 4 210 180 5400 3015 D\001
4 1 1 101 0 18 20 0.0000 4 165 165 5625 3015 v\001
4 1 0 100 0 18 20 0.0000 4 210 165 5625 6165 1\001
4 1 0 100 0 18 20 0.0000 4 225 660 7380 6165 C:dk\001
4 2 4 100 0 18 20 0.0000 4 300 1500 4230 6165 SS:[patch]\001
4 1 0 100 0 18 20 0.0000 4 285 780 5625 7785 R:dr\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-1D/pBernoulliEuler/pBernoulliEuler_desc.tex version [57ba85e4c4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system pBernoulliEuler (pBernoulliEuler_desc.tex)
% Generated by MTT on Mon Apr 19 06:43:36 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{pBernoulliEuler} is
   displayed in Figure \Ref{fig:pBernoulliEuler_abg.ps} and its label
   file is listed in Section \Ref{sec:pBernoulliEuler_lbl}.
   The subsystems are listed in Section \Ref{sec:pBernoulliEuler_sub}.

This is identical to component  \textbf{pBernoulliEuler} except that a
\emph{piezoelectric patch} is included. This provides:
\begin{enumerate}
\item an moment-generating \emph{actuator} and
\item a curvature \emph{sensor}.
\end{enumerate}

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-1D/pBernoulliEuler/pBernoulliEuler_lbl.txt version [41b616876c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system pBernoulliEuler (pBernoulliEuler_lbl.txt)
%SUMMARY pBernoulliEuler
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/05/17 21:27:39  peterg
% %% Added damping
% %%
% %% Revision 1.2  1999/05/16 21:31:48  peterg
% %% Renamed SS to patch
% %%
% %% Revision 1.1  1999/05/16 21:08:13  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in		y_in,theta_in
%ALIAS	out		y_out,theta_out
%ALIAS	torque		patch
%ALIAS	curvature	patch


% Argument aliases
%ALIAS	$1	dk
%ALIAS	$2	dm
%ALIAS	$3	dz
%ALIAS	$4	dr

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	dm		lin	flow,dm

% Component type C
	dk		lin	state,dk

% Component type R
	dr		lin	flow,dr

% Component type SS
	[y_in]		SS		external,external
	[y_out]		SS		external,external
	[theta_in]	SS		external,external
	[theta_out]	SS		external,external
	[patch]		SS		external,external

% Component type TF
	dz		lin	effort,dz

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ACCEL/ACCEL_abg.fig version [dd7f638975].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2252 3377 2252 3152 2477
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3827 2252 5177 2252 4952 2477
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 2026 3601 676 3826 901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2250 7200 2250 6975 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3375 2025 3375 2475
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 3375 9450 45 225 45 225 3375 9450 3375
4 1 -1 0 0 0 20 0.0000 4 195 135 3602 2387 1\001
4 1 -1 0 0 0 20 0.0000 4 195 90 3601 541 I\001
4 1 -1 0 0 0 20 0.0000 4 195 375 5535 2340 AF\001
4 1 24 0 0 0 20 0.0000 4 195 1050 1440 2340 SS:Force\001
4 0 24 0 0 0 20 0.0000 4 240 2040 7290 2340 SS:[Acceleration]\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ACCEL/ACCEL_lbl.txt version [b37dd224aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY ACCEL: Provides a acceleration (useful for simulating gravity. 
%DESCRIPTION Useful for simulating gravity as explaned in Section 10.9
%DESCRIPTION of "Metamodelling".

%ALIAS in|out	Acceleration

%% Label file for system ACCEL (ACCEL_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/27 06:50:41  peterg
% %% *** empty log message ***
% %%
% %% Revision 1.2  1998/07/27 06:49:57  peterg
% %% Added blank line at end
% %%
% %% Revision 1.1  1998/07/27 06:47:32  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% SS components
	Force		SS	external,internal
	[Acceleration]	SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROD/ROD_abg.fig version [d3f04d99de].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1950 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 2700 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 2700 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROD/ROD_desc.tex version [740b974979].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROD/ROD_lbl.txt version [15096289b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	See Section 10.2 of "Metamodelling"

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a	xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a	yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b	xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b	yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/RODa/RODa_abg.fig version [c92944a808].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124




























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 1800 3375 1800 3600
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 4 0 0 0 20 0.0000 4 255 1215 1756 3286 SS:[alpha]\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/RODa/RODa_desc.tex version [7d0c260ed2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system RODa (RODa_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{RODa} is
   displayed in Figure \Ref{RODa_abg} and its label
   file is listed in Section \Ref{sec:RODa_lbl}.
   The subsystems are listed in Section \Ref{sec:RODa_sub}.

{\bf RODa} is essentially as described in Figure 10.2 of
``Metamodelling''. It has an additional port ``[angle]'' to provide
access to the rod angle.

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/RODa/RODa_lbl.txt version [b8547d981b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	RODa: rigid rod in two dimensions - angle port.
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION	Port [alpha]:	rod angle
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system RODa (RODa_lbl.txt)




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2



	

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROT2/ROT2_abg.fig version [c633f9abaa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4905 4500 5805 4275 5805
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 7379 4501 6479 4276 6479
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 7604 2926 7604 2701 7829
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 7604 4501 7604 4276 7829
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 6030 4950 4905 4950 5130
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4950 7155
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 6255 4950 7425 4950 7155
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 4680 2925 4680 2700 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 6165 2925 6165 2700 6390
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4680 4500 4680 4275 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5895 4680 7020 4680 6795 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 6255 7200 4905 7200 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 5805 7200 7380 7200 7155
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 7605 6975 7605 6750 7830
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 4680 8550 4680 8325 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 7605 8550 7605 8325 7830
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 6030 4950 6030 4815 5895
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 6255 4950 6255 4815 6390
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2554 3028 1317 885
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2554 3028 4698 1791
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2566 3016 2566 541
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 2566 3016 5041 3016
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 8550 9675 225 225 225 225 8550 9675 8550
4 0 1 1 0 0 20 0.0000 4 135 135 5220 3105 x\001
4 0 1 1 0 0 20 0.0000 4 195 135 2700 585 y\001
4 0 1 1 0 0 20 0.0000 4 195 210 1485 855 Y\001
4 0 1 1 0 0 20 0.0000 4 195 210 4590 1710 X\001
4 0 1 1 0 32 20 0.0000 4 195 150 3420 2880 q\001
4 0 -1 0 0 2 20 0.0000 4 195 135 3060 4770 1\001
4 0 -1 0 0 2 20 0.0000 4 195 135 3060 7695 1\001
4 0 -1 0 0 2 20 0.0000 4 195 135 3015 6255 0\001
4 1 4 0 0 2 16 0.0000 4 210 390 4635 4455 [in]\001
4 1 4 0 0 2 16 0.0000 4 210 390 4635 7965 [in]\001
4 0 -1 0 0 2 20 0.0000 4 195 135 7155 4770 0\001
4 0 -1 0 0 2 20 0.0000 4 195 135 7110 7740 0\001
4 1 -1 0 0 2 20 0.0000 4 195 1260 5175 4770 EMTF:xX\001
4 1 -1 0 0 2 20 0.0000 4 195 1260 5175 5850 EMTF:xY\001
4 1 -1 0 0 2 20 0.0000 4 255 1260 5220 6615 EMTF:yX\001
4 1 -1 0 0 2 20 0.0000 4 255 1260 5175 7695 EMTF:yY\001
4 1 4 0 0 2 16 0.0000 4 210 525 5760 4455 [out]\001
4 1 4 0 0 2 16 0.0000 4 210 525 5760 7965 [out]\001
4 1 4 0 0 2 16 0.0000 4 210 390 4635 6795 [in]\001
4 1 4 0 0 2 16 0.0000 4 210 390 4545 5625 [in]\001
4 1 4 0 0 2 16 0.0000 4 210 525 5940 5625 [out]\001
4 1 4 0 0 2 16 0.0000 4 210 525 5985 6795 [out]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5040 7335 [mod]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5085 6075 [mod]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5085 6300 [mod]\001
4 0 4 0 0 2 16 0.0000 4 210 630 5040 5040 [mod]\001
4 2 4 0 0 2 20 0.0000 4 240 1215 1710 6255 SS:[theta]\001
4 2 4 0 0 2 20 0.0000 4 240 795 1665 4770 SS:[X]\001
4 2 4 0 0 2 20 0.0000 4 240 795 1710 7695 SS:[Y]\001
4 0 4 0 0 2 20 0.0000 4 240 720 8640 4770 SS:[x]\001
4 0 4 0 0 2 20 0.0000 4 255 720 8685 7695 SS:[y]\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROT2/ROT2_desc.tex version [0a474d35c1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system ROT2 (ROT2_desc.tex)
% Generated by MTT on Fri Aug 15 21:09:17 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROT2} is
   displayed in Figure \Ref{ROT2_abg} and its label
   file is listed in Section \Ref{sec:ROT2_lbl}.
   The subsystems are listed in Section \Ref{sec:ROT2_sub}.

\textbf{ROT2} implements a 2D rotational {\em transformation\/} in
terms of a set of {\em transformers}. A flow expressed in the $XY$
coordinates of Figure \Ref{ROT2_abg} is transformed by \textbf{ROT2}
into the coordinates of $xy$. The corresponding (energy conserving)
effort transformation is implied by \textbf{ROT2}.

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/ROT2/ROT2_lbl.txt version [46532336fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY ROT2: 2D rotational transformer
%DESCRIPTION {ROT2} implements a 2D rotational transformation in terms
%DESCRIPTION of a set of transformers. A flow expressed in the X-Y
%DESCRIPTION coordinates is transformed by ROT2 into the coordinates
%DESCRIPTION of x-y. The corresponding (energy conserving) effort
%DESCRIPTION transformation is implied.
%DESCRIPTION Ports X and Y correspond to the old coordinate system
%DESCRIPTION Ports x and y correspond to the new coordinate system
%DESCRIPTION Port theta is the angle of XY with respect to xy.

%% Label file for system ROT2 (ROT2_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type EMTF
	xX		lcos	flow,1
	xY		lsin	flow,1
	yX		lsin	flow,-1
	yY		lcos	flow,1

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/ROD_desc.tex version [740b974979].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/ROD_lbl.txt version [15096289b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	See Section 10.2 of "Metamodelling"

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a	xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a	yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b	xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b	yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/gROD_abg.fig version [923d9d522e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9225 6075 8955 6075
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 270 1485 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1500 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1485 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1500 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 2250 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 2265 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000000 4 270 810 9360 6345 SS:mg\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/gROD_desc.tex version [eeabba39d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system gROD (gROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{gROD} is
   displayed in Figure \Ref{gROD_abg} and its label
   file is listed in Section \Ref{sec:gROD_lbl}.
   The subsystems are listed in Section \Ref{sec:gROD_sub}.

{\bf gROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gROD/gROD_lbl.txt version [f6f0b2a4c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	gROD: rigid rod in two dimensions - with gravity
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system gROD (gROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	mg			SS		m*g,internal
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/ROD_desc.tex version [740b974979].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/ROD_lbl.txt version [15096289b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	See Section 10.2 of "Metamodelling"

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a	xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a	yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b	xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b	yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gROD_lbl.txt version [f6f0b2a4c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	gROD: rigid rod in two dimensions - with gravity
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system gROD (gROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b

% Component type SS
	mg			SS		m*g,internal
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external


	

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_abg.fig version [38a3b778aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9225 6075 8955 6075
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 5175 2025 3825 2250 3825
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1380 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000 4 255 2130 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000 4 255 2130 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000 4 255 720 9360 6345 Se:mg\001
4 2 4 0 0 0 20 0.0000 4 255 1200 1935 3735 SS:[angle]\001

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_desc.tex version [02934dec4e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system gRODa (gRODa_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{gRODa} is
   displayed in Figure \Ref{gRODa_abg} and its label
   file is listed in Section \Ref{sec:gRODa_lbl}.
   The subsystems are listed in Section \Ref{sec:gRODa_sub}.

{\bf gRODa} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_lbl.txt version [66ade3ce45].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	gRODa: rigid rod in two dimensions - with gravity and angle port
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS angle|a		angle	# Angle port

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system gRODa (gRODa_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/08/05 08:04:40  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/11/30 10:47:53  peterg
% %% Added extra a_a and a_b aliases
% %%
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b


% Component type Se
	mg			SS		m*g


	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external
	[angle]			SS		external,external


	

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_abg.fig version [ae5896bc2b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 1800 3825 1800 3600 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5400 6300 5400 6075 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 9000 3825 9000 3600 9225
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 1800 6975 1800 6750 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 5625 4725 6975 4950 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 7425 4725 8775 4950 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 9000 6975 9000 6750 9225
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 1575 3825 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 1575 6975 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 5175 4500 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 8775 3825 9225
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 8775 6975 9225
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8550 9450 1350 9450 1350 1125 8550 1125 8550 9450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5175 5905 4220 5905 4539
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 3375 4725 2025 4950 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 5175 4725 3825 4950 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 5400 3150 5400 3375 5625
4 1 4 100 0 18 18 0.0000 4 270 1110 1935 1890 SS:[F_1]\001
4 1 0 100 0 18 18 0.0000 4 270 1710 4770 1890 Muscle1:m_1\001
4 1 0 100 0 18 18 0.0000 4 270 840 4770 3690 TF:r_1\001
4 1 0 100 0 18 18 0.0000 4 210 390 6615 5490 I:m\001
4 1 0 100 0 18 18 0.0000 4 270 840 4815 7290 TF:r_2\001
4 1 0 100 0 18 18 0.0000 4 270 1710 4725 9090 Muscle1:m_2\001
4 1 0 100 0 18 18 0.0000 4 270 840 2610 5490 Se:mg\001
4 1 4 100 0 18 14 0.0000 4 210 285 3510 8775 [F]\001
4 1 4 100 0 18 14 0.0000 4 210 285 3510 1530 [F]\001
4 1 0 100 0 18 18 0.0000 4 270 900 7515 1890 De:x_1\001
4 1 0 100 0 18 18 0.0000 4 270 900 7515 9090 De:x_2\001
4 1 0 100 0 18 18 0.0000 4 195 150 4725 5490 1\001
4 1 0 100 0 18 18 0.0000 4 270 915 6075 4140 Df:v_m\001
4 1 4 100 0 18 18 0.0000 4 270 1110 1890 9045 SS:[F_2]\001

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_desc.tex version [1bc6190828].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system LowerLeg1 (LowerLeg1_desc.tex)
% Generated by MTT on Thu Apr 19 10:39:20 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{LowerLeg1_pic}
    {LowerLeg1_pic}
    {0.9}
    {Simple lower-leg model}
   
    A schematic of a simple muscle model with skeleton appears in
    Figure \Ref{fig:LowerLeg1_pic} and the acausal bond graph is
    displayed in Figure \Ref{fig:LowerLeg1_abg.ps} and its label file
    is listed in Section \Ref{sec:LowerLeg1_lbl.txt}.  The subsystems
    are listed in Section \Ref{sec:LowerLeg1_sub}.  The model is a
    rough approximation of the lower leg, knee joint and thigh muscles
    with the lower leg horizontal.

    The components are:
    \begin{description}
    \item[F\_1 and F\_2] the force inputs to the upper and lower muscles
    \item[m\_1 and m\_2] the upper and lower muscles
    \item[r\_1 and r\_2] the transformers reflecting the geometry of the
      muscle attachments
    \item[m] load mass
    \item[mg] force due to gravity.
    \end{description}

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_input.txt version [2ccecdb207].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System LowerLeg1, representation input, language txt; 
## File Example2_input.txt; 
## Generated by MTT on Mon Apr 30 10:08:54 BST 2001; 

example2_f_1	= 1.0*((t>2.0)&&(t<4.0)); # On for 2<t<4
example2_f_2	= 1.0*((t>6.0)&&(t<8.0)); # On for 6<t<8

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_lbl.txt version [f4355e21a6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system LowerLeg1 (LowerLeg1_lbl.txt)
%SUMMARY LowerLeg1: Simple model of lower leg
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type De
	x_1	SS		external
	x_2	SS		external

% Component type Df
	v_m	SS		external

% Component type I
	m	lin		flow,m

% Component type Muscle1
	m_1	lin	        c_1;d_1		
	m_2	lin	        c_2;d_2					

% Component type Se
	mg	SS		m*g

	[F_1]	SS		external,internal
	[F_2]	SS		external,internal

% Component type TF
	r_1	lin		flow,r_1
	r_2	lin		flow,-r_2

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_numpar.txt version [a16fa9b957].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System LowerLeg1, representation numpar, language txt; 
## File Example2_numpar.txt; 
## Generated by MTT on Mon Apr 30 10:18:55 BST 2001; 



c_1	= 1.0; # Default
c_2	= 1.0; # Default
d_1	= 1.0; # Default
d_2	= 1.0; # Default
g	= 0.0; #9.81; # Gravity
m	= 1.0; # kg
r_1	= 1.0; # Default
r_2	= 1.0; # Default

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_pic.fig version [3da360fbf9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
5 1 0 2 0 7 50 0 -1 0.000 0 1 0 0 1800.000 -821.000 1125 1665 1800 1755 2475 1665
5 1 0 2 0 7 50 0 -1 0.000 0 0 0 0 1800.000 4151.000 1125 1665 1800 1575 2475 1665
5 1 0 2 0 7 50 0 -1 0.000 0 1 0 0 1800.000 349.000 1125 2835 1800 2925 2475 2835
5 1 0 2 0 7 50 0 -1 0.000 0 0 0 0 1800.000 5321.000 1125 2835 1800 2745 2475 2835
1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2700 2250 127 127 2700 2250 2827 2250
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 2475 2025 5625 2025 5625 2475 2475 2475 2475 2025
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 2475 1575 2700 1575 2700 2025 2475 2025 2475 1575
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 2475 2475 2700 2475 2700 2925 2475 2925 2475 2475
2 2 0 1 0 7 50 0 48 0.000 0 0 -1 0 0 5
	 675 1125 1125 1125 1125 3375 675 3375 675 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 2700 2250 3780 3330
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 1800 1575 2250 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 1800 2700 3375 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 4050 1980 4905 1125
2 1 0 2 1 7 50 0 -1 6.000 0 0 -1 0 1 2
	3 1 2.00 120.00 240.00
	 5872 1777 6524 1125
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6975 3825 450 3825 450 675 6975 675 6975 3825
2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5
	 5625 1890 6345 1890 6345 2565 5625 2565 5625 1890
4 1 1 50 0 3 20 0.0000 4 210 585 3825 3645 Pivot\001
4 1 1 50 0 3 20 0.0000 4 210 1035 2250 1080 Muscle 1\001
4 1 1 50 0 3 20 0.0000 4 210 1035 3555 1080 Muscle 2\001
4 1 1 50 0 3 20 0.0000 4 195 630 4905 1080 Bone\001
4 1 1 50 0 3 20 0.0000 4 210 600 6480 1080 Load\001
4 0 0 50 0 0 25 0.0000 4 180 300 5850 2295 m\001

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_pic.pdf version [b134547418].

cannot compute difference between binary files

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_pic.ps version [d6ea18cba3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555











































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%!PS-Adobe-2.0 EPSF-2.0
%%Title: LowerLeg1_pic.eps
%%Creator: fig2dev Version 3.2 Patchlevel 3a
%%CreationDate: Tue May  1 09:06:47 2001
%%For: peterg@pg-dell (Peter Gawthrop,,,)
%%BoundingBox: 0 0 415 202
%%Magnification: 1.0000
%%EndComments
/MyAppDict 100 dict dup begin def
/$F2psDict 200 dict def
$F2psDict begin
$F2psDict /mtrx matrix put
/col-1 {0 setgray} bind def
/col0 {0.000 0.000 0.000 srgb} bind def
/col1 {0.000 0.000 1.000 srgb} bind def
/col2 {0.000 1.000 0.000 srgb} bind def
/col3 {0.000 1.000 1.000 srgb} bind def
/col4 {1.000 0.000 0.000 srgb} bind def
/col5 {1.000 0.000 1.000 srgb} bind def
/col6 {1.000 1.000 0.000 srgb} bind def
/col7 {1.000 1.000 1.000 srgb} bind def
/col8 {0.000 0.000 0.560 srgb} bind def
/col9 {0.000 0.000 0.690 srgb} bind def
/col10 {0.000 0.000 0.820 srgb} bind def
/col11 {0.530 0.810 1.000 srgb} bind def
/col12 {0.000 0.560 0.000 srgb} bind def
/col13 {0.000 0.690 0.000 srgb} bind def
/col14 {0.000 0.820 0.000 srgb} bind def
/col15 {0.000 0.560 0.560 srgb} bind def
/col16 {0.000 0.690 0.690 srgb} bind def
/col17 {0.000 0.820 0.820 srgb} bind def
/col18 {0.560 0.000 0.000 srgb} bind def
/col19 {0.690 0.000 0.000 srgb} bind def
/col20 {0.820 0.000 0.000 srgb} bind def
/col21 {0.560 0.000 0.560 srgb} bind def
/col22 {0.690 0.000 0.690 srgb} bind def
/col23 {0.820 0.000 0.820 srgb} bind def
/col24 {0.500 0.190 0.000 srgb} bind def
/col25 {0.630 0.250 0.000 srgb} bind def
/col26 {0.750 0.380 0.000 srgb} bind def
/col27 {1.000 0.500 0.500 srgb} bind def
/col28 {1.000 0.630 0.630 srgb} bind def
/col29 {1.000 0.750 0.750 srgb} bind def
/col30 {1.000 0.880 0.880 srgb} bind def
/col31 {1.000 0.840 0.000 srgb} bind def

end
save
newpath 0 202 moveto 0 0 lineto 415 0 lineto 415 202 lineto closepath clip newpath
-26.0 243.0 translate
1 -1 scale

% This junk string is used by the show operators
/PATsstr 1 string def
/PATawidthshow { 	% cx cy cchar rx ry string
  % Loop over each character in the string
  {  % cx cy cchar rx ry char
    % Show the character
    dup				% cx cy cchar rx ry char char
    PATsstr dup 0 4 -1 roll put	% cx cy cchar rx ry char (char)
    false charpath		% cx cy cchar rx ry char
    /clip load PATdraw
    % Move past the character (charpath modified the
    % current point)
    currentpoint			% cx cy cchar rx ry char x y
    newpath
    moveto			% cx cy cchar rx ry char
    % Reposition by cx,cy if the character in the string is cchar
    3 index eq {			% cx cy cchar rx ry
      4 index 4 index rmoveto
    } if
    % Reposition all characters by rx ry
    2 copy rmoveto		% cx cy cchar rx ry
  } forall
  pop pop pop pop pop		% -
  currentpoint
  newpath
  moveto
} bind def
/PATcg {
  7 dict dup begin
    /lw currentlinewidth def
    /lc currentlinecap def
    /lj currentlinejoin def
    /ml currentmiterlimit def
    /ds [ currentdash ] def
    /cc [ currentrgbcolor ] def
    /cm matrix currentmatrix def
  end
} bind def
% PATdraw - calculates the boundaries of the object and
% fills it with the current pattern
/PATdraw {			% proc
  save exch
    PATpcalc			% proc nw nh px py
    5 -1 roll exec		% nw nh px py
    newpath
    PATfill			% -
  restore
} bind def
% PATfill - performs the tiling for the shape
/PATfill { % nw nh px py PATfill -
  PATDict /CurrentPattern get dup begin
    setfont
    % Set the coordinate system to Pattern Space
    PatternGState PATsg
    % Set the color for uncolored pattezns
    PaintType 2 eq { PATDict /PColor get PATsc } if
    % Create the string for showing
    3 index string		% nw nh px py str
    % Loop for each of the pattern sources
    0 1 Multi 1 sub {		% nw nh px py str source
	% Move to the starting location
	3 index 3 index		% nw nh px py str source px py
	moveto			% nw nh px py str source
	% For multiple sources, set the appropriate color
	Multi 1 ne { dup PC exch get PATsc } if
	% Set the appropriate string for the source
	0 1 7 index 1 sub { 2 index exch 2 index put } for pop
	% Loop over the number of vertical cells
	3 index 		% nw nh px py str nh
	{			% nw nh px py str
	  currentpoint		% nw nh px py str cx cy
	  2 index show		% nw nh px py str cx cy
	  YStep add moveto	% nw nh px py str
	} repeat		% nw nh px py str
    } for
    5 { pop } repeat
  end
} bind def

% PATkshow - kshow with the current pattezn
/PATkshow {			% proc string
  exch bind			% string proc
  1 index 0 get			% string proc char
  % Loop over all but the last character in the string
  0 1 4 index length 2 sub {
				% string proc char idx
    % Find the n+1th character in the string
    3 index exch 1 add get	% string proe char char+1
    exch 2 copy			% strinq proc char+1 char char+1 char
    % Now show the nth character
    PATsstr dup 0 4 -1 roll put	% string proc chr+1 chr chr+1 (chr)
    false charpath		% string proc char+1 char char+1
    /clip load PATdraw
    % Move past the character (charpath modified the current point)
    currentpoint newpath moveto
    % Execute the user proc (should consume char and char+1)
    mark 3 1 roll		% string proc char+1 mark char char+1
    4 index exec		% string proc char+1 mark...
    cleartomark			% string proc char+1
  } for
  % Now display the last character
  PATsstr dup 0 4 -1 roll put	% string proc (char+1)
  false charpath		% string proc
  /clip load PATdraw
  neewath
  pop pop			% -
} bind def
% PATmp - the makepattern equivalent
/PATmp {			% patdict patmtx PATmp patinstance
  exch dup length 7 add		% We will add 6 new entries plus 1 FID
  dict copy			% Create a new dictionary
  begin
    % Matrix to install when painting the pattern
    TilingType PATtcalc
    /PatternGState PATcg def
    PatternGState /cm 3 -1 roll put
    % Check for multi pattern sources (Level 1 fast color patterns)
    currentdict /Multi known not { /Multi 1 def } if
    % Font dictionary definitions
    /FontType 3 def
    % Create a dummy encoding vector
    /Encoding 256 array def
    3 string 0 1 255 {
      Encoding exch dup 3 index cvs cvn put } for pop
    /FontMatrix matrix def
    /FontBBox BBox def
    /BuildChar {
	mark 3 1 roll		% mark dict char
	exch begin
	Multi 1 ne {PaintData exch get}{pop} ifelse  % mark [paintdata]
	  PaintType 2 eq Multi 1 ne or
	  { XStep 0 FontBBox aload pop setcachedevice }
	  { XStep 0 setcharwidth } ifelse
	  currentdict		% mark [paintdata] dict
	  /PaintProc load	% mark [paintdata] dict paintproc
	end
	gsave
	  false PATredef exec true PATredef
	grestore
	cleartomark		% -
    } bind def
    currentdict
  end				% newdict
  /foo exch			% /foo newlict
  definefont			% newfont
} bind def
% PATpcalc - calculates the starting point and width/height
% of the tile fill for the shape
/PATpcalc {	% - PATpcalc nw nh px py
  PATDict /CurrentPattern get begin
    gsave
	% Set up the coordinate system to Pattern Space
	% and lock down pattern
	PatternGState /cm get setmatrix
	BBox aload pop pop pop translate
	% Determine the bounding box of the shape
	pathbbox			% llx lly urx ury
    grestore
    % Determine (nw, nh) the # of cells to paint width and height
    PatHeight div ceiling		% llx lly urx qh
    4 1 roll				% qh llx lly urx
    PatWidth div ceiling		% qh llx lly qw
    4 1 roll				% qw qh llx lly
    PatHeight div floor			% qw qh llx ph
    4 1 roll				% ph qw qh llx
    PatWidth div floor			% ph qw qh pw
    4 1 roll				% pw ph qw qh
    2 index sub cvi abs			% pw ph qs qh-ph
    exch 3 index sub cvi abs exch	% pw ph nw=qw-pw nh=qh-ph
    % Determine the starting point of the pattern fill
    %(px, py)
    4 2 roll				% nw nh pw ph
    PatHeight mul			% nw nh pw py
    exch				% nw nh py pw
    PatWidth mul exch			% nw nh px py
  end
} bind def

% Save the original routines so that we can use them later on
/oldfill	/fill load def
/oldeofill	/eofill load def
/oldstroke	/stroke load def
/oldshow	/show load def
/oldashow	/ashow load def
/oldwidthshow	/widthshow load def
/oldawidthshow	/awidthshow load def
/oldkshow	/kshow load def

% These defs are necessary so that subsequent procs don't bind in
% the originals
/fill	   { oldfill } bind def
/eofill	   { oldeofill } bind def
/stroke	   { oldstroke } bind def
/show	   { oldshow } bind def
/ashow	   { oldashow } bind def
/widthshow { oldwidthshow } bind def
/awidthshow { oldawidthshow } bind def
/kshow 	   { oldkshow } bind def
/PATredef {
  MyAppDict begin
    {
    /fill { /clip load PATdraw newpath } bind def
    /eofill { /eoclip load PATdraw newpath } bind def
    /stroke { PATstroke } bind def
    /show { 0 0 null 0 0 6 -1 roll PATawidthshow } bind def
    /ashow { 0 0 null 6 3 roll PATawidthshow }
    bind def
    /widthshow { 0 0 3 -1 roll PATawidthshow }
    bind def
    /awidthshow { PATawidthshow } bind def
    /kshow { PATkshow } bind def
  } {
    /fill   { oldfill } bind def
    /eofill { oldeofill } bind def
    /stroke { oldstroke } bind def
    /show   { oldshow } bind def
    /ashow  { oldashow } bind def
    /widthshow { oldwidthshow } bind def
    /awidthshow { oldawidthshow } bind def
    /kshow  { oldkshow } bind def
    } ifelse
  end
} bind def
false PATredef
% Conditionally define setcmykcolor if not available
/setcmykcolor where { pop } {
  /setcmykcolor {
    1 sub 4 1 roll
    3 {
	3 index add neg dup 0 lt { pop 0 } if 3 1 roll
    } repeat
    setrgbcolor - pop
  } bind def
} ifelse
/PATsc {		% colorarray
  aload length		% c1 ... cn length
    dup 1 eq { pop setgray } { 3 eq { setrgbcolor } { setcmykcolor
  } ifelse } ifelse
} bind def
/PATsg {		% dict
  begin
    lw setlinewidth
    lc setlinecap
    lj setlinejoin
    ml setmiterlimit
    ds aload pop setdash
    cc aload pop setrgbcolor
    cm setmatrix
  end
} bind def

/PATDict 3 dict def
/PATsp {
  true PATredef
  PATDict begin
    /CurrentPattern exch def
    % If it's an uncolored pattern, save the color
    CurrentPattern /PaintType get 2 eq {
      /PColor exch def
    } if
    /CColor [ currentrgbcolor ] def
  end
} bind def
% PATstroke - stroke with the current pattern
/PATstroke {
  countdictstack
  save
  mark
  {
    currentpoint strokepath moveto
    PATpcalc				% proc nw nh px py
    clip newpath PATfill
    } stopped {
	(*** PATstroke Warning: Path is too complex, stroking
	  with gray) =
    cleartomark
    restore
    countdictstack exch sub dup 0 gt
	{ { end } repeat } { pop } ifelse
    gsave 0.5 setgray oldstroke grestore
  } { pop restore pop } ifelse
  newpath
} bind def
/PATtcalc {		% modmtx tilingtype PATtcalc tilematrix
  % Note: tiling types 2 and 3 are not supported
  gsave
    exch concat					% tilingtype
    matrix currentmatrix exch			% cmtx tilingtype
    % Tiling type 1 and 3: constant spacing
    2 ne {
	% Distort the pattern so that it occupies
	% an integral number of device pixels
	dup 4 get exch dup 5 get exch		% tx ty cmtx
	XStep 0 dtransform
	round exch round exch			% tx ty cmtx dx.x dx.y
	XStep div exch XStep div exch		% tx ty cmtx a b
	0 YStep dtransform
	round exch round exch			% tx ty cmtx a b dy.x dy.y
	YStep div exch YStep div exch		% tx ty cmtx a b c d
	7 -3 roll astore			% { a b c d tx ty }
    } if
  grestore
} bind def
/PATusp {
  false PATredef
  PATDict begin
    CColor PATsc
  end
} bind def

% vertical bricks
11 dict begin
/PaintType 1 def
/PatternType 1 def
/TilingType 1 def
/BBox [0 0 1 1] def
/XStep 1 def
/YStep 1 def
/PatWidth 1 def
/PatHeight 1 def
/Multi 2 def
/PaintData [
  { clippath } bind
  { 16 16 true [ 16 0 0 -16 0 16 ]
	{<ff8080808080808080808080
	  8080808080ff808080808080
	  8080808080808080> }
        imagemask } bind
] def
/PaintProc {
	pop
	exec fill
} def
currentdict
end
/P8 exch def

/cp {closepath} bind def
/ef {eofill} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth} bind def
/tr {translate} bind def
/tnt {dup dup currentrgbcolor
  4 -2 roll dup 1 exch sub 3 -1 roll mul add
  4 -2 roll dup 1 exch sub 3 -1 roll mul add
  4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
  bind def
/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
  4 -2 roll mul srgb} bind def
 /DrawEllipse {
	/endangle exch def
	/startangle exch def
	/yrad exch def
	/xrad exch def
	/y exch def
	/x exch def
	/savematrix mtrx currentmatrix def
	x y tr xrad yrad sc 0 0 1 startangle endangle arc
	closepath
	savematrix setmatrix
	} def

/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def

$F2psBegin
%%Page: 1 1
10 setmiterlimit
 0.06299 0.06299 sc
% Polyline
15.000 slw
n 555 675 m 450 675 450 3720 105 arcto 4 {pop} repeat
  450 3825 6870 3825 105 arcto 4 {pop} repeat
  6975 3825 6975 780 105 arcto 4 {pop} repeat
  6975 675 555 675 105 arcto 4 {pop} repeat
 cp gs col31 s gr 
% Arc
n 1800.0 -821.0 2576.0 105.2 74.8 arcn
gs col0 s gr

% Arc
n 1800.0 4151.0 2576.0 -105.2 -74.8 arc
gs col0 s gr

% Arc
n 1800.0 349.0 2576.0 105.2 74.8 arcn
gs col0 s gr

% Arc
n 1800.0 5321.0 2576.0 -105.2 -74.8 arc
gs col0 s gr

% Ellipse
n 2700 2250 127 127 0 360 DrawEllipse gs col0 s gr

% Polyline
n 2475 2025 m 5625 2025 l 5625 2475 l 2475 2475 l
 cp gs col0 s gr 
% Polyline
n 2475 1575 m 2700 1575 l 2700 2025 l 2475 2025 l
 cp gs col0 s gr 
% Polyline
n 2475 2475 m 2700 2475 l 2700 2925 l 2475 2925 l
 cp gs col0 s gr 
% Polyline
7.500 slw
n 675 1125 m 1125 1125 l 1125 3375 l 675 3375 l
 cp gs /PC [[1.00 1.00 1.00] [0.00 0.00 0.00]] def
15.00 15.00 sc P8 [16 0 0 -16 45.00 75.00] PATmp PATsp ef gr PATusp gs col0 s gr 
% Polyline
15.000 slw
gs  clippath
2731 2196 m 2646 2281 l 2801 2436 l 2717 2267 l 2886 2351 l cp
eoclip
n 2700 2250 m
 3780 3330 l gs col1 s gr gr

% arrowhead
n 2886 2351 m 2717 2267 l 2801 2436 l 2886 2436 l 2886 2351 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
1746 1543 m 1831 1628 l 1986 1473 l 1817 1558 l 1901 1388 l cp
eoclip
n 1800 1575 m
 2250 1125 l gs col1 s gr gr

% arrowhead
n 1901 1388 m 1817 1558 l 1986 1473 l 1986 1388 l 1901 1388 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
1746 2668 m 1831 2753 l 1986 2598 l 1817 2683 l 1901 2513 l cp
eoclip
n 1800 2700 m
 3375 1125 l gs col1 s gr gr

% arrowhead
n 1901 2513 m 1817 2683 l 1986 2598 l 1986 2513 l 1901 2513 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
3996 1948 m 4081 2033 l 4236 1878 l 4067 1963 l 4151 1793 l cp
eoclip
n 4050 1980 m
 4905 1125 l gs col1 s gr gr

% arrowhead
n 4151 1793 m 4067 1963 l 4236 1878 l 4236 1793 l 4151 1793 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
gs  clippath
5818 1745 m 5903 1830 l 6058 1675 l 5889 1760 l 5973 1590 l cp
eoclip
n 5872 1777 m
 6524 1125 l gs col1 s gr gr

% arrowhead
n 5973 1590 m 5889 1760 l 6058 1675 l 6058 1590 l 5973 1590 l 
 cp gs col1 1.00 shd ef gr  col1 s
% Polyline
n 5625 1890 m 6345 1890 l 6345 2565 l 5625 2565 l
 cp gs col0 s gr 
/Times-BoldItalic ff 300.00 scf sf
3825 3645 m
gs 1 -1 sc (Pivot) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
2250 1080 m
gs 1 -1 sc (Muscle 1) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
3555 1080 m
gs 1 -1 sc (Muscle 2) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
4905 1080 m
gs 1 -1 sc (Bone) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-BoldItalic ff 300.00 scf sf
6480 1080 m
gs 1 -1 sc (Load) dup sw pop 2 div neg 0 rm  col1 sh gr
/Times-Roman ff 375.00 scf sf
5850 2295 m
gs 1 -1 sc (m) col0 sh gr
$F2psEnd
rs
end

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/LowerLeg1/LowerLeg1_rep.txt version [58be281b07].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system LowerLeg1 (Example1_rep.txt)
## Generated by MTT on" Thu Apr 19 10:26:57 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt LowerLeg1 abg tex			# The system description
mtt LowerLeg1 cbg ps 		        # The causal bond graph
mtt LowerLeg1 lbl txt
mtt Muscle1 lbl txt
mtt LowerLeg1 struc tex	        # The system structure
mtt LowerLeg1 sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt LowerLeg1 dae tex	        # The system dae
mtt LowerLeg1 ode tex	        # The system ode 
## mtt LowerLeg1 sspar tex		# Steady-state parameters
## mtt LowerLeg1 ss tex 		# Steady state
## mtt LowerLeg1 dm tex		# Descriptor matrices (of linearised system)
mtt LowerLeg1 sm tex		# State matrices (of linearised system)
mtt LowerLeg1 tf tex		# Transfer function (of linearised system)
## mtt LowerLeg1 lmfr ps		# log modulus of frequency response (of linearised system)
 mtt LowerLeg1 simpar tex		# Simulation parameters
 mtt LowerLeg1 numpar tex		# Numerical simulation parameters
## mtt LowerLeg1 state tex		# Simulation initial state
 mtt LowerLeg1 input tex		# Simulation input
## mtt LowerLeg1 logic tex		# Logic control
 mtt LowerLeg1 odeso ps		# Simulation output

mtt LowerLeg1 rep txt		# This file

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/Muscle1/Muscle1_abg.fig version [827c8ec540].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 4050 2700 3825 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2700 5850 2700 5625 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 2475 4275 1125 4500 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 2700 8550 2700 8325 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4275 4275 2925 4500 3150
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 4950 1575 4950 1575 450 9900 450 9900 4950
4 1 0 100 0 18 18 0.0000 4 195 150 4275 2790 1\001
4 2 4 100 0 18 18 0.0000 4 270 870 2610 2790 SS:[in]\001
4 1 0 100 0 18 18 0.0000 4 270 840 4455 945 R:d_m\001
4 1 0 100 0 18 18 0.0000 4 270 1170 6525 2790 CDx:c_m\001
4 0 4 100 0 18 18 0.0000 4 270 1065 8640 2790 SS:[out]\001
4 1 1 101 0 3 20 0.0000 4 210 1170 8055 3285 Extension\001
4 1 4 100 0 18 18 0.0000 4 270 810 4275 4545 SS:[F]\001
4 1 1 101 0 3 20 0.0000 4 270 3150 7875 4680 Simple linear muscle model\001
4 1 1 101 0 3 20 0.0000 4 210 1365 2340 3240 Connection\001
4 1 1 101 0 3 20 0.0000 4 270 1335 3015 4545 Force input\001

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/Muscle1/Muscle1_desc.tex version [dd9850e23d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Muscle1 (Muscle1_desc.tex)
% Generated by MTT on Thu Apr 19 10:39:29 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Muscle1} is
   displayed in Figure \Ref{fig:Muscle1_abg.ps} and its label
   file is listed in Section \Ref{sec:Muscle1_lbl}.
   The subsystems are listed in Section \Ref{sec:Muscle1_sub}.


This model is a highly simplified linear model of a muscle. The two
main components are:
\begin{itemize}
\item a \textbf{CDx} component representing the muscle compliance and
  also providing a measurement of muscle extension and
\item an \textbf{R} component representing mechanical damping in the muscle
\end{itemize}

The component has three ports:
\begin{description}
\item [in] representing the connection of the muscle to the outside world. The
  corresponding force corresponds to the sum of the muscle force and
  the reaction force of connected components.
\item[out] a measurement of the muscle extension.
\item[F] Representing the force component of the muscle model.
\end{description} 

Deleted mttroot/mtt/lib/comp/compound/Physiological/Movement/Muscles/Muscle1/Muscle1_lbl.txt version [c874229564].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Muscle1 (Muscle1_lbl.txt)
%SUMMARY Muscle1
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	F	F
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	c_m
%ALIAS	$2	d_m

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type CDx
	c_m	lin		c_m

% Component type R
	d_m	lin		flow,d_m

% Component type SS
	[F]	SS		external,external
	[in]	SS		external,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/O/O_abg.fig version [0c02cc0c9a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 6075 3645 6075 3420 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5760 3825 4410 4050 4635
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 6075 5400 6075 5175 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 3150 3645 3150 3420 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2835 3825 1485 4050 1710
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5400 3150 5175 3375
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 4185 SS:[B2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 6165 SS:[B3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 6165 SS:[B1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 6165 0\001
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 1260 SS:[A2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 3240 SS:[A3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 3240 SS:[A1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3240 0\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/O/O_lbl.txt version [8f92217838].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system O (O_lbl.txt)
%SUMMARY O Three-port zero junction for 2-bond vector bonds :-)
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:47:49  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	A1,B1
%ALIAS	out	A2,B2
%ALIAS	in_2|out_2	A3,B3

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[A1]	SS		external,external
	[A2]	SS		external,external
	[A3]	SS		external,external
	[B1]	SS		external,external
	[B2]	SS		external,external
	[B3]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/l/l_abg.fig version [d54e002ecd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 6075 3645 6075 3420 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5760 3825 4410 4050 4635
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 6075 5400 6075 5175 6300
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2295 3150 3645 3150 3420 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2835 3825 1485 4050 1710
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5400 3150 5175 3375
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 4185 SS:[B2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 6165 SS:[B3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 6165 SS:[B1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 6165 1\001
4 1 4 100 0 18 20 0.0000 4 285 1080 3870 1260 SS:[A2]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 6075 3240 SS:[A3]\001
4 1 4 100 0 18 20 0.0000 4 285 1080 1665 3240 SS:[A1]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3240 1\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/l/l_lbl.txt version [fe5dad5d52].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system l (l_lbl.txt)
%SUMMARY l Three port 1 junction with 2-bond vector ports :-)
%DESCRIPTIlN <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:49:49  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	A1,B1
%ALIAS	out	A2,B2
%ALIAS	in_2|out_2	A3,B3

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[A1]	SS		external,external
	[A2]	SS		external,external
	[A3]	SS		external,external
	[B1]	SS		external,external
	[B2]	SS		external,external
	[B3]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sAE/sAE_abg.fig version [75198870de].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 4050 9000 4050 8775 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 4050 10800 4050 10575 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 450 5625 450 5400 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 450 9000 450 8775 675
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2520 9225 3825 9225 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5625 3825 5625 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 225 3825 675
4 1 0 100 0 18 20 0.0000 4 210 1155 6660 4140 AE:sens\001
4 1 0 100 0 18 20 0.0000 4 195 150 9225 4140 1\001
4 1 0 100 0 18 20 0.0000 4 195 150 4050 540 0\001
4 1 0 100 0 18 20 0.0000 4 270 960 4050 2340 AE:k_s\001
4 1 0 100 0 18 20 0.0000 4 210 1320 6660 540 AE:actual\001
4 1 4 100 0 18 20 0.0000 4 270 1740 3060 4140 SS:[Sens_in]\001
4 1 4 100 0 18 20 0.0000 4 270 1935 12240 4140 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 270 2115 10575 585 SS:[Actual_out]\001
4 1 4 100 0 18 20 0.0000 4 270 1920 1170 585 SS:[Actual_in]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sAE/sAE_lbl.txt version [d9db7d23e5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sAE (sAE_lbl.txt)
%SUMMARY sAE
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	k
%ALIAS	$2	k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	actual		lin		k
	sens		lin		k
	k_s		lin		k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sAF/sAF_abg.fig version [53eaaab3d3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2430 180 2520 720
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2475 225 2475 675
-6
6 4230 3780 4320 4320
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4275 3825 4275 4275
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 4050 9000 4050 8775 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 4050 10800 4050 10575 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 450 5625 450 5400 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 450 9000 450 8775 675
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2520 9225 3825 9225 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
4 1 0 100 0 18 20 0.0000 4 285 1425 6660 4140 AF:sens\001
4 1 0 100 0 18 20 0.0000 4 270 195 9225 4140 0\001
4 1 0 100 0 18 20 0.0000 4 270 195 4050 540 1\001
4 1 0 100 0 18 20 0.0000 4 360 1215 4050 2340 AF:k_s\001
4 1 0 100 0 18 20 0.0000 4 285 1680 6660 540 AF:actual\001
4 1 4 100 0 18 20 0.0000 4 360 2280 3060 4140 SS:[Sens_in]\001
4 1 4 100 0 18 20 0.0000 4 360 2520 12240 4140 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 360 2775 10575 585 SS:[Actual_out]\001
4 1 4 100 0 18 20 0.0000 4 360 2535 1170 585 SS:[Actual_in]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sAF/sAF_lbl.txt version [a37eff47e5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sAF (sAF_lbl.txt)
%SUMMARY sAF
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	k
%ALIAS	$2	k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	actual		lin		k
	sens		lin		k
	k_s		lin		k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sC/sC_abg.fig version [b3dd4dbe30].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
2 4 0 3 31 7 101 0 -1 0.000 0 0 11 0 0 5
	 9000 4725 1350 4725 1350 2253 9000 2253 9000 4725
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 450 4950 3465 C:c\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sC/sC_lbl.txt version [b25645ac14].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sC (sC_lbl.txt)
%SUMMARY sC Sensitivity C component
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	effort,c
%ALIAS	$2	cs

%CR alias
%ALIAS $1 slin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	c	slin 	effort,c;cs

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external



Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sCS/sCS_abg.fig version [9878162dec].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 6 100 0 18 20 0.0000 4 271 196 2476 4186 [1,2]\001
4 1 0 100 0 18 20 0.0000 4 270 195 2476 4185 1\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 2700 4275
4 1 0 100 0 18 20 0.0000 4 285 570 2475 2295 sC:c\001
4 0 0 100 0 18 20 0.0000 4 360 1185 4185 4185 sSe:e_0\001
4 1 6 100 0 18 20 0.0000 4 361 1186 2476 6031 [1,2]\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2476 6030 SS:[in]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sCS/sCS_lbl.txt version [da775c33bd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sCS (sCS_lbl.txt)
%SUMMARY sCS C component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:31:35  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in_1,in_2

% Argument aliases
%ALIAS	$1	effort,c
%ALIAS	$2	e_0
%ALIAS	$3	c_s
%ALIAS	$4	e_0s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c		slin	effort,c;c_s

% Component type SS
	[in]	 SS	external,external

% Component type Se
	e_0		SS	e_0;e_0s


Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sCT/sCT_abg.fig version [6a3e472415].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2700 5625 2700 5400 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 3825 6525 1575 900 1575 900 3825 6525 3825
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2475 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3105 S\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2835 .\001
4 2 6 0 0 0 20 0.0000 4 240 510 1981 2791 [1,2]\001
4 2 4 0 0 0 20 0.0000 4 240 810 1981 2790 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 735 3825 2790 sFP:fp\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2475 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 4950 3105 Q\001
4 1 1 1 0 3 20 0.0000 4 195 165 4950 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 4995 2835 .\001
4 1 -1 0 0 0 20 0.0000 4 195 495 5940 2790 sC:c\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sCT/sCT_lbl.txt version [4492e9a698].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY sCT Sensitivity version of Continuous-Time (thermal C) component

## System sCT, representation lbl, language txt
## File sCT_lbl.txt
## Generated by MTT on Fri Jul  6 05:16:27 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in	in_1,in_2

## Argument aliases
#ALIAS	$1	effort,c
#ALIAS	$2	cs

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[in]	SS		external,external		

## Component type C
	c	slin		effort,c;cs		

## Component type FP
	fp	lin		

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sCT/sCT_rep.txt version [b85aacdbc1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sCT (sCT_rep.txt)
## Generated by MTT on" Fri Jul  6 05:27:38 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sCT abg tex			# The system description
##mtt sCT cbg ps 		        # The causal bond graph
mtt sCT struc tex	        # The system structure
mtt sCT sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sCT dae tex	        # The system dae
## mtt sCT ode tex	        # The system ode 
## mtt sCT sspar tex		# Steady-state parameters
## mtt sCT ss tex 		# Steady state
## mtt sCT dm tex		# Descriptor matrices (of linearised system)
## mtt sCT sm tex		# State matrices (of linearised system)
## mtt sCT tf tex		# Transfer function (of linearised system)
## mtt sCT lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sCT simpar tex		# Simulation parameters
## mtt sCT numpar tex		# Numerical simulation parameters
## mtt sCT state tex		# Simulation initial state
## mtt sCT input tex		# Simulation input
## mtt sCT logic tex		# Logic control
## mtt sCT odeso ps		# Simulation output

## mtt sCT rep txt		# This file

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sDC/sDC_abg.fig version [89b1252cd5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2036 2724 3371 2724 3063 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3836 2700 5171 2700 4863 2923
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5421 2501 5421 1342 5678 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8501 2724 9836 2724 9528 2947
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11325 4730 11325 494 8758 494 8758 4730 11325 4730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5672 2700 7006 2700 6698 2923
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 4725 6300 494 2293 494 2293 4725 6300 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2501 3600 1342 3857 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11886 2546 11886 1386 12143 1654
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12143 2724 13478 2724 13170 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10041 2546 10041 1386 10298 1654
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10298 2724 11633 2724 11325 2947
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15750 5175 45 5175 45 316 15750 316 15750 5175
4 2 4 0 0 0 20 0.0000 4 255 1815 1980 2790 SS:[Electrical]\001
4 1 1 1 0 0 23 0.0000 4 240 1395 1472 3170 Terminals\001
4 1 -1 0 0 0 23 0.0000 4 240 90 5370 2858 l\001
4 1 -1 0 0 0 23 0.0000 4 285 1365 7783 2813 sGY:k_m\001
4 1 -1 0 0 0 23 0.0000 4 285 765 5370 1252 sI:l_a\001
4 1 1 1 0 0 23 0.0000 4 240 1290 5421 5043 Electrical\001
4 1 1 1 0 0 23 0.0000 4 240 1605 10041 5043 Mechanical\001
4 1 -1 0 0 0 23 0.0000 4 240 90 3600 2835 l\001
4 1 -1 0 0 0 23 0.0000 4 270 900 3645 1260 sR:r_a\001
4 1 4 100 0 18 4 0.0000 4 75 270 3780 2475 [out_2]\001
4 1 4 100 0 18 4 0.0000 4 75 270 5580 2475 [out_2]\001
4 1 -1 0 0 0 23 0.0000 4 240 90 11880 2835 l\001
4 1 4 100 0 18 4 0.0000 4 75 270 11745 2475 [out_2]\001
4 1 -1 0 0 0 23 0.0000 4 300 885 10144 1252 sI:j_m\001
4 1 -1 0 0 0 23 0.0000 4 240 90 10035 2835 l\001
4 1 4 100 0 18 4 0.0000 4 75 270 9900 2475 [out_2]\001
4 1 -1 0 0 0 23 0.0000 4 285 1080 11880 1260 sR:b_m\001
4 0 4 0 0 0 20 0.0000 4 255 2055 13635 2790 SS:[Mechanical]\001
4 1 1 1 0 0 23 0.0000 4 240 735 12645 3150 Shaft\001
4 1 4 100 0 18 16 0.0000 4 225 480 2115 2520 [1,2]\001
4 1 4 100 0 18 16 0.0000 4 225 480 13365 2565 [1,2]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sDC/sDC_desc.tex version [465a6a54c1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system sDC (sDC_desc.tex)
% Generated by MTT on Thu Sep 11 10:09:58 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sDC} is
   displayed in Figure \Ref{sDC_abg} and its label
   file is listed in Section \Ref{sec:sDC_lbl}.
   The subsystems are listed in Section \Ref{sec:sDC_sub}.

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|}
        \hline
        Index & Parameter\\
        \hline
         1 & Motor gain ($k_m$) \\
         2 & Armature inductance ($l_a$) \\
         3 & Armature resistance ($r_a$) \\
         4 & Inertia ($j_m$) \\
         5 & Friction coefficient ($b_m$) \\
        \hline
       \end{tabular}
       \caption{sDC motor parameters}
       \label{tab:sDC_components}
     \end{center}
   \end{table}
{\bf sDC} is a two(vector)-port component representing a DC  motor and its
sensitivity functions. It has the 5
parameters listed in Table \Ref{tab:sDC_components}.


Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sDC/sDC_lbl.txt version [70aedeb957].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sDC (sDC_lbl.txt)
%SUMMARY sDC
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in		Electrical_1,Electrical_2
%ALIAS	out		Mechanical_1,Mechanical_2

% Argument aliases
%ALIAS $1	k_m
%ALIAS $2	l_a
%ALIAS $3	r_a
%ALIAS $4	j_m
%ALIAS $5	b_m

%ALIAS $6	k_ms
%ALIAS $7	l_as
%ALIAS $8	r_as
%ALIAS $9	j_ms
%ALIAS $10	b_ms

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[Electrical]	SS		external,external
	[Mechanical]	SS		external,external

% Component type sGY
	k_m	        lin		flow,k_m;k_ms

% Component type sI
	j_m		lin		flow,j_m;j_ms
	l_a		lin		flow,l_a;l_as

% Component type sR
	b_m		lin		flow,b_m;b_ms
	r_a		lin		flow,r_a;r_as


Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sDe/sDe_abg.fig version [fe2c89039d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
4 1 0 100 0 18 20 0.0000 4 270 1110 1485 2115 SS:ss_2\001
4 1 0 100 0 18 20 0.0000 4 270 1110 1485 1440 SS:ss_1\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4545 1440 SS:[port_1]\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4500 2115 SS:[port_2]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sDe/sDe_lbl.txt version [10df3ea2fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sDe (sDe_lbl.txt)
%SUMMARY sDe Sensitivity version of Effort detector (De)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:53:34  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS $1 external

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external
	ss_1		SS		external,0
	ss_2		SS		external,0

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sDf/sDf_abg.fig version [795b94a9b4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 900 1215 2070 1530
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 1440 SS:ss_1\001
-6
6 900 1890 2070 2205
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 2115 SS:ss_2\001
-6
6 2205 1305 3645 1620
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
-6
6 2205 1980 3645 2295
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
-6
6 3735 1215 5355 1530
4 1 4 100 0 18 20 0.0000 4 300 1620 4545 1440 SS:[port_1]\001
-6
6 3690 1890 5310 2205
4 1 4 100 0 18 20 0.0000 4 300 1620 4500 2115 SS:[port_2]\001
-6

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sDf/sDf_lbl.txt version [55d304bd19].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sDf (sDf_lbl.txt)
%SUMMARY sDf Sensitivity version of Effort detector (De)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/09/07 05:32:17  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/07/29 04:53:34  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS $1 external

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external
	ss_1		SS		0,external
	ss_2		SS		0,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sEMTF/sEMTF_abg.fig version [06c2007d04].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 7155 2295 7695
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 7200 2250 7650
-6
6 3510 4005 4050 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4005 4050 3555 4050
-6
6 3645 5850 4185 5940
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4140 5895 3690 5895
-6
6 8730 5355 9270 5445
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9225 5400 8775 5400
-6
6 3600 7155 4140 7245
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4095 7200 3645 7200
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 7425 3600 7425 3375 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 7425 5400 7425 5175 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 7425 8775 7425 8550 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 7425 10575 7425 10350 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 3600 3825 3375 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3825 5400 3825 5175 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 3825 8775 3825 8550 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 3825 10575 3825 10350 4050
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5895 9000 7200 9000 6975
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9006 5873 3831 7178 3831 6953
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 450 6300 1800 6525 1575
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2250 6300 3600 6525 3375
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 1800 6525 1800
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 2025 4275 2025 4275 5400 4500 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 3825 5400 4050 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4050 9000 5400 9225 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 2250 6525 7200 6750 6975
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 2025 8550 2025 8550 5400 8775 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 8550 9225 8550 9225 5850 9450 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 8550 3600 8550 3600 5850 3375 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 10125 6300 8775 6525 9000
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 8775 6525 8775
4 1 4 100 0 18 20 0.0000 4 285 2415 6210 360 SS:[Actual_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6300 2115 0\001
4 1 4 100 0 18 20 0.0000 4 285 1845 1215 7515 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 7515 1\001
4 1 0 100 0 18 20 0.0000 4 225 1590 6435 7515 EMTF:sens\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 7515 0\001
4 1 4 100 0 18 20 0.0000 4 285 2040 11790 7515 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 285 2055 1215 3915 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3915 1\001
4 1 0 100 0 18 20 0.0000 4 225 1785 6435 3915 EMTF:actual\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 3915 0\001
4 1 4 100 0 18 20 0.0000 4 285 2250 11790 3915 SS:[Actual_out]\001
4 1 0 100 0 18 20 0.0000 4 225 1170 8955 5715 AE3:ae3\001
4 1 0 100 0 18 20 0.0000 4 225 1095 3825 5715 AF3:af3\001
4 2 4 100 0 18 14 0.0000 4 210 600 6255 3600 [mod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 6435 7155 [mod]\001
4 1 4 100 0 18 20 0.0000 4 285 2205 6300 10395 SS:[Sens_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6345 8640 0\001
4 2 4 100 0 18 14 0.0000 4 210 720 3420 5985 [smod]\001
4 0 4 100 0 18 14 0.0000 4 210 720 9540 5940 [smod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 8505 5355 [mod]\001
4 0 4 100 0 18 14 0.0000 4 210 600 4455 5400 [mod]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sEMTF/sEMTF_lbl.txt version [974b4d5e9f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sEMTF (sEMTF_lbl.txt)
%SUMMARY sEMTF Effort modulated TF - sensitivity version
%DESCRIPTION It is assumed that no sensitivity parameter is associated
%DESCRIPTION with this component.
%DESCRIPTION This is a built out of EMTFs and the 4 port AE3 component
%DESCRIPTION There is one argument alias - the transformer (flow) gain 
%DESCRIPTION There are two CR aliases: one for the EMTF and one for
%DESCRIPTION the AE3
%DESCRIPTION Examples:
%DESCRIPTION   lin;slin  n
%DESCRIPTION   lsin;slsin l
%DESCRIPTION   lcos;slcos l



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/04/17 18:50:35  gawthrop
% %% Sensitivity EMTF components
% %%
% %% Revision 1.1  2000/12/28 17:29:10  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out
%ALIAS	mod	Actual_mod,Sens_mod


% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	lsin
%ALIAS	$2	slsin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type EMTF
	actual		lsin	flow,l
	sens		lsin	flow,l

% Component type AE3 (????NB NEGATIVE GAIN HERE!!!!)
	ae3             slsin   l

% Component type AF3
	af3             slsin   l

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Actual_mod]	SS		external,internal
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external
	[Sens_mod]	SS		external,internal



Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_abg.fig version [853ebbe17a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 675 4050 675 3825 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1350 4050 1350 3825 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 1125 4050 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 450 4050 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 675 4725 675 4950 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 1350 4725 1350 4950 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8100 675 6750 675 6975 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8100 1350 6750 1350 6975 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8100 450 8100 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8100 1125 8100 1575
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 1800 1350 1800 1350 225 9900 225 9900 1800
4 1 4 100 0 18 18 0.0000 4 270 870 2115 765 SS:[In]\001
4 1 4 100 0 18 18 0.0000 4 270 1020 2115 1395 SS:[sIn]\001
4 1 0 100 0 18 24 0.0000 4 285 510 4410 1125 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 540 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 1215 [4]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 1215 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 540 [1]\001
4 1 0 100 0 18 18 0.0000 4 210 375 6390 765 AF\001
4 1 0 100 0 18 18 0.0000 4 210 375 6390 1440 AF\001
4 1 4 100 0 18 18 0.0000 4 270 1230 8820 765 SS:[Mod]\001
4 1 4 100 0 18 18 0.0000 4 270 1380 8865 1440 SS:[sMod]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_cr.r version [24ddbdd6a4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% CR file for sFMR
%% Just for flow input definition of r, ie must use with flow,r;k_s
in "$MTT_CRS/r/slin.cr";

OPERATOR sFMR;

% Ordinary FMR port
FOR ALL gain_cause,r,k_s,out_cause,in,sin,in_cause,modu,smodu
LET sFMR(gain_cause,r,k_s,out_cause,1,
	in,in_cause,1,
	sin,in_cause,2,
	modu,flow,3,
	smodu,flow,4
	) 
        = slin(gain_cause,r*modu,k_s,out_cause,1,
               in,in_cause,1,
               sin,in_cause,2);

% Sensitivity FMR port - effort input
FOR ALL r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(flow,r,k_s,out_cause,2,
	inp,effort,1,
	sinp,effort,2,
	modu,flow,3,
	smodu,flow,4
	)
        = (
          slin(flow,r,k_s,out_cause,2,
               inp/modu,effort,1,
               sinp/modu,effort,2)
        - smodu*(1/(r*(modu^2))) 
        );

% Sensitivity FMR port - flow input
FOR ALL r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(flow,r,k_s,out_cause,2,
	inp,flow,1,
	sinp,flow,2,
	modu,flow,3,
	smodu,flow,4
	) 
	= (
          slin(flow,r,k_s,out_cause,2,
               inp*modu,flow,1,
               sinp*modu,flow,2)
        + r*inp*smodu
        );

% Modulation port
FOR ALL gain_cause,r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(gain_cause,r,k_s,out_cause,3,
	inp,inp_cause,1,
	sinp,inp_cause,2,
	modu,flow,3,
	smodu,flow,4
	) 
        = 0;

% Sensitivity modulation port
FOR ALL gain_cause,r,k_s,out_cause,inp,sinp,inp_cause,modu,smodu
LET sFMR(gain_cause,r,k_s,out_cause,4,
	inp,inp_cause,1,
	sinp,inp_cause,2,
	modu,flow,3,
	smodu,flow,4
	) 
        = 0;
END;

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_desc.tex version [eee4a49ecd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system sFMR (sFMR_desc.tex)
% Generated by MTT on Thu Jul 5 23:47:35 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sFMR} is
   displayed in Figure \Ref{fig:sFMR_abg.ps} and its label
   file is listed in Section \Ref{sec:sFMR_lbl}.
   The subsystems are listed in Section \Ref{sec:sFMR_sub}.


This is the sensitivity version of the \textbf{FMR} (flow-modulated
resistor) component.

In the linear case, the CR of the standard port is:
\begin{equation}
  e = mrf
\end{equation}
where $e$ is the effort, $m$ the (flow) modulation, $r$ the
``resistance'' and $f$ the flow.

The corresponding sensitivity CR is:
\begin{equation}
  e^\prime  = m^\prime rf + mr^\prime f + mrf^\prime
\end{equation}

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_lbl.txt version [a614981b1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY sFMR Sensitivity version of FMR (Flow-modulated R)

## System sFMR, representation lbl, language txt
## File sFMR_lbl.txt
## Generated by MTT on Thu Jul  5 04:45:59 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in	In,sIn
#ALIAS	out	Mod,sMod


## Argument aliases
#ALIAS	$1	flow,r
#ALIAS	$2	k_s

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	r	sFMR		flow,r,k_s		

## Component type SS
	[In]	SS		external,external		
	[sIn]	SS		external,external		
	[Mod]	SS		external,external		
	[sMod]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFMR/sFMR_rep.txt version [5d2ba7f5ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sFMR (sFMR_rep.txt)
## Generated by MTT on" Thu Jul  5 23:56:36 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sFMR abg tex			# The system description
mtt sFMR cr  tex			# The CR
##mtt sFMR cbg ps 		        # The causal bond graph
mtt sFMR struc tex	        # The system structure
mtt sFMR sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sFMR dae tex	        # The system dae
## mtt sFMR ode tex	        # The system ode 
## mtt sFMR sspar tex		# Steady-state parameters
## mtt sFMR ss tex 		# Steady state
## mtt sFMR dm tex		# Descriptor matrices (of linearised system)
## mtt sFMR sm tex		# State matrices (of linearised system)
## mtt sFMR tf tex		# Transfer function (of linearised system)
## mtt sFMR lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sFMR simpar tex		# Simulation parameters
## mtt sFMR numpar tex		# Numerical simulation parameters
## mtt sFMR state tex		# Simulation initial state
## mtt sFMR input tex		# Simulation input
## mtt sFMR logic tex		# Logic control
## mtt sFMR odeso ps		# Simulation output

## mtt sFMR rep txt		# This file

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFP/sFP_abg.fig version [98a0a6cf36].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 675 4050 675 3825 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1350 4050 1350 3825 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 675 6075 675 5850 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 1350 6075 1350 5850 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 1125 2700 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2700 450 2700 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 450 4725 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 1125 4725 1575
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 7875 1800 1350 1800 1350 225 7875 225 7875 1800
4 1 4 100 0 18 18 0.0000 4 270 810 2115 765 SS:[F]\001
4 1 4 100 0 18 18 0.0000 4 270 960 2115 1395 SS:[sF]\001
4 1 4 100 0 18 18 0.0000 4 270 960 6885 1440 SS:[sP]\001
4 1 0 100 0 18 24 0.0000 4 285 510 4410 1125 R:r\001
4 1 4 100 0 18 18 0.0000 4 270 810 6840 765 SS:[P]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 540 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 1215 [4]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 1215 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 540 [1]\001
4 1 1 101 0 3 20 0.0000 4 195 165 3195 945 S\001
4 1 1 101 0 3 20 0.0000 4 240 210 5535 945 Q\001
4 1 1 101 0 3 20 0.0000 4 195 165 3195 450 T\001
4 1 1 101 0 3 20 0.0000 4 195 135 3330 585 1\001
4 1 1 101 0 3 20 0.0000 4 195 165 5445 450 T\001
4 1 1 101 0 3 20 0.0000 4 195 135 5580 585 2\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFP/sFP_cr.r version [4727041a69].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% CR file for sFP

OPERATOR sFP;

% Entropy flow in

% Ordinary FP port
% Temperature
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(effort,1,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	) 
        = Temperature;

% Heat
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(flow,2,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	)
        = Entropy*Temperature;

% Temperature sensitivity
% Sensitivity  FP port
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(effort,3,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	) 
        = sTemperature;

% Heat sensitivity
FOR ALL Entropy,Temperature,sEntropy,sTemperature
LET sFP(flow,4,
	Entropy,flow,1,
	Temperature,effort,2,
	sEntropy,flow,3,
	sTemperature,effort,4
	) 
        = (Entropy*sTemperature + sEntropy*Temperature);

% Heat flow in

% Ordinary FP port
% Temperature
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(effort,2,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = Temperature;

% Heat
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(flow,1,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = Heat/Temperature;

% Temperature sensitivity
% Sensitivity  FP port
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(effort,4,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = sTemperature;

% Heat sensitivity
FOR ALL Heat,Temperature,sHeat,sTemperature
LET sFP(flow,3,
	Temperature,effort,1,
	Heat,flow,2,
	sTemperature,effort,3,
	sHeat,flow,4
	) 
        = (sHeat*Temperature - Heat*sTemperature)/Temperature^2;
END;

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFP/sFP_desc.tex version [5a88ca8029].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system sFP (sFP_desc.tex)
% Generated by MTT on Fri Jul 6 01:55:23 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sFP} is
   displayed in Figure \Ref{fig:sFP_abg.ps} and its label
   file is listed in Section \Ref{sec:sFP_lbl}.
   The subsystems are listed in Section \Ref{sec:sFP_sub}.

This is the sensitivity version of the \textbf{FP} (flow/power
real-pseuso component).

The standard ports implement the CR:
\begin{align}
  T_1 &= T_2 \\
  Q &= S*T_2
\end{align}

The \emph{sensitivity} ports implement the CR:
\begin{align}
  T_1^\prime &= T_2^\prime \\
  Q^\prime &= S^\prime *T_2 + S*T_2^\prime
\end{align}

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFP/sFP_lbl.txt version [0db9ba715f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY sFP Sensitivity version of FP - real-pseudo conversion

## System sFP, representation lbl, language txt
## File sFP_lbl.txt
## Generated by MTT on Thu Jul  5 08:03:02 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in|f    F,sF
#ALIAS	out|p   P,sP


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	r       sFP

## Component type SS
	[F]	SS		external,external		
	[P]	SS		external,external		
	[sF]	SS		external,external		
	[sP]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sFP/sFP_rep.txt version [6d67192426].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sFP (sFP_rep.txt)
## Generated by MTT on" Fri Jul  6 02:04:19 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sFP abg tex			# The system description
mtt sFP cr tex			# The system description
##mtt sFP cbg ps 		        # The causal bond graph
mtt sFP struc tex	        # The system structure
mtt sFP sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sFP dae tex	        # The system dae
## mtt sFP ode tex	        # The system ode 
## mtt sFP sspar tex		# Steady-state parameters
## mtt sFP ss tex 		# Steady state
## mtt sFP dm tex		# Descriptor matrices (of linearised system)
## mtt sFP sm tex		# State matrices (of linearised system)
## mtt sFP tf tex		# Transfer function (of linearised system)
## mtt sFP lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sFP simpar tex		# Simulation parameters
## mtt sFP numpar tex		# Numerical simulation parameters
## mtt sFP state tex		# Simulation initial state
## mtt sFP input tex		# Simulation input
## mtt sFP logic tex		# Logic control
## mtt sFP odeso ps		# Simulation output

## mtt sFP rep txt		# This file

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sGY/sGY_abg.fig version [45c2af76d2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 1125 3825 1125 3600 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 450 6525 450 6300 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 1125 6525 1125 6300 1350
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 450 8550 450 8325 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7200 1125 8550 1125 8325 1350
4 1 4 100 0 18 20 0.0000 4 270 1920 1440 540 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 210 960 4545 855 sTF:stf\001
4 1 4 100 0 18 20 0.0000 4 270 1740 1440 1215 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 210 420 6840 540 GY\001
4 1 0 100 0 18 20 0.0000 4 210 420 6840 1215 GY\001
4 1 4 100 0 18 20 0.0000 4 270 2115 9765 540 SS:[Actual_out]\001
4 1 4 100 0 18 20 0.0000 4 270 1935 9765 1215 SS:[Sens_out]\001
4 1 4 100 0 18 14 0.0000 4 210 1125 3825 315 [Actual_in]\001
4 1 4 100 0 18 14 0.0000 4 210 1275 5175 315 [Actual_out]\001
4 1 4 100 0 18 14 0.0000 4 210 1140 5175 1575 [Sens_out]\001
4 1 4 100 0 18 14 0.0000 4 210 990 3870 1575 [Sens_in]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sGY/sGY_lbl.txt version [2cd97b9fb4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sGY (sGY_lbl.txt)
%SUMMARY sGY GY component with sensitivity ports
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	flow,k
%ALIAS	$2	k_s

%ALIAS	$1	lin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type sTF
        stf		lin		flow,k;k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sI/sI_abg.fig version [0b170eafdf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
2 4 0 3 31 7 101 0 -1 0.000 0 0 11 0 0 5
	 9000 4725 1350 4725 1350 2253 9000 2253 9000 4725
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 390 4950 3465 I:m\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sI/sI_lbl.txt version [c893be13e2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sI (sI_lbl.txt)
%SUMMARY sI Sensitivity I component
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	flow,m
%ALIAS	$2	ms

%CR alias
%ALIAS $1 slin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m	slin 	flow,m;ms

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external



Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sINTF/sINTF_abg.fig version [2b8dc82992].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2925 3150 2925 2925 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2250 3150 2250 2925 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2925 6300 2925 6075 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2250 6300 2250 6075 2475
4 1 4 100 0 18 20 0.0000 4 270 1200 990 3015 SS:[in_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1200 990 2340 SS:[in_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1455 4050 3015 INTF:intf_2\001
4 1 0 100 0 18 20 0.0000 4 270 1455 4050 2340 INTF:intf_1\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 3015 SS:[out_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 2340 SS:[out_1]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sINTF/sINTF_lbl.txt version [123e35cee2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sINTF (sINTF_lbl.txt)
%SUMMARY sINTF Sensitivity version of INTF
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:32:30  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in_1,in_2
%ALIAS	out	out_1,out_2

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type INTF
	intf_1
	intf_2

% Component type SS
	[in_1]	SS		external,external
	[in_2]	SS		external,external
	[out_1]	SS		external,external
	[out_2]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sINTFS/sINTFS_abg.fig version [3245e72115].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2925 3150 2925 2925 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1800 2250 3150 2250 2925 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2925 6300 2925 6075 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2250 6300 2250 6075 2475
4 1 4 100 0 18 20 0.0000 4 270 1200 990 3015 SS:[in_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1200 990 2340 SS:[in_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1650 4050 3015 INTFS:intf_2\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 3015 SS:[out_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1395 7245 2340 SS:[out_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1650 4095 2340 INTFS:intf_1\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sINTFS/sINTFS_lbl.txt version [f58d20ad1f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sINTFS (sINTFS_lbl.txt)
%SUMMARY sINTFS Sensitivity version of INTF with initial state
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:32:30  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in_1,in_2
%ALIAS	out	out_1,out_2

% Argument aliases
%ALIAS	$1      e_0
%ALIAS	$2      k_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type INTFS
	intf_1    none	e_0
	intf_2    none  k_s

% Component type SS
	[in_1]	SS		external,external
	[in_2]	SS		external,external
	[out_1]	SS		external,external
	[out_2]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sIS/sIS_abg.fig version [afb2e2fe02].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
2 4 0 2 31 7 52 0 -1 0.000 0 0 7 0 0 5
	 6075 6300 6075 1350 1125 1350 1125 6300 6075 6300
4 1 0 100 0 18 20 0.0000 4 210 405 2475 2295 sI:i\001
4 0 0 100 0 18 20 0.0000 4 270 960 4185 4185 sSf:f_0\001
4 1 6 100 0 18 20 0.0000 4 270 555 2476 6031 [1,2]\001
4 1 4 100 0 18 20 0.0000 4 270 900 2476 6030 SS:[in]\001
4 1 6 100 0 18 20 0.0000 4 270 555 2476 4186 [1,2]\001
4 1 0 100 0 18 20 0.0000 4 195 150 2476 4185 0\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sIS/sIS_lbl.txt version [f0aeba0ddf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sIS (sIS_lbl.txt)
%SUMMARY sIS
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:29:10  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Port aliases
%ALIAS	in	in_1,in_2

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0
%ALIAS	$3	i_s
%ALIAS	$4	f_0s

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[in]	SS		external,external

% Component type sI
	i       slin             flow,i;i_s

% Component type sSf
	f_0     SS	        f_0;f_0s

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sR/sR_abg.fig version [1cfa4eb3a3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
2 4 0 3 31 7 101 0 -1 0.000 0 0 11 0 0 5
	 9000 4725 1350 4725 1350 2253 9000 2253 9000 4725
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 390 4950 3465 R:r\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sR/sR_lbl.txt version [e03a82f71c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sR (sR_lbl.txt)
%SUMMARY sR Sensitivity R component
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	flow,r
%ALIAS	$2	rs

%CR alias
%ALIAS $1 slin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	r	slin 	flow,r;rs

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external



Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sRS/sRS_abg.fig version [530171f10a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 675 4050 675 3825 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1350 4050 1350 3825 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 1125 4050 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 450 4050 900
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 1800 1350 1800 1350 225 9900 225 9900 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 675 6075 675 5850 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 1350 6075 1350 5850 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 1125 4725 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 450 4725 900
4 1 4 100 0 18 18 0.0000 4 270 870 2115 765 SS:[In]\001
4 1 4 100 0 18 18 0.0000 4 270 1020 2115 1395 SS:[sIn]\001
4 1 0 100 0 18 24 0.0000 4 285 510 4410 1125 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 540 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 4860 1215 [4]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 1215 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 3870 540 [1]\001
4 1 4 100 0 18 18 0.0000 4 270 1230 6795 765 SS:[Out]\001
4 1 4 100 0 18 18 0.0000 4 270 1380 6885 1440 SS:[sOut]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sRS/sRS_cr.r version [5c21ad435b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% CR file for sFMR
%% Just for flow input definition of r, ie must use with flow,r;k_s

in "$MTT_CRS/r/slin.cr"; %% make sure CR slin is there

OPERATOR sRS;

% Ordinary RS port
% R component
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,1,
	inp,in_cause,1,
	temp,effort,2,
	sinp,in_cause,3,
	stemp,effort,4
	) 
        = lin(gain_cause,r,temp_cause,1,
               inp,in_cause,1);
% Entropy flow 
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,2,
	inp,in_cause,1,
	temp,effort,2,
	sinp,in_cause,3,
	stemp,effort,4
	) 
        = inp*lin(gain_cause,r,temp_cause,1,
               inp,in_cause,1)/temp;

% Sensitivity ports
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,3,
	inp,in_cause,1,
	temp,effort,2,
	sinp,in_cause,3,
	stemp,effort,4
	) 
        = slin(gain_cause,r,rs,temp_cause,2,
               inp,in_cause,1,
               sinp,in_cause,2
        );

%% Sensitivity entropy flow
%% - flow in
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,4,
	inp,flow,1,
	temp,effort,2,
	sinp,flow,3,
	stemp,effort,4
	) 
        = 2*inp*sinp*r/temp
        + (inp^2)*rs/temp
        - (inp^2)*r*stemp/(temp^2);

%% - effort in
FOR ALL gain_cause,r,rs,out_cause,inp,sinp,in_cause,temp,stemp
LET sRS(gain_cause,r,rs,out_cause,4,
	inp,effort,1,
	temp,effort,2,
	sinp,effort,3,
	stemp,effort,4
	) 
        = 2*inp*sinp/(r*temp)
        - (inp^2)*rs/((r^2)*temp)
        - (inp^2)*stemp/(r*temp^2);

END;

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sRS/sRS_desc.tex version [891b367d21].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system sRS (sFMR_desc.tex)
% Generated by MTT on Thu Jul 5 23:47:35 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/07/06 01:17:14  gawthrop
% %% New sensitivity components (for extruder model)
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sRS} is
   displayed in Figure \Ref{fig:sFMR_abg.ps} and its label
   file is listed in Section \Ref{sec:sFMR_lbl}.
   The subsystems are listed in Section \Ref{sec:sFMR_sub}.


This is the sensitivity version of the \textbf{FMR} (flow-modulated
resistor) component.

In the linear case, the CR of the standard port is:
\begin{equation}
  e = mrf
\end{equation}
where $e$ is the effort, $m$ the (flow) modulation, $r$ the
``resistance'' and $f$ the flow.

The corresponding sensitivity CR is:
\begin{equation}
  e^\prime  = m^\prime rf + mr^\prime f + mrf^\prime
\end{equation}

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sRS/sRS_lbl.txt version [fbf7e22063].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY sRS Sensitivity version of RS

## System sRS, representation lbl, language txt

## Port aliases
#ALIAS	in	In,sIn
#ALIAS	out	Out,sOut


## Argument aliases
#ALIAS	$1	flow,r
#ALIAS	$2	rs

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type R
	r	sRS		flow,r;rs		

## Component type SS
	[In]	SS		external,external		
	[sIn]	SS		external,external		
	[Out]	SS		external,external		
	[sOut]	SS		external,external		

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sRS/sRS_rep.txt version [a8fe94a22d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sRS (sFMR_rep.txt)
## Generated by MTT on" Thu Jul  5 23:56:36 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/07/06 01:18:24  gawthrop
## New sensitivity components - documentation
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt sRS abg tex			# The system description
mtt sRS cr  tex			# The CR
##mtt sRS cbg ps 		        # The causal bond graph
mtt sRS struc tex	        # The system structure
mtt sRS sympar tex	        # The system parameters
## Uncomment the following lines or add others
mtt sRS dae tex	        # The system dae
## mtt sRS ode tex	        # The system ode 
## mtt sRS sspar tex		# Steady-state parameters
## mtt sRS ss tex 		# Steady state
## mtt sRS dm tex		# Descriptor matrices (of linearised system)
## mtt sRS sm tex		# State matrices (of linearised system)
## mtt sRS tf tex		# Transfer function (of linearised system)
## mtt sRS lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sRS simpar tex		# Simulation parameters
## mtt sRS numpar tex		# Numerical simulation parameters
## mtt sRS state tex		# Simulation initial state
## mtt sRS input tex		# Simulation input
## mtt sRS logic tex		# Logic control
## mtt sRS odeso ps		# Simulation output

## mtt sRS rep txt		# This file

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sRT/sRT_abg.fig version [f43a08790f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2701 5625 2701 5400 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2701 7425 2701 7200 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2476 5850 1126 6075 1351
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3600 450 3600 450 451 11475 451 11475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2701 3375 2701 3150 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2701 9675 2701 9450 2926
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2520 3375 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8325 2475 8325 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5625 2475 5625 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 2475 6075 2925
4 1 6 0 0 0 20 0.0000 4 240 510 5851 2792 [1,2]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5851 2791 1\001
4 1 -1 0 0 0 20 0.0000 4 195 480 5850 991 sR:r\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2476 [p]\001
4 1 4 0 0 0 20 0.0000 4 255 315 7290 2476 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 5040 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 5085 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 5040 2521 T\001
4 1 1 1 0 3 20 0.0000 4 240 210 6615 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 6660 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 6615 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 6795 2611 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 5220 2611 1\001
4 1 -1 0 0 0 20 0.0000 4 255 870 3825 2790 sFP:fp1\001
4 2 6 0 0 0 20 0.0000 4 240 510 1981 2791 [1,2]\001
4 2 4 0 0 0 20 0.0000 4 240 810 1981 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 2611 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 3241 1\001
4 1 -1 0 0 0 20 0.0000 4 255 870 7920 2790 sFP:fp2\001
4 1 4 0 0 0 20 0.0000 4 240 270 8505 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 9135 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 3241 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 2611 2\001
4 0 6 0 0 0 20 0.0000 4 240 510 9811 2792 [1,2]\001
4 0 4 0 0 0 20 0.0000 4 240 960 9811 2791 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sRT/sRT_lbl.txt version [c50752cef2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY sRT Sensitivity version of RT

## System sRT, representation lbl, language txt
## File sRT_lbl.txt
## Generated by MTT on Fri Jul  6 05:51:50 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases
#ALIAS	in	in_1,in_2
#ALIAS	out	out_1,out_2

## Argument aliases
#ALIAS	$1	flow,r
#ALIAS	$2	rs

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[in]	SS		external,external		
	[out]	SS		external,external		

## Component type FP
	fp1	lin
	fp2	lin		

## Component type R
	r	slin		flow,r;rs		

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sSe/sSe_abg.fig version [31113ead72].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
4 1 0 100 0 18 20 0.0000 4 270 1080 1485 2115 Se:se_2\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4500 2115 SS:[port_2]\001
4 1 4 100 0 18 20 0.0000 4 270 1515 4545 1440 SS:[port_1]\001
4 1 0 100 0 18 20 0.0000 4 270 1080 1485 1440 Se:se_1\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sSe/sSe_lbl.txt version [e9246e3267].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sSe (sSe_lbl.txt)
%SUMMARY sSe Sensitivity version of effort source (Se)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:54:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS	$1 e_s
%ALIAS	$2 k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external

% Component type Se
	se_1		SS		e_s
	se_2		SS		k_s

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sSe/sSe_sSe_abg.fig version [8738ce32fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 900 1215 2070 1530
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 1440 Sf:sf_1\001
-6
6 900 1890 2070 2205
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 2115 Sf:sf_2\001
-6
6 2205 1305 3645 1620
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
-6
6 2205 1980 3645 2295
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
-6
6 3735 1215 5355 1530
4 1 4 100 0 18 20 0.0000 4 300 1620 4545 1440 SS:[port_1]\001
-6
6 3690 1890 5310 2205
4 1 4 100 0 18 20 0.0000 4 300 1620 4500 2115 SS:[port_2]\001
-6

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sSf/sSf_abg.fig version [8738ce32fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 900 1215 2070 1530
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 1440 Sf:sf_1\001
-6
6 900 1890 2070 2205
4 1 0 100 0 18 20 0.0000 4 285 1155 1485 2115 Sf:sf_2\001
-6
6 2205 1305 3645 1620
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 3600 1350 3375 1575
-6
6 2205 1980 3645 2295
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 3600 2025 3375 2250
-6
6 3735 1215 5355 1530
4 1 4 100 0 18 20 0.0000 4 300 1620 4545 1440 SS:[port_1]\001
-6
6 3690 1890 5310 2205
4 1 4 100 0 18 20 0.0000 4 300 1620 4500 2115 SS:[port_2]\001
-6

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sSf/sSf_lbl.txt version [7503578c13].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sSf (sSf_lbl.txt)
%SUMMARY sSf Sensitivity version of flow source (Sf)
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 04:54:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in|out	port_1,port_2

% Argument aliases
%ALIAS	$1 f_s
%ALIAS	$2 k_s


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[port_1]	SS		external,external
	[port_2]	SS		external,external

% Component type Sf
	sf_1		SS		f_s
	sf_2		SS		k_s

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sTF/sTF_abg.fig version [d3bd4652b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 4050 3825 4050 3600 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 4050 9000 4050 8775 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 4050 10800 4050 10575 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 450 3825 450 3600 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 450 5625 450 5400 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 450 9000 450 8775 675
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9450 450 10800 450 10575 675
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2520 9225 3825 9225 3600
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9231 2498 4056 3803 4056 3578
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 675 9225 2025 9450 1800
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 2
	 3825 675 4275 675
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 2
	 9000 2025 9450 2025
4 1 4 100 0 18 20 0.0000 4 270 1740 1440 4140 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 195 150 4050 4140 1\001
4 1 0 100 0 18 20 0.0000 4 210 1095 6660 4140 TF:sens\001
4 1 0 100 0 18 20 0.0000 4 195 150 9225 4140 0\001
4 1 4 100 0 18 20 0.0000 4 270 1935 12015 4140 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 270 1920 1440 540 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 195 150 4050 540 1\001
4 1 0 100 0 18 20 0.0000 4 195 150 9225 540 0\001
4 1 4 100 0 18 20 0.0000 4 270 2115 12015 540 SS:[Actual_out]\001
4 1 0 100 0 18 20 0.0000 4 210 825 9180 2340 AE:ae\001
4 1 0 100 0 18 20 0.0000 4 210 750 4050 2340 AF:af\001
4 1 0 100 0 18 20 0.0000 4 210 1260 6660 540 TF:actual\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sTF/sTF_lbl.txt version [6977eeb4be].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sTF (sTF_lbl.txt)
%SUMMARY sTF TF component with sensitivity ports
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1999/08/26 01:34:59  peterg
% %% Summary line added
% %%
% %% Revision 1.2  1999/08/26 01:22:25  peterg
% %% New alias $1 flow,k
% %%
% %% Revision 1.1  1999/08/26 00:15:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out


% Argument aliases
%ALIAS	$1	flow,k
%ALIAS	$2	k_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	ae		lin		effort,-k_s

% Component type AF
	af		lin		flow,k_s

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external

% Component type TF
	actual		lin	flow,k
	sens		lin	flow,k

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sTF/testsTF_abg.fig version [136b338a92].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 2925 6075 2925 5850 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 2700 2250 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2925 3600 2925 3375 3150
4 1 0 100 0 18 18 0.0000 4 210 930 4185 3060 sTF:stf\001
4 1 0 100 0 18 18 0.0000 4 270 1050 1620 3015 SS:ss_1\001
4 1 0 100 0 18 18 0.0000 4 270 1050 6750 3015 SS:ss_2\001
4 1 4 100 0 18 14 0.0000 4 210 450 2385 2700 [1,2]\001
4 1 4 100 0 18 14 0.0000 4 210 450 6030 2790 [1,2]\001

Deleted mttroot/mtt/lib/comp/compound/Sensitivity/sTF/testsTF_lbl.txt version [11d70877b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY testsTF
#DESCRIPTION Detailed description here

## System testsTF, representation lbl, language txt
## File testsTF_lbl.txt
## Generated by MTT on Thu Aug  9 12:38:50 BST 2001

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ###############################################################

## Port aliases

## Argument aliases
#ALIAS	$1	k
#ALIAS	$2	k_s

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 
	ss_1	SS		external,external		
	ss_2	SS		external,external		

## Component type sTF
	stf	slin		flow,n;n_s

Deleted mttroot/mtt/lib/comp/compound/Thermal/CT/CT_abg.fig version [2a418d3ee2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3375 2700 3150 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5850 3825 5850 1575 225 1575 225 3825 5850 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2700 5625 2700 5400 2925
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2475 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3105 S\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2835 .\001
4 2 4 0 0 0 20 0.0000 4 240 810 1980 2790 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 630 3825 2790 FP:fp\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2475 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 4950 3105 Q\001
4 1 1 1 0 3 20 0.0000 4 195 165 4950 2475 T\001
4 1 1 1 0 3 30 0.0000 4 60 105 4995 2835 .\001
4 1 -1 0 0 0 20 0.0000 4 195 390 5940 2790 C:c\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CT/CT_desc.tex version [7676ba8d58].

1
2
3
4
5
6
7







-
-
-
-
-
-
-

Component \textbf{CT} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{C} component.

 

Deleted mttroot/mtt/lib/comp/compound/Thermal/CT/CT_lbl.txt version [ee5a8364ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CT: One-port thermal C component with T/Sdot bond
%DESCRIPTION CR and parameters as for a one-port C component
%DESCRIPTION Internally pseudo
%DESCRIPTION Example label file entry:
%DESCRIPTION % Component type CT
%DESCRIPTION 	c		lin	effort,c

%Port aliases
%ALIAS		Thermal|out	in

%CR aliases
%ALIAS          $1		effort,c_t
%ALIAS          $a1		lin

%% Label file for system CT (CT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2001/07/03 22:59:10  gawthrop
% %% Fixed problems with argument passing for CRs
% %%
% %% Revision 1.6  2001/06/13 17:10:26  gawthrop
% %% Alias for the cr (ie ALIAS	$1	lin)
% %%
% %% Revision 1.5  2001/06/11 15:09:18  gawthrop
% %% Removed spurious parameter
% %%
% %% Revision 1.4  1998/07/22 11:28:15  peterg
% %% Out as port alias
% %%
% %% Revision 1.3  1998/07/22 11:27:41  peterg
% %% Changed port name
% %%
% %% Revision 1.2  1998/06/29 10:12:58  peterg
% %% Converted to FP component
% %% Removed FP label
% %%
% %% Revision 1.1  1997/09/04  09:49:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c		lin		effort,c_t

% Component type FP
        fp

% Component type SS
	[in]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/CT2/CT2.cr version [46957c5ad0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CT2    Constitutive Relationship for a two port thermo C
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.
%DESCRIPTION Parameter 4: t_0 -- the temperature at which internal
%DESCRIPTION energy is zero.

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 20:45:21  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR CT2;
Port 1 - Thermal
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,1,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,2,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = (gamma-1)*(InternalEnergy+c_v*m*t_0)/Volume;

END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/CT2/CT2_abg.fig version [4aa81090a9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 5400 4050 5400 3825 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5400 4725 5400 4950 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 5175 2700 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2025 2475 3375 2700 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3825 6525 5175 6750 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3375 6525 2025 6750 2250
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 5085 5895 5085 4950 3690 4950 3690 5895 5085 5895
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 2024 6750 3262 5512
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 5175 2700 5625
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 5175 6075 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6525 5625 6525 6750 4500 6750 4725 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 2475 5625 2475 6750 4050 6750 3825 6975
4 1 4 0 0 0 20 0.0000000 4 240 345 2250 4005 [e]\001
4 1 4 0 0 0 20 0.0000000 4 240 330 2250 3375 [s]\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 2430 5490 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 420 4410 5490 C:c\001
4 1 -1 0 0 0 20 0.0000000 4 270 690 6525 5490 PS:ps\001
4 0 4 0 0 0 20 0.0000000 4 270 960 6660 5850 [power]\001
4 1 -1 0 0 0 20 0.0000000 4 210 690 2430 3690 ES:es\001
4 1 4 0 0 0 20 0.0000000 4 240 870 2475 1845 SS:[in]\001
4 2 4 0 0 0 20 0.0000000 4 240 600 5985 5265 [out]\001
4 0 4 0 0 0 20 0.0000000 4 240 450 6750 5175 [in]\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 6435 3690 0\001
4 1 4 0 0 0 20 0.0000000 4 240 1020 6480 1890 SS:[out]\001
4 1 1 1 0 3 20 0.0000000 4 240 2340 6480 1530 Mechanical Power\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2160 2700 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6300 2700 P\001
4 0 1 1 0 3 20 0.0000000 4 210 675 6660 2700 dV/dt\001
4 1 1 1 0 3 20 0.0000000 4 240 1935 2475 1530 Thermal Power\001
4 0 1 1 0 3 20 0.0000000 4 210 720 2610 4365 dH/dt\001
4 1 1 1 0 3 20 0.0000000 4 255 840 1935 4365 T-T_0\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6300 4365 P\001
4 0 1 1 0 3 20 0.0000000 4 210 855 6705 4365 -dV/dt\001
4 2 1 1 0 3 20 0.0000000 4 210 1755 2025 6660 dH/dt-PdV/dt\001
4 1 1 1 0 3 20 0.0000000 4 270 1485 4365 4770 Two-port C\001
4 1 4 0 0 0 20 0.0000000 4 240 450 4050 5265 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 600 4770 5265 [out]\001
4 0 1 1 0 3 20 0.0000000 4 210 855 4005 7335 PdV/dt\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 4230 6840 1\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CT2/CT2_desc.tex version [2ac31e428a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system CT2 (CT2_desc.tex)
% Generated by MTT on Thu Dec 4 16:00:14 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 20:29:56  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CT2} is
   displayed in Figure \Ref{CT2_abg} and its label
   file is listed in Section \Ref{sec:CT2_lbl}.
   The subsystems are listed in Section \Ref{sec:CT2_sub}.

\textbf{CT2} is a two port thermal capacitor representing an ideal
heat engine converting heat to work without energy loss. There are two
ports {\bf [in]} (with covariables Temperature (absolute) and
entropy flow) and {\bf [out]} with covariables Pressure and rate of
change of volume. 

Rather than using the corresponding (nonlinear) Constitutive
Relationship (with entropy and volume as states) directly, the
component is built up from a {\em linear\/} two-port capacitor with
internal energy and volume as states. The {\bf ES} component provides
the conversion from the pseudo Bond Graph with temperature (relative)
and enthalpy flow as covariables to the true Bond Graph with with
covariables Temperature (absolute) and entropy flow.

The power-sensor {\bf PS} component is used to subtract the work enrgy
from the internal energy.







Deleted mttroot/mtt/lib/comp/compound/Thermal/CT2/CT2_lbl.txt version [db65e0d0b3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CT2: Two-port thermal C component - a heat engine.
%DESCRIPTION Port [in]: a (true) thermal bond 
%DESCRIPTION Port [out]: a mechanical (P, dV/dT) bond.
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.
%DESCRIPTION Parameter 4: t_0 -- the temperature at which internal
%DESCRIPTION energy is zero.

%% Label file for system CT2 (CT2_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C	c_v,gamma,m,t_0
	c	CT2	$1,$2,$3,$4

% Component type ES
	es

% Component type PS
	ps

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

	
	

Deleted mttroot/mtt/lib/comp/compound/Thermal/CU/CU_abg.fig version [1ce5cce7a3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 3375 2250 3375 2025 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 3375 3825 3375 3600 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 3375 5400 3375 5175 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 5175 4725 4050 4725 4050 3600 4275 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3375 7200 3375 6975 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 3375 8775 3375 8550 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9225 3375 10350 3375 10125 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10800 3375 11925 3375 11700 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 9000 3600 9000 4725 6075 4725 6300 4950
4 1 -1 0 0 2 20 0.0000 4 195 360 2475 3465 FP\001
4 1 -1 0 0 2 20 0.0000 4 195 135 4050 3465 0\001
4 1 4 0 0 2 16 0.0000 4 210 270 2160 3105 [f]\001
4 1 4 0 0 2 16 0.0000 4 225 315 2835 3105 [p]\001
4 1 1 1 0 3 22 0.0000 4 225 195 1440 3150 T\001
4 1 1 1 0 3 22 0.0000 4 225 195 3240 3150 T\001
4 1 1 1 0 3 22 0.0000 4 225 195 4815 3150 T\001
4 1 1 1 0 3 22 0.0000 4 285 720 4815 3825 Q-W\001
4 1 1 1 0 3 22 0.0000 4 285 240 3240 3825 Q\001
4 1 1 1 0 3 30 0.0000 4 60 120 3285 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 195 1440 3825 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 1485 3555 .\001
4 1 1 1 0 3 30 0.0000 4 60 120 4590 3555 .\001
4 1 1 1 0 3 30 0.0000 4 60 120 5040 3555 .\001
4 1 -1 0 0 2 20 0.0000 4 195 360 7425 3465 FP\001
4 1 -1 0 0 2 20 0.0000 4 195 360 10575 3465 FP\001
4 1 -1 0 0 2 20 0.0000 4 195 135 9000 3465 1\001
4 0 4 0 0 2 20 0.0000 4 240 990 12060 3465 SS:[out]\001
4 1 4 0 0 2 16 0.0000 4 210 270 10935 3105 [f]\001
4 1 4 0 0 2 16 0.0000 4 210 270 7110 3105 [f]\001
4 1 4 0 0 2 16 0.0000 4 225 315 7785 3105 [p]\001
4 1 4 0 0 2 16 0.0000 4 225 315 10260 3105 [p]\001
4 1 1 1 0 3 22 0.0000 4 225 195 6615 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 195 9765 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 195 11385 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 225 11385 3825 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 11430 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 285 9765 3825 W\001
4 1 1 1 0 3 30 0.0000 4 60 120 9810 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 225 6615 3825 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 6660 3555 .\001
4 1 -1 0 0 2 20 0.0000 4 195 405 5715 3465 C:c\001
4 1 1 1 0 3 22 0.0000 4 225 195 8190 3150 P\001
4 1 1 1 0 3 22 0.0000 4 225 285 8190 3825 W\001
4 1 1 1 0 3 30 0.0000 4 60 120 8235 3555 .\001
4 1 1 1 0 3 22 0.0000 4 225 195 8190 4500 P\001
4 1 1 1 0 3 22 0.0000 4 225 285 8190 5175 W\001
4 1 1 1 0 3 30 0.0000 4 60 120 8235 4905 .\001
4 2 4 0 0 2 20 0.0000 4 240 825 990 3465 SS:[in]\001
4 1 -1 0 0 2 20 0.0000 4 195 690 5625 4815 AF:af\001
4 1 1 1 0 3 22 0.0000 4 300 1275 900 4275 Heat port\001
4 1 1 1 0 3 22 0.0000 4 315 1305 11295 4275 Work port\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CU/CU_cr.r version [796052bb26].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CU    Constitutive Relationship for a two port thermo C
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.


%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:34:56  peterg
% %% Put under RCS
% %%
% %% Revision 1.1  1997/12/07 20:45:21  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR CU;

%% Integral/Integral causality
Port 1 - Thermal
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,1,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,2,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = (gamma-1)*(InternalEnergy)/Volume;

%% Derivative/Integral causality
Port 1 - Thermal
FOR ALL COMPONENT,  c_v,gamma,m,Temperature,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,state,1,
	Temperature, effort, 1,
	Volume, state, 2)
         = Temperature*(m*c_v);

Port 2 - Mechanical
FOR ALL COMPONENT,  c_v,gamma,m,Temperature,Volume
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,2,
	Temperature, effort, 1,
	Volume, state, 2)
         = (gamma-1)*(m*c_v)*(Temperature)/Volume;

%% Integral/Derivative causality
Port 1 - Thermal
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Pressure
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,effort,1,
	InternalEnergy, state, 1,
	Pressure, effort, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL COMPONENT,  c_v,gamma,m,InternalEnergy,Pressure
LET CU(COMPONENT, ideal_gas,c_v,gamma,m,state,2,
	InternalEnergy, state, 1,
	Pressure, effort, 2)
         = (gamma-1)*(InternalEnergy)/Pressure;


END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/CU/CU_lbl.txt version [d81160e763].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CU
%DESCRIPTION <Detailed description here>
%% Label file for system CU (CU_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Component type AF (gain of -1)
	af		lin		-1

% Component type C
	c		CU		$1

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Comb/Comb_abg.fig version [61d53b3fc6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4953 2928 6528 2928 6303 3153
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2476 2926 4051 2926 3826 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2476 4051 4051 4051 3826 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 4051 6526 4051 6301 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 5618 4501 4493 4726 4718
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6978 2925 8553 2925 8328 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6978 4050 8553 4050 8328 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 2693 6750 1568 6975 1793
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 4268 6750 5393 6975 5168
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6480 1575 6975 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6480 5400 6975 5400
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 6300 11025 675 225 675 225 6300 11025 6300
4 2 4 0 0 0 20 0.0000 4 255 2085 2436 4101 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2438 3023 SS:[Thermal_in]\001
4 2 4 0 0 0 12 0.0000 4 180 540 4102 3337 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 4147 3922 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 5002 3922 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 5002 3337 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1470 4504 3649 hPipe:pipe\001
4 1 1 1 0 3 20 0.0000 4 195 135 2933 3968 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 2798 4238 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2798 3878 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2798 4508 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 2842 2752 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2977 2842 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2977 3517 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2842 3382 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2842 3112 .\001
4 1 4 0 0 0 20 0.0000 4 240 1140 4501 5986 SS:[Heat]\001
4 1 1 1 0 3 30 0.0000 4 60 120 7933 4244 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 7933 3884 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 7933 4514 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 8068 3974 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7933 2713 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8068 2803 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7933 3343 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 7933 3073 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 8068 3478 2\001
4 0 4 0 0 0 20 0.0000 4 255 2235 8696 4197 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 8651 3026 SS:[Thermal_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6750 3060 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6750 4140 0\001
4 1 -1 0 0 22 20 0.0000 4 210 675 6705 5715 SS:P\001
4 1 -1 0 0 22 20 0.0000 4 210 645 6705 1440 SS:T\001
4 1 4 0 0 0 12 0.0000 4 180 495 4501 4366 [Heat]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Comb/Comb_desc.tex version [67dab7f8b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Comb (Comb_desc.tex)
% Generated by MTT on Tue Mar 31 15:58:34 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Comb} is
   displayed in Figure \Ref{Comb_abg} and its label
   file is listed in Section \Ref{sec:Comb_lbl}.
   The subsystems are listed in Section \Ref{sec:Comb_sub}.
   
   This thermal tank model has been developed to represent an ideal
   (and non-dynamic) combustion chamber for a gas turbine. The major
   simplification is that the mass contained in the tank is assumed
   constant -- this is consistent with using an ideal compressor and an
   ideal turbine with identical mass flows. Energy conservatioin is
   ensured by using true bonds and \textbf{TF} components.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Comb/Comb_lbl.txt version [cfaa583e32].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Comb: Combustion chamber model

%DESCRIPTION   This thermal tank model has been developed to represent an ideal
%DESCRIPTION   (and non-dynamic) combustion chamber for a gas turbine. The major
%DESCRIPTION   simplification is that the mass contained in the tank is assumed
%DESCRIPTION   constant -- this is consistent with using an ideal compressor and an
%DESCRIPTION   ideal turbine with identical mass flows. Energy conservation is
%DESCRIPTION   ensured by using true bonds and components.
 
%ALIAS	in Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	$1	m_c
%ALIAS	$2	v_c
%ALIAS	$3	r

%ALIAS	hPipe	CompressibleFlow/hPipe

%% Label file for system Comb (Comb_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.6  1998/07/04 08:24:25  peterg
% %% New-style SS
% %%
% %% Revision 1.5  1998/07/03 14:55:33  peterg
% %% Aliased parameters.
% %% Removed _c from parameters,
% %%
% %% Revision 1.4  1998/07/02 19:46:34  peterg
% %% New aliases
% %%
% %% Revision 1.3  1998/07/02 10:54:42  peterg
% %% Lower case in out
% %%
% %% Revision 1.2  1998/07/02 10:49:32  peterg
% %% Added port aliases
% %%
% %% Revision 1.1  1998/05/19 09:11:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Heat]		SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	P		SS	external,0
	T		SS	external,0

% Component type hPipe
	pipe	none	m_c;v_c;r



Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_abg.fig version [3e14bcdbdd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2476 5626 2476 5401 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 3376 5626 3376 5401 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5626 2251 5626 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5626 3151 5626 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6752 2927 7877 2927 7652 3152
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7877 2702 7877 3152
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 2475 3826 2475 3601 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 3375 3826 3375 3601 3600
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 4725 10125 1350 90 1350 90 4725 10125 4725
4 2 4 0 0 22 20 0.0000 4 270 1890 2610 2565 SS:[Pressure]\001
4 2 4 0 0 22 20 0.0000 4 270 2385 2655 3465 SS:[Temperature]\001
4 1 1 1 0 3 20 0.0000 4 195 165 5041 2251 P\001
4 1 1 1 0 3 20 0.0000 4 195 165 4996 3241 T\001
4 1 4 0 0 22 20 0.0000 4 270 330 5895 2520 [1]\001
4 1 4 0 0 22 20 0.0000 4 270 330 5895 3465 [2]\001
4 1 -1 0 0 18 30 0.0000 4 345 600 6030 3060 R:r\001
4 1 4 0 0 22 20 0.0000 4 270 330 6570 3015 [3]\001
4 1 1 1 0 32 30 0.0000 4 345 210 7337 2792 r\001
4 0 4 0 0 22 20 0.0000 4 270 1695 8146 3016 SS:[Density]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4140 2610 AE\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4140 3465 AE\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_cr.r version [e0f1508d57].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for Density (Density_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Density;

% Ideal gas
FOR ALL COMPONENT,  R,Temperature,Pressure,Nothing
LET Density(COMPONENT, density,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = Pressure/(R*Temperature);

FOR ALL COMPONENT,  R,Temperature,Pressure,Nothing
LET Density(COMPONENT, specific_volume,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = (R*Temperature)/Pressure;

% Incompressible
FOR ALL COMPONENT,  rho,Temperature,Pressure,Nothing
LET Density(COMPONENT, density,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = rho;

FOR ALL COMPONENT,  rho,Temperature,Pressure,Nothing
LET Density(COMPONENT, specific_volume,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = 1/rho;

END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_desc.tex version [f12aa62d5f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Density (Density_desc.tex)
% Generated by MTT on Thu Mar 19 13:24:59 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Density} is
   displayed in Figure \Ref{Density_abg} and its label
   file is listed in Section \Ref{sec:Density_lbl}.

This three port component computes the density $\rho$ of substance in
terms of the temperature $T$ and the pressure $P$. At the moment,
there are four forms dependent on the four forms of the component parameter:
\begin{enumerate}
\item \emph{density,incompressible,rho}
\item \emph{specific\_volume,incompressible,rho}
\item \emph{density,ideal\_gas,R}
\item \emph{specific\_volume,ideal\_gas,R}
\end{enumerate}

\begin{equation}
  y = 
  \begin{cases}
    \rho & \text{if the parameter is
      \emph{density,incompressible,rho}}\\
    \frac{1}{\rho} & \text{if the parameter is
      \emph{specific\_volume,incompressible,rho}}\\
    \frac{P}{RT} & \text{if the parameter is \emph{density,ideal\_gas,R}}\\
    \frac{RT}{P} & \text{if the parameter is
      \emph{specific\_volume,ideal\_gas,R}}
  \end{cases}
\end{equation}
where $\rho$ is the density of the incompressible fluid and $R$ the
universal gas constant of the ideal gas.

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Density/Density_lbl.txt version [9d2703c643].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Density - Computes  P and T.

%DESCRIPTION Parameter: density,ideal_gas,gas_constant
%DESCRIPTION OR       : specific_volume,ideal_gas,gas_constant
%DESCRIPTION OR       : density,incompressible,gas_constant
%DESCRIPTION OR       : specific_volume,incompressible,gas_constant
%DESCRIPTION Port [P]: Pressure
%DESCRIPTION Port [T]: Temperature
%DESCRIPTION Port [rho]: Density

%ALIAS	P	Pressure
%ALIAS	T	Temperature
%ALIAS	rho|out	Density

%ALIAS	$1	density,ideal_gas,r



%% Label file for system Density (Density_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type R
	r		Density		density,ideal_gas,r

% Component type SS
	[Pressure]	SS		external,external
	[Temperature]	SS		external,external
	[Density]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/ICV/ICV_abg.fig version [3ae1de99d6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4503 2928 6078 2928 5853 3153
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 2926 3601 2926 3376 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 4051 3601 4051 3376 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 4051 6076 4051 5851 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6528 2925 8103 2925 7878 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6528 4050 8103 4050 7878 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 6300 9900 675 225 675 225 6300 9900 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2693 6300 1568 6525 1793
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 4268 6300 5393 6525 5168
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6030 1575 6525 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6030 5400 6525 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 4500 4320 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 4507 4050 5632 4275 5407
4 2 4 0 0 0 12 0.0000 4 180 540 3652 3337 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 3697 3922 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 4552 3922 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 4552 3337 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1470 4054 3649 hPipe:pipe\001
4 1 1 1 0 3 20 0.0000 4 195 135 2483 3968 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 2348 4238 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2348 3878 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2348 4508 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 2392 2752 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2527 2842 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2527 3517 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2392 3382 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2392 3112 .\001
4 2 4 0 0 0 20 0.0000 4 255 1290 1896 4191 SS:[Hy_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1275 1943 3023 SS:[Th_in]\001
4 1 4 0 0 22 12 0.0000 4 180 540 4051 4366 [Heat]\001
4 1 -1 0 0 0 20 0.0000 4 195 570 4051 5986 CT:c\001
4 1 1 1 0 3 30 0.0000 4 60 120 7483 4244 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 7483 3884 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 7483 4514 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 7618 3974 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7483 2713 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 7618 2803 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7483 3343 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 7483 3073 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 7618 3478 2\001
4 0 4 0 0 0 20 0.0000 4 255 1440 8246 4197 SS:[Hy_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1425 8201 3026 SS:[Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6300 3060 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6300 4140 0\001
4 1 -1 0 0 22 20 0.0000 4 210 675 6255 5715 SS:P\001
4 1 -1 0 0 22 20 0.0000 4 210 645 6255 1440 SS:T\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/ICV/ICV_desc.tex version [b0103a1ae6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ICV (ICV_desc.tex)
% Generated by MTT on Tue Mar 31 15:58:34 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ICV} is
   displayed in Figure \Ref{ICV_abg} and its label
   file is listed in Section \Ref{sec:ICV_lbl}.
   The subsystems are listed in Section \Ref{sec:ICV_sub}.
   
   This thermal tank model has been developed to represent an
   inter-volume component (ICV) for a gas turbine. The major
   simplification is that the mass contained in the ICV is assumed
   constant -- this is consistent with using an ideal compressor and an
   ideal turbine with identical mass flows. Energy conservation is
   ensured by using true bonds and \textbf{TF} components.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/ICV/ICV_lbl.txt version [65e966e572].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY ICV Inter-component volume for a gas turbine.
%DESCRIPTION Parameter 1 Thermal capacity (c)

%% Label file for system ICV (ICV_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CT
	c		lin		effort,$1

% Component type SS
	[Hy_in]		external	external
	[Hy_out]	external	external
	[T]		external	external
	[Th_in]		external	external
	[Th_out]	external	external
	P		external	0
	T		external	0

% Component type hPipe
	pipe	none	m_c;v_c;r

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_abg.fig version [de507d7428].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 2927 6977 2927 6752 3152
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 2926 4051 2926 3826 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 2701 4051 3151
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 2925 2251 2925 2026 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 2026 4051 2026 3826 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 1801 4051 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 2025 2251 2025 2026 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 3826 4051 3826 3826 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 3601 4051 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 3825 2251 3825 2026 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 4949 4951 3824 5176 4049
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 3824 5176 3824
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 6749 4950 5624 5175 5849
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 2700 5850 3150
4 1 4 0 0 22 20 0.0000 4 270 330 5670 3015 [5]\001
4 1 1 1 0 22 20 0.0000 4 150 255 6437 2792 m\001
4 0 4 0 0 22 20 0.0000 4 270 2055 7246 3016 SS:[MassFlow]\001
4 1 -1 0 0 18 30 0.0000 4 345 600 5040 3060 R:r\001
4 1 1 1 0 3 20 0.0000 4 195 165 3466 2701 P\001
4 1 4 0 0 22 20 0.0000 4 270 330 4320 2970 [2]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 2565 3060 AE\001
4 2 4 0 0 22 20 0.0000 4 270 1005 1080 3015 SS:[P2]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3466 1801 P\001
4 1 4 0 0 22 20 0.0000 4 270 330 4320 2070 [1]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 2565 2160 AE\001
4 2 4 0 0 22 20 0.0000 4 270 1005 1080 2115 SS:[P1]\001
4 1 1 1 0 3 20 0.0000 4 195 135 3601 1981 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3601 2881 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 6436 2566 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3421 3691 T\001
4 1 4 0 0 22 20 0.0000 4 270 330 4320 3915 [3]\001
4 1 -1 0 0 18 20 0.0000 4 210 405 2565 3915 AE\001
4 2 4 0 0 22 20 0.0000 4 270 975 1080 3915 SS:[T1]\001
4 1 1 1 0 3 20 0.0000 4 195 135 3601 3781 1\001
4 1 4 0 0 22 20 1.5708 4 270 330 5040 3555 [4]\001
4 1 -1 0 0 18 20 1.5708 4 210 405 5040 5310 AE\001
4 2 4 0 0 22 20 1.5708 4 270 1305 5040 6795 SS:[Area]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_cr.r version [d6639e6e67].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for NozzleFlow (NozzleFlow_cr.r)
% Generated by PJG at Wed Apr 8 09:30 GMT 1998


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



OPERATOR NozzleFlow;
% Ideal gas - but polytropic expansion
FOR ALL R, n, p1, p2, T1, A, Nothing
LET NozzleFlow(R,n,flow,5,
	p1,effort,1,
	p2,effort,2,
	T1,effort,3,
	A,effort,4,
	Nothing,effort,5
	) = A*p1*( (2*n/(n-1)) * (1/(R*T1)) * 
                ((p2/p1)^(2/n)) * (1 - (p2/p1)^(n-1/n) ) ^(1/2)
                );

END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_desc.tex version [d6b48465a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system NozzleFlow (NozzleFlow_desc.tex)
% Generated by MTT on Thu Mar 19 13:24:59 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{NozzleFlow} is
   displayed in Figure \Ref{NozzleFlow_abg} and its label
   file is listed in Section \Ref{sec:NozzleFlow_lbl}.

This 5 port component computes the mass flow in a polytropic
convergent nozzle from the formula:
\begin{equation}
  \dot m = A p_1 \sqrt{\frac{2n}{n-1}\frac{1}{RT_1} 
   \left ( \frac{p_2}{p_1} \right )^\frac{2}{n}
    \left [ 1- \left ( \frac{p_2}{p_1} \right )^\frac{n-1}{n} \right ]  }
\end{equation}

where:
\begin{itemize}
\item $n$ is the coefficient of polytropic expansion and
\item $R$ is the universal gas constant.
\end{itemize}

If the expansion is isentropic
\begin{equation}
  n=\gamma=\frac{c_p}{c_v}
\end{equation}
whre $c_p$ and $c_v$ are the spesicfic heats at constant pressure and volume.

Typical values for air are 
\begin{equation}
  \begin{align}
    R &= 287 \text{Nm}\text{kg}^{-1}{K}^{-1}\\
    \gamma &= 1.4
  \end{align}
\end{equation}

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_lbl.txt version [c51871a280].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY NozzleFlow Subsonic ideal gas nozzle flow with polytropic expansion
%DESCRIPTION Polytropic expansion coefficient n=gamma=c_p/c_v for isentropic expansion.
 

%ALIAS $1	R	Ideal gas constant
%ALIAS $2	n	Index of polytropic expansion

%% Label file for system NozzleFlow (NozzleFlow_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type R
	r		NozzleFlow	R,n

% Component type SS
	[Area]		SS	external,external
	[MassFlow]	SS	external,external
	[P1]		SS	external,external
	[P2]		SS	external,external
	[T1]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/NozzleFlow/NozzleFlow_rep.txt version [14692cdf88].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system NozzleFlow (NozzleFlow_rep.txt)
# Generated by MTT on" Thursday September 24 09:49:01 BST 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt NozzleFlow abg tex			# The system description

# Uncomment the following lines or add others
mtt NozzleFlow ode tex	        # The system ode 
# mtt NozzleFlow sspar tex		# Steady-state parameters
# mtt NozzleFlow ss tex 		# Steady state
# mtt NozzleFlow sm tex			# State matrices (of linearised system)
# mtt NozzleFlow lmfr ps		# log modulus of frequency response (of linearised system)
# mtt NozzleFlow simpar tex		# Simulation parameters
# mtt NozzleFlow numpar tex		# Numerical simulation parameters
# mtt NozzleFlow input tex		# Simulation input
# mtt NozzleFlow odeso ps		# Simulation output

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_abg.fig version [af2780bc2d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 2027 5852 2027 5627 2252
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5852 1802 5852 2252
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2026 4052 2026 3827 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 2702 5852 2702 5627 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2701 4052 2701 3827 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 3377 5852 3377 5627 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5852 3152 5852 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 3376 4052 3376 3827 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7428 2703 8553 2703 8328 2928
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 2478 5850 2928
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9003 2700 10128 2700 9903 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8778 4050 8778 2925 9003 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 2925 8775 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8775 4050 9000 4050
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13050 5625 135 5625 135 1125 13050 1125 13050 5625
4 1 -1 0 0 18 20 0.0000 4 210 405 4366 2161 AE\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4366 2836 AE\001
4 1 -1 0 0 18 20 0.0000 4 210 405 4366 3466 AE\001
4 2 4 0 0 22 20 0.0000 4 270 2190 2881 2116 SS:[Pressure_1]\001
4 2 4 0 0 22 20 0.0000 4 270 2190 2881 2791 SS:[Pressure_2]\001
4 2 4 0 0 22 20 0.0000 4 270 2685 2881 3466 SS:[Temperature_1]\001
4 1 -1 0 0 18 30 0.0000 4 345 600 6706 2836 R:r\001
4 1 4 0 0 22 20 0.0000 4 270 330 6120 2790 [2]\001
4 1 4 0 0 22 20 0.0000 4 270 330 6120 3465 [3]\001
4 1 4 0 0 22 20 0.0000 4 270 330 6120 2115 [1]\001
4 1 4 0 0 22 20 0.0000 4 270 330 7245 2790 [4]\001
4 0 4 0 0 22 20 0.0000 4 270 2685 10260 2790 SS:[Temperature_2]\001
4 1 -1 0 0 18 20 0.0000 4 210 1080 8775 4410 SS:zero\001
4 1 -1 0 0 18 20 0.0000 4 195 150 8820 2790 1\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_cr.r version [60c0a3c72c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for Poly (Poly_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Poly;

% Ideal gas

% Temperature output on port [T2]
FOR ALL COMPONENT,  alpha,P1,P2,T1,Nothing
LET Poly(COMPONENT, alpha,effort,4,
	P1,effort,1,
	P2,effort,2,
	T1,effort,3,
	Nothing,flow,4
	) = T1*(P2/P1)^alpha;



END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_desc.tex version [0fc0fe1509].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Poly (Poly_desc.tex)
% Generated by MTT on Thu Mar 19 13:24:59 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/03/31 15:05:33  peterg
% %% Spell checked
% %%
% %% Revision 1.2  1998/03/27 10:56:14  peterg
% %% Added bicausal bit
% %%
% %% Revision 1.1  1998/03/26 15:13:35  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Poly} is
   displayed in Figure \Ref{Poly_abg} and its label
   file is listed in Section \Ref{sec:Poly_lbl}.

This four-port component computes the temperature following a
polytropic expansion using:
\begin{equation}
  T_2 = T_1 \left ( \frac{P_2}{P_1} \right )^\alpha
\end{equation}
where $\alpha = \frac{n-1}{n}$ and $n$ is the coefficient of
polytropic expansion.  This component imposes zero flow at all its
ports and therefore does not affect energy balance.

The output is \emph{bicausal} as it imposes both $T_2$ and a zero flow.
This is implemented using the bicausal \textbf{SS} component labeled
``zero''.

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Poly/Poly_lbl.txt version [5420451ef5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Poly - computes polytropic expansion temperature.
%DESCRIPTION Parameter: alpha = (n-1)/n (n = polytropic index)

%DESCRIPTION This four-port component computes the temperature following
%DESCRIPTION a polytropic expansion using where alpha = (n-1)/n and n is
%DESCRIPTION the coefficient of polytropic expansion.  This component
%DESCRIPTION imposes zero flow at all its ports and therefore does not
%DESCRIPTION affect energy balance.  The output is bicausal as it
%DESCRIPTION imposes both T_2 and a zero flow.  This is implemented using
%DESCRIPTION the bicausal SS component labeled ``zero''.

%ALIAS	P1	Pressure_1
%ALIAS	P2	Pressure_2
%ALIAS	T1	Temperature_1
%ALIAS	T2|out	Temperature_2

%ALIAS $1	alpha

%% Label file for system Poly (Poly_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/27 10:48:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type R
	r		Poly		alpha

% Component type SS
	zero		SS		0,0
	[Pressure_1]	SS		external,external
	[Temperature_1]	SS		external,external
	[Pressure_2]	SS		external,external
	[Temperature_2]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Pump/Pump_abg.fig version [dbddf488a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7203 2028 8778 2028 8553 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 2026 6301 2026 6076 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6301 3151 6076 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2703 2028 4278 2028 4053 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2656 3151 4683 3151 4458 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8776 3151 10803 3151 10578 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 3151 8326 3151 8101 3376
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4501 1801 4501 901 6076 901 5851 1126
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4951 2926 4951 1351 6076 1351 5851 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 7426 901 9001 901 9001 1801 9226 1576
2 1 0 2 5 -1 0 0 -1 0.000 0 0 -1 0 0 4
	 8551 2926 8551 1351 7426 1351 7651 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6755 7969 6755 6844 6980 7069
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6754 6371 6754 5246 6979 5471
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6752 4751 6752 3626 6977 3851
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9228 2025 10803 2025 10578 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11704 2028 13279 2028 13054 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9225 1800 10125 900 10125 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10013 788 10238 1013
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15705 8550 15705 225 225 225 225 8550 15705 8550
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 7965 6975 7965
4 2 4 0 0 0 20 0.0000 4 255 1935 2617 2122 SS:[Thermal_in]\001
4 2 4 0 0 0 20 0.0000 4 255 2085 2615 3245 SS:[Hydraulic_in]\001
4 2 4 0 0 0 12 0.0000 4 180 540 6352 2437 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 6397 3022 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 7252 3022 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 7252 2437 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 9047 2117 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 10181 3297 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 10181 2937 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 10181 3567 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 10316 3027 2\001
4 0 4 0 0 0 20 0.0000 4 255 2235 10944 3250 SS:[Hydraulic_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1305 6796 1261 Poly:poly\001
4 2 4 0 0 22 12 0.0000 4 180 345 7291 856 [T2]\001
4 2 4 0 0 22 12 0.0000 4 180 345 7336 1531 [P2]\001
4 0 4 0 0 22 12 0.0000 4 180 345 6211 856 [T1]\001
4 0 4 0 0 22 12 0.0000 4 180 345 6211 1531 [P1]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 8596 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4951 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4501 2161 0\001
4 1 4 0 0 0 20 0.0000 4 240 1215 6755 8330 SS:[Shaft]\001
4 1 1 1 0 32 30 0.0000 4 240 195 6530 7610 t\001
4 1 1 1 0 32 30 0.0000 4 240 285 6980 7610 w\001
4 1 4 0 0 0 12 0.0000 4 180 540 6751 3421 [Work]\001
4 1 -1 0 0 22 20 0.0000 4 210 750 11250 2115 EBTF\001
4 1 1 1 0 3 20 0.0000 4 195 165 12657 1767 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 12792 1857 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 12657 2397 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 12657 2127 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 12792 2532 2\001
4 0 4 0 0 0 20 0.0000 4 255 2085 13375 2080 SS:[Thermal_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1530 6754 2749 wPipe:pipe\001
4 1 -1 0 0 22 20 0.0000 4 210 645 10305 765 SS:T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3157 3022 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3022 3292 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3022 2932 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 3022 3562 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 3066 1806 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3201 1896 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3201 2571 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3066 2436 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3066 2166 .\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6755 6710 1\001
4 1 -1 0 0 22 20 0.0000 4 270 915 6800 5090 TF:k_p\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Pump/Pump_desc.tex version [ec8169ffc6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Pump (Pump_desc.tex)
% Generated by MTT on Fri Mar 20 15:53:12 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/01 08:09:06  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pump} is
   displayed in Figure \Ref{Pump_abg} and its label
   file is listed in Section \Ref{sec:Pump_lbl}.
   The subsystems are listed in Section \Ref{sec:Pump_sub}.

\textbf{Pump} represents an ideal pumping component for compressible
or incompressible flow though a pipe, it may also be used as a turbine.

The pump is ideal in the sense that the mass flow rate $\dot m$
depends only on the shaft speed $\omega$:
\begin{equation}
  \dot m = k_p \omega
\end{equation}

It is implemented using three components:
\begin{itemize}
\item the ideal isentropic \textbf{wPipe} component which gives the
  correct energy flows
\item the polytropic expansion \textbf{Poly} component which imposes
  the correct temperature at the output of the pump. This component
  imposes zero flow at all its ports and therefore does not affect
  energy balance. It has a bicausal output imposing both the
  temperature measured by the \textbf{SS} component ``T'' and a zero
  flow.
\item the \emph{effort-bicausal transformer} \textbf{EBTF}
  component. This component is an energy-conserving \textbf{TF}
  component with non-standard causality. The modulus is determined by
  the two imposed efforts ($T$ and $T_2$), and this modulus determines
  the flows in the usual way. In particular, it makes sure that the
  internal energy flowing from the pump to the following components
  (imposing $T_2$) is correct.
\end{itemize}

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Pump/Pump_lbl.txt version [968ba1a760].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Pump Ideal pump component for compressible flow

%DESCRIPTION Pump represents an ideal pumping component for compressible
%DESCRIPTION or incompressible flow though a pipe, it may also be used as a turbine.
%DESCRIPTION The pump is ideal in the sense that the mass flow rate
%DESCRIPTION depends only on the shaft speed.

%DESCRIPTION Parameter 1: c_v - specific heat of fluid
%DESCRIPTION Parameter 2: Parameter passed to Density component
%DESCRIPTION Parameter 3: alpha = (n-1)/n, n coefficient of polytropic
%DESCRIPTION expansion.
%DESCRIPTION Parameter 4: k_p pump constant: mass flow = k_p*shaft speed

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Work	Shaft

%ALIAS  $1		c_v
%ALIAS  $2		density,ideal_gas,r
%ALIAS  $3		alpha
%ALIAS  $4		flow,k_p

%ALIAS	wPipe	CompressibleFlow/wPipe
%ALIAS	Poly	CompressibleFlow/Poly

%% Label file for system Pump (Pump_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  1998/07/04 08:39:58  peterg
% %% New-style SS
% %%
% %% Revision 1.6  1998/07/03 15:02:25  peterg
% %% Work alias added
% %%
% %% Revision 1.5  1998/07/03 14:43:24  peterg
% %% Added parameter aliases
% %%
% %% Revision 1.4  1998/07/02 19:46:19  peterg
% %% New aliases
% %%
% %% Revision 1.3  1998/07/02 10:55:54  peterg
% %% Lower case in out
% %%
% %% Revision 1.2  1998/07/02 10:52:33  peterg
% %% Added port aliases
% %%
% %% Revision 1.1  1998/04/07 15:23:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type wPipe
	pipe	none			c_v;density,ideal_gas,r

% Component type Poly
	poly		Poly		alpha

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Shaft]		SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	T		SS	external,0

% Component type TF
	k_p		lin	flow,k_p

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Tank/Tank_abg.fig version [49b9e2e5c7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 3600 9680 3602 9455 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9900 3825 9900 5850 10125 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 6300 4725 6300 4500 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6077 6301 7202 6301 6977 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 6299 9230 6302 9005 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10575 6300 13725 6300 13500 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3600 11700 3600 11475 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 3600 13725 3600 13500 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 3825 7425 4725 7650 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 6075 7425 5175 7650 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 2228 7425 3353 7650 3128
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9675 9000 5625 9000 5625 1350 9675 1350 9675 9000
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15525 9450 15525 675 90 675 90 9450 15525 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7650 6525 8775 7650 9945 7650 9945 6750 10170 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7200 6525 6030 7695 5400 7695 5400 6750 5625 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 7657 7425 6532 7650 6757
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3600 6300 3600 6075 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3600 7200 3600 6975 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 3600 5175 3600 4950 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3600 2925 3600 2700 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 3825 5400 4725 5625 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 5175 5400 5850 5625 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 4950 4275 4950 4500 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4275 4725 4275 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5175 4950 5175 5175
4 1 1 1 0 3 20 0.0000000 4 210 150 2073 4143 1\001
4 1 1 1 0 3 20 0.0000000 4 210 165 1938 4008 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 1938 3738 .\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 7426 3691 0\001
4 1 1 1 0 3 20 0.0000000 4 210 165 13102 4012 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 13102 3742 .\001
4 1 1 1 0 3 20 0.0000000 4 210 150 13237 4147 2\001
4 0 4 0 0 0 20 0.0000000 4 240 1500 13820 3695 SS:[Th_out]\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 9901 3691 0\001
4 1 1 1 0 3 20 0.0000000 4 210 150 2029 6169 1\001
4 1 1 1 0 3 30 0.0000000 4 60 105 1894 6439 .\001
4 1 1 1 0 3 20 0.0000000 4 210 180 1894 6079 P\001
4 1 1 1 0 3 20 0.0000000 4 210 195 1894 6709 V\001
4 2 4 0 0 0 20 0.0000000 4 270 1380 1442 6392 SS:[Hy_in]\001
4 2 4 0 0 0 12 0.0000000 4 180 570 4680 6165 [Hy_in]\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 7427 6437 0\001
4 2 4 0 0 0 12 0.0000000 4 180 570 9225 6165 [Hy_in]\001
4 0 4 0 0 0 12 0.0000000 4 180 660 6076 6166 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000000 4 225 945 5401 6391 VM:v2m\001
4 1 1 1 0 3 30 0.0000000 4 60 105 13102 6488 .\001
4 1 1 1 0 3 20 0.0000000 4 210 180 13102 6128 P\001
4 1 1 1 0 3 20 0.0000000 4 210 195 13102 6758 V\001
4 1 1 1 0 3 20 0.0000000 4 210 150 13237 6218 2\001
4 0 4 0 0 0 20 0.0000000 4 270 1530 13865 6441 SS:[Hy_out]\001
4 0 4 0 0 0 12 0.0000000 4 180 660 10531 6166 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000000 4 225 945 9901 6391 VM:m2v\001
4 1 4 0 0 0 12 0.0000000 4 165 225 5402 6077 [T]\001
4 1 4 0 0 0 12 0.0000000 4 165 225 5402 6617 [P]\001
4 1 4 0 0 0 12 0.0000000 4 165 225 9902 6077 [T]\001
4 1 4 0 0 0 12 0.0000000 4 165 225 9902 6617 [P]\001
4 2 4 0 0 0 20 0.0000000 4 240 1350 1534 3694 SS:[Th_in]\001
4 1 -1 0 0 22 20 0.0000000 4 225 330 11926 3691 ES\001
4 1 4 0 0 0 12 0.0000000 4 165 195 11567 3332 [e]\001
4 1 4 0 0 0 12 0.0000000 4 165 195 12242 3332 [s]\001
4 1 -1 0 0 22 20 0.0000000 4 285 1290 7471 5041 Tankp:tank\001
4 2 4 0 0 0 12 0.0000000 4 165 315 7200 4680 [Th]\001
4 2 4 0 0 0 12 0.0000000 4 180 345 7245 5265 [Hy]\001
4 1 1 1 0 3 20 0.0000000 4 270 2400 7425 8685 Pseudo bond graph\001
4 1 4 0 0 0 20 0.0000000 4 270 1110 7426 2116 SS:[pTh]\001
4 1 4 0 0 0 20 0.0000000 4 270 1140 7426 7966 SS:[pHy]\001
4 1 -1 0 0 22 20 0.0000000 4 225 330 6570 3690 AF\001
4 1 1 1 0 3 20 0.0000000 4 210 180 13102 3382 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 13237 3472 2\001
4 1 4 0 0 0 12 0.0000000 4 165 195 2793 3378 [s]\001
4 1 4 0 0 0 12 0.0000000 4 165 195 3423 3378 [e]\001
4 1 -1 0 0 22 20 0.0000000 4 225 330 3150 3735 ES\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 5401 3691 1\001
4 1 -1 0 0 22 20 0.0000000 4 225 135 5400 5085 0\001
4 1 -1 0 0 22 20 0.0000000 4 225 900 3735 5040 SS:zero\001
4 1 1 1 0 3 20 0.0000000 4 210 180 4999 5674 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 5134 5764 1\001
4 1 1 1 0 3 20 0.0000000 4 210 180 1938 3378 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 2073 3468 1\001
4 1 1 1 0 3 20 0.0000000 4 210 180 10358 5454 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 10493 5544 2\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Tank/Tank_desc.tex version [cb521024f4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Tank (Tank_desc.tex)
% Generated by MTT on Tue Jan 13 18:03:04 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tank} is
   displayed in Figure \Ref{Tank_abg} and its label
   file is listed in Section \Ref{sec:Tank_lbl}.
   The subsystems are listed in Section \Ref{sec:Tank_sub}.

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Tank/Tank_lbl.txt version [4e0b60130e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Tank - thermal storage component for compressible fluids.
%DESCRIPTION Two port thermal storage component for compressible
%DESCRIPTION fluids
%DESCRIPTION Parameter 1 Passed to Tankp subcomponent
%DESCRIPTION Parameter 2 Parameter two of density component.
%DESCRIPTION Typical label file entry:
%DESCRIPTION % Component type Tank
%DESCRIPTION   	C1	none	ideal_gas,r_g,c_p,v_t;r_g
%DESCRIPTION Port [Th_in]: Thermal flow bond (T/Sdot)
%DESCRIPTION Port [Th_out]: Thermal flow bond (T/Sdot)
%DESCRIPTION Port [Hy_in]: Hydraulic flow bond (P/Vdot)
%DESCRIPTION Port [Hy_out]: Hydraulic flow bond (P/Vdot)
%DESCRIPTION Port [pTh]: Thermal flow pseudo bond direct to tank (T/Edot)
%DESCRIPTION Port [pHy]: Hydraulic flow pseudo bond direct to tank (P/mdot)

%% Label file for system Tank (Tank_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/26 09:00:26  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hy_in]		external	external
	[Hy_out]	external	external
	[pHy]		external	external
	[pTh]		external	external
	[Th_in]		external	external
	[Th_out]	external	external
	zero		internal	internal

% Component type Tankp
	tank		none		$1

% Component type VMe
	v2m		none	density,$2
	m2v		none	specific_volume,$2


Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_abg.fig version [cbe50075c1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2926 3646 3376 3646
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2926 946 3376 946
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 947 3151 2072 3376 1847
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3646 3151 2521 3376 2746
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5850 4275 5850 225 225 225 225 4275 5850 4275
4 1 -1 0 0 22 20 0.0000 4 210 870 3151 2431 C:tank\001
4 1 4 0 0 0 20 0.0000 4 240 915 3150 765 SS:[Th]\001
4 1 4 0 0 0 20 0.0000 4 255 930 3105 3960 SS:[Hy]\001
4 1 4 0 0 0 20 0.0000 4 240 405 2836 2026 [in]\001
4 1 4 0 0 0 20 0.0000 4 240 555 2791 2746 [out]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_cr.r version [b03cd8ad39].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for Tankp (Tankp_cr.r)
% Generated by MTT at Thu Mar  5 10:30:23 GMT 1998

OPERATOR Tankp; 
%%%% Incompressible %%%%
%Temperature
FOR ALL c_p,c,StoredMass,StoredEnthalpy
LET Tankp(incompressible,c_p,c,effort,1,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = StoredEnthalpy/(StoredMass*c_p);

%Pressure
FOR ALL c_p,c,StoredMass,StoredEnthalpy
LET Tankp(incompressible,c_p,c,effort,2,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = StoredMass/c;

%%%% Ideal gas %%%%
%Temperature
FOR ALL R,c_p,Volume,StoredMass,StoredEnthalpy
LET Tankp(ideal_gas,R,c_p,Volume,effort,1,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = (StoredEnthalpy/(c_p*StoredMass));

%Pressure
FOR ALL R,c_p,Volume,StoredMass,StoredEnthalpy
LET Tankp(ideal_gas,R,c_p,Volume,effort,2,
	StoredEnthalpy,state,1,
	StoredMass,state,2
	) = R*( ( (StoredEnthalpy/(c_p*StoredMass)))/(Volume/StoredMass) );

END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_desc.tex version [aa7ccbe134].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Tankp (Tankp_desc.tex)
% Generated by MTT on Fri Mar 20 12:21:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tankp} is
   displayed in Figure \Ref{Tankp_abg} and its label
   file is listed in Section \Ref{sec:Tankp_lbl}.
   The subsystems are listed in Section \Ref{sec:Tankp_sub}.

\textbf{Tankp} is a pseudo bond graph based model of a tank storing
(as the two states)
\begin{itemize}
\item enthalpy and 
\item mass
\end{itemize}

There are two versions:
\begin{itemize}
\item the incompressible version where the tank has a pressure-based
  capacitance $c_t$ and
\item the ideal-gas version were the tank has a volume  $v_t$ and $r$
  and $c_p$ are the universal gas constant and the specific heat respectively.
\end{itemize}








Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Tankp/Tankp_lbl.txt version [685d1ad022].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Tankp	Pseudo bond graph model of a tank storing mass and enthalpy
%DESCRIPTION Parameter 1: EITHER
%DESCRIPTION incompressible,c OR
%DESCRIPTION ideal_gas,R,c_p,v_t

%% Label file for system Tankp (Tankp_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	tank		Tankp		$1

% Component type SS
	[Hy]		external	external
	[Th]		external	external

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Turb/Turb_abg.fig version [5566bbcbd7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6528 2028 8103 2028 7878 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 2026 5626 2026 5401 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 3151 5626 3151 5401 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2028 2028 3603 2028 3378 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1981 3151 4008 3151 3783 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 3151 10128 3151 9903 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 3151 7651 3151 7426 3376
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3826 1801 3826 901 5401 901 5176 1126
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4276 2926 4276 1351 5401 1351 5176 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6751 901 8326 901 8326 1801 8551 1576
2 1 0 2 5 -1 0 0 -1 0.000 0 0 -1 0 0 4
	 7876 2926 7876 1351 6751 1351 6976 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8553 2025 10128 2025 9903 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11029 2028 12604 2028 12379 2253
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 1800 9450 900 9450 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9338 788 9563 1013
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3619 6075 4744 6300 4519
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5194 6075 6319 6300 6094
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 6994 6075 8119 6300 7894
4 2 4 0 0 0 12 0.0000 4 180 540 5677 2437 [Th_in]\001
4 2 4 0 0 0 12 0.0000 4 180 570 5722 3022 [Hy_in]\001
4 0 4 0 0 0 12 0.0000 4 180 675 6577 3022 [Hy_out]\001
4 0 4 0 0 0 12 0.0000 4 180 645 6577 2437 [Th_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 8372 2117 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 9506 3297 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9506 2937 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 9506 3567 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 9641 3027 2\001
4 0 4 0 0 0 20 0.0000 4 255 1440 10269 3250 SS:[Hydraulic_out]\001
4 1 1 1 0 3 20 0.0000 4 195 135 2482 3022 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 2347 3292 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2347 2932 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2347 3562 V\001
4 1 1 1 0 3 20 0.0000 4 195 165 2391 1806 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2526 1896 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2526 2571 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2391 2436 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2391 2166 .\001
4 2 4 0 0 0 20 0.0000 4 255 1290 1895 3245 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1275 1942 2077 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 270 1305 6121 1261 Poly:poly\001
4 2 4 0 0 22 12 0.0000 4 180 345 6616 856 [T2]\001
4 2 4 0 0 22 12 0.0000 4 180 345 6661 1531 [P2]\001
4 0 4 0 0 22 12 0.0000 4 180 345 5536 856 [T1]\001
4 0 4 0 0 22 12 0.0000 4 180 345 5536 1531 [P1]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 7921 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4276 3286 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3826 2161 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6080 5090 1\001
4 1 1 1 0 32 30 0.0000 4 240 195 5855 7610 t\001
4 1 1 1 0 32 30 0.0000 4 240 285 6305 7610 w\001
4 1 -1 0 0 22 20 0.0000 4 210 750 10575 2115 EBTF\001
4 1 1 1 0 3 20 0.0000 4 195 165 11982 1767 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 12117 1857 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 11982 2397 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 11982 2127 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 12117 2532 2\001
4 0 4 0 0 0 20 0.0000 4 255 1425 12700 2080 SS:[Thermal_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1530 6079 2749 wPipe:pipe\001
4 1 -1 0 0 22 20 0.0000 4 210 645 9630 765 SS:T\001
4 1 -1 0 0 22 20 0.0000 4 270 825 6080 6755 TF:k_t\001
4 1 4 0 0 0 20 0.0000 4 240 1215 6120 8460 SS:[Shaft]\001
4 1 4 0 0 0 12 0.0000 4 180 495 6076 3421 [Work]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Turb/Turb_desc.tex version [68c72a056b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Turb (Turb_desc.tex)
% Generated by MTT on Fri Mar 20 15:53:12 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Turb} is
   displayed in Figure \Ref{Turb_abg} and its label
   file is listed in Section \Ref{sec:Turb_lbl}.
   The subsystems are listed in Section \Ref{sec:Turb_sub}.

\textbf{Turb} represents an ideal turbine component for compressible
or incompressible flow though a pipe.

It is identical to the \textbf{Pump} component (which has a more
complete description) exept for the direction of work flow.

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/Turb/Turb_lbl.txt version [62ed8c5a7a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Turb Ideal turbine component for compressible flow
%DESCRIPTION Parameter 1: c_p - specific heat of fluid
%DESCRIPTION Parameter 2: Parameter passed to Density component
%DESCRIPTION Parameter 3: alpha = (n-1)/n, n coefficient of polytropic
%DESCRIPTION expansion.
%DESCRIPTION Parameter 4: k_t pump constant: mass flow = k_t*shaft speed

%ALIAS	in		Thermal_in,Hydraulic_in
%ALIAS	out		Thermal_out,Hydraulic_out

%ALIAS	Th_in		Thermal_in
%ALIAS	Hy_in		Hydraulic_in

%ALIAS	Th_out		Thermal_out
%ALIAS	Hy_out		Hydraulic_out

%ALIAS  $1		c_p
%ALIAS  $2		ideal_gas,r
%ALIAS  $3		alpha
%ALIAS  $4		effort,k

%% Label file for system Turb (Turb_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.5  1998/07/03 10:12:18  peterg
% %% New aliased parameter form
% %%
% %% Revision 1.4  1998/07/02 19:48:45  peterg
% %% Changed aliases
% %%
% %% Revision 1.3  1998/07/02 10:55:24  peterg
% %% Lower case in out
% %%
% %% Revision 1.2  1998/07/02 10:51:10  peterg
% %% Added port aliases
% %%
% %% Revision 1.1  1998/04/07 15:21:02  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Pipe
	pipe	none		c_p;ideal_gas,r

% Component type Poly
	poly		Poly		alpha

% Component type SS
	[Hydraulic_in]	external	external
	[Hydraulic_out]	external	external
	[Shaft]		external	external
	[Thermal_in]	external	external
	[Thermal_out]	external	external
	T		external	0

% Component type TF
	k_t		lin	effort,k




Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/hPipe/hPipe_abg.fig version [411e1f86bc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5143 4050 6088 3105 6088 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 2488 1822 5210 1822 6110 2722 5840 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6313 4500 6313 3150 6538 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6538 3150 7438 4050 7213 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2445 4052 4020 4052 3795 4277
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8564 4052 10139 4052 9914 4277
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6538 2700 7438 1800 10138 1800 9913 2025
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13050 4950 45 4950 45 450 13050 450 13050 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6165 3105 6435 3105
4 1 -1 0 0 22 20 0.0000 4 195 150 6315 3017 0\001
4 1 1 1 0 3 20 0.0000 4 195 510 5865 3872 mp v\001
4 1 1 1 0 3 20 0.0000 4 195 330 6043 4050 1 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 5729 3691 .\001
4 1 1 1 0 3 20 0.0000 4 195 510 6675 3872 mp v\001
4 1 1 1 0 3 20 0.0000 4 195 330 6853 4050 2 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 6539 3691 .\001
4 2 4 0 0 22 20 0.0000 4 270 2355 2399 4141 SS:[Hydraulic_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2805 3782 P\001
4 1 1 1 0 3 20 0.0000 4 195 135 2941 4683 1\001
4 1 1 1 0 3 20 0.0000 4 195 195 2806 4548 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 2805 4277 .\001
4 2 4 0 0 22 20 0.0000 4 270 2145 2355 1892 SS:[Thermal_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2894 1531 T\001
4 0 4 0 0 22 20 0.0000 4 270 2550 10319 4187 SS:[Hydraulic_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9689 3783 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 9600 4458 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 9599 4187 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 9735 4593 2\001
4 0 4 0 0 22 20 0.0000 4 270 2340 10365 1892 SS:[Thermal_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9734 1532 T\001
4 1 -1 0 0 22 20 0.0000 4 210 945 4558 4185 TF:P2T\001
4 1 -1 0 0 22 20 0.0000 4 210 945 8068 4140 TF:T2P\001
4 1 4 0 0 22 20 0.0000 4 270 1290 6359 4771 SS:[Heat]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/hPipe/hPipe_desc.tex version [5824e24429].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system hPipe (hPipe_desc.tex)
% Generated by MTT on Tue Mar 31 09:54:08 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{hPipe} is
   displayed in Figure \Ref{hPipe_abg} and its label
   file is listed in Section \Ref{sec:hPipe_lbl}.
   The subsystems are listed in Section \Ref{sec:hPipe_sub}.
   

\textbf{hPipe} represents an ideal (energy conserving) pipe carrying a
fluid with heat transfer. To ensure energy conservation, power bonds are used and
connected by (energy conserving) \textbf{TF} components.
It is assumed that the working fluid is an ideal gas (gas constant $r$) and that a mass
$m_t$ is stored within pipe with a volume $v_t$.

The central \textbf{0} junction carries temperature ($T$) and the two
hydraulic ports are connected to this by appropriate transformers.
The modulus of the \textbf{TF} component labeled ``P2T'' is such P and
T are related by the ideal gas law
\begin{equation}
  P = \frac{Rm_t}{v_t} T
\end{equation}

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/hPipe/hPipe_lbl.txt version [4fbc3c7372].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY hPipe: Pipe for compressible fluid with heat transfer and heat storage.

%DESCRIPTION hPipe represents an ideal (energy conserving) pipe carrying a
%DESCRIPTION fluid with heat transfer. To ensure energy conservation, power bonds are used and
%DESCRIPTION connected by (energy conserving) TF components.
%DESCRIPTION It is assumed that the working fluid is an ideal gas (gas constant r) and that a mass
%DESCRIPTION m_t is stored within pipe with a volume v_t.

%DESCRIPTION Parameter 1: m_t (mass in pipe)
%DESCRIPTION Parameter 2: v_t (volume of pipe)
%DESCRIPTION Parameter 3: r (gas constant)
%DESCRIPTION Typical lable entry 
%DESCRIPTION % Component type hPipe
%DESCRIPTION 	pipe		none		m_p;v_p;r

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	$1	m
%ALIAS	$2	v
%ALIAS	$3	r



%% Label file for system hPipe (hPipe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/03 17:38:32  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Heat]		SS	external,external
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

% Component type TF
	P2T		lin	flow,r*m/v
	T2P		lin	effort,r*m/v

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/wPipe/wPipe_abg.fig version [41fd44dc27].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1666 3781 3241 3781 3016 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3691 3781 4591 3781 4366 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3466 1756 3466 2431 3691 2206
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3466 3556 3466 2881 3691 3106
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4366 2656 5491 2656 5491 3331 5716 3106
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6392 1532 7292 2432 7022 2432
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7742 2882 8642 3782 8372 3782
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7764 2454 8664 1554 8664 1824
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6392 3782 7292 2882 7292 3152
2 1 0 2 5 7 0 0 -1 0.000 0 0 -1 0 0 4
	 10666 2658 9766 2658 9766 3333 9993 3106
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11566 1758 11566 2433 11791 2208
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11566 3558 11566 2883 11791 3108
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9766 1531 11341 1531 11116 1756
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1666 1531 3241 1531 3016 1756
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3691 1531 5266 1531 5041 1756
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11836 1533 13411 1533 13186 1758
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11791 3781 13366 3781 13141 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10411 3781 11311 3781 11086 4006
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7515 4275 7516 3106 7741 3331
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7515 5895 7516 4726 7741 4951
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 16200 6300 45 6300 45 180 16200 180 16200 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7335 5895 7695 5895
4 2 4 0 0 22 20 0.0000 4 270 2355 2430 3915 SS:[Hydraulic_in]\001
4 2 4 0 0 22 20 0.0000 4 270 2145 2476 1666 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3466 1621 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3466 3916 0\001
4 1 4 0 0 22 12 0.0000 4 180 405 4186 2521 [rho]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 7517 2792 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11566 1623 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11566 3918 0\001
4 1 4 0 0 22 12 0.0000 4 180 405 10846 2523 [rho]\001
4 1 4 0 0 22 12 0.0000 4 180 495 9766 3558 [mod]\001
4 1 -1 0 0 22 20 0.0000 4 210 840 5851 1621 TF:t2u\001
4 1 -1 0 0 22 20 0.0000 4 270 1515 5536 3916 EMTF:p2pv\001
4 1 4 0 0 22 12 0.0000 4 180 495 5491 3601 [mod]\001
4 2 4 0 0 22 12 0.0000 4 180 240 3331 3016 [P]\001
4 2 4 0 0 22 12 0.0000 4 180 240 3331 2386 [T]\001
4 2 4 0 0 22 12 0.0000 4 180 240 11431 2386 [T]\001
4 2 4 0 0 22 12 0.0000 4 180 240 11431 3016 [P]\001
4 0 4 0 0 22 20 0.0000 4 270 2340 13591 1621 SS:[Thermal_out]\001
4 0 4 0 0 22 20 0.0000 4 270 2550 13546 3916 SS:[Hydraulic_out]\001
4 1 4 0 0 22 12 0.0000 4 180 270 4816 3601 [in]\001
4 1 4 0 0 22 12 0.0000 4 180 405 6301 3601 [out]\001
4 1 4 0 0 22 12 0.0000 4 180 405 10441 3556 [out]\001
4 1 4 0 0 22 12 0.0000 4 180 270 8911 3556 [in]\001
4 1 -1 0 0 22 20 0.0000 4 210 840 9316 1621 TF:u2t\001
4 1 -1 0 0 22 20 0.0000 4 270 1515 9631 3871 EMTF:pv2p\001
4 1 1 1 0 3 20 0.0000 4 195 135 2161 3646 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2026 3511 P\001
4 1 1 1 0 3 20 0.0000 4 195 165 12960 1261 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 13095 1396 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 13051 3647 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 12916 3512 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 12827 4187 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 12826 3916 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 12962 4322 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 2162 4412 1\001
4 1 1 1 0 3 20 0.0000 4 195 195 2027 4277 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 2026 4006 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 6841 3736 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 6841 3511 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 8101 3691 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 8101 3466 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 6570 2295 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 6570 2070 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 8461 2341 m\001
4 1 1 1 0 3 30 0.0000 4 60 120 8461 2116 .\001
4 1 1 1 0 3 20 0.0000 4 135 150 7922 1847 u\001
4 1 1 1 0 3 20 0.0000 4 195 135 8057 1982 2\001
4 1 1 1 0 3 20 0.0000 4 195 300 6482 3062 p v\001
4 1 1 1 0 3 20 0.0000 4 195 330 6570 3240 1 1\001
4 1 1 1 0 3 20 0.0000 4 195 300 8372 3063 p v\001
4 1 1 1 0 3 20 0.0000 4 195 330 8460 3241 2 2\001
4 1 -1 0 0 22 20 0.0000 4 270 1725 3511 2791 Density:rho1\001
4 1 -1 0 0 22 20 0.0000 4 270 1725 11521 2793 Density:rho2\001
4 1 1 1 0 3 20 0.0000 4 195 135 7246 1981 1\001
4 1 1 1 0 3 20 0.0000 4 135 150 7111 1846 u\001
4 1 1 1 0 3 20 0.0000 4 195 165 2115 1260 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2250 1395 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 7517 4592 1\001
4 1 4 0 0 22 20 0.0000 4 270 1380 7516 6211 SS:[Shaft]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/wPipe/wPipe_desc.tex version [25ee8a0694].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system wPipe (wPipe_desc.tex)
% Generated by MTT on Mon Mar 9 09:11:22 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{wPipe} is
   displayed in Figure \Ref{wPipe_abg} and its label
   file is listed in Section \Ref{sec:wPipe_lbl}.
   The subsystems are listed in Section \Ref{sec:wPipe_sub}.

\textbf{wPipe} represents an ideal (energy conserving) pipe carrying a
fluid with work transfer. To ensure energy conservation, power bonds are used and
connected by (energy conserving) \textbf{TF} components.

The central \textbf{1} junction carries mass flow ($\dot m$) and the
four ports are connected to this by appropriate transformers. In the
case of the hydraulic ports, these transformers are \emph{modulated}
by the corresponding fluid density.
The bonds impinging on this  \textbf{1} junction carry the
corresponding effort variables; in particular, the thermal bonds carry
specific internal energy $u$ and the hydraulic bonds carry $Pv$ where
$P$ is the pressure and $v$ the specific volume.

The ports ``Work\_in'' and ``Work\_out'' are convenient for attaching
(for example) the shadt work of a pump, turbine or compressor.

The ports are 
\begin{itemize}
\item [Hy\_in] Pressure/volume-flow inflow
\item [Hy\_in] Pressure/volume-flow outflow
\item [Th\_in] Temperature/Entropy-flow in flow
\item [Th\_out] Temperature/Entropy-flow out flow
\item [Shaft] Torque/angular velocity input.
\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/CompressibleFlow/wPipe/wPipe_lbl.txt version [abb521f401].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY wPipe Isentropic pipe with work transfer.

%DESCRIPTION wPipe represents an ideal (energy conserving) pipe carrying a
%DESCRIPTION fluid with work transfer. To ensure energy conservation, power bonds are used and
%DESCRIPTION connected by (energy conserving) TF components.

%DESCRIPTION Parameter 1: c_v - specific heat of fluid
%DESCRIPTION Parameter 2: Parameter passed to Density component
%DESCRIPTION Ports:

%DESCRIPTION [Hy_in] Pressure/volume-flow inflow
%DESCRIPTION [Hy_in] Pressure/volume-flow outflow
%DESCRIPTION [Th_in] Temperature/Entropy-flow in flow
%DESCRIPTION [Th_out] Temperature/Entropy-flow out flow
%DESCRIPTION [Shaft] Torque/angular velocity input.

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Work	Shaft

%ALIAS  $1		c_v
%ALIAS  $2		density,ideal_gas,r

%ALIAS	Density		CompressibleFlow/Density

%% Label file for system wPipe (wPipe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/07/04 08:33:30  peterg
% %% New-style SS
% %%
% %% Revision 1.1  1998/07/03 17:38:20  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Density
	rho1		none	density,ideal_gas,r
	rho2		none	density,ideal_gas,r

% Component type EMTF
	p2pv		lin		flow
	pv2p		lin		effort

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Shaft]		SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

% Component type TF
	t2u		lin	effort,c_v
	u2t		lin	flow,c_v




Deleted mttroot/mtt/lib/comp/compound/Thermal/Conv/Conv_abg.fig version [7d2151b2ad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 1351 5176 1351 4951 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5401 1576 5401 2701 5626 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5401 3151 5401 4276 5626 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2251 4501 5176 4501 4951 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 6751 1351 6526 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 1351 8551 1351 8326 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9226 1350 10351 1350 10126 1575
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8370 2925 4275 2925 4275 630 8370 630 8370 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2206 1351 3331 1351 3106 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 6075 11925 225 675 225 675 6075 11925 6075
4 1 -1 0 0 22 20 0.0000 4 210 390 3736 1441 ES\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5401 1441 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5401 4636 1\001
4 1 -1 0 0 22 20 0.0000 4 270 1215 5401 3061 FMR:c_p\001
4 1 1 1 0 3 30 0.0000 4 60 120 2657 4682 .\001
4 1 1 1 0 3 20 0.0000 4 135 210 2657 4952 m\001
4 1 4 0 0 0 20 0.0000 4 240 285 3466 1126 [s]\001
4 1 4 0 0 0 20 0.0000 4 240 300 4006 1126 [e]\001
4 1 1 1 0 3 20 0.0000 4 195 135 4592 1262 1\001
4 1 1 1 0 3 20 0.0000 4 195 615 4770 1080 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 5085 1260 0\001
4 1 1 1 0 3 20 0.0000 4 195 180 4683 1803 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 4683 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 6079 1804 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 6079 1534 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 6120 1125 0\001
4 1 -1 0 0 22 20 0.0000 4 210 390 7111 1441 AF\001
4 1 -1 0 0 22 20 0.0000 4 210 390 8911 1441 ES\001
4 1 1 1 0 3 20 0.0000 4 195 180 7832 1803 E\001
4 1 4 0 0 0 20 0.0000 4 240 300 8641 1081 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 285 9136 1081 [s]\001
4 1 1 1 0 3 30 0.0000 4 60 120 7832 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 615 7922 1082 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8237 1262 0\001
4 1 1 1 0 3 20 0.0000 4 195 135 7744 1264 2\001
4 1 1 1 0 3 20 0.0000 4 270 2340 6930 2340 Pseudo Bond Graph\001
4 2 4 0 0 0 20 0.0000 4 240 1200 2160 4590 SS:[Mdot]\001
4 2 4 0 0 0 20 0.0000 4 255 1275 2072 1442 SS:[Th_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2611 1171 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2746 1261 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2746 1936 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2611 1801 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2611 1531 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9590 1220 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 9725 1310 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 9590 1850 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9590 1580 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 9725 1985 2\001
4 0 4 0 0 0 20 0.0000 4 255 1425 10443 1443 SS:[Th_out]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/Conv/Conv_desc.tex version [f754dcd4e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Conv (Conv_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:53 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/09 10:19:43  peterg
% %% Added note about energy consevation.
% %%
% %% Revision 1.1  1998/03/09 10:13:27  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Conv} is
   displayed in Figure \Ref{Conv_abg} and its label
   file is listed in Section \Ref{sec:Conv_lbl}.
   The subsystems are listed in Section \Ref{sec:Conv_sub}.

The \textbf{Conv} component represents one way isenentropic flow of 
fluid though a pipe. Externally, it has true energy bonds: $P$/$\dot V$
(Pressure/volume-flow) representing hydraulic energy and $T$/$\dot
S$(Temperature/Entropy-flow) representing convected thermal energy.

Internally, however, the thermal part is represented by a pseudo bond
graph which computes the flow of internal energy $\dot E$ from the
upstream temperature $T_1$ and the mass flow rate $\dot m$ as:
\begin{equation}
  \dot E = c_p T_1 \dot m
\end{equation}
The $AF$ component makes the $FMR$ component use $T_1$ rather than
$T_1-T_2$.

The two \textbf{ES} components provide the conversion from true to
psuedo thermal bonds and vice versa.

%The pipe has an resistance to flow represented by the \textbf{RS}
%component labeled `r' which can be linear or nonlinear. The hydraulic
%energy loss reappears on the thermal bond of this (energy-conserving)
%\textbf{RS} component.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/Conv/Conv_lbl.txt version [829d4c79b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Conv	Convection of heat through a pipe
%DESCRIPTION Parameter 1: Specific heat of fluid (c_p)

%% Label file for system Conv (Conv_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type FMR
	c_p		lin	effort,$1

% Component type SS
	[Hy_in]		SS	external,external
	[Hy_out]	SS	external,external
	[Th_in]		SS	external,external
	[Th_out]	SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/Cycle/Cycle_abg.fig version [7b351255a8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1800 6750 1800 6525 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2025 5175 3375 5400 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 5175 5400 4950
2 2 0 3 1 7 1 0 -1 0.000 1 0 -1 0 0 5
	 6075 900 9000 900 9000 2700 6075 2700 6075 900
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8325 900 8550 900 8550 2700 8325 2700 8325 900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3825 10125 5175 10350 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 1800 9900 1800 9675 2025
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8550 1665 9585 1665 9585 1935 8550 1935 8550 1665
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 4725 1440 5805 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 9675 1440 10755 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 7785 3465 8415 2835
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 1800 4950 1800 4725 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1755 1800 3105 1800 2880 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 2025 3375 5175 3600 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 5175 3600 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10350 1800 11700 1800 11475 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 1800 13500 1800 13275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11700 5175 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11925 2025 11925 5175 12150 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 2025 10125 3375 10350 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2025 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 10350 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 5175 10350 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 5400 5175
4 1 -1 0 0 0 20 0.0000 4 255 855 7290 1890 CU:gas\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 1890 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1590 5175 3690 INTF:entropy\001
4 1 -1 0 0 0 20 0.0000 4 195 135 10125 1890 1\001
4 1 1 1 0 3 20 0.0000 4 270 1035 7200 1440 Ideal gas\001
4 1 1 1 0 3 20 0.0000 4 210 885 4635 1305 Heat in\001
4 1 1 1 0 3 20 0.0000 4 210 1080 10170 1305 Work out\001
4 1 1 1 0 3 20 0.0000 4 270 1800 5130 5895 Entropy change\001
4 1 1 1 0 3 20 0.0000 4 270 1365 7110 3690 Ideal piston\001
4 1 -1 0 0 0 20 0.0000 4 195 1560 10125 3690 INTF:volume\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 1890 0\001
4 2 4 0 0 0 20 0.0000 4 240 1140 1575 1890 SS:[Heat]\001
4 1 -1 0 0 0 20 0.0000 4 195 585 3375 5490 SS:T\001
4 1 1 1 0 3 20 0.0000 4 255 1485 3240 5895 Temperature\001
4 1 -1 0 0 0 20 0.0000 4 195 570 5130 5490 SS:S\001
4 1 -1 0 0 0 20 0.0000 4 195 615 10125 5490 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 195 570 11880 5490 SS:P\001
4 0 4 0 0 0 20 0.0000 4 240 1230 13680 1890 SS:[Work]\001
4 1 1 1 0 3 20 0.0000 4 270 1815 10080 5850 Volume change\001
4 1 1 1 0 3 20 0.0000 4 195 975 11925 5850 Pressure\001
4 1 -1 0 0 0 20 0.0000 4 195 135 11925 1890 0\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/Cycle/Cycle_desc.tex version [d51575eb68].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Cycle (Cycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/06/30 12:46:24  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cycle} is
   displayed in Figure \Ref{Cycle_abg} and its label
   file is listed in Section \Ref{sec:Cycle_lbl}.
   The subsystems are listed in Section \Ref{sec:Cycle_sub}.

The system has two heat engine ports: 
\begin{enumerate}
\item \textbf{[Heat]} and
\item \textbf{[Work]}
\end{enumerate}
By convention, energy flows in to the \textbf{[Heat]} port and out of
the \textbf{[Work]} port. Both ports are true energy ports.


The subsystem \textbf{CU} (Section \Ref{sec:CU}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

Four \textbf{SS} components are set up as sensors to measure the
important quantities pertaining to the cycle:
\begin{enumerate}
\item \textbf{S} to measure the integrated entropy flow
\item \textbf{T} to measure the (absolute) temperature
\item \textbf{V} to measure the integrated volume change
\item \textbf{P} to measure the pressure
\end{enumerate}

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|l|l|l|}
         \hline
         Cycle & Compression & Heating & Expansion & Cooling \\
         \hline
         Otto & II & II & II & II \\
         Carnot & II & DI & II & DI \\
         Diesel & II & ID & II & II \\
         Joule & II & ID & II & ID \\
         \hline
       \end{tabular}
       \caption{Cycles and their causality}
       \label{tab:cycles}
     \end{center}
   \end{table}
   
   A number of cycles can be built depending on the causality of the
   two ports \textbf{[Heat]} and \textbf{[Work]} of \textbf{Cycle}
   Some possible cycles listed in Tables \Ref{tab:cycles} where each
   table entry gives the causality on the heat and work ports
   respectively.

Deleted mttroot/mtt/lib/comp/compound/Thermal/Cycle/Cycle_lbl.txt version [d82e73d04d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Cycle: Closed cycle with ideal gas
#DESCRIPTION Uses the CU two-port thermal capacitor.

#ALIAS in	Heat
#ALIAS out	Work

#ALIAS $1	ideal_gas
#ALIAS $2	c_v
#ALIAS $3	gamma_g
#ALIAS $4	m_g

## Label file for system Cycle (Cycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1998/07/21 14:21:04  peterg
# ## New style file
# ##
# ## Revision 1.1  1997/12/08 20:24:43  peterg
# ## Initial revision
# ##
# ## Revision 1.1  1997/12/07 20:38:05  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank




# Component type CU
	gas	CU	ideal_gas,c_v,gamma_g,m_g

# Component type INTF
	entropy
	volume

# Component type SS
	S	SS	external,0
	T	SS	external,0
	V	SS	external,0
	P	SS	external,0
	[Heat]	SS	external,external
	[Work]	SS	external,external



Deleted mttroot/mtt/lib/comp/compound/Thermal/Cycle/Cycle_simp.r version [b8f003f5e9].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce commands to simplify output for system Cycle (Cycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/FMRT/FMRT_abg.fig version [b00ff3b590].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2701 5625 2701 5400 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2701 7425 2701 7200 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2476 5850 1126 6075 1351
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3600 450 3600 450 451 11475 451 11475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2701 3375 2701 3150 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2701 9675 2701 9450 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 900 5625 900 5400 1125
4 1 -1 0 0 0 20 0.0000 4 195 150 5850 2791 1\001
4 1 4 0 0 0 20 0.0000 4 255 360 4410 2476 [p]\001
4 1 4 0 0 0 20 0.0000 4 255 360 7290 2476 [p]\001
4 1 1 1 0 3 20 0.0000 4 255 225 5040 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 120 5085 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 5040 2521 T\001
4 1 1 1 0 3 20 0.0000 4 255 225 6615 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 120 6660 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 6615 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 150 6795 2611 2\001
4 1 1 1 0 3 20 0.0000 4 195 150 5220 2611 1\001
4 1 -1 0 0 0 20 0.0000 4 255 825 3825 2790 FP:fp1\001
4 2 4 0 0 0 20 0.0000 4 255 870 1980 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 315 3285 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2520 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 2475 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 150 2610 2611 1\001
4 1 1 1 0 3 20 0.0000 4 195 150 2610 3241 1\001
4 1 -1 0 0 0 20 0.0000 4 255 825 7920 2790 FP:fp2\001
4 1 4 0 0 0 20 0.0000 4 240 315 8505 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9135 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 9090 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 150 9270 3241 2\001
4 1 1 1 0 3 20 0.0000 4 195 150 9270 2611 2\001
4 0 4 0 0 0 20 0.0000 4 255 1020 9810 2791 SS:[out]\001
4 0 -1 0 0 0 20 0.0000 4 195 825 5850 990 FMR:r\001
4 2 4 0 0 0 20 0.0000 4 255 1170 4185 990 SS:[mod]\001
4 1 4 0 0 0 20 0.0000 4 255 750 5400 765 [mod]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/FMRT/FMRT_desc.tex version [5df3411dfb].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Component \textbf{FMRT} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{R} component.

The resistance $r$ is modulated by a flow variable $f$ on the [mod] port
so that the {\em conductance\/} $\sigma$ is:
\begin{equation}
  \sigma = \frac{f}{r} 
\end{equation}

Deleted mttroot/mtt/lib/comp/compound/Thermal/FMRT/FMRT_lbl.txt version [e0d0d8668e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY FMRT: Two port thermal resistance with T/Sdot bonds with flow modulation
#DESCRIPTION Port [in]: T/Sdot power in
#DESCRIPTION Port [out]: T/Sdot power out
#DESCRIPTION CR and parameters as for a one-port R component
#DESCRIPTION Internally pseudo bond graph 
#DESCRIPTION Example label file entry:
#DESCRIPTION # Component type RT
#DESCRIPTION	r		lin	flow,r

#ALIAS	ThermalIn	in
#ALIAS	ThermalOut	out
#ALIAS	Modulation	mod

#ALIAS	$1	flow,r
#ALIAS	$1	lin


## Label file for system FMRT (FMRT_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.8  2001/07/05 08:42:41  gawthrop
# ## Updated to allow auto-generation of sensitivity version
# ##
# ## Revision 1.7  2001/07/03 22:59:10  gawthrop
# ## Fixed problems with argument passing for CRs
# ##
# ## Revision 1.6  2001/06/13 17:10:26  gawthrop
# ## Alias for the cr (ie ALIAS	$1	lin)
# ##
# ## Revision 1.5  2001/06/11 19:51:08  gawthrop
# ## Zapped spurious $1 alias
# ##
# ## Revision 1.4  1998/07/22 11:31:42  peterg
# ## New port names
# ##
# ## Revision 1.3  1998/07/21 16:26:05  peterg
# ## Now has aliased parameters.
# ##
# ## Revision 1.2  1998/06/29 10:08:14  peterg
# ## Converted to FP component
# ## Removed lables from FP
# ##
# ## Revision 1.1  1997/09/04  09:48:47  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank


# Component type FMR
	r		lin		flow,r

# Component type FP
        fp1
        fp2

# Component type SS
	[in]		SS		external,external
	[out]		SS		external,external
	[mod]		SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pipe/Pipe_abg.fig version [d78afb5ca3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2715 1351 3840 1351 3615 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4515 1351 5640 1351 5415 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 1576 5865 2701 6090 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 3151 5865 4276 6090 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2715 4501 5640 4501 5415 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6090 1351 7215 1351 6990 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7890 1351 9015 1351 8790 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6090 4501 10815 4501 10590 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9690 1350 10815 1350 10590 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11039 4274 11039 3149 11264 3374
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11039 2699 11039 1574 11264 1799
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11267 1353 12392 1353 12167 1578
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11267 4500 12392 4500 12167 4725
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8834 2925 4739 2925 4739 630 8834 630 8834 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 15075 6075 15075 450 450 450 450 6075 15075 6075
4 2 4 0 0 0 20 0.0000 4 255 2085 2624 4590 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2581 1442 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 390 4200 1441 ES\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5865 1441 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 5865 4636 1\001
4 1 -1 0 0 22 20 0.0000 4 210 390 7575 1441 AF\001
4 1 -1 0 0 22 20 0.0000 4 270 1665 5865 3061 FMR:rho_cp\001
4 1 -1 0 0 22 20 0.0000 4 210 390 9375 1441 ES\001
4 1 1 1 0 3 20 0.0000 4 195 180 8296 1803 E\001
4 1 1 1 0 3 20 0.0000 4 195 135 3256 4412 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3121 4682 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3121 4322 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 3121 4952 V\001
4 1 4 0 0 0 20 0.0000 4 240 285 3930 1126 [s]\001
4 1 4 0 0 0 20 0.0000 4 240 300 4470 1126 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 300 9105 1081 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 285 9600 1081 [s]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3120 1171 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3255 1261 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3255 1936 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3120 1801 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3120 1531 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 5056 1262 1\001
4 1 1 1 0 3 20 0.0000 4 195 615 5234 1080 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 5549 1260 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 8296 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 615 8386 1082 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8701 1262 0\001
4 1 1 1 0 3 20 0.0000 4 195 135 8208 1264 2\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11039 1440 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 11039 4590 1\001
4 1 -1 0 0 22 20 0.0000 4 210 600 11084 3015 RS:r\001
4 0 4 0 0 0 20 0.0000 4 255 2235 12617 4593 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 12572 1443 SS:[Thermal_out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 11674 4685 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 11674 4325 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 11674 4955 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 11809 4415 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 11674 1175 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 11809 1265 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 11674 1805 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 11674 1535 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 11809 1940 2\001
4 1 1 1 0 3 20 0.0000 4 270 2340 7394 2340 Pseudo Bond Graph\001
4 1 1 1 0 3 20 0.0000 4 195 180 5147 1803 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 5147 1533 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 6543 1804 E\001
4 1 1 1 0 3 30 0.0000 4 60 120 6543 1534 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 6584 1125 0\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pipe/Pipe_desc.tex version [0ebe3c440d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Pipe (Pipe_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:53 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/09 10:13:27  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pipe} is
   displayed in Figure \Ref{Pipe_abg} and its label
   file is listed in Section \Ref{sec:Pipe_lbl}.
   The subsystems are listed in Section \Ref{sec:Pipe_sub}.

The \textbf{Pipe} component represents one way flow of incompressible
fluid though a pipe. Externally, it has true energy bonds: $P$/$\dot V$
(Pressure/volume-flow) representing hydraulic energy and $T$/$\dot
S$(Temperature/Entropy-flow) representing convected thermal energy.

Internally, however, the thermal part is represented by a pseudo bond
graph which computes the flow of internal energy $\dot E$ from the
upstream temperature $T_1$ and the volumetric flow rate $\dot V$ as:
\begin{equation}
  \dot E = \rho c_p T_1 \dot V
\end{equation}
The $AF$ component makes the $FMR$ component use $T_1$ rather than
$T_1-T_2$.

The two \textbf{ES} components provide the conversion from true to
psuedo thermal bonds and vice versa.

The pipe has an resistance to flow represented by the \textbf{RS}
component labeled `r' which can be linear or nonlinear. The hydraulic
energy loss reappears on the thermal bond of this (energy-conserving)
\textbf{RS} component.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pipe/Pipe_lbl.txt version [5c1c8daacb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Pipe (Pipe_lbl.txt)
%SUMMARY Pipe: Pipe containing hot incompressible liquid
%DESCRIPTION

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/20 11:34:17  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out


%ALIAS	$1	rho
%ALIAS	$2	c_p
%ALIAS	$3	flow,r


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type FMR
	rho_cp		lin	effort,$1*$2

% Component type RS
	r		$1	$3

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pump/Pump_abg.fig version [64178c150c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2714 2476 3839 2476 3614 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4289 2476 5414 2476 5189 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6313 2477 8297 2478 8072 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2713 1351 5418 1353 5193 1578
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6313 1351 8297 1352 8072 1577
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3825 4050 2700 4275 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5400 4050 4275 4275 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4063 7020 4063 5895 4288 6120
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10800 7650 10800 450 405 450 405 7650 10800 7650
4 2 4 0 0 0 20 0.0000 4 255 2085 2669 2567 SS:[Hydraulic_in]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4064 2612 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3166 2389 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3031 2659 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3031 2299 P\001
4 0 4 0 0 0 20 0.0000 4 255 2235 8522 2571 SS:[Hydraulic_out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 7579 2663 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 7579 2303 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 7579 2933 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 7714 2393 2\001
4 0 4 0 0 0 20 0.0000 4 255 1035 6313 2341 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1305 5953 1936 Pipe:pipe\001
4 2 4 0 0 0 20 0.0000 4 255 870 5459 1172 [Th_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2536 1444 SS:[Thermal_in]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3075 1173 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3210 1263 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3210 1938 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3075 1803 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3075 1533 .\001
4 0 4 0 0 0 20 0.0000 4 255 1020 6313 1171 [Th_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 8477 1400 SS:[Thermal_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 7579 1132 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 7714 1222 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 7579 1762 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 7579 1492 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 7714 1897 2\001
4 2 4 0 0 0 20 0.0000 4 255 885 5457 2340 [Hy_in]\001
4 1 1 1 0 3 20 0.0000 4 195 195 3031 2929 V\001
4 1 -1 0 0 22 20 0.0000 4 270 915 4063 4141 TF:k_p\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4064 5717 1\001
4 1 4 0 0 0 20 0.0000 4 240 1215 4063 7381 SS:[Shaft]\001
4 1 1 1 0 32 30 0.0000 4 240 195 3838 6661 t\001
4 1 1 1 0 32 30 0.0000 4 240 285 4288 6661 w\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pump/Pump_desc.tex version [af214b606c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Pump (Pump_desc.tex)
% Generated by MTT on Mon Mar 9 09:11:22 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pump} is
   displayed in Figure \Ref{Pump_abg} and its label
   file is listed in Section \Ref{sec:Pump_lbl}.
   The subsystems are listed in Section \Ref{sec:Pump_sub}.

\textbf{Pump} represents an ideal pump for incompressible fluid
driving fluid though a \textbf{Pipe} component. The pipe component
provides the correct thermal flow; if its resistance is set to zero,
the pump is an ideal component.

The flow must be one way (in to out) for correct thermal properties.

The ports are 
\begin{itemize}
\item [Hy_in] Pressure/volume-flow inflow
\item [Hy_in] Pressure/volume-flow outflow
\item [Th_in] Temperature/Entropy-flow in flow
\item [Th_out] Temperature/Entropy-flow out flow
\item [Shaft] Torque/angular velocity input.
\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Pump/Pump_lbl.txt version [9da52c1c35].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Pump: a hydraulic pump - incompressible flow
%DESCRIPTION Typical lable: pump  lin  rho;c_p;flow,r;k_p

%% Label file for system Pump (Pump_lbl.txt)


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/20 10:07:14  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ALIAS	Pipe	IncompressibleFlow/Pipe
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Work	Shaft

%ALIAS  $1	rho
%ALIAS  $2	c_p
%ALIAS  $3	flow,r
%ALIAS  $4	flow,k_p

%ALIAS	$1	lin

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank


% Component type Pipe
	pipe		lin	rho;c_p;flow,r

% Component type TF
	k_p		lin	flow,k_p

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	[Shaft]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_abg.fig version [33782b4512].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2940 2477 4065 2477 3840 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4740 2477 5865 2477 5640 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2940 5627 5865 5627 5640 5852
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6315 2478 7440 2478 7215 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8116 2479 9241 2479 9016 2704
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6315 5626 9240 5626 9015 5851
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7484 6571 4739 6571 4739 1801 7484 1801 7484 6571
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5864 5401 6314 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5864 2701 6314 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6089 2702 6089 3827 6314 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6089 5401 6089 4276 6314 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6088 1127 6088 2252 6313 2027
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11700 7200 11700 225 675 225 675 7200 11700 7200
4 0 4 0 0 0 20 0.0000 4 255 2235 9421 5719 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 9376 2569 SS:[Thermal_out]\001
4 2 4 0 0 0 20 0.0000 4 255 2085 2894 5716 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2806 2568 SS:[Thermal_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 390 4425 2567 ES\001
4 1 1 1 0 3 20 0.0000 4 195 135 3481 5538 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 3346 5808 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 3346 5448 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 3346 6078 V\001
4 1 4 0 0 0 20 0.0000 4 240 285 4155 2252 [s]\001
4 1 4 0 0 0 20 0.0000 4 240 300 4695 2252 [e]\001
4 1 1 1 0 3 20 0.0000 4 195 165 3345 2297 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 3480 2387 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 3480 3062 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 3345 2927 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 3345 2657 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 5281 2388 1\001
4 1 1 1 0 3 20 0.0000 4 195 615 5459 2206 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 5774 2386 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 5372 2659 .\001
4 1 1 1 0 3 20 0.0000 4 195 180 5372 2929 E\001
4 1 -1 0 0 22 20 0.0000 4 210 870 6089 4186 C:tank\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6090 2567 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6090 5762 0\001
4 1 -1 0 0 22 20 0.0000 4 210 390 7800 2568 ES\001
4 1 1 1 0 3 30 0.0000 4 60 120 8523 5811 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 8523 5451 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 8523 6081 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 8658 5541 2\001
4 1 1 1 0 3 20 0.0000 4 195 180 6721 2930 E\001
4 1 4 0 0 0 20 0.0000 4 240 300 7530 2208 [e]\001
4 1 4 0 0 0 20 0.0000 4 240 285 8025 2208 [s]\001
4 1 1 1 0 3 20 0.0000 4 195 165 8523 2301 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 8658 2391 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 8523 2931 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 8523 2661 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 8658 3066 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 6721 2660 .\001
4 1 1 1 0 3 20 0.0000 4 195 615 6811 2209 T - T\001
4 1 1 1 0 3 20 0.0000 4 195 135 7126 2389 0\001
4 1 1 1 0 3 20 0.0000 4 195 135 6633 2391 2\001
4 1 1 1 0 3 20 0.0000 4 270 2340 6134 6346 Pseudo Bond Graph\001
4 1 4 0 0 0 20 0.0000 4 240 555 5639 3826 [out]\001
4 1 4 0 0 0 20 0.0000 4 240 405 5684 4501 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 1500 6088 990 SS:[Heat_in]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_cr.r version [2d58561817].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for Tank (Tank_cr.r)
% Generated by MTT at Thu Mar  5 10:30:23 GMT 1998

OPERATOR tank;

%Pressure
FOR ALL COMPONENT, rho,c_p,c,Volume,Energy
LET tank(COMPONENT, rho,c_p,c,effort,1,
	Volume,state,1,
	Energy,state,2
	) = (Volume*rho)/c;

%Temperature
FOR ALL COMPONENT, rho,c_p,c,Volume,Energy
LET tank(COMPONENT, rho,c_p,c,effort,2,
	Volume,state,1,
	Energy,state,2
	) = Energy/(Volume*rho*c_p);

END;

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_desc.tex version [cb521024f4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Tank (Tank_desc.tex)
% Generated by MTT on Tue Jan 13 18:03:04 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Tank} is
   displayed in Figure \Ref{Tank_abg} and its label
   file is listed in Section \Ref{sec:Tank_lbl}.
   The subsystems are listed in Section \Ref{sec:Tank_sub}.

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/Tank/Tank_lbl.txt version [7694e0fcab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Tank (Tank_lbl.txt)
%SUMMARY Tank: Tank of hot incompressible liquid
%DESCRIPTION c is the pressure constant: P=(rho*V)/c
%DESCRIPTION Typical lable: tank  Tank  rho;c_p;c

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/11/20 09:46:34  peterg
% %% Modernised lbl syntax
% %%
% %% Revision 1.1  1998/11/20 08:57:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Heat	Heat_in

% Argument aliases
%ALIAS	$1	rho
%ALIAS	$2	c_p
%ALIAS	$3	c

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	tank		Tank	       rho,c_p,c

% Component type SS
	[Heat_in]	SS		external,external
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/lPump/lPump_abg.fig version [2ccac3b7ce].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 7426 6526 6301 6751 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 6302 6078 6302 5853 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5177 6078 5177 5853 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 2476 3601 4951 3871 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 3601 3601 6076 3871 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 2701 6976 2476 9451 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3825 6975 3600 9450 6075
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 6301 9228 6301 9003 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 5176 9228 5176 9003 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 6302 3378 6302 3153 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 5177 3378 5177 3153 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9678 5177 10803 5177 10578 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9678 6302 10803 6302 10578 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 9001 6525 7876 6750 8101
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13275 9675 13275 1350 45 1350 45 9675 13275 9675
4 2 4 0 0 0 20 0.0000 4 255 2085 2205 6390 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2205 5265 SS:[Thermal_in]\001
4 2 4 0 0 0 20 0.0000 4 255 870 6123 4998 [Th_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1020 6977 4997 [Th_out]\001
4 1 4 0 0 0 20 0.0000 4 240 810 6572 6167 [Shaft]\001
4 2 4 0 0 0 20 0.0000 4 255 885 5986 6166 [Hy_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1035 7112 6167 [Hy_out]\001
4 1 -1 0 0 22 20 0.0000 4 270 1665 6527 5762 Pump:pump\001
4 1 -1 0 0 22 20 0.0000 4 270 1260 6527 3152 Pipe:leak\001
4 1 1 1 0 3 20 0.0000 4 195 135 2705 6215 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2570 6125 P\001
4 1 1 1 0 3 20 0.0000 4 195 165 2614 4999 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2749 5089 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2749 5764 1\001
4 1 1 1 0 3 20 0.0000 4 195 165 2614 5629 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2614 5359 .\001
4 1 1 1 0 3 20 0.0000 4 195 195 2570 6755 V\001
4 1 1 1 0 3 30 0.0000 4 60 120 2570 6485 .\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3603 6393 0\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3603 5268 0\001
4 0 4 0 0 0 20 0.0000 4 255 2085 10941 5271 SS:[Thermal_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2235 10941 6397 SS:[Hydraulic_out]\001
4 1 1 1 0 3 20 0.0000 4 195 165 10043 4958 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 10178 5048 2\001
4 1 1 1 0 3 20 0.0000 4 195 165 10043 5588 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 10043 5318 .\001
4 1 1 1 0 3 20 0.0000 4 195 135 10178 5723 2\001
4 1 -1 0 0 22 20 0.0000 4 195 150 9453 5268 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 10088 6489 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 10088 6129 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 10088 6759 V\001
4 1 1 1 0 3 20 0.0000 4 195 135 10223 6219 2\001
4 1 -1 0 0 22 20 0.0000 4 195 150 9498 6438 0\001
4 0 4 0 0 0 20 0.0000 4 255 870 7023 2343 [Th_in]\001
4 0 4 0 0 0 20 0.0000 4 255 885 7021 3466 [Hy_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1020 6032 2342 [Th_out]\001
4 2 4 0 0 0 20 0.0000 4 255 1035 6032 3467 [Hy_out]\001
4 1 4 0 0 0 20 0.0000 4 240 1215 6482 9317 SS:[Shaft]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6528 7743 1\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/lPump/lPump_desc.tex version [e567a661c2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system lPump (lPump_desc.tex)
% Generated by MTT on Mon Mar 9 10:35:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{lPump} is
   displayed in Figure \Ref{lPump_abg} and its label
   file is listed in Section \Ref{sec:lPump_lbl}.
   The subsystems are listed in Section \Ref{sec:lPump_sub}.

\textbf{lPump} corrsponds to the \textbf{Pump} component but with a
backflow leakage around the ump driven by the pressure drop across
the pump. This leakage is implemented using the \textbf{Pipe}
component to give the correct thermal behaviour.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/IncompressibleFlow/lPump/lPump_lbl.txt version [d8173c6ec9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system lPump (lPump_lbl.txt)
%SUMMARY lPump: a hydraulic pump with leakage - incompressible flow

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Component aliases
%ALIAS	Pipe	IncompressibleFlow/Pipe
%ALIAS	Pump	IncompressibleFlow/Pump

% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

% Argument aliases
%ALIAS  $1	rho
%ALIAS  $2	c_p
%ALIAS  $3	flow,r
%ALIAS  $4	flow,k_p
%ALIAS  $5	flow,r_l


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Pipe
	leak		lin	$1;$2;$5

% Component type Pump
	pump		lin	$1;$2;$3;$4

% Component type SS
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external
	[Shaft]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT/RT_abg.fig version [932b6ad72c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2701 5625 2701 5400 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 2701 7425 2701 7200 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2476 5850 1126 6075 1351
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3600 450 3600 450 451 11475 451 11475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2701 3375 2701 3150 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2701 9675 2701 9450 2926
4 1 -1 0 0 0 20 0.0000 4 195 135 5850 2791 1\001
4 1 -1 0 0 0 20 0.0000 4 195 375 5850 991 R:r\001
4 1 4 0 0 0 20 0.0000 4 255 315 4410 2476 [p]\001
4 1 4 0 0 0 20 0.0000 4 255 315 7290 2476 [p]\001
4 1 1 1 0 3 20 0.0000 4 240 210 5040 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 5085 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 5040 2521 T\001
4 1 1 1 0 3 20 0.0000 4 240 210 6615 3106 Q\001
4 1 1 1 0 3 30 0.0000 4 60 105 6660 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 6615 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 6795 2611 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 5220 2611 1\001
4 1 -1 0 0 0 20 0.0000 4 255 765 3825 2790 FP:fp1\001
4 2 4 0 0 0 20 0.0000 4 240 810 1980 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 270 3285 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 2520 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2475 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 2611 1\001
4 1 1 1 0 3 20 0.0000 4 195 135 2610 3241 1\001
4 1 -1 0 0 0 20 0.0000 4 255 765 7920 2790 FP:fp2\001
4 1 4 0 0 0 20 0.0000 4 240 270 8505 2476 [f]\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 3106 S\001
4 1 1 1 0 3 30 0.0000 4 60 105 9135 2836 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 9090 2521 T\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 3241 2\001
4 1 1 1 0 3 20 0.0000 4 195 135 9270 2611 2\001
4 0 4 0 0 0 20 0.0000 4 240 960 9810 2791 SS:[out]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT/RT_desc.tex version [2c0ca51cf3].

1
2
3
4
5





-
-
-
-
-
Component \textbf{RT} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{R} component.
 

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT/RT_lbl.txt version [f1b276aa6b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY RT: Two port thermal resistance with T/Sdot bonds
%DESCRIPTION Port [in]: T/Sdot power in
%DESCRIPTION Port [out]: T/Sdot power out
%DESCRIPTION CR and parameters as for a one-port R component
%DESCRIPTION Internally pseudo bond graph 
%DESCRIPTION Example label file entry:
%DESCRIPTION % Component type RT
%DESCRIPTION	r		lin	flow,r

%ALIAS	ThermalIn	in
%ALIAS	ThermalOut	out

%ALIAS	$1	flow,r
%ALIAS	$a1	lin


%% Label file for system RT (RT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2001/07/03 22:59:10  gawthrop
% %% Fixed problems with argument passing for CRs
% %%
% %% Revision 1.6  2001/06/13 17:10:26  gawthrop
% %% Alias for the cr (ie ALIAS	$1	lin)
% %%
% %% Revision 1.5  2001/06/11 19:51:08  gawthrop
% %% Zapped spurious $1 alias
% %%
% %% Revision 1.4  1998/07/22 11:31:42  peterg
% %% New port names
% %%
% %% Revision 1.3  1998/07/21 16:26:05  peterg
% %% Now has aliased parameters.
% %%
% %% Revision 1.2  1998/06/29 10:08:14  peterg
% %% Converted to FP component
% %% Removed lables from FP
% %%
% %% Revision 1.1  1997/09/04  09:48:47  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank


% Component type R
	r		lin		flow,r

% Component type FP
        fp1
        fp2

% Component type SS
	[in]		SS		external,external
	[out]		SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT/TestRT_abg.fig version [cbe47fe6bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 3600 3600 3600 3375 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3600 5850 3600 5625 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 3420 3600 3780
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 3420 4500 3780
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7020 4725 1125 4725 1125 2295 7020 2295 7020 4725
4 1 -1 0 0 2 20 0.0000 4 195 705 4050 3690 RT:rt\001
4 1 -1 0 0 2 20 0.0000 4 255 870 1800 3690 SS:T_1\001
4 1 -1 0 0 2 20 0.0000 4 255 870 6345 3690 SS:T_2\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT/TestRT_lbl.txt version [c0d3a5ad40].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TestRT
%DESCRIPTION <Detailed description here>
%% Label file for system TestRT (TestRT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RT
	rt		lin		flow,r;0

% Component type SS
	T_1		external	external
	T_2		external	external

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT1/RT1_abg.fig version [b3391c9064].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 2700 2925 2700 2700 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 5175 2700 4950 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 5400 1125 5625 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 2700 6975 2700 6750 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 2701 9226 2701 9001 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10081 2701 11431 2701 11206 2926
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12600 4275 12600 450 225 450 225 4275 12600 4275
4 1 -1 0 0 0 20 0.0000000 4 210 690 3420 2790 ES:es\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5400 2790 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 390 5400 990 R:r\001
4 2 4 0 0 0 20 0.0000000 4 240 870 1485 2790 SS:[in]\001
4 1 4 0 0 0 20 0.0000000 4 240 330 2835 2475 [s]\001
4 1 4 0 0 0 20 0.0000000 4 240 345 3960 2475 [e]\001
4 1 -1 0 0 0 20 0.0000000 4 210 705 7470 2790 AF:af\001
4 1 -1 0 0 0 20 0.0000000 4 210 690 9676 2791 ES:se\001
4 0 4 0 0 0 20 0.0000000 4 240 1020 11611 2791 SS:[out]\001
4 1 4 0 0 0 20 0.0000000 4 240 345 9091 2476 [e]\001
4 1 4 0 0 0 20 0.0000000 4 240 330 10306 2476 [s]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT1/RT1_desc.tex version [4642e64d86].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Component \textbf{RT1} is a two port thermal resistor with true power
bonds. Internally, it has a pseudo Bond Graph representation, and the
corresponding thermal resistance just acts as an ordinary one-port
\textbf{R} component.
Unlike the {\bf RT} component, it is {\em one-sided\/} in the snese
that the paper flow depends only on the upstream temperature. It is
useful for modelling radiation via the Stefan-Boltzmann law when using
the {\bf StefanBoltzmann} CR.


This one-sidedness is achieved using the {\bf AF} component to isolate
the intrnal {\bf R} component from the downstream temperature.
 

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/comp/compound/Thermal/RT1/RT1_lbl.txt version [024d59e57d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system RT1 (RT1_lbl.txt)
%SUMMARY RT1: Two port thermal resistance with T/Sdot bonds
%DESCRIPTION Port [in]: T/Sdot power in
%DESCRIPTION Port [out]: T/Sdot power out
%DESCRIPTION CR and parameters as for a one-port R component
%DESCRIPTION One sided: flow depends on upstream temperature only
%DESCRIPTION Useful for radiation modelling
%DESCRIPTION Example label file entry:
%DESCRIPTION % Component type RT1
%DESCRIPTION	r		lin	flow,r


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 10:40:45  peterg
% %% Put under RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	r
%ALIAS	$1	lin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AF
	af

% Component type ES
	es
	se

% Component type R
	r		lin	flow,r

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/ThermalConversion/ES/ES_abg.fig version [59448e3014].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4515 2701 5865 2701 5640 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2715 2701 4065 2701 3840 2926
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 3600 225 3600 225 1801 8325 1801 8325 3600
4 1 4 0 0 0 20 0.0000000 4 270 360 4650 2476 [p]\001
4 1 -1 0 0 0 20 0.0000000 4 210 330 4290 2791 FP\001
4 1 4 0 0 0 20 0.0000000 4 240 315 3975 2476 [f]\001
4 1 1 1 0 3 20 0.0000000 4 210 165 3165 3106 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 3210 2836 .\001
4 1 1 1 0 3 20 0.0000000 4 270 210 5280 3106 Q\001
4 1 1 1 0 3 30 0.0000000 4 60 105 5325 2836 .\001
4 1 1 1 0 3 20 0.0000000 4 210 180 5280 2521 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 3165 2521 T\001
4 1 1 1 0 3 20 0.0000000 4 210 150 3300 2611 1\001
4 1 1 1 0 3 20 0.0000000 4 210 150 3300 3241 1\001
4 1 1 1 0 3 20 0.0000000 4 210 150 5460 2611 1\001
4 0 4 0 0 0 20 0.0000000 4 270 2115 6000 2791 SS:[EnergyFlow]\001
4 2 4 0 0 0 20 0.0000000 4 270 2220 2655 2790 SS:[EntropyFlow]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/ThermalConversion/ES/ES_lbl.txt version [aac3c82503].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system ES (ES_lbl.txt)
%SUMMARY ES	Identical to the FP component except for the port labels
%DESCRIPTION Converts true thermal to pseudo BGs

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	e|p	EnergyFlow
%ALIAS	s|f	EntropyFlow

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[EnergyFlow]	SS		external,external
	[EntropyFlow]	SS		external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/VM/VM_abg.fig version [3136079f4d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 3600 3825 3375 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 3600 4500 2925 4500 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1980 5400 2655 5625 2430
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 6975 3600 6750 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7246 3826 8371 3826 8146 4051
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5175 10125 450 225 450 225 5175 10125 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 1125 4500 1125 4275 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 900 4500 1395
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 1800 4500 1800 4275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 1575 4500 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4050 6300 4725 6525 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4500 4725 4320 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 4725 4950 4725 5175 4950
4 2 4 0 0 0 20 0.0000 4 255 1290 2073 3918 SS:[Hy_in]\001
4 1 1 1 0 3 30 0.0000 4 60 120 2570 4010 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2570 3650 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2570 4280 V\001
4 1 4 0 0 0 20 0.0000 4 240 570 5445 1935 [rho]\001
4 2 4 0 0 0 20 0.0000 4 240 675 5355 2700 [mod]\001
4 1 -1 0 0 22 20 0.0000 4 210 1365 5400 3015 EMAF:rho\001
4 1 4 0 0 0 20 0.0000 4 240 405 4860 3285 [in]\001
4 1 4 0 0 0 20 0.0000 4 240 555 5851 3241 [out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 8018 3968 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 8018 3608 P\001
4 1 1 1 0 3 20 0.0000 4 135 210 8018 4238 m\001
4 0 4 0 0 0 20 0.0000 4 255 1440 8551 3916 SS:[Hy_out]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3825 3915 1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6975 3915 0\001
4 1 1 1 0 3 20 0.0000 4 195 165 2613 948 T\001
4 2 4 0 0 0 20 0.0000 4 240 345 4410 1665 [P]\001
4 2 4 0 0 0 20 0.0000 4 240 360 4455 945 [T]\001
4 2 4 0 0 0 20 0.0000 4 240 750 2119 1849 SS:[P]\001
4 2 4 0 0 0 20 0.0000 4 240 765 2119 1219 SS:[T]\001
4 1 -1 0 0 22 20 0.0000 4 270 2130 5715 1530 Density:density\001
4 1 -1 0 0 22 20 0.0000 4 195 150 4725 4815 0\001
4 1 -1 0 0 22 20 0.0000 4 210 405 5985 4815 AE\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/VM/VM_desc.tex version [8bf823999e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system VM (VM_desc.tex)
% Generated by MTT on Thu Mar 19 14:37:43 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{VM} is
   displayed in Figure \Ref{VM_abg} and its label
   file is listed in Section \Ref{sec:VM_lbl}.
   The subsystems are listed in Section \Ref{sec:VM_sub}.

The \textbf{VM} component acts as a density-modulated transformer
converting a $P$/$\dot V$ energy bond to a $P$/$\dot m$ pseudo bond. It used
the \textbf{Density} component and therfore inherits the properties of
that component -- in particular it takes the same parameter. The four
ports are:

\begin{itemize}
\item [Hy_in]: hydraulic in
\item [Hy_out]: hydraulic out
\item [P]: Pressure
\item [T]: Temperature
\end{itemize}

Deleted mttroot/mtt/lib/comp/compound/Thermal/VM/VM_lbl.txt version [86421d4963].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY VM: Volumetric to mass flow and vv - pseudo mass-flow bond
%DESCRIPTION Converts between P/Vdot energy bond to a P/mdot pseudo bond
%DESCRIPTION Parameter 1: passed to the Density subcomponent
%% Label file for system VM (VM_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/26 08:37:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Density
	density		none		$1

% Component type EMAF
	rho

% Component type SS
	[Hy_in]		SS	external,external
	[Hy_out]	SS	external,external
	[P]		SS	external,external
	[T]		SS	external,external

Deleted mttroot/mtt/lib/comp/compound/Thermal/VMe/VMe_abg.fig version [671e477a6f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 4950 3825 4725 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 1350 4500 1350 4275 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2250 5400 3600 5625 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9045 4725 9045 450 225 450 225 4725 9045 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 3826 7201 3826 6976 4051
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 1125 4500 1620
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 2025 4500 2025 4275 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 1800 4500 2295
4 1 1 1 0 3 20 0.0000 4 195 165 2613 1173 T\001
4 2 4 0 0 0 20 0.0000 4 255 1290 2073 3918 SS:[Hy_in]\001
4 1 4 0 0 0 20 0.0000 4 240 570 5400 2115 [rho]\001
4 1 1 1 0 3 30 0.0000 4 60 120 2570 4010 .\001
4 1 1 1 0 3 20 0.0000 4 195 165 2570 3650 P\001
4 1 1 1 0 3 20 0.0000 4 195 195 2570 4280 V\001
4 1 4 0 0 0 20 0.0000 4 240 405 4725 3690 [in]\001
4 2 4 0 0 0 20 0.0000 4 240 675 5310 3330 [mod]\001
4 1 -1 0 0 22 20 0.0000 4 210 1065 5535 3915 EMTF:tf\001
4 1 4 0 0 0 20 0.0000 4 240 555 6301 3691 [out]\001
4 1 1 1 0 3 30 0.0000 4 60 120 6848 3968 .\001
4 1 1 1 0 3 20 0.0000 4 195 270 6848 3608 Pv\001
4 1 1 1 0 3 20 0.0000 4 135 210 6848 4238 m\001
4 1 -1 0 0 22 20 0.0000 4 270 2130 5805 1665 Density:density\001
4 2 4 0 0 0 20 0.0000 4 240 345 4410 1890 [P]\001
4 2 4 0 0 0 20 0.0000 4 240 360 4455 1170 [T]\001
4 2 4 0 0 0 20 0.0000 4 240 750 2119 2074 SS:[P]\001
4 2 4 0 0 0 20 0.0000 4 240 765 2119 1444 SS:[T]\001
4 0 4 0 0 0 20 0.0000 4 255 1440 7381 3916 SS:[Hy_out]\001

Deleted mttroot/mtt/lib/comp/compound/Thermal/VMe/VMe_desc.tex version [2e1c5f9d5d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system VMe (VMe_desc.tex)
% Generated by MTT on Thu Mar 19 14:37:43 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{VMe} is
   displayed in Figure \Ref{VMe_abg} and its label
   file is listed in Section \Ref{sec:VMe_lbl}.
   The subsystems are listed in Section \Ref{sec:VMe_sub}.

The \textbf{VMe} component acts as a density-modulated transformer
converting a $P$/$\dot V$ energy bond to a $Pv$/$\dot m$ bond. It used
the \textbf{Density} component and therfore inherits the properties of
that component -- in particular it takes the same parameter. The four
ports are:

\begin{itemize}
\item [Hy_in]: hydraulic in
\item [Hy_out]: hydraulic out
\item [P]: Pressure
\item [T]: Temperature
\end{itemize}

Deleted mttroot/mtt/lib/comp/compound/Thermal/VMe/VMe_lbl.txt version [1cd2644cf2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY VMe: Volumetric to mass flow and vv - energy bonds
%DESCRIPTION Converts between P/Vdot energy bond to a Pv/mdot energy bond
%DESCRIPTION Parameter 1: passed to the Density subcomponent
%% Label file for system VMe (VMe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/26 08:38:15  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Density
	density		none		$1

% Component type EMTF
	tf		lin		flow

% Component type SS
	[Hy_in]		SS	external,external
	[Hy_out]	SS	external,external
	[P]		SS	external,external
	[T]		SS	external,external

Deleted mttroot/mtt/lib/comp/simple/AE_alias.m version [6bf2090b41].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = AE_alias	# Port aliases for AE

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/AE_cause.m version [4bfc8d144a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = AE_cause(bonds);
% AE_cause - Causality for effort amplifier component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  AE_cause
% [bonds,status] = AE_cause(bonds)

%SUMMARY AE: effort amplifier
%DESCRIPTION Port[1]: amplifier effort input e_1 (f_1=0)
%DESCRIPTION Port[2]: amplifier effort output e_2 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/11/01 11:40:30  peterg
% %% Documentation.
% %%
% %% Revision 1.1  1996/08/30 19:05:21  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AE')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% Port 1 must impose (zero) flow and port 2 have flow imposed
if (f_1==-1)|(f_2==1) % Conflict
  status = 1;
 else 					% Do the rest of the causality

   if f_1 == 0 				% Set port 1 effort
     f_1 = 1;
   end;
   
   if f_2 == 0 				% Set port 2 effort
     f_2 = -1;
   end;
   
   number_set = sum(sum([e_1 e_2]~=zeros(1,2) ));
   if number_set==0 			% Under causal
     status = -1;
   elseif number_set==1 		% Set the causality
     if e_1 == 0
       e_1 = -e_2;
     else
       e_2 = -e_1;
     end
     status = 0;
   elseif number_set==2 		% Check the causality
     if e_1==-e_2
       status = 0;
     else
       status = 1;
     end
 end;
end;
 
 bonds = [e_1 f_1
           e_2 f_2]

Deleted mttroot/mtt/lib/comp/simple/AE_eqn.m version [a764490bd3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = AE_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);
% AE_eqn. Equation generation for effort amplifier.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/09/10 10:10:41  peter
% %% Now uses eqaution.m to format the equation.
% %%
% %% Revision 1.3  1996/08/30 19:03:10  peter
% %% Added argument check.
% %% Added extra name argument.
% %%
% %% Revision 1.2  1996/08/30 13:23:11  peter
% %% Added bond number check
% %%
% %% Revision 1.1  1996/08/22 13:12:34  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AE')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Flow on port 1 is always zero
   fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(1), -1));
  
  
outcause = 1;
incause = 1;

if e_2 == -1 				% Unicausal: e_2 := e_1
  outbond = bond_number(2);
  inbond = bond_number(1);
  outport = 2;
  inport = 1;
else 	                                % Bicausal: e_1 := e_2      
  outbond = bond_number(1);
  inbond = bond_number(2);
  outport = 1;
  inport = 2;
end


eqn =  equation("AE",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

			  
			  
			  



Deleted mttroot/mtt/lib/comp/simple/AE_seqn.m version [9121c470c0].

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = AE_seqn (Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = AE_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## Implements the AE component 

  [eqn,insigs,innames] = Amp_seqn ("AE",Name, name, cr, arg, outsig, insigs, innames);
endfunction

Deleted mttroot/mtt/lib/comp/simple/AF_alias.m version [779ca55ad2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = AF_alias	# Port aliases for AF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/AF_cause.m version [de8629abe8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = AF_cause(bonds);
% AF_cause - Causality for Flow amplifier component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  AF_cause
% [bonds,status] = AF_cause(bonds)

%SUMMARY AF: flow amplifier
%DESCRIPTION Port[1]: amplifier flow input f_1 (e_1=0)
%DESCRIPTION Port[2]: amplifier flow output f_2 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/08/30 19:05:32  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% Port 1 must impose (zero) effort and port 2 have effort imposed
if (e_1==1)|(e_2==-1) % Conflict
  status = 1;
 else 					% Do the rest of the causality

   if e_1 == 0 				% Set port 1 effort
     e_1 = -1;
   end;
   
   if e_2 == 0 				% Set port 2 effort
     e_2 = 1;
   end;
   
   number_set = sum(sum([f_1 f_2]~=zeros(1,2) ));
   if number_set==0 			% Under causal
     status = -1;
   elseif number_set==1 		% Set the causality
     if f_1 == 0
       f_1 = -f_2;
     else
       f_2 = -f_1;
     end
     status = 0;
   elseif number_set==2 		% Check the causality
     if f_1==-f_2
       status = 0;
     else
       status = 1;
     end
 end;
end;
 
 bonds = [e_1 f_1
           e_2 f_2];

Deleted mttroot/mtt/lib/comp/simple/AF_eqn.m version [beebc3dcaf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = AF_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% AF_eqn - equations for flow amplifier
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  AF_eqn
% structure = AF_eqn(bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/09/12 19:29:35  peter
% %% Use new equation method.
% %%
% %% Revision 1.2  1996/09/11 13:35:14  peter
% %% New equation.m method used.
% %%
% %% Revision 1.1  1996/08/30 18:38:57  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'AF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% Effort on port 1 is always zero
   fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(1), 1));
  
outcause = -1;
incause = -1;

if f_2 == 1 				% Unicausal: f_2 := f_1
  outbond = bond_number(2);
  inbond = bond_number(1);
  outport = 2;
  inport = 1;
else 	                                % Bicausal: f_1 := f_2      
  outbond = bond_number(1);
  inbond = bond_number(2);
  outport = 1;
  inport = 2;
end


eqn =  equation("AF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);







Deleted mttroot/mtt/lib/comp/simple/AF_seqn.m version [969c3baa60].

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = AF_seqn (Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = AF_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## Implements the AF component 

  [eqn,insigs,innames] = Amp_seqn ("AF",Name, name, cr, arg, outsig, insigs, innames);
endfunction

Deleted mttroot/mtt/lib/comp/simple/Amp_seqn.m version [fde6465120].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = Amp_seqn (AmpType,Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = AF_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 

  N = mtt_check_sigs (outsig,insigs);
  if (N!=2)
    mtt_error("Amplifier component must have exactly two ports");
  endif
  

  ## On which port is the equation required?
  outbond_number = outsig(1);
  outport = find(abs(insigs(:,1))!=outbond_number*ones(N,1));

  ## Some definitions
  flow = -1;
  effort = 1;

  if strcmp(AmpType,"AE")
    causality = effort;
    other_causality = flow;
  elseif strcmp(AmpType,"AF")
    causality = flow;
    other_causality = effort;
  else
    mtt_error(sprintf("Amp_seqn: type %s unknown", AmpType));
  endif
  
  ## Standard causality
  if (outport==2)
    qAmpType = sprintf("""%s""", AmpType);
    eqn = equation(qAmpType,Name,cr,arg,outsig(1),causality,2, ...
		 insigs(2,1),causality,1);
  elseif (outport==1)
    LHS = varname(Name,insigs(2,1),other_causality);
    eqn = sprintf("%s := 0;", LHS);
  else
    mtt_error("AF_seqn: outport must be 1 or 2");
  endif

endfunction

Deleted mttroot/mtt/lib/comp/simple/C2_cause.m version [1f39f9455a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = C2_cause(bonds);
% C2_cause - Unicausal multiport C2 C2omponent
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  C2_cause
% [bonds,status] = C2_cause(bonds)

%SUMMARY C2: elementary C component with two ports
%DESCRIPTION Two port dynamic component
%DESCRIPTION Preferred integral causality (flow input)
%DESCRIPTION Cannot be bicausal




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1996.

% Unicausal multiport C component
% Same causal pattern as R component

[bonds,status] = R_cause(bonds);


Deleted mttroot/mtt/lib/comp/simple/CI_seqn.m version [2217509088].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = CI_seqn (comp_type,Name, name, cr, arg, outsig, insigs ,innames)

  ## usage:  [eqn,inbonds] = CI_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port C's ??

  delim = "__";
  N = mtt_check_sigs (outsig,insigs);

  state_index=3;
  
  i_cause = outsig(2);		# Extract causality

  state_equation=((i_cause==1)&&strcmp(comp_type,"C")) ...
      ||((i_cause==-1)&&strcmp(comp_type,"I"));

  ## Create the equation
  if state_equation			# output/state
    LHS = varname(Name, outsig(1,1), state_index);
    RHS = sprintf("MTTx_%s%s%s", Name, delim, name);
    eqn_1 = sprintf("%s := %s;", LHS, RHS);
    
    inports = [1:N]; 
    comp_type_str=sprintf("""%s""", comp_type);
    eqn_2 = equation(comp_type_str,Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
	     insigs(:,1),state_index,inports);
    
    eqn = sprintf("%s\n%s", eqn_1, eqn_2);
  else			# state derivative
    RHS = varname(Name, insigs(1,1), insigs(1,2));
    LHS = sprintf("MTTdx_%s%s%s", Name, delim, name);
    eqn = sprintf("%s := %s;", LHS, RHS);
  endif
  
endfunction

Deleted mttroot/mtt/lib/comp/simple/C_alias.m version [1470d15671].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = C_alias	# Port aliases for C

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 14:49:14  peterg
## Initial revision
##
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/C_cause.m version [2222eab409].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = C_cause(bonds);
% C_cause - Unicausal multiport C component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  C_cause
% [bonds,status] = C_cause(bonds)

%SUMMARY C: elementary C component
%DESCRIPTION Single port dynamic component
%DESCRIPTION Preferred integral causality (flow input)
%DESCRIPTION Cannot be bicausal



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/11/01 12:35:36  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% Unicausal multiport C component
% Same causal pattern as R component

% [bonds,status] = R_cause(bonds);

% Set causality to preferred if not already set.
% Find the number of ports
[ports,junk] = size(bonds);

% default undercausal status
statuses = -ones(ports,1);

% Force unicausality but DONT set if not already set
preferred = -1;
for i = 1:ports
  if (bonds(i,1)~=0)&(bonds(i,2)~=0) % Both bonds set
    statuses(i) = bonds(i,1)~=bonds(i,2);
  elseif bonds(i,2)~=0               % Bond 1 set
    bonds(i,1) = bonds(i,2);
    statuses(i) = 0;
  elseif bonds(i,1)~=0               % Bond 2 set
    bonds(i,2) = bonds(i,1);
    statuses(i) = 0;
  else				# Don't set
#    bonds(i,1) = preferred;
#    bonds(i,2) = preferred;
#    statuses(i) = 0;
  end;
end;

if max(statuses)==1
  status = 1;
elseif min(statuses)==-1
  status = -1;
else
  status = 0;
end;


Deleted mttroot/mtt/lib/comp/simple/C_eqn.m version [0e1e88a5f1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function structure =  C_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% C_eqn - equation generation for C component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  C_eqn
% structure =  C_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2003/01/07 10:10:14  gawthrop
% %% Uses new version of equation.m - passes component type to cr.
% %%
% %% Revision 1.2  1997/04/09 13:00:28  peterg
% %% *** empty log message ***
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

			
if nargin<8
  eqnfile = 'stdout';
end;

% Unicausal version
CorI = 1;
structure = cieqn(name,bond_number,bonds,direction,cr,args, structure, ...
                 CorI, eqnfile);







Deleted mttroot/mtt/lib/comp/simple/C_seqn.m version [40b9922c1a].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = C_seqn (Name, name, cr, arg, outsig, insigs ,innames)

  ## usage:  [eqn,inbonds] = C_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port C's ??


  [eqn,insigs,innames] = CI_seqn ("C", Name, name, cr, arg, outsig, insigs ,innames);

endfunction

Deleted mttroot/mtt/lib/comp/simple/EBTF_alias.m version [e1757cdf64].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = EBTF_alias	# Port aliases for EBTF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/EBTF_cause.m version [61b581107d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = EBTF_cause(bonds);
% EBTF_cause - causality for a EBTF component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  EBTF_cause
% [bonds,status] = EBTF_cause(bonds)

%SUMMARY EBTF: transformer component - bicausal on effort
%DESCRIPTION Energy conserving two-port
%DESCRIPTION e_1 f_1 = e_2 f_2 and e_1 and e_2 are both imposed.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




% Copyright (c) P.J. Gawthrop, 1998.

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'EBTF')==0
  return
end

% Effort must be imposed by both bonds
if (bonds(1,1)==-1)|(bonds(2,1)==-1) % Overcausal
  status = 1;
  return
end;

bonds(1,1) = 1; 
bonds(2,1) = 1;

% Flow bond must have through causality
if (bonds(1,2)==0)&(bonds(2,2)==0) % Undercausal
  status = -1;
  return
end;

if (bonds(1,2)==bonds(2,2))&(bonds(1,2)!=0) % Overcausal
  status = 1;
  return
end;

%Set flow causality
if (bonds(1,2)!=0)
  bonds(2,2) = -bonds(1,2)
else
  bonds(1,2) = -bonds(2,2)
end;
  
status = 0;







Deleted mttroot/mtt/lib/comp/simple/EBTF_eqn.m version [f9d4dc3a42].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = EBTF_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);

if nargin<8
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'EBTF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Effort -- no equation

% Flow
effort1_name = varname(name,bond_number(1), 1);
effort2_name = varname(name,bond_number(2), 1);
flow1_name = varname(name,bond_number(1), -1);
flow2_name = varname(name,bond_number(2), -1);

if f_1==-1 %Write flow on port 2
  fprintf(eqnfile,'%s := (%s/%s)*%s;\n' , ...
      flow2_name, ...
      effort1_name, ...
      effort2_name, ...
      flow1_name);
else %Write flow on port 1
  fprintf(eqnfile,'%s := (%s/%s)*%s;\n' , ...
      flow1_name, ...
      effort2_name, ...
      effort1_name, ...
      flow2_name);
end;

 









Deleted mttroot/mtt/lib/comp/simple/EMTF_alias.m version [b25e2d18fc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = EMTF_alias	# Port aliases for EMTF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';
  alias.mod    = '3';

endfunction


Deleted mttroot/mtt/lib/comp/simple/EMTF_cause.m version [e4232f67a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = EMTF_cause(bonds);
% EMTF_cause - causality for a modulated TF component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  EMTF_cause
% [bonds,status] = EMTF_cause(bonds)
% Causality for effort-modulated EMTF 
% At the moment, modulation can NOT be inverted.

%SUMMARY EMTF: effort-modulated transformer
%DESCRIPTION Energy conserving three-port
%DESCRIPTION Ports [1] and [2] as for TF
%DESCRIPTION e_1 = f(f_2); f_1 = f(e_2)
%DESCRIPTION Effort on port[3] modulates the CR


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

status = -1;

% Check that there are exactly three bonds.
if check_bonds(bonds,3,'EMTF')==0
  return
end

% Extract the bond information
TF_bonds = bonds(1:2,:);
e_3 = bonds(3,1);
f_3 = bonds(3,2);

%Causality of EMTF is same as that of a TF on ports 1 and 2
[TF_bonds,TF_status] = TF_cause(TF_bonds);


% Effort is the modulation - imposed on component.
if e_3==-1 				% Conflict
  mod_status_e = 1;
else 					% Do the rest of the causality
  if e_3==0 				% Set to the fixed causality
    e_3 = 1;
  end;
  mod_status_e = 0;
end;
 
% Zero flow imposed by component.
if f_3==-1 				% Conflict
  mod_status_f = 1;
else 					% Do the rest of the causality
  if f_3==0 				% Set to the fixed causality
    f_3 = 1;
  end;
  mod_status_f = 0;
end;
 
bonds = [TF_bonds
         e_3 f_3];
	
if (TF_status == 0) & (mod_status_e == 0) & (mod_status_f == 0)
  status = 0;
end;

if (TF_status == 1) | (mod_status_e == 1) | (mod_status_f == 1)
  status = 1;
end;

 
 
 
 
 
   

Deleted mttroot/mtt/lib/comp/simple/EMTF_eqn.m version [7cc82fd47a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = EMTF_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 11:45:48  peterg
% %% *** empty log message ***
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


			
if nargin<8
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,3,'EMTF')==0
  return
end

% There are 3 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);
e_3 = bonds(3,1);


% Effort
outcause = 1;
incause = [1;1];
if e_1==1
  outbond = bond_number(2);
  inbond =  bond_number([1 3]);
  outport = 2;
  inport = [1;3];
else
  outbond = bond_number(1);
  inbond =  bond_number([2 3]);
  outport = 1;
  inport = [2;3];
end;

eqn =  equation("EMTF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Flow
outcause = -1;
incause = [-1;1];
if f_1==-1
  outbond = bond_number(2);
  inbond =  bond_number([1 3]);
  outport = 2;
  inport = [1;3];
else
  outbond = bond_number(1);
  inbond =  bond_number([2 3]);
  outport = 1;
  inport = [2;3];
end;

eqn =  equation("EMTF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Modulation: flow on port 3 is always zero
  fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(3), -1));







Deleted mttroot/mtt/lib/comp/simple/ES_alias.m version [2c3cf765fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = ES_alias	# Port aliases for ES

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 14:47:53  peterg
## Initial revision
##
###############################################################

  alias.in     = '1';
  alias.out    = '2';

  alias.e     = '1';
  alias.s     = '2';

  alias.enthalpy     = '1';
  alias.entropy      = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/ES_cause.m version [b7ca65e279].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = ES_cause(bonds);
% Causality for ES component

%SUMMARY ES: converts thermal pseudobond to true bond and vv
%DESCRIPTION Port [e]: temperature (T) / enthalpy flow (E) bond
%DESCRIPTION Port [s]: temperature (T) / entropy flow (S) bond



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'ES')==0
  return
end

% Same causality as TF
[bonds,status] = TF_cause(bonds);


Deleted mttroot/mtt/lib/comp/simple/ES_eqn.m version [31e29928e3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = ES_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% ES_eqn - equations for ES component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  ES_eqn
% ES_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/02/25 16:59:56  peterg
% %% Corrected enthalpy-entropy conversion -- use temp on the entropy side.
% %%
% %% Revision 1.1  1998/02/25 15:03:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'ES')==0
  return
end


% There are 2 ports; extract the information
e_bond = bonds(1,:);
s_bond = bonds(2,:);

% The efforts are the same - but the enthalpy side has relative T
if e_bond(1)==1 %effort imposed on the enthalpy bond 
%  fprintf(eqnfile,'%s := %s + t_0;\n' , ...
  fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(2), 1), ...
    varname(name,bond_number(1), 1) );
else %effort imposed on the entropy bond 
%  fprintf(eqnfile,'%s := %s - t_0;\n' , ...
  fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
end;

% The flows need to be converted - use the absolute temp on the
% entropy side
if e_bond(2)==-1 %flow imposed on the enthalpy bond 
  fprintf(eqnfile,'%s := %s/%s;\n' , ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), 1) );
else % flow imposed on the entropy bond 
    fprintf(eqnfile,'%s := %s*%s;\n' , ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(2), 1) );
end;

Deleted mttroot/mtt/lib/comp/simple/FMR_alias.m version [85c12f71ad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = FMR_alias	# Port aliases for FMR

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/02 14:47:14  peterg
## Initial revision
##
###############################################################

  alias.in     = '1';
  alias.out    = '2';
  alias.mod    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/FMR_cause.m version [5abb14a644].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = FMR_cause(bonds);

% Causality for Flow-modulated R component

%SUMMARY FMR: flow-modulated resistor
%DESCRIPTION Port[in]: a simple one port resistor
%DESCRIPTION Port[out]: flow provides modulation for the resistor
%DESCRIPTION Used with the lin CR, with parameters flow,r this gives
%DESCRIPTION a resistance r*f_m where f_m is the flow on port [out]
%DESCRIPTION Can be bicausal - deduces modulation from e and f on port[in]

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/11/01 11:53:48  peterg
% %% Documentation
% %%
% %% Revision 1.2  1996/08/30 13:29:05  peter
% %% Error check on bond numbers.
% %%
% %% Revision 1.1  1996/08/09 08:28:02  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'FMR')==0
  return
end


% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

% e_2 must be effort causality (imposes zero effort)
 if e_2 == 1 				% Conflict
   status = 1;
 else 					% Do the rest of the causality
   if e_2==0 				% Set to the fixed causality
     e_2 = -1;
   end;
   
   number_set = sum(sum([e_1 f_1 f_2]~=zeros(1,3) ));
   if number_set<2 			% Under causal
     status = -1;
   elseif number_set==2 		% Set the causality
     if f_2 == -1 			% Unicausal
       if e_1 == 0
 	e_1 = f_1;
       else
	 f_1 = e_1;
       end;
     elseif f_2 == 1 			% Bicausal
       e_1 = 1;
       f_1 = -1;
     elseif f_2 == 0
       if e_1==f_1
	 f_2 = -1;                      % Unicausal
       else
	 f_2 = 1;                      % Bicausal
       end;
     end;
     status = 0;
   elseif number_set==3 		% Check the causality
     if ( (f_2==-1)&(e_1~=f_1) )|( (f_2==1)&(e_1==f_1) )
       status = 1;
     else
       status = 0;
     end;
   end;
 end;
 
 bonds = [e_1 f_1
           e_2 f_2];

Deleted mttroot/mtt/lib/comp/simple/FMR_eqn.m version [da8322ed66].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = FMR_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% FMR_eqn - equations for flow-modulated resistor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  FMR_eqn
% FMR_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/09/12 19:30:31  peter
% %% Updated to use new eqaution.m
% %%
% %% Revision 1.2  1996/08/30 18:35:43  peter
% %% New name argument added.
% %%
% %% Revision 1.1  1996/08/30 16:38:25  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'FMR')==0
  return
end


% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);

if length(cr)==0  % Then do default unity CR
  if f_2 == -1 				% Standard with modulation
    if f_1 == 1 			% Flow out
      op = '*';
    else                                % Effort out
      op = '/';
    end;
    
    fprintf(eqnfile, '%s := %s%s%s;\n', ...
	varname(name,bond_number(1), -e_1), ...
	varname(name,bond_number(1), e_1), ...
	op, ...
	varname(name,bond_number(2), -1));
  else 					% Deduce modulation
    
    fprintf(eqnfile, '%s := %s/%s;\n', ...
	varname(name,bond_number(2), -1), ...
	varname(name,bond_number(1), -1), ...
	varname(name,bond_number(1), 1));
  end;
else  % write the full works
  if f_2 == -1 				% Standard with modulation
    outport = 1;
    outnumber = bond_number(1);
    if f_1 == 1 			% Flow out
      outcause = -1;
    else                                % Effort out
      outcause = 1;
    end;    
    incause = [-outcause; -1]; % Flow input on port 2
    eqn =  equation("FMR",name,cr,args,outnumber,outcause,outport, ...
                               bond_number,incause,1:ports);
    fprintf(eqnfile, '%s',eqn);

  else % Modulation is output
    outport = 2;
    outcause = -1;
    outnumber = bond_number(2);
    innumber = bond_number(1)*[1;1];    
    incause = [1; -1]; % Effort and flow on port 1
    inports = [1; 1];
    eqn =  equation("FMR",name,cr,args,outnumber,outcause,outport, ...
                               innumber,incause,inports);
    fprintf(eqnfile, '%s',eqn);
  end;
end;

  % Effort on port 2 is always zero
  fprintf(eqnfile, '%s := 0;\n', ...
      varname(name,bond_number(2), 1));

 
      


 



Deleted mttroot/mtt/lib/comp/simple/FP_alias.m version [793aa2894c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = FP_alias	# Port aliases for FP

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/07 15:01:09  peterg
## Named ports correctely  f --> 1, p --> 2
##
## Revision 1.1  1998/07/02 14:46:42  peterg
## Initial revision
##
###############################################################

  alias.f     = '1';
  alias.p     = '2';

  alias.s     = '1';
  alias.e     = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/FP_cause.m version [95df5297d9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = FP_cause(bonds);
% Causality for FP component

%SUMMARY FP: converts true bond to a pseudo bond with power flow as flow
%DESCRIPTION Port [f]: True bond with a flow covariable
%DESCRIPTION Port [p]: Pseudo bond with power (ef) as flow variable



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/06/29 09:56:24  peterg
% %% Changed name to FP from ES
% %%
% %% Revision 1.1  1998/06/29 09:56:02  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/09/04  08:34:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'FP')==0
  return
end

% Same causality as TF
[bonds,status] = TF_cause(bonds);



Deleted mttroot/mtt/lib/comp/simple/FP_eqn.m version [764e3abe81].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = FP_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% FP_eqn - equations for FP component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  FP_eqn
% FP_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/07 15:00:04  peterg
% %% Replaced e_ by f_
% %%          s_ by p_
% %%
% %% Revision 1.2  1998/06/29 09:54:16  peterg
% %% Changed name from ES to FP
% %%
% %% Revision 1.1  1998/06/29 09:53:22  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/03/27 10:59:43  peterg
% %% Zapped t_0 again ...
% %%
% %% Revision 1.2  1998/02/25 16:59:56  peterg
% %% Corrected enthalpy-entropy conversion -- use temp on the entropy side.
% %%
% %% Revision 1.1  1998/02/25 15:03:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'FP')==0
  return
end


% There are 2 ports; extract the information
f_bond = bonds(1,:);
p_bond = bonds(2,:);

% The efforts are the same
if p_bond(1)==1 %effort imposed on the pseudo bond 
    fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
else %effort imposed on the true bond 
    fprintf(eqnfile,'%s := %s;\n' , ...
    varname(name,bond_number(2), 1), ...
    varname(name,bond_number(1), 1) );
end;

% The flows need to be converted
if p_bond(2)==-1 %flow imposed on the pseudo bond 
  fprintf(eqnfile,'%s := %s/%s;\n' , ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(1), 1) );
else % flow imposed on the true bond 
    fprintf(eqnfile,'%s := %s*%s;\n' , ...
    varname(name,bond_number(2), -1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), 1) );
end;

Deleted mttroot/mtt/lib/comp/simple/GY_alias.m version [e9fdf0c734].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = GY_alias	# Port aliases for GY

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/GY_cause.m version [eeb1062035].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = GY_cause(bonds);
% GY_cause - causality for GY component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  GY_cause
% [bonds,status] = GY_cause(bonds);

%SUMMARY GY: elementary gyrator component
%DESCRIPTION Energy conserving two-port
%DESCRIPTION e_1 = f(f_2); f_1 = f(e_2)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/09/12  09:42:12  peterg
% %% Fixed causality bug.
% %%
% %% Revision 1.1  1996/11/01  12:04:25  peterg
% %% Initial revision
% %% 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

%Causality of GY is same as that of a TF but with flipped effort/flow
bonds(2,:) = - bonds(2,2:-1:1);
[bonds,status] = TF_cause(bonds);
bonds(2,:) = - bonds(2,2:-1:1);

Deleted mttroot/mtt/lib/comp/simple/GY_eqn.m version [b248761e3d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = GY_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% GY_eqn - equations for GY component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  GY_eqn
% structure = GY_eqn(bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 11:51:06  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


if nargin<8
  eqnfile = 'stdout';
end;


% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Effort - flow
if e_1==1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
  outcause = -1;
  incause = 1;
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
  outcause = 1;
  incause = -1;
end;

eqn =  equation("GY",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Flow-effort
if f_1==-1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
  outcause = 1;
  incause = -1; 
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
  outcause = -1;
  incause = 1; 
end;

eqn =  equation("GY",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

Deleted mttroot/mtt/lib/comp/simple/GY_seqn.m version [a2d9704220].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = GY_seqn (Name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = GY_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ##
  ## GYs have two ports; the input and output ports must be different
  N = mtt_check_sigs (outsig,insigs);

  if N!=2
    error("A GY must have exactly two ports");
  else
    if insigs(1,3)==outsig(3)	# First signal is on output port
      inport = 2;
    else
      inport = 1;
    endif
  endif
  
  insig = insigs(inport,:);
  inname = innames(inport,:);
  eqn = equation("""GY""",Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
		 insig(:,1),insig(:,2),inport);

  insigs = insig;		# Set the correct input signals
  innames = inname;		# Set the correct input names
  
endfunction

Deleted mttroot/mtt/lib/comp/simple/I_alias.m version [0cb127a054].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = I_alias	# Port aliases for I

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in   = '1';
  alias.out  = '1';

endfunction


Deleted mttroot/mtt/lib/comp/simple/I_cause.m version [30d1b2c13a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = I_cause(bonds);
% I_cause  - Unicausal multiport C component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  I_cause
% [bonds,status] = I_cause(bonds)

%SUMMARY I: elementary I component
%DESCRIPTION Single port dynamic component
%DESCRIPTION Preferred integral causality (effort input)
%DESCRIPTION Cannot be bicausal


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% Same causal pattern as R component
[bonds,status] = R_cause(bonds);


Deleted mttroot/mtt/lib/comp/simple/I_eqn.m version [b3f1b49438].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function structure =  I_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% I_eqn - equations for I component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  I_eqn
% structure =  I_eqn(bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.


if nargin<8
  eqnfile = 'stdout';
end;

% Unicausal version
CorI = -1;
structure = cieqn(name,bond_number,bonds,direction,cr,args, structure, ...
                 CorI, eqnfile);

Deleted mttroot/mtt/lib/comp/simple/I_seqn.m version [b8f0958d68].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = I_seqn (Name, name, cr, arg, outsig, insigs ,innames)

  ## usage:  [eqn,inbonds] = I_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port I's ??


  [eqn,insigs,innames] = CI_seqn ("I", Name, name, cr, arg, outsig, insigs ,innames);

endfunction

Deleted mttroot/mtt/lib/comp/simple/PS_alias.m version [9be95d8930].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = PS_alias	# Port aliases for PS

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';
  alias.power  = '3';

endfunction


Deleted mttroot/mtt/lib/comp/simple/PS_cause.m version [c1061e4855].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = PS_cause(bonds);
% Causality for PS component

%SUMMARY PS: Power sensor
%DESCRIPTION Port[in]: Inflowing bond
%DESCRIPTION Port[out]: Outflowing bond e_2=e_1; f_2=f_1.
%DESCRIPTION Port[power]: f = power = e_1*f_1 = e_2*f_2


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly three bonds.
if check_bonds(bonds,3,'PS')==0
  return
end

% Do the [in] and [out] ports -- like a TF
inout_bonds = bonds(1:2,:);
[inout_bonds,inout_status] = TF_cause(inout_bonds);

% Do the power port -- must have flow out and effort in
power_bonds = bonds(3,:);
for i = 1:2
  if (power_bonds(i)==1)
    power_status = 0;
  elseif (power_bonds(i)==0)
    power_bonds(i)==1;
    power_status = 0;
  else
    power_status = 1;
  end;
end;


  
  
  
  
% Reconstruct the bonds
bonds = [inout_bonds; power_bonds];

% Generate an overall status
if (inout_status==1)|(power_status==1)
  status = 1;
elseif
  (inout_status==-1)|(power_status==-1)
  status=-1;
else
  status = 0;
end;


Deleted mttroot/mtt/lib/comp/simple/PS_eqn.m version [2c48293db7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = PS_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% PS_eqn - equations for a power sensor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  PS_eqn
% PS_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly three bonds.
ports = 3;
if check_bonds(bonds,ports,'PS')==0
  return
end


% There are 3 ports; extract the information
inout_bonds = bonds(1:2,:);
power_bonds = bonds(3,:);

inout_direction = direction(1:2,:);
power_direction = direction(3,:);

% Do ports [in] and [out] - unit gain TF.
structure = TF_eqn(name,bond_number(1:2),inout_bonds,inout_direction, ...
'lin','effort,1', structure,eqnfile);

% Do port [power] - the power bit.
% This computes f_2 = e_1*f_1
fprintf(eqnfile,'%s := %s*%s;\n' , ...
    varname(name,bond_number(3), -power_bonds(1)), ...
    varname(name,bond_number(1),  1), ...
    varname(name,bond_number(1), -1) );



Deleted mttroot/mtt/lib/comp/simple/RST_alias.m version [bd9ad2f3b7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = RST_alias	# Port aliases for RST

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/RST_cause.m version [9248b5c94d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = RST_cause(bonds);
% Causality for RST component

%SUMMARY RST: thermal resistor with entropy generation
%DESCRIPTION Port[in]: a simple one port resistor but:
%DESCRIPTION flow is multiplied by e_out
%DESCRIPTION Port[out]: thermal power - effort is temperature, flow is entropy flow
%DESCRIPTION Not bicausal (yet)


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'RST')==0
  return
end

% Same causality as RS
[bonds,status] = RS_cause(bonds);

Deleted mttroot/mtt/lib/comp/simple/RST_eqn.m version [a09541d179].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = RT_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% RT_eqn - equations for flow-modulated resistor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  RT_eqn
% RT_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% VeRTion control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/03  09:30:45  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'RT')==0
  return
end


% There are 2 ports; extract the information
in_bonds = bonds(1,:);
out_bonds = bonds(2,:);
in_direction = direction(1,:);
out_direction = direction(2,:);

% Do port [in] - a standard resistor -- except for modulation by e_2
structure = R_eqn(name,bond_number(1),in_bonds,in_direction,cr,args, ...
    structure,eqnfile);

% Resistance is multiplied by effort e_1 + e_2 (ie effort on upsteam side of
% the 1 junction)
if in_bonds(1) == 1 % Flow output - divide by e_1+e_2
  fprintf(eqnfile,'%s := %s/(%s+%s);\n' , ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
else
   % Effort output - multiply by e_1+e_2
  fprintf(eqnfile,'%s := %s*(%s+%s);\n' , ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(1), 1), ...
    varname(name,bond_number(2), 1) );
end;


% Do port [out] - the thermal bit. RT is power conserving.
% This computes f_2 = e_1*f_1/e_2 or  e_2 = e_1*f_1/f_2
fprintf(eqnfile,'%s := %s*%s/%s;\n' , ...
    varname(name,bond_number(2), -out_bonds(1)), ...
    varname(name,bond_number(1),  1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), out_bonds(1)) );


Deleted mttroot/mtt/lib/comp/simple/RS_alias.m version [6c14fcbe8a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = RS_alias	# Port aliases for RS

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/RS_cause.m version [c96451fbaa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = RS_cause(bonds);
% Causality for RS component

%SUMMARY RS: resistor with entropy generation
%DESCRIPTION Port[in]: a simple one port resistor
%DESCRIPTION Port[out]: thermal power - effort is temperature, flow is entropy flow
%DESCRIPTION Not bicausal (yet)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Copyright (c) P.J. Gawthrop, 1997.

status = -1;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'RS')==0
  return
end

% There are 2 ports; extract the information
in_bonds = bonds(1,:);
out_bonds = bonds(2,:);

% Port [in] is an ordinary resistor
[in_bonds,in_status] = R_cause(in_bonds); 

% Port [out] has the same causality pattern as an ordinary resistor
[out_bonds,out_status] = R_cause(out_bonds); 

% Reconstruct the bonds
bonds = [in_bonds; out_bonds];

% Generate an overall status
if (in_status==1)|(out_status==1)
  status = 1;
elseif
  (in_status==-1)|(out_status==-1)
  status=-1;
else
  status = 0;
end;


Deleted mttroot/mtt/lib/comp/simple/RS_eqn.m version [47ff4db70d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = RS_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% RS_eqn - equations for flow-modulated resistor
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  RS_eqn
% RS_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Copyright (c) P.J. Gawthrop, 1997.


if nargin<6
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
ports = 2;
if check_bonds(bonds,ports,'RS')==0
  return
end


% There are 2 ports; extract the information
in_bonds = bonds(1,:);
out_bonds = bonds(2,:);
in_direction = direction(1,:);
out_direction = direction(2,:);

% Do port [in] - a standard resistor
structure = R_eqn(name,bond_number(1),in_bonds,in_direction,cr,args, ...
    structure,eqnfile);

% Do port [out] - the thermal bit. RS is power conserving.
% This computes f_2 = e_1*f_1/e_2 or  e_2 = e_1*f_1/f_2
fprintf(eqnfile,'%s := %s*%s/%s;\n' , ...
    varname(name,bond_number(2), -out_bonds(1)), ...
    varname(name,bond_number(1),  1), ...
    varname(name,bond_number(1), -1), ...
    varname(name,bond_number(2), out_bonds(1)) );


Deleted mttroot/mtt/lib/comp/simple/R_alias.m version [12d1346387].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = R_alias	# Port aliases for R

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '1';

endfunction


Deleted mttroot/mtt/lib/comp/simple/R_cause.m version [9a5c0ab992].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = R_cause(bonds);
% R_cause - Causality function for a (multi-port) unicausal R component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  R_cause
% [bonds,status] = R_cause(bonds)

%SUMMARY R: R component
%DESCRIPTION Multiport component with no dynamics
%DESCRIPTION Cannot be bicausal

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/08/30 19:05:08  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.
 

% Find the number of ports
[ports,junk] = size(bonds);

% default undercausal status
statuses = -ones(ports,1);

% Force unicausality
for i = 1:ports
  if (bonds(i,1)~=0)&(bonds(i,2)~=0) % Both bonds set
    statuses(i) = bonds(i,1)~=bonds(i,2);
  elseif bonds(i,2)~=0               % Bond 1 set
    bonds(i,1) = bonds(i,2);
    statuses(i) = 0;
  elseif bonds(i,1)~=0               % Bond 2 set
    bonds(i,2) = bonds(i,1);
    statuses(i) = 0;
  end;
end;

if max(statuses)==1
  status = 1;
elseif min(statuses)==-1
  status = -1;
else
  status = 0;
end;
  

Deleted mttroot/mtt/lib/comp/simple/R_eqn.m version [9457569ec3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = R_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% R_eqn - Equation function for a (multi-port) unicausal R component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  R_eqn
% structure = R_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/09/12 19:28:11  peter
% %% Added defaults (with no constitutive relationship)
% %%
% %% Revision 1.3  1996/09/12 16:40:45  peter
% %% Now does a default (when no constitutive relationship) with a unit
% %% constitutive relationship on each port.
% %%
% %% Revision 1.2  1996/09/12 13:12:04  peter
% %% Removed an fprintf that was a mistake.
% %%
% %% Revision 1.1  1996/09/12 11:00:56  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<8
  eqnfile = 'stdout';
end;


% Find the number of ports
[ports,junk] = size(bonds);


for outport = 1:ports
  outcause = -bonds(outport,1);
  outnumber = bond_number(outport);
  if length(cr)>0
    incause = bonds(:,1);
    inport = 1:ports;
    inbond = bond_number;
  else % default if no cr: unit cr on each port
    incause = bonds(outport,1);
    inport = outport;
    inbond = outnumber;
  end;
  
  eqn =  equation("R",name,cr,args,outnumber,outcause,outport, ...
                               inbond,incause,inport);
  fprintf(eqnfile, '%s',eqn);
end;


Deleted mttroot/mtt/lib/comp/simple/R_seqn.m version [a084871fab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = R_seqn (Name, name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = R_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port R's use all potential signals

  N = mtt_check_sigs (outsig,insigs);
  
  inports = [1:N]; 
  eqn = equation("""R""",Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
		 insigs(:,1),insigs(:,2),inports);

  ## No change
  ## insigs = insigs;
  ## innames = innames;

endfunction

Deleted mttroot/mtt/lib/comp/simple/SS_alias.m version [532fa03c37].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = SS_alias	# Port aliases for SS

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1998/07/28 19:08:22  peterg
## Some vector aliases added.
##
## Revision 1.1  1998/07/02 14:37:42  peterg
## Initial revision
##
###############################################################

  alias.in   = "1";
  alias.out  = "1";

  MAX = 10;
  value = "1";
  for i=1:MAX
    eval(sprintf("alias.in%i = \"%s\";", i, value));
    eval(sprintf("alias.out%i = \"%s\";", i, value));
    value = sprintf("%s,%i",value,i+1);
  endfor;
endfunction


Deleted mttroot/mtt/lib/comp/simple/SS_cause.m version [8964220e5e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = SS_cause(bonds)
% SS_cause = causality for an SS component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  SS_cause
% [bonds,status] = SS_cause(bonds)

%SUMMARY SS: source-sensor component
%DESCRIPTION multi-port source sensor component
%DESCRIPTION when the name is [name], acts as port `name' of a system.
%DESCRIPTION may be bicausal

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/11/01 14:41:14  peterg
% %% Check correct bonds
% %%
% %% Revision 1.1  1996/11/01 12:18:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

## Check that there is exactly one bonds.
##if check_bonds(bonds,1,'SS')==0
##  return
##end

disp("Starting SS_cause");

[n_bonds,junk] = size(bonds);
Status=zeros(n_bonds,1);
for i=1:n_bonds
  if (bonds(i,1)==0)|(bonds(i,2)==0) % Under causal
    Status(i) = -1;
  else                          % causal
    Status(i) = 0;
 end;
end;
status=min(Status);







Deleted mttroot/mtt/lib/comp/simple/SS_eqn.m version [00c79cfc09].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267











































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function structure =  SS_eqn(name,Bond_number,Bonds,Direction,cr,args, ...
			     structure,filenum);

  disp("SS_eqn");
  name,Bond_number,Bonds,Direction

  ## Set up globals to count the component inputs and outputs. This relies on
  ## the named SS (the ports) being in the correct order. Using globals here
  ## avoids changing the common argument list for all _eqn files for something
  ## which is only used for named SS components.
  global local_u_index
  global local_y_index
  global at_top_level

  ## SS_eqn - equations for SS component
  ## 
  ##     ####################################### 
  ##     ###### Model Transformation Tools #####
  ##     ######################################
  ## 
  ## Matlab function  SS_eqn
  ## structure =  SS_eqn(name,bond_number,bonds,direction,cr,args, ...
  ##    structure,filenum);


  ## Copyright (c) P.J. Gawthrop, 1996.

  
  ## ###############################################################
  ## ### Version control history
  ## ###############################################################
  ## ### $Id$
  ## ### $Log$
  ## ### Revision 1.27  2005/03/21 10:34:47  gawthrop
  ## ### Tidied.
  ## ###
  ## ### Revision 1.26  2004/08/29 13:11:21  geraint
  ## ### Writes MTTyz vector in the same format as MTTx and MTTy: MTTyz($d,1)
  ## ##
  ## ### Revision 1.25  2003/01/07 18:09:21  geraint
  ## ### More informative error message.
  ## ##
  ## ### Revision 1.24  1999/10/22 02:20:32  peterg
  ## ### Changed error handleing of number of attributes >2
  ## ##
  ## ### Revision 1.23  1998/12/03 16:46:16  peterg
  ## ### Deblanked attributes so that zero attribute works.
  ## ##
  ## ### Revision 1.22  1998/07/28 19:05:46  peterg
  ## ### Fixed a few bugs.
  ## ##
  ## ### Revision 1.21  1998/07/28 14:21:31  peterg
  ## ### Vector SS ports.
  ## ##
  ## ### Revision 1.20  1998/07/08 14:42:52  peterg
  ## ### Removed the annoying info message - it causes problems with big
  ## ### systems
  ## ##
  ## ### Revision 1.19  1998/07/08 11:33:54  peterg
  ## ### Replace mtt_info by mtt_error when appropriate
  ## ##
  ## ### Revision 1.18  1998/07/08 11:30:45  peterg
  ## ### Removed second (fileID) argument from mtt_info
  ## ##
  ## ### Revision 1.17  1998/07/04 07:15:44  peterg
  ## ### Back under RCS
  ## ##
  ## ### Revision 1.16  1998/04/11 19:07:16  peterg
  ## ### Now do named ports as ordinary ports iff at top level.
  ## ### --- not yet complete, need to pass necesssary info though to this
  ## ###     function
  ## ##
  ## ### Revision 1.15  1997/12/16 19:16:07  peterg
  ## ### Added unknown input to the effort part.
  ## ##
  ## ### Revision 1.14  1997/12/16 18:25:19  peterg
  ## ### Added unknown_input attribure to flow -- effort still needs doing
  ## ##
  ## ### Revision 1.13  1997/09/18 13:15:15  peterg
  ## ### Fixed incorrect error message flagging inappropriate flow outputs
  ## ### -- used to give the effort rather than the flow in the error message.
  ## ##
  ## ### Revision 1.12  1997/08/26 07:51:30  peterg
  ## ### Now counts the local input and outputs by order of appearence rather
  ## ### than by port number - it therfore handles ports with bicausality correctely.
  ## ##
  ## ### Revision 1.11  1997/05/09 08:21:07  peterg
  ## ### Explicit computation of port number -- avoids str2num
  ## ##
  ## ### Revision 1.10  1997/03/22  17:13:03  peterg
  ## ### Fixed bug for port nos. > 1 digit!
  ## ##
  ## ### Revision 1.9  1997/03/22  15:50:59  peterg
  ## ### Changed #1.0f to %d format.
  ## ##
  ## ### Revision 1.8  1996/12/10 16:52:29  peterg
  ## ### Detect null string using strcmp, not length.
  ## ### Put filnum argument to mtt_info.
  ## ##
  ## ### Revision 1.7  1996/12/07 17:17:40  peterg
  ## ### Added some ;
  ## ##
  ## ### Revision 1.6  1996/12/05 09:49:09  peterg
  ## ### Explicit computation of port number from string.
  ## ##
  ## ### Revision 1.5  1996/12/04 21:27:53  peterg
  ## ### Replaced str2num by sprintf
  ## ##
  ## ### Revision 1.4  1996/08/18  20:06:21  peter
  ## ### Included zero outputs.
  ## ##
  ## ### Revision 1.3  1996/08/09 14:08:04  peter
  ## ### Empty effort and flow attributes replaced by 'external'.
  ## ##
  ## ### Revision 1.2  1996/08/08 16:38:19  peter
  ## ### Changed to filenumer type of fprintf
  ## ##
  ## ### Revision 1.1  1996/08/08 16:19:08  peter
  ## ### Initial revision
  ## ##
  ## ###############################################################


  ## The string 'cr' contains the effort attributes;  
  ## 'arg' contains the flow attributes. 
  ## external indicates an external variable
  ## internal indicates an internal variable
  ## anything else is the name of a constant.
  ## Blank is taken to be external
  ## If its a numbered port:
  ##     cr contains 'MTT_port'
  ##     arg contains port number

  if (strcmp(cr,"SS"))		# Then its the standard file
    a = char(strsplit(args,","))
    [N,M]=size(a);
    if (N~=2)			# Must have 2 arguments
      mtt_error(sprintf("SS should have 2 args not %i", N));
    endif
    effort_attribute = deblank(a(1,:));
    flow_attribute   = deblank(a(2,:));
  else				# Old style file
    effort_attribute = cr;
    flow_attribute = args;
  endif

  ## Default attributes
  if strcmp(effort_attribute,"")
    effort_attribute = "external";
  endif

  if strcmp(flow_attribute,"")
    flow_attribute = "external";
  endif

  inputs = structure(3);
  outputs = structure(4);
  zero_outputs = structure(5);
  unknown_inputs = structure(6);
  
  n_bonds = length(Bond_number)	# Multi port?
  for i=1:n_bonds		# Loop over all the bonds
    bond_number = Bond_number(i);
    bonds = Bonds(i,:);
    direction = Direction(i,:);
    Named_Port = name(1)=="[";	
    if Named_Port
      sname = name(2:length(name)); #Strip the []
    else
      sname = name;
    endif
    
    if Named_Port&&~at_top_level # It's a named port
      ## Effort 
      if bonds(1,1)==-1		# Source
	local_u_index = local_u_index + 1
	fprintf(filenum, "%s := %s_MTTu%d;\n", ...
		varname(sname, bond_number,1), sname, local_u_index);
      else # Sensor
	local_y_index = local_y_index + 1
	fprintf(filenum, "%s_MTTy%d := %s;\n", ...
		sname, local_y_index, varname(sname, bond_number,1));
      endif
      
      ## Flow 
      if bonds(1,2)==1		# Source
	local_u_index = local_u_index + 1
	fprintf(filenum, "%s := %s_MTTu%d;\n", ...
		varname(sname, bond_number,-1), sname, local_u_index);
      else # Sensor
	local_y_index = local_y_index + 1
	fprintf(filenum, "%s_MTTy%d := %s;\n", ...
		sname, local_y_index, varname(sname, bond_number,-1));
      endif
    else			# Now do SS which are not ports
      ## Effort
      if strcmp(effort_attribute, "external")
	if bonds(1,1)==-1	# Source
	  inputs = inputs+1;
	  fprintf(filenum, "%s := MTTu(%d,1);\n", ...
		  varname(sname, bond_number,1),inputs);
	else			# Sensor
	  outputs = outputs+1;
	  fprintf(filenum, "MTTy(%d,1) := %s;\n", ...
		  outputs, varname(sname, bond_number,1));
	endif
      elseif strcmp(effort_attribute, "unknown") # Unknown input
	unknown_inputs = unknown_inputs + 1;
	fprintf(filenum, "%s := MTTUi%d;\n", ...
		varname(sname, bond_number,1), unknown_inputs);
      elseif strcmp(effort_attribute, "internal")
	## Do nothing
      else 
	if bonds(1,1)==-1	# Named or unknown source
	  fprintf(filenum, "%s := %s;\n", ...
		  varname(sname, bond_number,1), effort_attribute);
	else # Sensor
	  if strcmp(effort_attribute, "zero") #Zero output
	    zero_outputs = zero_outputs + 1;
	    fprintf(filenum, "MTTyz(%d,1) := %s;\n", ...
		    zero_outputs, varname(sname, bond_number,1));
	  else
	    mtt_error([effort_attribute, " not appropriate for an output (", name, ")"]);
	  endif
	endif
      endif
      
      ## Flow
      if strcmp(flow_attribute, "external")
	if bonds(1,2)==1	# Source
	  inputs = inputs+1
	  fprintf(filenum, "%s := MTTu(%d,1);\n", varname(sname, bond_number,-1),inputs);
	else			# Sensor
	  outputs = outputs+1
	  fprintf(filenum, "MTTy(%d,1) := %s;\n", outputs, ...
		  varname(sname, bond_number,-1));
	endif
      elseif strcmp(flow_attribute, "unknown") # Unknown input
	unknown_inputs = unknown_inputs + 1
	fprintf(filenum, "%s := MTTUi%d;\n", ...
		varname(sname, bond_number,-1), unknown_inputs);
      elseif strcmp(flow_attribute, "internal")
	## Do nothing
      else			# Named constant
	if bonds(1,2)==1	# Source
	  fprintf(filenum, "%s := %s;\n", ...
		  varname(sname, bond_number,-1), flow_attribute);
	else			# Sensor
	  if strcmp(flow_attribute, "zero") #Zero output
	    zero_outputs = zero_outputs + 1
	    fprintf(filenum, "MTTyz(%d,1) := %s;\n", ...
		    zero_outputs, varname(sname, bond_number,-1));
	  else
	    mtt_error([flow_attribute, " not appropriate for an output (", name, ")"]);
	  endif
	endif
      endif
    endif
    
    structure(3) = inputs;
    structure(4) = outputs;
    structure(5) = zero_outputs;
    structure(6) = unknown_inputs;
    
  endfor
endfunction

Deleted mttroot/mtt/lib/comp/simple/SS_seqn.m version [96afb2658a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = SS_seqn (Name, name, cr, arg, outsig, ...
					 insigs,innames,is_port)

  ## usage:  [eqn,inbonds] = SS_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ## 
  ## Multi port SS's ??

  delim = "__";
  N = mtt_check_sigs (outsig,insigs);

  full_name = sprintf("%s%s%s", Name,delim,name);

  ## Get the special attibutes for SS
  attrib_name = char(strsplit(arg,","));
  [N_a,M_a]=size(attrib_name);
  if (N_a~=2)		# Must have 2 arguments
    mtt_error(sprintf("SS should have 2 args not %i", N_a));
  end;

  effort_attribute = deblank(attrib_name(1,:));
  flow_attribute   = deblank(attrib_name(2,:));

  ## Default attributes
  if strcmp(effort_attribute,"")||is_port
    effort_attribute = "external";
  end;
  
  if strcmp(flow_attribute,"")||is_port
    flow_attribute = "external";
  end;


  if mtt_is_external("SS",outsig,insigs) # Source
    if outsig(2)==1		# effort output.
      attribute = effort_attribute;
    else
      attribute = flow_attribute;
    endif

    ## Create the equation
    LHS = varname(Name, outsig(1,1), outsig(1,2));
    RHS = Source_seqn (attribute,full_name);
    eqn = sprintf("%s := %s;", LHS, RHS);
  else				# Sensor
   if insigs(1,2)==1		# effort output.
     attribute = effort_attribute;
   else
     attribute = flow_attribute;
   endif

   ## Create the equation
   LHS = Sensor_seqn (attribute,full_name);
   RHS = varname(Name, insigs(1,1), insigs(1,2));
   eqn = sprintf("%s := %s;", LHS, RHS);
 endif
 
endfunction

Deleted mttroot/mtt/lib/comp/simple/Sensor_seqn.m version [60348ae058].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function LHS = Sensor_seqn (attribute,name)

  ## usage:  LHS = Sensor_seqn (attribute,name)
  ##
  ## Write the LHS of a sensor equation
  

  if strcmp(attribute,"external")
    LHS = sprintf("MTTy_%s", name);  
  elseif strcmp(attribute,"internal")
    LHS = sprintf("MTTy_%s", name); 
  else
    error(sprintf("attribute ""%s"" not appropriate for a " ...
    "source"), attribute);
  endif
endfunction

Deleted mttroot/mtt/lib/comp/simple/Source_seqn.m version [7ea4860836].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function RHS = Source_seqn (attribute,name)

  ## usage:  RHS = Source_seqn (attribute,name)
  ##
  ## Write the RHS of a source equation
  
  if strcmp(attribute,"external")
    RHS = sprintf("MTTu_%s",name);
   elseif strcmp(attribute,"internal")
     error(sprintf("attribute ""internal"" not appropriate for a " 
 	"source"));
  else
    RHS = attribute;
  endif
  
endfunction

Deleted mttroot/mtt/lib/comp/simple/TF_alias.m version [5fdd82024a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function alias = TF_alias	# Port aliases for TF

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

  alias.in     = '1';
  alias.out    = '2';

endfunction


Deleted mttroot/mtt/lib/comp/simple/TF_cause.m version [7adfcd4d2d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = TF_cause(bonds);
% TF_cause - causality for a TF component
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  TF_cause
% [bonds,status] = TF_cause(bonds)

%SUMMARY TF: elementary transformer component
%DESCRIPTION Energy conserving two-port
%DESCRIPTION e_1 = f(e_2); f_1 = f(f_2)


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/11/01 12:05:54  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'TF')==0
  return
end


%Causality of TF is same as that of a junction
[bonds,status] = zero_cause(bonds);

Deleted mttroot/mtt/lib/comp/simple/TF_eqn.m version [da8cba2d73].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = TF_eqn(name,bond_number,bonds,direction,cr,args, ...
                            structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/09/10 10:41:37  peter
% %% Now used equation.m to write the equations.
% %%
% %% Revision 1.1  1996/08/19 09:05:04  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

			
if nargin<8
  eqnfile = 'stdout';
end;

% Check that there are exactly two bonds.
if check_bonds(bonds,2,'TF')==0
  return
end

% There are 2 ports; extract the information
e_1 = bonds(1,1);
f_1 = bonds(1,2);
e_2 = bonds(2,1);
f_2 = bonds(2,2);


% Effort
outcause = 1;
incause = 1;
if e_1==1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
end;

eqn =  equation("TF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);

% Flow
outcause = -1;
incause = -1;
if f_1==-1
  outbond = bond_number(2);
  inbond =  bond_number(1);
  outport = 2;
  inport = 1;
else
  outbond = bond_number(1);
  inbond =  bond_number(2);
  outport = 1;
  inport = 2;
end;

eqn =  equation("TF",name,cr,args,outbond,outcause,outport, ...
                             inbond,incause,inport);
fprintf(eqnfile, '%s',eqn);








Deleted mttroot/mtt/lib/comp/simple/TF_seqn.m version [4d8c4483a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = TF_seqn (Name, cr, arg, outsig, insigs, innames)

  ## usage:  [eqn,inbonds] = TF_seqn (Name, cr, arg, outbond, inbonds)
  ##
  ##
  ## TFs have two ports; the input and output ports must be different
  N = mtt_check_sigs (outsig,insigs);

  if N!=2
    error("A TF must have exactly two ports");
  else
    if insigs(1,3)==outsig(3)	# First signal is on output port
      inport = 2;
    else
      inport = 1;
    endif
  endif
  
  insig = insigs(inport,:);
  inname = innames(inport,:);
  eqn = equation("""TF""",Name,cr,arg,outsig(1),outsig(2),outsig(3), ...
			 insig(:,1),insig(:,2),inport);

  insigs = insig;		# Set the correct input signals
  innames = inname;		# Set the correct input names
  
endfunction

Deleted mttroot/mtt/lib/comp/simple/check_bonds.m version [1d5b1ad1e3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ok = check_bonds(bonds,n,component);
% check_bonds - check to see correct number (n) of bonds.
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  check_bonds
% err = check_bonds(bonds,n);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.
% Check that there are exactly two bonds.
[n_bonds,cols] = size(bonds);
if n_bonds~=n
  mtt_info(sprintf('MTT error: %s must have %1.0f (not %1.0f) bonds', ...
      component, n, n_bonds));
  ok=0;
else
  ok=1;
end

Deleted mttroot/mtt/lib/comp/simple/cicause.m version [94090e2bee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = cicause(bonds,default);
% cicause - Sets causality for C & I components
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cicause
% [bonds,status] = cicause(bonds,default)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.



if (norm(bonds)>1)
  if (bonds(1)==-bonds(2)) % Over causal
    status = 1;
  else                       % Causal
    status = 0;
  end;
elseif norm(bonds)==0 % Acausal
  % bonds = default*[1 1]; %Set integral causality
  % status = 0;
  status = -1;
else % Set causality 
  % Effort
  if bonds(1)==0
    status = 0;
    bonds(1) = bonds(2);
  end;

  % Flow
  if bonds(2)==0
    status = 0;
    bonds(2) = bonds(1);
  end;

end;

Deleted mttroot/mtt/lib/comp/simple/cieqn.m version [e985d8ce2c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function structure =  cieqn(name, bond_number,bonds,direction,cr,args, ...
    structure,CorI,eqnfile);
% cieqn - Equation function for a (multi-port) unicausal C or I component
% CorI = 1 for C, -1 for I; 0 for ISW

% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  cieqn


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/06/29 13:05:08  peterg
% %% Changed cieqn so that sign ignored.
% %%
% %% Revision 1.2  1997/12/04 13:48:00  peterg
% %% Added sign info to take account of direction of bonds.
% %%
% %% Revision 1.1  1997/04/09  10:18:26  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<8
  eqnfile = 'stdout';
end;

if (CorI==1)
  comp_type = "C";
else
  comp_type = "I";
endif

CorIorISW = CorI;
if CorIorISW==0 % ISW
   CorI = -1;
end;


% Find the number of ports
[ports,junk] = size(bonds);

% Right-hand side causality
RHS_cause = (bonds(:,1)==CorI*ones(ports,1))*CorI
state_cause = zeros(ports,1); % State causality

for outport = 1:ports

#  % Sort out direction
#  if direction(outport,1) == 1
#    sign = '+';
#  else
#    sign = '-';
#  end;

  sign = '+';  
  LHS_number = bond_number(outport);
  if bonds(outport,1) == -CorI % Integral causality on this port
    state = structure(1)+1;
    LHS_cause = CorI;

    % Print equation of form x_i = MTTx(i)
    fprintf(eqnfile, '%s := MTTx(%1.0f,1);\n', ...
        varname(name,LHS_number, state_cause), state);

    % Print equation of form xdot = input - with sign
    fprintf(eqnfile, 'MTTdX(%1.0f,1) := %s%s;\n', state, sign, ...
                     varname(name,LHS_number,-LHS_cause));
    % Print equation of form output = CR (state) 
    eqn =  equation(comp_type,name,cr,args,LHS_number,LHS_cause,outport, ...
                             bond_number,state_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(1) = state;
  else % Derivative causality
    nonstate = structure(2)+1;
    LHS_cause = -CorI;

    % Print equation of form zdot = MTTdz(i) -- with sign 
    fprintf(eqnfile, '%s := %sMTTdz(%1.0f,1);\n', ...
                             varname(name,LHS_number,LHS_cause), sign, ...
                             nonstate);
    % Print equation of form MTTz(i) = z_i
    fprintf(eqnfile, 'MTTz(%1.0f,1) := %s;\n', nonstate, ...
             varname(name,LHS_number, state_cause));
				 
   % Print equation of form z_i = CR(input)
      eqn =  equation(comp_type,name,cr,args,LHS_number,state_cause, outport, ...
                             bond_number,RHS_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(2) = nonstate;
 end;
end;









Deleted mttroot/mtt/lib/comp/simple/comp_ports.m version [09c16f9abd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ports = comp_ports(comp_type,N)
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  comp_ports
% ports = comp_ports(comp_type)
% Returns the port list for simple components


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.8  1998/06/29 12:16:05  peterg
% %% Whoops - FP bonds are p and f (in that order)
% %%
% %% Revision 1.7  1998/06/29 12:13:36  peterg
% %% Changed FP ports to f and p
% %%
% %% Revision 1.6  1998/06/29 09:55:17  peterg
% %% Changed name to FP from ES
% %%
% %% Revision 1.5  1998/04/12 15:01:53  peterg
% %% Converted to uniform port notation - always use []
% %%
% %% Revision 1.4  1998/03/31 08:39:31  peterg
% %% Added EBTF
% %%
% %% Revision 1.3  1997/11/21 11:32:57  peterg
% %% N ports numbered 1..N
% %%
% %% Revision 1.2  1997/08/28  08:08:24  peterg
% %% Added RS component to the two-port list
% %%
% %% Revision 1.1  1997/08/02 19:35:47  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


junctions = '-zero-one-';
one_ports = '-SS-';
two_ports = '-TF-GY-AE-AF-FMR-RS-EBTF-';
N_ports   = '-R-C-I-';
comp_type = ['-', comp_type, '-'];

#if length(findstr(comp_type,junctions))==1
#  ports = ['[undefined]'];
#elseif length(findstr(comp_type,one_ports))==1
#  ports = ['[in]'];
#elseif length(findstr(comp_type,two_ports))==1
#  ports = ['[in]';'[out]'];
#elseif length(findstr(comp_type,'[-EMTF-]'))==1
#  ports = ['[in]';'[out]';'[mod]'];
#elseif length(findstr(comp_type,'[-FP-]'))==1
#  ports = ['[p]';'[f]'];
#elseif length(findstr(comp_type,'[-PS-]'))==1
#  ports = ['[in]';'[out]';'[power]'];
#elseif length(findstr(comp_type,N_ports))==1
#  if N==1
#    ports = ['[in]'];
#  elseif N==2
#    ports = ['[in]';'[out]'];
#  elseif N>2
#    ports = '[1]';
#    for i=2:N
#      ports = [ports; sprintf("[%i]",i)];
#    end;
#  end;
#end;
 
# All the above is now done in the alias files
  ports = '[1]';
  for i=2:N
    ports = [ports; sprintf("[%i]",i)];
  end;

endfunction

Deleted mttroot/mtt/lib/comp/simple/juncause.m version [c96eb0a15f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = juncause(bonds,jun,cause)
% [bonds,status] = juncause(bonds,jun,cause)

% Causality for  either effort or flow on  either zero or one junctions

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/08/09  08:29:04  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


j =  (3-cause)/2; % j is 1 for effort, 2 for flow

[n_bonds,junk] = size(bonds);
[causing_bond, n,other_bonds,m] = getindex(bonds(:,j),jun);
if n>1 % over causal
  status = 1;
elseif n==1 %causal
  status = 0;
  bonds(other_bonds(:,1),j) = -jun*ones(m,1);
elseif n==0  % undercausal - try other way
  [causing_bond, n,other_bonds,m] = getindex(bonds(:,j),-jun);
  if n==n_bonds % over causal
    status = 1;
  elseif n==n_bonds-1 %causal
    status = 0;
    bonds(other_bonds(:,1),j) = jun*ones(m,1);
  else  % undercausal
    status = -1;
  end;
end;




Deleted mttroot/mtt/lib/comp/simple/junction_seqn.m version [1675df1f08].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [eqn,insigs,innames] = junction_seqn (jun_type,Name, outsig, ...
					       insigs, innames)
  ## usage:  [eqn,insigs] = junction_seqn (jun_type,Name, outport, outsig, ...
  ##				       insigs)
  ##
  ## 
  ## Junctions

  ## Sanity check
  N = mtt_check_sigs (outsig,insigs);

  outport = outsig(3);

  ## Setup up causality corresponding to junction
  if jun_type=="0"
    i_jun_type = 1;
  elseif jun_type=="1"
    i_jun_type = -1;
  else
    error("Junction type %s unknown", jun_type)
  endif

  ## Is output same causality as junction?
  same_type = outsig(2)==i_jun_type;


  ## LHS 
  eqn = sprintf("%s :=", varname(Name, abs(outsig(1)), outsig(2)));

  ## Find the input bond of the same causality as junction
  one = ones(N,1);
  inport = find(insigs(:,2)==i_jun_type*one);

  ##RHS
  if same_type
    insig = insigs(inport,:);
    inname = innames(inport,:);
    eqn = sprintf("%s\n\t%s", eqn, varname(Name, abs(insigs(inport,1)),i_jun_type));
  else
    insig=[];
    inname="";
    inports = [];
    out_dir = sign(insigs(inport,1));
    for i=1:N
      if i!=inport
	in_dir = sign(insigs(i,1));
	plusminus = sign2name(-in_dir*out_dir);
	eqn = sprintf("%s\n\t%s%s", eqn, plusminus, varname(Name, ...
		      abs(insigs(i,1)), -i_jun_type));
	insig = [insig; insigs(i,:)];
	inname = [inname; innames(i,:)];
      endif
    endfor
  endif
  eqn = sprintf("%s;", eqn);
  insigs = insig;
  innames = inname;
endfunction

Deleted mttroot/mtt/lib/comp/simple/juneqn.m version [1b08ed726b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  juneqn(name,bond_number,bonds,direction,cr,args,jun,filenumber)
% juneqn - Equations for  both  effort and flow on  either 
% zero or one junctions
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  juneqn
% juneqn(name,bond_number,bonds,direction,cr,args,jun,filenumber)

% Copyright (c) P.J. Gawthrop, 1996.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/12/05 10:02:45  peterg
% %% Explicit generation of strong-causality equations -- oneequation not
% %% used now.
% %%
% %% Revision 1.2  1996/08/08  18:09:10  peter
% %% Changed to finenumber format.
% %%
% %% Revision 1.1  1996/08/08 16:38:50  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Same causality as junction
column =  (3-jun)/2; 
[causing_bond,n,other_bonds,m] = getindex(bonds(:,column),jun)
for i=other_bonds'
  fprintf(filenumber, '%s \t:=\t%s;\n', ...
      varname(name, bond_number(i),jun), ...
      varname(name, bond_number(causing_bond),jun) ...
  );
end;


% Opposite causality to junction
column =  (3+jun)/2;
[caused_bond,n,other_bonds,m] = getindex(bonds(:,column),jun)
fprintf(filenumber, '%s\t:= \n',  varname(name, bond_number(caused_bond),-jun));
for i=other_bonds'
  term_sign = -direction(caused_bond,column)*direction(i,column)
  fprintf(filenumber, '\t\t%s %s\n', sign2name(term_sign), ...
      varname(name, bond_number(i),-jun));
end;
fprintf(filenumber, ';\n');

Deleted mttroot/mtt/lib/comp/simple/one_cause.m version [3018a4a5e9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = one_cause(bonds);
% one_cause - causality for a one junction
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  one_cause


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

%Effort
[bonds,e_status] = juncause(bonds,-1,1);

%Flow
[bonds,f_status] = juncause(bonds,-1,-1);

if (e_status==1)|(f_status==1)       % Over causal
  status = 1;
elseif (e_status==-1)|(f_status==-1) % Under causal
  status = -1;
else                                  % causal
  status = 0;
end;

Deleted mttroot/mtt/lib/comp/simple/one_eqn.m version [ec7724f3d8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  structure = one_eqn(name,bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% one_eqn - equations for a one junction
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  one_eqn
% one_eqn(name,bond_number,bonds,direction,cr,args, ...
%    structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/05 10:00:49  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

disp("one-eqn")
name,bond_number,bonds,direction,cr,args
if nargin<7
  eqnfile = 'stdout';
end;

juneqn(name,bond_number,bonds,direction,cr,args,-1,eqnfile)




Deleted mttroot/mtt/lib/comp/simple/oneeqn.m version [b6cf957a10].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  oneeqn(name,LHS_number,LHS_cause,RHS_number,RHS_cause,cr,args, ...
    eqnfile);
% oneeqn - prints a single equation
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  oneeqn
% oneeqn(name,LHS_number,LHS_cause,RHS_number,RHS_cause,cr,args,eqnfile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



if nargin<7
  eqnfile = 'stdout';
end;


fprintf(eqnfile, '%s := %s;\n', ...
    varname(name, LHS_number,LHS_cause), ...
    cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args));

Deleted mttroot/mtt/lib/comp/simple/zero_cause.m version [93a4da1931].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [bonds,status] = zero_cause(bonds);
% zero_cause - causality for zero junctions
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  zero_cause
% [bonds,status] = zero_cause(bonds);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Effort
[bonds,e_status] = juncause(bonds,1,1);

%Flow
[bonds,f_status] = juncause(bonds,1,-1);

status = 0;
if (e_status==1)|(f_status==1)       % Over causal
  status = 1;
endif;
if (e_status==-1)|(f_status==-1) % Under causal
  status = -1;
endif;

  

Deleted mttroot/mtt/lib/comp/simple/zero_eqn.m version [1f6c065bc3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function structure =  zero_eqn(name, bond_number,bonds,direction,cr,args, ...
    structure,eqnfile);
% zero_eqn - equations for zero junctions
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  zero_eqn
% zero_eqn(name, bond_number,bonds,direction,cr,args, structure,eqnfile);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if nargin<7
  eqnfile = 'stdout';
end;


juneqn(name, bond_number,bonds,direction,cr,args,1,eqnfile)




Deleted mttroot/mtt/lib/control/PPP/Beam_numpar.m version [0d62366729].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Script file  Beam_numpar.m
%% numpar file (Beam_numpar.m)
%% Generated by MTT at Thu Apr 22 07:00:08 BST 1999
% Global variable list
global ...
     area ...
     areamoment ...
     beamlength ...
     beamthickness ...
     beamwidth ...
     density ...
     ei ...
     n ...
     youngs ...
     dk ...
     dm ...
     dz ...
     rhoa ;
 %  -*-octave-*- Put Emacs into octave-mode
 %  Numerical parameter file (Beam_numpar.txt)
 %  Generated by MTT at Mon Apr 19 06:24:08 BST 1999

 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% Version control history
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% $Id$
 %  %% $Log$
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %  Parameters
n =  7;
beamlength =  0.58;
beamwidth =  0.05;
beamthickness =  0.005;
youngs =  1e6;
density =  1e5;
area =  beamwidth*beamthickness;
areamoment =  (beamthickness*beamwidth^2)/12;

ei=  58.6957			; %  from Reza
rhoa=  0.7989			; %  from Reza
 
dz =  beamlength/n;  %  BernoulliEuler
dm =  rhoa*dz;  %  BernoulliEuler
dk =  ei/dz;  %  BernoulliEuler

Deleted mttroot/mtt/lib/control/PPP/Beam_sm.m version [cd16b034f7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-octave-*- Put Emacs into octave-mode%
function [mtta,mttb,mttc,mttd] = Beam_sm();
% [mtta,mttb,mttc,mttd] = Beam_sm();
%System Beam, representation sm, language m;
%File Beam_sm.m;
%Generated by MTT on Thu Apr 22 07:02:48 BST 1999;
%
%====== Set up the global variables ======%
global ...
area ...
areamoment ...
beamlength ...
beamthickness ...
beamwidth ...
density ...
ei ...
n ...
youngs ...
dk ...
dm ...
dz ...
rhoa ;
%a matrix%
mtta = zeros(14,14);
mtta(1,2) = -dk/dz;
mtta(2,1) = 1.0/(dm*dz);
mtta(2,3) = -2.0/(dm*dz);
mtta(2,5) = 1.0/(dm*dz);
mtta(3,2) = (2.0*dk)/dz;
mtta(3,4) = -dk/dz;
mtta(4,3) = 1.0/(dm*dz);
mtta(4,5) = -2.0/(dm*dz);
mtta(4,7) = 1.0/(dm*dz);
mtta(5,2) = -dk/dz;
mtta(5,4) = (2.0*dk)/dz;
mtta(5,6) = -dk/dz;
mtta(6,5) = 1.0/(dm*dz);
mtta(6,7) = -2.0/(dm*dz);
mtta(6,9) = 1.0/(dm*dz);
mtta(7,4) = -dk/dz;
mtta(7,6) = (2.0*dk)/dz;
mtta(7,8) = -dk/dz;
mtta(8,7) = 1.0/(dm*dz);
mtta(8,9) = -2.0/(dm*dz);
mtta(8,11) = 1.0/(dm*dz);
mtta(9,6) = -dk/dz;
mtta(9,8) = (2.0*dk)/dz;
mtta(9,10) = -dk/dz;
mtta(10,9) = 1.0/(dm*dz);
mtta(10,11) = -2.0/(dm*dz);
mtta(10,13) = 1.0/(dm*dz);
mtta(11,8) = -dk/dz;
mtta(11,10) = (2.0*dk)/dz;
mtta(11,12) = -dk/dz;
mtta(12,11) = 1.0/(dm*dz);
mtta(12,13) = -2.0/(dm*dz);
mtta(13,10) = -dk/dz;
mtta(13,12) = (2.0*dk)/dz;
mtta(13,14) = -dk/dz;
mtta(14,13) = 1.0/(dm*dz);
%b matrix%
mttb = zeros(14,1);
mttb(11) = 1.0/dz;
mttb(13) = -2.0/dz;
%c matrix%
mttc = zeros(1,14);
mttc(1,1) = 1.0/dm;
%d matrix%
mttd = zeros(1,1);

Deleted mttroot/mtt/lib/control/PPP/NMPsystem.m version [2fed1aea39].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D] = NMPsystem ()

  ## usage:  [A,B,C,D] = NMPsystem ()
  ##
  ## NMP system example (2-s)/(s-1)^3

  A = [3 -3 1
       1  0  0
       0  1  0];

  B = [1 
       0 
       0];

  C = [0 -0.5 1];

  D = 0;



endfunction

Deleted mttroot/mtt/lib/control/PPP/TwoMassSpring.m version [5f26391fd5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D] = TwoMassSpring (k,m_1,m_2)

  ## usage:  [A,B,C,D] = TwoMassSpring (k,m_1,m_2)
  ##
  ## Two mass-spring example from Middleton et al.  EE9908

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  1999/05/18 22:31:26  peterg
  ## Fixed error in dim of D
  ##
  ## Revision 1.1  1999/05/18 22:28:56  peterg
  ## Initial revision
  ##
  ###############################################################


  A = [0    1 0 0
       -k/m_1 0 k/m_1 0
       0    0 0 1
       k/m_2 0 -k/m_2 0];
  B = [0
       1/m_1
       0 
       0];
  C = [1 0 0 0
       0 0 1 0];

  D = zeros(2,1);

endfunction

Deleted mttroot/mtt/lib/control/PPP/airc.m version [c3d4271b18].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D] = airc
% System AIRC 
% This system is the aircraft example from the book:
% J.M Maciejowski: Multivariable Feedback Design  Addison-Wesley, 1989
% It has 5 states, 3 inputs and 3 outputs.

% P J Gawthrop Jan 1998

A = [    0         0    1.1320         0   -1.0000
         0   -0.0538   -0.1712         0    0.0705
         0         0         0    1.0000         0
         0    0.0485         0   -0.8556   -1.0130
         0   -0.2909         0    1.0532   -0.6859];

B = [    0         0         0
   -0.1200    1.0000         0
         0         0         0
    4.4190         0   -1.6650
    1.5750         0   -0.0732];

C = [1     0     0     0     0
     0     1     0     0     0
     0     0     1     0     0];

D = zeros(3,3);


Deleted mttroot/mtt/lib/control/PPP/autm.m version [e5ff112d0d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D]=autm
% System AUTM
% This system is the automotive gas turbine example from the book:
% Y.S. Hung and A.G.J. Macfarlane: "Multivariable Feedback. A
% quasi-classical approach."  Springer 1982
% It has 12 states, 2 inputs and 2 outputs.

% P J Gawthrop Jan 1998

%A-matrix
A = zeros(12,12);
A(1,2) 	= 1;
A(2,1) 	= -0.202; A(2,2) = -1.150;
A(3,4) 	= 1;
A(4,5) 	= 1;
A(5,3) 	= -2.360; A(5,4) = -13.60; A(5,5) = -12.80;
A(6,7) 	= 1;
A(7,8) 	= 1;
A(8,6) 	= -1.620; A(8,7) = -9.400; A(8,8) = -9.150;
A(9,10) = 1;
A(10,11) = 1;
A(11,12) = 1;
A(12,9) = -188.0; A(12,10) = -111.6; A(12,11) = -116.4; A(12,12) = -20.8;

%B-matrix
B = zeros(12,2);
B(2,1)   =  1.0439; B(2,2)   = 4.1486;
B(5,1)   = -1.794;  B(5,2)   = 2.6775;
B(8,1)   =  1.0439; B(8,2)   = 4.1486;
B(12,1)  = -1.794;  B(12,2)  = 2.6775;

%C-matrix
C = zeros(2,12);
C(1,1)  = 0.2640; C(1,2)  = 0.8060; C(1,3) = -1.420; C(2,4) = -15.00; 
C(2,6)  = 4.9000; C(2,7)  = 2.1200; C(2,8) = 1.9500; C(2,9) = 9.3500;
C(2,10) = 25.800; C(2,11) = 7.1400;

%D-matrix
D = zeros(2,2);

Deleted mttroot/mtt/lib/control/PPP/butterworth_matrix.m version [c40a4036f0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function A = butterworth_matrix (n,p)

  ## usage:  A = butterworth (n,p)
  ##
  ## A-matrix for generating nth order Butterworth functions with parameter p

  ## Copyright (C) 2000 by Peter J. Gawthrop

  ## Butterworth poly
  pol = ppp_butter(n,p);
  
  ## Create A matrix (controller form)
  A = [-pol(2:n+1)
       eye(n-1) zeros(n-1,1)];
	
endfunction

Deleted mttroot/mtt/lib/control/PPP/damped_matrix.m version [62d084883f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function A = damped_matrix (frequency,damping)

  ## usage:  A = damped_matrix (frequency,damping)
  ##
  ## Gives an A matrix with eigenvalues with specified 
  ## frequencies and damping ratio

  N = length(frequency);

  if nargin<2
    damping = zeros(size(frequency));
  endif
  
  if length(damping) != N
    error("Frequency and damping vectors have different lengths");
  endif
  
  A = zeros(2*N,2*N);
  for i=1:N
    j = 2*(i-1)+1;
    A_i = [-2*damping(i)*frequency(i) -frequency(i)^2
	   1                           0];
    A(j:j+1,j:j+1) = A_i;
  endfor
  
endfunction

Deleted mttroot/mtt/lib/control/PPP/laguerre_matrix.m version [5e8ca33d42].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function A = laguerre_matrix (n,p)

  ## usage:  A = laguerre_matrix (n,p)
  ##
  ## A-matrix for generating nth order Laguerre functions with parameter p

  ## Copyright (C) 1999 by Peter J. Gawthrop

  if n<1			# Creatre empty matrix
    A = [];
  else				# Create A matrix
    A = diag(-p*ones(n,1));
    for i=1:n-1
      A = A + diag(-2*p*ones(n-i,1),-i);
    endfor
  endif

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_RT.m version [db4d51d37d].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function [y,u] = ppp_RT (U)

  ## usage:  [y,u] = ppp_RT (U)
  ##
  ## 

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_RT_sim.m version [b2a01fdb41].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y,u] = ppp_RT_sim (U)

  ## usage:  [y,u] = ppp_RT_sim (U)
  ##
  ## U   PPP weight (column vector)

  global system_name_sim i_ppp_sim x_0_sim y_sim u_sim A_u_sim


  ## Data from previous time - last point not used
  if length(y_sim)>0		# Avoid initial junk
    [n_t_old,junk] = size(y_sim);
    y = y_sim(1:n_t_old-1,:); u = u_sim(1:n_t_old-1,:);
  else
    y=[]; u=[];
  endif

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_RT_sim_compute.m version [bbee59ecfc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ppp_RT_sim_compute (U)

  ## usage:  [y,u] = ppp_RT_sim_compute (U)
  ##
  ## U   PPP weight (column vector)

  global system_name_sim i_ppp_sim x_0_sim y_sim u_sim A_u_sim simpar_sim

  ## System details -- defines simulation within ol interval
  par = eval(sprintf("%s_numpar;", system_name_sim));
  t = [0:simpar_sim.dt:simpar_sim.last];
  n_t = length(t);
  [n_x,n_y,n_u] = eval(sprintf("%s_def", system_name_sim));
  [n_U,junk] = size(A_u_sim);

  ## Set up u_star
  u_star = ppp_ustar(A_u_sim,1,t,0,0,n_u-n_U);

  ## Simulate
  par(i_ppp_sim(:,3)) = U;		# Update the simulation ppp weights
  [y_sim,x] = eval(sprintf("%s_sim(x_0_sim, par, simpar_sim, u_star);", \
			   system_name_sim));
  x_0_sim  = x(n_t,:)';		# Extract state for next time
  u_sim = u_star(:,1:n_U)*U;
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_are.m version [fabd8baa32].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [P,A_u,A_w,k] = ppp_are (A,B,C,D,Q,R,A_type)

  ## usage:  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R,A_type)
  ##
  ## 

  if nargin<1
    disp("usage:  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R,A_type)");
    return
  endif
  
  if nargin<7
    A_type = "feedback";
  endif
  
  [n_x,n_u,n_y] = abcddim(A,B,C,D); # Dimensions
  n_q = is_square(Q);		# Size of Q
  if n_q==0
    error("Q must be square");
  endif
  
  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)
  if n_q==n_y			# Output weight
    Q_x =  C'*Q*C;		# Weighting on x
  elseif n_q==n_x		# State weight
    Q_x = Q;
  else
    error(sprintf("Q (%ix%i) must be %ix%i or %ix%i",n_q,n_q,n_y,n_y,n_x,n_x));
  endif

  [k, P, poles] = lqr (A, B, Q_x, R); # Algebraic Riccati solution

  ## Basis functions
  if strcmp(A_type,"companion")
    A_u = compan(poly(poles));
  elseif strcmp(A_type,"feedback")
    A_u = A-B*k;
  else
    error(sprintf("A_type must be %s, not %s", "companion or feedback", A_type));
  endif
  
    ## Avoid spurious imag parts due to rounding
    A_u = real(A_u);		

  ## Setpoint basis functions
  A_w = 0;

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_aug.m version [85d071a163].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,v] = ppp_aug (A_1,A_2)

  ## usage:  [A,v] = ppp_aug (A_1,A_2)
  ##
  ## Augments square matrix A_1 with square matrix A_2 to create A=[A_1 0; A_2 0];
  ## and generates v, a compatible column vector with unit elements

  ## Copyright (C) 1999 by Peter J. Gawthrop


  [n_1,m_1] = size(A_1);
  if n_1 != m_1
    error("A_1 must be square");
  endif
  
  [n_2,m_2] = size(A_2);
  if n_2 != m_2
    error("A_2 must be square");
  endif

  A = [A_1            zeros(n_1,n_2)
       zeros(n_2,n_1) A_2];

  v = ones(n_1+n_2,1);

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_butter.m version [e0dda0f911].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function pol = ppp_butter (order,radius)

  ## usage:  pol = cgpc_butter (order,radius)
  ##
  ## Butterworth polynomial of given order and pole radius
  ## Copyright (C) 1999 by P.J. Gawthrop

  ## 	$Id$	

  theta = pi/(2*order);		# Angle with real axis

  even = (floor(order/2)==order/2);
  if even
    pol=1; N=order/2;
  else
    pol=[1 radius]; N=(order-1)/2;
  endif
  
  for i=1:N
    pol=conv(pol, [1 2*radius*cos(i*theta) radius^2]);
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_closedloop.m version [3bb5af1be2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Ac,Bc,Cc,Dc] = ppp_closedloop (A,B,C,D,k_x,k_w,l_x,l_y)

  ## usage:  [Ac,Bc,Cc,Dc] = ppp_closedloop (A,B,C,K_x,K_w,K_y,L)
  ##
  ## 


  ## Closed loop input  is [w;v]. 
  ## Closed loop output is [y;u]. 
  ## w is reference signal
  ## v is input disturbance
  ## Inputs:
  ## 	A,B,C,D		MIMO linear system matrices
  ## 	k_x,k_w,k_y	Gain matrices: u = k_w*w - k_x*x
  ##	L		Observer gain matrix
  ## Outputs
  ## 	Ac,Bc,Cc,Dc	Closed-loop charecteristic polynomial	

  ## Copyright (C) 1999 by Peter J. Gawthrop

  ## System dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Create matrices describing closed-loop system
  Ac = [ A,  -B*k_x     
	l_x*C,  (A - l_x*C - B*k_x)];

  Bc = [B*k_w    B
	B*k_w    zeros(n_x,n_u)];

  Cc = [C               zeros(n_y,n_x)
	zeros(n_u,n_x)  -k_x          ];

  Dc = [zeros(n_y,n_y)     zeros(n_y,n_u)
	k_w              zeros(n_u,n_u)];

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_cost.m version [f7cb316246].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [J J_U] = ppp_cost (U,x,W,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww)

  ## usage: [J J_U] = ppp_cost (U,x,W,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww)
  ## Computes the PPP cost function given U,x and W
  ## 
  ## J_uu,J_ux,J_uw,J_xx,J_xw,J_ww cost derivatives from ppp_lin

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  J = U'*J_uu*U/2 + U'*(J_ux*x - J_uw*W) - x'*J_xw*W + x'*J_xx*x/2 + W'*J_ww*W'/2;
  J_U = J_uu*U + (J_ux*x - J_uw*W) ;

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_error.m version [3cf9868bce].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function err = ppp_error(par)

  ## usage:  err = error (par)
  ##
  ## 

  global ppp_y_0 ppp_sim_command ppp_par ppp_i_par ppp_x0 ppp_sim ppp_u
  
  pars = ppp_par;
  pars(ppp_i_par) = par;
  
  y = sidSimpleExtruder_ssim(ppp_x0,pars,ppp_sim,ppp_u);
  
  [N,n_y] = size(y);

  Err = y - ppp_y_0;
  err = sum(diag(Err'*Err))/N
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex1.m version [a792430509].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex1 (ReturnName)

  ## usage:  ppp_ex1 ()
  ##
  ## PPP example - an unstable, nmp siso system
  ## 	$Id$	


  ## Example name
  name = "Linear unstable non-minimum phase third order system- Laguerre inputs";

  if nargin>0
    return
  endif
  

  ## System - unstable & NMP
  [A,B,C,D] = NMPsystem;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Setpoint
  A_w = ppp_aug(0,[]);

  ## Controller

  ##Optimisation horizon
  t = [4.0:0.05:5];

  ## A_u
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w);

  ## Design and plot
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t);


  ## Compute exact version
  poles = sort(eig(A_u));	# Desired poles - eigenvalues of A_u
  poles = poles(1:n_x);		# Loose the last one - due to setpoint 
  clp = poly(poles);		# Closed-loop cp
  kk = clp(2:n_x+1)+A(1,:);	# Corresponding gain
  A_c = A-B*kk;			# Closed-loop A
  K_X = ppp_open2closed (A_u,[A_c B*k_w; [0 0 0 0]],[kk -k_w]); # Exact
	
  ## Compute K_x using approx values
  A_c_a = A-B*k_x; 			
  K_X_comp = ppp_open2closed (A_u,[A_c_a B*k_w; [0 0 0 0]],[k_x -k_w]); # Computed Kx

  format bank
  log_cond_uu = log10(cond_uu)
  Exact_closed_loop_poles = poles'
  Approximate_closed_loop_poles = cl_poles
  Exact_k_x = kk
  Approximate_k_x = k_x
  Exact_K_X = K_X
  Approximate_K_X = [K_x -K_w]
  Computed_K_x = K_X_comp
  K_xw_error = Approximate_K_X-K_X
  format
endfunction



Deleted mttroot/mtt/lib/control/PPP/ppp_ex10.m version [cee25ffa57].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex10 (ReturnName)

  ## usage:  name = ppp_ex10 (ReturnName)
  ##
  ## PPP example - shows a standard multivariable system
  ##
 
  ## Example name
  name = "Remotely-piloted vehicle example:  system RPV from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = rpv;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = 1*[0.9:0.01:1];		# Time horizon
  A_w = 0;		# Setpoint
#   TC = 0.1*[1 1];		# Time constants for each input
#   A_u = [];
#   for tc=TC			# Input
#     A_u = [A_u;ppp_aug(laguerre_matrix(2,1/tc), 0)];
#   endfor
  A_u = ppp_aug(laguerre_matrix(2,5.0), A_w)
  Q = [1;1];		# Output weightings

  ## Design and plot
  W = [1;2]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex11.m version [b816bab9e6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107











































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,J] = ppp_ex11 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex11 (ReturnName)
  ##
  ## PPP example

  ## 	$Id$	


  ## Example name
  name = "Input constraints +-1.5 on u* at tau=0,0.5,1,1.5,2";

  if nargin>0
    return
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [6:0.02:7];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions

  Q = ones(n_y,1);;
  

  ## Constraints
  Gamma = [];
  gamma = [];

  ## Constraints - u
  Tau_u = [0:0.5:2];
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [];			# No output constraints
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  disp("Designing controller");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  ## Constrained OL simulation
  disp("Computing constrained ol response");
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  disp("Computing unconstrained ol response");
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y*");
  xlabel("t");
  grid;
  figure(1);
  plot(T,ys,"-;y*: constrained;", T,ysu, "--;y*: unconstrained;")

  ## Non-linear - closed-loop
    disp("Computing constrained closed-loop response");
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0);

  title("Constrained closed-loop response");
  xlabel("t");
  grid;
  figure(2);
  plot(T,y,"-;y;", T,u,"--;u;");

#   ## Compute derivatives.
#   dt = t(2)-t(1);
#   du = diff(u)/dt;
#   dus = diff(us)/dt;
#   T1 = T(1:length(T)-1);
  ##plot(T1,du,T1,dus);
endfunction




Deleted mttroot/mtt/lib/control/PPP/ppp_ex12.m version [03125b8f94].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,J,T1,du,dus] = ppp_ex12 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex12 (ReturnName)
  ##
  ## PPP example - shows input derivative constraints  
  ## $Id$


  ## Example name
  name = "Input derivative constraints +-1 on u* at tau=0,0.5,1,1.5,2";

  if nargin>0
    return
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [4:0.02:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  Q = ones(n_y,1);;

  ## Constaints - du*/dtau
  Tau = [0:0.5:2];
  one = ones(size(Tau));
  limit = 1;
  Min = -limit*one;
  Max =  limit*one;
  Order = one;
  [Gamma,gamma] = ppp_input_constraint (A_u,Tau,Min,Max,Order);

  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin (A,B,C,D,A_u,A_w,t,Q);
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar(A,B,C,D,x_0,A_u,U,T);

  ## Non-linear - closed-loop
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			   Tau,Min,Max,Order, \
			   [],[],[],[], W,x_0);

  title("y,y*,u and u*");
  xlabel("t");
  grid;
  plot(T,y,"1;y;", T,u,"2;u;", T,ys,"3;y*;", T,us,"4;u*;");

  ## Compute derivatives.
  dt = t(2)-t(1);
  du = diff(u)/dt;
  dus = diff(us)/dt;
  T1 = T(1:length(T)-1);
  ##plot(T1,du,T1,dus);
endfunction








Deleted mttroot/mtt/lib/control/PPP/ppp_ex13.m version [410a811ae6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex13 (ReturnName)

  ## usage:  ppp_ex13 ()
  ##
  ## PPP example: Sensitivity minimisation (incomplete)


  ## Example name
  name = "Sensitivity minimisation (incomplete)";

  if nargin>0
    return
  endif
  

  ## System - unstable
  A = [-3 -3 -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5 1
       0  1.0 0];
  D = [0;0];

  ## Setpoint
  A_w = [0;0]

  ## Controller
  t =[0:0.1:5];			# Optimisation horizon
  t1 =[0:0.1:1];
  t2 =[1.1:0.1:3.9];	
  t3 =[4:0.1:5];
  

  A_u = ppp_aug(laguerre_matrix(3,5.0), 0);
  q_s=1e3;
  Q = [exp(5*t)
       q_s*exp(-t)]
  size(Q)
  W = [1;0];

  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W)

endfunction



Deleted mttroot/mtt/lib/control/PPP/ppp_ex14m.m version [da6984e601].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102






































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex14m (ReturnName)

  ## usage:   [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex14 (ReturnName)
  ##
  ## PPP example - shows output constraints on nonlinear system
  ## 	$Id$	


  ## Example name
  name = "Output constraints -0.1 on y* at tau=0.1,0.5,1,2";

  if nargin>0
    if ReturnName
      return
    endif
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.02:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  Q = ones(n_y,1);;

  ## Constaints - u
  Tau_u = [];
  one = ones(size(Tau_u));
  limit = 3;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [0.1 0.5 1 2]
  one = ones(size(Tau_y));
  Min_y =  -0.01*one; # Min_y(5) = 0.99;
  Max_y =  1e5*one;   # Max_y(5) = 1.01;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);
  [Gamma_y,gamma_y] = ppp_output_constraint  (A,B,C,D,x_0,A_u,Tau_y,Min_y,Max_y,Order_y);

  Gamma = [Gamma_u; Gamma_y];
  gamma = [gamma_u; gamma_y];

  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constained and unconstrained y*");
  xlabel("t");
  grid;
  plot(T,ys,T,ysu)

  ## Non-linear - closed-loop
  movie = 1; 
  if movie
    hold on;
  endif
  
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0,movie);

  hold off;
#   title("y,y*,u and u*");
#   xlabel("t");
#   grid;
#   plot(T,y,T,u,T,ysu,T,usu);

  ## Compute derivatives.
  dt = t(2)-t(1);
  du = diff(u)/dt;
  dus = diff(us)/dt;
  T1 = T(1:length(T)-1);
  ##plot(T1,du,T1,dus);
endfunction




Deleted mttroot/mtt/lib/control/PPP/ppp_ex15.m version [f570a84dcf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  [name,T,y,u,ye,ue,J] = ppp_ex15 (ReturnName)

  ## usage:  ppp_ex15 ()
  ##
  ## PPP example - an unstable, nmp siso system
  ## 	$Id$	

  ## Example name
  name = "Linear unstable non-minimum phase third order system - intermittent control";

  if nargin>0
    return
  endif
  

  ## System - unstable
  A = [3 -3  1
       1  0  0
       0  1  0];
  B = [10
       0 
       0];
  C = [0 -0.5 1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Setpoint
  A_w = ppp_aug(0,[]);

  ## Controller
  t =[4.0:0.01:5.0];		# Optimisation horizon
  dt = t(2)-t(1);
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w);
  Q = 1;			# Weight

  ##Simulate
  W = 1;			# Setpoint
  x_0 = zeros(n_x,1);		# Initial state


  ## Closed-loop intermittent solution
  Delta_ol = 0.5		# Intermittent time

  disp("Intermittent control simulation");
  R=1;P=0;
  [T,y,u] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q,R,P, \
			  [],[],[],[], \
			  [],[],[],[],W,x_0,Delta_ol);
size(T)
  ## Exact closed-loop
  disp("Exact closed-loop");
  [k_x,k_w] = ppp_lin (A,B,C,D,A_u,A_w,t,Q)
  [ye,Xe] = ppp_sm2sr(A-B*k_x, B, C, D, T, k_w*W, x_0); # Compute Closed-loop control

  ue = k_w*ones(size(T))*W - k_x*Xe;


  title("y and u, exact and intermittent");
  xlabel("t");
  grid;
  plot(T,y,"1;y (intermittent);", T,u,"2;u (intermittent);",\
       T,ye,"3;y (exact);", T,ue,"4;u (exact);");

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex16.m version [b34052bc15].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,J] = ppp_ex16 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex16 (ReturnName)
  ##
  ## PPP example

  ## 	$Id$	


  ## Example name
  name = "Input constraints +-1.5 on u* at tau=0,0.1,0.2..,2.0 - intermittent control";

  if nargin>0
    return
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [5:0.01:6];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  A_u = ppp_aug(laguerre_matrix(1,0.5), A_u); # Add some extra slow modes
  Q = ones(n_y,1);;

  ## Constaints
  Gamma = [];
  gamma = [];

  ## Constaints - u
  Tau_u = [0:0.1:2]; 
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constaints - y
  Tau_y = [];
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  disp("Control design");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  disp("Open-loop simulations");
  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y* and u*");
  xlabel("t");
  grid;
  axis([0 6 -1 2]);
  plot(T,ys,T,ysu,T,us,T,usu)
  axis;

  ## Non-linear - closed-loop
  disp("Closed-loop simulation");
  Delta_ol = 0.1;
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0,Delta_ol);

  title("y,y*,u and u*");
  xlabel("t");
  grid;
  plot(T,y,T,u,T,ys,T,us);
endfunction








Deleted mttroot/mtt/lib/control/PPP/ppp_ex17.m version [fd73fba900].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex17 (ReturnName)

  ## usage:   [name,T,y,u,ys,us,ysu,usu,J] = ppp_ex17 (ReturnName)
  ##
  ## PPP example - shows output constraints on nonlinear system
  ## 	$Id$	


  ## Example name
  name = "Output constraints -0.1 on y* at tau=0.1,0.5,1,2 - intermittent control";

  if nargin>0
    if ReturnName
      return
    endif
  endif
  
  ## System
  A = [-3 -3  -1
       1  0  0
       0  1  0];
  B = [1 
       0 
       0];
  C = [0 -0.5  1];
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [9:0.02:10];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(3,2.0), A_w); # Input functions
  Q = ones(n_y,1);;

  ## Constraints - u
  Tau_u = [];
  one = ones(size(Tau_u));
  limit = 3;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [0.1 0.5 1 2]
  one = ones(size(Tau_y));
  Min_y =  -0.01*one; # Min_y(5) = 0.99;
  Max_y =  1e5*one;   # Max_y(5) = 1.01;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(3,1);

  ## Constrained - open-loop
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t,Q); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);
  [Gamma_y,gamma_y] = ppp_output_constraint  (A,B,C,D,x_0,A_u,Tau_y,Min_y,Max_y,Order_y);

  Gamma = [Gamma_u; Gamma_y];
  gamma = [gamma_u; gamma_y];

  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];

  ## OL solution
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constained and unconstrained y*");
  xlabel("t");
  grid;
  figure(1);
  plot(T,ys,"-;y* (constrained);", T,ysu,"--;y* (unconstrained);")

  ## Non-linear - closed-loop
  delta_ol = 0.1; mu = 1e-4;
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  Tau_u,Min_u,Max_u,Order_u, \
			  Tau_y,Min_y,Max_y,Order_y,W,x_0,delta_ol,mu);

  title("y and u");
  xlabel("t");
  grid;
  plot(T,y,"1;y (constrained);", T,u,"2;u (constrained);");

endfunction




Deleted mttroot/mtt/lib/control/PPP/ppp_ex18.m version [4568857bd3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex18 (ReturnName)

  ## usage:  ppp_ex18 ()
  ##
  ## PPP example - an unstable, nmp siso system
  ## 	$Id$	


  ## Example name
  name = "First order with redundant inputs";

  if nargin>0
    return
  endif
  
  ## System 
  A = 1
  B = 1
  C = 1
  D = 0;

  ## Setpoint
  A_w = ppp_aug(0,[]);

  ## Controller
  ##Optimisation horizon
  t =[2:0.1:3];

  ## A_u
  A_u = diag([0  -2 -4 -6])

  [ol_poles,cl_poles] = ppp_lin_plot (A,B,C,D,A_u,A_w,t)

  
endfunction





Deleted mttroot/mtt/lib/control/PPP/ppp_ex19.m version [8863f79b17].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,J] = ppp_ex19 (ReturnName,n_extra,T_extra)

  ## usage:   [name,T,y,u,ys,us,T1,du,dus] = ppp_ex19 (ReturnName)
  ##
  ## PPP example

  ## 	$Id$	


  ## Example name
  name = "Input constraints with redundant U*";

  if (nargin>0)&&(ReturnName==1)
    return
  endif


  if nargin<2
    n_extra = 3
  endif
  
  if nargin<3
    T_extra = 2.0
  endif
  

  ## System
  A = 1
  B = 1
  C = 1
  D = 0;
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Controller
  t = [2:0.01:3];		# Time horizon
  A_w = 0;
  A_u = diag([0  -6]);
  A_u = ppp_aug(A_u,laguerre_matrix(n_extra,1/T_extra))
  Q = 1;
  ## Constraints
  Gamma = [];
  gamma = [];

  ## Constraints - u
  Tau_u = [0 0.1 0.5 1 1.5 2];
  Tau_u = 0;
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [];
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=1;
  x_0 = zeros(n_x,1);

  ## Constrained - open-loop
  disp("Control design");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  disp("Open-loop simulations");
  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y*");
  xlabel("t");
  grid;
  plot(T,ys,"-;y* (constrained);", T,ysu,"--;y* (unconstrained);");

  ## Non-linear - closed-loop
  disp("Closed-loop simulation");
  [T1,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			   Tau_u,Min_u,Max_u,Order_u, \
			   Tau_y,Min_y,Max_y,Order_y,W,x_0);

  title("y and u");
  xlabel("t");
  grid;
  plot(T,y,"1;y (constrained);", T,u,"2;u (constrained);");

endfunction






Deleted mttroot/mtt/lib/control/PPP/ppp_ex2.m version [163faa5b9f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex2 (Return_Name)

  ## usage:  Name = ppp_ex2 (Return_Name)
  ##
  ## PPP example: Effect of slow desired closed-loop
  ## 	$Id$	


  ## Example name
  name = "Effect of slow desired closed-loop: closed-loop is same as open loop";

  if nargin>0
    return
  endif
  
  ## System
  A = -1;			# Fast - time constant = 1
  B = 0.5;			# Gain is 1/2
  C = 1;
  D = 0;

  ## Controller
  t =[9:0.1:10];		# Optimisation horizon

  A_u = [-0.1 0			# Slow - time constant = 10
         1 0];

  A_w = 0;			# Constant set point

  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot(A,B,C,D,A_u,A_w,t)
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex20.m version [bd637b24f5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,ysu,usu] = ppp_ex20 (ReturnName)

  ## usage:  ppp_ex20 ()
  ##
  ## PPP example - 2nd-order 2i2o system
  ## 	$Id$	


  ## Example name
  name = "2nd-order 2i2o system with 1st-order basis"

  if nargin>0
    return
  endif

  ## System  
  A = [-2 -1
       1   0];
  B = [[1;0], [1;2]];
  C = [ [0,1]; [2,1]];
  D = zeros(2,2);

#  sys = ss2sys(A,B,C,D);
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

#   ## Display it
#   for j = 1:n_u
#     for i = 1:n_y
#       sysout(sysprune(sys,i,j),"tf")
#       step(sysprune(sys,i,j),1,5);
#     endfor
#   endfor
  
  ## Setpoint
  A_w = 0;

  ## Controller

  ##Optimisation horizon
  t =[4:0.01:5];

  ## A_u
  pole = [3];
  poles = 1;
  A_u = ppp_aug(butterworth_matrix(poles,pole),0);
  Q = ones(n_y,1);;

  ## Setpoints
  W = [1:n_y]';

  ## Design and plot
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

  format bank
  cl_poles

  A_c = A-B*k_x;			# Closed-loop A
  A_cw = [A_c B*k_w*W
          zeros(1,n_x+1)]

  log_cond_uu = log10(cond_uu)
				#  K_xwe = ppp_open2closed(A_u,A_cwe,[k_xe -k_we*W]); # Exact Kx
#  K_xwc = ppp_open2closed(A_u,A_cw,[k_x -k_w*W]); # Computed Kx
				#  Exact_K_xw = K_xwe
  PPP_K_xw = [K_x -K_w*W] 
#  Comp_K_xw = K_xwc

#  Error = Approx_K_xw - Comp_K_xw

endfunction



Deleted mttroot/mtt/lib/control/PPP/ppp_ex20.new.m version [fd66e71f1b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# function name = ppp_ex20 (ReturnName)

#   ## usage:  name = ppp_ex20 (ReturnName)
#   ##
#   ## PPP example -- a standard multivariable example
#   ## 	$Id$	



#   ## Example name
#   name = "Turbogenerator example:  system TGEN from J.M Maciejowski: Multivariable Feedback Design";

#   if nargin>0
#     return
#   endif
  
  ## System
  [A,B,C,D] = airc;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [9:0.1:10];		# Time horizon
  A_w = zeros(n_y,1);		# Setpoint
  TC = 2*[1 1];		# Time constants for each input
 #  A_u = [];
#   for tc=TC			# Input
#     A_u = [A_u;ppp_aug(laguerre_matrix(3,1/tc), 0)];
#   endfor
 A_u =  ppp_aug(laguerre_matrix(5,1.0), 0);
 Q = [1;1];		# Output weightings

  ## Constraints
  Gamma = [];
  gamma = [];

  ## Constraints - u
  Tau_u = [0 0.1 0.5 1 1.5 2];
  Tau_u = 0;
  one = ones(size(Tau_u));
  limit = 1.5;
  Min_u = -limit*one;
  Max_u =  limit*one;
  Order_u = 0*one;

  ## Constraints - y
  Tau_y = [];
  one = ones(size(Tau_y));
  limit = 1.5; 
  Min_y = -limit*one;
  Max_y =  limit*one;
  Order_y = 0*one;

  ## Simulation
  W=[1;2;3];
  x_0 = zeros(n_x,1);

  ## Constrained - open-loop
  disp("Control design");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t); # Unconstrained design
  [Gamma_u,gamma_u] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u);

  Gamma = Gamma_u;
  gamma = gamma_u;

  disp("Open-loop simulations");
  ## Constrained OL simulation
  [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
  T = [0:t(2)-t(1):t(length(t))];
  [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

  ## Unconstrained OL simulation
  [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]);
  [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

  title("Constrained and unconstrained y*");
  xlabel("t");
  grid;
  plot(T,ys,T,ysu)

  ## Non-linear - closed-loop
  disp("Closed-loop simulation");
  [T1,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			   Tau_u,Min_u,Max_u,Order_u, \
			   Tau_y,Min_y,Max_y,Order_y,W,x_0);

  title("y,y*,u and u*");
  xlabel("t");
  grid;
  plot(T1,y,T,ys,T1,u,T,us);


#endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex21.m version [0b03160976].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,ys,us,ysu,usu] = ppp_ex21 (ReturnName)

  ## usage:  ppp_ex21 ()
  ##
  ## PPP example - 2nd-order 2i2o system system with anomalous behaviour"
  ## 	$Id$	


  ## Example name
  name = "2nd-order 2i2o system with anomalous behaviour"

  if nargin>0
    return
  endif

  ## System  
  A = [-2 -1
       1   0];
  B = [[1;0], [1;2]];
  C = [ [0,1]; [2,1]];
  D = zeros(2,2);

  sys = ss2sys(A,B,C,D);
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  ## Display it
  for j = 1:n_u
    for i = 1:n_y
      sysout(sysprune(sys,i,j),"tf")
      step(sysprune(sys,i,j),1,5);
    endfor
  endfor
  
  ## Setpoint
  A_w = 0;

  ## Controller

  ##Optimisation horizon
  t =[4:0.1:5];

  ## A_u
  pole = [4];
				#A_u = ppp_aug(laguerre_matrix(2,pole),0);
				#A_u = ppp_aug(diag([-3,-4]),0);
  A_u = ppp_aug(butterworth_matrix(2,pole),0);
  Q = ones(n_y,1);;

  ## Setpoints
  W = [1:n_y]';

  ## Initial condition
  x_0 = [0;0.5];

  ## Design and plot
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0);

  format short
  cl_poles

  A_c = A-B*k_x;			# Closed-loop A
  A_cw = [A_c B*k_w*W
          zeros(1,n_x+1)]

  log_cond_uu = log10(cond_uu)
				#  K_xwe = ppp_open2closed(A_u,A_cwe,[k_xe -k_we*W]); # Exact Kx
				#AA_u = ppp_inflate([A_u;A_u]);
  K_xwc = ppp_open2closed(A_u,A_cw,[k_x -k_w*W]) # Computed Kx
				#  Exact_K_xw = K_xwe
  Approx_K_xw = [K_x -K_w*W] 
  format

endfunction



Deleted mttroot/mtt/lib/control/PPP/ppp_ex3.m version [c1cd799f6a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex3 (Return_Name)

  ## usage:  Name = ppp_ex3 (Return_Name)
  ##
  ## PPP example: Uncoupled 5x5 system
  ##  	$Id$	




  ## Example name
  name = "Uncoupled NxN system - n first order systems";

  if nargin>0
    return
  endif
  
  ## System - N uncoupled integrators
  N = 3
  A = -0.0*eye(N);
  B = eye(N);
  C = eye(N);
  D = zeros(N,N);

  t =[4:0.1:5];			# Optimisation horizon
  ## Create composite matrices
  A_u = [];			# Initialise
  A_w = [];			# Initialise

  for i=1:N			
    ## Setpoint - constant
    a_w = ppp_aug(0,[]);
    A_w = [A_w;a_w];

    ## Controller
    a_u = ppp_aug(-i,a_w);
    A_u = [A_u; a_u];
 endfor
  
  A_u = [-diag([1:N])]

  Q = ones(N,1);		# Equal output weightings
  W = ones(N,1);		# Setpoints are all unity

  ## Design and simulate
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u] = ppp_lin(A,B,C,D,A_u,A_w,t);
  # [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = \
  #     ppp_lin_plot(A,B,C,D,A_u,A_w,t,Q,W);

  Approximate_K_x = K_x#(1:2:2*N,:)
  A_c = A-B*k_x;
  Closed_Loop_Poles = eig(A-B*k_x)
  ## Now try out the open/closed loop theory
#   A_u = -diag(1:N);		# Full A_u matrix
#   A_c = -diag(1:N);		# Ideal closed-loop
#   k_x = diag(1:N);		# Ideal feedback
  KK = ppp_open2closed (ppp_inflate(A_u),A_c,k_x);
  Exact_K_x_tilde = KK
  

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex4.m version [f6af77ca79].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex4 (ReturnName)

  ## usage:  ppp_ex4 ()
  ##
  ## PPP example -- a 1i2o system with performance limitations
  ## 	$Id$	



  ## Example name
  name = "Resonant system (1i2o): illustrates performance limitations with 2 different time-constants";

  if nargin>0
    return
  endif
  

  ##  Mass- sping damper from Middleton et al EE9908

  ## Set parameters to unity
  m_1 = 1;		
  m_2 = 1;
  k = 1;

  ## System
  [A,B,C,D] = TwoMassSpring (k,m_1,m_2);

  for TC = [0.4 1]
    disp(sprintf("\nClosed-loop time constant = %1.1f\n",TC));
    ## Controller
    A_w = zeros(2,1);	# Setpoint: Unit W* for each output
    t =[11:0.1:12];			# Optimisation horizon
    [A_u] = ppp_aug(laguerre_matrix(4,1/TC), 0);	# U*

    Q = [1;0];

    ## Design and plot
    [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q)
    hold on;
  endfor

  hold off;
endfunction




Deleted mttroot/mtt/lib/control/PPP/ppp_ex5.m version [eab12a6897].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex5 (ReturnName)

  ## usage:  ppp_ex5 (ReturnName)
  ##
  ## PPP example -- a 28-state vibrating beam system
  ## 	$Id$	


  ## Example name
  name = "Vibrating beam: 14 state regulation problem with 7 beam velocities as output";

  if nargin>0
    return
  endif
  
  
  ## System - beam
  Beam_numpar;
  [A,B,C,D]=Beam_sm;
  
  ## Redo C and D to reveal ALL velocities
  c = C(1);
  C = zeros(7,14);
  for i = 1:7
    C(i,2*i-1) = c;
  endfor
  D = zeros(7,1);

  e = eig(A);			# Eigenvalues
  N = length(e);
  frequencies = sort(imag(e));
  frequencies = frequencies(N/2+1:N); # Modal frequencies

  ## Controller
  ## Controller design parameters
  t = [0.4:0.01:0.5];		# Optimisation horizon

  Q = ones(7,1); 

  ## Specify input basis functions 
  ##  - damped sinusoids with same frequencies as beam
  damping_ratio = 0.2;		# Damping ratio of inputs
  A_u = damped_matrix(frequencies,0.2*ones(size(frequencies)));
  u_0 = ones(14,1);		# Initial conditions

  A_w = zeros(7,1);		# Setpoint
  W =  zeros(7,1);		# Zero setpoint

  ## Set up an "typical" initial condition
  x_0 = zeros(14,1);
  x_0(2:2:14) = ones(1,7);	# Set initial twist to 1.

  ## Simulation
  [ol_poles,cl_poles] =  ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0);

  

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex6.m version [a3383c7b66].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [name,T,y,u,J] = ppp_ex6 (ReturnName)

  ## usage:  [name,T,y,u,J] = ppp_ex6 (ReturnName)
  ##
  ## PPP example -- PPP for redundant actuation
  ## 	$Id$	


  ## Example name
  name = "Two input-one output system with input constraints";

  if nargin>0
    return
  endif
  
  ## System
  A = 0;
  B = [0.5 1];
  C = 1;
  D = [0 0];
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.1:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = [-2;-0.5];		# Input
  Q = 1;			# Output weight

  ## Constrain  input 1 at time tau=0
  Tau = 0;
  Max = [1;inf]
  Min = [-inf;-inf];
  Order = 0;
  i_u = 1;
  
  ## Simulation
  W=1;
  x_0 = 0;

  ## Linear
  ppp_lin_plot (A,B,C,D,A_u,A_w,t);
  
  ## Non-linear
  movie = 0;
  [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, Tau,Min,Max,Order, \
	      [],[],[],[], W,x_0);
  title("y,u_1,u_2");
  xlabel("t");
  grid;
  plot(T,y,"-;y;", T,u(1,:),"--;u_1;", T,u(2,:),".-;u_2;");

endfunction



Deleted mttroot/mtt/lib/control/PPP/ppp_ex7.m version [20afb5cf0e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex7 (ReturnName)

  ## usage:  name = ppp_ex7 (ReturnName)
  ##
  ## PPP example -- standard multivariable system
  ## 	$Id$	


  ## Example name
  name = "Aircraft example:  system AIRC from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = airc;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.01:5];		# Time horizon
  A_w = 0;		# Setpoint (same for each input)
  #A_u = ppp_aug(laguerre_matrix(5,1), 0) # Same for each input 
  A_u = laguerre_matrix(5,1); # Same for each input 
  Q = ones(3,1);		# Output weightings
  ## Design and plot
  W = [1;2;3]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);
   cl_poles

  ## Try open-closed theory but using computed values:
  A_c = A - B*k_x; eig(A_c)
  K_x
  KK = ppp_open2closed (A_u,A_c,k_x)

  100*((KK-K_x)./KK)
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex8.m version [d3d175c796].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex8 (ReturnName)

  ## usage:  name = ppp_ex8 (ReturnName)
  ##
  ## PPP example - standard multivariable example
  ## 	$Id$	

  ## Example name
  name = "Automotive gas turbine example:  system AUTM from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = autm;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [4:0.1:5];		# Time horizon
  A_w = 0;			# Setpoint
  A_u = ppp_aug(laguerre_matrix(4,2.0), 0) # Input
  Q = [1;1e3];		# Output weightings

  ## Design and plot
  W = [1;2]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ex9.m version [c71a52df94].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function name = ppp_ex9 (ReturnName)

  ## usage:  name = ppp_ex9 (ReturnName)
  ##
  ## PPP example -- a standard multivariable example
  ## 	$Id$	



  ## Example name
  name = "Turbogenerator example:  system TGEN from J.M Maciejowski: Multivariable Feedback Design";

  if nargin>0
    return
  endif
  
  ## System
  [A,B,C,D] = tgen;
  [n_x,n_u,n_y] = abcddim(A,B,C,D)

  ## Controller
  t = [1.0:0.01:2.0];		# Time horizon
#   A_w = zeros(n_y,1);		# Setpoint
#   TC = 2*[1 1];		# Time constants for each input
#   A_u = [];
#   for tc=TC			# Input
#     A_u = [A_u;ppp_aug(laguerre_matrix(3,1/tc), 0)];
#   endfor
  A_w = 0;
  A_u = ppp_aug(ppp_aug(laguerre_matrix(2,1.0),laguerre_matrix(2,2.0)), A_w)
  Q = [1;1];		# Output weightings

  ## Design and plot
  W = [1;2]
  [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W);

#   ol_poles, cl_poles
#   k_x,k_w
#   K_X = [K_x -K_w]
#   A_c = A - B*k_x;
#   K_X_comp = ppp_open2closed (A_u,[A_c B*k_w*W; zeros(1,n_x+1)],[k_x -k_w*W])
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_examples.m version [e27b26eff0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ppp_examples ()

  ## usage:  ppp_examples ()
  ##
  ## Various menu-driven PPP examples


  str="menu(""Predictive Pole-Placement (PPP) examples"",""Exit"",""All examples"; # Menu string

  used = 2;
  option=used;  

  while option>1

    exists=1; 
    i_example=1;		# Example counter
    while exists
      name=sprintf("ppp_ex%i",i_example);
      exists=(exist(name)==2);
      if exists
	title = eval(sprintf("%s(1);", name)); 
	str = sprintf("%s"",""%s",str,title);
	i_example++;
      endif
    endwhile
    n_examples = i_example-1;

    str = sprintf("%s"" );\n",str);

    option=eval(str);		# Menu - ask user

    if option>1			# Do something - else return
      if option==2		# All examples
	Examples=1:n_examples;
      else			# Just the chosen examples
	Examples = option-used;
      endif
      for example=Examples	# Do the chosen examples
	eval(sprintf("Title = ppp_ex%i(1);",example));
	disp(sprintf("Evaluating example ppp_ex%i:\n\t %s\n", example, Title));
	eval(sprintf("ppp_ex%i;",example));
      endfor
    endif
    
    
  endwhile

endfunction






Deleted mttroot/mtt/lib/control/PPP/ppp_extract.m version [b84460c15f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function A_i = ppp_extract (A_u,input)

  ## usage:  A_i = ppp_extract (A_u)
  ##
  ## Extracts the ith A_u matrix.

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  [n,m] = size(A_u);		# Size of composite A_u matrix
  square = (n==m);		# Its a square matrix so same U* on each input
  if square
    A_i = A_u;			# All a_u the same
  else
    N = m;			# Number of U* functions per input  
    n_u = n/m;
    if floor(n_u) != n_u	# Check that n_u is an integer
      error("A_u must be square or be a column of square matrices");
    endif
    
    if input>n_u
      error("Input index too large");
    endif
    
    ## Extract the ith matrix
    start = (input-1)*N;
    range=(start+1:start+N);
    A_i = A_u(range,:);
  endif

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_identify.m version [fae8c72792].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [par,Par,Error,Y] = ppp_identify (system_name,u,y_0,par_names,par_0,extras)
  ## ppp_identify: System identification for PPP
  ## usage:  [par,Par,Error,Y] = ppp_identify(system_name,u,y_0,par_names,par_0,extras)
  ##
  ##  system_name     String containing system name
  ##  u               System input (column vector, each row is u')
  ##  y_0             Desired model output
  ##  par_names       Column vector of (padded) strings - the adjustable
  ##                  parameter names
  ##  par_0           Initial parameter vector estimate
  ##  extras (opt)    optimisation parameters
  ##        .criterion convergence criterion
  ##        .max_iterations limit to number of iterations
  ##        .v  Initial Levenberg-Marquardt parameter

  
  if nargin<6
    extras.criterion = 1e-5;
    extras.max_iterations = 10;
    extras.v = 1e-5;
    extras.verbose = 0;
  endif  

  s_system_name = sprintf("s%s", system_name); # Name of sensitivity system

  ## Set up parameters
  sim = eval([s_system_name, "_simpar;"]); # Simulation parameter
  sym = eval([s_system_name, "_sympar;"]); # Parameter names
  x0  = eval([s_system_name, "_state(par_0);"]); # Initial state

#   ## Set up the free parameter list
#   free = [];
#   [n,m] = size(par_names);
#   for i = 1:n
#     p_name = deblank(par_names(i,:));
#     s_name = sprintf("%ss", p_name);
#     if struct_contains(sym, p_name)
#       i_p = eval(sprintf("sym.%s;", p_name));
#       if struct_contains(sym, s_name)
# 	i_s = eval(sprintf("sym.%s;", s_name));
# 	free_i = eval(sprintf("[%i,%i];", i_p, i_s));
# 	free = [free; free_i];
#       else
# 	printf("Sensitivity parameter %s does not exist: ignoring \
# 	parameter %s\n", s_name, p_name);
#       endif
#     else
#       printf("Parameter %s does not exist: ignoring\n", p_name)
#     endif
#   endfor
#   free
  free = ppp_indices(par_names,sym);
  [par,Par,Error,Y] = ppp_optimise(s_system_name,x0,par_0,sim,u,y_0,free,extras);

endfunction







Deleted mttroot/mtt/lib/control/PPP/ppp_indices.m version [719278145f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function indices = ppp_indices (names,sympar,sympars)

  ## usage:  indices = ppp_indices (names,sympar)
  ##
  ## names: column vector of component names
  ## sympar symbolic parameter structure for system
  ## sympars symbolic parameter structure for sensitivity system
 

  ## Returns a matrix indices with 3 columns, one row per name
  ## First  col: index of ith parameter of sensitivity system
  ## Second col: index of ith sensitivity parameter of sensitivity system
  ## Third col : index of ith parameter of system
  ## Copyright (C) 2002 by Peter J. Gawthrop

  ## Sanity check
  if nargin<3
    printf("Usage: ppp_indices (names,sympar,sympars)\n");
    return
  endif
  
  ## Set up the
  indices = [];
  [n,m] = size(names);
  for i = 1:n
    p_name = deblank(names(i,:));
    s_name = sprintf("%ss", p_name);
    if struct_contains(sympars, p_name)
      i_ps = eval(sprintf("sympars.%s;", p_name));
      if struct_contains(sympars, s_name)
	i_s = eval(sprintf("sympars.%s;", s_name));
	if struct_contains(sympar, p_name)
	  i_p = eval(sprintf("sympar.%s;", p_name));
	  indices_i = eval(sprintf("[%i,%i,%i];", i_ps, i_s, i_p));
	  indices = [indices; indices_i];
	else
	  printf("Parameter %s does not exist in sympar: ignoring\n", p_name)
	endif
      else
	printf("Sensitivity parameter %s does not exist in sympars: ignoring \
	parameter %s\n", s_name, p_name);
      endif
    else
      printf("Parameter %s does not exist in sympars: ignoring\n", p_name)
    endif
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_inflate.m version [c4fc3a116e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function A_m = ppp_inflate (A_v)

  ## usage:  A_m = ppp_inflate (A_v)
  ##
  ## Creates the square matrix A_m with the matrix elements of the column
  ## vector of square matrices A_v.

  ## Copyright (C) 2001 by Peter J. Gawthrop

  [N,M] = size(A_v);

  if N<M
    error("A_v must have at least as many rows as columns");
  endif
  
  n = N/M;			# Number of matrix elements in A_v

  if round(n)!=n
    error("A_v must be a column vector of square matrices");
  endif
  
  A_m = [];
  for i = 1:n
    A_m = ppp_aug(A_m,ppp_extract(A_v,i));
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_input_constraint.m version [75b7c0f8a7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Gamma,gamma] = ppp_input_constraint (A_u,Tau,Min,Max,Order,i_u,n_u)

  ## usage:  [Gamma,gamma] = ppp_input_constraint (A_u,Tau,Min,Max,Order,i_u,n_u)
  ##
  ## Derives the input constraint matrices Gamma and gamma
  ## For Constraints Min and max at times Tau 
  ## Order=0 - input constraints
  ## Order=1 - input derivative constraints
  ## etc
  ## i_u: Integer index of the input to be constrained
  ## n_u: Number of inputs
  ## NOTE You can stack up Gamma and gamma matrices for create 
  ##    multi-input constraints.
  ## Limits at inf and -inf are discarded

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	


  ## Sizes
  [n_U,m_U] = size(A_u);	# Number of basis functions
  [n,N_t] = size(Tau);		# Number of constraint times
  
  ## Defaults
  if nargin<5
    Order = zeros(1,N_t);
  endif

  if nargin<6
    i_u = 1;
    n_u = 1;
  endif
  
  if N_t==0			# Nothing to be done
    Gamma = [];
    gamma = [];
    return
  endif
  
  if n != 1
    error("Tau must be a row vector");
  endif
  
  n = length(Min);
  m = length(Max);
  o = length(Order);

  if (n != N_t)||(m != N_t)||(o != N_t)
    error("Tau, Min, Max and Order must be the same length");
  endif
  
  ## Extract the A_i matrix for this input
  A_i = ppp_extract(A_u,i_u);

  ## Create the constraints in the form: Gamma*U < gamma
  Gamma = [];
  gamma = [];
  one = ones(m_U,1);
  i=0;

  zero_l = zeros(1,(i_u-1)*m_U); # Pad left-hand
  zero_r = zeros(1,(n_u-i_u)*m_U); # Pad right-hand
  for tau = Tau			# Stack constraints for each tau
    i++;

    Gamma_tau = ( A_i^Order(i) * expm(A_i*tau) * one )';
    Gamma_tau = [ zero_l Gamma_tau zero_r ]; # Only for i_uth input

    if Max(i)<inf
      Gamma = [Gamma; Gamma_tau];
      gamma = [gamma; Max(i)];
    endif
    
    if Min(i)>-inf
      Gamma = [Gamma; -Gamma_tau];
      gamma = [gamma; -Min(i)];
    endif
    
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_input_constraints.m version [804cd7fa35].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Gamma,gamma] = ppp_input_constraints (A_u,Tau,Min,Max,Order)

  ## usage:  [Gamma,gamma] = ppp_input_constraints (A_u,Tau,Min,Max[,Order])
  ##
  ## Derives input copnstraint matrices Gamma and gamma 
  ## for multi-input systems.
  ## A_u Input-generating matrix
  ## Tau row vector of times at which constraints occur
  ## Max, Maximum and minimum values
  ## Limits at inf and -inf are discarded

  ## Sanity check
  [n_u,n_tau] = size(Min);
  [n,m] = size(Max);
  if (n!=n_u)||(m!=n_tau)
    error("Max and Min must have the same dimensions");
  endif
  
  [n,m] = size(Tau);
  if (m!=n_tau)
    error("Max and Min must have same number of columns as Tau");
  endif
  if (n>1)
    error("Tau must be a row vector");
  endif

  ##Defaults
  if nargin<5
    Order=zeros(1,n_tau);
  endif
  
  ## Stack up constraints for each input
  Gamma=[];
  gamma=[];
  for i_u=1:n_u
    [Gamma_i,gamma_i] = \
	ppp_input_constraint(A_u,Tau,Min(i_u,:),Max(i_u,:),Order,i_u,n_u);
    Gamma = [Gamma; Gamma_i];
    gamma = [gamma; gamma_i];
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_int_obs.m version [9bfdfe49cb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [x_p,y_p,y_new,error] = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)

  ## usage: x_new = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)
  ##
  ## Intermittent observer for PPP
  ##
  ## x,y Current estimated state and measured output
  ## U PPP control weights
  ## A,B,C,D System matrices
  ## A_u PPP basis matrix
  ## delta time step
  ## L Observer gain
  ## x_p, y_p predicted estimated state and output
  ## y_new corrected estimated current output
  ## error corresponding error

  ## Copyright (C) 2003 by Peter J. Gawthrop

  ## Sanity check
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  if nargin<10
    L = zeros(n_x,n_y);
  endif
  
  ## Corrector (on current value of output)
  error = (C*x-y);
  x_new = x - L*error;
  y_new = C*x_new;

  ## Predictor (predicts Delta_OL ahead)
  [y_p,us,x_p] = ppp_ystar (A,B,C,D,x_new,A_u,U,delta);

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ippp.m version [d40f70c238].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function i_ppp = ppp_ippp (n_ppp,sympar,sympars)

  ## usage:  i_ppp = ppp_ippp (n_ppp,sympar,sympars)
  ## nppp   number of ppp parameters
  ## sympars symbolic parameter structure for system
  ## sympar symbolic parameter structure for sensitivity system
  ## Returns a matrix i_ppp with n_ppp rows and 3 columns
  ## First  col: index of ith ppp parameter of sensitivity system
  ## Second col: index of ith ppp sensitivity parameter of sensitivity system
  ## Third col : index of ith ppp  parameter of system
  ## Copyright (C) 2002 by Peter J. Gawthrop

  i_ppp = [];
  for i=1:n_ppp
    i_ppp_i = eval(sprintf("[sympars.ppp_%i, sympars.ppp_%is \
			     sympar.ppp_%i];",i,i,i));
    i_ppp = [i_ppp ; i_ppp_i];
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_lin.m version [a68c3b73aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238














































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] = ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P,max_cond);
  ## usage:
  ## [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] =
  ##  ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P,max_cond)

  ##
  ## Linear PPP (Predictive pole-placement) computation 
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## OR
  ## A_u: square system matrix for U* generation 
  ##      same square matrix for each system input.
  ## A_w: composite system matrix for W* generation 
  ##      one square matrix (A_wi) row for each system output
  ##      each A_wi generates W*' for ith system output.
  ## tau: row vector of times for optimisation (equispaced in time)
  ## Q column vector of output weights (defaults to unity)
  ## OR
  ## Q matrix,  each row corresponds to time-varying weight compatible with t
  ## max_cond: Maximum condition number of J_uu (def 1/eps)
  ## OUTPUTS:
  ## k_x: State feedback gain
  ## k_w: setpoint gain
  ## ie u(t) = k_w w(t) - k_x x(t)
  ## K_x, K_w: open loop gains
  ## Us0: Value of U* at tau=0
  ## J_uu, J_ux, J_uw, J_xx,J_xw,J_ww: cost derivatives
  ## cond_uu : Condition number of J_uu
  ## Copyright (C) 1999, 2000 by Peter J. Gawthrop
  ## 	$Id$	

  ## Check some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  if (n_x==-1)
    return
  endif
  
  ## Default Q (output weight)
  if nargin<8
    Q = ones(n_y,1);
  endif

  ## Default R (input weight)
  if nargin<9
    R = zeros(n_u,1);
  endif

  ## Default P (terminal weight)
  if nargin<10
    P = zeros(n_x,n_x);
    P_weighting = 0;
  else
    P_weighting = 1;
  endif

  ## Default condittion number
  if nargin<11
    max_cond = 1e20;
  endif
  
  [n_U,m_U] = size(A_u);
  if (n_U != n_u*m_U)&&(n_U != m_U)
    error("A_u must be square or have N_u rows and N_u/n_u columns");
  endif

  if (n_U == m_U)		# U matrix square
    n_U = n_U*n_u;		# So same U* on each input
  endif

  
  [n_W,m_W] = size(A_w);
  if n_W>0
    if (n_W != n_y*m_W)&&(n_W != m_W)
      error("A_w must either be square or have N_w rows and N_w/n_y columns");
    endif
    square_W = (n_W== m_W);	# Flag indicates W is square
    if (n_W == m_W)		# W matrix square
      n_W = n_W*n_y;		# So same W* on each output
    endif
  endif
  

  [n_t,m_t] = size(tau);
  if n_t != 1
    error("tau must be a row vector");
  endif
  dt = tau(2) - tau(1);		# Sample interval

  [n_Q,m_Q] = size(Q);
  if ((m_Q != 1)&&(m_Q != m_t)) || (n_Q != n_y)
    error("Q must be a column vector with one row per system output");
  endif

  if (m_Q == 1)			# Convert to vector Q(i)
    Q = Q*ones(1,m_t);		# Extend to cover full range of tau
  endif
  
  ##Set up initial states
  u_0 = ones(m_U,1);
  w_0 = ones(m_W,1);

  ## Find y_U - derivative of y* wrt U.
  i_U = 0;
  x_0 = zeros(n_x,1);		# This is for x=0
  y_u = [];			# Initialise
  x_u_t = [];			# Initialise
  Us = [];			# Initialise
  for i=1:n_U			# Do for each input function U*_i
    dU = zeros(n_U,1);
    dU(++i_U) = 1;		# Create dU/dU_i 
    [ys,us,xs] = ppp_ystar (A,B,C,D,x_0,A_u,dU,tau); # Find ystar and ustar
    y_u = [y_u ys'];		# Save y_u (y for input u)  with one row for each t.
    Us = [Us us'];		# Save u (input)  with one row for each
				# t.
    x_u_t = [x_u_t xs(:,m_t)];	# x_u at terminal time
  endfor

  Ws = [];			# Initialise
  if n_W>0
    ## Find w*
    i_W = 0;
    x_0 = zeros(n_x,1);		# This is for x=0
    for i=1:n_W			# Do for each setpoint function W*i
      dW = zeros(n_W,1);
      dW(++i_W) = 1;		# Create dW/dW_i 
      [ys,ws] = ppp_ystar ([],[],[],[],[],A_w,dW,tau); # Find ystar and ustar
      Ws = [Ws ws'];		# Save u (input)  with one row for each t.
    endfor
  endif
  


  ## Find y_x - derivative of y* wrt x.
  y_x=[];
  for t_i=tau
    y = C*expm(A*t_i);
    yy = reshape(y,1,n_y*n_x);	# Reshape to a row vector
    y_x = [y_x; yy];
  endfor

  ## Compute the integrals to give cost function derivatives
  [n_yu m] = size(y_u');
  [n_yx m] = size(y_x');
  [n_yw m] = size(Ws');

  J_uu = zeros(n_U,n_U);
  J_ux = zeros(n_U,n_x);
  J_uw = zeros(n_U,n_W);
  J_xx = zeros(n_x,n_x);
  J_xw = zeros(n_x,n_W);
  J_ww = zeros(n_W,n_W);

  ## Add up cost derivatives for each output but weighted by Q.
  ## Scaled by time interval
  ## y_u,y_x and Ws should really be 3D matrices, but instead are stored
  ## with one row for each time and one vector (size n_y) column for
  ## each element of U

  ## Scale Q
  Q = Q*dt;			# Scale to give correct units
  ## Non-w bits
  for i = 1:n_y			# For each output
    QQ = ones(n_U,1)*Q(i,:);	# Resize Q
    J_uu = J_uu + (QQ .* y_u(:,i:n_y:n_yu)') * y_u(:,i:n_y:n_yu);
    J_ux = J_ux + (QQ .* y_u(:,i:n_y:n_yu)') * y_x(:,i:n_y:n_yx);
    QQ = ones(n_x,1)*Q(i,:);	# Resize Q
    J_xx = J_xx + (QQ .* y_x(:,i:n_y:n_yx)') * y_x(:,i:n_y:n_yx);
  endfor

  ## Input weighting (scalar for the moment)
  if (n_u>1)
    warning("Sorry, cant do n_u>1 just now: exiting");
    return
  endif

  ## Scale R
  R = R*dt;			# Scale to give correct units
  for i = 1:m_t
    Ust = Us(i,:);
    J_uu = J_uu + Ust'*R*Ust;
  endfor
  
  ## w bits
  if n_W>0
    for i = 1:n_y			# For each output
      QQ = ones(n_U,1)*Q(i,:);	# Resize Q
      J_uw = J_uw + (QQ .* y_u(:,i:n_y:n_yu)') * Ws (:,i:n_y:n_yw);
      QQ = ones(n_x,1)*Q(i,:);	# Resize Q
      J_xw = J_xw + (QQ .* y_x(:,i:n_y:n_yx)') * Ws (:,i:n_y:n_yw);
      QQ = ones(n_W,1)*Q(i,:);	# Resize Q
      J_ww = J_ww + (QQ .* Ws (:,i:n_y:n_yw)') * Ws (:,i:n_y:n_yw);
    endfor
  endif

  if P_weighting
    ## Terminal constraint 
    tau_last = tau(m_t);
    x_x_t = expm(A*tau_last);	# deriv. of x*(tau_2) wrt x(0)
    J_ux = J_ux + x_u_t'*P*x_x_t;
    J_uu = J_uu + x_u_t'*P*x_u_t;
    
    ## Terminal constraint - w bits
    ## NB SISO ONLY at the moment
    C = C(1,:);			# REMOVE ME
    
    ## deriv of x* wrt W
    if (cond(A)<1e10)		# Finite ss gain
      x_W_t =  (A\B)*inv(C*(A\B));
    else				# Infinite ss gain
      Y_0 = zeros(n_x,n_y); Y_0(1,:) = ones(1,n_y);
      x_W_t =  obsv(A,C)\Y_0;
    endif
    
    J_uw = J_uw + x_u_t'*P*x_W_t;
  endif
  
  ## Exit if badly conditioned
  cond_uu = cond(J_uu);
  if cond_uu>max_cond
    error(sprintf("J_uu is badly conditioned. Condition number = \
	10^%i",log10(cond_uu)));
  endif

  ## Compute the open-loop gains
  K_w = J_uu\J_uw;
  K_x = J_uu\J_ux;

  ## U*(tau) at tau=0 
  Us0 = ppp_ustar(A_u,n_u,0);		
  
  ## Compute the closed-loop gains
  k_x = Us0*K_x;
  k_w = Us0*K_w;

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_lin_con_sol.m version [3f791341cb].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
function U = ppp_lin_con_sol (x,w,J_uu,J_ux,J_uw)

  ## usage:  U = ppp_lin_con_sol (x,w,J_uu,J_ux,J_uw)
  ##
  ## 

  ## Pass info to the solnp algorithm
  global ppp_J_uu, ppp_J_ux, ppp_J_uw

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_lin_obs.m version [3637bc55b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [l_x,l_y,L_x,L_y,J_uu,J_ux,J_uw,Us0] = ppp_lin_obs (A,B,C,D,A_u,A_y,t,Q)

  ## usage:  [l_x,l_y,L_x,L_y,J_uu,J_ux,J_uw,Us0] = ppp_lin_obs  (A,B,C,D,A_u,A_y,t,Q)
  ##
  ## Linear PPP (Predictive pole-placement) computation 
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## A_y: composite system matrix for W* generation 
  ##      one square matrix (A_yi) row for each system output
  ##      each A_yi generates W*' for ith system output.
  ## t: row vector of times for optimisation (equispaced in time)
  ## Q column vector of output weights (defaults to unity)

  ## OUTPUTS:
  ## l_x: State feedback gain
  ## l_y: setpoint gain
  ## ie u(t) = l_y w(t) - l_x x(t)
  ## L_x, L_y: open loop gains
  ## J_uu, J_ux, J_uw: cost derivatives
  ## Us0: Value of U* at tau=0

  ## Check some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  if (n_x==-1)
    return
  endif

  ## Default Q
  if nargin<8
    Q = ones(n_y,1);
  endif
  

#   B_x = eye(n_x);		# Pseudo B
#   D_x = zeros(n_y,n_x);		# Pseudo D
  [l_x,l_y,L_x,L_y,J_uu,J_ux,J_uw,Us0] = ppp_lin(A',C',B',D',A_u',A_y',t,Q);
  
  l_x = l_x';
  l_y = l_y';
  L_x = L_x';
  L_y = L_y';
endfunction









Deleted mttroot/mtt/lib/control/PPP/ppp_lin_plot.m version [460292101c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90


























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] =  ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0)

  ## usage:   [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w,cond_uu] = ppp_lin_plot (A,B,C,D,A_u,A_w,t,Q,W,x_0)
  ##
  ## Linear PPP (Predictive pole-placement) computation with plotting
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## A_w: composite system matrix for W* generation 
  ##      one square matrix (A_wi) row for each system output
  ##      each A_wi generates W*' for ith system output.
  ## t: row vector of times for optimisation (equispaced in time)
  ## Q: column vector of output weights (defaults to unity)
  ## W: Constant setpoint vector (one element per output)
  ## x_0: Initial state
  ## OUTPUTS:
  ## Various poles 'n zeros
  ## k_x: State feedback gain
  ## k_w: setpoint gain
  ## ie u(t) = k_w w(t) - k_x x(t)
  ## K_x, K_w: open loop gains
  ## J_uu, J_ux, J_uw: cost derivatives

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  ## Some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  [n_U,m_U]=size(A_u);
  square = (n_U==m_U);		# Its a square matrix so same U* on each input
  [n_W,m_W]=size(A_w);
  if n_W==m_W			# A_w square
    n_W = n_W*n_y;		# Total W functions
  endif
  

  [n_t,m_t] = size(t);

  ## Default Q
  if nargin<8
    Q = ones(n_y,1)
  endif

  ## Default W
  if nargin<9
    W = ones(n_W,1)
  endif

  ## Default x_0
  if nargin<10
    x_0 = zeros(n_x,1);
  endif

  ## Check some dimensions
  [n_Q,m_Q] = size(Q);
  if ((m_Q != 1)&&(m_Q != m_t)) || (n_Q != n_y)
    error("Q must be a column vector with one row per system output");
  endif

  [n,m] = size(W);
  if ((m != 1) || (n != n_W))
    error("W must be a column vector with one element per system output");
  endif

  [n,m] = size(x_0);
  if ((m != 1) || (n != n_x))
    error("x_0 must be a column vector with one element per system state");
  endif

  ## Simulate
  [y,ystar,t,k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu]\
      =  ppp_lin_sim(A,B,C,D,A_u,A_w,t,Q,W,x_0);

  ## Plot
  xlabel("Time"); title("y* and y"); grid;
  plot(t,ystar,t,y);

  ## Compute some pole/zero info
  cl_poles = eig(A-B*k_x)';
  ol_poles = eig(A)';

  if nargout>3
    ol_zeros = tzero(A,B,C,D)';
    cl_zeros = tzero(A-B*k_x,B,C,D)';
  endif

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_lin_quad.m version [56182147a4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] = \
      ppp_lin_quad (A,B,C,D,tau,Q,R,A_e)

  ## usage:[k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] =
  ## ppp_lin_quad (A,B,C,D,tau,Q,R[,A_e])
  ##
  ## 

  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)

  if nargin<8
    A_e = [];
  endif
  
  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R);

  A_u = ppp_aug(A_u,A_e);

  ## PPP solution
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] = \
      ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P);


endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_lin_run.m version [10c572cbb5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382






























































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [t,y,u,X_est,y_c,t_e,y_e,e_e,p_c,p_o] = ppp_lin_run (Name,Simulate,ControlType,w,x_0,p_c,p_o)

  ## usage: [t,y,u,y_c,t_e,y_e,e_e,p_c,p_o] = ppp_lin_run (Name,Simulate,ControlType,w,x_0,p_c,p_o)
  ##
  ## 
  ## Linear closed-loop PPP of lego system (and simulation)
  ##
  ## Name: Name of system (in mtt terms)
  ## Simulate = 0: real thing
  ## Simulate = 1: simulate
  ## Control = 0:  step test
  ## Control = 1:  PPP open-loop
  ## Control = 2:  PPP closed-loop
  ## w is the (constant) setpoint
  ## par_control and par_observer are structures containing parameters
  ## for the observer and controller

  ##Defaults
  if nargin<1			# Default name to dir name
    names = split(pwd,"/");
    [n_name,m_name] = size(names);
    Name = deblank(names(n_name,:));
  endif

  if nargin<6
    p_c.N = 50;
  endif

  if nargin<7
    p_o.sigma = 1e-1;
  endif

  ## System
  sys = mtt2sys(Name);		# Create system
  [A,B,C_0,D_0] = sys2ss(sys);	# SS form
  [n_x, n_u, n_y] = abcddim(A,B,C_0,D_0);

  ## Extract matrices for controlled and constrained outputs.
  if !struct_contains(p_c,"I_0") # Indices for controlled outputs
    p_c.I_0 = 1:n_y
  endif
  if !struct_contains(p_c,"I_1") # Indices for constrained outputs
    p_c.I_1 = 1:n_y
  endif

  C = C_0(p_c.I_0,:)
  C_c = C_0(p_c.I_1,:);
  D = D_0(p_c.I_0,:);
  D_c = D_0(p_c.I_1,:);
  [n_x, n_u, n_y] = abcddim(A,B,C,D); # Dimensions
  [n_x, n_u, n_y_c] = abcddim(A,B,C_c,D_c); # Dimensions


  if nargin<2
    Simulate = 1;
  endif
  
  if nargin<3
    ControlType = 2;
  endif
  
  if nargin<4
    w = ones(n_y,1);;
  endif
  
  if nargin<5
    x_0 = zeros(n_x,1);
  endif
  
  if !struct_contains(p_c,"delta_ol")
    p_c.delta_ol = 0.5;	# OL sample interval
  endif
  
  if !struct_contains(p_c,"T")
    p_c.T = 10;			# Last time point.
  endif

  if !struct_contains(p_c,"Iterations")
    p_c.Iterations = 5;		# Number of interations, total =T*Iterations
  endif

  if !struct_contains(p_c,"augment")
    p_c.augment = 0;		# Augment basis funs with constant
  endif
  
  if !struct_contains(p_c,"integrate")
    p_c.integrate = 0;		
  endif
  
  if !struct_contains(p_c,"Tau_u")
    p_c.Tau_u = [];
    p_c.Min_u = [];
    p_c.Max_u = [];
  endif

  if !struct_contains(p_c,"Tau_y")
    p_c.Tau_y = [];
    p_c.Min_y = [];
    p_c.Max_y = [];
  endif


  if !struct_contains(p_c,"Method")
    p_c.Method = "lq";
  endif

  if struct_contains(p_c,"Method")
    if strcmp(p_c.Method,"lq")
      p_c.Q = eye(n_y);
      p_c.n_U = n_x;
      if !struct_contains(p_c,"R")
	p_c.R = (0.1^2)*eye(n_u);
      endif
    elseif strcmp(p_c.Method,"original");
      if !struct_contains(p_c,"A_w")
	p_c.A_w = 0;
      endif
      if !struct_contains(p_c,"A_u")
	p_c.n_U = n_x;
	a_u = 2.0;
	p_c.A_u = laguerre_matrix(p_c.n_U,a_u);
	if p_c.augment		# Put in constant term
	  p_c.A_u = ppp_aug(0,p_c.A_u);
	endif
      endif
    else
      error(sprintf("Method %s not recognised", p_c.Method));
    endif
  endif

  if !struct_contains(p_c,"tau") # Time horizon
    if strcmp(p_c.Method,"lq")
      p_c.tau = [0:0.1:1]*2;
    elseif strcmp(p_c.Method,"original");
      p_c.tau = [10:0.1:11];
    else
      error(sprintf("Method %s not recognised", p_c.Method));
    endif
  endif
  
  if !struct_contains(p_c,"A_e")
    p_c.A_e = [];			# No extra modes
  endif

  if !struct_contains(p_o,"x_0")
    p_o.x_0 = zeros(n_x,1);
  endif
  
  if !struct_contains(p_o,"method")
    ##p_o.method = "continuous";
    ##p_o.method = "intermittent";
    p_o.method = "remote";
  endif
  
  ## Check w.
  [n_w,m_w] = size(w);
  if ( (n_w!=n_y) || (m_w!=1) )
    error(sprintf("ppp_lin_run: w must a column vector with %i elements",n_y));
  endif
  
  ## Initialise
  x_est = p_o.x_0;

  ## Initialise simulation state
  x = x_0;
  y_i = C*x_0

  if ControlType==0		# Step input
    I = 1;			# 1 large sample
    p_c.delta_ol = p_c.T;	# I
    K_w = zeros(p_c.n_U,n_y);
    K_w(1,1) = 1;
    K_w(2,1) = -1;
    K_x = zeros(p_c.n_U,n_x);
  else
    I = ceil(p_c.T/p_c.delta_ol) # Number of large samples
    if strcmp(p_c.Method, "original")
      [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] =\
	  ppp_lin(A,B,C,D,p_c.A_u,p_c.A_w,p_c.tau); # Design
    elseif strcmp(p_c.Method, "lq") # LQ design
      [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] \
	  = ppp_lin_quad (A,B,C,D,p_c.tau,p_c.Q,p_c.R,p_c.A_e);
      p_c.A_u = A_u;
    else
      error(sprintf("Control method %s not recognised", p_c.Method));
    endif

    ##Sanity check A_u
    [p_c.n_U,M_u] = size(p_c.A_u);
    if (p_c.n_U!=M_u)
      error("A_u must be square");
    endif

    ## Checks
    cl_poles = eig(A - B*k_x)
    ol_poles = eig(A)
    t_max = 1/min(abs(cl_poles));
    t_min = 1/max(abs(cl_poles));
  endif
  
  ## Initial control U
  U = zeros(p_c.n_U,1)	;

  ## Short sample interval
  dt = p_c.delta_ol/p_c.N;

  ## Observer design
  G = eye(n_x);		# State noise gain 
  sigma_x = eye(n_x);		# State noise variance
  Sigma = p_o.sigma*eye(n_y)	# Measurement noise variance
  
  if strcmp(p_o.method, "intermittent")
    Ad = expm(A*p_c.delta_ol);		# Discrete-time transition matrix
    if (ControlType==2)		# 
      [L, M, P, obs_poles] = dlqe(Ad,G,C,sigma_x,Sigma);
    else
      L = zeros(n_x,n_y);
      obs_poles = eig(Ad);
    endif
  elseif strcmp(p_o.method, "continuous")
    Ad = expm(A*dt);		# Discrete-time transition matrix
    A_ud = expm(p_c.A_u*dt);	# Discrete-time input transition
    if (ControlType==2)		# 
      [L, M, P, obs_poles] = dlqe(Ad,G,C,sigma_x,Sigma);
    else
      L = zeros(n_x,n_y);
      obs_poles = eig(Ad);
    endif
  elseif strcmp(p_o.method, "remote")
    L = zeros(n_x,n_y);
    obs_poles = [];
  else
    error(sprintf("Observer method ""%s"" unknown", p_o.method));
  endif
  
  ## Display the poles
  obs_poles

  ## Write the include file for the real-time function
  ## Use double length to allow for overuns
  overrun = 2;
  Ustar = ppp_ustar (p_c.A_u, n_u, [0:dt:overrun*p_c.delta_ol], 0,0);
  if p_c.integrate		# Integrate Ustar
    disp("Integrating Ustar");
    Ustar = cumsum(Ustar)*dt;
  endif
  
  disp("Writing Ustar.h ...");
  ppp_ustar2h(Ustar); 
  disp("done.");


  ## Control loop
  y = [];
  y_c = [];
  u = [];
  t = [];
  y_e = [];
  X_est = [];
  t_e = [];
  e_e = [];
  tick = time;
  i=0;

  for j=1:p_c.Iterations
    for k=1:I
      tim=time;			# Timing
      i++;

      if Simulate		# Exact simulation 
	X = x;			# Current (simulated) state
      else			# The real thing
	if strcmp(p_o.method, "remote")
	  [t_i,y_i,u_i,X] = ppp_put_get_X(U); # Remote-state interface
	else
	  [t_i,y_i,u_i] = ppp_put_get(U); # Generic interface to real-time
	endif
      endif
      
      ## Observer
      if strcmp(p_o.method, "intermittent")
	[x_est y_est y_new, e_est] = ppp_int_obs \
	    (x_est,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,L);
      elseif strcmp(p_o.method, "continuous")
	Ui = U;			# U at sub intervals
	for k = 1:p_c.N
	  [x_est y_est y_new e_est] = ppp_int_obs \
	      (x_est,yi(:,k),Ui,A,B,C,D,p_c.A_u,dt,L);
	  Ui = A_ud'*Ui;
	  y_e = [y_e; y_new'];
	  e_e = [e_e; e_est'];
	endfor
      elseif strcmp(p_o.method, "remote")
	## predict from remote state (with zero L)	
	if (ControlType==2)	# Closed-loop
    	  [x_est y_est y_new e_est] = ppp_int_obs \
    	      (X,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,zeros(n_x,1));
	##  x_est = X; y_est=y_i; y_new=y_i; e_est=0;
	else			# Open-loop
	  [x_est y_est y_new e_est] = ppp_int_obs \
	      (x_est,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,zeros(n_x,1));
	endif
      endif
      
      ## Simulation (based on U_i)
      if Simulate
	t_sim = [1:p_c.N]*dt;	# Simulation time points
	[yi,ui,xsi] = ppp_ystar(A,B,C,D,x,p_c.A_u,U,t_sim); # Simulate
	x = xsi(:,p_c.N);	# NEXT state
	ti  = [(i-1)*p_c.N:i*p_c.N-1]*dt; 
	y_i = yi(1);	# Current output
	t_i = ti(1);
      endif

      ##Control
      if ( length(p_c.Tau_u)==0&&length(p_c.Tau_y)==0 )
	U = K_w*w - K_x*x_est;
      else
	## Input constraints 
	[Gamma_u, gamma_u] = \
	    ppp_input_constraints(p_c.A_u,p_c.Tau_u,p_c.Min_u,p_c.Max_u);
	
	## Output constraints
	[Gamma_y,gamma_y] = \
	    ppp_output_constraints(A,B,C_c,D_c,x_est,p_c.A_u,\
				   p_c.Tau_y,p_c.Min_y,p_c.Max_y);
	
	## Composite constraints - t=0
	Gamma = [Gamma_u; Gamma_y];
	gamma = [gamma_u; gamma_y];
	
	[u_qp,U,n_active] = ppp_qp \
	    (x_est,w,J_uu,J_ux,J_uw,Us0,Gamma,gamma,1e-6,1);
      endif

      ## Allow for the delay
      ##U = expm(p_c.delta_ol*p_c.A_u)*U;

      ## Save data
      if Simulate
	t = [t;ti'];
	y = [y;yi'];
	X_est = [X_est;x_est'];
	y_c = [y_c;(C_c*xsi)'];
	u = [u;ui'];
      else
	t = [t;t_i];
	y = [y;y_i'];
	X_est = [X_est;x_est'];
	u = [u;u_i'];
      endif

      if strcmp(p_o.method, "intermittent")||strcmp(p_o.method, "remote")
	y_e = [y_e; y_new'];
	e_e = [e_e; e_est'];
	t_e = [t_e; t_i];
      endif
      if !Simulate
	delta_comp = time-tim;
	usleep(floor(1e6*(p_c.delta_ol-delta_comp-0.01)));
      endif
      
    endfor			# Main loop
    w = -w;
  endfor 			# Outer loop
  if !Simulate
    ppp_put_get(0*U); 		# Reset to zero
  endif

  
  if strcmp(p_o.method, "continuous")
    t_e = t;
  endif
  
  
  average_ol_sample_interval = (time-tick)/i

  ## Put data on file (so can use for identification)
  filename = sprintf("%s_ident_data.dat",Name);
  eval(sprintf("save -ascii %s t y u",filename));

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_lin_sim.m version [767b01c78f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y,ystar,t,k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] =  ppp_lin_sim(A,B,C,D,A_u,A_w,tau,Q,W,x_0)

  ## usage:   [ol_poles,cl_poles,ol_zeros,cl_zeros,k_x,k_w,K_x,K_w] = ppp_lin_plot (A,B,C,D,A_u,A_w,tau,Q,W,x_0)
  ##
  ## Linear PPP (Predictive pole-placement) computation with plotting
  ## INPUTS:
  ## A,B,C,D: system matrices
  ## A_u: composite system matrix for U* generation 
  ##      one square matrix (A_ui) row for each system input
  ##      each A_ui generates U*' for ith system input.
  ## A_w: composite system matrix for W* generation 
  ##      one square matrix (A_wi) row for each system output
  ##      each A_wi generates W*' for ith system output.
  ## tau: row vector of times for optimisation (equispaced in time)
  ## Q: column vector of output weights (defaults to unity)
  ## W: Constant setpoint vector (one element per output)
  ## x_0: Initial state
  ## OUTPUTS:
  ## y : closed-loop output
  ## ystar : open-loop moving-horizon output
  ## t : time axis

  ## Copyright (C) 2001 by Peter J. Gawthrop
  ## 	$id: ppp_lin_plot.m,v 1.13 2001/01/26 16:03:13 peterg Exp $	

  ## Some dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  [n_U,m_U]=size(A_u);
  square = (n_U==m_U);		# Its a square matrix so same U* on each input
  [n_W,m_W]=size(A_w);
  if n_W==m_W			# A_w square
    n_W = n_W*n_y;		# Total W functions
  endif
  

  [n_tau,m_tau] = size(tau);

  ## Default Q
  if nargin<8
    Q = ones(n_y,1);
  endif

  ## Default W
  if nargin<9
    W = ones(n_W,1)
  endif

  ## Default x_0
  if nargin<10
    x_0 = zeros(n_x,1);
  endif

  ## Check some dimensions
  [n_Q,m_Q] = size(Q);
  if ((m_Q != 1)&&(m_Q != m_tau)) || (n_Q != n_y)
    error("Q must be a column vector with one row per system output");
  endif

  [n,m] = size(W);
  if ((m != 1) || (n != n_W))
    error("W must be a column vector with one element per system output");
  endif

  [n,m] = size(x_0);
  if ((m != 1) || (n != n_x))
    error("x_0 must be a column vector with one element per system state");
  endif

  ## Control design
  disp("Designing controller");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,y_u,cond_uu] = ppp_lin  (A,B,C,D,A_u,A_w,tau,Q);

  ## Set up simulation times
  dtau = tau(2) -tau(1);		# Time increment
  t =  0:dtau:tau(length(tau));	# Time starting at zero

  ## Compute the OL step response
  disp("Computing OL response");
  U = K_w*W - K_x*x_0;
  ystar = ppp_ystar (A,B,C,D,x_0,A_u,U,t);

  ## Compute the CL step response
  disp("Computing CL response");
  y = ppp_sm2sr(A-B*k_x, B, C, D, t, k_w*W, x_0); # Compute Closed-loop control


endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_nlin.m version [d0ab21bae9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [U, U_all, Error, Y, its] = ppp_nlin(system_name,x_0,par_0,sim,us,w,free, Q, extras)

  ## usage:  [U, U_all, Error, Y,its ] = ppp_nlin(system_name,x_0,par_0,sim,us,w,free, Q, extras)
  ##
  ## 
  
  if nargin<9
    extras.criterion = 1e-8;
    extras.max_iterations = 10;
    extras.v = 0.1;
    extras.verbose = 1;
  endif
  
  s_system_name = sprintf("s%s", system_name); # Name of sensitivity system
  
  ## Details
  [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name));
  [n_tau,n_us] = size(us);
  
  if nargin<8
    Q = ones(n_y,1);
  endif
 
  ## Checks
  if (n_us<>n_u)
    error(sprintf("Inputs (%i)  differenct to system inputs (%i)", n_us, n_u));
  endif
    
  ##Optimise
  [par,Par,Error,Y,its] = ppp_optimise(s_system_name,x_0,par_0,sim,us,w,free,Q,extras);
  
  U = par(free(:,1));
  U_all = Par(free(:,1),:);
endfunction



Deleted mttroot/mtt/lib/control/PPP/ppp_nlin_run.m version [76fba90674].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y,u,t,p,UU,t_open,t_ppp,t_est,its_ppp,its_est] = ppp_nlin_run(system_name,i_ppp,i_par,A_u,w_s,N_ol,Q,extras)


  ## usage: [y,u,t,p,U,t_open,t_ppp,t_est,its_ppp,its_est] =
  ## ppp_nlin_run (system_name,i_ppp,i_par,A_u,w_s,N_ol[,extras])
  ##
  ##  y,u,t   System output, input and corresponding time p
  ##  Estimated parameters U       PPP weight vector t_open  The
  ##  open-loop interval t_ppp   Time for each ppp optimisation t_est
  ##  Time for each estimation i_ppp   Matrix of ppp gain indices: col.
  ##  1 Gain indices in sensitivity system col. 2  Gain sensitivity
  ##  indices in sensitivity system col. 3  Gain indices in  system
  ##  i_par Matrix of indices of estimated parameters col. 1  Parameter
  ##  indices in sensitivity system col. 2  Parameter sensitivity
  ##  indices in sensitivity system col. 3  Parameter indices in  system
  ##  A_u     Basis function generating matrix w_s     w_star: That part
  ##  of the moving horizon setpoint within the optimisation horizon.
  ##  N_ol The number of open-loop intervals to be computed extras
  ##  Extra parameters in  a structure: extras.alpha           ??
  ##  extras.criterion Optimisation convergence criterion
  ##  extras.emulate_timing Simulate some real-time features
  ##  extras.estimate Estimate parameters and states
  ##  extras.max_iterations Maximum optimisation iterations
  ##  extras.simulate 1 for simulation (not real-time) extras.vInitial Levenberg-Marquardt parameter
  ##          extras.verbose         1 for extra info display
  ##
  ## Real-time implementatipn of  nonlinear PPP Copyright (C) 2001,2002
  ## by Peter J. Gawthrop

  ## Globals to pass details to simulation
  global system_name_sim i_ppp_sim x_0_sim y_sim u_sim A_u_sim simpar_sim

  ## Defaults
  if nargin<8
    extras.alpha = 0.1;
    extras.criterion = 1e-5;
    extras.emulate_timing = 0;
    extras.max_iterations = 10;
    extras.simulate = 1;
    extras.v = 1e-5;
    extras.verbose = 0;
    extras.visual = 0;
  endif

  ##Estimate if we have some adjustable parameters
  estimating_parameters = (length(i_par)>0);
  
  ## Names
  s_system_name = sprintf("s%s", system_name);

  ## System details -- defines simulation within ol interval
  par = eval(sprintf("%s_numpar;", system_name));
  simpar = eval(sprintf("%s_simpar;", system_name));
  dt = simpar.dt;		# Sample interval
  simpar_est = simpar;		# Initial estimation simulation params
  simpar_model = simpar;	# Initial internal model simulation params
  simpar_pred = simpar;		# Initial prediction simulation params
  T_ol_0 = simpar.last;		# The initial specified interval
  n_t = round(simpar.last/simpar.dt); # Corresponding length
  x_0 = eval(sprintf("%s_state(par);", system_name));
  x_0_model = x_0;
  [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name));
  [n_par,m_par] = size(i_par);
  if nargin<8
    Q = ones(n_y,1);
  endif
 
  ## Sensitivity system details -- defines moving horizon simulation
  simpars = eval(sprintf("%s_simpar;", s_system_name));
  pars = eval(sprintf("%s_numpar;", s_system_name));
  x_0s = eval(sprintf("%s_state(pars);", s_system_name));
  x_0_models = x_0s;

  p = []; # Initialise saved parameters

  ## Times
  ## -- within opt horizon
  n_Tau = round(simpars.last/simpars.dt);
  dtau = simpars.dt;
  Tau = [0:n_Tau-1]'*dtau;
  [n_tau,n_w] = size(w_s);
  tau = Tau(n_Tau-n_tau+1:n_Tau);
  w = w_s(n_tau,:);		# Final value of setpoint


  ## Main simulation loop
  y = [];
  x = [];
  u = [];
  t = [];


  t_last = 0;
  UU_l =[];
  UU_c =[];
  
  t_ppp = [];
  t_est = [];
  its_ppp = [];
  its_est = [];
  t_open = [];
  x_nexts = zeros(2*n_x,1);

  ## Initial U is zero
  [n_U,junk] = size(A_u);
  U = zeros(n_U,1);

  ## Initialise saved U
  UU = [];

  ## Create input basis functions
  u_star_tau = ppp_ustar(A_u,1,Tau',0,0,n_u-n_U);
	
  ## Reverse time to get "previous" U
  U_old = U;

  if (extras.simulate==1)
    ## Set up globals for simulation
    system_name_sim = system_name;
    i_ppp_sim = i_ppp;
    x_0_sim = x_0;
    y_sim = [];			# Junk
    u_sim = [];			# Junk
    A_u_sim = A_u;
    simpar_sim = simpar;
    T_total = simpar.last;
  endif
  
  for i = 0:N_ol		# Main loop 
    printf("%i",i);
    UU = [UU; U'];		# Save control U
    
    if n_par>0
      par_est = pars(i_par(:,1));
      p = [p; par_est'];		# Save up the estimated parameters
    endif
    

    if (extras.simulate==1)
      [y_ol,u_ol] = ppp_RT_sim(U); # Simulate
    else
      [y_ol,u_ol] = ppp_RT(U);	# Real thing
    endif

    t_start = time;		# Initialise time

    if (i==0)			# Data is rubbish at i=0 - ignore
      usleep(T_ol_0*1e6);		# Hang about
    else
      ## Set up time information for the gathered data
      n_ol = length(y_ol);	# How many data points?
      t_ol = [0:n_ol-1]'*dt;
      T_ol = n_ol*dt;		# Length of ol interval
      t_open = [t_open;T_ol];

      ## Generate input to actual system
      u_star_t = ppp_ustar(A_u,1,t_ol',0,0,n_u-n_U);

      ## Tune parameters/states
      if (estimating_parameters==1)

	## Set up according to interval length
	if (T_ol>T_ol_0) ## Truncate data
	  simpar_est.last = T_ol_0;
	  y_est = y_ol(1:n_t+1,:);
	else
	  simpar_est.last = T_ol;
	  y_est = y_ol;
	endif

	simpar_pred.last = T_ol_0; # Predicted length of next interval
	pars(i_ppp(:,1)) = U_old; # Update the simulation ppp weights
	
	## Optimise
	tick = time;
	[pars,Par,Error,Y,its] = \
	    ppp_optimise(s_system_name,x_0_models,pars,simpar_est,u_star_t,y_est,i_par,Q,extras);
	
	if extras.visual
	  figure(11);
	  title("Parameter optimisation"); 
	  II = [1:length(y_est)]; plot(II,y_est,"*", II,Y);
	endif
	
	est_time = time-tick;  
	t_est = [t_est;est_time];
	its_est = [its_est; its-1];
      endif

      ## Update internal model
      par(i_ppp(:,3)) = U_old; # Update the internal model ppp weights

      if (estimating_parameters==1)
	par(i_par(:,3)) = pars(i_par(:,1)); # Update the internal model params
      endif

      simpar_model.last = T_ol;
      [y_model,x_model] = eval(sprintf("%s_sim(x_0_model, par, simpar_model, \
 					       u_star_t);",system_name));

      x_0 = x_model(n_ol+1,:)';	# Initial state of next interval
##      x_0 = x_model(n_ol-1,:)';	# Initial state of next interval
      x_0_model = x_0;
      x_0_models(1:2:(2*n_x)-1) = x_0_model;

      ## Compute U by optimisation
      tick = time;

      ## Predict state at start of next interval
      par(i_ppp(:,3)) = U;
      [y_next,x_next] = eval(sprintf("%s_sim(x_0, par, simpar, \
					     u_star_t);",system_name));
      x_next = x_next(n_t+1,:)'; # Initial state for next time
      x_nexts(1:2:(2*n_x)-1) = x_next; # And for internal sensitivity model
      
      ## Optimize for next interval      
      U_old = U;		# Save previous value
      U = expm(A_u*T_ol)*U;	# Initialise from continuation trajectory
      pars(i_ppp(:,1)) = U;	# Put initial value of U into the parameter vector
      [U, U_all, Error, Y, its] = ppp_nlin(system_name,x_nexts,pars,simpars,u_star_tau,w_s,i_ppp,Q,extras);
      if extras.visual
	figure(12);
	title("PPP optimisation");
	II = [1:length(w_s)]; plot(II,w_s,"*", II,Y);
	figure(1);
	endif

      ppp_time = time-tick;  
      t_ppp = [t_ppp;ppp_time];
      its_ppp = [its_ppp; its-1];

      ## Total execution time
      T_total = time - t_start;
      if (extras.simulate==1)&&(extras.emulate_timing!=1)
	printf(".");
	T_diff = 0;		# Always correct interval
      else
	T_diff = T_total - T_ol_0; # Compute difference
	if T_diff<0
	  printf("-");
	  usleep(-T_diff*1e6);
	  T_total = time - t_start;
	else
	  printf("+");
	endif   
				printf("%2.2f",T_total);
      endif
      T_total = simpar.dt*round(T_total/simpar.dt); # Whole no. of intervals

      pars(i_ppp(:,1)) = U;	# Put final value of U into the parameter vector

      ## Save up data
      y_ol = y_ol(1:n_ol,:);
      y = [y; y_ol];
      u = [u; u_ol];
      t = [t; t_ol+t_last*ones(n_ol,1) ];
      t_last = t_last + T_ol;

    endif


    if (extras.simulate==1) # Do the actual simulation
      if (extras.emulate_timing==1) # Emulate timing
	simpar_sim.last = T_total; # simulate for actual execution time
      endif
      ppp_RT_sim_compute (U_old);
    endif
    
  endfor
  printf("\n");
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_nlin_sim.m version [26d1c64307].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198






































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y,x,u,t,p,UU,UU_c,UU_l,t_ppp,t_est] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras)

  ## usage: [y,x,u,t,p,UU,UU_c,UU_l,t_ppp,t_est] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N_ol,extras) 
  ##
  ## 
  
  ## Simulate nonlinear PPP
  ## Copyright (C) 2000 by Peter J. Gawthrop

  ## Defaults
  if nargin<7
    extras.U_initial = "zero";
    extras.U_next = "continuation";
    extras.criterion = 1e-5;
    extras.max_iterations = 10;
    extras.v = 0.1;
    extras.verbose = 0;
    extras.estimate = 1;
  endif
  
  

  ## Names
  s_system_name = sprintf("s%s", system_name);

  ## System details -- defines simulation within ol interval
  par = eval(sprintf("%s_numpar;", system_name));
  simpar = eval(sprintf("%s_simpar;", system_name));
  x_0 = eval(sprintf("%s_state(par);", system_name));
  [n_x,n_y,n_u] = eval(sprintf("%s_def;", system_name));

  ## Sensitivity system details -- defines moving horizon simulation
  simpars = eval(sprintf("%s_simpar;", s_system_name));
  pars = eval(sprintf("%s_numpar;", s_system_name));

  ## Times
  ## -- within opt horizon
  n_Tau = round(simpars.last/simpars.dt);
  dtau = simpars.dt;
  Tau = [0:n_Tau-1]'*dtau;
  [n_tau,n_w] = size(w_s);
  tau = Tau(n_Tau-n_tau+1:n_Tau);
  w = w_s(length(w_s));		# Final value of setpoint

  ## -- within ol interval
  n_t = round(simpar.last/simpar.dt);
  dt = simpar.dt;
  t_ol = [0:n_t-1]'*dt;
  T_ol = n_t*dt;

  ## Create input basis functions
  [n_U,junk] = size(A_u);

  ## For moving horizon
  eA = expm(A_u*dtau);
  u_star_i = ones(n_U,1);
  u_star_tau = [];
  for i = 1:n_Tau
    u_star_tau = [u_star_tau; u_star_i'];
    u_star_i = eA*u_star_i;
  endfor

  ## and for actual implementation
  eA = expm(A_u*dt);
  u_star_i = ones(n_U,1);
  u_star_t = [];
  for i = 1:n_t
    u_star_t = [u_star_t; u_star_i'];
    u_star_i = eA*u_star_i;
  endfor
  
  if extras.verbose
    title("U*(tau)")
    xlabel("tau");
    plot(Tau,u_star_tau)
    title("U*(t)")
    xlabel("t_ol");
    plot(t_ol,u_star_t)
  endif
  

  ## Check number of inputs adjust if necessary
  if n_u>n_U
    disp(sprintf("Augmenting inputs with %i zeros", n_u-n_U));
    u_star_tau = [u_star_tau; zeros(n_u-n_U, n_Tau)];
    u_star_t   = [u_star_t; zeros(n_u-n_U, n_t)];
  endif
  
  if n_u<n_U
    error(sprintf("n_U (%i) must be less than or equal to n_u (%i)", \
		  n_U, n_u));
  endif
  
  ## Compute linear gains 
  [A,B,C,D] = eval(sprintf("%s_sm(par);", system_name));
  B = B(:,1); D = D(:,1);
  [k_x,k_w,K_x,K_w] = ppp_lin(A,B,C,D,A_u,0,tau');

  ## Main simulation loop
  y = [];
  x = [];
  u = [];
  t = [];

  p = [];

  t_last = 0;
  UU = [];
  UU_l =[];
  UU_c =[];
  
  t_ppp = [];
  t_est = [];

  x_0s = zeros(2*n_x,1);

  if  strcmp(extras.U_initial,"linear")
    U = K_w*w - K_x*x_0;
  elseif strcmp(extras.U_initial,"zero")
    U = zeros(n_U,1);
  else
    error(sprintf("extras.U_initial = \"%s\" is invalid", extras.U_initial));
  endif

  ## Reverse time to get "previous" U
  U = expm(-A_u*T_ol)*U;

  for i = 1:N_ol		# Main loop 
    ## Compute initial U from linear case
    U_l = K_w*w - K_x*x_0;

    ## Compute initial U  for next time from continuation trajectory
    U_c = expm(A_u*T_ol)*U;

    ## Create sensitivity system state
    x_0s(1:2:2*n_x) = x_0;
    
    ## Set next U (initial value for optimisation)
    if  strcmp(extras.U_next,"linear")
      U = U_l;
    elseif strcmp(extras.U_next,"continuation")
      U = U_c;
    elseif strcmp(extras.U_next,"zero")
      U = zeros(n_U,1);
    else
      error(sprintf("extras.U_next = \"%s\" is invalid", extras.U_next));
    endif
    pars(i_ppp(:,1)) = U;	# Put initial value of U into the parameter vector

    ## Compute U by optimisation
    tick = time;
    if extras.max_iterations>0
      [U, U_all, Error, Y] = ppp_nlin(system_name,x_0s,pars,simpars,u_star_tau,w_s,i_ppp,extras);
      pars(i_ppp(:,1)) = U;	# Put final value of U into the parameter vector
    else
      Error = [];
    endif
    ppp_time = time-tick;  
    t_ppp = [t_ppp;ppp_time];
    
    ## Generate control
    u_ol = u_star_t*U;		# Not used - just for show

    ## Simulate system over one ol interval
    par(i_ppp(:,3)) = pars(i_ppp(:,1)); # Update the simulation ppp weights
    [y_ol,x_ol] = eval(sprintf("%s_sim(x_0, par, simpar, u_star_t);", system_name));


    ## Tune parameters/states
    if (extras.estimate==1)
      tick = time;
      par_est = pars(i_par(:,1));
      p = [p; par_est'];
      pars = ppp_optimise(s_system_name,x_0s,pars,simpar,u_star_t,y_ol,i_par,extras);
      est_time = time-tick;  
      t_est = [t_est;est_time];
    endif

    x_0  = x_ol(n_t+1,:)';	# Extract state for next time
    y_ol = y_ol(1:n_t,:);	# Avoid extra points due to rounding error 
    x_ol = x_ol(1:n_t,:);	# Avoid extra points due to rounding error 
    
    
    y = [y; y_ol];
    x = [x; x_ol];
    u = [u; u_ol];

    UU = [UU; U'];
    UU_l = [UU_l; U_l'];
    UU_c = [UU_c; U_c'];

    t = [t; t_ol+t_last*ones(n_t,1) ];
    t_last = t_last + T_ol; 


  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_open2closed.m version [fea943f4dc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [K_x T] = ppp_open2closed (A_u,A_c,k_x,x_0,Us0);

  ## usage:  [K_x T] = ppp_open2closed (A_u,A_c,k_x,x_0[,Us0]);
  ## K_x is the open-loop matrix as in U = K_w W - K_x x
  ## Note that K_x is a column vector of matrices - one matrix per input.
  ## T is the transformation matrix: x = T*Ustar; A_c = T*A_u*T^-1; U = (k_x*T)'
  ## A_u: The control basis-function matrix
  ## Us0: The initial value of Ustar
  ## A_c: closed-loop system matrix
  ## k_x: closed-loop feedback gain
  ## x_0: initial state
  ## Us0: initial basis fun state

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	


  ## Check sizes
  n_o = is_square(A_u);
  n_c = is_square(A_c);

  if (n_o==0)||(n_c==0)||(n_o!=n_c)
    error("A_u and A_c must be square and of the same dimension");
  endif

  [n_u,n_x] = size(k_x);

  ## Defaults
  if nargin<4
    x_0 = zeros(n_c,1);
  endif

  if nargin<5 #Create U*(0)
    ##Us0  = ppp_ustar(A_u,n_u);
    Us0 = ones(1,n_o);
  endif
  

  ## Decompose A_u and Us0 into two bits:
  if n_o==n_c
    A_w = [];
    u_0 = Us0(1:n_c)';		# Assume same Us0 on each input
  else
    A_w = A_u(n_c+1:n_o, n_c+1:n_o)
    A_u = A_u(1:n_c, 1:n_c)
    U_w = Us0(1,n_c+1:n_o)'
    u_0 = Us0(1:n_c)'
  endif
  
  if !is_controllable(A_u,u_0)
    error("The pair [A_u, u_0] must be controllable");
  endif

  ## Controllability matrices
  C_o = u_0;
  C_c = x_0;
  for i=1:n_c-1
    C_o = [C_o A_u^i*u_0]; 
    C_c = [C_c A_c^i*x_0];
  endfor

  ## Transformation matrix: x = T*Ustar; A_c = T*A_u*T^-1; U = (k_x*T)'
  iC_o = C_o^-1;
  T = C_c*iC_o;

  K_x = [];
  for j = 1:n_u
    ## K_j matrix
    K_j = [];
    for i=1:n_c;
      ## Create T_i = dT/dx_i
      T_i = zeros(n_c,1);
      T_i(i) = 1;
      for k=1:n_c-1;
	A_k = A_c^k;
	T_i = [T_i A_k(:,i)];
      endfor
      T_i = T_i*iC_o;
      kj = k_x(j,:);		# jth row of k_x
      K_ji = kj*T_i;		# ith row of K_j
      K_j = [K_j; K_ji];
    endfor
    K_x = [K_x; K_j'];
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_optimise.m version [21b69c71ec].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [par,Par,Error,Y,iterations,x] = \
      ppp_optimise(system_name,x_0,par_0,simpar,u,y_0,free,Q,extras);
  ## Levenberg-Marquardt optimisation for PPP/MTT
  ## Usage: [par,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpar,u,y_0,free[,Q,extras]);
  ##  system_name     String containing system name
  ##  x_0             Initial state
  ##  par_0           Initial parameter vector estimate
  ##  simpar          Simulation parameters:
  ##        .first      first time
  ##        .dt         time increment
  ##        .stepfactor Euler integration step factor
  ##  u               System input (column vector, each row is u')
  ##  y_0             Desired model output
  ##  free            one row for each adjustable parameter
  ##                  first column parameter indices
  ##                  second column corresponding sensitivity indices
  ##  Q               vector of positive output weights.
  ##  extras (opt)    optimisation parameters
  ##        .criterion convergence criterion
  ##        .max_iterations limit to number of iterations
  ##        .v  Initial Levenberg-Marquardt parameter

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.14  2002/08/20 16:14:35  gawthrop
  ## Include Q in documentation
  ##
  ## Revision 1.13  2002/08/20 15:43:45  gawthrop
  ## Works with ident DIY rep
  ##
  ## Revision 1.12  2002/06/11 11:25:25  gawthrop
  ## No longer delay the simulated data.
  ##
  ## Revision 1.11  2002/05/20 13:32:36  gawthrop
  ## Sanity check on y_0
  ##
  ## Revision 1.10  2002/05/13 16:01:09  gawthrop
  ## Addes Q weighting matrix
  ##
  ## Revision 1.9  2002/05/08 10:14:21  gawthrop
  ## Idetification now OK (Moved data range in ppp_optimise by one sample interval)
  ##
  ## Revision 1.8  2002/04/23 17:50:39  gawthrop
  ## error --> err to avoid name clash with built in function
  ##
  ## Revision 1.7  2001/08/10 16:19:06  gawthrop
  ## Tidied up the optimisation stuff
  ##
  ## Revision 1.6  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ## Revision 1.5  2001/06/06 07:54:38  gawthrop
  ## Further fixes to make nonlinear PPP work ...
  ##
  ## Revision 1.4  2001/05/26 15:46:38  gawthrop
  ## Updated to account for new nonlinear ppp
  ##
  ## Revision 1.3  2001/04/05 11:50:12  gawthrop
  ## Tidied up documentation + verbose mode
  ##
  ## Revision 1.2  2001/04/04 08:36:25  gawthrop
  ## Restuctured to be more logical.
  ## Data is now in columns to be compatible with MTT.
  ##
  ## Revision 1.1  2000/12/28 11:58:07  peterg
  ## Put under CVS
  ##
  ###############################################################


  ## Copyright (C) 1999,2000,2001,2002 by Peter J. Gawthrop

  ## Simulation command
  sim_command = sprintf("%s_ssim(x_0,par,simpar,u,i_s);", system_name);

  ## Extract indices
  i_t = free(:,1);		# Parameters
  i_s = free(:,2)';		# Sensitivities

  if nargin<9
    extras.criterion = 1e-5;
    extras.max_iterations = 10;
    extras.v = 1e-5;
    extras.verbose = 0;
  endif
  

  [n_data,n_y] = size(y_0);
  if n_data<n_y
    error("ppp_optimise: y_0 should be in columns, not rows")
  endif

  if nargin<8
    Q = ones(n_y,1);
  endif
  
  n_th = length(i_s);
  err_old = inf;
  err_old_old = inf;
  err = 1e50;
  reduction = inf;
  predicted_reduction = 0;
  par = par_0;
  Par = par_0;
  step = ones(n_th,1);
  Error = [];
  Y = [];
  iterations = 0;
  v = extras.v;			# Levenverg-Marquardt parameter.
  r = 1;			# Step ratio

  if extras.verbose		# Diagnostics
    printf("Iteration: %i\n", iterations);
    printf("  error:  %g\n", err);
    printf("  reduction:  %g\n", reduction);
    printf("  prediction: %g\n", predicted_reduction);
    printf("  ratio:      %g\n", r);
    printf("  L-M param:  %g\n", v);
    printf("  parameters: ");
    for i_th=1:n_th
      printf("%g ", par(i_t(i_th)));
    endfor
    printf("\n");
  endif
  
  while (abs(reduction)>extras.criterion)&&\
	(abs(err)>extras.criterion)&&\
	(iterations<extras.max_iterations)

    iterations = iterations + 1; # Increment iteration counter

    [y,y_par,x] = eval(sim_command); # Simulate
    [N_data,N_y] = size(y);

    if (N_y!=n_y)
      mess = sprintf("n_y (%i) in data not same as n_y (%i) in model", n_y,N_y);
      error(mess);
    endif

    ## Use the last part of the simulation to compare with data
    ## ### Removed #### And shift back by one data point
#     if ( (N_data-n_data)<1 )
#       error(sprintf("y_0 (%i) must be shorter than y (%i)", n_data, N_data));
#     endif
    y = y(N_data-n_data+1:N_data,:);
    y_par = y_par(N_data-n_data+1:N_data,:);

    if extras.visual==1
      ## Plot
      title("Optimisation data");
      plot([y y_0])
    endif
    
    ##Evaluate error, cost derivative J and cost second derivative JJ
    err = 0; 
    J = zeros(n_th,1);
    JJ = zeros(n_th,n_th);
   
    for i = 1:n_y
      E = y(:,i) - y_0(:,i);	#  Error in ith output
      err = err + Q(i)*(E'*E);	# Sum the squared error over outputs
      y_par_i = y_par(:,i:n_y:n_y*n_th); # sensitivity function (ith output)
      J  = J + Q(i)*y_par_i'*E;	# Jacobian
      JJ = JJ + Q(i)*y_par_i'*y_par_i; # Newton Euler approx Hessian
    endfor

    if iterations>1 # Adjust the Levenberg-Marquardt parameter
      reduction = err_old-err;
      predicted_reduction =  2*J'*step + step'*JJ*step;
      r = predicted_reduction/reduction;
      if (r<0.25)||(reduction<0)
	v = 4*v;
      elseif r>0.75
	v = v/2;
      endif

      if reduction<0		# Its getting worse
	par(i_t) = par(i_t) + step; # rewind parameter
	err = err_old;	# rewind error
	err_old = err_old_old; # rewind old error
	if extras.verbose
	  printf(" Rewinding ....\n");
	endif
      endif
    endif

    ## Compute step using pseudo inverse
    JJL = JJ + v*eye(n_th);	# Levenberg-Marquardt term
    step =  pinv(JJL)*J;	# Step size
    par(i_t) = par(i_t) - step; # Increment parameters
    err_old_old = err_old;	# Save old error
    err_old = err;		# Save error

    ##Some diagnostics
    Error = [Error err];	# Save error
    Par = [Par par];		# Save parameters
    Y = [Y y];			# Save output

    if extras.verbose		# Diagnostics
      printf("Iteration: %i\n", iterations);
      printf("  error:  %g\n", err);
      printf("  reduction:  %g\n", reduction);
      printf("  prediction: %g\n", predicted_reduction);
      printf("  ratio:      %g\n", r);
      printf("  L-M param:  %g\n", v);
      printf("  parameters: ");
      for i_th=1:n_th
	printf("%g ", par(i_t(i_th)));
      endfor
      printf("\n");
    endif
    

  endwhile

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_output_constraint.m version [1ed78d0651].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Gamma,gamma] = ppp_output_constraint (A,B,C,D,x_0,A_u,Tau,Min,Max,Order,i_y)

  ## usage:  [Gamma,gamma] = ppp_output_constraint (A,B,C,D,x_0,A_u,Tau,Min,Max,Order)
  ##
  ## Derives the output constraint matrices Gamma and gamma
  ## For Constraints Min and Max at times Tau
  ## Initial state x_0 
  ## Order=0 - output constraints
  ## Order=1 - output derivative constraints
  ## etc
  ## NOTE You can stack up Gamma and gamma matrices for create multi-output constraints.

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  ## Sizes
  [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions
  [n_U,m_U] = size(A_u);	# Number of basis functions
  [n,n_tau] = size(Tau);		# Number of constraint times
  
  if n_tau==0			# Nothing to be done
    Gamma = [];
    gamma = [];
    return
  endif

  ## Defaults
  if nargin<10
    Order = zeros(1,n_tau);
  endif

  if nargin<11
    i_y = 1;			# First output
  endif

  if n != 1
    error("Tau must be a row vector");
  endif
  
  n = length(Min);
  m = length(Max);
  o = length(Order);

  if (n != n_tau)||(m != n_tau)||(o != n_tau)
    error("Tau, Min, Max and Order must be the same length");
  endif
  

  ## Compute Gamma 
  Gamma = [];
  zero_x = zeros(size(x_0));
  for i=1:n_U
    U = zeros(n_U,1); U(i,1) = 1; # Set up U_i
    y_i = ppp_ystar (A,B,C,D,zero_x,A_u,U,Tau); # Compute y* for ith input for each tau
    y_i = y_i(i_y,:); # Pluck out output i_y
    ## Gamma = [Gamma [-y_i';y_i']]; # Put in parts for Min and max
    Gamma_i = [];
    if (Min>-inf)
      Gamma_i = [Gamma_i; -y_i']; # Min part of column
    endif
    if (Max<inf)
      Gamma_i = [Gamma_i;  y_i'];	# Add column for Max
    endif
    Gamma = [Gamma Gamma_i]; # Put in parts for Min and max
  endfor

  ## Compute gamma
  zero_U = zeros(size(U));
  y_x = ppp_ystar (A,B,C,D,x_0,A_u,zero_U,Tau);	# Output if U is zero
  gamma = [];
  if (Min>-inf)
    gamma = [gamma; -(Min-y_x)'];
  endif
  if (Max<inf)
    gamma = [gamma; (Max-y_x)'];
  endif
  
endfunction


Deleted mttroot/mtt/lib/control/PPP/ppp_output_constraints.m version [e3acc8646d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Gamma,gamma] = ppp_output_constraints (A,B,C,D,x_0,A_u,Tau,Min,Max,Order)

  ## usage:
  ## [Gamma,gamma] = ppp_output_constraints(A,B,C,D,x_0,A_u,Tau,Min,Max,Order)
  ##
  ## 
  
  ## Sanity check
  [n_y,n_tau] = size(Min);
  [n,m] = size(Max);
  if (n!=n_y)||(m!=n_tau)
    error("Max and Min must have the same dimensions");
  endif
  
  [n,m] = size(Tau);
  if (m!=n_tau)
    error("Max and Min must have same number of columns as Tau");
  endif
  if (n>1)
    error("Tau must be a row vector");
  endif

  ##Defaults
  if nargin<10
    Order=zeros(n_y,n_tau);
  endif
  
  ## Stack up constraints for each output
  Gamma=[];
  gamma=[];
  for i_y=1:n_y
    [Gamma_i,gamma_i] = \
	ppp_output_constraint (A,B,C,D,x_0,A_u,Tau,\
			       Min(i_y,:),Max(i_y,:),Order(i_y,:),i_y);
    Gamma = [Gamma; Gamma_i];
    gamma = [gamma; gamma_i];
  endfor
  
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_pred.m version [a109d8be6c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A_p,B_p] = ppp_pred (A,B,C,D,A_u,Ust0,T)

  ## usage:  [A_p,B_p] = ppp_pred (A,B,C,D,A_u,Ust0,T)
  ##
  ## PPP prediction matrices: x_pred = A_p*x + B_p*U

  ## Sanity
  [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions
  if (n_x==-1)
    error("A B C D not compatible");
  endif
  
  n_U = issquare(A_u);
  if (n_U!=n_x)
    error(sprintf("A_u must be %ix%i",n_x,n_x));
  endif
  
  [nn,mm] = size(Ust0);
  if (nn!=1)||(mm!=n_x)
    error(sprintf("Ust0 must be 1x%i",n_x));
  endif
  
      Z = zeros(n_x,n_x);
      AA = [A   B*Ust0
	    Z   A_u'];

      eAA = expm(AA*T);
      A_p = eAA(1:n_x,1:n_x);
      B_p = eAA(1:n_x,n_x+1:2*n_x);
  
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_qp.m version [78c9145b4b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [u,U,n_active] = ppp_qp (x,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma,mu,test)

  ## usage:  [u,U] = ppp_qp (x,W,J_uu,J_ux,J_uw,Gamma,gamma)
  ## INPUTS:
  ##      x: system state    
  ##      W: Setpoint vector
  ##      J_uu,J_ux,J_uw: Cost derivatives (see ppp_lin)
  ##      Us0: value of U* at tau=0 (see ppp_lin)
  ##      Gamma, gamma: U constrained by Gamma*U <= gamma 
  ##      mu  Parameter of qp_mu
  ## Outputs:
  ##      u: control signal
  ##      U: control weight vector
  ##
  ## Predictive pole-placement of linear systems using quadratic programming
  ## Use ppp_input_constraint and ppp_output_constraint to generate Gamma and gamma
  ## Use ppp_lin to generate J_uu,J_ux,J_uw
  ## Use ppp_cost to evaluate resultant cost function

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  if nargin<9
    mu = 0
  endif

  if nargin<10
    test=0;
  endif
  

  ## Check the sizes
  n_x = length(x);

  [n_U,m_U] = size(J_uu);
  if n_U != m_U
    error("J_uu must be square");
  endif

  [n,m] = size(J_ux);
  if (n != n_U)||(m != n_x)
    error("J_ux should be %ix%i not %ix%i",n_U,n_x,n,m);
  endif


  if length(gamma)>0		# Constraints exist: do the QP algorithm
    ## QP solution for weights U	
##    [U,iterations] = qp_mu(J_uu,(J_ux*x-J_uw*W),Gamma,gamma,mu,[],[],0,test);
    [U,n_active] = qp_hild(J_uu,(J_ux*x - J_uw*W),Gamma,gamma);	# 
##    iterations = 0;

    ##U = qp(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
    ##U = pd_lcp04(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
    u = Us0*U;			# Control signal
  else			# Do the unconstrained solution
    ## Compute the open-loop gains
    n_active = 0;
    K_w = J_uu\J_uw;
    K_x = J_uu\J_ux;

    ## Closed-loop control
    U = K_w*W - K_x*x;		# Basis functions weights - U(t)
    u = Us0*U;			# Control u(t)
  endif

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_qp_sim.m version [6333ae0d35].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [T,y,u,X,Iterations] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q,R,P,\
					    Tau_u,Min_u,Max_u,Order_u, \
					    Tau_y,Min_y,Max_y,Order_y, \
					    W,x_0,Delta_ol,mu,test,movie)

  ## usage: [T,y,u,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, Tau_u,Min_u,Max_u,Order_u, Tau_y,Min_y,Max_y,Order_y, W,x_0,movie)
  ## Needs documentation - see ppp_ex11 for example of use.
  ## OUTPUTS
  ## T: Time vector
  ## y,u,J output, input and cost

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	
  
  if nargin<21			# No intermittent control
    Delta_ol = 0;
  endif

  if nargin<22			# Mu
    mu = 0;
  endif

  if nargin<23
    test=0
  endif
  
  if nargin<24			# No movie
    movie = 0;
  endif

test = test
  ## Check some sizes
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  [n_x0,m_x0] = size(x_0);
  if (n_x0 != n_x)||(m_x0 != 1)
    error(sprintf("Initial state x_0 must be %ix1 not %ix%i",n_x,n_x0,m_x0));
  endif
  
  ## Input constraints 
  [Gamma_u, gamma_u] = ppp_input_constraints(A_u,Tau_u,Min_u,Max_u);

  ## Output constraints
  [Gamma_y,gamma_y] = ppp_output_constraints(A,B,C,D,x_0,A_u,Tau_y,Min_y,Max_y,Order_y);

  ## Composite constraints - t=0
  Gamma = [Gamma_u; Gamma_y];
  gamma = [gamma_u; gamma_y];

  ## Design the controller
  ## disp("Designing controller");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] = ppp_lin (A,B,C,D,A_u,A_w,t,Q,R,P);

  ## Set up various time vectors
  dt = t(2)-t(1);		# Time increment

  ## Make sure Delta_ol is multiple of dt
  Delta_ol = floor(Delta_ol/dt)*dt;

  if Delta_ol>0			# Intermittent control
    T_ol = 0:dt:Delta_ol;	# Create the open-loop time vector
  else
    T_ol = [0,dt];
    Delta_ol = dt;
  endif
  t_last = t(length(t));
  T_cl = 0:Delta_ol:2*t_last-Delta_ol; # Closed-loop time vector
  T = 0:dt:2*t_last;		# Overall time vector
 
  ## Lengths thereof
  n_Tcl = length(T_cl);
  n_ol = length(T_ol);
  n_T = length(T);

  ## Expand W with constant last value or truncate
  [n_W,m_W] = size(W);

  if m_W>n_T
    W = W(:,1:n_T);
  else
    W = [W W(:,m_W)*ones(1,n_T-m_W+1)];
  endif

  ## Compute U*
  Ustar_ol = ppp_ustar(A_u,n_u,T_ol); # U* in the open-loop interval

  [n,m] = size(Ustar_ol);
  n_U = m/length(T_ol);		# Determine size of each Ustar

#   ## Discrete-time system
#   csys = ss2sys(A,B,C,D);
#   dsys = c2d(csys,dt);
#   [Ad, Bd] = sys2ss(dsys)

  x = x_0;			# Initialise state

  ## Initialise the saved variable arrays
  X = [];
  u = [];
  Iterations = [];
  du = [];
  J = [];
  tick= time;

  ## disp("Simulating ...");
  for t=T_cl			# Outer loop at Delta_ol
    printf("%g\r",t);
    ##disp(sprintf("Time %g", t));
    ## Output constraints
    [Gamma_y,gamma_y] = ppp_output_constraints  (A,B,C,D,x,A_u,Tau_y,Min_y,Max_y,Order_y);
    
    ## Composite constraints 
    Gamma = [Gamma_u; Gamma_y];
    gamma = [gamma_u; gamma_y];
    
    ## Current Setpoint value
    w = W(:,floor(t/dt)+1);
    
    ## Compute U(t) via QP optimisation
    [uu, U, iterations] = ppp_qp (x,w,J_uu,J_ux,J_uw,Us0,Gamma,gamma,mu,test); # Compute U

    ## Compute the cost (not necessary but maybe interesting)
#    [J_t] = ppp_cost (U,x,W,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww); # cost
#    J = [J J_t];

    ## OL Simulation (exact)
    [ys,us,xs] = ppp_ystar (A,B,C,D,x,A_u,U,T_ol);

    ## Save values (discarding final ones)
    X = [X xs(:,1:n_ol-1)];			# save state
    u = [u us(:,1:n_ol-1)];			# save input
    Iterations = [Iterations iterations*ones(1,n_ol-1)];

    ## Final values
    x = xs(:,n_ol);		# Final state
    ut = us(:,n_ol);		# Final control

  endfor
  
  ## Save the last values
  X = [X x];		# Save state
  u = [u ut];		# Save input
  Iterations = [Iterations iterations]; # Save iteration count

  tock = time;
  Elapsed_Time = tock-tick;
  y = C*X + D*u;		# System output


endfunction



Deleted mttroot/mtt/lib/control/PPP/ppp_sim.m version [a4ff8b90d8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y,y_s] = ppp_sim (system_name,x_0,u,t,par,i_s,external)

  ## mtt_sim: Simulates system  sensitivity functions. 
  ## usage:  [y,y_s] = ppp_sim (system_name,x_0,u,t,par,i_s)
  ##   system_name string containing name of the sensitivity system
  ##   x_0         initial state 
  ##   u           system input (one input per row)
  ##   t           row vector of time
  ##   par         system parameter vector
  ##   i_s         indices of sensitivity parameters 


  if nargin<7
    external = 0;
  endif
  
  ## Some sizes
  n_s = length(i_s);
  n_t = length(t);


  for i = 1:n_s

    ## Set sensitivity parameters
    par(i_s(i)) = 1.0;
    par(complement(i_s(i),i_s)) = 0;

    if external
      par_string = "";
      for i_string=1:length(par)
	par_string = sprintf("%s %s", par_string, num2str(par(i_string)));
      endfor
      data_string = system(sprintf("./%s_ode2odes.out %s | cut -f 2-%i", \
				   system_name, par_string, 1+n_s));
      Y = str2num(data_string)';
    else
      Y = eval(sprintf("%s_sim(x_0,u,t,par);", system_name));
    endif

    [n_Y,m_Y] = size(Y);
     n_y = n_Y/2;
    if i==1	
      y = Y(1:2:n_Y,:);		# Save up the output
      y_s = zeros(n_s*n_y, n_t); # Initialise for speed
    endif
 
    y_s((i-1)*n_y+1:i*n_y,:)  = Y(2:2:n_Y,:);	# Other sensitivities
    
  endfor

title("");
plot(t,y);

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_sm2sr.m version [b8cab9f99f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Y,X] = ppp_sm2sr(A,B,C,D,T,u0,x0);
  ## Usage [Y,X] = ppp_sm2sr(A,B,C,D,T,u0,x0);
  ## Computes a step response
  ## A,B,C,D- state matrices
  ## T vector of time points
  ## u0 input gain vector: u = u0*unit step.

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  [Ny,Nu] = size(D);
  [Ny,Nx] = size(C);

  if nargin<6
    u0 = zeros(Nu,1);
    u0(1) = 1;
  end;

  if nargin<7
    x0 = zeros(Nx,1);
  end;

  [N,M] = size(T);
  if M>N
    T = T';
    N = M;
  end;



  one = eye(Nx);

  Y = zeros(Ny,N);
  X = zeros(Nx,N);

  dt = T(2)-T(1);		# Assumes fixed interval
  expAdt = expm(A*dt);		# Compute matrix exponential
  i = 0;
  expAt = one;

  DoingStep = max(abs(u0))>0;	# Is there a step component?
  DoingInitial = max(abs(x0))>0; # Is there an initial component?
  for t = T'
    i=i+1;
    if Nx>0
      x = zeros(Nx,1);
      if DoingStep
	x = x + ( A\(expAt-one) )*B*u0;
      endif
      if DoingInitial
	x = x + expAt*x0;
      endif
      
      expAt = expAt*expAdt;

      X(:,i) = x;
      if Ny>0
	y = C*x + D*u0;
	Y(:,i) = y;
      endif
    elseif Ny>0
      y = D*u0;
      Y(:,i) = y;
    endif
  endfor


endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ustar.m version [84e1f5fdcb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function Ustar = ppp_ustar (A_u,n_u,tau,order,packed,n_zero)

  ## usage:  Us = ppp_ustar(A_u,n_u,tau,order,packed)
  ##
  ## Computes the U* matrix at time tau in terms of A_u
  ## n_u : Number of system inputs
  ## If tau is a vector, computes U* at each tau and puts into a row vector:
  ## If packed==1
  ##     Ustar = [Ustar(tau_1) Ustar(tau_2) ...]
  ## else Ustar = [Ustar(tau_1); Ustar(tau_2) ...]
  ## n_zero extra zero columns appended

  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  if nargin<2
    n_u = 1;
  endif
  
  if nargin<3
    tau = 0;
  endif
  
  if nargin<4
    order = 0;
  endif
  
  if nargin<5
    packed=1;
  endif
  
  if nargin<6
    n_zero=0;
  endif
  

  [n,m] = size(A_u);		# Size of composite A_u matrix
  N = m;			# Number of U* functions per input  
  nm = n/m;

  if (nm != n_u)&&(n!=m)	# Check consistency
    error("A_u must be square or be a column of square matrices");
  endif

  u_0 = ones(N,1);

  Ustar = [];
  for t = tau;
    ustar = [];
    for i = 1:n_u
      A_i = ppp_extract(A_u,i);
      Ak = A_i^order;
      eA = expm(A_i*t);
      if (packed==1)
	ustar = [ustar; zeros(1,(i-1)*N), (Ak*eA*u_0)', \
		 zeros(1,(n_u-i)*N)];
      else
	ustar = [ustar, (Ak*eA*u_0)'];
      endif
    endfor

    if (packed==1)
      Ustar = [Ustar ustar];
    else
      Ustar = [Ustar; ustar];
    endif
  endfor

  if (n_zero>0)
    [N,M] = size(Ustar);
    Ustar = [Ustar zeros(N, n_zero)];
  endif
  
endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_ustar2h.m version [d77ecc26ba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ppp_ustar2h (Ustar,DT,name)

  ## usage:  ppp_Ustar2h (Ustar[,name])
  ##
  ## 

  if nargin<2
    DT = 1;
  endif
  
  if nargin<3
    name = "Ustar";
  endif

  [N,N_U] = size(Ustar);

  ## Open the file 
  filename = sprintf("%s.h", name);
  fid = fopen(filename,"w");

  ## Header
  header = sprintf("/*\n File %s generated by ppp_ustar2h on %s */\n", \
		   filename, ctime(time));

  def = sprintf("#define N_U %i\n#define N_T %i\n#define DT %g\n", \
		 N_U, N, DT);
  def = sprintf("%sdouble U[N_U]={",def);
  for j=1:N_U
    if j<N_U
      comma = ",";
    else
      comma = "";
    endif
    def = sprintf("%s0.0%s ",def, comma);
  endfor
  def = sprintf("%s};\n",def)

  fprintf(fid, "%s%sdouble %s[N_T][N_U] = {\n",header,def,name);
  for i=1:N
    fprintf(fid, "{");
    for j=1:N_U
      if j<N_U
	comma = ",";
      else
	comma = "";
      endif
      fprintf(fid, "%g%s ", Ustar(i,j),comma);
    endfor

    if i<N
      fprintf(fid, "},\n");
    else
      fprintf(fid, "}\n");
    endif
    
  endfor
  fprintf(fid, "};\n");

  fclose(fid);

endfunction

Deleted mttroot/mtt/lib/control/PPP/ppp_y_u.m version [8a57fa7a93].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y_u, Us] = ppp_y_u (A,B,C,D,A_u,u_0,tau)

  ## usage:  y_u = ppp_y_u (A,B,C,D,A_u,u_0,t)
  ##
  ## Computes y_u derivative of y* wrt U
  ## Called by ppp_lin
  ## OBSOLETE

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.6  2000/12/27 16:41:05  peterg
  ## *** empty log message ***
  ##
  ## Revision 1.5  1999/05/31 01:58:01  peterg
  ## Now uses ppp_extract
  ##
  ## Revision 1.4  1999/05/12 00:10:35  peterg
  ## Modified for alternative (square) A_u
  ##
  ## Revision 1.3  1999/05/03 23:56:32  peterg
  ## Multivariable version - tested for N uncoupled systems
  ##
  ## Revision 1.2  1999/05/03 00:38:32  peterg
  ## Changed data storage:
  ## y_u saved as row vector, one row for each time, one column for
  ## each U
  ## y_x saved as row vector, one row for each time, one column for
  ## each x
  ## W* saved as row vector, one row for each time, one column for
  ## each element of W*
  ## This is consistent with paper.
  ##
  ## Revision 1.1  1999/04/29 06:02:43  peterg
  ## Initial revision
  ##
  ###############################################################



  ## Check argument dimensions
  [n_x,n_u,n_y] = abcddim(A,B,C,D);
  if (n_x==-1)
    return
  endif

  [n,m] = size(A_u);		# Size of composite A_u matrix
  N = m;			# Number of U* functions per input
  
  y_u = [];			# Initialise
  Us = [];
  
#   for input=1:n_u		# Do for each system input
#     a_u = ppp_extract(A_u,input); # Extract the relecant A_u matrix
#     for i=1:N			# Do for each input function U*_i
#       C_u = zeros(1,N); C_u(i) = 1; # Create C_u for this U*_i
#       b = B(:,input);		# B vector for this input
#       d = D(:,input);		# D vector for this input
#       [y,u] = ppp_transient (t,a_u,C_u,u_0,A,b,C,d); # Compute response for this input
#       y_u = [y_u y'];		# Save y_u (y for input u)  with one row for each t.
#       Us = [Us u'];		# Save u (input)  with one row for each t.
#     endfor
#   endfor
  i_U = 0;
  x_0 = zeros(n_x,1);		# This is for x=0
  for input=1:n_u		# Do for each system input
    a_u = ppp_extract(A_u,input); # Extract the relevant A_u matrix
    for i=1:N			# Do for each input function U*_i
      dU = zeros(N*n_u,1);
      dU(++i_U) = 1;		# Create dU/dU_i 
      [ys,us] = ppp_ystar (A,B,C,D,x_0,a_u,dU,tau); # Find ystar and ustar
      y_u = [y_u ys'];		# Save y_u (y for input u)  with one row for each t.
      Us = [Us us'];		# Save u (input)  with one row for each t.
    endfor
  endfor

endfunction




Deleted mttroot/mtt/lib/control/PPP/ppp_ystar.m version [0c38479f43].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [ys,us,xs,xu,AA] = ppp_ystar (A,B,C,D,x_0,A_u,U,tau,Us0)

  ## usage:  [ys,us,xs,xu,AA] = ppp_ystar (A,B,C,D,x_0,A_u,U,tau[,Us0])
  ##
  ## Computes open-loop moving horizon variables at time tau
  ## Inputs:
  ## A,B,C,D     System matrices
  ## x_0         Initial state
  ## A_u         composite system matrix for U* generation 
  ##             one square matrix (A_ui) row for each system input
  ##             each A_ui generates U*' for ith system input.
  ## OR
  ## A_u         square system matrix for U* generation 
  ##             same square matrix for each system input
  ## U           Column vector of optimisation coefficients  
  ## tau         Row vector of times at which outputs are computed
  ## Us0         Initial value of U* (default ones(NU,1))
  ## Outputs:
  ## ys          y*, one column for each time tau 
  ## us          u*, one column for each time tau 
  ## xs          x*, one column for each time tau 
  ## xu          x_u, one column for each time tau 
  ## AA          The composite system matrix
  

  ## Copyright (C) 1999,2005 by Peter J. Gawthrop
  ## 	$Id$	

  if (size(A)>0)
    [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions
  else
    n_x = 0;
    n_y = 0;
    n_u = 0;
  endif
  
  no_system = n_x==0;

  [n,m] = size(A_u);		# Size of composite A_u matrix
  square = (n==m);		# Is A_u square?
  n_U = m;			# functions per input

  [n,m] = size(U);
  if (m != 1)
    error("U must be a column vector");
  endif
  
  if n_u>0
    if n_u!=length(U)/n_U
      error("U must be a column vector with n_u*n_U components");
    endif
  else
    n_u = length(U)/n_U;	# Deduce n_u from U if no system
  endif
  
  [n_x0,m_x0] = size(x_0);
  if n_x0!=n_x
    error(sprintf("x_0 must be a column with length %i", n_x));
  endif
  

  [n,m]=size(tau);
  if (n != 1 )
    error("tau must be a row vector of times");
  endif

  if nargin<9
    Us0 = ones(1,n_U);
  endif
  
  [n_Us0,m_Us0] = size(Us0);
  if (n_Us0>1)||(n_Us0>m_Us0)
    error(sprintf("Us0 must be a row vector, not %ix%i ",n_Us0,m_Us0));
  endif
	  
  
  if square			# Then same A_u for each input
    ## Reorganise vector U into matrix Utilde  
    Utilde = [];
    for i=1:n_u
      j = (i-1)*n_U;
      range = j+1:j+n_U;
      Utilde = [Utilde; U(range,1)'];
    endfor

    ## Composite A matrix
    if no_system
      AA = A_u;
    else
      Z = zeros(n_U,n_x);
      AA = [A   B*Utilde
	    Z   A_u];
    endif
    
    xx_0 = [x_0;Us0'];		# Composite initial condition
  else				# Different A_u on each input
    ## Reorganise vector U into matrix Utilde  
    Utilde = [];
    for i=1:n_u
      j = (i-1)*n_U;
      k = (n_u-i)*n_U;
      range = j+1:j+n_U;
      Utilde = [Utilde; zeros(1,j), U(range,1)', zeros(1,k)];
    endfor

    ## Create the full A_u matrix (AA_u) with the A_i s on the diagonal
#     AA_u = [];
#     for i = 1:n_u
#       AA_u = ppp_aug(AA_u,ppp_extract(A_u,i));
#     endfor
    AA_u = ppp_inflate(A_u);

    ## Composite A matrix
    if no_system
      AA = AA_u;
    else
      Z = zeros(n_U*n_u,n_x);
      AA = [A   B*Utilde
	    Z   AA_u];
    endif
    xx_0 = [x_0;ones(n_U*n_u,1)];	# Composite initial condition
  endif
  
  
  ## Initialise
  xs = [];			# x star
  xu = [];			# x star
  ys = [];			# y star
  us = [];			# u star
  n_xx = length(xx_0);		# Length of composite state

  ## Compute the star variables
  for t=tau
    xxt = expm(AA*t)*xx_0;	# Composite state
    xst = xxt(1:n_x);		# x star
    xut = xxt(n_x+1:n_xx);	# x star
    if length(C)>0
      yst = C*xst;		# y star
    else
      yst = [];
    endif
    
    ust = Utilde*xut;		# u star

    xs = [xs xst];		# x star
    xu = [xu xut];		# x star
    ys = [ys yst];		# y star
    us = [us ust];		# u star
  endfor

endfunction

Deleted mttroot/mtt/lib/control/PPP/rpv.m version [c302718039].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D] = rpv
% System RPV
% This system is the remotely-piloted vehicle example from the book:
% J.M Maciejowski: Multivariable Feedback Design  Addison-Wesley, 1989
% It has 6 states, 2 inputs and 2 outputs.

% P J Gawthrop Jan 1998

A = [-0.0257  -36.6170  -18.8970  -32.0900    3.2509   -0.7626
      0.0001   -1.8997    0.9831   -0.0007   -0.1780   -0.0050
      0.0123   11.7200   -2.6316    0.0009  -31.6040   22.3960
           0         0    1.0000         0         0         0
           0         0         0         0  -30.0000         0
           0         0         0         0         0  -30.0000];

B = [0     0
     0     0
     0     0
     0     0
    30     0
     0    30];

C = [0     1     0     0     0     0
     0     0     0     1     0     0];

D = zeros(2,2);


Deleted mttroot/mtt/lib/control/PPP/tgen.m version [37e3b79324].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [A,B,C,D] = tgen
% System TGEN from
% This system is the turbogenerator example from the book:
% J.M Maciejowski: Multivariable Feedback Design  Addison-Wesley, 1989
% It has 6 states, 2 inputs and 2 outputs.

% P J Gawthrop Jan 1998

A = [-18.4456    4.2263   -2.2830    0.2260    0.4220   -0.0951
      -4.0977   -6.0706    5.6825   -0.6966   -1.2246    0.2873
       1.4449    1.4336   -2.6477    0.6092    0.8979   -0.2300
      -0.0093    0.2302   -0.5002   -0.1764   -6.3152    0.1350
      -0.0464   -0.3489    0.7238    6.3117   -0.6886    0.3645
      -0.0602   -0.2361    0.2300    0.0915   -0.3214   -0.2087];

B = [-0.2748    3.1463
     -0.0501   -9.3737
     -0.1550    7.4296
      0.0716   -4.9176
     -0.0814  -10.2648
      0.0244   13.7943];

C = [0.5971   -0.7697    4.8850    4.8608   -9.8177   -8.8610
     3.1013    9.3422   -5.6000   -0.7490    2.9974   10.5719];

D = zeros(2,2);


Deleted mttroot/mtt/lib/control/PPP/transient.m version [14fe0c3057].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function X = transient (t,A,x_0)

  ## usage:  L = transient (t,p,order)
  ##
  ## Computes transient response for time t with initial condition x_0

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.1  1999/04/27 04:46:05  peterg
  ## Initial revision
  ##
  ## Revision 1.1  1999/04/25 23:19:40  peterg
  ## Initial revision
  ##
  ###############################################################


X=[];
  for tt=t			# Create the Transient up to highest order
    x = expm(A*tt)*x_0;
    X = [X x];
  endfor

endfunction

Deleted mttroot/mtt/lib/cr/hh/ISW.hh version [ae8d942dc5].

1
2
3
4
5
6






-
-
-
-
-
-
#ifndef ISW_HH
#define ISW_HH

// dummy file

#endif // ISW_H

Deleted mttroot/mtt/lib/cr/hh/SS.hh version [24fd0512ed].

1
2
3
4
5
6






-
-
-
-
-
-
#ifndef SS_HH
#define SS_HH

// dummy file

#endif // SS_H

Deleted mttroot/mtt/lib/cr/hh/causality.hh version [fa67fbd353].

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
#ifndef CAUSALITY_HH
#define CAUSALITY_HH

enum causality { effort, flow, state };

typedef enum causality causality_t;

#endif

Deleted mttroot/mtt/lib/cr/hh/components.hh version [2fc3af9d6e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef COMPONENTS_HH
#define COMPONENTS_HH

// $ cd $(echo $MTT_COMPONENTS/simple | sed 's/\.://')
// $ ls *_eqn.m | gawk -F_ '{printf ("%s, ", $1)}'
enum component {
  AE, AF, C, EBTF, EMTF, ES, FMR, FP, GY, I, PS, RST, RS, R, SS, TF,
  ae, af, c, ebtf, emtf, es, fmr, fp, gy, i, ps, rst, rs, r, ss, tf
};

typedef enum component component_t;
  

#endif

Deleted mttroot/mtt/lib/cr/hh/constants.hh version [65d242bd40].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
#ifndef CONSTANTS_HH
#define CONSTANTS_HH

const double	pi	= 3.14159264;
const double	pi2	= pi * pi;
const double	pi4	= pi2 * pi2;

// Reynolds number
const double	ReL	= 2300.0;	// transition from laminar flow
const double	ReT	= 4000.0;	// transition to turbulent flow

#endif // CONSTANTS

Deleted mttroot/mtt/lib/cr/hh/fade.hh version [ea57877552].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef FADE_HH
#define FADE_HH

#include <cmath>		// tanh

#include "constants.hh"		// pi

inline double
fade(const double x,
     const double x1,
     const double x2,
     const double y1,
     const double y2)
{
  /* fades two functions together smoothly over the range x1 to x2
   * function does not check that x2 > x1
   */
  double theta;
  theta = (x - x1) / (x2 - x1);		// map (linear)     {x1  , x2 } => {0   , +1 }
  theta = (theta - 0.5) * 2.0 * pi;	// map (linear)     {0   , +1 } => {-Pi , +Pi}
  theta = tanh(theta);			// map (non-linear) {-Pi , +Pi} => {-1  , +1 }
  theta = (theta + 1.0) / 2.0;		// map (linear)     {-1  , +1 } => {0   , +1 }

  return (theta * y1 + (1.0 - theta) * y2);
}

inline double
chkfade(const double x,
	const double x1,
	const double x2,
	const double y1,
	const double y2)
{
  double X1 = x1, X2 = x2;
  if (x1 > x2) {
    std::cerr << "* Warning: chkfade; x2 > x1, swapping" << std::endl;
    X1 = x2;
    X2 = x1;
  }
  return ((x <= X1) ? y1 : (x > X2) ? y2 : fade(x, X1, X2, y1, y2));
}

#endif // FADE_HH

Deleted mttroot/mtt/lib/cr/hh/frictionfactor.hh version [45faf85d37].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef FRICTIONFACTOR_HH
#define FRICTIONFACTOR_HH

#include <iostream>
#include <cmath>

#include "constants.hh"		// ReL, ReT
#include "fade.hh"

inline double
frictionfactor(const double Re, const double r) {
  if (0.0 == Re) {
    return 0.0;
  }
  else if (ReL >= Re) {		// laminar flow
    return 16.0 / Re;		// using k = 4.f.(l/d)
  } else if (ReT <= Re) {	// turbulent flow
    /* S.E.Haaland
     * Simple and explicit formulas for the friction factor in turbulent pipe flow
     * Journal of Fluids Engineering, 105 (1983)
     */
    double A = 6.91 / Re;
    double B = pow((r / 3.71), 1.11);
    double f = pow(-3.6 * log10(A + B), -2);
    return f;
  } else {			// transition region 
    double ffL = frictionfactor(ReL, r);
    double ffT = frictionfactor(ReT, r);
    return fade(Re, ReL, ReT, ffL, ffT);
  }
}

#endif // FRICTIONFACTOR_HH

Deleted mttroot/mtt/lib/cr/hh/kinematicviscosity.hh version [ebebe8b69e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef KINEMATICVISCOSITY_HH
#define KINEMATICVISCOSITY_HH

#include <cmath>		// pow
#include <string>

inline double
kerosenekinematicviscosity(const double T)
  /*
   * B.S.Massey
   * Mechanics of fluids
   * ISBN: 0 412 34280 4
   * log-log plot of kinematic viscosity versus temperature is linear for kerosene
   * L(n) = log10(n)
   *
   * T =   0 deg C : nu = 4.0 mm2/s
   * T = 100 deg C : nu = 0.9 mm2/s
   *
   * deg C => K, mm2/s => m2/s
   *
   * T1 = 273.15 : nu1 = 4.0e-6 m2/s
   * T2 = 373.15 : nu2 = 0.9e-6 m2/s
   *
   * L(nu) = m L(T) + c
   *
   *    m = (L(nu2) - L(nu1)) / (L(T2) - L(T1))
   *      = L(nu2/nu1) / L(T2/T1)
   *      = L(0.9/4.0) / L(373.15/273.15)
   *      = -4.781567507
   *
   *    c = L(nu1) - m * L(T1)
   *      = L(4.0e-6) - m * L(273.15)
   *      = 6.251876827 
   *
   * nu {m2/s} = 10^(m * L(T {Kelvin}) + c)
   *
   *    = 10^(m * L(T) + c)
   *    = 10^c * (10^L(T))^m
   *    = 10^c * T^m
   *
   * 10^c = 1.78598097e6
   * 
   * nu = 1.78598097e6 * T^(-4.781567507)
   */
{
  return 1.79e6 * pow(T, -4.78);
}

inline double
kinematicviscosity(const std::string fluid,
		   const double T)
{
  if ("kerosene" == fluid) {
    return kerosenekinematicviscosity(T);
  } else {
    std::cerr << __FILE__ << ": fluid \"" << fluid << "\" unknown" << std::endl;
    exit(-1);
  }
}

#endif // KINEMATICVISCOSITY_HH

Deleted mttroot/mtt/lib/cr/hh/lin.hh version [1652f288ca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef LIN_HH
#define LIN_HH

#include <iostream>

#include "causality.hh"
#include "components.hh"
// translated from lin.cr

// one 2-port, R/C/I; two 2-port, TF/GY
inline double
lin(const component_t	type,
    // parameters
    const causality_t	gain_causality,
    const double	gain,
    // output
    const causality_t	out_causality,
    const int		out_port,
    // input
    const double	input,
    const causality_t	in_causality,
    const int		in_port)
{
  if (out_port == in_port) {			  // R/C/I
    if (gain_causality == in_causality) {
      return input * gain;
    } else {
      return input / gain;
    }
  } else {					  // GY/TF
    if (out_causality == in_causality) {	// gyrator
      if ((out_port == 1 && out_causality != gain_causality)
	  ||(out_port == 2 && out_causality == gain_causality)) {
	return input * gain;
      } else {
	return input / gain;
      }
    } else {				// transformer
      if (out_causality == gain_causality) {
	return input * gain;
      } else {
	return input / gain;
      }
    }
  }
}

// two 2-port, AE/AF
inline double
lin(const component_t	type,
    // parameters
    const double	gain,
    // output
    const causality_t	out_causality,
    const int		out_port,
    // input
    const double	input,
    const causality_t	in_causality,
    const int		in_port)
{
  return
    (out_port == 1) ? input * gain :
    input / gain;
}




// three 2-port, FMR
inline double
lin(const component_t	type,
    // parameters
    const causality_t	gain_causality,
    const double	gain,
    // output
    const causality_t	out_causality,
    const int		out_port,
    // input
    const double	input,
    const causality_t	in_causality,
    const int		in_port,
    const double	modulation,
    const causality_t	mod_causality,
    const int		mod_port)
{
  if (mod_causality == flow) {		// uni-causal
    if (out_port == 2) {
      return 0;
    } else {
      double k = 1.0;
      if (gain_causality == in_causality) {
	k *= gain;
      } else {
	k /= gain;
      }
      if (in_causality == effort) {
	k *= modulation;
      } else {
	k /= modulation;
      }
      return input * k;
    }
  } else {				// bi-causal
    if ((in_causality == effort)
	&&(mod_causality == flow)
	&&(gain_causality == effort)
	&&(in_port == 1)
	&&(mod_port == 1)) {
      return (input / modulation) / gain;
    } else {

	// three 2-port, EMTF
	
	if ((out_causality == gain_causality && out_port == 2)
	    ||(out_causality != gain_causality && out_port == 1)) {
	  return input * gain * modulation;
	} else if((out_causality != gain_causality && out_port == 2)
		  ||(out_causality == gain_causality && out_port == 1)) {
	  return input / (gain * modulation);
	} else {
	  std::cerr << "* Error: __FILE__ does not cover this case" << std::endl;
	  exit(-1);
	}
    } // EMTF
  } // bi-causal
}


#endif // LIN_HH

Deleted mttroot/mtt/lib/cr/hh/pressuredrop.hh version [edb487c3ad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef PRESSUREDROP_HH
#define PRESSUREDROP_HH

#include <cmath>		// fabs, pow
#include <string>

#include "causality.hh"
#include "constants.hh"
#include "frictionfactor.hh"
#include "kinematicviscosity.hh"
#include "sign.hh"

inline double
pressuredrop(const std::string fluid,
	     const double d,
	     const double l,
	     const double r,
	     const double rho,
	     const double T,
	     const double Q)
{
  double nu = kinematicviscosity(fluid, T);
  double Re = 4.0 * fabs(Q) / (pi * d * nu);
  double f = frictionfactor(Re, r);
  double k = 4.0 * f * l / d;
  double dP = k * 8.0 * rho * pow(Q, 2) / (pi2 * pow(d, 4));
  return (dP * sign(Q));
}

inline double
pressuredrop(const std::string fluid,
	     const double d,
	     const double l,
	     const double r,
	     const double rho,
	     const double T,
	     const causality_t effort_causality, const int port,
	     const double Q, const causality_t flow_causality, const int port_in)
{
  
  /* assert(effort == causality);
   * assert(flow == causality_in);
   * assert(1 == port_in);
   * assert(1 == port);
   */
  return pressuredrop(fluid, d, l, r, rho, T, Q);
}

#endif // PRESSUREDROP_HH

Deleted mttroot/mtt/lib/cr/hh/sign.hh version [593009ad4f].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef SIGN_HH
#define SIGN_HH

template <class T>
inline int
sign(T x)
{
  return ((x > 0) ? +1 :
	  (x < 0) ? -1 :
	  0);
}

#endif // SIGN_HH

Deleted mttroot/mtt/lib/cr/hh/squarelaw.hh version [2920b23040].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef SQUARELAW_HH
#define SQUARELAW_HH

#include <cmath
#include "sign.hh"

#include "causality.hh"

inline double squarelaw(const double gain,
			const causality_t causality, const int port,
			const double input, const causality_t in_causality, const int in_port)
  /*
   * implements P = R Q^2
   * direction of flow is retained
   */
{
  if (causality == effort) {
    return pow(input, 2) * gain * sign(input * gain);
  } else {
    return sqrt(fabs(input / gain)) * sign(input / gain);
  }
}

#endif // SQUARELAE_HH

Deleted mttroot/mtt/lib/cr/hh/staticpressure.hh version [a1d4591eb9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef STATICPRESSURE_HH
#define STATICPRESSURE_HH

#include <cmath>		// log, pow

#include "causality.hh"
#include "constants.hh"

inline double
staticpressure(const double beta,
	       const double C_d,
	       const double d,
	       const double P_ref,
	       const double rho,
	       const causality_t causality, const int port,
	       const double Q1, const causality_t causality1, const int port1,
	       const double Q2, const causality_t causality2, const int port2)
{
  static double P;
  if (0.0 != Q1 && 0.0 != Q2) {
    double num = pi2 * pow(d, 4) * log(Q1 / Q2);
    double den = 8.0 * beta * rho * Q1 * (Q2 - Q1 + C_d * (Q1 + Q2) / 2.0);
    P = P_ref + log(num / den)/beta;
  }
    return P;
}

#endif // STATICPRESSUE_HH

Deleted mttroot/mtt/lib/cr/perl/Density.pm version [5a84b70eb1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156




























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::Density;

#-------------------------------------------------------------------------------
#		linear constitutive relationship with cosine modulation
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&Density);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub Density_r(@);		# R

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub Density (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^R|r$/)	{ $retval = Density_r	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# R
#-------------------------------------------------------------------------------
sub Density_r (@) {

    my @args = @_;
    my $retval = '';
    
    if ($#args == 15-1)
    {
	if ($args[2] eq 'ideal_gas')
	{
	    my ($component,
		$required_output,
		$law,
		$R,
		$out_causality,
		$out_port,
		$Pressure,
		$P_causality,
		$P_port,
		$Temperature,
		$T_causality,
		$T_port,
		$Nothing,
		$N_causality,
		$N_port) = @args;
	    
	    if (($P_causality eq 'effort') and
		($P_port == 1) and
		($T_causality eq 'effort') and
		($T_port == 2) and
		($N_causality eq 'flow') and
		($N_port == 3))
	    {
		if ($required_output eq 'density')
		{
		    return "(($Pressure)/(($R)*($Temperature)))";
		}
		elsif ($required_output eq 'specific_volume')
		{
		    return "(($R)*($Temperature)/($Pressure))";
		}
	    }
	}
	elsif ($args[2] eq 'incompressible')
	{
	    my ($component,
		$required_output,
		$law,
		$rho,
		$out_causality,
		$out_port,
		$Pressure,
		$P_causality,
		$P_port,
		$Temperature,
		$T_causality,
		$T_port,
		$Nothing,
		$N_causality,
		$N_port) = @args;
	    
	    if (($P_causality eq 'effort') and
		($P_port == 1) and
		($T_causality eq 'effort') and
		($T_port == 2) and
		($N_causality eq 'flow') and
		($N_port == 3))
	    {
		if ($required_output eq 'density')
		{
		    return "($rho)";
		}
		elsif ($required_output eq 'specific_volume')
		{
		    return "(1/($rho))";
		}
	    }
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Deleted mttroot/mtt/lib/cr/perl/Poly.pm version [c84d6eb22f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::Poly;

#-------------------------------------------------------------------------------
#		Polytropic constitutive relationship 
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&Poly);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub Poly_any(@);		# any component

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub Poly (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    $retval = Poly_any	(@args);
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# any component
#-------------------------------------------------------------------------------
sub Poly_any (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 16-1)
    {
	my ($component,
	    $alpha,
	    $out_causality,
	    $out_port,
	    $P1,
	    $in1_causality,
	    $in1_port,
	    $P2,
	    $in2_causality,
	    $in2_port,
	    $T1,
	    $in3_causality,
	    $in3_port,
	    $Nothing,
	    $in4_causality,
	    $in4_port) = @args;

	if (($in1_port == 1) and
	    ($in1_causality eq 'effort') and
	    ($in2_port == 2) and
	    ($in2_causality eq 'effort') and
	    ($in3_port == 3) and
	    ($in3_causality eq 'effort') and
	    ($in4_port == 4) and
	    ($in4_causality eq 'flow'))
	{
	    if ($out_port != 4)
	    {
		return "(0)";
	    }
	    elsif ($out_causality eq 'effort')
	    {
		# return temperature T2
		$retval = "($T1)*pow((($P2)/($P1)),($alpha))";
	    }
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Deleted mttroot/mtt/lib/cr/perl/apply_cr.pl version [41a7e19374].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/perl -w
#
#     apply_cr.pl - apply specified CRs to text on standard input
#     Copyright (C) 2004  Geraint Paul Bevan
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#		--------------------------
#		Model Transformation Tools
#		--------------------------
#
#
#-------------------------------------------------------------------------------

use strict;
use Getopt::Long;

my $cr_name='';
#-------------------------------------------------------------------------------
# arguments and options
#-------------------------------------------------------------------------------
my $crlist	= '';
my $debug	= 0;
my $help	= 0;

GetOptions ('debug'	=> \$debug,
	    'help'	=> \$help);

#-------------------------------------------------------------------------------
# globals
#-------------------------------------------------------------------------------

my @expressions;
my @prefixes;

my $expression;
my $i = 0;

#-------------------------------------------------------------------------------
# subroutine declarations
#-------------------------------------------------------------------------------
sub substitute_subexpressions();
sub process_expression();
sub display_subexpressions();
sub reassemble_expression();
sub usage();

#-------------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------------

if ($help) {
    usage();
    exit 1;
}

while (<STDIN>) {
    $expression = $_;
    print STDERR "Start Expression -> $expression\n" if $debug;

    $i = 0;
    @expressions = ();
    @prefixes = ();

    substitute_subexpressions();
    display_subexpressions () if ($debug);
    
    for ($i = 0; $i <= $#expressions; $i++) {
	process_expression ();
    }
    
    display_subexpressions () if ($debug);
    reassemble_expression ();
    print STDOUT "$expression";
}

#-------------------------------------------------------------------------------
# subroutines
#-------------------------------------------------------------------------------
sub substitute_subexpressions() {
    
    while ($expression =~ /\(.*\)/) {
	$_ = $expression;
	# get a matched pair of brackets
	s/ (.*) ( \({1} [^\(\)]* \){1} ) (.*) /$1 : $2 : $3/x;
	
	my $extracted;
	my $remainder;
	my $skipped;
	($skipped, $extracted, $remainder) = split (/ : /);
	
	$expressions[$i] = $extracted if $extracted;
	
	$_ = $skipped;
	s/(\s)//g;			# strip whitespace
	s/ (.*?) (\w*)$ /$2/x;	# get function name (if any)
	$prefixes[$i] = $_;
	$skipped =~ s/(.*)$prefixes[$i]$/$1/;
	
	$expression = "$skipped\{$i\}$remainder";
	
	$i++;
    }
    $expressions[$i] = $expression;
#    $prefixes[$i] = "";
}
#-------------------------------------------------------------------------------
sub process_expression() {

    my $cr = '';
    foreach my $cr_name (@ARGV) {	
	if ($prefixes[$i]) {
	    if ($prefixes[$i] eq $cr_name) {
		$cr = $cr_name;
	    }
	}
    }
    if ($cr eq '') {
	return;
    }

    # call cr(arg1,arg2,...) User-defined CR in the model directory
    if (-e "$cr.pm") {
	my $expr = $expressions[$i];
	eval "require $cr";
	$cr->import (@_[1 .. $#_]);    
	no strict 'refs';		# allow symbolic references
	my $substitution = &$cr ($expr);
	use strict 'refs';
	if ($substitution) {
	    $prefixes[$i] = "";
	    $expressions[$i] = "$substitution";
	}
    }
    # call cr(arg1,arg2,...) Standard CR in the mtt namespace
    if (-e "mtt/$cr.pm") {
	my $expr = $expressions[$i];
	my $mttcr = "mtt::$cr";
	eval "require 'mtt/$cr.pm'";
	$mttcr->import (@_[1 .. $#_]);
	no strict 'refs';		# allow symbolic references
	my $substitution = &$cr ($expr);
	use strict 'refs';
	if ($substitution) {
	    $prefixes[$i] = "";
	    $expressions[$i] = "$substitution";
	}
    }
}
#-------------------------------------------------------------------------------
sub display_subexpressions() {

    for ($i = 0; $i <= $#expressions; $i++) {
	my $prefix = " ";
	$prefix = $prefixes[$i] if ($prefixes[$i]); 
	print STDERR "$i\t($prefix)\t$expressions[$i]\n\n";
    }    
}
#-------------------------------------------------------------------------------
sub reassemble_expression () {

    $expression = $expressions[$#expressions];

    for ($i = $#expressions; $i >= 0; $i--) {
	print STDERR "{$i}: $expressions[$i]\n" if $debug;
	$expression =~ s/\{$i\}/$prefixes[$i]$expressions[$i]/g;
    }
    print STDERR "Final expression -> $expression\n" if $debug;
}
#-------------------------------------------------------------------------------
sub usage() {
    
    print STDOUT
	"\nUsage: $0 [options] crname1 crname2 ..\n" .
	"\n" .
	"\toptions:\n" .
	"\t--debug\n" .
	"\t--help\n" .
	"\n";
}

Deleted mttroot/mtt/lib/cr/perl/lcos.pm version [658fa3455b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::lcos;

#-------------------------------------------------------------------------------
#		linear constitutive relationship with cosine modulation
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&lcos);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub lcos_emtf(@);		# EMTF

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub lcos (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^EMTF|emtf$/)	{ $retval = lcos_emtf	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# EMTF
#-------------------------------------------------------------------------------
sub lcos_emtf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 11-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_port == 3) and
	     ($out_causality eq $in_causality))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*($gain)*(cos($mod_input)))";
	}
	elsif ((($mod_port == 3) and
		($out_causality eq $in_causality))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/(($gain)*(cos($mod_input))))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Deleted mttroot/mtt/lib/cr/perl/lin.pm version [961e5e7d01].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::lin;

#-------------------------------------------------------------------------------
#		Default linear constitutive relationship
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&lin);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub lin_amp (@);		# AE AF
sub lin_cir (@);		# C I R
sub lin_emtf(@);		# EMTF
sub lin_fmr (@);		# FMR
sub lin_gy  (@);		# GY
sub lin_tf  (@);		# TF

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub lin (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^AE|ae$/)	{ $retval = lin_amp	(@args); }
    if (/^AF|af$/)	{ $retval = lin_amp	(@args); }
    if (/^C|c$/)	{ $retval = lin_cir	(@args); }
    if (/^EMTF|emtf$/)	{ $retval = lin_emtf	(@args); }
    if (/^FMR|fmr$/)	{ $retval = lin_fmr	(@args); }
    if (/^GY|gy$/)	{ $retval = lin_gy	(@args); }
    if (/^I|i$/)	{ $retval = lin_cir	(@args); }
    if (/^R|r$/)	{ $retval = lin_cir	(@args); }
    if (/^TF|tf$/)	{ $retval = lin_tf	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# AE and AF
#-------------------------------------------------------------------------------
sub lin_amp (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1) {

	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;

	if (($out_port == 2) and
	    ($in_port  == 1))
	{			# uni-causal
	    $retval = "(($input)*($gain))";
	}

	elsif (($out_port == 1) and
	       ($in_port  == 2))
	{			# bi-causal
	    $retval = "(($input)/($gain))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# C, I and R
#-------------------------------------------------------------------------------
sub lin_cir (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;
	
	if (
	    ($out_port == 1)
	    and
	    ($in_port  == 1)
	    )
	{			# single port	    
	    if ($in_causality eq $gain_causality)
	    {
		$retval = "(($input)*($gain))";
	    }	    
	    elsif ($in_causality ne $gain_causality)
	    {
		$retval = "(($input)/($gain))";
	    }
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# EMTF
#-------------------------------------------------------------------------------
sub lin_emtf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 10-1)
    {				# modulation only
	my ($component,
	    $gain_causality,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_causality eq 'effort') and
	     ($mod_port == 3))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*($mod_input))";
	}
	elsif ((($mod_causality eq 'effort') and
		($mod_port == 3))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/($mod_input))";
	}
    }
    elsif ($#args == 11-1)
    {				# modulation and gain
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_causality eq 'effort') and
	     ($mod_port == 3))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*(($gain)*($mod_input)))";
	}
	elsif ((($mod_causality eq 'effort') and
		($mod_port == 3))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/(($gain)*($mod_input)))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}
#-------------------------------------------------------------------------------
# FMR
#-------------------------------------------------------------------------------
sub lin_fmr (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 7-1)
    {				# uni-causal
	# flow modulation multiplies effort on port 1 (or divides flow)
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $input,
	    $in_causality,
	    $mod_input) = @args;

	if (($gain_causality eq $in_causality) and
	    ($out_causality eq 'flow'))
	{
	    $retval = "(($input)*($gain)*($mod_input))";
	}
	elsif (($gain_causality eq $in_causality) and
	       ($out_causality eq 'effort'))
	{
	    $retval = "(($input)*($gain)/($mod_input))";
	}
	elsif (($gain_causality ne $in_causality) and
	       ($out_causality eq 'flow'))
	{
	    $retval = "(($input)*($mod_input)/($gain))";
	}
	elsif (($gain_causality ne $in_causality) and
	       ($out_causality eq 'effort'))
	{
	    $retval = "(($input)/(($gain)*($mod_input)))";
	}
    }
    elsif ($#args == 11-1)
    {				# bi-causal
	# deduces the flow on port 2
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $e_input,
	    $e_causality,
	    $e_port,
	    $f_input,
	    $f_causality,
	    $f_port) = @args;

	if (($gain_causality eq 'effort') and
	    ($out_causality eq 'flow') and
	    ($out_port == 2) and
	    ($e_causality eq 'effort') and
	    ($e_port == 1) and
	    ($f_causality eq 'flow') and
	    ($f_port == 1))
	{
	    $retval = "((($f_input)/($e_input))/($gain))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# GY
#-------------------------------------------------------------------------------
sub lin_gy (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;

	if (($out_causality ne $in_causality) and
	    ($out_port != $in_port)
	    and
	    (($out_causality ne $gain_causality) and
	     ($out_port == 2))
	    or
	    (($out_causality ne $gain_causality) and
	     ($out_port == 1)))
	{
	    $retval = "(($input)/($gain))";
	}

	elsif (($out_causality ne $in_causality) and
	       ($out_port != $in_port)
	       and
	       (($out_causality eq $gain_causality) and
		($out_port == 2))
	       or
	       (($out_causality eq $gain_causality) and
		($out_port == 1)))
	{
	    $retval = "(($input)*($gain))";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# TF
#-------------------------------------------------------------------------------
sub lin_tf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 8-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port) = @args;

	if (($out_causality eq $in_causality) and
	    ($out_port ne $in_port)
	    and
	    (($out_causality eq $gain_causality) and
	     ($out_port == 2))
	    or
	    (($out_causality ne $gain_causality) and
	     ($out_port == 1)))
	{
	    $retval = "(($input)*($gain))";
	}
	
	elsif (($out_causality eq $in_causality) and
	       ($out_port ne $in_port)
	       and
	       (($out_causality ne $gain_causality) and
		($out_port == 2))
	       or
	       (($out_causality eq $gain_causality) and
		($out_port == 1)))
	{
	    $retval = "(($input)/($gain))";
	}
    }

    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}
#-------------------------------------------------------------------------------
1;				# return true

Deleted mttroot/mtt/lib/cr/perl/lsin.pm version [965bba1c0f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package mtt::lsin;

#-------------------------------------------------------------------------------
#		linear constitutive relationship with sine modulation
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&lsin);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub lsin_emtf(@);		# EMTF

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub lsin (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^EMTF|emtf$/)	{ $retval = lsin_emtf	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# EMTF
#-------------------------------------------------------------------------------
sub lsin_emtf (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 11-1)
    {
	my ($component,
	    $gain_causality,
	    $gain,
	    $out_causality,
	    $out_port,
	    $input,
	    $in_causality,
	    $in_port,
	    $mod_input,
	    $mod_causality,
	    $mod_port) = @args;

	if ((($mod_port == 3) and
	     ($out_causality eq $in_causality))
	    and
	    ((($out_causality eq $gain_causality) and
	      ($out_port == 2))
	     or
	     (($out_causality ne $gain_causality) and
	      ($out_port == 1))))
	{
	    $retval = "(($input)*($gain)*(sin($mod_input)))";
	}
	elsif ((($mod_port == 3) and
		($out_causality eq $in_causality))
	       and
	       ((($out_causality ne $gain_causality) and
		 ($out_port == 2))
		or
		(($out_causality eq $gain_causality) and
		 ($out_port == 1))))
	{
	    $retval = "(($input)/(($gain)*(sin($mod_input))))";
	}
    }

    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Deleted mttroot/mtt/lib/cr/r/CT2.cr version [19581da283].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CT2    Constitutive Relationship for a two port thermo C
%DESCRIPTION Parameter 1: c_v (specific heat at constant volume)
%DESCRIPTION Parameter 2: gamma = c_p/c_v
%DESCRIPTION Parameter 3: mass of (ideal) gas within component.
%DESCRIPTION Parameter 4: t_0 -- the temperature at which internal
%DESCRIPTION energy is zero.

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/12/07 20:45:21  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR CT2;
Port 1 - Thermal
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,1,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = InternalEnergy/(m*c_v);

Port 2 - Mechanical
FOR ALL c_v,gamma,m,t_0,InternalEnergy,Volume
LET CT2(c_v,gamma,m,t_0,effort,2,
	InternalEnergy, state, 1,
	Volume, state, 2)
         = (gamma-1)*(InternalEnergy+c_v*m*t_0)/Volume;

Deleted mttroot/mtt/lib/cr/r/MA.cr version [2731f4363e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY MA: Mass-action kinetics for Re
%DESCRIPTION Parameter 1: kappa

OPERATOR MA;

%%% Two port version (standard)
FOR ALL n_out, A_f, A_r, kappa
LET MA(R, flow,kappa,flow,n_out,	
   A_f,effort,1,	
   A_r,effort,2) = kappa*(exp(A_f/RT) - exp(A_r/RT));


%%% Four port version (stoichiometric) with integral causality
%% Flows on ports 1 & 2 = flow on port 3.
FOR ALL A_f, A_r, v_1, v_2,kappa
LET MA(R, flow,kappa,flow,1,	
   A_f,effort,1,	
   A_r,effort,2,
   v_1,flow,3,
   v_2,effort,4) = v_1;

FOR ALL A_f, A_r, v_1, v_2,kappa
LET MA(R, flow,kappa,flow,2,	
   A_f,effort,1,	
   A_r,effort,2,
   v_1,flow,3,
   v_2,effort,4) = v_1;

%% Flow on port 4 is induced flow
FOR ALL A_f, A_r, v_1, v_2,kappa
LET MA(R, flow,kappa,flow,4,	
   A_f,effort,1,	
   A_r,effort,2,
   v_1,flow,3,
   v_2,effort,4) = kappa*(exp(A_f/RT) - exp(A_r/RT));

%%% Four port version (stoichiometric) with flow imposed on port 1
%% Flow on port 2 = flow on port 1
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,2,	
   v_1,flow,1,	
   A_2,effort,2,
   v_3,flow,3,
   A_4,effort,4) = v_1;

%% Flow on port 4 = flow on port 1
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,4,	
   v_1,flow,1,	
   A_2,effort,2,
   v_3,flow,3,
   A_4,effort,4) = v_1;

%% Effort on port 1
FOR ALL A_1,A_2,A_3,A_4,v_1,v_2,v_3,v_4,kappa
LET MA(R,flow,kappa,effort,1,
   v_1,flow,1,	
   A_2,effort,2,
   v_3,flow,3,
   A_4,effort,4) = RT*log( (v_1/kappa) + exp(A_2/RT) );


%%% Four port version (stoichiometric) with flow imposed on port 2

%% Flow on port 1 = flow on port 2
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,1,	
   A_1,effort,1,	
   v_2,flow,2,
   v_3,flow,3,
   A_4,effort,4) = v_2;

%% Flow on port 4 = flow on port 2
FOR ALL A_1,A_2,A_3,A_4, v_1,v_2,v_3,v_4, kappa
LET MA(R, flow,kappa,flow,4,	
   A_1,effort,1,	
   v_2,flow,2,
   v_3,flow,3,
   A_4,effort,4) = v_2;

%% Effort on port 2
FOR ALL A_1,A_2,A_3,A_4,v_1,v_2,v_3,v_4,kappa
LET MA(R,flow,kappa,effort,2,
   A_1,effort,1,	
   v_2,flow,2,
   v_3,flow,3,
   A_4,effort,4) = RT*log( (v_2/kappa) + exp(A_1/RT) );

%%% Five port version (stoichiometric) with integral causality
%% Flow on port 1  = flow on port 3.
FOR ALL A_f, A_r, v_f, v_r, v, kappa
LET MA(R, flow,kappa,flow,1,	
   A_f,effort,1,	
   A_r,effort,2,
   v_f,flow,3,
   v_r,flow,4,
   v,effort,5) = v_f;

%% Flow on port 2  = flow on port 4.
FOR ALL A_f, A_r, v_f, v_r, v, kappa
LET MA(R, flow,kappa,flow,2,	
   A_f,effort,1,	
   A_r,effort,2,
   v_f,flow,3,
   v_r,flow,4,
   v,effort,5) = v_r;

%% Flow on port 5 is induced flow
FOR ALL A_f, A_r, v_f, v_r, v, kappa
LET MA(R, flow,kappa,flow,5,	
   A_f,effort,1,	
   A_r,effort,2,
   v_f,flow,3,
   v_r,flow,4,
   v,effort,5) = kappa*(exp(A_f/RT) - exp(A_r/RT));


%% AE version
FOR ALL mu
LET MA(AE, effort,2, mu, effort,1) = exp(mu/RT);

Deleted mttroot/mtt/lib/cr/r/SS.cr version [0b96d2255a].

1
2
3



-
-
-
%% A dummy constitutive relationship file for SS 

END;;

Deleted mttroot/mtt/lib/cr/r/StefanBoltzmann.cr version [49afc9586a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY StefanBoltzmann: Stefan-Boltzmann radiation law.	
%DESCRIPTION Parameter 1: Stefan-Boltzmann constant
%DESCRIPTION Parameter 2: Area of radiating surface



OPERATOR StefanBoltzmann;


FOR ALL sigma,Area,input
LET StefanBoltzmann(sigma,Area,flow, 1, 
	input, effort, 1)
	 = sigma*area*input^4;


Deleted mttroot/mtt/lib/cr/r/cm.cr version [2b06c8ed91].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY cm: relation for 2-port CM component
%DESCRIPTION Parameter 1 capacitance at separation x_0
%DESCRIPTION Parameter 2 x_0
%DESCRIPTION parameter 3 moving-plate mass

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:18:38  peterg
% %% put under RCS
% %%
% %% Revision 1.1  1996/11/02  10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR cm;
%Linear electrical bit
FOR ALL comp,c_0,x_0,elec_state,mech_state LET
cm(comp,c_0,x_0,effort,1,
	elec_state,state,1,
	mech_state,state,2
	)
	= elec_state/(c_0*x_0/mech_state);

%Nonlinear mechanical bit
FOR ALL comp,c_0,x_0,elec_state,mech_state LET
cm(comp,c_0,x_0,effort,2,
	elec_state,state,1,
	mech_state,state,2
	)
	= -(c_0*x_0)*((elec_state/mech_state)^2)/2; 

END;;

Deleted mttroot/mtt/lib/cr/r/cp.cr version [40c7eabbcf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY cp    Chemical potential constitutive relationship

% This formula gives the Gibb's free energy for a reaction component
% with given concentration.
% k_e is the corresponding equilibrium constant.

% C version integral causality
FOR ALL  concentration, k_e, RT
LET cp(C,k_e,RT, effort, 1, 
        concentration, state, 1)
         = RT*log(k_e*concentration);

% C version derivative causality
FOR ALL  potential, k_e, RT
LET cp(C,k_e,RT, state, 1, 
        potential, effort, 1)
         = exp(potential/RT)/k_e;

%AE version
FOR ALL  concentration, RT
LET cp(AE,RT,effort,2,concentration,effort,1) 
        = RT*log(concentration);

%AE version with k_e
FOR ALL  concentration, k_e, RT
LET cp(AE,k_e,RT,effort,2,concentration,effort,1) 
        = RT*log(k_e*concentration);

Deleted mttroot/mtt/lib/cr/r/cr.cr version [40890d353a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY cr generic CR
%DESCRIPTION Argument is an algebraic expression with no embeddedwhite space
%DESCRIPTION Only available for one ports just now
%DESCRIPTION effort (or integrated effort) variable must be called mtt_e
%DESCRIPTION flow (or integrated flow) variable must be called mtt_f
%DESCRIPTION For example:
%DESCRIPTION             mtt_e=k*mtt_f
%DESCRIPTION             mtt_f=mtt_e/r

% $Log$
% Revision 1.5  2003/01/09 09:57:42  gawthrop
% Added dummy first argument (comp_type) to cr
%
% Revision 1.4  2000/12/28 09:18:38  peterg
% put under RCS
%
% Revision 1.3  2000/10/05 10:13:00  peterg
% New eqn2ass function.
% Started extension to multiports
%
% Revision 1.2  2000/10/03 18:35:04  peterg
% Removed comment bug
%
% Revision 1.1  2000/10/03 18:34:00  peterg
% Initial revision
%

%Copyright (C) 2000 by Peter J. Gawthrop


% Function to convert equation to assignment
OPERATOR eqn2ass;
FOR ALL comp_type, eqn,outlist,inputs 
LET eqn2ass(eqn,outlist,inputs) =
BEGIN
    ass := {}; mtt_ports := 0;
    solutions := solve(eqn,outlist);
    FOR EACH solution IN solutions DO
    BEGIN
       mtt_ports := mtt_ports + 1;
       rh := RHS(solution);
       FOR EACH input IN inputs DO
         rh := sub(input,rh);
       ass := APPEND(ass,{rh});
    END;
    IF mtt_ports EQ 1 THEN
      RETURN FIRST(ass) 
    ELSE
      RETURN ass; 

    %return sub(input,rhs(first(solve(eqn,outlist))));
    % Needs multiplicity warning
END;


OPERATOR cr;

% Version for one-port components

% We need four versions so that state does not need to be explicitly
% mentioned.
% At the moment, assume only one solution (in fact the first is
% chosen)

%%%% This is the Equation version
% Flow input
FOR ALL comp_type, mtt_cr, input, out_cause
LET cr(comp_type,mtt_cr,out_cause, 1, input, flow, 1) 
      = eqn2ass(mtt_cr,mtt_e,{mtt_f=input});

% Effort input
FOR ALL comp_type, mtt_cr, input, out_cause
LET cr(comp_type,mtt_cr,out_cause, 1, input, effort, 1)
    = eqn2ass(mtt_cr,mtt_f,{mtt_e=input});

% Effort output
FOR ALL comp_type, mtt_cr, input, in_cause
LET cr(comp_type,mtt_cr,effort, 1, input, in_cause, 1) 
    = eqn2ass(mtt_cr,mtt_e,{mtt_f=input});

% Flow output
FOR ALL comp_type, mtt_cr, input, in_cause
LET cr(comp_type,mtt_cr,flow, 1, input, in_cause, 1) 
    = eqn2ass(mtt_cr,mtt_f,{mtt_e=input});

%%%% This is the assignment version
% Flow input
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, out_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,out_cause, 1, input, flow, 1) 
    = sub(mtt_f=input,mtt_cr_f);

% Effort input
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, out_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,out_cause, 1, input, effort, 1) 
    = sub(mtt_e=input,mtt_cr_e);

% Effort output
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, in_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,effort, 1, input, in_cause, 1) 
    = sub(mtt_f=input,mtt_cr_f);

% Flow output
FOR ALL comp_type, mtt_cr_e,mtt_cr_f, input, in_cause
LET cr(comp_type,mtt_cr_e,mtt_cr_f,flow, 1, input, in_cause, 1) 
    = sub(mtt_e=input,mtt_cr_e);


%%% Q&D FMR 2 port.
FOR ALL comp_type, mtt_cr_e,mtt_cr_f,input_1,input_2
LET cr(comp_type,mtt_cr_e,mtt_cr_f,flow,1,
	input_1,effort,1,
	input_2,flow,2
	)  = sub(mtt_mod=input_2,sub(mtt_e=input_1,mtt_cr_e));

%% AE amplifier
FOR ALL  mtt_cr, input, out_cause
LET cr(ae,mtt_cr,effort, 2, 
        input, effort, 1)
    = eqn2ass(mtt_cr,mtt_2,{mtt_1=input});

END;

Deleted mttroot/mtt/lib/cr/r/defaultcr.r version [76c5822e3e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%Linear Constitutive Relationship for single port components: R,C,I.
% e = Gain*f (if gain_causality = flow) 
%           f = Gain*e (if gain_causality = effort)
OPERATOR lin;
FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality = gain_causality
LET lin(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = gain*input;

%Linear CR: e = (1/Gain)*f (if gain_causality = flow) 
%           f = (1/Gain)*e (if gain_causality = effort)
FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET lin(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = input/gain;


% Linear Constitutive Relationship for AE and AF
% Output = gain * input

% Unicausal form
FOR ALL gain, input, causality
LET lin(gain, causality, 2, input, causality, 1) = gain*input;

%Bicausal form
FOR ALL gain, output, causality
LET lin(gain, causality, 1, output, causality, 2) = output/gain;

% Linear Constitutive Relationship for TF
FOR ALL gain, input, causality, gain_causality, outport, inport
SUCH THAT (
	(causality = gain_causality) AND (outport = 2)
	OR
	(causality NEQ gain_causality) AND (outport = 1)
	)
LET lin(gain_causality, gain, causality, outport, input, causality, inport)
	 = gain*input;

FOR ALL gain, input, causality, gain_causality, outport, inport
SUCH THAT (
	(causality NEQ gain_causality) AND (outport = 2)
	OR
	(causality = gain_causality) AND (outport = 1)
	)
LET lin(gain_causality, gain, causality, outport, input, causality, inport)
	 = input/gain;

END;

Deleted mttroot/mtt/lib/cr/r/delta_h.cr version [3c6f66bca6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY delta_h	CR for gas turbine compressor


OPERATOR delta_h;

% Port 1 - generates delta h
FOR ALL c_p,Temperature,Massflow,DeltaT
LET delta_h(c_p, flow, 1,
		Temperature,effort,1,
		Massflow,flow,2,
		DeltaT,effort,3)
	 = Massflow*c_p*DeltaT;

% Port 2 - generates zero effort
FOR ALL c_p,Temperature,Massflow,DeltaT
LET delta_h(c_p, effort, 2,
		Temperature,effort,1,
		Massflow,flow,2,
		DeltaT,effort,3)
	 = 0;

% Port 3 - generates zero effort
FOR ALL c_p,Temperature,Massflow,DeltaT
LET delta_h(c_p, flow,3,
		Temperature,effort,1,
		Massflow,flow,2,
		DeltaT,effort,3)
	 = 0;



Deleted mttroot/mtt/lib/cr/r/lcos.cr version [09845c166a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY lcos	linear constitutive relationship with cos modulation
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship with cos modulation


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 17:51:02  peterg
% %% Added END
% %%
% %% Revision 1.1  1996/11/02 10:18:07  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR lcos;

%DESCRIPTION three port component: EMTF
FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality = gain_causality) AND (outport = 2)
	OR
	(causality NEQ gain_causality) AND (outport = 1)
	)
LET lcos(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = cos(m_input)*gain*input;

FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality NEQ gain_causality) AND (outport = 2)
	OR
	(causality = gain_causality) AND (outport = 1)
	)
LET lcos(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = input/(cos(m_input)*gain);

END;;

Deleted mttroot/mtt/lib/cr/r/lin.cr version [044595bc38].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229





































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY lin    linear constitutive relationship
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 09:19:07  peterg
% % put under RCS
% %
% % Revision 1.3  1998/07/04 10:47:04  peterg
% % back under RCS
% %
% % Revision 1.2  1998/03/04 15:38:54  peterg
% % Added END statement
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%DESCRIPTION    single port components: R,C,I
%Linear Constitutive Relationship for single port components: R,C,I.
% e = Gain*f (if gain_causality = flow) 
%           f = Gain*e (if gain_causality = effort)
OPERATOR lin;
FOR ALL comp_type,  gain_causality, gain, causality, input, other_causality
SUCH THAT causality = gain_causality
LET lin(comp_type,gain_causality, gain, other_causality, 1, input, causality, 1)
         = gain*input;

%Linear CR: e = (1/Gain)*f (if gain_causality = flow) 
%           f = (1/Gain)*e (if gain_causality = effort)
FOR ALL comp_type,  gain_causality, gain, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET lin(comp_type,gain_causality, gain, other_causality, 1, input, causality, 1)
         = input/gain;

%DESCRIPTION    two port components: AE, AF
% Linear Constitutive Relationship for AE and AF
% Output = gain * input

% Unicausal form
FOR ALL comp_type,  gain, input, causality
LET lin(comp_type,gain, causality, 2, input, causality, 1) = gain*input;

%Bicausal form
FOR ALL comp_type,  gain, output, causality
LET lin(comp_type,gain, causality, 1, output, causality, 2) = output/gain;

%DESCRIPTION   two port component: TF
% Linear Constitutive Relationship for TF
FOR ALL comp_type,  gain_causality, gain, causality, outport, input, same_causality, inport

SUCH THAT 
       ( causality = same_causality ) 
       AND 
       ( inport NEQ outport )
       AND
       (
       ( (causality = gain_causality) AND (outport = 2) )
       OR
       ( (causality NEQ gain_causality) AND (outport = 1) )
       )
LET lin(comp_type,gain_causality, gain, causality, outport, 
          input, same_causality, inport)
        = gain*input;

FOR ALL comp_type,  gain_causality, gain, causality, outport, 
        input, same_causality, inport
SUCH THAT 
       ( causality = same_causality ) 
       AND       
       ( inport NEQ outport )
       AND
       (
       ( (causality NEQ gain_causality) AND (outport = 2) )
       OR
       ( (causality = gain_causality) AND (outport = 1) )
       )
LET lin(comp_type,gain_causality, gain, causality, outport, 
         input, same_causality, inport)
        = input/gain;

%% This version in not reliable. I rellly need to pass component names
%% as cr arguments.

%DESCRIPTION    two port component: GY
% Linear Constitutive Relationship for GY

FOR ALL comp_type,  gain, input, causality, gain_causality, other_causality, 
        outport, inport
SUCH THAT 
        (causality NEQ other_causality) 
        AND
        ( inport NEQ outport )
        AND
        (
        ( (causality NEQ gain_causality) AND (outport = 2) )
        OR
        ( (causality NEQ gain_causality) AND (outport = 1) )
        )
LET lin(comp_type,gain_causality, gain, other_causality, outport, 
        input, causality, inport)
         = input/gain;

FOR ALL comp_type,  gain, input, causality, gain_causality, other_causality, 
        outport, inport
SUCH THAT 
        (causality NEQ other_causality) 
        AND
        ( inport NEQ outport )
        AND
        (
        ( (causality = gain_causality) AND (outport = 2) )
        OR
        ( (causality = gain_causality) AND (outport = 1) )
        )
LET lin(comp_type,gain_causality, gain, other_causality, outport, 
        input, causality, inport)
         = gain*input;

%DESCRIPTION    three port component: FMR

% Linear Constitutive Relationship for FMR - unicausal case
% Flow modulation multiplies effort on port 1 (or divides flow)

% The 4 possibilities follow...
FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality=in_causality) AND (out_causality=flow)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input*gain*mod_input;

FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality=in_causality) AND (out_causality=effort)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input*gain/mod_input;

FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality NEQ in_causality) AND (out_causality=flow)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input*mod_input/gain;

FOR ALL comp_type,  gain_causality, gain, out_causality, input, in_causality,
        mod_input
SUCH THAT (gain_causality NEQ in_causality) AND (out_causality=effort)
LET lin(comp_type,gain_causality, gain, out_causality, 1, 
                input, in_causality, 1,
                mod_input, flow, 2)
         = input/(gain*mod_input);

% Linear Constitutive Relationship for FMR - bicausal case
% Deduces the flow on port 2.

% The 2 possibilities follow...
FOR ALL comp_type,  gain,  e_input, f_input
LET lin(comp_type,effort, gain, flow, 2, 
                e_input, effort, 1,
                f_input, flow, 1)
         = (f_input/e_input)/gain;

%EMTF component - modulation only
% Linear Constitutive Relationship for EMTF
FOR ALL comp_type,  gain_causality, gain, causality, outport, input, same_causality, inport
SUCH THAT 
       ( (causality = gain_causality) AND (outport = 2) )
       OR
       ( (causality NEQ gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, causality, outport, 
          input, same_causality, inport,
	  gain, effort, 3)
        = gain*input;

FOR ALL comp_type,  gain_causality, gain, causality, outport, 
        input, same_causality, inport
SUCH THAT 
       ( (causality NEQ gain_causality) AND (outport = 2) )
       OR
       ( (causality = gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, causality, outport, 
         input, same_causality, inport,
	  gain, effort, 3)
        = input/gain;

%EMTF component - modulation and gain
% Linear Constitutive Relationship for EMTF
FOR ALL comp_type,  gain_causality, gain, causality, outport, input,
same_causality, inport, modulation
SUCH THAT 
       ( (causality = gain_causality) AND (outport = 2) )
       OR
       ( (causality NEQ gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, gain, causality, outport, 
          input, same_causality, inport,
	  modulation, effort, 3)
        = gain*modulation*input;

FOR ALL comp_type,  gain_causality, gain, causality, outport, 
        input, same_causality, inport, modulation
SUCH THAT 
       ( (causality NEQ gain_causality) AND (outport = 2) )
       OR
       ( (causality = gain_causality) AND (outport = 1) )
LET lin(comp_type,gain_causality, gain, causality, outport, 
         input, same_causality, inport,
	  modulation, effort, 3)
        = input/(gain*modulation);

END;;

Deleted mttroot/mtt/lib/cr/r/linx.cr version [1543a01070].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%%% linx - cr for single port I and C with an initial state x_0



%DESCRIPTION    linear cr for single port I and C with an initial state x0
%DESCRIPTION    only adds x0 if in integral causality


OPERATOR linx;

%% Input causality as specified
%Linear Constitutive Relationship for single port components: C,I.
% e = Gain*f (if gain_causality = flow) 
%           f = Gain*e (if gain_causality = effort)

FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT (causality = gain_causality) AND (causality = state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = gain*(input + x0);


FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT (causality = gain_causality) AND (causality NEQ state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = gain*(input);

%% Input causality not as specified
%Linear CR: e = (1/Gain)*f (if gain_causality = flow) 
%           f = (1/Gain)*e (if gain_causality = effort)

FOR ALL gain_causality, gain, x0, causality, input, other_causality
SUCH THAT (causality NEQ gain_causality) AND  (causality = state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = (input+x0)/gain;

FOR ALL gain_causality, gain, x0, causality, input, other_causality
SUCH THAT (causality NEQ gain_causality) AND  (causality NEQ state)
LET linx(gain_causality, gain, x0, other_causality, 1, input, causality, 1)
         = (input)/gain;




END;;

Deleted mttroot/mtt/lib/cr/r/lsin.cr version [0a475c4148].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY lsin	linear constitutive relationship with sin modulation
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:

%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship with sin modulation


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/04 17:51:37  peterg
% %% Added END
% %%
% %% Revision 1.1  1996/11/02 10:18:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR lsin;

%DESCRIPTION three port component: EMTF
FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality = gain_causality) AND (outport = 2)
	OR
	(causality NEQ gain_causality) AND (outport = 1)
	)
LET lsin(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = sin(m_input)*gain*input;

FOR ALL comp_type, gain, input, causality, gain_causality, outport, inport,
	 m_input, m_causality
SUCH THAT (
	(causality NEQ gain_causality) AND (outport = 2)
	OR
	(causality = gain_causality) AND (outport = 1)
	)
LET lsin(comp_type, gain_causality, gain, causality, outport, 
	input, causality, inport,
	m_input, m_causality, 3)
	 = input/(sin(m_input)*gain);

END;;

Deleted mttroot/mtt/lib/cr/r/oneway.cr version [a74db11764].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY oneway	One way constitutive relationship eg Diode
%DESCRIPTION Parameter 1 is a large number being the forward gain
%DESCRIPTION	-- the reciprocal is the backward gain
%DESCRIPTION The input must be an effort
%DESCRIPTION Typical use is an R component with effort input

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


OPERATOR oneway; 

%Input has flow causality
FOR ALL r,  input
LET oneway(r, effort, 1, input, flow, 1)
	 = ((1 - sign(input))/2)*r*input;

%Input has effort causality
FOR ALL r,  input
LET oneway(r, flow, 1, input, effort, 1)
	 = ((1 - sign(input))/2)*(1/r)*input;

Deleted mttroot/mtt/lib/cr/r/polytrop.cr version [e32e195400].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY polytrop	CR for gas turbine compressor


OPERATOR polytrop;

% Port 1 generates zero flow
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, flow, 1,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = 0;

% Port 2 generates deltaT
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, effort, 2,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = temperature*((Ipressure/Fpressure)^(gamma)-1);

% Port 3 generates zero flow
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, flow, 3,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = 0;

% Port 4 generates zero flow
FOR ALL Ipressure,temperature,Fpressure,gamma,enthflow
LET polytrop(gamma, flow, 4,
		Fpressure,effort,1,
		enthflow,flow,2,
		temperature,effort,3,
		Ipressure,effort,4)
	 = 0;

Deleted mttroot/mtt/lib/cr/r/powerlaw.cr version [18888cef83].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY powerlaw	powerlaw constitutive relationship
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort or flow
%DESCRIPTION Parameter 2 is the gain r corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


%DESCRIPTION	single port components: R

%Powerlaw Constitutive Relationship for single port components: R


OPERATOR powerlaw;
FOR ALL gain_causality, gain, power, causality, input, other_causality
SUCH THAT causality = gain_causality
LET powerlaw(gain_causality, gain, power, other_causality, 1, input, causality, 1)
	 = gain*(abs(input)^power)*sign(input);


FOR ALL gain_causality, gain, power, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET powerlaw(gain_causality, gain, power, other_causality, 1, input, causality, 1)
	 = ( (abs(input)/gain)^(1/power) )*sign(input);

END;

Deleted mttroot/mtt/lib/cr/r/reed.cr version [2dd994541f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY reed Nonlinear 2-port R for musical reed component


%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Linear constitutive relationship.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/11/02 10:21:19  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/09/12 11:18:26  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Linear Constitutive Relationship for reed - unicausal case with 
% pressure output.
OPERATOR reed,abs,sign;

% Port 1 - the modulated R
FOR ALL D,q,H,airflow,displacement
LET reed(D,q,H, effort, 1, 
		airflow,flow,1,
		displacement, effort,2)
	 = (D*sign(airflow)*(airflow)^q)/((H-displacement)^2);

% Port 2 - zero flow
FOR ALL D,q,H,airflow,displacement
LET reed(D,q, flow, 2, 
		airflow,flow,1,
		displacement, effort,2)
	 =0;

Deleted mttroot/mtt/lib/cr/r/sat_tank.cr version [95637b5048].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY sat_tank Saturation nonlinearity with variable slopes for tank
%DESCRIPTION Parameter 1 is the slope of the "normal" linear part of the CR
%DESCRIPTION Parameter 2 is the "large" slope
%DESCRIPTION Parameter 3 is the lower bound of the state
%DESCRIPTION Parameter 4 is the upper bound of the state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OPERATOR sign0;
FOR ALL x
	LET sign0(x) = (sign(x)+1)/2;

OPERATOR sat_tank; 
%Output has effort causality, input is state
FOR ALL k_0, k_1, x_0, x_1, x
LET sat_tank(k_0, k_1, x_0, x_1, effort, 1,
         x, state, 1)
	 = x*k_0 + (x-x_1)*(k_1-k_0)*sign0(x-x_1) + (x-x_0)*(k_1-k_0)*sign0(x_0-x);


Deleted mttroot/mtt/lib/cr/r/slcos.cr version [e42d3ee3a4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY slcos	linear constitutive relationship with sin modulation - sensitivity
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


OPERATOR slcos;

%DESCRIPTION four port component - effort i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slcos(gain, effort, 2, 
	input, effort, 1,
	junk, flow, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = -gain*sin(m_input)*dm_input*input;

%DESCRIPTION four port component - flow i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slcos(gain, flow, 2, 
	input, flow, 1,
	junk, effort, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = -gain*sin(m_input)*dm_input*input;

END;;

Deleted mttroot/mtt/lib/cr/r/slin.cr version [b68eb630ad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%DESCRIPTION Sensitivity version of lin

in "$MTT_CRS/r/lin.cr";

% One port version for historical reasons
OPERATOR slin;
FOR ALL gain_causality, gain, causality, input, other_causality
LET slin(gain_causality, gain, other_causality, 1, input, causality, 1)
         = lin(gain_causality, gain, other_causality, 1, input,
	 causality, 1);

% Two port version for sC,sI,sR 

% Port 1 - standard 
FOR ALL COMPONENT, gain_causality, gain, sgain, causality, input, sinput, other_causality
LET slin(COMPONENT,gain_causality, gain, sgain, other_causality, 1, 
       input, causality, 1,
       sinput, causality, 2)
         = lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               input, causality, 1); 


% Port 2 - sensitivity
FOR ALL COMPONENT, gain_causality, gain, sgain, causality, input, sinput, other_causality
SUCH THAT sgain NEQ 0
LET slin(COMPONENT,gain_causality, gain, sgain, other_causality, 2, 
       input, causality, 1,
       sinput, causality, 2)
         = lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               sinput, causality, 1)
         + sgain*df(lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               input, causality, 1), gain); 

%% Don't compute the derivative in this case
FOR ALL COMPONENT, gain_causality, gain, sgain, causality, input, sinput, other_causality
SUCH THAT sgain EQ 0
LET slin(COMPONENT,gain_causality, gain, sgain, other_causality, 2, 
       input, causality, 1,
       sinput, causality, 2)
         = lin(COMPONENT,gain_causality, gain, other_causality, 1, 
               sinput, causality, 1);
         

%% This is the version to go with sEMTF
%% It is the CR passed to the AE3 components

%DESCRIPTION four port component - effort i/o
FOR ALL COMPONENT, gain, input, junk, m_input, dm_input
LET slin(COMPONENT,gain, effort, 2, 
	input, effort, 1,
	junk, flow, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*dm_input*input;

%DESCRIPTION four port component - flow i/o
FOR ALL COMPONENT, gain, input, junk, m_input, dm_input
LET slin(COMPONENT,gain, flow, 2, 
	input, flow, 1,
	junk, effort, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*dm_input*input;

END;;






Deleted mttroot/mtt/lib/cr/r/slsin.cr version [68fd274f15].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY slsin	linear constitutive relationship with sin modulation - sensitivity
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort, flow or state
%DESCRIPTION Parameter 2 is the gain corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


OPERATOR slsin;

%DESCRIPTION four port component - effort i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slsin(gain, effort, 2, 
	input, effort, 1,
	junk, flow, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*cos(m_input)*dm_input*input;

%DESCRIPTION four port component - flow i/o
FOR ALL gain, input, junk, m_input, dm_input
LET slsin(gain, flow, 2, 
	input, flow, 1,
	junk, effort, 2,
	m_input, effort, 3,
        dm_input,effort, 4)
	 = gain*cos(m_input)*dm_input*input;

END;;

Deleted mttroot/mtt/lib/cr/r/square.cr version [34c368838f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY square	square-law constitutive relationship
%DESCRIPTION Parameter 1 defines input causality relating to parameter 2
%DESCRIPTION value is effort or flow
%DESCRIPTION Parameter 2 is the gain r corresponding to the causality of
%DESCRIPTION parameter 1.
%DESCRIPTION Supported components:


%DESCRIPTION	single port components: R

%Square-Law Constitutive Relationship for single port components: R
% output = Gain*input^2*sign(input) {if gain_causality = causality} 
% output = (1/Gain^(1/2))*input^(1/2)*sign(input) 
%		{if gain_causality not= causality} 



OPERATOR square;
FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality = gain_causality
LET square(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = gain*input^2*sign(input);


FOR ALL gain_causality, gain, causality, input, other_causality
SUCH THAT causality NEQ gain_causality
LET square(gain_causality, gain, other_causality, 1, input, causality, 1)
	 = input^(1/2)*sign(input)/(gain^(1/2));


END;

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Comb_abg.m version [64d72d515d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Comb] =  Comb_abg
# This function is the acausal bond graph representation of Comb
# Generated by MTT on Thu Mar 16 10:33:30 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hydraulic_in
  Comb.ports.Hydraulic_in.type = "SS";
  Comb.ports.Hydraulic_in.cr = "SS";
  Comb.ports.Hydraulic_in.arg = "external,external";
  Comb.ports.Hydraulic_in.repetitions = 1;
  Comb.ports.Hydraulic_in.status = -1;
  Comb.ports.Hydraulic_in.connections = [-3 ];

# Port Hydraulic_out
  Comb.ports.Hydraulic_out.type = "SS";
  Comb.ports.Hydraulic_out.cr = "SS";
  Comb.ports.Hydraulic_out.arg = "external,external";
  Comb.ports.Hydraulic_out.repetitions = 1;
  Comb.ports.Hydraulic_out.status = -1;
  Comb.ports.Hydraulic_out.connections = [7 ];

# Port Heat
  Comb.ports.Heat.type = "SS";
  Comb.ports.Heat.cr = "SS";
  Comb.ports.Heat.arg = "external,external";
  Comb.ports.Heat.repetitions = 1;
  Comb.ports.Heat.status = -1;
  Comb.ports.Heat.connections = [-5 ];

# Port Thermal_in
  Comb.ports.Thermal_in.type = "SS";
  Comb.ports.Thermal_in.cr = "SS";
  Comb.ports.Thermal_in.arg = "external,external";
  Comb.ports.Thermal_in.repetitions = 1;
  Comb.ports.Thermal_in.status = -1;
  Comb.ports.Thermal_in.connections = [-2 ];

# Port Thermal_out
  Comb.ports.Thermal_out.type = "SS";
  Comb.ports.Thermal_out.cr = "SS";
  Comb.ports.Thermal_out.arg = "external,external";
  Comb.ports.Thermal_out.repetitions = 1;
  Comb.ports.Thermal_out.status = -1;
  Comb.ports.Thermal_out.connections = [6 ];

# Component P
  Comb.subsystems.P.type = "SS";
  Comb.subsystems.P.cr = "SS";
  Comb.subsystems.P.arg = "external,0";
  Comb.subsystems.P.repetitions = 1;
  Comb.subsystems.P.status = -1;
  Comb.subsystems.P.connections = [9 ];

# Component T
  Comb.subsystems.T.type = "SS";
  Comb.subsystems.T.cr = "SS";
  Comb.subsystems.T.arg = "external,0";
  Comb.subsystems.T.repetitions = 1;
  Comb.subsystems.T.status = -1;
  Comb.subsystems.T.connections = [8 ];

# Component pipe
  Comb.subsystems.pipe.type = "hPipe";
  Comb.subsystems.pipe.cr = "none";
  Comb.subsystems.pipe.arg = "m_c;v_c;r";
  Comb.subsystems.pipe.repetitions = 1;
  Comb.subsystems.pipe.status = -1;
  Comb.subsystems.pipe.connections = [5 3 -4 2 -1 ];

# Component mtt1
  Comb.subsystems.mtt1.type = "0";
  Comb.subsystems.mtt1.cr = "";
  Comb.subsystems.mtt1.arg = "";
  Comb.subsystems.mtt1.repetitions = 1;
  Comb.subsystems.mtt1.status = -1;
  Comb.subsystems.mtt1.connections = [1 -6 -8 ];

# Component mtt2
  Comb.subsystems.mtt2.type = "0";
  Comb.subsystems.mtt2.cr = "";
  Comb.subsystems.mtt2.arg = "";
  Comb.subsystems.mtt2.repetitions = 1;
  Comb.subsystems.mtt2.status = -1;
  Comb.subsystems.mtt2.connections = [4 -7 -9 ];

# Ordered list of Port names
  Comb.portlist(1,:) = "Hydraulic_in ";
  Comb.portlist(2,:) = "Hydraulic_out";
  Comb.portlist(3,:) = "Heat         ";
  Comb.portlist(4,:) = "Thermal_in   ";
  Comb.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  Comb.subsystemlist(1,:) = "P   ";
  Comb.subsystemlist(2,:) = "T   ";
  Comb.subsystemlist(3,:) = "pipe";
  Comb.subsystemlist(4,:) = "mtt1";
  Comb.subsystemlist(5,:) = "mtt2";

# Bonds 
  Comb.bonds = [
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      1 1 
      1 1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Comb.alias.out = "Thermal_out,Hydraulic_out";
Comb.alias.Hy_out = "Hydraulic_out";
Comb.alias.v_c = "$2";
Comb.alias.Th_in = "Thermal_in";
Comb.alias.r = "$3";
Comb.alias.Th_out = "Thermal_out";
Comb.alias.in = "Thermal_in,Hydraulic_in";
Comb.alias.Hy_in = "Hydraulic_in";
Comb.alias.m_c = "$1";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Density_abg.m version [1b2d66d65e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Density] =  Density_abg
# This function is the acausal bond graph representation of Density
# Generated by MTT on Thu Mar 16 10:36:39 2000
# The file is in Octave format

# Subsystems and Ports

# Port Pressure
  Density.ports.Pressure.type = "SS";
  Density.ports.Pressure.cr = "SS";
  Density.ports.Pressure.arg = "external,external";
  Density.ports.Pressure.repetitions = 1;
  Density.ports.Pressure.status = -1;
  Density.ports.Pressure.connections = [-4 ];

# Port Temperature
  Density.ports.Temperature.type = "SS";
  Density.ports.Temperature.cr = "SS";
  Density.ports.Temperature.arg = "external,external";
  Density.ports.Temperature.repetitions = 1;
  Density.ports.Temperature.status = -1;
  Density.ports.Temperature.connections = [-5 ];

# Port Density
  Density.ports.Density.type = "SS";
  Density.ports.Density.cr = "SS";
  Density.ports.Density.arg = "external,external";
  Density.ports.Density.repetitions = 1;
  Density.ports.Density.status = -1;
  Density.ports.Density.connections = [3 ];

# Component r
  Density.subsystems.r.type = "R";
  Density.subsystems.r.cr = "Density";
  Density.subsystems.r.arg = "density,ideal_gas,r";
  Density.subsystems.r.repetitions = 1;
  Density.subsystems.r.status = -1;
  Density.subsystems.r.connections = [1 2 -3 ];

# Component mtt1
  Density.subsystems.mtt1.type = "AE";
  Density.subsystems.mtt1.cr = "";
  Density.subsystems.mtt1.arg = "";
  Density.subsystems.mtt1.repetitions = 1;
  Density.subsystems.mtt1.status = -1;
  Density.subsystems.mtt1.connections = [4 -1 ];

# Component mtt2
  Density.subsystems.mtt2.type = "AE";
  Density.subsystems.mtt2.cr = "";
  Density.subsystems.mtt2.arg = "";
  Density.subsystems.mtt2.repetitions = 1;
  Density.subsystems.mtt2.status = -1;
  Density.subsystems.mtt2.connections = [5 -2 ];

# Ordered list of Port names
  Density.portlist(1,:) = "Pressure   ";
  Density.portlist(2,:) = "Temperature";
  Density.portlist(3,:) = "Density    ";

# Ordered list of subsystem names
  Density.subsystemlist(1,:) = "r   ";
  Density.subsystemlist(2,:) = "mtt1";
  Density.subsystemlist(3,:) = "mtt2";

# Bonds 
  Density.bonds = [
      1 1 
      1 1 
      1 1 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
Density.alias.P = "Pressure";
Density.alias.out = "Density";
Density.alias.rho = "Density";
Density.alias.T = "Temperature";
Density.alias.density__ideal_gas__r = "$1";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Density_cr.r version [5fd3e01e3d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for Density (Density_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Density;

% Ideal gas
FOR ALL R,Temperature,Pressure,Nothing
LET Density(density,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = Pressure/(R*Temperature);

FOR ALL R,Temperature,Pressure,Nothing
LET Density(specific_volume,ideal_gas,R,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = (R*Temperature)/Pressure;

% Incompressible
FOR ALL rho,Temperature,Pressure,Nothing
LET Density(density,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = rho;

FOR ALL rho,Temperature,Pressure,Nothing
LET Density(specific_volume,incompressible,rho,effort,3,
	Pressure,effort,1,
	Temperature,effort,2,
	Nothing,flow,3
	) = 1/rho;

END;

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/In_abg.m version [39b730b677].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [In] =  In_abg
# This function is the acausal bond graph representation of In
# Generated by MTT on Thu Mar 16 10:33:58 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hy_out
  In.ports.Hy_out.type = "SS";
  In.ports.Hy_out.cr = "SS";
  In.ports.Hy_out.arg = "external,external";
  In.ports.Hy_out.repetitions = 1;
  In.ports.Hy_out.status = -1;
  In.ports.Hy_out.connections = [2 ];

# Port Th_out
  In.ports.Th_out.type = "SS";
  In.ports.Th_out.cr = "SS";
  In.ports.Th_out.arg = "external,external";
  In.ports.Th_out.repetitions = 1;
  In.ports.Th_out.status = -1;
  In.ports.Th_out.connections = [1 ];

# Component Hy_in
  In.subsystems.Hy_in.type = "SS";
  In.subsystems.Hy_in.cr = "SS";
  In.subsystems.Hy_in.arg = "p_1,internal";
  In.subsystems.Hy_in.repetitions = 1;
  In.subsystems.Hy_in.status = -1;
  In.subsystems.Hy_in.connections = [-2 ];

# Component Th_in
  In.subsystems.Th_in.type = "SS";
  In.subsystems.Th_in.cr = "SS";
  In.subsystems.Th_in.arg = "t_1,internal";
  In.subsystems.Th_in.repetitions = 1;
  In.subsystems.Th_in.status = -1;
  In.subsystems.Th_in.connections = [-1 ];

# Ordered list of Port names
  In.portlist(1,:) = "Hy_out";
  In.portlist(2,:) = "Th_out";

# Ordered list of subsystem names
  In.subsystemlist(1,:) = "Hy_in";
  In.subsystemlist(2,:) = "Th_in";

# Bonds 
  In.bonds = [
      1 1 
      1 1 
      ];

# Aliases 
# A double underscore __ represents a comma 
In.alias.out = "Th_out,Hy_out";
In.alias.in = "Th_out,Hy_out";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/In_desc.tex version [0c97485c1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Load_abg.m version [ebdf741bae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Load] =  Load_abg
# This function is the acausal bond graph representation of Load
# Generated by MTT on Thu Mar 16 10:34:27 2000
# The file is in Octave format

# Subsystems and Ports

# Port in
  Load.ports.in.type = "SS";
  Load.ports.in.cr = "SS";
  Load.ports.in.arg = "external,external";
  Load.ports.in.repetitions = 1;
  Load.ports.in.status = -1;
  Load.ports.in.connections = [-1 ];

# Port out
  Load.ports.out.type = "SS";
  Load.ports.out.cr = "SS";
  Load.ports.out.arg = "external,external";
  Load.ports.out.repetitions = 1;
  Load.ports.out.status = -1;
  Load.ports.out.connections = [3 ];

# Component PowerSensor
  Load.subsystems.PowerSensor.type = "PS";
  Load.subsystems.PowerSensor.cr = "";
  Load.subsystems.PowerSensor.arg = "";
  Load.subsystems.PowerSensor.repetitions = 1;
  Load.subsystems.PowerSensor.status = -1;
  Load.subsystems.PowerSensor.connections = [1 -2 -3 ];

# Component r_l
  Load.subsystems.r_l.type = "R";
  Load.subsystems.r_l.cr = "lin";
  Load.subsystems.r_l.arg = "flow,r_l";
  Load.subsystems.r_l.repetitions = 1;
  Load.subsystems.r_l.status = -1;
  Load.subsystems.r_l.connections = [2 ];

# Ordered list of Port names
  Load.portlist(1,:) = "in ";
  Load.portlist(2,:) = "out";

# Ordered list of subsystem names
  Load.subsystemlist(1,:) = "PowerSensor";
  Load.subsystemlist(2,:) = "r_l        ";

# Bonds 
  Load.bonds = [
      0 0 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
Load.alias.out = "out";
Load.alias.r_l = "$2";
Load.alias.in = "in";
Load.alias.PowerSensor = "$1";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Out_abg.m version [06caed529c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Out] =  Out_abg
# This function is the acausal bond graph representation of Out
# Generated by MTT on Thu Mar 16 10:34:51 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hy_in
  Out.ports.Hy_in.type = "SS";
  Out.ports.Hy_in.cr = "SS";
  Out.ports.Hy_in.arg = "external,external";
  Out.ports.Hy_in.repetitions = 1;
  Out.ports.Hy_in.status = -1;
  Out.ports.Hy_in.connections = [-1 ];

# Port Th_in
  Out.ports.Th_in.type = "SS";
  Out.ports.Th_in.cr = "SS";
  Out.ports.Th_in.arg = "external,external";
  Out.ports.Th_in.repetitions = 1;
  Out.ports.Th_in.status = -1;
  Out.ports.Th_in.connections = [-2 ];

# Component Hy_out
  Out.subsystems.Hy_out.type = "SS";
  Out.subsystems.Hy_out.cr = "SS";
  Out.subsystems.Hy_out.arg = "p_1,internal";
  Out.subsystems.Hy_out.repetitions = 1;
  Out.subsystems.Hy_out.status = -1;
  Out.subsystems.Hy_out.connections = [1 ];

# Component Th_out
  Out.subsystems.Th_out.type = "SS";
  Out.subsystems.Th_out.cr = "SS";
  Out.subsystems.Th_out.arg = "t_1,internal";
  Out.subsystems.Th_out.repetitions = 1;
  Out.subsystems.Th_out.status = -1;
  Out.subsystems.Th_out.connections = [2 ];

# Ordered list of Port names
  Out.portlist(1,:) = "Hy_in";
  Out.portlist(2,:) = "Th_in";

# Ordered list of subsystem names
  Out.subsystemlist(1,:) = "Hy_out";
  Out.subsystemlist(2,:) = "Th_out";

# Bonds 
  Out.bonds = [
      -1 -1 
      -1 -1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Out.alias.in = "Th_in,Hy_in";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Out_desc.tex version [3dd57dc573].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Poly_abg.m version [efdf7b7d95].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Poly] =  Poly_abg
# This function is the acausal bond graph representation of Poly
# Generated by MTT on Thu Mar 16 10:35:48 2000
# The file is in Octave format

# Subsystems and Ports

# Port Pressure_1
  Poly.ports.Pressure_1.type = "SS";
  Poly.ports.Pressure_1.cr = "SS";
  Poly.ports.Pressure_1.arg = "external,external";
  Poly.ports.Pressure_1.repetitions = 1;
  Poly.ports.Pressure_1.status = -1;
  Poly.ports.Pressure_1.connections = [-2 ];

# Port Temperature_1
  Poly.ports.Temperature_1.type = "SS";
  Poly.ports.Temperature_1.cr = "SS";
  Poly.ports.Temperature_1.arg = "external,external";
  Poly.ports.Temperature_1.repetitions = 1;
  Poly.ports.Temperature_1.status = -1;
  Poly.ports.Temperature_1.connections = [-6 ];

# Port Pressure_2
  Poly.ports.Pressure_2.type = "SS";
  Poly.ports.Pressure_2.cr = "SS";
  Poly.ports.Pressure_2.arg = "external,external";
  Poly.ports.Pressure_2.repetitions = 1;
  Poly.ports.Pressure_2.status = -1;
  Poly.ports.Pressure_2.connections = [-4 ];

# Port Temperature_2
  Poly.ports.Temperature_2.type = "SS";
  Poly.ports.Temperature_2.cr = "SS";
  Poly.ports.Temperature_2.arg = "external,external";
  Poly.ports.Temperature_2.repetitions = 1;
  Poly.ports.Temperature_2.status = -1;
  Poly.ports.Temperature_2.connections = [8 ];

# Component r
  Poly.subsystems.r.type = "R";
  Poly.subsystems.r.cr = "Poly";
  Poly.subsystems.r.arg = "alpha";
  Poly.subsystems.r.repetitions = 1;
  Poly.subsystems.r.status = -1;
  Poly.subsystems.r.connections = [1 3 5 -7 ];

# Component zero
  Poly.subsystems.zero.type = "SS";
  Poly.subsystems.zero.cr = "SS";
  Poly.subsystems.zero.arg = "0,0";
  Poly.subsystems.zero.repetitions = 1;
  Poly.subsystems.zero.status = -1;
  Poly.subsystems.zero.connections = [-9 ];

# Component mtt1
  Poly.subsystems.mtt1.type = "AE";
  Poly.subsystems.mtt1.cr = "";
  Poly.subsystems.mtt1.arg = "";
  Poly.subsystems.mtt1.repetitions = 1;
  Poly.subsystems.mtt1.status = -1;
  Poly.subsystems.mtt1.connections = [2 -1 ];

# Component mtt2
  Poly.subsystems.mtt2.type = "AE";
  Poly.subsystems.mtt2.cr = "";
  Poly.subsystems.mtt2.arg = "";
  Poly.subsystems.mtt2.repetitions = 1;
  Poly.subsystems.mtt2.status = -1;
  Poly.subsystems.mtt2.connections = [4 -3 ];

# Component mtt3
  Poly.subsystems.mtt3.type = "AE";
  Poly.subsystems.mtt3.cr = "";
  Poly.subsystems.mtt3.arg = "";
  Poly.subsystems.mtt3.repetitions = 1;
  Poly.subsystems.mtt3.status = -1;
  Poly.subsystems.mtt3.connections = [6 -5 ];

# Component mtt4
  Poly.subsystems.mtt4.type = "1";
  Poly.subsystems.mtt4.cr = "";
  Poly.subsystems.mtt4.arg = "";
  Poly.subsystems.mtt4.repetitions = 1;
  Poly.subsystems.mtt4.status = -1;
  Poly.subsystems.mtt4.connections = [7 -8 9 ];

# Ordered list of Port names
  Poly.portlist(1,:) = "Pressure_1   ";
  Poly.portlist(2,:) = "Temperature_1";
  Poly.portlist(3,:) = "Pressure_2   ";
  Poly.portlist(4,:) = "Temperature_2";

# Ordered list of subsystem names
  Poly.subsystemlist(1,:) = "r   ";
  Poly.subsystemlist(2,:) = "zero";
  Poly.subsystemlist(3,:) = "mtt1";
  Poly.subsystemlist(4,:) = "mtt2";
  Poly.subsystemlist(5,:) = "mtt3";
  Poly.subsystemlist(6,:) = "mtt4";

# Bonds 
  Poly.bonds = [
      1 1 
      0 0 
      1 1 
      0 0 
      1 1 
      0 0 
      0 0 
      0 0 
      1 -1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Poly.alias.out = "Temperature_2";
Poly.alias.P1 = "Pressure_1";
Poly.alias.P2 = "Pressure_2";
Poly.alias.T1 = "Temperature_1";
Poly.alias.T2 = "Temperature_2";
Poly.alias.alpha = "$1";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Poly_cr.r version [ad1eaacee8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for Poly (Poly_cr.r)
% Generated by MTT at Wed Mar 11 11:01:28 GMT 1998

OPERATOR Poly;

% Ideal gas

% Temperature output on port [T2]
FOR ALL alpha,P1,P2,T1,Nothing
LET Poly(alpha,effort,4,
	P1,effort,1,
	P2,effort,2,
	T1,effort,3,
	Nothing,flow,4
	) = T1*(P2/P1)^alpha;



END;

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/Pump_abg.m version [3fd343e8e9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180




















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [Pump] =  Pump_abg
# This function is the acausal bond graph representation of Pump
# Generated by MTT on Thu Mar 16 10:38:10 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hydraulic_in
  Pump.ports.Hydraulic_in.type = "SS";
  Pump.ports.Hydraulic_in.cr = "SS";
  Pump.ports.Hydraulic_in.arg = "external,external";
  Pump.ports.Hydraulic_in.repetitions = 1;
  Pump.ports.Hydraulic_in.status = -1;
  Pump.ports.Hydraulic_in.connections = [-5 ];

# Port Hydraulic_out
  Pump.ports.Hydraulic_out.type = "SS";
  Pump.ports.Hydraulic_out.cr = "SS";
  Pump.ports.Hydraulic_out.arg = "external,external";
  Pump.ports.Hydraulic_out.repetitions = 1;
  Pump.ports.Hydraulic_out.status = -1;
  Pump.ports.Hydraulic_out.connections = [6 ];

# Port Shaft
  Pump.ports.Shaft.type = "SS";
  Pump.ports.Shaft.cr = "SS";
  Pump.ports.Shaft.arg = "external,external";
  Pump.ports.Shaft.repetitions = 1;
  Pump.ports.Shaft.status = -1;
  Pump.ports.Shaft.connections = [-12 ];

# Port Thermal_in
  Pump.ports.Thermal_in.type = "SS";
  Pump.ports.Thermal_in.cr = "SS";
  Pump.ports.Thermal_in.arg = "external,external";
  Pump.ports.Thermal_in.repetitions = 1;
  Pump.ports.Thermal_in.status = -1;
  Pump.ports.Thermal_in.connections = [-4 ];

# Port Thermal_out
  Pump.ports.Thermal_out.type = "SS";
  Pump.ports.Thermal_out.cr = "SS";
  Pump.ports.Thermal_out.arg = "external,external";
  Pump.ports.Thermal_out.repetitions = 1;
  Pump.ports.Thermal_out.status = -1;
  Pump.ports.Thermal_out.connections = [16 ];

# Component pipe
  Pump.subsystems.pipe.type = "wPipe";
  Pump.subsystems.pipe.cr = "none";
  Pump.subsystems.pipe.arg = "c_v;density,ideal_gas,r";
  Pump.subsystems.pipe.repetitions = 1;
  Pump.subsystems.pipe.status = -1;
  Pump.subsystems.pipe.connections = [3 -7 14 2 -1 ];

# Component poly
  Pump.subsystems.poly.type = "Poly";
  Pump.subsystems.poly.cr = "Poly";
  Pump.subsystems.poly.arg = "alpha";
  Pump.subsystems.poly.repetitions = 1;
  Pump.subsystems.poly.status = -1;
  Pump.subsystems.poly.connections = [9 8 11 -10 ];

# Component T
  Pump.subsystems.T.type = "SS";
  Pump.subsystems.T.cr = "SS";
  Pump.subsystems.T.arg = "external,0";
  Pump.subsystems.T.repetitions = 1;
  Pump.subsystems.T.status = -1;
  Pump.subsystems.T.connections = [17 ];

# Component k_p
  Pump.subsystems.k_p.type = "TF";
  Pump.subsystems.k_p.cr = "lin";
  Pump.subsystems.k_p.arg = "flow,k_p";
  Pump.subsystems.k_p.repetitions = 1;
  Pump.subsystems.k_p.status = -1;
  Pump.subsystems.k_p.connections = [13 -14 ];

# Component mtt1
  Pump.subsystems.mtt1.type = "0";
  Pump.subsystems.mtt1.cr = "";
  Pump.subsystems.mtt1.arg = "";
  Pump.subsystems.mtt1.repetitions = 1;
  Pump.subsystems.mtt1.status = -1;
  Pump.subsystems.mtt1.connections = [1 10 -15 -17 ];

# Component mtt2
  Pump.subsystems.mtt2.type = "0";
  Pump.subsystems.mtt2.cr = "";
  Pump.subsystems.mtt2.arg = "";
  Pump.subsystems.mtt2.repetitions = 1;
  Pump.subsystems.mtt2.status = -1;
  Pump.subsystems.mtt2.connections = [-6 7 -11 ];

# Component mtt3
  Pump.subsystems.mtt3.type = "0";
  Pump.subsystems.mtt3.cr = "";
  Pump.subsystems.mtt3.arg = "";
  Pump.subsystems.mtt3.repetitions = 1;
  Pump.subsystems.mtt3.status = -1;
  Pump.subsystems.mtt3.connections = [-3 5 -9 ];

# Component mtt4
  Pump.subsystems.mtt4.type = "0";
  Pump.subsystems.mtt4.cr = "";
  Pump.subsystems.mtt4.arg = "";
  Pump.subsystems.mtt4.repetitions = 1;
  Pump.subsystems.mtt4.status = -1;
  Pump.subsystems.mtt4.connections = [-2 4 -8 ];

# Component mtt5
  Pump.subsystems.mtt5.type = "EBTF";
  Pump.subsystems.mtt5.cr = "";
  Pump.subsystems.mtt5.arg = "";
  Pump.subsystems.mtt5.repetitions = 1;
  Pump.subsystems.mtt5.status = -1;
  Pump.subsystems.mtt5.connections = [15 -16 ];

# Component mtt6
  Pump.subsystems.mtt6.type = "1";
  Pump.subsystems.mtt6.cr = "";
  Pump.subsystems.mtt6.arg = "";
  Pump.subsystems.mtt6.repetitions = 1;
  Pump.subsystems.mtt6.status = -1;
  Pump.subsystems.mtt6.connections = [12 -13 ];

# Ordered list of Port names
  Pump.portlist(1,:) = "Hydraulic_in ";
  Pump.portlist(2,:) = "Hydraulic_out";
  Pump.portlist(3,:) = "Shaft        ";
  Pump.portlist(4,:) = "Thermal_in   ";
  Pump.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  Pump.subsystemlist(1,:) = "pipe";
  Pump.subsystemlist(2,:) = "poly";
  Pump.subsystemlist(3,:) = "T   ";
  Pump.subsystemlist(4,:) = "k_p ";
  Pump.subsystemlist(5,:) = "mtt1";
  Pump.subsystemlist(6,:) = "mtt2";
  Pump.subsystemlist(7,:) = "mtt3";
  Pump.subsystemlist(8,:) = "mtt4";
  Pump.subsystemlist(9,:) = "mtt5";
  Pump.subsystemlist(10,:) = "mtt6";

# Bonds 
  Pump.bonds = [
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      -1 -1 
      0 0 
      0 0 
      0 0 
      0 0 
      1 1 
      ];

# Aliases 
# A double underscore __ represents a comma 
Pump.alias.out = "Thermal_out,Hydraulic_out";
Pump.alias.Hy_out = "Hydraulic_out";
Pump.alias.c_v = "$1";
Pump.alias.flow__k_p = "$4";
Pump.alias.Th_in = "Thermal_in";
Pump.alias.Th_out = "Thermal_out";
Pump.alias.Work = "Shaft";
Pump.alias.alpha = "$3";
Pump.alias.in = "Thermal_in,Hydraulic_in";
Pump.alias.Hy_in = "Hydraulic_in";
Pump.alias.density__ideal_gas__r = "$2";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_abg.m version [43a702b612].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165





































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [SimpleGasTurbineABG] =  SimpleGasTurbineABG_abg
# This function is the acausal bond graph representation of SimpleGasTurbineABG
# Generated by MTT on Thu Mar 16 12:59:12 2000
# The file is in Octave format

# Subsystems and Ports

# Component c1
  SimpleGasTurbineABG.subsystems.c1.type = "Comb";
  SimpleGasTurbineABG.subsystems.c1.cr = "none";
  SimpleGasTurbineABG.subsystems.c1.arg = "m_c;v_c;r";
  SimpleGasTurbineABG.subsystems.c1.repetitions = 1;
  SimpleGasTurbineABG.subsystems.c1.status = -1;
  SimpleGasTurbineABG.subsystems.c1.connections = [14 -15 7 10 -11 ];

# Component j_s
  SimpleGasTurbineABG.subsystems.j_s.type = "I";
  SimpleGasTurbineABG.subsystems.j_s.cr = "lin";
  SimpleGasTurbineABG.subsystems.j_s.arg = "flow,j_s";
  SimpleGasTurbineABG.subsystems.j_s.repetitions = 1;
  SimpleGasTurbineABG.subsystems.j_s.status = -1;
  SimpleGasTurbineABG.subsystems.j_s.connections = [2 ];

# Component comp
  SimpleGasTurbineABG.subsystems.comp.type = "Pump";
  SimpleGasTurbineABG.subsystems.comp.cr = "none";
  SimpleGasTurbineABG.subsystems.comp.arg = "c_v;density,ideal_gas,r;alpha;effort,k";
  SimpleGasTurbineABG.subsystems.comp.repetitions = 1;
  SimpleGasTurbineABG.subsystems.comp.status = -1;
  SimpleGasTurbineABG.subsystems.comp.connections = [16 -14 1 12 -10 ];

# Component turb
  SimpleGasTurbineABG.subsystems.turb.type = "Pump";
  SimpleGasTurbineABG.subsystems.turb.cr = "none";
  SimpleGasTurbineABG.subsystems.turb.arg = "c_v;density,ideal_gas,r;alpha;effort,k";
  SimpleGasTurbineABG.subsystems.turb.repetitions = 1;
  SimpleGasTurbineABG.subsystems.turb.status = -1;
  SimpleGasTurbineABG.subsystems.turb.connections = [15 -17 -6 11 -13 ];

# Component Work
  SimpleGasTurbineABG.subsystems.Work.type = "SS";
  SimpleGasTurbineABG.subsystems.Work.cr = "SS";
  SimpleGasTurbineABG.subsystems.Work.arg = "0,external";
  SimpleGasTurbineABG.subsystems.Work.repetitions = 1;
  SimpleGasTurbineABG.subsystems.Work.status = -1;
  SimpleGasTurbineABG.subsystems.Work.connections = [4 ];

# Component Heat
  SimpleGasTurbineABG.subsystems.Heat.type = "SS";
  SimpleGasTurbineABG.subsystems.Heat.cr = "SS";
  SimpleGasTurbineABG.subsystems.Heat.arg = "0,external";
  SimpleGasTurbineABG.subsystems.Heat.repetitions = 1;
  SimpleGasTurbineABG.subsystems.Heat.status = -1;
  SimpleGasTurbineABG.subsystems.Heat.connections = [9 ];

# Component Speed
  SimpleGasTurbineABG.subsystems.Speed.type = "SS";
  SimpleGasTurbineABG.subsystems.Speed.cr = "SS";
  SimpleGasTurbineABG.subsystems.Speed.arg = "0,external";
  SimpleGasTurbineABG.subsystems.Speed.repetitions = 1;
  SimpleGasTurbineABG.subsystems.Speed.status = -1;
  SimpleGasTurbineABG.subsystems.Speed.connections = [5 ];

# Component T3
  SimpleGasTurbineABG.subsystems.T3.type = "SS";
  SimpleGasTurbineABG.subsystems.T3.cr = "SS";
  SimpleGasTurbineABG.subsystems.T3.arg = "external,external";
  SimpleGasTurbineABG.subsystems.T3.repetitions = 1;
  SimpleGasTurbineABG.subsystems.T3.status = -1;
  SimpleGasTurbineABG.subsystems.T3.connections = [-8 ];

# Component in
  SimpleGasTurbineABG.subsystems.in.type = "In";
  SimpleGasTurbineABG.subsystems.in.cr = "";
  SimpleGasTurbineABG.subsystems.in.arg = "";
  SimpleGasTurbineABG.subsystems.in.repetitions = 1;
  SimpleGasTurbineABG.subsystems.in.status = -1;
  SimpleGasTurbineABG.subsystems.in.connections = [-16 -12 ];

# Component out
  SimpleGasTurbineABG.subsystems.out.type = "Out";
  SimpleGasTurbineABG.subsystems.out.cr = "";
  SimpleGasTurbineABG.subsystems.out.arg = "";
  SimpleGasTurbineABG.subsystems.out.repetitions = 1;
  SimpleGasTurbineABG.subsystems.out.status = -1;
  SimpleGasTurbineABG.subsystems.out.connections = [17 13 ];

# Component mtt1
  SimpleGasTurbineABG.subsystems.mtt1.type = "1";
  SimpleGasTurbineABG.subsystems.mtt1.cr = "";
  SimpleGasTurbineABG.subsystems.mtt1.arg = "";
  SimpleGasTurbineABG.subsystems.mtt1.repetitions = 1;
  SimpleGasTurbineABG.subsystems.mtt1.status = -1;
  SimpleGasTurbineABG.subsystems.mtt1.connections = [-1 -2 -3 -5 6 ];

# Component mtt2
  SimpleGasTurbineABG.subsystems.mtt2.type = "Load";
  SimpleGasTurbineABG.subsystems.mtt2.cr = "";
  SimpleGasTurbineABG.subsystems.mtt2.arg = "";
  SimpleGasTurbineABG.subsystems.mtt2.repetitions = 1;
  SimpleGasTurbineABG.subsystems.mtt2.status = -1;
  SimpleGasTurbineABG.subsystems.mtt2.connections = [3 -4 ];

# Component mtt3
  SimpleGasTurbineABG.subsystems.mtt3.type = "PS";
  SimpleGasTurbineABG.subsystems.mtt3.cr = "";
  SimpleGasTurbineABG.subsystems.mtt3.arg = "";
  SimpleGasTurbineABG.subsystems.mtt3.repetitions = 1;
  SimpleGasTurbineABG.subsystems.mtt3.status = -1;
  SimpleGasTurbineABG.subsystems.mtt3.connections = [8 -7 -9 ];

# Ordered list of subsystem names
  SimpleGasTurbineABG.subsystemlist(1,:) = "c1   ";
  SimpleGasTurbineABG.subsystemlist(2,:) = "j_s  ";
  SimpleGasTurbineABG.subsystemlist(3,:) = "comp ";
  SimpleGasTurbineABG.subsystemlist(4,:) = "turb ";
  SimpleGasTurbineABG.subsystemlist(5,:) = "Work ";
  SimpleGasTurbineABG.subsystemlist(6,:) = "Heat ";
  SimpleGasTurbineABG.subsystemlist(7,:) = "Speed";
  SimpleGasTurbineABG.subsystemlist(8,:) = "T3   ";
  SimpleGasTurbineABG.subsystemlist(9,:) = "in   ";
  SimpleGasTurbineABG.subsystemlist(10,:) = "out  ";
  SimpleGasTurbineABG.subsystemlist(11,:) = "mtt1 ";
  SimpleGasTurbineABG.subsystemlist(12,:) = "mtt2 ";
  SimpleGasTurbineABG.subsystemlist(13,:) = "mtt3 ";

# Bonds 
  SimpleGasTurbineABG.bonds = [
      0 0 
      1 1 
      0 0 
      -1 -1 
      -1 -1 
      0 0 
      0 0 
      1 1 
      -1 -1 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
# Explicit variable declarations
#VAR t_2
#VAR t_3
#VAR t_4
#VAR p_2
#VAR p_3
#VAR p_4
#VAR mdot
#VAR gamma_0
#VAR q_0
#VAR w_0
#VAR omega_0
#VAR r_p
#VAR c_p
#VAR mom_0
endfunction

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_desc.tex version [cfa31dba4b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123



























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system SimpleGasTurbineABG (SimpleGasTurbineABG_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/05/18 15:45:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{SimpleGasTurbineABG} is
   displayed in Figure \Ref{SimpleGasTurbineABG_abg} and its label
   file is listed in Section \Ref{sec:SimpleGasTurbineABG_lbl}.
   The subsystems are listed in Section \Ref{sec:SimpleGasTurbineABG_sub}.
   
   \textbf{SimpleGasTurbineABG} can be regarded as an single-spool gas
   turbine (producing shaft power) with an ideal-gas working fluid. It
   corresponds to the simple Joule Cycle as described in Chapter 12 of
   Rogers and Mayhew and in Chapter 2 of Cohen, Rogers and
   Saravanamutto. However, unlike those examples, the system is
   written with dynamics in mind.
   
   The system is described using an energy Bond Graph- this ensures
   that the first law is observed. In particular transformers are used
   to explicitly convert between energy covariables. Although this is
   a simple model, I believe that it provides the basis for building
   complex thermodynamic systems involving gas power cycles.


There are five main components:
\begin{enumerate}
\item p1 -- a \textbf{Pump} component representing the compressor
  stage. This converts shaft work to energy flow in the working fluid.
\item c1 -- a \textbf{Comb} component representing the combustion
  chamber. This converts the heat obtained by burning fuel to energy
  flow in the working fluid.
\item t1 -- a \textbf{Turb} component representing the turbine
  component. This converts the energy flow in the working fluid to
  shaft work
\item j\_s -- an \textbf{I} component representing the combined inertia
  of the shaft and compressor and turbine rotors.
\item a \textbf{Load} component to absorb the shaft power.
\end{enumerate}
The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

Both \textbf{Pump} and \textbf{Turb} are implemented with the
\emph{polytropic} constitutive relationship with index $n$. When
$n=\gamma=\frac{c_p}{c_v}$ this corresponds to isentropic compression
and expansion and thus the \textbf{SimpleGasTurbineABG} achieves its
cycle efficiency. However, other values of $n$ can be used to account
for isentropic efficiency of less than unity.

To obtain a very simple dynamic model (and to avoid the need for an
accurate combustion chamber model) there are no dynamics associated
with the combustion chamber, but rahter it is assumed that the
corresponding temperature is imposed on the component (that is $T_3$
is the system input) the corresponding heat flow is then an output.

Both heat input and work output are measured using the \textbf{PS}
(power sensor) component, that for work output is embedded in the
\textbf{Load} component. These can be monitored to give the efficiency
of the \textbf{SimpleGasTurbineABG}.

A symbolic steady-state for the model was computed -- see Section
\ref{sec:SimpleGasTurbineABG_ss.tex}. In particular, the load
resistance was chosen to absorb all the generated work at the steady
state and the shaft inertia was chosen to give a unit time constant
for the linearised system. The mass flow and shaft speeds were taken
as unity.

For the purposed of simulation, the numerical values given in Examples
12.1 of Chapter 12 of Rogers and Mayhew, except that the isentropic
efficiencies are 100\% ($n=\gamma$) -- see Section
\ref{sec:SimpleGasTurbineABG_numpar.tex}.

Simulations were performed starting at the steady state and increasing
the combustion chamber temperature by 10\% at $t=1$ and reducing by
10\% at $t=5$. Graphs of the various outputs are plotted:
\begin{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-p1-T,SimpleGasTurbineABG-c1-T,SimpleGasTurbineABG-t1-T}
  -- the temperatures at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-Heat,SimpleGasTurbineABG-Work}
  -- the heat input and work output
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-Speed} -- the shaft speed and
\item Figure
  \Ref{fig:SimpleGasTurbineABG_odeso.ps-SimpleGasTurbineABG-p1-P,SimpleGasTurbineABG-c1-P,SimpleGasTurbineABG-t1-P}
  -- the pressure at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\end{itemize}

This model can be modified extended in various ways to yield related
dynamic systems. For example:
\begin{itemize}
\item an air cooler is obtained by changing the direction of heat and
  work flows
\item additional \textbf{Turb} and \textbf{Comb} components add reheat
  to the cycle
\item an isentropic nozzle can be added and the work output removed
  to give a jet engine.
\end{itemize}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_input.txt version [a6afb44f57].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (SimpleGasTurbineABG_input.txt)
# Generated by MTT at Tue Mar 31 12:38:39 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

t_3 = 1000;

# Set the inputs
u(1) =	 t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); # SimpleGasTurbineABG (T3)

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_numpar.txt version [9bfc3242f4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (SimpleGasTurbine_numpar.txt)
# Generated by MTT at Tue Mar 31 12:15:00 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 16:55:29  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#Dummies
 alpha = 1;
 c_v = 1;
 density = 1;
 ideal_gas = 1;
 j_s = 1;
 k = 1;
 k_p = 1;
 m = 1;
 m_c = 1;
 p_1 = 1;
 r = 1;
 r_l = 1;
 t_1 = 1;
 v = 1;
 v_c = 1;


# Parameters
c_p = 	1005.0;
c_v = 	718.0; 
gamma_0 =  c_p/c_v;
alpha = (gamma_0-1)/gamma_0;
k = 	1.0;
p_1 = 	1e5; # 1 bar
p_4 = 	p_1; 
r = 	c_p-c_v;
t_1 = 	288.0; # In
v_c = 	1.0;

%Set the CC pressure and temperature
t_3 = 1000.0;
r_p = 6.0;
p_3 = r_p*p_1;

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c = (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 = p_1;
p_2 = p_3;

%Compute ss temperatures (isentropic)
t_2 = t_1*pow((p_2/p_1),alpha);
t_4 = t_3*pow((p_4/p_3),alpha);

%Find the steady-state work output
w_0 = c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Unit mass flow
mdot = 1;

%Corresponding shaft speed
omega_0 = mdot/k;

%Compute the corresponding load resistance (to absorb that work)
r_l = w_0/pow((omega_0),2);

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s = r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 =  omega_0*j_s;

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_rep.txt version [1fdcfffbf7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system SimpleGasTurbineABG (SimpleGasTurbineABG_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 16:55:29  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%mtt -abg -o -ss SimpleGasTurbineABG abg tex
mtt -abg -o -ss SimpleGasTurbineABG struc tex
mtt -abg -o -ss SimpleGasTurbineABG sympar tex
mtt -abg -o -ss SimpleGasTurbineABG ode tex

mtt -abg -o -ss SimpleGasTurbineABG sspar r
mtt -abg -o -ss SimpleGasTurbineABG ss tex
mtt -abg -o -ss SimpleGasTurbineABG sm tex


mtt -abg -o -ss SimpleGasTurbineABG numpar tex
mtt -abg -o -ss SimpleGasTurbineABG input tex
mtt -abg -o -ss SimpleGasTurbineABG state tex
mtt -abg -o -ss SimpleGasTurbineABG simpar tex
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_p1_T,SimpleGasTurbineABG_c1_T,SimpleGasTurbineABG_t1_T'
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_Heat,SimpleGasTurbineABG_Work'
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_Speed'
mtt -abg -o -ss SimpleGasTurbineABG odeso ps 'SimpleGasTurbineABG_p1_P,SimpleGasTurbineABG_c1_P,SimpleGasTurbineABG_t1_P'





Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_simp.r version [ca6f515178].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
%% Reduce commands to simplify output for system SimpleGasTurbineABG (SimpleGasTurbineABG_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LET c_v = c_p - r;
END;

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_sspar.r version [8d3c89c1a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (SimpleGasTurbineABG_sspar.r)
% Generated by MTT at Thu Mar 26 16:28:59 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c := (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 := p_1;
p_2 := p_3;

%Compute ss temperatures (isentropic)
t_2 := t_1*(p_2/p_1)^alpha;
t_4 := t_3*(p_4/p_3)^alpha;

%Find the steady-state work output
w_0 := c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Compute the corresponding load resistance (to absorb that work)
r_l := w_0/(omega_0)^2;

%Unit mass flow
mdot := 1;

%Corresponding shaft speed
omega_0 := mdot/k;

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s := r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 :=  omega_0*j_s;


% Steady-state states
MTTX1 := 	mom_0;

% Steady-state inputs - combustion temperature
MTTU1 := 	t_3; % SimpleGasTurbineABG (T3)

;;END;

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/SimpleGasTurbineABG_state.txt version [ee6857149c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (SimpleGasTurbineABG_state.txt)
# Generated by MTT at Tue Mar 31 12:37:17 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SimpleGasTurbineABG_numpar;

# Set the states
x(1) =	 j_s/k ; # SimpleGasTurbineABG (j_s)

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/hPipe_abg.m version [32f5edad6e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [hPipe] =  hPipe_abg
# This function is the acausal bond graph representation of hPipe
# Generated by MTT on Thu Mar 16 10:33:07 2000
# The file is in Octave format

# Subsystems and Ports

# Port Heat
  hPipe.ports.Heat.type = "SS";
  hPipe.ports.Heat.cr = "SS";
  hPipe.ports.Heat.arg = "external,external";
  hPipe.ports.Heat.repetitions = 1;
  hPipe.ports.Heat.status = -1;
  hPipe.ports.Heat.connections = [-3 ];

# Port Hydraulic_in
  hPipe.ports.Hydraulic_in.type = "SS";
  hPipe.ports.Hydraulic_in.cr = "SS";
  hPipe.ports.Hydraulic_in.arg = "external,external";
  hPipe.ports.Hydraulic_in.repetitions = 1;
  hPipe.ports.Hydraulic_in.status = -1;
  hPipe.ports.Hydraulic_in.connections = [-5 ];

# Port Hydraulic_out
  hPipe.ports.Hydraulic_out.type = "SS";
  hPipe.ports.Hydraulic_out.cr = "SS";
  hPipe.ports.Hydraulic_out.arg = "external,external";
  hPipe.ports.Hydraulic_out.repetitions = 1;
  hPipe.ports.Hydraulic_out.status = -1;
  hPipe.ports.Hydraulic_out.connections = [6 ];

# Port Thermal_in
  hPipe.ports.Thermal_in.type = "SS";
  hPipe.ports.Thermal_in.cr = "SS";
  hPipe.ports.Thermal_in.arg = "external,external";
  hPipe.ports.Thermal_in.repetitions = 1;
  hPipe.ports.Thermal_in.status = -1;
  hPipe.ports.Thermal_in.connections = [-2 ];

# Port Thermal_out
  hPipe.ports.Thermal_out.type = "SS";
  hPipe.ports.Thermal_out.cr = "SS";
  hPipe.ports.Thermal_out.arg = "external,external";
  hPipe.ports.Thermal_out.repetitions = 1;
  hPipe.ports.Thermal_out.status = -1;
  hPipe.ports.Thermal_out.connections = [7 ];

# Component P2T
  hPipe.subsystems.P2T.type = "TF";
  hPipe.subsystems.P2T.cr = "lin";
  hPipe.subsystems.P2T.arg = "flow,r*m/v";
  hPipe.subsystems.P2T.repetitions = 1;
  hPipe.subsystems.P2T.status = -1;
  hPipe.subsystems.P2T.connections = [5 -1 ];

# Component T2P
  hPipe.subsystems.T2P.type = "TF";
  hPipe.subsystems.T2P.cr = "lin";
  hPipe.subsystems.T2P.arg = "effort,r*m/v";
  hPipe.subsystems.T2P.repetitions = 1;
  hPipe.subsystems.T2P.status = -1;
  hPipe.subsystems.T2P.connections = [4 -6 ];

# Component mtt1
  hPipe.subsystems.mtt1.type = "0";
  hPipe.subsystems.mtt1.cr = "";
  hPipe.subsystems.mtt1.arg = "";
  hPipe.subsystems.mtt1.repetitions = 1;
  hPipe.subsystems.mtt1.status = -1;
  hPipe.subsystems.mtt1.connections = [1 2 3 -4 -7 ];

# Ordered list of Port names
  hPipe.portlist(1,:) = "Heat         ";
  hPipe.portlist(2,:) = "Hydraulic_in ";
  hPipe.portlist(3,:) = "Hydraulic_out";
  hPipe.portlist(4,:) = "Thermal_in   ";
  hPipe.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  hPipe.subsystemlist(1,:) = "P2T ";
  hPipe.subsystemlist(2,:) = "T2P ";
  hPipe.subsystemlist(3,:) = "mtt1";

# Bonds 
  hPipe.bonds = [
      0 0 
      0 0 
      1 1 
      0 0 
      0 0 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
hPipe.alias.out = "Thermal_out,Hydraulic_out";
hPipe.alias.Hy_out = "Hydraulic_out";
hPipe.alias.Th_in = "Thermal_in";
hPipe.alias.r = "$3";
hPipe.alias.Th_out = "Thermal_out";
hPipe.alias.m = "$1";
hPipe.alias.v = "$2";
hPipe.alias.in = "Thermal_in,Hydraulic_in";
hPipe.alias.Hy_in = "Hydraulic_in";

Deleted mttroot/mtt/lib/examples/ABG/SimpleGasTurbineABG/wPipe_abg.m version [b1c4a72c91].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199







































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [wPipe] =  wPipe_abg
# This function is the acausal bond graph representation of wPipe
# Generated by MTT on Thu Mar 16 10:37:39 2000
# The file is in Octave format

# Subsystems and Ports

# Port Hydraulic_in
  wPipe.ports.Hydraulic_in.type = "SS";
  wPipe.ports.Hydraulic_in.cr = "SS";
  wPipe.ports.Hydraulic_in.arg = "external,external";
  wPipe.ports.Hydraulic_in.repetitions = 1;
  wPipe.ports.Hydraulic_in.status = -1;
  wPipe.ports.Hydraulic_in.connections = [-1 ];

# Port Hydraulic_out
  wPipe.ports.Hydraulic_out.type = "SS";
  wPipe.ports.Hydraulic_out.cr = "SS";
  wPipe.ports.Hydraulic_out.arg = "external,external";
  wPipe.ports.Hydraulic_out.repetitions = 1;
  wPipe.ports.Hydraulic_out.status = -1;
  wPipe.ports.Hydraulic_out.connections = [17 ];

# Port Shaft
  wPipe.ports.Shaft.type = "SS";
  wPipe.ports.Shaft.cr = "SS";
  wPipe.ports.Shaft.arg = "external,external";
  wPipe.ports.Shaft.repetitions = 1;
  wPipe.ports.Shaft.status = -1;
  wPipe.ports.Shaft.connections = [-20 ];

# Port Thermal_in
  wPipe.ports.Thermal_in.type = "SS";
  wPipe.ports.Thermal_in.cr = "SS";
  wPipe.ports.Thermal_in.arg = "external,external";
  wPipe.ports.Thermal_in.repetitions = 1;
  wPipe.ports.Thermal_in.status = -1;
  wPipe.ports.Thermal_in.connections = [-14 ];

# Port Thermal_out
  wPipe.ports.Thermal_out.type = "SS";
  wPipe.ports.Thermal_out.cr = "SS";
  wPipe.ports.Thermal_out.arg = "external,external";
  wPipe.ports.Thermal_out.repetitions = 1;
  wPipe.ports.Thermal_out.status = -1;
  wPipe.ports.Thermal_out.connections = [16 ];

# Component rho1
  wPipe.subsystems.rho1.type = "Density";
  wPipe.subsystems.rho1.cr = "none";
  wPipe.subsystems.rho1.arg = "density,ideal_gas,r";
  wPipe.subsystems.rho1.repetitions = 1;
  wPipe.subsystems.rho1.status = -1;
  wPipe.subsystems.rho1.connections = [4 3 -5 ];

# Component rho2
  wPipe.subsystems.rho2.type = "Density";
  wPipe.subsystems.rho2.cr = "none";
  wPipe.subsystems.rho2.arg = "density,ideal_gas,r";
  wPipe.subsystems.rho2.repetitions = 1;
  wPipe.subsystems.rho2.status = -1;
  wPipe.subsystems.rho2.connections = [12 11 -10 ];

# Component p2pv
  wPipe.subsystems.p2pv.type = "EMTF";
  wPipe.subsystems.p2pv.cr = "lin";
  wPipe.subsystems.p2pv.arg = "flow";
  wPipe.subsystems.p2pv.repetitions = 1;
  wPipe.subsystems.p2pv.status = -1;
  wPipe.subsystems.p2pv.connections = [2 -9 5 ];

# Component pv2p
  wPipe.subsystems.pv2p.type = "EMTF";
  wPipe.subsystems.pv2p.cr = "lin";
  wPipe.subsystems.pv2p.arg = "effort";
  wPipe.subsystems.pv2p.repetitions = 1;
  wPipe.subsystems.pv2p.status = -1;
  wPipe.subsystems.pv2p.connections = [7 -18 10 ];

# Component t2u
  wPipe.subsystems.t2u.type = "TF";
  wPipe.subsystems.t2u.cr = "lin";
  wPipe.subsystems.t2u.arg = "effort,c_v";
  wPipe.subsystems.t2u.repetitions = 1;
  wPipe.subsystems.t2u.status = -1;
  wPipe.subsystems.t2u.connections = [15 -6 ];

# Component u2t
  wPipe.subsystems.u2t.type = "TF";
  wPipe.subsystems.u2t.cr = "lin";
  wPipe.subsystems.u2t.arg = "flow,c_v";
  wPipe.subsystems.u2t.repetitions = 1;
  wPipe.subsystems.u2t.status = -1;
  wPipe.subsystems.u2t.connections = [8 -13 ];

# Component mtt1
  wPipe.subsystems.mtt1.type = "0";
  wPipe.subsystems.mtt1.cr = "";
  wPipe.subsystems.mtt1.arg = "";
  wPipe.subsystems.mtt1.repetitions = 1;
  wPipe.subsystems.mtt1.status = -1;
  wPipe.subsystems.mtt1.connections = [-3 14 -15 ];

# Component mtt2
  wPipe.subsystems.mtt2.type = "0";
  wPipe.subsystems.mtt2.cr = "";
  wPipe.subsystems.mtt2.arg = "";
  wPipe.subsystems.mtt2.repetitions = 1;
  wPipe.subsystems.mtt2.status = -1;
  wPipe.subsystems.mtt2.connections = [1 -2 -4 ];

# Component mtt3
  wPipe.subsystems.mtt3.type = "1";
  wPipe.subsystems.mtt3.cr = "";
  wPipe.subsystems.mtt3.arg = "";
  wPipe.subsystems.mtt3.repetitions = 1;
  wPipe.subsystems.mtt3.status = -1;
  wPipe.subsystems.mtt3.connections = [6 -7 -8 9 19 ];

# Component mtt4
  wPipe.subsystems.mtt4.type = "0";
  wPipe.subsystems.mtt4.cr = "";
  wPipe.subsystems.mtt4.arg = "";
  wPipe.subsystems.mtt4.repetitions = 1;
  wPipe.subsystems.mtt4.status = -1;
  wPipe.subsystems.mtt4.connections = [-11 13 -16 ];

# Component mtt5
  wPipe.subsystems.mtt5.type = "0";
  wPipe.subsystems.mtt5.cr = "";
  wPipe.subsystems.mtt5.arg = "";
  wPipe.subsystems.mtt5.repetitions = 1;
  wPipe.subsystems.mtt5.status = -1;
  wPipe.subsystems.mtt5.connections = [-12 -17 18 ];

# Component mtt6
  wPipe.subsystems.mtt6.type = "1";
  wPipe.subsystems.mtt6.cr = "";
  wPipe.subsystems.mtt6.arg = "";
  wPipe.subsystems.mtt6.repetitions = 1;
  wPipe.subsystems.mtt6.status = -1;
  wPipe.subsystems.mtt6.connections = [-19 20 ];

# Ordered list of Port names
  wPipe.portlist(1,:) = "Hydraulic_in ";
  wPipe.portlist(2,:) = "Hydraulic_out";
  wPipe.portlist(3,:) = "Shaft        ";
  wPipe.portlist(4,:) = "Thermal_in   ";
  wPipe.portlist(5,:) = "Thermal_out  ";

# Ordered list of subsystem names
  wPipe.subsystemlist(1,:) = "rho1";
  wPipe.subsystemlist(2,:) = "rho2";
  wPipe.subsystemlist(3,:) = "p2pv";
  wPipe.subsystemlist(4,:) = "pv2p";
  wPipe.subsystemlist(5,:) = "t2u ";
  wPipe.subsystemlist(6,:) = "u2t ";
  wPipe.subsystemlist(7,:) = "mtt1";
  wPipe.subsystemlist(8,:) = "mtt2";
  wPipe.subsystemlist(9,:) = "mtt3";
  wPipe.subsystemlist(10,:) = "mtt4";
  wPipe.subsystemlist(11,:) = "mtt5";
  wPipe.subsystemlist(12,:) = "mtt6";

# Bonds 
  wPipe.bonds = [
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      0 0 
      -1 -1 
      ];

# Aliases 
# A double underscore __ represents a comma 
wPipe.alias.out = "Thermal_out,Hydraulic_out";
wPipe.alias.Hy_out = "Hydraulic_out";
wPipe.alias.c_v = "$1";
wPipe.alias.Th_in = "Thermal_in";
wPipe.alias.Th_out = "Thermal_out";
wPipe.alias.Work = "Shaft";
wPipe.alias.in = "Thermal_in,Hydraulic_in";
wPipe.alias.Hy_in = "Hydraulic_in";
wPipe.alias.density__ideal_gas__r = "$2";

Deleted mttroot/mtt/lib/examples/ABG/rcABG/rcABG_abg.m version [df1614e2f8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [rc] =  rc_abg
# This function is the acausal bond graph representation of rc
# Generated by MTT on Thu Mar 16 08:45:29 2000
# The file is in Octave format

# Subsystems and Ports

# Component c
  rc.subsystems.c.type = "C";
  rc.subsystems.c.cr = "lin";
  rc.subsystems.c.arg = "effort,c";
  rc.subsystems.c.repetitions = 1;
  rc.subsystems.c.status = -1;
  rc.subsystems.c.connections = [5 ];

# Component r
  rc.subsystems.r.type = "R";
  rc.subsystems.r.cr = "lin";
  rc.subsystems.r.arg = "flow,r";
  rc.subsystems.r.repetitions = 1;
  rc.subsystems.r.status = -1;
  rc.subsystems.r.connections = [4 ];

# Component e1
  rc.subsystems.e1.type = "SS";
  rc.subsystems.e1.cr = "SS";
  rc.subsystems.e1.arg = "external,internal";
  rc.subsystems.e1.repetitions = 1;
  rc.subsystems.e1.status = -1;
  rc.subsystems.e1.connections = [-1 ];

# Component e2
  rc.subsystems.e2.type = "SS";
  rc.subsystems.e2.cr = "SS";
  rc.subsystems.e2.arg = "external,0";
  rc.subsystems.e2.repetitions = 1;
  rc.subsystems.e2.status = -1;
  rc.subsystems.e2.connections = [3 ];

# Component mtt1
  rc.subsystems.mtt1.type = "1";
  rc.subsystems.mtt1.cr = "";
  rc.subsystems.mtt1.arg = "";
  rc.subsystems.mtt1.repetitions = 1;
  rc.subsystems.mtt1.status = -1;
  rc.subsystems.mtt1.connections = [1 -2 -4 ];

# Component mtt2
  rc.subsystems.mtt2.type = "0";
  rc.subsystems.mtt2.cr = "";
  rc.subsystems.mtt2.arg = "";
  rc.subsystems.mtt2.repetitions = 1;
  rc.subsystems.mtt2.status = -1;
  rc.subsystems.mtt2.connections = [2 -3 -5 ];

# Ordered list of subsystem names
  rc.subsystemlist(1,:) = "c   ";
  rc.subsystemlist(2,:) = "r   ";
  rc.subsystemlist(3,:) = "e1  ";
  rc.subsystemlist(4,:) = "e2  ";
  rc.subsystemlist(5,:) = "mtt1";
  rc.subsystemlist(6,:) = "mtt2";

# Bonds 
  rc.bonds = [
      1 1 
      0 0 
      1 1 
      0 0 
      0 0 
      ];

# Aliases 
# A double underscore __ represents a comma 
rc.alias.r = "$2";
rc.alias.c = "$1";

Deleted mttroot/mtt/lib/examples/ABG/rcABG/rcABG_rep.txt version [55de203c56].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% %% Outline report file for system rcABG (rcABG_rep.txt)
mtt rcABG struc tex
mtt rcABG ode tex
mtt rcABG sm tex
mtt rcABG tf tex
mtt rcABG sro ps
mtt rcABG lmfr ps
mtt rcABG nyfr ps

mtt rcABG numpar txt
mtt rcABG input txt
mtt rcABG odeso ps
mtt rcABG rep txt


Deleted mttroot/mtt/lib/examples/AlgebraicLoops/aRC/aRC_abg.fig version [d59bd2ce5c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 4680 630 6570 1620
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4725 1215 5175 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4725 1080 5175 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4950 675 4950 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4950 1215 4950 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 6075 1530 6075 765
4 0 1 1 0 0 20 0.0000 4 180 165 5355 1215 c\001
4 0 1 1 0 0 20 0.0000 4 180 165 6300 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 6390 1305 2\001
-6
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 4500 2925 5400 3150 5175
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 6075 6750 225 675 225 675 6075 6750 6075
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 3600 585 4500 585 4500 765 3600 765 3600 585
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 3600 675
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 2
	 4500 675 5850 675
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 2
	 1755 1575 5850 1575
2 1 0 2 4 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1935 5040 2160 5265
2 1 0 2 4 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2070 5130 2706 4494 2706 4812
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 255 825 5987 4367 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 330 825 2926 2926 R:r_1\001
4 1 -1 0 0 0 20 0.0000 4 255 495 4276 2926 C:c\001
4 1 -1 0 0 0 20 0.0000 4 255 825 1395 4365 SS:e1\001
4 0 1 1 0 0 20 0.0000 4 330 495 2880 450 r_1\001
4 0 1 1 0 0 20 0.0000 4 180 165 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 255 1545 3600 2025 Schematic\001
4 1 1 1 0 0 20 0.0000 4 330 1725 4860 4860 Bond graph\001
4 1 -1 0 0 0 20 0.0000 4 330 825 3015 5715 R:r_2\001
4 0 1 1 0 0 20 0.0000 4 330 495 3870 450 r_2\001
4 1 -1 0 0 0 20 0.0000 4 330 1110 1755 5535 SS:loop\001

Deleted mttroot/mtt/lib/examples/AlgebraicLoops/aRC/aRC_desc.tex version [e70a959805].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system aRC (aRC_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:02:29  peterg
% %% To RCS
% %%
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{aRC} is
   displayed in Figure \Ref{aRC_abg} and its label
   file is listed in Section \Ref{sec:aRC_lbl}.
   The subsystems are listed in Section \Ref{sec:aRC_sub}.

The system \textbf{aRC} is the simple electrical rc circuit shown in
Figure \Ref{aRC_abg}. It can be regarded as a single-input
single-output system with input $e_1$ and output $e_2$.

The two resistors ($r_1$ and $r_2$) are in series; this give an
undercausal system with a corresponding algebraic loop. The loop is
broken by adding the {\bf SS} component ``loop'' to localise the
algabraic equation byh choosing the corresponding flow such that the
corresponding effort is zero. This algebraic equation appears in
Section \Ref{sec:aRC_dae-noargs.tex}.

This loop is algbraicly solved to give the ordinary differential
equation of Section \Ref{sec:aRC_ode-A.tex} and the transfer function of
Section \Ref{sec:aRC_tf-A.tex}.

Deleted mttroot/mtt/lib/examples/AlgebraicLoops/aRC/aRC_lbl.txt version [b09da23797].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY aRC: Simple RC circuit example with algebraic loop

%% Label file for system aRC (aRC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/20 16:03:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/05/12  15:11:47  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/04/18  13:27:54  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/04/18  13:20:13  peterg
% %% Initial revision
% %% Revision 1.1  1996/09/10 11:37:14  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Source - effort source (e1) flow ignored
e1	SS external,internal

% Sensor - effort sensor (e2)	zero flow
e2	SS external,0

% R component - linear with resistance r (effort = r*flow)
r_1	lin	flow,r_1
r_2	lin	flow,r_2

% C component - linear with capacitance c (state = c*effort)
c	lin	effort,c

% Algebraic loop SS
loop	SS      zero,unknown



Deleted mttroot/mtt/lib/examples/AlgebraicLoops/aRC/aRC_rep.txt version [ce544498bf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system aRC (aRC_rep.txt)
## Generated by MTT on" Fri Oct 15 14:56:13 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:02:29  peterg
## To RCS
##
###############################################################

mtt aRC abg tex			# The system description
mtt aRC cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt aRC struc tex	        # The system structure
mtt aRC dae tex			# The system dae
mtt -A aRC ode tex	        # The system ode 
## mtt aRC sspar tex		# Steady-state parameters
## mtt aRC ss tex 		# Steady state
## mtt aRC dm tex		# Descriptor matrices (of linearised system)
## mtt aRC sm tex		# State matrices (of linearised system)
mtt -A aRC tf tex		# Transfer function (of linearised system)
## mtt aRC lmfr ps		# log modulus of frequency response (of linearised system)
## mtt aRC simpar tex		# Simulation parameters
## mtt aRC numpar tex		# Numerical simulation parameters
## mtt aRC input tex		# Simulation input
## mtt aRC odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/AlgebraicLoops/aRC/aRC_sspar.r version [c42ae262e6].

1
2


-
-
%% Reduce steady-state parameter file for aRC (aRC_sspar.r) cat /home/peter/mtt_new/mtt/trans/m/aRCs_header.txt
END;

Deleted mttroot/mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_abg.fig version [7c16f519c4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291



































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Inches
1200 2
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4201 7186 4201 6451 4336 6631
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4201 4801 4201 4066 4336 4246
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4276 7201 4801 6901 4651 6901
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9901 6151 10576 6151 10426 6001
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9901 5026 10576 5026 10426 4876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4501 6226 5176 6226 5026 6076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4501 5026 5176 5026 5026 4876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9601 5266 9601 6001 9466 5821
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9901 3901 10576 3901 10426 3751
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4501 3901 5176 3901 5026 3751
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5401 1876 5701 1876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5551 1201 5551 1876 5401 1726
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5926 1951 5926 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4051 3601 4351 3601
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4501 1951 4501 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 7351 1951 7351 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4201 3601 6751 2326 6451 2251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7051 2251 9526 3676 9526 3376
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5251 2101 4501 2101 4651 1951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5926 2101 6601 2101 6451 1951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7351 2101 8026 2101 7876 1951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 9376 3676 9676 3676
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 11341 8491 12076 8356 11896
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5491 14941 5491 15676 5356 15496
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5401 8401 5701 8401
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5371 10246 5671 10246
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5326 12076 5626 12076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5326 13876 5626 13876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5326 15676 5626 15676
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 15676 8626 15676
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 13876 8626 13876
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 12076 8626 12076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 10276 8626 10276
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8326 8401 8626 8401
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 14926 7201 14926
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 13126 7201 13126
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 11326 7201 11326
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 9526 7201 9526
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 6901 7651 7201 7651
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 14941 7021 15676 6901 15496
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 13141 7021 13876 6901 13696
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 11341 7021 12076 6901 11896
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7021 9541 7021 10276 6901 10096
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7051 7651 7051 8386 6931 8206
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 11101 8776 10951
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 12901 8776 12751
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 14701 8776 14551
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8476 7651 8476 8386 8341 8206
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 9541 8491 10276 8356 10096
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 13141 8491 13876 8356 13696
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8491 14941 8491 15676 8356 15496
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5551 7651 5551 8386 5416 8206
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5536 9496 5536 10231 5401 10051
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5491 11341 5491 12076 5356 11896
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5491 13141 5491 13876 5356 13696
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7051 1876 7501 1501 7501 1726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 7501 7801 8101 7651 8101
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 9301 7801 9901 7651 9901
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 11101 7801 11701 7651 11701
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 12901 7801 13501 7651 13501
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 14701 7801 15301 7651 15301
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 4051 9601 4351 9526 4276
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 4576 9601 4876 9526 4801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 6376 9601 6676 9526 6601
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9601 7051 9601 7351 9526 7276
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 5476 4201 5176 4276 5251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 6076 4201 5776 4276 5851
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 9303 7878 9303 7953 9378
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 9303 7278 9303 7353 9378
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 9152 8177 9452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 11103 7878 11103 7953 11178
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 11103 7278 11103 7353 11178
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 10952 8177 11252
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 12903 7878 12903 7953 12978
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 12903 7278 12903 7353 12978
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 12752 8177 13052
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8178 14703 7878 14703 7953 14778
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7578 14703 7278 14703 7353 14778
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 8177 14552 8177 14852
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 14701 5926 14701 6076 14851
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 12901 5926 12901 6076 13051
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 11101 5926 11101 6076 11251
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 9301 5926 9301 6076 9451
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6676 7501 5926 7501 6076 7651
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8776 7501 8971 7636
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9526 7501 8851 9301 8776 9076
2 1 0 1 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9742 7410 10267 7110 10117 7110
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 7501 7801 7501 7876 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7501 7501 7201 7501 7276 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5102 9302 4802 9302 4877 9377
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5103 11103 4803 11103 4878 11178
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5028 12903 4728 12903 4803 12978
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5028 14703 4728 14703 4803 14778
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 9301 4201 7501 4351 7801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4051 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 3976 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4051 7576
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4426 11101 4051 7576 4201 7801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4426 12901 3901 7576 3976 7726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4426 14701 3676 7501 3826 7801
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5177 7502 4877 7502 4952 7577
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4577 7502 4277 7502 4352 7577
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 8700 9000 7050 6600 7050 6600 8700 9000 8700
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 12300 9000 10650 6600 10650 6600 12300 9000 12300
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 14175 9000 12525 6600 12525 6600 14175 9000 14175
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 15975 9000 14325 6600 14325 6600 15975 9000 15975
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 10500 9000 8850 6600 8850 6600 10500 9000 10500
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13800 16125 300 16125 300 600 13800 600 13800 16125
4 0 0 0 0 0 12 0.0000000 4 180 495 10276 7051 C:apc2\001
4 0 0 0 0 0 12 0.0000000 4 180 510 4876 7051 C:vpc2\001
4 0 0 0 0 0 12 0.0000000 4 180 495 10651 5101 C:apc1\001
4 0 0 0 0 0 12 0.0000000 4 180 480 10651 6226 R:apr2\001
4 0 0 0 0 0 12 0.0000000 4 180 480 10651 4051 R:apr1\001
4 0 0 0 0 0 12 0.0000000 4 180 510 5251 5101 C:vpc1\001
4 0 0 0 0 0 12 0.0000000 4 180 495 5251 6301 R:vpr2\001
4 1 0 0 0 0 12 0.0000000 4 180 495 5551 3976 R:vpr1\001
4 1 0 0 0 0 12 0.0000000 4 180 390 9601 6301 1:ap3\001
4 1 0 0 0 0 12 0.0000000 4 180 405 4201 6301 1:vp3\001
4 1 0 0 0 0 12 0.0000000 4 180 390 9601 5101 0:ap2\001
4 1 0 0 0 0 12 0.0000000 4 180 405 4126 5101 0:vp2\001
4 1 0 0 0 0 12 0.0000000 4 180 390 9526 3976 1:ap1\001
4 1 0 0 0 0 12 0.0000000 4 180 405 4126 3976 1:vp1\001
4 0 0 0 0 0 12 0.0000000 4 180 420 7576 1576 SS:ye\001
4 0 0 0 0 0 12 0.0000000 4 135 390 5326 1201 SS:t0\001
4 1 0 0 0 0 12 0.0000000 4 135 270 4201 2176 R:ri\001
4 1 0 0 0 0 12 0.0000000 4 135 240 5551 2176 1:fi\001
4 1 0 0 0 0 12 0.0000000 4 135 225 7051 2176 0:ti\001
4 1 0 0 0 0 12 0.0000000 4 135 285 8401 2176 C:ci\001
4 0 0 0 0 0 12 0.0000000 4 135 345 8251 14776 1:fsa\001
4 0 0 0 0 0 12 0.0000000 4 135 330 8251 12976 1:ffa\001
4 0 0 0 0 0 12 0.0000000 4 135 315 8251 11176 1:fla\001
4 0 0 0 0 0 12 0.0000000 4 135 360 8251 9376 1:fva\001
4 0 0 0 0 0 12 0.0000000 4 135 360 8251 7576 1:fba\001
4 0 0 0 0 0 12 0.0000000 4 135 360 5251 14776 1:fsv\001
4 0 0 0 0 0 12 0.0000000 4 135 345 5251 12976 1:ffv\001
4 0 0 0 0 0 12 0.0000000 4 135 330 5251 11176 1:flv\001
4 0 0 0 0 0 12 0.0000000 4 135 375 5251 9376 1:fvv\001
4 0 0 0 0 0 12 0.0000000 4 180 345 9601 7576 0:tap\001
4 1 0 0 0 0 12 0.0000000 4 135 390 5476 15901 R:rs1\001
4 1 0 0 0 0 12 0.0000000 4 135 405 5551 10501 R:rv1\001
4 1 0 0 0 0 12 0.0000000 4 135 405 5551 8626 R:rb1\001
4 0 0 0 0 0 12 0.0000000 4 180 420 7501 15601 SS:ys\001
4 0 0 0 0 0 12 0.0000000 4 180 405 7501 13801 SS:yf\001
4 1 0 0 0 0 12 0.0000000 4 180 390 7726 12001 SS:yl\001
4 1 0 0 0 0 12 0.0000000 4 180 435 7801 10201 SS:yv\001
4 1 0 0 0 0 12 0.0000000 4 180 435 7801 8326 SS:yb\001
4 1 0 0 0 0 12 0.0000000 4 135 390 8476 15901 R:rs2\001
4 1 0 0 0 0 12 0.0000000 4 135 405 8476 10501 R:rv2\001
4 1 0 0 0 0 12 0.0000000 4 135 405 8476 8626 R:rb2\001
4 1 0 0 0 0 12 0.0000000 4 135 315 6976 15901 C:cs\001
4 1 0 0 0 0 12 0.0000000 4 135 300 7051 14101 C:cf\001
4 1 0 0 0 0 12 0.0000000 4 135 285 6976 12376 C:cl\001
4 1 0 0 0 0 12 0.0000000 4 135 330 6976 10501 C:cv\001
4 1 0 0 0 0 12 0.0000000 4 135 330 7051 8626 C:cb\001
4 1 0 0 0 0 12 0.0000000 4 135 255 7051 14776 0:ts\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7051 12976 0:tf\001
4 1 0 0 0 0 12 0.0000000 4 135 225 7051 11176 0:tl\001
4 1 0 0 0 0 12 0.0000000 4 135 270 7051 9376 0:tv\001
4 1 0 0 0 0 12 0.0000000 4 135 270 7051 7576 0:tb\001
4 1 0 0 0 0 12 0.0000000 4 135 360 8476 12376 R:rl1\001
4 1 0 0 0 0 12 0.0000000 4 135 375 8476 14101 R:rf1\001
4 1 0 0 0 0 12 0.0000000 4 135 360 5476 12376 R:rl2\001
4 1 0 0 0 0 12 0.0000000 4 135 375 5476 14101 R:rf2\001
4 1 0 0 0 0 12 0.0000000 4 135 240 9601 4501 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 9601 6901 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4201 5701 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 9378 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 11178 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 12978 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7728 14778 AF\001
4 0 0 0 0 0 12 0.0000000 4 135 375 5251 7576 1:fbv\001
4 2 0 0 0 0 12 0.0000000 4 180 360 4126 7501 0:tvp\001
4 1 0 0 0 0 12 0.0000000 4 135 240 7651 7576 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4652 9377 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4653 11178 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4578 12978 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4578 14778 AF\001
4 1 0 0 0 0 12 0.0000000 4 135 240 4727 7577 AF\001

Deleted mttroot/mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_desc.tex version [d9550f793f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system MaplesonModelP (MaplesonModelP_desc.tex)
% Generated by MTT on Wed Dec 10 09:04:14 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MaplesonModelP} is
   displayed in Figure \Ref{MaplesonModelP_abg} and its label
   file is listed in Section \Ref{sec:MaplesonModelP_lbl}.
   The subsystems are listed in Section \Ref{sec:MaplesonModelP_sub}.

This is a Bond Graph interpretation of Mapleson's model P of the
pharmokokinetics of anaesthetic drug delivery. It is discussed in
detail in Chapter 9 of ``Metamodelling''.

It badly needs conversion to hierarchical form.


%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_input.txt version [e19c71456b].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System MaplesonModelP, representation input, language txt; 
## File MaplesonModelP_input.txt; 
## Generated by MTT on Fri Nov 10 10:45:52 GMT 2000; 


MaplesonModelP__t0	= 0.75*760*(t<2); #75% atmospheric pressure for 2 sec.

Deleted mttroot/mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_lbl.txt version [30211b8f11].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167







































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY MaplesonModelP: Pharmokinetic model from section 9.6 of"Metamodelling"
#DESCRIPTION Detailed model with pools
#DESCRIPTION
#DESCRIPTION Note that the bond graph has been redrawn to replace active bonds with
#DESCRIPTION AF components.
#DESCRIPTION This would be much neater using a heirachical model.
#DESCRIPTION 
#DESCRIPTION The following commands make the figures.
#DESCRIPTION 
#DESCRIPTION Fig 9.17	mtt MaplesonModelP abg view
#DESCRIPTION Figs 9.18-19	mtt MaplesonModelP odeso view 'T=[0:0.1:6]'
#DESCRIPTION Fig 9.20	mtt MaplesonModelP lmfr view 'W=logspace(-2,2,100)'
#DESCRIPTION Fig 9.21	mtt MaplesonModelP lpfr view 'W=logspace(-2,2,100)'


# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  1996/08/30  18:37:56  peter
# ## Initial revision
# ##
# ###############################################################

#VAR apools
#VAR breathing_interval
#VAR heart_interval
#VAR k_ap
#VAR k_b
#VAR k_f
#VAR k_i
#VAR k_l
#VAR k_s
#VAR k_v
#VAR k_vp
#VAR kb
#VAR kf
#VAR kl
#VAR ks
#VAR kv
#VAR lambdab
#VAR lambdablood
#VAR lambdaf
#VAR lambdal
#VAR lambdalung
#VAR lambdav
#VAR stroke_volume
#VAR t_1
#VAR t_2
#VAR t_b
#VAR t_f
#VAR t_i
#VAR t_l
#VAR t_s
#VAR t_v
#VAR v_i
#VAR vap
#VAR varterial
#VAR vb
#VAR vbp
#VAR vf
#VAR vfp
#VAR vgas
#VAR vl
#VAR vlp
#VAR vlung
#VAR vplung
#VAR vpools
#VAR vsp
#VAR vv
#VAR vvenous
#VAR vvp

### Common tension junctions ###
ti
tb
tv
tl
tf
ts
tap
tvp

##Common flow junctions - inspiration ###
fi

##Common flow junctions - arteries ###
fba
fva
fla
ffa
fsa

##Common flow junctions - veins ###
fbv
fvv
flv
ffv
fsv

## More junctions
ap3
vp3
ap2
vp2
ap1
vp1

### Resistances ###
rb1	lin	flow,r_b
rv1	lin	flow,r_v
rl1	lin	flow,r_l
rf1	lin	flow,r_f
rs1	lin	flow,r_s

rb2	lin	flow,r_b
rv2	lin	flow,r_v
rl2	lin	flow,r_l
rf2	lin	flow,r_f
rs2	lin	flow,r_s

ri	lin	flow,r_i

## Capacities ###
cb	lin	effort,c_b
cv	lin	effort,c_v
cl	lin	effort,c_l
cf	lin	effort,c_f
cs	lin	effort,c_s
ci	lin	effort,c_i


### Input ###
t0	SS  external,internal

### Outputs ###
yb	SS  external,0	
yv	SS  external,0	
yl	SS  external,0	
yf	SS  external,0	
ys	SS  external,0	
ye	SS  external,0	

### Arterial pool
# ap1	apool1
# ap2	apool2
# ap3	apool3

apc1	lin	effort,c_ap
apc2	lin	effort,c_ap

apr1	lin	flow,r_ap
apr2	lin	flow,r_ap


### Venous pool
# vp1	vpool1
# vp2	vpool2
# vp3	vpool3

vpc1	lin	effort,c_vp
vpc2	lin	effort,c_vp
vpr1	lin	flow,r_vp
vpr2	lin	flow,r_vp


Deleted mttroot/mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_numpar.txt version [3482181f7e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (MaplesonModelP_numpar.txt)
# Generated by MTT at Mon Aug 11 14:45:13 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters

# Modified 17/11/93 to correspond to Mapleson's 1973 paper. 
# Like model O except that blood has its own pools distinct form the tissues. 


Heart_interval = 1.0/60.0;
Breathing_interval = 4*Heart_interval;
Stroke_volume = 0.108;
lambdaBlood = 0.46;
vArterial = 1.4;
vVenous = 4.0;

# %%%%%%%%%%%%%%%%%% Inspiration %%%%%%%%%%%%%%%%%%%%%%%%%%%
v_i = 0.4;
r_i = Breathing_interval/v_i;

# %%%%%%%%%%%%%%%%%% Lung %%%%%%%%%%%%%%%%%%%%%%%%%%% 
vLung = 0.6;
vPLung =  0;
vGas = 2.5;
lambdaLung = 0.46;

c_i = lambdaLung*(vLung + vPLung) + vGas;
t_i = r_i*c_i;
# %%%%%%%%%%%%%%%%%% Brain %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kB = 0.000086;

vB = 0.0007;
vBP = 0.0;

lambdaB = 0.46;

c_b = lambdaB*vB + lambdaBlood*vBP;
r_b = Heart_interval/(kB*lambdaBlood*Stroke_volume);
t_b = r_b*c_b;

# %%%%%%%%%%%%%%%%%% Viscera %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kV = 0.63;

vV = 6.2;
lambdaV = 0.46;
vVP = 0;

c_v = lambdaV*vV + lambdaBlood*vVP;
r_v = Heart_interval/(kV*lambdaBlood*Stroke_volume);
t_v = r_v*c_v;

# %%%%%%%%%%%%%%%%%% Lean %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kL = 0.131;

vL = 39.2;
lambdaL = 0.46;
vLP = 0;

c_l = lambdaL*vL + lambdaBlood*vLP;
r_l = Heart_interval/(kL*lambdaBlood*Stroke_volume);
t_l = r_l*c_l;

# %%%%%%%%%%%%%%%%%% Fat %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kF = 0.04;

vF = 12.2;
lambdaF = 1.40;
vFP = 0;

c_f = lambdaF*vF + lambdaBlood*(vFP);
r_f = Heart_interval/(kF*lambdaBlood*Stroke_volume);
t_f = r_f*c_f;

# %%%%%%%%%%%%%%%%%% Shunt %%%%%%%%%%%%%%%%%%%%%%%%%%% 
kS = 0.199;

vSP = 0.126*vVenous;

c_s = lambdaBlood*(vSP);
r_s = Heart_interval/(kS*lambdaBlood*Stroke_volume);
t_s = r_s*c_s;

# %%%%%%%%%%%%%%%%%% Time constants %%%%%%%%%%%%%%%%%%%%%%%%%%% 
t_1 = t_b*t_v*t_l*t_f*t_s;
t_2 = t_1*t_i;


# %%%%%%%%%%%%%%%%%% Convert from rs to ks %%%%%%%%%%%%%%%%%%%% 

k_b = 1/r_b;
k_v = 1/r_v;
k_l = 1/r_l;
k_f = 1/r_f;
k_s = 1/r_s;
k_i = 1/r_i;

# %%%%%%%%%%%%%%%%%% Arterial pools %%%%%%%%%%%%%%%%%%%%%%%%%%% 
# Two pool version 
aPools = 2;

vAP = vArterial;

c_ap = lambdaBlood*(vAP)/aPools;
r_ap  = Heart_interval/(lambdaBlood*Stroke_volume);

# %%%%%%%%%%%%%%%%%% Venous pools %%%%%%%%%%%%%%%%%%%%%%%%%%% 
# Two pool version 
vPools = 2;

vVP = vVenous - vSP;

c_vp = lambdaBlood*(vVP)/vPools;
r_vp  = Heart_interval/(lambdaBlood*Stroke_volume);

k_ap = 1/r_ap;
k_vp = 1/r_vp;


Deleted mttroot/mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_rep.txt version [88420fc7c7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system MaplesonModelP (MaplesonModelP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/02/17 01:46:48  peterg
% %% Included simpar rep.
% %%
% %% Revision 1.1  1999/02/17 00:08:06  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt MaplesonModelP abg tex
mtt MaplesonModelP struc tex
mtt MaplesonModelP ode tex
mtt MaplesonModelP sm tex
mtt MaplesonModelP lmfr ps

mtt MaplesonModelP simpar txt
mtt MaplesonModelP numpar txt
mtt MaplesonModelP input txt
mtt MaplesonModelP odeso ps

Deleted mttroot/mtt/lib/examples/Anaesthesia/MaplesonModelP/MaplesonModelP_simpar.txt version [3858c22495].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system MaplesonModelP (MaplesonModelP_simpar.txt)
# Generated by MTT on Fri Nov 10 11:37:00 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/MakeFigure.m version [bcab2a5c23].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


par = Reactor_numpar;		# Parameters
sym = Reactor_sympar;		# Parameter indices

F_s= [90:10:500];		# Range of flows

Z_a = []; Z_b = []; P = [];
for f_s=F_s
  par(sym.f_s) = f_s;
  [A,B,C,D] = Reactor_sm(par);	# Linearised system

  p = sort(eig(A));
  P = [P p];

  C_a = C([1 3],:);		# C vector for c_a and t
  D_a = D([1 3],:);		# D vector for c_a and t
  z_a = tzero(A,B,C_a,D_a);	# Transmission zeros for c_a and t
  Z_a = [Z_a z_a];

  C_b = C(2:3,:);		# C vector for c_b and t
  D_b = D(2:3,:);		# D vector for c_b and t
  z_b = tzero(A,B,C_b,D_b);	# Transmission zeros for c_b and t
  Z_b = [Z_b z_b];
endfor

grid; xlabel("f_s"); ylabel("p1,p2");
plot(F_s,P(1:2,:));
psfig("Reactor_pole_1_2");

grid; xlabel("f_s"); ylabel("p3");
plot(F_s,P(3,:));
psfig("Reactor_pole_3");

grid; xlabel("f_s"); ylabel("z_a");
plot(F_s,Z_a);
psfig("Reactor_zero_a");

grid; xlabel("f_s"); ylabel("z_b");
plot(F_s,Z_b);
psfig("Reactor_zero_b");

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Makefile version [97d3b40e97].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
## Makes the schematic diagram and the (trasmission) zero figure
all: Reactor_pic.ps Reactor_zero_b.ps

Reactor_pic.ps: Reactor_pic.fig
	fig2dev -Lps Reactor_pic.fig> Reactor_pic.ps

Reactor_zero_b.ps: Reactor_abg.fig
	mtt -q Reactor sm m
	mtt -q Reactor numpar m;
	mtt -q Reactor sympar m;
	octave MakeFigure.m


Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_abg.fig version [f1af6b8b3a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137









































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3001 8701 3001 7801 3151 7951
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1801 9001 2701 9001 2551 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 8776 2701 9226
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3301 9001 4201 9001 4051 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 9301 3601 9901 3826 9901
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5701 9001 4801 9001 4951 9151
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 6000 2700 6000 2550 6150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 10350 5025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6000 1800 5775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6225 1800 6000
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 10200 600 10200 600 7500 11100 7500 11100 10200
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 6600 600 6600 600 5400 11100 5400 11100 6600
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5700 8775 5700 9225
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4425 9300 3975 9300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4800 4500 8700 4650 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6000 4800 4800 8700 5025 8625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4800 5100 8700 5400 8700
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4800 4275 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4200 4275 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4800 5775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4200 5775 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4800 8775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4200 8775 4200
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 7200 3000 6300 3150 6450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10500 4800 3300 6000 3525 6075
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 5100 600 5100 600 3300 11100 3300 11100 5100
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4485 2395 4485 4130 4633 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 2999 2395 2999 4130 3148 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5970 2395 5970 4130 6119 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 10428 2397 10428 4132 10577 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8943 2397 8943 4132 9091 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 2100 2700 2100 2550 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3300 2100 4200 2100 4050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4800 2100 5700 2100 5550 2250
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4200 1800 3600 1200 3600 1425
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 1875 2700 2325
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 8701 1801 8101 1201 8101 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9301 2101 10201 2101 10051 2251
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6300 2100 7200 2100 7050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7800 2100 8700 2100 8550 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1950 4350 1650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 1950 8850 1650
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 300 600 300 600 2700 11100 2700 11100 300
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 4800 3000 5700 3150 5550
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 9301 1801 9901 1201 9901 1426
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10050 1350 9900 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 1200 9750 1050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4801 1801 5401 1201 5401 1426
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5550 1350 5400 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5400 1200 5250 1050
4 1 0 0 0 0 20 0.0000 4 195 1065 3075 4575 FMR:rfa\001
4 1 0 0 0 0 20 0.0000 4 195 1065 4575 4575 Rate:AD\001
4 1 0 0 0 0 20 0.0000 4 195 1050 6000 4575 Rate:AB\001
4 2 0 0 0 0 20 0.0000 4 255 810 1651 9076 SS:t_0\001
4 2 0 0 0 0 20 0.0000 4 255 690 3451 9976 C:h_r\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 6075 1\001
4 2 0 0 0 0 20 0.0000 4 210 525 1725 6075 SS:f\001
4 1 0 0 0 0 20 0.0000 4 195 150 3001 9076 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4501 9076 0\001
4 1 0 0 0 0 20 0.0000 4 195 1035 9001 4576 Rate:BC\001
4 1 0 0 0 0 20 0.0000 4 210 1080 10576 4576 FMR:rfb\001
4 1 1 1 0 3 20 0.0000 4 195 2595 9600 7800 THERMAL MODEL\001
4 1 1 1 0 3 20 0.0000 4 195 2865 9450 5700 HYDRAULIC MODEL\001
4 1 0 0 0 0 20 0.0000 4 195 915 3000 7575 FMR:rt\001
4 2 0 0 0 0 20 0.0000 4 255 855 1650 2175 SS:c_0\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4500 2175 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 6000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 9001 2176 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 10501 2176 1\001
4 1 0 0 0 0 20 0.0000 4 195 375 7500 2175 AF\001
4 1 0 0 0 0 20 0.0000 4 255 825 8100 1050 C:m_b\001
4 1 0 0 0 0 20 0.0000 4 240 810 3600 1050 C:m_a\001
4 1 1 1 0 3 20 0.0000 4 195 3645 9075 600 CONCENTRATION MODEL\001
4 1 0 0 0 0 20 0.0000 4 210 510 6151 9076 SS:t\001
4 1 0 0 0 0 20 0.0000 4 255 855 9975 1050 SS:c_b\001
4 1 0 0 0 0 20 0.0000 4 255 840 5475 1050 SS:c_a\001
4 1 1 1 0 3 20 0.0000 4 195 2640 9675 3750 REACTION MODEL\001

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_desc.tex version [b3d301e887].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Reactor (Reactor_desc.tex)
% Generated by MTT on Fri Mar 3 12:43:33 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{Reactor_pic}
{Reactor_pic} {0.9} {System \textbf{Reactor}, Schematic}

Figure \Ref{fig:Reactor_pic} is the schematic diagram od a chemical reactor.
The acausal bond graph of system \textbf{Reactor} is displayed in
Figure \Ref{fig:Reactor_abg.ps} and its label file is listed in
Section \Ref{sec:Reactor_lbl}.  The subsystems are listed in Section
\Ref{sec:Reactor_sub}.

This example of a (nonlinear) chemical reactor is due to Trickett and
Bogle\footnote{ K. J. Tricket, \emph{Quantification of Inverse
    Responses for Controllability Assessment of Nonlinear Processes},
  PhD Thesis, University College London, 1994} is used in this
section.  The reactor has two reaction mechanisms: $\text{A}
\rightarrow \text{B} \rightarrow \text{C}$ and $\text{2A} \rightarrow
\text{D}$.  The reactor mass inflow and outflow $f_r$ are identical.
$q$ represents the heat inflow to the reactor.

This is a two input, two-output unstable nonlinear system with unstable zero
dynamics.
The following figures illustrate the properties of the
\emph{linearised} system.

\fig{Reactor_pole_1_2}
{Reactor_pole_1_2} {0.9} {System \textbf{Reactor}: poles 1 and 2
  v. steady-state flow $f_s$}

\fig{Reactor_pole_3}
{Reactor_pole_3} {0.9} {System \textbf{Reactor}: pole 3
  v. steady-state flow $f_s$}

\fig{Reactor_zero_a}
{Reactor_zero_a} {0.9} {System \textbf{Reactor}: zero of system with
  $t$ and $c_a$ as output
  v. steady-state flow $f_s$}

\fig{Reactor_zero_b}
{Reactor_zero_b} {0.9} {System \textbf{Reactor}: pole 3
  v. steady-state flow $f_s$}

\begin{itemize}
\item Figures \Ref{fig:Reactor_pole_1_2} and
  \Ref{fig:Reactor_pole_3} show the three poles of the
  \emph{linearised} system as the steady-state flow varies. 
\item Figure \Ref{fig:Reactor_zero_a} shows the system zero (when $t$ and
  $c_a$ are the two system outputs) as the
  \emph{linearised} system as the steady-state flow varies. 
\item Figure \Ref{fig:Reactor_zero_b} shows the system zero (when $t$ and
  $c_b$ are the two system outputs) as the
  \emph{linearised} system as the steady-state flow varies. 
\end{itemize}

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_input.txt version [f29f445616].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (Reactor_input.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2003/06/06 06:38:02  gawthrop
## Made compatible with current MTT.
##
## Revision 1.2  2000/12/28 18:52:24  peterg
## Updated for new formats
##
## Revision 1.1  2000/12/28 17:09:55  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (Reactor_sspar.r)
## as siso_sspar ecxept that inputs/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume Reactor:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
x3 = c_p*t_s*v_r;


#Steady-state input q needed to achieve steady-state t_s
q_s = -( (t_0-t_s)*c_p*f_s + e_1*h_1*k_1*x1 + e_2*h_2*k_2*x2 + e_3*h_3*k_3*pow(x1,2));

## The two inputs at steady-state
u1 = f_s;
u2 = q_s;


# Set the inputs
## Removed by MTT on Thu Dec 28 18:44:39 GMT 2000: mttu(1) = u1 + 0.1*u1*(t>0.01); # f (Reactor)
## Removed by MTT on Thu Dec 28 18:44:39 GMT 2000: mttu(2) = u2 + 0.1*u2*(t>0.05) ; # t (Reactor)



## Removed by MTT on Thu Jun  5 12:48:41 BST 2003: reactor_f	= u1 + 0.1*u1*(t>0.01); # Added by MTT on Thu Dec 28 18:44:47 GMT 2000
## Removed by MTT on Thu Jun  5 12:48:41 BST 2003: reactor_t	= u2 + 0.1*u2*(t>0.05); # Added by MTT on Thu Dec 28 18:44:47 GMT 2000
reactor__f	= u1 + 0.1*u1*(t>0.01); # f (Reactor)
reactor__t	= u2 + 0.1*u2*(t>0.05) ; # t (Reactor)

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_lbl.txt version [58ee2fa737].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Reactor (Reactor_lbl.txt)
%SUMMARY Reactor: Simple reactor model
%DESCRIPTION Pseudo bond graph reactor model (based on ancient version)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:09:55  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%ALIAS Rate Chemical/Rate

% Extra variables
%VAR t_s
%VAR f_s
%VAR t_0
%VAR c_0
%VAR rho
%VAR v_r
%VAR e_1
%VAR e_2
%VAR e_3
%VAR a
%VAR b
%VAR c
%VAR c_A
%VAR c_B
%VAR x1
%VAR x2
%VAR x3
%VAR q_S
%VAR h
%VAR k
%VAR n
%VAR q

%VAR u1
%VAR u2

% Port aliases

% Argument aliases

%% each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m_a	lin		effort,1
	m_b	lin		effort,1
	h_r	lin		effort,c_p

% Component type FMR
	rfa	lin		effort,1		
	rfb	lin		effort,1		
	rt	lin		effort,c_p

% Component type Rate
        AB	Rate	k_1,q_1,h_1,1
	BC	Rate	k_2,q_2,h_2,1
	AD	Rate	k_3,q_3,h_3,2

% Component type SS
	c_0	SS		c_0,internal
	c_a	SS		external,0
	c_b	SS		external,0
	f	SS		internal,external
	t	SS		external,external
	t_0	SS		t_0,internal

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_numpar.txt version [39eebbbfae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (Reactor_numpar.txt)
# Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:09:55  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Dummies
a = 0;				# Dummy
b = 0;				# Dummy
c = 0;				# Dummy
c_0 = 0;			# Dummy
c_a = 0;			# Dummy
c_b = 0;			# Dummy
c_p = 0;			# Dummy
e_1 = 0;			# Dummy
e_2 = 0;			# Dummy
e_3 = 0;			# Dummy
f_s = 0;			# Dummy
h = 0;				# Dummy
h_1 = 0;			# Dummy
h_2 = 0;			# Dummy
h_3 = 0;			# Dummy
k = 0;				# Dummy
k_1 = 0;			# Dummy
k_2 = 0;			# Dummy
k_3 = 0;			# Dummy
n = 0;				# Dummy
q = 0;				# Dummy
q_1 = 0;			# Dummy
q_2 = 0;			# Dummy
q_3 = 0;			# Dummy
q_s = 0;			# Dummy
rho = 0;			# Dummy
t_0 = 0;			# Dummy
t_s = 0;			# Dummy
v_r = 0;			# Dummy
x1 = 0;				# Dummy
x2 = 0;				# Dummy
x3 = 0;				# Dummy

## The bulk liquid
rho = 900;			# Density
c_p = 5.0;			# Specific heat

## Substance A
k_1 = 2.5e10;			# Reaction rate constant
q_1 = 1e4;			# Exotherm constant
h_1 = 1e4;			# Heat of reaction

## Substance B
k_2 = 2.65e12;			# Reaction rate constant
q_2 = 1.2e4;			# Exotherm constant
h_2 = 1.2e4;			# Heat of reaction

## Substance C
k_3 = 6e7;			# Reaction rate constant
q_3 = 8e3;			# Exotherm constant
h_3 = 3e4;			# Heat of reaction

## Inflow parameters
c_0 = 10;			# Inflow conc
t_0 = 530;			# Inflow temp

## Steady-state values
t_s = 530;			# Steady-state temp
f_s = 100;			# Steady-state flow








u1	= 1.0; # Added by MTT on Thu Jun 05 12:45:35 BST 2003
u2	= 1.0; # Added by MTT on Thu Jun 05 12:45:35 BST 2003

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_pic.fig version [c396b14562].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Landscape
Center
Inches
Letter  
100.00
Single
-2
1200 2
6 2400 3150 3225 3375
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2625 3300 2925 3300
4 0 -1 0 0 2 20 0.0000 4 210 210 2400 3375 A\001
4 0 -1 0 0 2 20 0.0000 4 210 225 3000 3375 D\001
-6
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 2100 2100 3900 1500 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 1500 4050 3900 4050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 1500 4350 2100 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2100 3600 3900 4200 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 3600 4350 4200 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 3900 4050 4200 4050
2 1 1 2 -1 -1 0 0 -1 6.000 0 0 -1 0 0 2
	 2100 2400 3600 2400
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2400 2925 2700 2925
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 3000 2925 3300 2925
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 2850 4800 2850 3750
4 0 -1 0 0 2 20 0.0000 4 210 210 2175 3000 A\001
4 0 -1 0 0 2 20 0.0000 4 210 195 2775 3000 B\001
4 0 -1 0 0 2 20 0.0000 4 210 210 3375 3000 C\001
4 0 -1 0 0 2 20 0.0000 4 210 150 2250 3375 2\001
4 0 -1 0 0 3 12 0.0000 4 135 90 1875 4950 0\001
4 0 -1 0 0 3 12 0.0000 4 135 90 2250 4950 0\001
4 0 -1 0 0 3 20 0.0000 4 210 150 2775 5025 q\001
4 0 -1 0 0 3 20 0.0000 4 285 765 1500 4800 f , c  , t\001
4 0 -1 0 0 3 20 0.0000 4 285 765 3600 4800 f , c  , t\001
4 0 -1 0 0 3 12 0.0000 4 135 90 3975 4950 b\001
4 0 -1 0 0 3 12 0.0000 4 90 75 4350 4950 r\001

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_rep.txt version [303d4e3fcb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Reactor (Reactor_rep.txt)
## Generated by MTT on" Fri Mar  3 12:13:34 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:09:55  peterg
## To RCS
##
###############################################################

mtt Reactor abg tex			# The system description
mtt Reactor cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt Reactor struc tex	        # The system structure
## mtt Reactor dae tex	        # The system dae
mtt Reactor ode tex	        # The system ode 
mtt Reactor sspar tex		# Steady-state parameters
mtt Reactor ss tex 		# Steady state
## mtt Reactor dm tex		# Descriptor matrices (of linearised system)
mtt Reactor sm tex		# State matrices (of linearised system)
## mtt Reactor tf tex		# Transfer function (of linearised system)
## mtt Reactor lmfr ps		# log modulus of frequency response (of linearised system)
mtt Reactor simpar tex		# Simulation parameters
mtt Reactor numpar tex		# Numerical simulation parameters
mtt Reactor input tex		# Simulation input
mtt Reactor state tex		# Simulation initial state

## The system outputs
mtt  Reactor odeso ps 'Reactor__c_a'
mtt  Reactor odeso ps 'Reactor__c_b'
mtt  Reactor odeso ps 'Reactor__t'

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_simp.r version [c0625028b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output (mimo_sim.r)
m_r   := rho*v_r;
%mttx1 := c_a*v_r;
%mttx2 := c_b*v_r;

% THIS MUST BE CHANGED - probs with cp and FMRs
%c_p := 1;

%let mttx3/c_p = t;

let  e^(q_1/(mttx3/c_p)) = 1/epsilon_1;
let  e^(q_2/(mttx3/c_p)) = 1/epsilon_2;
let  e^(q_3/(mttx3/c_p)) = 1/epsilon_3;

let  e^(q_1/t_s) = 1/epsilon_1;
let  e^(q_2/t_s) = 1/epsilon_2;
let  e^(q_3/t_s) = 1/epsilon_3;

FACTOR mttx1,mttx2;

END;

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_simpar.txt version [5dd7482825].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Reactor (Reactor_simpar.txt)
# Generated by MTT on Fri Mar 3 12:11:48 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/08/24 12:32:25  peterg
## Initial revision
##
###############################################################


LAST        = 0.1;       # Last time in simulation
DT          = 0.0002;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_sspar.r version [f8d86e9c44].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file (Reactor_sspar.r)
%% as siso_sspar ecxept that inputs/states have different meaning
%% Steady state for constant c_a, c_b and t=t_s and f=f_s

%% Unit volume Reactor:
v_r := 1;

%% Do the inputs first -- this avoids problems with reduce not
%% recognising that complicated expressions are zero

%% The exponentials.
e_1 := e^(-q_1/t_s);
e_2 := e^(-q_2/t_s);
e_3 := e^(-q_3/t_s);

%Steady-state input q needed to achieve steady-state t_s
q_s := -( 
        + (t_0-t_s)*c_p*f_s
        + e_1*h_1*k_1*x1
        + e_2*h_2*k_2*x2
        + e_3*h_3*k_3*x1^2
       );

%% The two inputs at steady-state
MTTu1 := f_s;
MTTu2 := q_s;

%States (masses)
x1 := c_a*v_r;
x2 := c_b*v_r;

%Thermal state
x3 := c_p*t_s*v_r;

%Load up the vectors
MTTx1 := x1;
MTTx2 := x2;
MTTx3 := x3;

MTTy1 := c_b;
MTTy2 := t_s;

%% Finally, solve for the steady-state concentrations
%% Solve for ca - a quadratic.
a 	:= k_3*e_3;	%ca^2 
b 	:= k_1*e_1 + f_s;	%ca^1 
c 	:= -c_0*f_s;

c_a	:= (-b + sqrt(b^2 - 4*a*c))/(2*a);

%% solve for c_b
c_b 	:= c_a*k_1*e_1/(f_s+k_2*e_2);


END;


Deleted mttroot/mtt/lib/examples/Chemical/Reactor/Reactor_state.txt version [a989fd6bf6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# State specification (Reactor_state.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2003/06/06 06:38:31  gawthrop
## Made compatible with current MTT.
##
## Revision 1.2  2000/12/28 18:52:25  peterg
## Updated for new formats
##
## Revision 1.1  2000/12/28 17:09:55  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (Reactor_sspar.r)
## as siso_sspar ecxept that states/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume Reactor:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
x3 = c_p*t_s*v_r;


#Steady-state state q needed to achieve steady-state t_s
q_s = -((t_0-t_s)*c_p*f_s + e_1*h_1*k_1*x1 + e_2*h_2*k_2*x2 + e_3*h_3*k_3*pow(x1,2));

## The two inputs at steady-state
u1 = f_s;
u2 = q_s;

## Load up the states
## Removed by MTT on Thu Dec 28 18:46:20 GMT 2000: mttx(1) = x1;
## Removed by MTT on Thu Dec 28 18:46:20 GMT 2000: mttx(2) = x2;
## Removed by MTT on Thu Dec 28 18:46:20 GMT 2000: mttx(3) = x3;




## Removed by MTT on Thu Jun  5 12:47:23 BST 2003: reactor_h_r	= x3; # Added by MTT on Thu Dec 28 18:46:25 GMT 2000
## Removed by MTT on Thu Jun  5 12:47:23 BST 2003: reactor_m_a	= x1; # Added by MTT on Thu Dec 28 18:46:25 GMT 2000
## Removed by MTT on Thu Jun  5 12:47:23 BST 2003: reactor_m_b	= x2; # Added by MTT on Thu Dec 28 18:46:25 GMT 2000
reactor__h_r	= x3;
reactor__m_a	= x1;
reactor__m_b	= x2;

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/MakeFigure.m version [138a415543].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Makes the figures

par = ReactorTF_numpar;		# Parameters
sym = ReactorTF_sympar;		# Parameter indices

F_s= [90:10:500];		# Range of flows

Z = [];
for f_s=F_s
  par(sym.f_s) = f_s;
  z = sort(eig(ReactorTF_sm(par)));
  Z = [Z z];
endfor


grid; xlabel("f_s"); ylabel("z_1");
plot(F_s,Z(1,:));
psfig("ReactorTF_zero_1");

grid; xlabel("f_s"); ylabel("z_2");
plot(F_s,Z(2,:));
psfig("ReactorTF_zero_2");

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/Makefile version [2d406594de].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Makes the schematic diagram and the zero figure
all: ReactorTF_pic.ps ReactorTF_zero_1.ps ReactorTF_zero_2.ps

ReactorTF_pic.ps: ReactorTF_pic.fig
	fig2dev -Lps ReactorTF_pic.fig> ReactorTF_pic.ps

ReactorTF_zero_1.ps: ReactorTF_abg.fig
	mtt -q ReactorTF sm m; mtt -q ReactorTF numpar m;
	mtt -q ReactorTF sympar m;
	octave MakeFigure.m

ReactorTF_zero_2.ps: ReactorTF_zero_1.ps
	touch ReactorTF_zero_2.ps

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_abg.fig version [c9c0507fc0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130


































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3001 8701 3001 7801 3151 7951
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1801 9001 2701 9001 2551 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 8776 2701 9226
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3301 9001 4201 9001 4051 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 9301 3601 9901 3826 9901
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5701 9001 4801 9001 4951 9151
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 6000 2700 6000 2550 6150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 10350 5025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6000 1800 5775
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 10200 600 10200 600 7500 11100 7500 11100 10200
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 6600 600 6600 600 5400 11100 5400 11100 6600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4800 4500 8700 4650 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6000 4800 4800 8700 5025 8625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4800 5100 8700 5400 8700
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4800 4275 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4200 4275 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4800 5775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4200 5775 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4800 8775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4200 8775 4200
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 7200 3000 6300 3150 6450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10500 4800 3300 6000 3525 6075
2 4 1 2 1 7 1 0 -1 4.000 0 0 7 0 0 5
	 11100 5100 600 5100 600 3300 11100 3300 11100 5100
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4485 2395 4485 4130 4633 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 2999 2395 2999 4130 3148 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5970 2395 5970 4130 6119 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 10428 2397 10428 4132 10577 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8943 2397 8943 4132 9091 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 2100 2700 2100 2550 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3300 2100 4200 2100 4050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4800 2100 5700 2100 5550 2250
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4200 1800 3600 1200 3600 1425
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 1875 2700 2325
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 8701 1801 8101 1201 8101 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9301 2101 10201 2101 10051 2251
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 9301 1801 9901 1201 9901 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6300 2100 7200 2100 7050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7800 2100 8700 2100 8550 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1950 4350 1650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10050 1350 9900 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 1200 9750 1050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 1950 8850 1650
2 4 1 2 1 7 1 0 -1 4.000 0 0 7 0 0 5
	 11100 300 600 300 600 2700 11100 2700 11100 300
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 4800 3000 5700 3150 5550
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4800 8775 4800 9000
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 5700 9000 5700 9225
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 6225 2700 6000
4 1 0 0 0 0 20 0.0000 4 195 1065 3075 4575 FMR:rfa\001
4 1 0 0 0 0 20 0.0000 4 195 1065 4575 4575 Rate:AD\001
4 1 0 0 0 0 20 0.0000 4 195 1050 6000 4575 Rate:AB\001
4 2 0 0 0 0 20 0.0000 4 255 810 1651 9076 SS:t_0\001
4 2 0 0 0 0 20 0.0000 4 255 690 3451 9976 C:h_r\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 6075 1\001
4 2 0 0 0 0 20 0.0000 4 210 525 1725 6075 SS:f\001
4 1 0 0 0 0 20 0.0000 4 195 150 3001 9076 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4501 9076 0\001
4 1 0 0 0 0 20 0.0000 4 195 1035 9001 4576 Rate:BC\001
4 1 0 0 0 0 20 0.0000 4 210 1080 10576 4576 FMR:rfb\001
4 1 1 1 0 3 20 0.0000 4 195 2595 9600 7800 THERMAL MODEL\001
4 1 0 0 0 0 20 0.0000 4 195 915 3000 7575 FMR:rt\001
4 1 1 1 0 3 20 0.0000 4 195 2640 9675 3750 REACTION MODEL\001
4 2 0 0 0 0 20 0.0000 4 255 855 1650 2175 SS:c_0\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4500 2175 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 6000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 9001 2176 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 10501 2176 1\001
4 1 0 0 0 0 20 0.0000 4 195 375 7500 2175 AF\001
4 1 0 0 0 0 20 0.0000 4 255 825 8100 1050 C:m_b\001
4 1 0 0 0 0 20 0.0000 4 255 855 9975 1050 SS:c_b\001
4 1 0 0 0 0 20 0.0000 4 240 810 3600 1050 C:m_a\001
4 1 1 1 0 3 20 0.0000 4 195 3645 9075 600 CONCENTRATION MODEL\001
4 1 0 0 0 0 20 0.0000 4 210 510 6151 9076 SS:t\001
4 1 1 1 0 3 20 0.0000 4 195 2865 9450 5700 HYDRAULIC MODEL\001

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_args.new version [5936bc7523].

1

-
 

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_desc.tex version [75defbbb1b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ReactorTF (ReactorTF_desc.tex)
% Generated by MTT on Fri Mar 3 12:43:33 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{ReactorTF_pic}
{ReactorTF_pic} {0.9} {System \textbf{ReactorTF}, Schematic}

Figure \Ref{fig:ReactorTF_pic} is the schematic diagram of a chemical
reactor.

The acausal bond graph of system \textbf{ReactorTF} is displayed in
Figure \Ref{fig:ReactorTF_abg.ps} and its label file is listed in
Section \Ref{sec:ReactorTF_lbl}.  The subsystems are listed in Section
\Ref{sec:ReactorTF_sub}.

This example of a (nonlinear) chemical reactor is due to Trickett and
Bogle\footnote{ K. J. Tricket, \emph{Quantification of Inverse
    Responses for Controllability Assessment of Nonlinear Processes},
  PhD Thesis, University College London, 1994} is used in this
section.  The reactor has two reaction mechanisms: $\text{A}
\rightarrow \text{B} \rightarrow \text{C}$ and $\text{2A} \rightarrow
\text{D}$.  The reactor mass inflow and outflow $f_r$ are identical.
$q$ represents the heat inflow to the reactor.

The control loop $t$/$f$ has been inverted. The resulting SISO
system has two interpretations:
\begin{enumerate}
\item the \emph{dynamics} of the $c_b$/$q$ loop when the $t$/$f$ loop
  is under perfect control and
\item the \emph{inverse} dynamics of the  $t$/$f$ loop.
\end{enumerate}

\fig{ReactorTF_zero_1} {ReactorTF_zero_1} {0.9}
{System\textbf{ReactorTF}: zero 1 v flow} 
\fig{ReactorTF_zero_2} {ReactorTF_zero_2} {0.9}
{System\textbf{ReactorTF}: zero 2 v flow} 

Figures \Ref{fig:ReactorTF_zero_1} and \Ref{fig:ReactorTF_zero_2}
shows the poles of the linearised system as the steady-state flow
varies: these are the \emph{zeros} of the $t$/$f$ control-loop when
the $c_b$/$q$ loop is \emph{open}.


Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_input.txt version [5e10439ee4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (ReactorTF_input.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:38:44  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:12:57  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTF_sspar.r)
## as siso_sspar ecxept that inputs/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTF:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
#x3 = c_p*t_s*v_r;


#Steady-state input q needed to achieve steady-state t_s
q_s = -( (t_0-t_s)*c_p*f_s + e_1*h_1*k_1*x1 + e_2*h_2*k_2*x2 + e_3*h_3*k_3*pow(x1,2));

# Set the inputs
## Removed by MTT on Thu Jun  5 14:13:24 BST 2003: mttu(1) = q_s + 0.1*q_s*(t>0.01); # q (ReactorTF)
reactortf__t	=  q_s + 0.1*q_s*(t>0.01); # q (ReactorTF)

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_lbl.txt version [254ff21c0a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system ReactorTF (ReactorTF_lbl.txt)
%SUMMARY ReactorTF: Simple reactor model -- TF loop inverted
%DESCRIPTION Pseudo bond graph reactor model (based on ancient version)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:12:57  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%ALIAS Rate Chemical/Rate

% Extra variables
%VAR t_s
%VAR f_s
%VAR t_0
%VAR c_0
%VAR rho
%VAR v_r
%VAR e_1
%VAR e_2
%VAR e_3
%VAR a
%VAR b
%VAR c
%VAR c_A
%VAR c_B
%VAR x1
%VAR x2
%VAR x3
%VAR q_S

%VAR h
%VAR k
%VAR n
%VAR q


% Port aliases

% Argument aliases

%% each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m_a	lin		effort,1
	m_b	lin		effort,1
	h_r	lin		effort,c_p

% Component type FMR
	rfa	lin		effort,1		
	rfb	lin		effort,1		
	rt	lin		effort,c_p

% Component type Rate
        AB	Rate	k_1,q_1,h_1,1
	BC	Rate	k_2,q_2,h_2,1
	AD	Rate	k_3,q_3,h_3,2

% Component type SS
	c_0	SS		c_0,internal
	c_b	SS		external,0
	f	SS		internal,internal
	t	SS		t_s,external
	t_0	SS		t_0,internal



Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_numpar.m version [b474b96e57].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186


























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttpar = ReactorTF_numpar();
% mttpar = ReactorTF_numpar();
%System ReactorTF, representation numpar, language m;
%File ReactorTF_numpar.m;
%Generated by MTT on Thu Aug 24 14:28:46 BST 2000;
%

#====== Set up the global variables ======#
global ...
     a ...
     b ...
     c ...
     c_0 ...
     c_a ...
     c_b ...
     c_p ...
     e_1 ...
     e_2 ...
     e_3 ...
     f_s ...
     h ...
     h_1 ...
     h_2 ...
     h_3 ...
     k ...
     k_1 ...
     k_2 ...
     k_3 ...
     n ...
     q ...
     q_1 ...
     q_2 ...
     q_3 ...
     q_s ...
     rho ...
     t_0 ...
     t_s ...
     v_r ...
     x1 ...
     x2 ...
     x3 ;
## Set parameters to zero
 a = 0.0;
 b = 0.0;
 c = 0.0;
 c_0 = 0.0;
 c_a = 0.0;
 c_b = 0.0;
 c_p = 0.0;
 e_1 = 0.0;
 e_2 = 0.0;
 e_3 = 0.0;
 f_s = 0.0;
 h = 0.0;
 h_1 = 0.0;
 h_2 = 0.0;
 h_3 = 0.0;
 k = 0.0;
 k_1 = 0.0;
 k_2 = 0.0;
 k_3 = 0.0;
 n = 0.0;
 q = 0.0;
 q_1 = 0.0;
 q_2 = 0.0;
 q_3 = 0.0;
 q_s = 0.0;
 rho = 0.0;
 t_0 = 0.0;
 t_s = 0.0;
 v_r = 0.0;
 x1 = 0.0;
 x2 = 0.0;
 x3 = 0.0;
 %  -*-octave-*- Put Emacs into octave-mode
 %  Numerical parameter file (ReactorTF_numpar.txt)
 %  Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% Version control history
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% $Id$
 %  %% $Log$
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 % 
a =  0;				 %  Dummy
b =  0;				 %  Dummy
c =  0;				 %  Dummy
c_0 =  0;			 %  Dummy
c_a =  0;			 %  Dummy
c_b =  0;			 %  Dummy
c_p =  0;			 %  Dummy
e_1 =  0;			 %  Dummy
e_2 =  0;			 %  Dummy
e_3 =  0;			 %  Dummy
f_s =  0;			 %  Dummy
h =  0;				 %  Dummy
h_1 =  0;			 %  Dummy
h_2 =  0;			 %  Dummy
h_3 =  0;			 %  Dummy
k =  0;				 %  Dummy
k_1 =  0;			 %  Dummy
k_2 =  0;			 %  Dummy
k_3 =  0;			 %  Dummy
n =  0;				 %  Dummy
q =  0;				 %  Dummy
q_1 =  0;			 %  Dummy
q_2 =  0;			 %  Dummy
q_3 =  0;			 %  Dummy
q_s =  0;			 %  Dummy
rho =  0;			 %  Dummy
t_0 =  0;			 %  Dummy
t_s =  0;			 %  Dummy
v_r =  0;			 %  Dummy
x1 =  0;				 %  Dummy
x2 =  0;				 %  Dummy
x3 =  0;				 %  Dummy

 % 
rho =  900;			 %  Density
c_p =  5.0;			 %  Specific heat

 % 
k_1 =  2.5e10;			 %  Reaction rate constant
q_1 =  1e4;			 %  Exotherm constant
h_1 =  1e4;			 %  Heat of reaction

 % 
k_2 =  2.65e12;			 %  Reaction rate constant
q_2 =  1.2e4;			 %  Exotherm constant
h_2 =  1.2e4;			 %  Heat of reaction

 % 
k_3 =  6e7;			 %  Reaction rate constant
q_3 =  8e3;			 %  Exotherm constant
h_3 =  3e4;			 %  Heat of reaction

 % 
c_0 =  10;			 %  Inflow conc
t_0 =  500;			 %  Inflow temp

 % 
t_s =  530;			 %  Steady-state temp
f_s =  100;			 %  Steady-state flow








## Set up the parameter vector
  mttpar(1) 	= a;
  mttpar(2) 	= b;
  mttpar(3) 	= c;
  mttpar(4) 	= c_0;
  mttpar(5) 	= c_a;
  mttpar(6) 	= c_b;
  mttpar(7) 	= c_p;
  mttpar(8) 	= e_1;
  mttpar(9) 	= e_2;
  mttpar(10) 	= e_3;
  mttpar(11) 	= f_s;
  mttpar(12) 	= h;
  mttpar(13) 	= h_1;
  mttpar(14) 	= h_2;
  mttpar(15) 	= h_3;
  mttpar(16) 	= k;
  mttpar(17) 	= k_1;
  mttpar(18) 	= k_2;
  mttpar(19) 	= k_3;
  mttpar(20) 	= n;
  mttpar(21) 	= q;
  mttpar(22) 	= q_1;
  mttpar(23) 	= q_2;
  mttpar(24) 	= q_3;
  mttpar(25) 	= q_s;
  mttpar(26) 	= rho;
  mttpar(27) 	= t_0;
  mttpar(28) 	= t_s;
  mttpar(29) 	= v_r;
  mttpar(30) 	= x1;
  mttpar(31) 	= x2;
  mttpar(32) 	= x3;

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_numpar.txt version [28d37b19ef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (ReactorTF_numpar.txt)
# Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Dummies
a = 0;				# Dummy
b = 0;				# Dummy
c = 0;				# Dummy
c_0 = 0;			# Dummy
c_a = 0;			# Dummy
c_b = 0;			# Dummy
c_p = 0;			# Dummy
e_1 = 0;			# Dummy
e_2 = 0;			# Dummy
e_3 = 0;			# Dummy
f_s = 0;			# Dummy
h = 0;				# Dummy
h_1 = 0;			# Dummy
h_2 = 0;			# Dummy
h_3 = 0;			# Dummy
k = 0;				# Dummy
k_1 = 0;			# Dummy
k_2 = 0;			# Dummy
k_3 = 0;			# Dummy
n = 0;				# Dummy
q = 0;				# Dummy
q_1 = 0;			# Dummy
q_2 = 0;			# Dummy
q_3 = 0;			# Dummy
q_s = 0;			# Dummy
rho = 0;			# Dummy
t_0 = 0;			# Dummy
t_s = 0;			# Dummy
v_r = 0;			# Dummy
x1 = 0;				# Dummy
x2 = 0;				# Dummy
x3 = 0;				# Dummy

## The bulk liquid
rho = 900;			# Density
c_p = 5.0;			# Specific heat

## Substance A
k_1 = 2.5e10;			# Reaction rate constant
q_1 = 1e4;			# Exotherm constant
h_1 = 1e4;			# Heat of reaction

## Substance B
k_2 = 2.65e12;			# Reaction rate constant
q_2 = 1.2e4;			# Exotherm constant
h_2 = 1.2e4;			# Heat of reaction

## Substance C
k_3 = 6e7;			# Reaction rate constant
q_3 = 8e3;			# Exotherm constant
h_3 = 3e4;			# Heat of reaction

## Inflow parameters
c_0 = 10;			# Inflow conc
t_0 = 500;			# Inflow temp

## Steady-state values
t_s = 530;			# Steady-state temp
f_s = 100;			# Steady-state flow








Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_pic.fig version [c396b14562].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Landscape
Center
Inches
Letter  
100.00
Single
-2
1200 2
6 2400 3150 3225 3375
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2625 3300 2925 3300
4 0 -1 0 0 2 20 0.0000 4 210 210 2400 3375 A\001
4 0 -1 0 0 2 20 0.0000 4 210 225 3000 3375 D\001
-6
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 2100 2100 3900 1500 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 1500 4050 3900 4050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 1500 4350 2100 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2100 3600 3900 4200 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 3600 4350 4200 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 3900 4050 4200 4050
2 1 1 2 -1 -1 0 0 -1 6.000 0 0 -1 0 0 2
	 2100 2400 3600 2400
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2400 2925 2700 2925
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 3000 2925 3300 2925
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 2850 4800 2850 3750
4 0 -1 0 0 2 20 0.0000 4 210 210 2175 3000 A\001
4 0 -1 0 0 2 20 0.0000 4 210 195 2775 3000 B\001
4 0 -1 0 0 2 20 0.0000 4 210 210 3375 3000 C\001
4 0 -1 0 0 2 20 0.0000 4 210 150 2250 3375 2\001
4 0 -1 0 0 3 12 0.0000 4 135 90 1875 4950 0\001
4 0 -1 0 0 3 12 0.0000 4 135 90 2250 4950 0\001
4 0 -1 0 0 3 20 0.0000 4 210 150 2775 5025 q\001
4 0 -1 0 0 3 20 0.0000 4 285 765 1500 4800 f , c  , t\001
4 0 -1 0 0 3 20 0.0000 4 285 765 3600 4800 f , c  , t\001
4 0 -1 0 0 3 12 0.0000 4 135 90 3975 4950 b\001
4 0 -1 0 0 3 12 0.0000 4 90 75 4350 4950 r\001

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_rep.tex version [c4b39857a2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


\section{\textbf{ReactorTF}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:ReactorTF_abg.tex}
\index{\textbf{ReactorTF} -- abg}


MTT command:
\begin{verbatim}
mtt ReactorTF abg tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_abg.tex}


\section{\textbf{ReactorTF}: representation \textbf{cbg}, language \textbf{ps}}
\label{sec:ReactorTF_cbg.ps}
\index{\textbf{ReactorTF} -- cbg}


MTT command:
\begin{verbatim}
mtt ReactorTF cbg ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:ReactorTF_cbg.ps}.
\fig{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_cbg}
    {ReactorTF_cbg.ps}
    {0.9}
    {System \textbf{ReactorTF}, representation cbg}


\section{\textbf{ReactorTF}: representation \textbf{struc}, language \textbf{tex}}
\label{sec:ReactorTF_struc.tex}
\index{\textbf{ReactorTF} -- struc}


MTT command:
\begin{verbatim}
mtt ReactorTF struc tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_struc.tex}


\section{\textbf{ReactorTF}: representation \textbf{ode}, language \textbf{tex}}
\label{sec:ReactorTF_ode.tex}
\index{\textbf{ReactorTF} -- ode}


MTT command:
\begin{verbatim}
mtt ReactorTF ode tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_ode.tex}


\section{\textbf{ReactorTF}: representation \textbf{sspar}, language \textbf{tex}}
\label{sec:ReactorTF_sspar.tex}
\index{\textbf{ReactorTF} -- sspar}


MTT command:
\begin{verbatim}
mtt ReactorTF sspar tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_sspar.tex}


\section{\textbf{ReactorTF}: representation \textbf{ss}, language \textbf{tex}}
\label{sec:ReactorTF_ss.tex}
\index{\textbf{ReactorTF} -- ss}


MTT command:
\begin{verbatim}
mtt ReactorTF ss tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_ss.tex}


\section{\textbf{ReactorTF}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:ReactorTF_sm.tex}
\index{\textbf{ReactorTF} -- sm}


MTT command:
\begin{verbatim}
mtt ReactorTF sm tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_sm.tex}


\section{\textbf{ReactorTF}: representation \textbf{simpar}, language \textbf{tex}}
\label{sec:ReactorTF_simpar.tex}
\index{\textbf{ReactorTF} -- simpar}


MTT command:
\begin{verbatim}
mtt ReactorTF simpar tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_simpar.tex}


\section{\textbf{ReactorTF}: representation \textbf{numpar}, language \textbf{tex}}
\label{sec:ReactorTF_numpar.tex}
\index{\textbf{ReactorTF} -- numpar}


MTT command:
\begin{verbatim}
mtt ReactorTF numpar tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_numpar.tex}


\section{\textbf{ReactorTF}: representation \textbf{input}, language \textbf{tex}}
\label{sec:ReactorTF_input.tex}
\index{\textbf{ReactorTF} -- input}


MTT command:
\begin{verbatim}
mtt ReactorTF input tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_input.tex}


\section{\textbf{ReactorTF}: representation \textbf{state}, language \textbf{tex}}
\label{sec:ReactorTF_state.tex}
\index{\textbf{ReactorTF} -- state}


MTT command:
\begin{verbatim}
mtt ReactorTF state tex 
\end{verbatim}
  \input{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_state.tex}


\section{\textbf{ReactorTF}: representation \textbf{odeso}, language \textbf{ps}}
\label{sec:ReactorTF_odeso.ps}
\index{\textbf{ReactorTF} -- odeso}


MTT command:
\begin{verbatim}
mtt ReactorTF odeso ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:ReactorTF_odeso.ps}.
\fig{/home/peterg/JUNK/Reactor/ReactorTF/MTT_work/ReactorTF_odeso}
    {ReactorTF_odeso.ps}
    {0.9}
    {System \textbf{ReactorTF}, representation odeso}

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_rep.txt version [e9c51c0201].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system ReactorTF (ReactorTF_rep.txt)
## Generated by MTT on" Fri Mar  3 12:13:34 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:12:57  peterg
## To RCS
##
###############################################################

mtt ReactorTF abg tex			# The system description
mtt ReactorTF cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt ReactorTF struc tex	        # The system structure
## mtt ReactorTF dae tex	        # The system dae
mtt ReactorTF ode tex	        # The system ode 
mtt ReactorTF sspar tex		# Steady-state parameters
mtt ReactorTF ss tex 		# Steady state
## mtt ReactorTF dm tex		# Descriptor matrices (of linearised system)
mtt ReactorTF sm tex		# State matrices (of linearised system)
## mtt ReactorTF tf tex		# Transfer function (of linearised system)
## mtt ReactorTF lmfr ps		# log modulus of frequency response (of linearised system)
mtt ReactorTF simpar tex		# Simulation parameters
mtt ReactorTF numpar tex		# Numerical simulation parameters
mtt ReactorTF input tex		# Simulation input
mtt ReactorTF state tex		# Simulation initial state
mtt ReactorTF odeso ps		# Simulation

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_simp.r version [c0625028b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output (mimo_sim.r)
m_r   := rho*v_r;
%mttx1 := c_a*v_r;
%mttx2 := c_b*v_r;

% THIS MUST BE CHANGED - probs with cp and FMRs
%c_p := 1;

%let mttx3/c_p = t;

let  e^(q_1/(mttx3/c_p)) = 1/epsilon_1;
let  e^(q_2/(mttx3/c_p)) = 1/epsilon_2;
let  e^(q_3/(mttx3/c_p)) = 1/epsilon_3;

let  e^(q_1/t_s) = 1/epsilon_1;
let  e^(q_2/t_s) = 1/epsilon_2;
let  e^(q_3/t_s) = 1/epsilon_3;

FACTOR mttx1,mttx2;

END;

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_simpar.txt version [a9ebdd151e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ReactorTF (ReactorTF_simpar.txt)
# Generated by MTT on Fri Mar 3 12:11:48 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 0.05;       # Last time in simulation
DT          = 0.0002;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_sm.m version [8997bae617].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [mtta,mttb,mttc,mttd] = ReactorTF_sm(mttpar);
% [mtta,mttb,mttc,mttd] = ReactorTF_sm(mttpar);
%System ReactorTF, representation sm, language m;
%File ReactorTF_sm.m;
%Generated by MTT on Thu Aug 24 14:45:50 BST 2000;
%
%====== Set up the global variables ======%
global ...
a ...
b ...
c ...
c_0 ...
c_a ...
c_b ...
c_p ...
e_1 ...
e_2 ...
e_3 ...
f_s ...
h ...
h_1 ...
h_2 ...
h_3 ...
k ...
k_1 ...
k_2 ...
k_3 ...
n ...
q ...
q_1 ...
q_2 ...
q_3 ...
q_s ...
rho ...
t_0 ...
t_s ...
v_r ...
x1 ...
x2 ...
x3 ;
a 	= mttpar(1);
b 	= mttpar(2);
c 	= mttpar(3);
c_0 	= mttpar(4);
c_a 	= mttpar(5);
c_b 	= mttpar(6);
c_p 	= mttpar(7);
e_1 	= mttpar(8);
e_2 	= mttpar(9);
e_3 	= mttpar(10);
f_s 	= mttpar(11);
h 	= mttpar(12);
h_1 	= mttpar(13);
h_2 	= mttpar(14);
h_3 	= mttpar(15);
k 	= mttpar(16);
k_1 	= mttpar(17);
k_2 	= mttpar(18);
k_3 	= mttpar(19);
n 	= mttpar(20);
q 	= mttpar(21);
q_1 	= mttpar(22);
q_2 	= mttpar(23);
q_3 	= mttpar(24);
q_s 	= mttpar(25);
rho 	= mttpar(26);
t_0 	= mttpar(27);
t_s 	= mttpar(28);
v_r 	= mttpar(29);
x1 	= mttpar(30);
x2 	= mttpar(31);
x3 	= mttpar(32);
%a matrix%
mtta = zeros(2,2);
mtt_t1 = exp((2.0*q_1+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s^2*h_3;
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_0*f_s*h_3*k_3;
mtt_t1 = mtt_t1-(exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_1*k_1);
mtt_t1 = mtt_t1+2.0*exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_3*k_1;
mtt_t1 = mtt_t1-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))^2*c_0*h_1*k_1*k_3);
mtt_t1 = mtt_t1+2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))^2*c_0*h_3*k_1*k_3;
mtt_t1 = mtt_t1-(exp(q_3/t_s)*abs(exp(q_1/t_s))^2*h_1*k_1^2);
mtt_t1 = mtt_t1+exp(q_3/t_s)*abs(exp(q_1/t_s))^2*h_3*k_1^2;
mtt_t3 = 2.0*exp((2.0*q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t4 = 2.0*exp((2.0*q_1)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t4 = mtt_t4*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t3*abs(exp(q_1/t_s))*f_s*h_3)-(mtt_t4*abs(exp(q_1/t_s))*c_0*h_3*k_3);
mtt_t5 = 2.0*exp((2.0*q_1)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t5 = mtt_t5*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t3 = 2.0*exp((2.0*q_1)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t5*abs(exp(q_1/t_s))*c_p*k_3*t_0)+mtt_t3*abs(exp(q_1/t_s))*c_p*k_3*t_s;
mtt_t4 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t4 = mtt_t4*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t3 = 2.0*exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1+mtt_t4*abs(exp(q_1/t_s))*h_1*k_1-(mtt_t3*abs(exp(q_1/t_s))*h_3*k_1);
mtt_t1 = mtt_t1+exp((4.0*q_1+q_3)/t_s)*f_s^2*h_3;
mtt_t1 = mtt_t1+4.0*exp((4.0*q_1)/t_s)*c_0*f_s*h_3*k_3;
mtt_t1 = mtt_t1+2.0*exp((3.0*q_1+q_3)/t_s)*f_s*h_3*k_1;
mtt_t1 = mtt_t1+exp((2.0*q_1+q_3)/t_s)*h_3*k_1^2;
mtt_t2 = 2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_3*t_0;
mtta(1,1) = mtt_t1/(mtt_t2-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_3*t_s));
mtt_t1 = -(exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*h_2*k_2);
mtt_t1 = mtt_t1-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_0*h_2*k_2*k_3);
mtt_t3 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(exp(q_3/t_s)*abs(exp(q_1/t_s))*h_2*k_1*k_2)+mtt_t3*h_2*k_2;
mtt_t2 = 2.0*exp((q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_0;
mtta(1,2) = mtt_t1/(mtt_t2-(2.0*exp((q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_s));
mtt_t1 = exp((2.0*q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s^2*h_3*k_1;
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_1*k_3*t_0;
mtt_t1 = mtt_t1-(2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_1*k_3*t_s);
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_1*k_2*k_3*t_0;
mtt_t1 = mtt_t1-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_1*k_2*k_3*t_s);
mtt_t1 = mtt_t1-(exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_1*k_1^2);
mtt_t1 = mtt_t1+2.0*exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*f_s*h_3*k_1^2;
mtt_t1 = mtt_t1-(exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*h_1*k_1^3);
mtt_t1 = mtt_t1+exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))^2*h_3*k_1^3;
mtt_t3 = 2.0*exp((2.0*q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t4 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t4 = mtt_t4*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t3*abs(exp(q_1/t_s))*f_s*h_3*k_1)+mtt_t4*abs(exp(q_1/t_s))*h_1*k_1^2;
mtt_t5 = 2.0*exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t5 = mtt_t5*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(mtt_t5*abs(exp(q_1/t_s))*h_3*k_1^2);
mtt_t1 = mtt_t1+exp((4.0*q_1+q_2+q_3)/t_s)*f_s^2*h_3*k_1;
mtt_t1 = mtt_t1+4.0*exp((4.0*q_1+q_2)/t_s)*c_0*f_s*h_3*k_1*k_3;
mtt_t1 = mtt_t1+2.0*exp((3.0*q_1+q_2+q_3)/t_s)*f_s*h_3*k_1^2;
mtt_t1 = mtt_t1+exp((2.0*q_1+q_2+q_3)/t_s)*h_3*k_1^3;
mtt_t2 = 2.0*exp((3.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_3*t_0;
mtt_t2 = mtt_t2-(2.0*exp((3.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))^2*c_p*f_s*k_3*t_s);
mtt_t2 = mtt_t2+2.0*exp((3.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_2*k_3*t_0;
mtta(2,1) = mtt_t1/(mtt_t2-(2.0*exp((3.0*q_1)/t_s)*abs(exp(q_1/t_s))^2*c_p*k_2*k_3*t_s));
mtt_t1 = -(2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s^2*k_3*t_0);
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s^2*k_3*t_s;
mtt_t1 = mtt_t1-(4.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_2*k_3*t_0);
mtt_t1 = mtt_t1+4.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_2*k_3*t_s;
mtt_t1 = mtt_t1-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2^2*k_3*t_0);
mtt_t1 = mtt_t1+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2^2*k_3*t_s;
mtt_t1 = mtt_t1-(exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*h_2*k_1*k_2);
mtt_t1 = mtt_t1-(exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))*h_2*k_1^2*k_2);
mtt_t3 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1+mtt_t3*h_2*k_1*k_2;
mtt_t2 = 2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_0;
mtt_t2 = mtt_t2-(2.0*exp((2.0*q_1+2.0*q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_s);
mtt_t2 = mtt_t2+2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_0;
mtta(2,2) = mtt_t1/(mtt_t2-(2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_s));
%b matrix%
mttb = zeros(2,1);
mtt_t1 = -(exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))*f_s);
mtt_t1 = mtt_t1-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_0*k_3);
mtt_t1 = mtt_t1-(exp(q_3/t_s)*abs(exp(q_1/t_s))*k_1);
mtt_t3 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t1 = mtt_t1+mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t4 = 2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_0;
mttb(1) = mtt_t1/(mtt_t4-(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_p*k_3*t_s));
mtt_t1 = -(exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*k_1);
mtt_t3 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1-(exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))*k_1^2)+mtt_t3*k_1;
mtt_t2 = 2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_0;
mtt_t2 = mtt_t2-(2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*c_p*f_s*k_3*t_s);
mtt_t2 = mtt_t2+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_0;
mttb(2) = mtt_t1/(mtt_t2-(2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*c_p*k_2*k_3*t_s));
%c matrix%
mttc = zeros(1,2);
mttc(1,2) = 1.0;
%d matrix%
mttd = zeros(1,1);

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_sspar.r version [5ae7de35e5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file (ReactorTF_sspar.r)
%% as siso_sspar ecxept that inputs/states have different meaning
%% Steady state for constant c_a, c_b and t=t_s and f=f_s

%% Unit volume ReactorTF:
v_r := 1;

%% Do the inputs first -- this avoids problems with reduce not
%% recognising that complicated expressions are zero

%% The exponentials.
e_1 := e^(-q_1/t_s);
e_2 := e^(-q_2/t_s);
e_3 := e^(-q_3/t_s);

%Steady-state input q needed to achieve steady-state t_s
q_s := -( 
        + (t_0-t_s)*c_p*f_s
        + e_1*h_1*k_1*x1
        + e_2*h_2*k_2*x2
        + e_3*h_3*k_3*x1^2
       );

%% The input at steady-state
MTTu1 := q_s;

%States (masses)
x1 := c_a*v_r;
x2 := c_b*v_r;

%Thermal state
x3 := c_p*t_s*v_r;

%Load up the vectors
MTTx1 := x1;
MTTx2 := x2;

MTTy1 := c_b;
%MTTy2 := t_s;

%% Finally, solve for the steady-state concentrations
%% Solve for ca - a quadratic.
a 	:= k_3*e_3;	%ca^2 
b 	:= k_1*e_1 + f_s;	%ca^1 
c 	:= -c_0*f_s;

c_a	:= (-b + sqrt(b^2 - 4*a*c))/(2*a);

%% solve for c_b
c_b 	:= c_a*k_1*e_1/(f_s+k_2*e_2);


END;


Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_state.txt version [9b324c96c8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# State specification (ReactorTF_state.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:39:05  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:12:57  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTF_sspar.r)
## as siso_sspar ecxept that states/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTF:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
#x3 = c_p*t_s*v_r;

## Load up the states
## Removed by MTT on Thu Jun  5 14:14:18 BST 2003: mttx(1) = x1;
## Removed by MTT on Thu Jun  5 14:14:18 BST 2003: mttx(2) = x2;
## Removed by MTT on Thu Jun  5 14:14:18 BST 2003: mttx(3) = x3;




reactortf__m_a	= x1;
reactortf__m_b	= x2;

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTF/ReactorTF_sympar.m version [971206bf83].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function sympar = ReactorTF_sympar();
% sympar = ReactorTF_sympar();
%System ReactorTF, representation sympar, language m;
%File ReactorTF_sympar.m;
%Generated by MTT on Thu Aug 24 14:45:51 BST 2000;
%
global ...
mtt_no_globals ;
  sympar.a 	= 1; # ReactorTF
  sympar.b 	= 2; # ReactorTF
  sympar.c 	= 3; # ReactorTF
  sympar.c_0 	= 4; # ReactorTF
  sympar.c_A 	= 5; # ReactorTF
  sympar.c_B 	= 6; # ReactorTF
  sympar.c_p 	= 7; # ReactorTF
  sympar.e_1 	= 8; # ReactorTF
  sympar.e_2 	= 9; # ReactorTF
  sympar.e_3 	= 10; # ReactorTF
  sympar.f_s 	= 11; # ReactorTF
  sympar.h 	= 12; # Rate
  sympar.h_1 	= 13; # ReactorTF
  sympar.h_2 	= 14; # ReactorTF
  sympar.h_3 	= 15; # ReactorTF
  sympar.k 	= 16; # Rate
  sympar.k_1 	= 17; # ReactorTF
  sympar.k_2 	= 18; # ReactorTF
  sympar.k_3 	= 19; # ReactorTF
  sympar.n 	= 20; # Rate
  sympar.q 	= 21; # Rate
  sympar.q_1 	= 22; # ReactorTF
  sympar.q_2 	= 23; # ReactorTF
  sympar.q_3 	= 24; # ReactorTF
  sympar.q_S 	= 25; # ReactorTF
  sympar.rho 	= 26; # ReactorTF
  sympar.t_0 	= 27; # ReactorTF
  sympar.t_s 	= 28; # ReactorTF
  sympar.v_r 	= 29; # ReactorTF
  sympar.x1 	= 30; # ReactorTF
  sympar.x2 	= 31; # ReactorTF
  sympar.x3 	= 32; # ReactorTF

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/MakeFigure.m version [f0f759751c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Makes the figures

par = ReactorTQ_numpar;		# Parameters
sym = ReactorTQ_sympar;		# Parameter indices

F_s= [90:10:500];		# Range of flows

Z = [];
for f_s=F_s
  par(sym.f_s) = f_s;
  z = sort(eig(ReactorTQ_sm(par)));
  Z = [Z z];
endfor


grid; xlabel("f_s"); ylabel("z");
plot(F_s,Z);
psfig("ReactorTQ_zero");

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/Makefile version [1134f9d9da].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
## Makes the schematic diagram and the zero figure
all: ReactorTQ_pic.ps ReactorTQ_zero.ps

ReactorTQ_pic.ps: ReactorTQ_pic.fig
	fig2dev -Lps ReactorTQ_pic.fig> ReactorTQ_pic.ps

ReactorTQ_zero.ps: ReactorTQ_abg.fig
	mtt -q ReactorTQ sm m; mtt -q ReactorTQ numpar m;
	mtt -q ReactorTQ sympar m;
	octave MakeFigure.m

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_abg.fig version [79f241dde0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3001 8701 3001 7801 3151 7951
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1801 9001 2701 9001 2551 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 8776 2701 9226
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3301 9001 4201 9001 4051 9151
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4201 9301 3601 9901 3826 9901
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5701 9001 4801 9001 4951 9151
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 6000 2700 6000 2550 6150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 10350 5025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6000 1800 5775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 6225 1800 6000
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 10200 600 10200 600 7500 11100 7500 11100 10200
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 6600 600 6600 600 5400 11100 5400 11100 6600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4800 4500 8700 4650 8550
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6000 4800 4800 8700 5025 8625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4800 5100 8700 5400 8700
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4800 4275 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 4200 4275 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4800 5775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 6225 4200 5775 4200
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4800 8775 4800
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 4200 8775 4200
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 7200 3000 6300 3150 6450
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10500 4800 3300 6000 3525 6075
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 5100 600 5100 600 3300 11100 3300 11100 5100
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4485 2395 4485 4130 4633 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 2999 2395 2999 4130 3148 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 5970 2395 5970 4130 6119 3841
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 10428 2397 10428 4132 10577 3843
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 1800 2100 2700 2100 2550 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3300 2100 4200 2100 4050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 4800 2100 5700 2100 5550 2250
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 4200 1800 3600 1200 3600 1425
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 1875 2700 2325
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 8701 1801 8101 1201 8101 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 9301 2101 10201 2101 10051 2251
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 9301 1801 9901 1201 9901 1426
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 6300 2100 7200 2100 7050 2250
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 7800 2100 8700 2100 8550 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1950 4350 1650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10050 1350 9900 1200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 1200 9750 1050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 1950 8850 1650
2 4 1 2 1 7 0 0 -1 4.000 0 0 7 0 0 5
	 11100 300 600 300 600 2700 11100 2700 11100 300
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 3000 4800 3000 5700 3150 5550
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 2
	 4800 8775 4800 9225
2 1 0 2 0 0 0 0 -1 0.000 0 0 0 0 0 3
	 8943 2397 8943 4132 9091 3843
4 1 0 0 0 0 20 0.0000 4 195 1065 3075 4575 FMR:rfa\001
4 1 0 0 0 0 20 0.0000 4 195 1065 4575 4575 Rate:AD\001
4 1 0 0 0 0 20 0.0000 4 195 1050 6000 4575 Rate:AB\001
4 2 0 0 0 0 20 0.0000 4 255 810 1651 9076 SS:t_0\001
4 2 0 0 0 0 20 0.0000 4 255 690 3451 9976 C:h_r\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 6075 1\001
4 2 0 0 0 0 20 0.0000 4 210 525 1725 6075 SS:f\001
4 1 0 0 0 0 20 0.0000 4 195 150 3001 9076 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4501 9076 0\001
4 1 0 0 0 0 20 0.0000 4 195 1035 9001 4576 Rate:BC\001
4 1 0 0 0 0 20 0.0000 4 210 1080 10576 4576 FMR:rfb\001
4 1 1 1 0 3 20 0.0000 4 195 2595 9600 7800 THERMAL MODEL\001
4 1 1 1 0 3 20 0.0000 4 195 2865 9450 5700 HYDRAULIC MODEL\001
4 1 0 0 0 0 20 0.0000 4 195 915 3000 7575 FMR:rt\001
4 1 1 1 0 3 20 0.0000 4 195 2640 9675 3750 REACTION MODEL\001
4 2 0 0 0 0 20 0.0000 4 255 855 1650 2175 SS:c_0\001
4 1 0 0 0 0 20 0.0000 4 195 150 3000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 4500 2175 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 6000 2175 1\001
4 1 0 0 0 0 20 0.0000 4 195 150 9001 2176 0\001
4 1 0 0 0 0 20 0.0000 4 195 150 10501 2176 1\001
4 1 0 0 0 0 20 0.0000 4 195 375 7500 2175 AF\001
4 1 0 0 0 0 20 0.0000 4 255 825 8100 1050 C:m_b\001
4 1 0 0 0 0 20 0.0000 4 255 855 9975 1050 SS:c_b\001
4 1 0 0 0 0 20 0.0000 4 240 810 3600 1050 C:m_a\001
4 1 1 1 0 3 20 0.0000 4 195 3645 9075 600 CONCENTRATION MODEL\001
4 1 0 0 0 0 20 0.0000 4 210 510 6151 9076 SS:t\001

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_args.new version [5936bc7523].

1

-
 

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_desc.tex version [74095d0a13].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ReactorTQ (ReactorTQ_desc.tex)
% Generated by MTT on Fri Mar 3 12:43:33 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fig{ReactorTQ_pic}
{ReactorTQ_pic} {0.9} {System \textbf{ReactorTQ}, Schematic}

Figure \Ref{fig:ReactorTQ_pic} is the schematic diagram of a chemical
reactor.

The acausal bond graph of system \textbf{ReactorTQ} is displayed in
Figure \Ref{fig:ReactorTQ_abg.ps} and its label file is listed in
Section \Ref{sec:ReactorTQ_lbl}.  The subsystems are listed in Section
\Ref{sec:ReactorTQ_sub}.

This example of a (nonlinear) chemical reactor is due to Trickett and
Bogle\footnote{ K. J. Tricket, \emph{Quantification of Inverse
    Responses for Controllability Assessment of Nonlinear Processes},
  PhD Thesis, University College London, 1994} is used in this
section.  The reactor has two reaction mechanisms: $\text{A}
\rightarrow \text{B} \rightarrow \text{C}$ and $\text{2A} \rightarrow
\text{D}$.  The reactor mass inflow and outflow $f_r$ are identical.
$q$ represents the heat inflow to the reactor.

The control loop $t$/$q$ has been inverted. The resulting SISO
system has two interpretations:
\begin{enumerate}
\item the \emph{dynamics} of the $c_b$/$f$ loop when the $t$/$q$ loop
  is under perfect control and
\item the \emph{inverse} dynamics of the  $t$/$q$ loop.
\end{enumerate}

\fig{ReactorTQ_zero} {ReactorTQ_zero} {0.9}
{System\textbf{ReactorTQ}: zeros v flow} 

Figure \Ref{fig:ReactorTQ_zero}
shows the poles of the linearised system as the steady-state flow
varies: these are the \emph{zeros} of the $c_b$/$f$ control-loop when
the $t$/$q$ loop is \emph{open}.


Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_input.txt version [f56e13e871].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (ReactorTQ_input.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:39:20  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:19:08  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTQ_sspar.r)
## as siso_sspar ecxept that inputs/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTQ:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;

#Thermal state
x3 = c_p*t_s*v_r;

# Set the inputs
## Removed by MTT on Thu Jun  5 14:27:42 BST 2003: mttu(1) = f_s + 0.1*f_s*(t>0.01); # f (ReactorTQ)
reactortq__f	=  f_s + 0.1*f_s*(t>0.01); # f (ReactorTQ)

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_lbl.txt version [a344d9fe61].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system ReactorTQ (ReactorTQ_lbl.txt)
%SUMMARY ReactorTQ: Simple reactor model - with TQ loop inverted
%DESCRIPTION Pseudo bond graph reactor model (based on ancient version)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:19:08  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%ALIAS Rate Chemical/Rate

% Extra variables
%VAR t_s
%VAR f_s
%VAR t_0
%VAR c_0
%VAR rho
%VAR v_r
%VAR e_1
%VAR e_2
%VAR e_3
%VAR a
%VAR b
%VAR c
%VAR c_A
%VAR c_B
%VAR x1
%VAR x2
%VAR x3
%VAR q_S

%VAR h
%VAR k
%VAR n
%VAR q


% Port aliases

% Argument aliases

%% each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type C
	m_a	lin		effort,1
	m_b	lin		effort,1
	h_r	lin		effort,c_p

% Component type FMR
	rfa	lin		effort,1		
	rfb	lin		effort,1		
	rt	lin		effort,c_p

% Component type Rate
        AB	Rate	k_1,q_1,h_1,1
	BC	Rate	k_2,q_2,h_2,1
	AD	Rate	k_3,q_3,h_3,2

% Component type SS
	c_0	SS		c_0,internal
	c_b	SS		external,0
	f	SS		internal,external
	t	SS		t_s,internal
	t_0	SS		t_0,internal



Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_numpar.m version [ae40d20e8b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186


























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttpar = ReactorTQ_numpar();
% mttpar = ReactorTQ_numpar();
%System ReactorTQ, representation numpar, language m;
%File ReactorTQ_numpar.m;
%Generated by MTT on Thu Aug 24 14:29:20 BST 2000;
%

#====== Set up the global variables ======#
global ...
     a ...
     b ...
     c ...
     c_0 ...
     c_a ...
     c_b ...
     c_p ...
     e_1 ...
     e_2 ...
     e_3 ...
     f_s ...
     h ...
     h_1 ...
     h_2 ...
     h_3 ...
     k ...
     k_1 ...
     k_2 ...
     k_3 ...
     n ...
     q ...
     q_1 ...
     q_2 ...
     q_3 ...
     q_s ...
     rho ...
     t_0 ...
     t_s ...
     v_r ...
     x1 ...
     x2 ...
     x3 ;
## Set parameters to zero
 a = 0.0;
 b = 0.0;
 c = 0.0;
 c_0 = 0.0;
 c_a = 0.0;
 c_b = 0.0;
 c_p = 0.0;
 e_1 = 0.0;
 e_2 = 0.0;
 e_3 = 0.0;
 f_s = 0.0;
 h = 0.0;
 h_1 = 0.0;
 h_2 = 0.0;
 h_3 = 0.0;
 k = 0.0;
 k_1 = 0.0;
 k_2 = 0.0;
 k_3 = 0.0;
 n = 0.0;
 q = 0.0;
 q_1 = 0.0;
 q_2 = 0.0;
 q_3 = 0.0;
 q_s = 0.0;
 rho = 0.0;
 t_0 = 0.0;
 t_s = 0.0;
 v_r = 0.0;
 x1 = 0.0;
 x2 = 0.0;
 x3 = 0.0;
 %  -*-octave-*- Put Emacs into octave-mode
 %  Numerical parameter file (ReactorTQ_numpar.txt)
 %  Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% Version control history
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %  %% $Id$
 %  %% $Log$
 %  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 % 
a =  0;				 %  Dummy
b =  0;				 %  Dummy
c =  0;				 %  Dummy
c_0 =  0;			 %  Dummy
c_a =  0;			 %  Dummy
c_b =  0;			 %  Dummy
c_p =  0;			 %  Dummy
e_1 =  0;			 %  Dummy
e_2 =  0;			 %  Dummy
e_3 =  0;			 %  Dummy
f_s =  0;			 %  Dummy
h =  0;				 %  Dummy
h_1 =  0;			 %  Dummy
h_2 =  0;			 %  Dummy
h_3 =  0;			 %  Dummy
k =  0;				 %  Dummy
k_1 =  0;			 %  Dummy
k_2 =  0;			 %  Dummy
k_3 =  0;			 %  Dummy
n =  0;				 %  Dummy
q =  0;				 %  Dummy
q_1 =  0;			 %  Dummy
q_2 =  0;			 %  Dummy
q_3 =  0;			 %  Dummy
q_s =  0;			 %  Dummy
rho =  0;			 %  Dummy
t_0 =  0;			 %  Dummy
t_s =  0;			 %  Dummy
v_r =  0;			 %  Dummy
x1 =  0;				 %  Dummy
x2 =  0;				 %  Dummy
x3 =  0;				 %  Dummy

 % 
rho =  900;			 %  Density
c_p =  5.0;			 %  Specific heat

 % 
k_1 =  2.5e10;			 %  Reaction rate constant
q_1 =  1e4;			 %  Exotherm constant
h_1 =  1e4;			 %  Heat of reaction

 % 
k_2 =  2.65e12;			 %  Reaction rate constant
q_2 =  1.2e4;			 %  Exotherm constant
h_2 =  1.2e4;			 %  Heat of reaction

 % 
k_3 =  6e7;			 %  Reaction rate constant
q_3 =  8e3;			 %  Exotherm constant
h_3 =  3e4;			 %  Heat of reaction

 % 
c_0 =  10;			 %  Inflow conc
t_0 =  530;			 %  Inflow temp

 % 
t_s =  530;			 %  Steady-state temp
f_s =  100;			 %  Steady-state flow








## Set up the parameter vector
  mttpar(1) 	= a;
  mttpar(2) 	= b;
  mttpar(3) 	= c;
  mttpar(4) 	= c_0;
  mttpar(5) 	= c_a;
  mttpar(6) 	= c_b;
  mttpar(7) 	= c_p;
  mttpar(8) 	= e_1;
  mttpar(9) 	= e_2;
  mttpar(10) 	= e_3;
  mttpar(11) 	= f_s;
  mttpar(12) 	= h;
  mttpar(13) 	= h_1;
  mttpar(14) 	= h_2;
  mttpar(15) 	= h_3;
  mttpar(16) 	= k;
  mttpar(17) 	= k_1;
  mttpar(18) 	= k_2;
  mttpar(19) 	= k_3;
  mttpar(20) 	= n;
  mttpar(21) 	= q;
  mttpar(22) 	= q_1;
  mttpar(23) 	= q_2;
  mttpar(24) 	= q_3;
  mttpar(25) 	= q_s;
  mttpar(26) 	= rho;
  mttpar(27) 	= t_0;
  mttpar(28) 	= t_s;
  mttpar(29) 	= v_r;
  mttpar(30) 	= x1;
  mttpar(31) 	= x2;
  mttpar(32) 	= x3;

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_numpar.txt version [099621e14f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (ReactorTQ_numpar.txt)
# Generated by MTT at Fri Mar  3 09:22:56 GMT 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Dummies
a = 0;				# Dummy
b = 0;				# Dummy
c = 0;				# Dummy
c_0 = 0;			# Dummy
c_a = 0;			# Dummy
c_b = 0;			# Dummy
c_p = 0;			# Dummy
e_1 = 0;			# Dummy
e_2 = 0;			# Dummy
e_3 = 0;			# Dummy
f_s = 0;			# Dummy
h = 0;				# Dummy
h_1 = 0;			# Dummy
h_2 = 0;			# Dummy
h_3 = 0;			# Dummy
k = 0;				# Dummy
k_1 = 0;			# Dummy
k_2 = 0;			# Dummy
k_3 = 0;			# Dummy
n = 0;				# Dummy
q = 0;				# Dummy
q_1 = 0;			# Dummy
q_2 = 0;			# Dummy
q_3 = 0;			# Dummy
q_s = 0;			# Dummy
rho = 0;			# Dummy
t_0 = 0;			# Dummy
t_s = 0;			# Dummy
v_r = 0;			# Dummy
x1 = 0;				# Dummy
x2 = 0;				# Dummy
x3 = 0;				# Dummy

## The bulk liquid
rho = 900;			# Density
c_p = 5.0;			# Specific heat

## Substance A
k_1 = 2.5e10;			# Reaction rate constant
q_1 = 1e4;			# Exotherm constant
h_1 = 1e4;			# Heat of reaction

## Substance B
k_2 = 2.65e12;			# Reaction rate constant
q_2 = 1.2e4;			# Exotherm constant
h_2 = 1.2e4;			# Heat of reaction

## Substance C
k_3 = 6e7;			# Reaction rate constant
q_3 = 8e3;			# Exotherm constant
h_3 = 3e4;			# Heat of reaction

## Inflow parameters
c_0 = 10;			# Inflow conc
t_0 = 530;			# Inflow temp

## Steady-state values
t_s = 530;			# Steady-state temp
f_s = 100;			# Steady-state flow








Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_pic.fig version [c396b14562].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Landscape
Center
Inches
Letter  
100.00
Single
-2
1200 2
6 2400 3150 3225 3375
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2625 3300 2925 3300
4 0 -1 0 0 2 20 0.0000 4 210 210 2400 3375 A\001
4 0 -1 0 0 2 20 0.0000 4 210 225 3000 3375 D\001
-6
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 2100 2100 3900 1500 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 1500 4050 3900 4050
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 1500 4350 2100 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 2100 3600 3900 4200 3900
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 3600 4350 4200 4350
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
	 3900 4050 4200 4050
2 1 1 2 -1 -1 0 0 -1 6.000 0 0 -1 0 0 2
	 2100 2400 3600 2400
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 2400 2925 2700 2925
2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 1.00 60.00 120.00
	 3000 2925 3300 2925
2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 2850 4800 2850 3750
4 0 -1 0 0 2 20 0.0000 4 210 210 2175 3000 A\001
4 0 -1 0 0 2 20 0.0000 4 210 195 2775 3000 B\001
4 0 -1 0 0 2 20 0.0000 4 210 210 3375 3000 C\001
4 0 -1 0 0 2 20 0.0000 4 210 150 2250 3375 2\001
4 0 -1 0 0 3 12 0.0000 4 135 90 1875 4950 0\001
4 0 -1 0 0 3 12 0.0000 4 135 90 2250 4950 0\001
4 0 -1 0 0 3 20 0.0000 4 210 150 2775 5025 q\001
4 0 -1 0 0 3 20 0.0000 4 285 765 1500 4800 f , c  , t\001
4 0 -1 0 0 3 20 0.0000 4 285 765 3600 4800 f , c  , t\001
4 0 -1 0 0 3 12 0.0000 4 135 90 3975 4950 b\001
4 0 -1 0 0 3 12 0.0000 4 90 75 4350 4950 r\001

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_rep.txt version [eb12752c52].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system ReactorTQ (ReactorTQ_rep.txt)
## Generated by MTT on" Fri Mar  3 12:13:34 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:19:08  peterg
## To RCS
##
###############################################################

mtt ReactorTQ abg tex			# The system description
mtt ReactorTQ cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt ReactorTQ struc tex	        # The system structure
## mtt ReactorTQ dae tex	        # The system dae
mtt ReactorTQ ode tex	        # The system ode 
## mtt ReactorTQ sspar tex		# Steady-state parameters
## mtt ReactorTQ ss tex 		# Steady state
## mtt ReactorTQ dm tex		# Descriptor matrices (of linearised system)
mtt ReactorTQ sm tex		# State matrices (of linearised system)
## mtt ReactorTQ tf tex		# Transfer function (of linearised system)
## mtt ReactorTQ lmfr ps		# log modulus of frequency response (of linearised system)
mtt ReactorTQ simpar tex		# Simulation parameters
mtt ReactorTQ numpar tex		# Numerical simulation parameters
mtt ReactorTQ input tex		# Simulation input
mtt ReactorTQ state tex		# Simulation initial state

mtt  ReactorTQ odeso ps

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_simp.r version [c0625028b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output (mimo_sim.r)
m_r   := rho*v_r;
%mttx1 := c_a*v_r;
%mttx2 := c_b*v_r;

% THIS MUST BE CHANGED - probs with cp and FMRs
%c_p := 1;

%let mttx3/c_p = t;

let  e^(q_1/(mttx3/c_p)) = 1/epsilon_1;
let  e^(q_2/(mttx3/c_p)) = 1/epsilon_2;
let  e^(q_3/(mttx3/c_p)) = 1/epsilon_3;

let  e^(q_1/t_s) = 1/epsilon_1;
let  e^(q_2/t_s) = 1/epsilon_2;
let  e^(q_3/t_s) = 1/epsilon_3;

FACTOR mttx1,mttx2;

END;

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_simpar.txt version [c234b6a60c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ReactorTQ (ReactorTQ_simpar.txt)
# Generated by MTT on Fri Mar 3 12:11:48 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 0.05;       # Last time in simulation
DT          = 0.0002;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_sm.m version [7b078c7c09].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [mtta,mttb,mttc,mttd] = ReactorTQ_sm(mttpar);
% [mtta,mttb,mttc,mttd] = ReactorTQ_sm(mttpar);
%System ReactorTQ, representation sm, language m;
%File ReactorTQ_sm.m;
%Generated by MTT on Thu Aug 24 14:47:46 BST 2000;
%
%====== Set up the global variables ======%
global ...
a ...
b ...
c ...
c_0 ...
c_a ...
c_b ...
c_p ...
e_1 ...
e_2 ...
e_3 ...
f_s ...
h ...
h_1 ...
h_2 ...
h_3 ...
k ...
k_1 ...
k_2 ...
k_3 ...
n ...
q ...
q_1 ...
q_2 ...
q_3 ...
q_s ...
rho ...
t_0 ...
t_s ...
v_r ...
x1 ...
x2 ...
x3 ;
a 	= mttpar(1);
b 	= mttpar(2);
c 	= mttpar(3);
c_0 	= mttpar(4);
c_a 	= mttpar(5);
c_b 	= mttpar(6);
c_p 	= mttpar(7);
e_1 	= mttpar(8);
e_2 	= mttpar(9);
e_3 	= mttpar(10);
f_s 	= mttpar(11);
h 	= mttpar(12);
h_1 	= mttpar(13);
h_2 	= mttpar(14);
h_3 	= mttpar(15);
k 	= mttpar(16);
k_1 	= mttpar(17);
k_2 	= mttpar(18);
k_3 	= mttpar(19);
n 	= mttpar(20);
q 	= mttpar(21);
q_1 	= mttpar(22);
q_2 	= mttpar(23);
q_3 	= mttpar(24);
q_s 	= mttpar(25);
rho 	= mttpar(26);
t_0 	= mttpar(27);
t_s 	= mttpar(28);
v_r 	= mttpar(29);
x1 	= mttpar(30);
x2 	= mttpar(31);
x3 	= mttpar(32);
%a matrix%
mtta = zeros(2,2);
mtt_t1 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t1 = -sqrt((mtt_t1+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtta(1,1) = mtt_t1/abs(exp(q_1/t_s));
mtta(2,1) = k_1/exp(q_1/t_s);
mtta(2,2) = (-(exp(q_2/t_s)*f_s)-k_2)/exp(q_2/t_s);
%b matrix%
mttb = zeros(2,1);
mtt_t1 = exp((q_1+q_3)/t_s)*abs(exp(q_1/t_s))*f_s+2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*c_0*k_3;
mtt_t1 = mtt_t1+exp(q_3/t_s)*abs(exp(q_1/t_s))*k_1;
mtt_t3 = exp((q_1+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t1 = mtt_t1-(mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s)));
mttb(1) = mtt_t1/(2.0*exp(q_1/t_s)*abs(exp(q_1/t_s))*k_3);
mtt_t1 = exp((q_1+q_2+q_3)/t_s)*abs(exp(q_1/t_s))*f_s*k_1;
mtt_t3 = exp((q_1+q_2+q_3)/t_s);
mtt_t2 = exp((2.0*q_1+q_3)/t_s)*f_s^2+4.0*exp((2.0*q_1)/t_s)*c_0*f_s*k_3;
mtt_t3 = mtt_t3*sqrt((mtt_t2+2.0*exp((q_1+q_3)/t_s)*f_s*k_1+exp(q_3/t_s)*k_1^2)/exp(q_3/t_s));
mtt_t1 = mtt_t1+exp((q_2+q_3)/t_s)*abs(exp(q_1/t_s))*k_1^2-(mtt_t3*k_1);
mtt_t2 = 2.0*exp((2.0*q_1+q_2)/t_s)*abs(exp(q_1/t_s))*f_s*k_3;
mttb(2) = mtt_t1/(mtt_t2+2.0*exp((2.0*q_1)/t_s)*abs(exp(q_1/t_s))*k_2*k_3);
%c matrix%
mttc = zeros(1,2);
mttc(1,2) = 1.0;
%d matrix%
mttd = zeros(1,1);

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_sspar.r version [686130de9e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file (ReactorTQ_sspar.r)
%% as siso_sspar ecxept that inputs/states have different meaning
%% Steady state for constant c_a, c_b and t=t_s and f=f_s

%% Unit volume ReactorTQ:
v_r := 1;

%% Do the inputs first -- this avoids problems with reduce not
%% recognising that complicated expressions are zero

%% The exponentials.
e_1 := e^(-q_1/t_s);
e_2 := e^(-q_2/t_s);
e_3 := e^(-q_3/t_s);

%Steady-state input q needed to achieve steady-state t_s
q_s := -( 
        + (t_0-t_s)*f_s
        + e_1*h_1*k_1*x1
        + e_2*h_2*k_2*x2
        + e_3*h_3*k_3*x1^2
       );

%% The input at steady-state
MTTu1 := f_s;

%States (masses)
x1 := c_a*v_r;
x2 := c_b*v_r;

%Load up the vectors
MTTx1 := x1;
MTTx2 := x2;

MTTy1 := c_b;

%% Finally, solve for the steady-state concentrations
%% Solve for ca - a quadratic.
a 	:= k_3*e_3;	%ca^2 
b 	:= k_1*e_1 + f_s;	%ca^1 
c 	:= -c_0*f_s;

c_a	:= (-b + sqrt(b^2 - 4*a*c))/(2*a);

%% solve for c_b
c_b 	:= c_a*k_1*e_1/(f_s+k_2*e_2);


END;


Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_state.txt version [35bb494f8e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# State specification (ReactorTQ_state.txt)
# Generated by MTT at Fri Mar  3 11:52:23 GMT 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/06/06 06:39:39  gawthrop
## Made compatible with current MTT.
##
## Revision 1.1  2000/12/28 17:19:08  peterg
## To RCS
##
###############################################################

## Reduce steady-state parameter file (ReactorTQ_sspar.r)
## as siso_sspar ecxept that states/states have different meaning
## Steady state for constant c_a, c_b and t=t_s and f=f_s

## Unit volume ReactorTQ:
v_r = 1;


## The exponentials.
e_1 = exp(-q_1/t_s);
e_2 = exp(-q_2/t_s);
e_3 = exp(-q_3/t_s);

## Solve for the steady-state concentrations
## Solve for ca - a quadratic.
a 	= k_3*e_3;	#ca^2 
b 	= k_1*e_1 + f_s;	#ca^1 
c 	= -c_0*f_s;

c_a	= (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);

## solve for c_b
c_b 	= c_a*k_1*e_1/(f_s+k_2*e_2);


#States (masses)
x1 = c_a*v_r;
x2 = c_b*v_r;


## The two inputs at steady-state
##mttu(1) = f_s;

## Load up the states
## Removed by MTT on Thu Jun  5 14:25:48 BST 2003: mttx(1) = x1;
## Removed by MTT on Thu Jun  5 14:25:48 BST 2003: mttx(2) = x2;
reactortq__m_a	= x1;
reactortq__m_b	= x2;

Deleted mttroot/mtt/lib/examples/Chemical/ReactorTQ/ReactorTQ_sympar.m version [b5bf2c1d7a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function sympar = ReactorTQ_sympar();
% sympar = ReactorTQ_sympar();
%System ReactorTQ, representation sympar, language m;
%File ReactorTQ_sympar.m;
%Generated by MTT on Thu Aug 24 14:47:48 BST 2000;
%
global ...
mtt_no_globals ;
  sympar.a 	= 1; # ReactorTQ
  sympar.b 	= 2; # ReactorTQ
  sympar.c 	= 3; # ReactorTQ
  sympar.c_0 	= 4; # ReactorTQ
  sympar.c_A 	= 5; # ReactorTQ
  sympar.c_B 	= 6; # ReactorTQ
  sympar.c_p 	= 7; # ReactorTQ
  sympar.e_1 	= 8; # ReactorTQ
  sympar.e_2 	= 9; # ReactorTQ
  sympar.e_3 	= 10; # ReactorTQ
  sympar.f_s 	= 11; # ReactorTQ
  sympar.h 	= 12; # Rate
  sympar.h_1 	= 13; # ReactorTQ
  sympar.h_2 	= 14; # ReactorTQ
  sympar.h_3 	= 15; # ReactorTQ
  sympar.k 	= 16; # Rate
  sympar.k_1 	= 17; # ReactorTQ
  sympar.k_2 	= 18; # ReactorTQ
  sympar.k_3 	= 19; # ReactorTQ
  sympar.n 	= 20; # Rate
  sympar.q 	= 21; # Rate
  sympar.q_1 	= 22; # ReactorTQ
  sympar.q_2 	= 23; # ReactorTQ
  sympar.q_3 	= 24; # ReactorTQ
  sympar.q_S 	= 25; # ReactorTQ
  sympar.rho 	= 26; # ReactorTQ
  sympar.t_0 	= 27; # ReactorTQ
  sympar.t_s 	= 28; # ReactorTQ
  sympar.v_r 	= 29; # ReactorTQ
  sympar.x1 	= 30; # ReactorTQ
  sympar.x2 	= 31; # ReactorTQ
  sympar.x3 	= 32; # ReactorTQ

Deleted mttroot/mtt/lib/examples/Components/OnePorts/OnePorts_abg.fig version [a2d62ed5ea].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2925 4725 2925 4500 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 2700 4725 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 3600 4725 3600 4500 3825
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 3375 3375 3825
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 4275 4725 4275 4500 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 4725 4950 4500 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 4725 4725 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 5625 4725 5625 4500 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 6300 4725 6300 4500 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 6075 3375 6525
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 5850 6750 2025 6750 2025 2475 5850 2475 5850 6750
4 1 0 100 0 18 18 0.0000 4 270 690 5265 3015 R:r_1\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 3015 SS:ss_1\001
4 1 0 100 0 18 18 0.0000 4 270 690 5265 3690 R:r_2\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 3690 SS:ss_2\001
4 1 0 100 0 18 18 0.0000 4 270 750 5265 4365 C:c_3\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 4365 SS:ss_3\001
4 1 0 100 0 18 18 0.0000 4 270 750 5265 5040 C:c_4\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 5040 SS:ss_4\001
4 1 0 100 0 18 18 0.0000 4 270 540 5265 5715 I:i_5\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 5715 SS:ss_5\001
4 1 0 100 0 18 18 0.0000 4 270 540 5265 6390 I:i_6\001
4 1 0 100 0 18 18 0.0000 4 270 1050 2790 6390 SS:ss_6\001

Deleted mttroot/mtt/lib/examples/Components/OnePorts/OnePorts_desc.tex version [940098c23a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system OnePorts (OnePorts_desc.tex)
% Generated by MTT on Fri Apr 19 08:12:54 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/04/19 07:42:28  gawthrop
% %% Simple teaching examples
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{OnePorts} is
   displayed in Figure \Ref{fig:OnePorts_abg.ps}; it contains the one
   port components: \textbf{R}, \textbf{C} and \textbf{I} in each of
   the two possible causalities.

   Note that the \textbf{R} has no prefered causality and, in this
   case, a causal stroke must be provided by the user. On the other
   hand, the \textbf{C} and \textbf{I} components are assigned
   prefered causality by MTT in the 3rd and 5th cases where no stroke
   is assigned by ther user. In the 4th and 6th cases, the user
   provides a causal stroke to put the components into derivative
   causality. \Ref{fig:OnePorts_cbg-noargs.ps} shows the causality
   automatically completed for the 3rd and 5th cases.
   
   Section \Ref{sec:OnePorts_ode-noargs.tex} gives the system equations, $y_1$ to
   $y_6$ are the outputs (with the given causality) of the 6
   components and $u_1$ to $u_6$ are the coresponding inputs. $x_1$
   and $x_2$ are the states of the 3rd and 5th cases (ie integrated
   flow and effort respectively), $z_1$ and $z_2$ are the
   corresponding quantities for the the 4th and 6th cases, the two
   components in derivative causality.

Deleted mttroot/mtt/lib/examples/Components/OnePorts/OnePorts_rep.txt version [9502ca8e13].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system OnePorts (OnePorts_rep.txt)
## Generated by MTT on" Thu Apr 18 08:49:49 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt OnePorts abg tex			# The system description
mtt OnePorts cbg ps 		        # The causal bond graph
mtt OnePorts struc tex	        # The system structure
mtt OnePorts sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt OnePorts dae tex	        # The system dae
mtt OnePorts ode tex	        # The system ode 
## mtt OnePorts sspar tex		# Steady-state parameters
## mtt OnePorts ss tex 		# Steady state
## mtt OnePorts dm tex		# Descriptor matrices (of linearised system)
## mtt OnePorts sm tex		# State matrices (of linearised system)
## mtt OnePorts tf tex		# Transfer function (of linearised system)
## mtt OnePorts lmfr ps		# log modulus of frequency response (of linearised system)
## mtt OnePorts simpar tex		# Simulation parameters
## mtt OnePorts numpar tex		# Numerical simulation parameters
## mtt OnePorts state tex		# Simulation initial state
## mtt OnePorts input tex		# Simulation input
## mtt OnePorts logic tex		# Logic control
## mtt OnePorts odeso ps		# Simulation output

## mtt OnePorts rep txt		# This file

Deleted mttroot/mtt/lib/examples/Components/TwoPorts/TwoPorts_abg.fig version [94a8b07bb2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2925 4050 2925 3825 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 2925 6525 2925 6300 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 2700 5175 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 3825 4050 3825 3825 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 6525 3825 6300 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4725 4050 4725 3825 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 4725 6525 4725 6300 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 4500 5175 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 5625 4050 5625 3825 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5175 5625 6525 5625 6300 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 5400 4050 5850
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 8100 6300 1125 6300 1125 2250 8100 2250 8100 6300
4 1 0 100 0 18 18 0.0000 4 270 900 4635 3015 TF:n_1\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 3015 SS:ss_11\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 3015 SS:ss_12\001
4 1 0 100 0 18 18 0.0000 4 270 900 4635 3915 TF:n_2\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 3915 SS:ss_21\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 3915 SS:ss_22\001
4 1 0 100 0 18 18 0.0000 4 270 960 4635 4815 GY:n_3\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 4815 SS:ss_31\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 4815 SS:ss_32\001
4 1 0 100 0 18 18 0.0000 4 270 960 4635 5715 GY:n_4\001
4 2 0 100 0 18 18 0.0000 4 270 1200 2520 5715 SS:ss_41\001
4 0 0 100 0 18 18 0.0000 4 270 1200 6705 5715 SS:ss_42\001

Deleted mttroot/mtt/lib/examples/Components/TwoPorts/TwoPorts_desc.tex version [b3da0d8473].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system TwoPorts (TwoPorts_desc.tex)
% Generated by MTT on Fri Apr 19 08:12:54 BST 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2002/04/19 07:47:45  gawthrop
% %% Simple teaching example.
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoPorts} is
   displayed in Figure \Ref{fig:TwoPorts_abg.ps}; it contains the two
   port components: \textbf{TF} and \textbf{GY} in each of
   the two possible causalities.
   
   Note that the neither component has prefered causality and, in both
   cases, a causal stroke must be provided by the user. 
   
   Section \Ref{sec:TwoPorts_ode-noargs.tex} gives the system equations.

Deleted mttroot/mtt/lib/examples/Components/TwoPorts/TwoPorts_rep.txt version [287249d02f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system TwoPorts (TwoPorts_rep.txt)
## Generated by MTT on" Thu Apr 18 08:45:30 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt TwoPorts abg tex			# The system description
mtt TwoPorts cbg ps 		        # The causal bond graph
mtt TwoPorts struc tex	        # The system structure
mtt TwoPorts sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt TwoPorts dae tex	        # The system dae
   mtt TwoPorts ode tex	        # The system ode 
## mtt TwoPorts sspar tex		# Steady-state parameters
## mtt TwoPorts ss tex 		# Steady state
## mtt TwoPorts dm tex		# Descriptor matrices (of linearised system)
## mtt TwoPorts sm tex		# State matrices (of linearised system)
## mtt TwoPorts tf tex		# Transfer function (of linearised system)
## mtt TwoPorts lmfr ps		# log modulus of frequency response (of linearised system)
## mtt TwoPorts simpar tex		# Simulation parameters
## mtt TwoPorts numpar tex		# Numerical simulation parameters
## mtt TwoPorts state tex		# Simulation initial state
## mtt TwoPorts input tex		# Simulation input
## mtt TwoPorts logic tex		# Logic control
## mtt TwoPorts odeso ps		# Simulation output

## mtt TwoPorts rep txt		# This file

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/INTFX_abg.fig version [d546a8c405].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3151 4501 3151 4276 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 2926 4726 2026 4951 2251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 3151 5851 3151 5626 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6975 4050 6975 1350 450 1350 450 4050 6975 4050
4 1 -1 0 0 0 20 0.0000 4 195 375 3151 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4726 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 600 4726 1891 CX:c\001
4 1 -1 0 0 0 20 0.0000 4 240 810 1306 3241 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 240 960 6346 3241 SS:[out]\001

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/INTFX_desc.tex version [9521268b12].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system INTFX (INTFX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 11:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTFX} is
   displayed in Figure \Ref{INTFX_abg} and its label
   file is listed in Section \Ref{sec:INTFX_lbl}.
   The subsystems are listed in Section \Ref{sec:INTFX_sub}.

\textbf{INTFX} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in].

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/INTFX_lbl.txt version [795adc6745].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY INTFX
%DESCRIPTION <Detailed description here>
%% Label file for system INTFX (INTFX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CX
	c		lin	effort,1

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/Makefile version [bb886d4f73].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Makefile for the Two link GMV example

all: msdp_tf.m twolinkp_obs.m twolinkp_sm.m TwoLinkGMV_numpar.m 

msdP_tf.m: msdP_abg.fig 
	mtt -q msdP tf m

msdp_tf.m: msdP_tf.m
	tr [A-Z] [a-z] <msdP_tf.m >msdp_tf.m

TwoLinkP_obs.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
	mtt -q TwoLinkP obs m

twolinkp_obs.m: TwoLinkP_obs.m
	tr [A-Z] [a-z] <TwoLinkP_obs.m >twolinkp_obs.m

TwoLinkP_sm.m: TwoLinkP_abg.fig TwoLinkP_lbl.txt
	mtt -q TwoLinkP sm m

twolinkp_sm.m: TwoLinkP_sm.m
	tr [A-Z] [a-z] <TwoLinkP_sm.m >twolinkp_sm.m

TwoLinkGMV_numpar.m: TwoLinkGMV_numpar.txt
	mtt -q TwoLinkGMV numpar m

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/RODaX_abg.fig version [69d5bf8861].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124




























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 1800 3375 1800 3600
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 IX:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTFX:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 4 0 0 0 20 0.0000 4 255 1215 1756 3286 SS:[alpha]\001

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/RODaX_desc.tex version [df20b89acf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system RODaX (RODaX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/12 15:25:35  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{RODaX} is
   displayed in Figure \Ref{RODaX_abg} and its label
   file is listed in Section \Ref{sec:RODaX_lbl}.
   The subsystems are listed in Section \Ref{sec:RODaX_sub}.

{\bf RODaX} is essentially as described in Figure 10.2 of
``Metamodelling''. It has an additional port ``[angle]'' to provide
access to the rod angle.

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/RODaX_lbl.txt version [25a69a9380].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	RODaX: rigid rod in two dimensions - angle port.
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION	Port [alpha]:	rod angle
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system RODaX (RODaX_lbl.txt)




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/04/12 15:24:06  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2



	

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_abg.fig version [b9d6a07d06].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 8550 9225 8550 9000 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 8325 9225 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 9450 9225 9450 9000 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 9225 9225 9675
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10215 2475 10215 2475 7650 11025 7650 11025 10215
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 8325 5625 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 9225 5625 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3825 5625 3825 8550 5625 8550 5400 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3375 6525 3375 9450 5625 9450 5400 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 5400 9225 5400 9000 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 5175 9225 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 6300 9225 6300 9000 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 6075 9225 6525
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 7065 2475 7065 2475 4500 11025 4500 11025 7065
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5400 5625 5400 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 5175 5625 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 6300 5625 6300 5400 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 6075 5625 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 5400 3600 5400 3375 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 5175 3600 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6300 3150 6300 2925 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 6075 3150 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 2250 9225 2250 9000 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2025 9225 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 9225 3150 9000 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2925 9225 3375
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 3915 2475 3915 2475 1350 11025 1350 11025 3915
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2025 5625 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5625 3150 5400 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2925 5625 3375
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 8640 SS:Theta_1_m\001
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 9540 SS:Theta_2_m\001
4 1 -1 0 0 22 20 0.0000 4 210 2445 6750 9090 TwoLinkPX:model\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 8415 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 9315 [Theta_2]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 8415 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 9315 [Joint_2]\001
4 1 1 1 0 3 26 0.0000 4 270 1005 6750 10080 Model\001
4 1 -1 0 0 22 20 0.0000 4 270 2415 6750 5940 TwoLinkP:system\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 5265 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 6165 [Theta_2]\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 5490 SS:Theta_1\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 6390 SS:Theta_2\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 5265 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 6165 [Joint_2]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3825 5490 0\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1935 6390 SS:Tau_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1980 5490 SS:Tau_1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3375 6390 0\001
4 1 1 1 0 3 26 0.0000 4 360 1110 6705 6885 System\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 2340 SS:Theta_1_r\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 3240 SS:Theta_2_r\001
4 1 1 1 0 3 26 0.0000 4 360 2055 6705 3735 Specification\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 2340 msdP:spec_1\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 3195 msdP:spec_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 4005 2340 SS:Ref_1\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 3960 3240 SS:Ref_2\001

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_args.new version [5936bc7523].

1

-
 

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_desc.tex version [430b6e90d4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system TwoLinkGMV (TwoLinkGMV_desc.tex)
% Generated by MTT on Wed Apr 15 18:15:23 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/15 18:41:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkGMV} is
   displayed in Figure \Ref{TwoLinkGMV_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkGMV_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkGMV_sub}.

This composite system provides an illustration of nonlinear
generalised minimum variance (GMV) control (continuous-time) operating on a
twolink manipulator. GMV can also be interpreted as:
\begin{itemize}
\item the exact linearisation (by feedback) followed by a
  pole-placement design on the resulting linear system and
\item a special case of generalised predictive control (GPC) were the
  prediction horizon is zero and the $P(s)$ polynomial is the same as
  the system relative degree and
\item One possible instance of physical-model-based control.
\end{itemize}

The composite system of Figure \Ref{TwoLinkGMV_abg} has three
(visible) parts:
\begin{enumerate}
\item a linear decoupled \emph{specification} system that describes the desired
  closed-loop system in terms of a physical system (two decoupled
  mass-spring-damper systems),
\item the system itself (a two-link manipulator) representing the
  system to be controlled, more details are given in Sections
  \Ref{sec:TwoLinkP_ode.tex} and \Ref{sec:TwoLinkP_rfe.tex}.
\item a model of the system with additional state inputs to be used as
  a state observer.
\end{enumerate}
The invisible parts are implemented in the text file
``TwoLinkGMV\_input.txt'' (see Section \Ref{sec:TwoLinkGMV_input.txt}).
These parts are:
\begin{itemize}
\item the reference signal (joint angles)
  \begin{equation}
    w(t) = 
    \begin{cases}
      \begin{pmatrix}
        \pi \\
        0
      \end{pmatrix} & 0 \ge t > 10 \\
      \begin{pmatrix}
        2\pi \\
        0
      \end{pmatrix} & 10 \ge t > 15 \\
      \begin{pmatrix}
        2\pi \\
        \pi
      \end{pmatrix} & 15 \ge t > 30 \\
    \end{cases}
  \end{equation}
\item The control signal (joint torques) being the solution of 
  \begin{equation}
    \phi^*(t) = O_o(\hat x(t)) + O_h(\hat x(t)) u(t) = w(t)
  \end{equation}
where $\hat x$ is the observed state.
\item The observer feedback signal
  \begin{equation}
    u_x = K ( y - \hat y)
  \end{equation}
where $K$ is the observer gain matrix and $y$ and $\hat y$ are the
system and model outputs respectively.
\end{itemize}
The observer gain is set up on the basis of the \emph{linearised}
system using LQ theory. This is implemented in the text file
``TwoLinkGMV\_state.txt'' (see Section \Ref{sec:TwoLinkGMV_state.txt})
using the Octave function ``lqe'' together with the MTT-generated
linearised system ``TwoLink\_sm''.


The system was simulated using Octave under MTT with the results given
in Figures
\Ref{fig:TwoLinkGMV_odeso.ps-TwoLinkGMV-Theta-1,TwoLinkGMV-Theta-1-r}
and
\Ref{fig:TwoLinkGMV_odeso.ps-TwoLinkGMV-Theta-2,TwoLinkGMV-Theta-2-r}
giving the actual and specification angles for joints 1 and 2
respectively.

The initial \emph{system} state was zero except that the angle of the
first rod was $\frac{\pi}{4}$. The initial \emph{observer} state was
(erroneously but deliberately) set at zero. This explains the
(decaying) discrepancy between the actual and specification angles.
Simulations with zero initial state gave precise matching.

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_input.txt version [4899e515e0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkGMV_input.txt)
# Generated by MTT at Mon Apr 13 11:02:37 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

# Reference signals
u(1) =	 pi + pi*(t>10) ;			# TwoLinkGMV (Ref_1)
u(2) =	 pi*(t>15) ;			# TwoLinkGMV (Ref_2)

# Control signals
w = u(1:2);			# Reference signal
x_model = x(9:12);		# Observed states
[O_o, O_h] = TwoLinkP_obs(x_model) #GPC O function (affine case)
[spec_n,spec_d] = msdP_tf;	# Spec transfer function
P = spec_d(3:-1:1);		# P poly with ascending coeffs
PP = [eye(2)*P(1) eye(2)*P(2) eye(2)*P(3)]; 
PO_o = PP*O_o;			# Compute Py with u zero
PO_h = PP*O_h;			# Coefficient of u
u_control =  PO_h\(w - PO_o);	# GMV control signal

u(3:4) = u_control;		# TwoLinkGMV (Tau_1)

# Observer
x_system = x(5:8);		# System states
error = x_system-x_model;	# Error in states
ObserverInput = ObserverGain*error;
u(5:8) = ObserverInput;		# Set the state-input to the observer

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_lbl.txt version [ad79cbc64e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkGMV - GMV control of two-link manipulator
%DESCRIPTION This composite system provides an illustration
%DESCRIPTION of nonlinear generalised minimum variance (GMV) control
%DESCRIPTION (continuous-time) operating on a twolink manipulator. 

%% Label file for system TwoLinkGMV (TwoLinkGMV_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	Ref_1		SS	external,internal
	Ref_2		SS	external,internal
	Tau_1		SS	external,internal
	Tau_2		SS	external,internal

	Theta_1		SS	external,0
	Theta_2		SS	external,0

	Theta_1_m	SS	external,0
	Theta_2_m	SS	external,0

	Theta_1_r	SS	external,0
	Theta_2_r	SS	external,0

% Component type msdP
	spec_1
	spec_2

% Component type TwoLinkP
	system

% Component type TwoLinkPX
	model


Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_numpar.txt version [ccf91065f0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkGMV_numpar.txt)
# Generated by MTT at Mon Apr 13 10:57:02 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_s = 	1.0; # msdP
j_s = 	1.0; # msdP
r_s = 	1.414; # msdP

j_r = 	1.0; # TwoLinkP,TwoLinkPX
l_r = 	1.0; # TwoLinkP,TwoLinkPX
m_r = 	1.0; # TwoLinkP,TwoLinkPX

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_obspar.r version [c3ef6ba928].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce  GPC observability function parameters for system TwoLinkGMV (TwoLinkGMV_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_rep.txt version [5a83bbbd32].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TwoLinkGMV (TwoLinkGMV_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkGMV abg tex
mtt TwoLinkGMV struc tex
mtt TwoLinkGMV sympar tex

mtt TwoLinkP struc tex
mtt TwoLinkP rfe tex
mtt TwoLinkP ode tex
mtt TwoLinkP obs tex

mtt TwoLinkP ss tex
mtt TwoLinkP sm tex

mtt msdP tf tex

mtt TwoLinkGMV numpar txt
mtt TwoLinkGMV state txt
mtt TwoLinkGMV input txt
mtt TwoLinkGMV odeso ps 'TwoLinkGMV_Theta_1,TwoLinkGMV_Theta_1_r'
mtt TwoLinkGMV odeso ps 'TwoLinkGMV_Theta_2,TwoLinkGMV_Theta_2_r'

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_simpar.txt version [49dd11c4f0].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system TwoLinkGMV (TwoLinkGMV_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30.0
DT=0.2
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_simpar.txt_old version [49dd11c4f0].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system TwoLinkGMV (TwoLinkGMV_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30.0
DT=0.2
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_sspar.r version [5689628a58].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (TwoLinkGMV_sspar.r)
% Generated by MTT at Tue Apr 14 08:47:47 BST 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	0; % TwoLinkGMV_spec_1 (c_s)
MTTX2 := 	0; % TwoLinkGMV_spec_1 (j_s)
MTTX3 := 	0; % TwoLinkGMV_spec_2 (c_s)
MTTX4 := 	0; % TwoLinkGMV_spec_2 (j_s)
MTTX5 := 	0; % TwoLinkGMV_system_rod1 (J)
MTTX6 := 	0; % TwoLinkGMV_system_rod1_th (3)
MTTX7 := 	0; % TwoLinkGMV_system_rod2 (J)
MTTX8 := 	0; % TwoLinkGMV_system_rod2_th (3)
MTTX9 := 	0; % TwoLinkGMV_model_rod1_J (i)
MTTX10 := 	0; % TwoLinkGMV_model_rod1_th_c (c)
MTTX11 := 	0; % TwoLinkGMV_model_rod2_J (i)
MTTX12 := 	0; % TwoLinkGMV_model_rod2_th_c (c)
% Steady-state inputs
MTTU1 := 	1; % TwoLinkGMV (Ref_1)
MTTU2 := 	1; % TwoLinkGMV (Ref_2)
MTTU3 := 	0; % TwoLinkGMV (Tau_1)
MTTU4 := 	0; % TwoLinkGMV (Tau_2)
MTTU5 := 	0; % TwoLinkGMV_model_rod1_J (X)
MTTU6 := 	0; % TwoLinkGMV_model_rod1_th_c (X)
MTTU7 := 	0; % TwoLinkGMV_model_rod2_J (X)
MTTU8 := 	0; % TwoLinkGMV_model_rod2_th_c (X)
;;END;

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkGMV_state.txt version [73974e101a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkGMV_state.txt)
# Generated by MTT at Tue Apr 14 08:54:28 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

# Set the states
x(1) =	 0 ; # TwoLinkGMV_spec_1 (c_s)
x(2) =	 0 ; # TwoLinkGMV_spec_1 (j_s)
x(3) =	 0 ; # TwoLinkGMV_spec_2 (c_s)
x(4) =	 0 ; # TwoLinkGMV_spec_2 (j_s)
x(5) =	 0 ; # TwoLinkGMV_system_rod1 (J)
x(6) =	 pi/4 ; # TwoLinkGMV_system_rod1_th (3)
x(7) =	 0 ; # TwoLinkGMV_system_rod2 (J)
x(8) =	 0 ; # TwoLinkGMV_system_rod2_th (3)
x(9) =	 0 ; # TwoLinkGMV_model_rod1_J (i)
x(10) =	 0 ; # TwoLinkGMV_model_rod1_th_c (c)
x(11) =	 0 ; # TwoLinkGMV_model_rod2_J (i)
x(12) =	 0 ; # TwoLinkGMV_model_rod2_th_c (c)

# Observer design
[A,B,C] = TwoLinkP_sm;		# Get the linearised system
sigma = 0.1;			# Measurement noise variance (pretend)
k = lqe(A,eye(4),C,eye(4),sigma*eye(2))
ObserverGain = k*C;		# This system happens to have a linear output

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkPX_abg.fig version [9ab26d89d5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104








































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3285 1575 3285 1800 3510
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3195 8055 1620 8055 1845 8280
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2025 1575 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 8325 1350 9450 1575 9225
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 7875 1350 3600 1575 3825
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4729 3379 RODaX:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4731 8196 RODaX:rod2\001
4 1 4 0 0 0 20 0.0000 4 255 1410 4771 946 SS:[Joint_1]\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5850 945 SS:v_y\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2882 5717 SS:[Joint_2]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3510 3375 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3555 8145 [alpha]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1308 8193 1\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1397 1892 SS:[Theta_1]\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1352 9767 SS:[Theta_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1263 3468 0\001

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkPX_desc.tex version [df58265a5a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoLinkPX (TwoLinkPX_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkPX} is
   displayed in Figure \Ref{TwoLinkPX_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkPX_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkPX_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkPX_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkPX_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkPX_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkPX_lbl.txt version [fbab683c87].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkPX: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkPX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_abg.fig version [44cfade14b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104








































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3285 1575 3285 1800 3510
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3195 8055 1620 8055 1845 8280
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2025 1575 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 8325 1350 9450 1575 9225
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 7875 1350 3600 1575 3825
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4729 3379 RODa:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4731 8196 RODa:rod2\001
4 1 4 0 0 0 20 0.0000 4 255 1410 4771 946 SS:[Joint_1]\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5850 945 SS:v_y\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2882 5717 SS:[Joint_2]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3510 3375 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3555 8145 [alpha]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1308 8193 1\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1397 1892 SS:[Theta_1]\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1352 9767 SS:[Theta_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1263 3468 0\001

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_cr.txt version [981cde0c6a].

1
2
3



-
-
-
lcos
lin
lsin

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_desc.tex version [6d2b3ecef6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoLinkP (TwoLinkP_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkP} is
   displayed in Figure \Ref{TwoLinkP_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkP_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkP_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkP_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkP_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkP_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_lbl.txt version [a70a30e484].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkP: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_obspar.r version [ea44a77131].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce  GPC observability function parameters for system TwoLinkP (TwoLinkP_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/TwoLinkP_subs.r version [87b1a943f2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce  substitution statements for system TwoLinkPX (TwoLinkPX_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/22 20:13:25  peterg
% %% Trig simplification added
% %%
% %% Revision 1.1  1998/03/22 20:12:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/msdP_abg.fig version [783d02bd00].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 6975 8325 1125 1125 1125 1125 6975 8325 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 5355 4815 6345 Mass-spring-damper system (position output)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 0 4 0 0 0 20 0.0000 4 240 960 6660 4140 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/msdP_desc.tex version [be83adfdb1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system msdP (msdP_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msdP} is
   displayed in Figure \Ref{msdP_abg} and its label
   file is listed in Section \Ref{sec:msdP_lbl}.
   The subsystems are listed in Section \Ref{sec:msdP_sub}.


 \textbf{msdP} is a simple Mass-Spring-Damper system with 
 force input and position output. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GMV/TwoLinkGMV/msdP_lbl.txt version [dee478e657].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY msdP
%DESCRIPTION <Detailed description here>
%% Label file for system msdP (msdP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_s		lin	effort,c_s

% Component type I
	j_s		lin	flow,j_s

% Component type R
	r_s		lin	flow,r_s

% Component type SS
	[in]		SS	external,internal
	[out]		SS	external,0

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/INTFX_abg.fig version [d546a8c405].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3151 2701 3151 2476 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3151 4501 3151 4276 3376
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 2926 4726 2026 4951 2251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 3151 5851 3151 5626 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6975 4050 6975 1350 450 1350 450 4050 6975 4050
4 1 -1 0 0 0 20 0.0000 4 195 375 3151 3241 AF\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4726 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 195 600 4726 1891 CX:c\001
4 1 -1 0 0 0 20 0.0000 4 240 810 1306 3241 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 240 960 6346 3241 SS:[out]\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/INTFX_desc.tex version [9521268b12].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system INTFX (INTFX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:16 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 11:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{INTFX} is
   displayed in Figure \Ref{INTFX_abg} and its label
   file is listed in Section \Ref{sec:INTFX_lbl}.
   The subsystems are listed in Section \Ref{sec:INTFX_sub}.

\textbf{INTFX} is a two-port component where the effort on port [out]
   is the integral of the flow on port [in].

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/INTFX_lbl.txt version [795adc6745].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY INTFX
%DESCRIPTION <Detailed description here>
%% Label file for system INTFX (INTFX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CX
	c		lin	effort,1

% Component type SS
	[in]		SS	external,external
	[out]		SS	external,external

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/RODaX_abg.fig version [69d5bf8861].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124




























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4950 1800 3375 1800 3600
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 IX:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTFX:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000 4 255 990 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000 4 255 1485 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001
4 1 4 0 0 0 20 0.0000 4 255 1215 1756 3286 SS:[alpha]\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/RODaX_desc.tex version [df20b89acf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system RODaX (RODaX_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/12 15:25:35  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{RODaX} is
   displayed in Figure \Ref{RODaX_abg} and its label
   file is listed in Section \Ref{sec:RODaX_lbl}.
   The subsystems are listed in Section \Ref{sec:RODaX_sub}.

{\bf RODaX} is essentially as described in Figure 10.2 of
``Metamodelling''. It has an additional port ``[angle]'' to provide
access to the rod angle.

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/RODaX_lbl.txt version [1c79a51b36].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	RODaX: rigid rod in two dimensions - angle port.
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION	Port [alpha]:	rod angle
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system RODaX (RODaX_lbl.txt)




% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  1998/04/12 15:24:06  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/Sensor_abg.fig version [8f5341f4f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 2025 3825 2025 3600 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 2025 5850 2025 5625 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3600 7875 3600 7650 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 1800 2475 2295
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 3375 6075 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 1800 5850 2295
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3600 3825 3600 3600 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3600 6075 3600 5850 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 3330 6300 2205 6525 2430
4 2 4 0 0 0 20 0.0000 4 240 720 2385 2115 SS:[v]\001
4 1 -1 0 0 0 20 0.0000 4 195 420 4140 2115 GY\001
4 1 -1 0 0 0 20 0.0000 4 195 840 6345 2070 AE:tau\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6300 3690 1\001
4 2 4 0 0 0 20 0.0000 4 255 720 2475 3690 SS:[p]\001
4 0 4 0 0 0 20 0.0000 4 240 690 8055 3645 SS:[s]\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4050 3690 AE\001
4 2 4 0 0 0 20 0.0000 4 240 405 5760 1755 [in]\001
4 2 4 0 0 0 20 0.0000 4 240 555 6255 2565 [out]\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/Sensor_lbl.txt version [c79dfd35bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Sensor
%DESCRIPTION <Detailed description here>
%% Label file for system Sensor (Sensor_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type AE
	tau		lin	tau

% Component type SS
	[p]		SS	external,external
	[s]		SS	external,external
	[v]		SS	external,external

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_abg.fig version [0183aa4021].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 8550 9225 8550 9000 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 8325 9225 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 9450 9225 9450 9000 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 9225 9225 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 8325 5625 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 9225 5625 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3825 5625 3825 8550 5625 8550 5400 8775
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 3375 6525 3375 9450 5625 9450 5400 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 5400 9225 5400 9000 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 5175 9225 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 6300 9225 6300 9000 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 6075 9225 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5400 5625 5400 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 5175 5625 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 6300 5625 6300 5400 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 6075 5625 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 5400 3600 5400 3375 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 5175 3600 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6300 3150 6300 2925 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 6075 3150 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 2250 9225 2250 9000 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2025 9225 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 9225 3150 9000 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9225 2925 9225 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2025 5625 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5625 3150 5400 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 2925 5625 3375
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 3915 2475 3915 2475 1350 11475 1350 11475 3915
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 7020 2475 7020 2475 4500 11475 4500 11475 7020
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 10215 2475 10215 2475 7650 11475 7650 11475 10215
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 8640 SS:Theta_1_m\001
4 0 -1 0 0 22 20 0.0000 4 270 1935 9315 9540 SS:Theta_2_m\001
4 1 -1 0 0 22 20 0.0000 4 210 2640 6750 9090 TwoLinkPSX:model\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 8415 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 9315 [Theta_2]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 8415 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 9315 [Joint_2]\001
4 1 1 1 0 3 26 0.0000 4 270 1005 6750 10080 Model\001
4 1 -1 0 0 22 20 0.0000 4 270 2610 6750 5940 TwoLinkPS:system\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 5265 [Theta_1]\001
4 0 4 0 0 22 20 0.0000 4 270 1230 7920 6165 [Theta_2]\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 5490 SS:Theta_1\001
4 0 -1 0 0 22 20 0.0000 4 270 1530 9315 6390 SS:Theta_2\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 5265 [Joint_1]\001
4 2 4 0 0 22 20 0.0000 4 270 1140 5535 6165 [Joint_2]\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3825 5490 0\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1935 6390 SS:Tau_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1275 1980 5490 SS:Tau_1\001
4 1 -1 0 0 22 20 0.0000 4 195 150 3375 6390 0\001
4 1 1 1 0 3 26 0.0000 4 360 1110 6705 6885 System\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 2340 SS:Theta_1_r\001
4 0 -1 0 0 22 20 0.0000 4 270 1785 9315 3240 SS:Theta_2_r\001
4 1 1 1 0 3 26 0.0000 4 360 2055 6705 3735 Specification\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 2340 msdP:spec_1\001
4 1 -1 0 0 22 20 0.0000 4 270 1860 6795 3195 msdP:spec_2\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 4005 2340 SS:Ref_1\001
4 2 -1 0 0 22 20 0.0000 4 270 1260 3960 3240 SS:Ref_2\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_desc.tex version [98eee8129d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system TwoLinkGPC (TwoLinkGPC_desc.tex)
% Generated by MTT on Wed Apr 15 18:15:23 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/15 18:41:58  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkGPC} is
   displayed in Figure \Ref{TwoLinkGPC_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkGPC_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkGPC_sub}.
   
   This example provides an illustration of nonlinear generalised
   predictive control (GPC) (continuous-time) operating on a twolink
   manipulator with a modified sensor.  The  sensor is modified in a
   rather contrived way to give a nonlinear system with an
   \emph{unstable} inverse. The idea is that the sensor approximates a
   pure delay of $\tau$ as:
   \begin{equation}
     e^{-s\tau} \approx 1 - s \tau
   \end{equation}
   
   The example contrasts GPC with GMV, which can also be interpreted
   as:
\begin{itemize}
\item the exact linearisation (by feedback) followed by a
  pole-placement design on the resulting linear system and
\item a special case of generalised predictive control (GPC) were the
  prediction horizon is zero and the $P(s)$ polynomial is the same as
  the system relative degree and
\end{itemize}


The composite system of Figure \Ref{TwoLinkGPC_abg} has three
(visible) parts:
\begin{enumerate}
\item a linear decoupled \emph{specification} system that describes the desired
  closed-loop system in terms of a physical system (two decoupled
  mass-spring-damper systems),
\item the system itself (a two-link manipulator) representing the
  system to be controlled, more details are given in Sections
  \Ref{sec:TwoLinkP_ode.tex} and \Ref{sec:TwoLinkP_rfe.tex}.
\item a model of the system with additional state inputs to be used as
  a state observer.
\end{enumerate}
The invisible parts are implemented in the text file
``TwoLinkGPC\_input.txt'' (see Section \Ref{sec:TwoLinkGPC_input.txt}).
These parts are:
\begin{itemize}
\item the reference signal (joint angles)
  \begin{equation}
    w(t) = 
    \begin{cases}
      \begin{pmatrix}
        \pi \\
        0
      \end{pmatrix} & 0 \ge t > 10 \\
      \begin{pmatrix}
        2\pi \\
        0
      \end{pmatrix} & 10 \ge t > 15 \\
      \begin{pmatrix}
        2\pi \\
        \pi
      \end{pmatrix} & 15 \ge t > 30 \\
    \end{cases}
  \end{equation}
\item The control signal (joint torques) being the solution of 
  \begin{equation}
    \phi^*(t) = O_o(\hat x(t)) + O_h(\hat x(t)) u(t) = w(t)
  \end{equation}
where $\hat x$ is the observed state.
\item The observer feedback signal
  \begin{equation}
    u_x = K ( y - \hat y)
  \end{equation}
where $K$ is the observer gain matrix and $y$ and $\hat y$ are the
system and model outputs respectively.
\end{itemize}
The observer gain is set up on the basis of the \emph{linearised}
system using LQ theory. This is implemented in the text file
``TwoLinkGPC\_state.txt'' (see Section \Ref{sec:TwoLinkGPC_state.txt})
using the Octave function ``lqe'' together with the MTT-generated
linearised system ``TwoLink\_sm''.


The system was simulated using Octave under MTT with the results given
in Figures
\Ref{fig:TwoLinkGPC_odeso.ps-TwoLinkGPC-Theta-1,TwoLinkGPC-Theta-1-r}
and
\Ref{fig:TwoLinkGPC_odeso.ps-TwoLinkGPC-Theta-2,TwoLinkGPC-Theta-2-r}
giving the actual and specification angles for joints 1 and 2
respectively.

The initial \emph{system} state was zero except that the angle of the
first rod was $\frac{\pi}{4}$. The initial \emph{observer} state was
(erroneously but deliberately) set at zero. This explains the
(decaying) discrepancy between the actual and specification angles.
Simulations with zero initial state gave precise matching.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_input.tex version [96bb3408b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Tex file (TwoLinkGPC_input.txt)
%% Generated by MTT at Wed Apr 29 11:21:32 BST 1998
\begin{verbatim}
# Numerical parameter file (TwoLinkGPC_input.txt)
# Generated by MTT at Mon Apr 13 11:02:37 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

if t<10
  tau = 0;
elseif t<20
  tau = 0.1;
else
  tau = 0.2;
end

# Reference signals
Period = 20;
u(1) =	 -pi*sign(cos(2*pi*t/Period))*(t>5); # TwoLinkGPC (Ref_1)
u(2) =	 pi*sign(sin(2*pi*t/Period)); # TwoLinkGPC (Ref_2)
w = u(1:2);			      # Reference signal

# Control signals
x_model = x(9:12);		# Observed states
[O_o, O_h] = TwoLinkPS_obs(x_model) #GPC O function (affine case)
[spec_n,spec_d] = msdP_tf;	# Spec transfer function
P = spec_d(3:-1:1);		# P poly with ascending coeffs
PP = [eye(2)*P(1) eye(2)*P(2) eye(2)*P(3)]; # Matrix version
PO_o = PP*O_o;			# Compute Py with u zero
PO_h = PP*O_h;			# Coefficient of u
u_control =  PO_h\(w - PO_o);	# GMV control signal

u(3:4) = u_control;		# TwoLinkGPC (Tau_1)

# Observer
x_system = x(5:8);		# System states
error = x_system-x_model;	# Error in states
ObserverInput = ObserverGain*error;
u(5:8) = ObserverInput;		# Set the state-input to the observer

\end{verbatim}

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_input.txt version [cc63da7250].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkGPC_input.txt)
# Generated by MTT at Mon Apr 13 11:02:37 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

if t<10
  tau = 0;
else
  tau = 0.1;
end

# Reference signals
Period = 20;
u(1) =	 -pi*sign(cos(2*pi*t/Period))*(t>5); # TwoLinkGPC (Ref_1)
u(2) =	 pi*sign(sin(2*pi*t/Period)); # TwoLinkGPC (Ref_2)
w = u(1:2);			      # Reference signal

# Control signals
x_model = x(9:12);		# Observed states
[O_o, O_h] = TwoLinkPS_obs(x_model) #GPC O function (affine case)
[spec_n,spec_d] = msdP_tf;	# Spec transfer function
P = spec_d(3:-1:1);		# P poly with ascending coeffs
PP = [eye(2)*P(1) eye(2)*P(2) eye(2)*P(3)]; # Matrix version
PO_o = PP*O_o;			# Compute Py with u zero
PO_h = PP*O_h;			# Coefficient of u
u_control =  PO_h\(w - PO_o);	# GMV control signal

u(3:4) = u_control;		# TwoLinkGPC (Tau_1)

# Observer
x_system = x(5:8);		# System states
error = x_system-x_model;	# Error in states
ObserverInput = ObserverGain*error;
u(5:8) = ObserverInput;		# Set the state-input to the observer

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_lbl.txt version [8c71877011].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkGPC - GPC control of two-link manipulator with delay
%DESCRIPTION This composite system provides an illustration
%DESCRIPTION of nonlinear GPC (Generalised Predictive Control) control
%DESCRIPTION (continuous-time) operating on a twolink manipulator. 

%% Label file for system TwoLinkGPC (TwoLinkGPC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/04/29 09:01:43  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	Ref_1		SS	external,internal
	Ref_2		SS	external,internal
	Tau_1		SS	external,internal
	Tau_2		SS	external,internal
	Theta_1		SS	external,0
	Theta_2		SS	external,0
	Theta_1_m	SS	external,0
	Theta_2_m	SS	external,0
	Theta_1_r	SS	external,0
	Theta_2_r	SS	external,0

% Component type msdP
	spec_1
	spec_2

% Component type TwoLinkP
	system

% Component type TwoLinkPX
	model

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_numpar.txt version [de52e6ae7d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkGPC_numpar.txt)
# Generated by MTT at Mon Apr 13 10:57:02 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_s = 	1.0; # msdP
j_s = 	1.0; # msdP
r_s = 	2.0; # msdP
tau =   0.1; # msdP
l_r = 	0.5; # TwoLinkP,TwoLinkPX
m_r = 	1.0; # TwoLinkP,TwoLinkPX
j_r = 	m_r*l_r*l_r/3; # TwoLinkP,TwoLinkPX

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_obspar.r version [9796c5f718].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce  GPC observability function parameters for system TwoLinkGPC (TwoLinkGPC_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_rep.txt version [68da84bc7f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TwoLinkGPC (TwoLinkGPC_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkGPC abg tex
mtt TwoLinkGPC struc tex
mtt TwoLinkGPC sympar tex

mtt TwoLinkPS struc tex
mtt TwoLinkPS rfe tex
mtt TwoLinkPS ode tex
mtt TwoLinkPS obs tex

mtt TwoLinkPS ss tex
mtt TwoLinkPS sm tex

mtt msdP tf tex

mtt TwoLinkGPC numpar txt
mtt TwoLinkGPC state txt
mtt TwoLinkGPC input txt

mtt TwoLinkGPC odeso ps 'TwoLinkGPC_Theta_1,TwoLinkGPC_Theta_1_r'
mtt TwoLinkGPC odeso ps 'TwoLinkGPC_Theta_2,TwoLinkGPC_Theta_2_r'



Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_simpar.txt version [85c8e666bb].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system TwoLinkGPC (TwoLinkGPC_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30
DT=0.1
STEPFACTOR=2

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_simpar.txt_old version [85c8e666bb].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system TwoLinkGPC (TwoLinkGPC_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=30
DT=0.1
STEPFACTOR=2

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkGPC_state.txt version [50c9fbc84f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkGPC_state.txt)
# Generated by MTT at Thu Apr 23 09:10:43 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global ObserverGain;

# Set the states
x(1) =	 0 ; # TwoLinkGPC_spec_1 (c_s)
x(2) =	 0 ; # TwoLinkGPC_spec_1 (j_s)
x(3) =	 0 ; # TwoLinkGPC_spec_2 (c_s)
x(4) =	 0 ; # TwoLinkGPC_spec_2 (j_s)
x(5) =	 0 ; # TwoLinkGPC_system_rod1 (J)
x(6) =	 0 ; # TwoLinkGPC_system_rod1_th (3)
x(7) =	 0 ; # TwoLinkGPC_system_rod2 (J)
x(8) =	 0 ; # TwoLinkGPC_system_rod2_th (3)
x(9) =	 0 ; # TwoLinkGPC_model_rod1_J (i)
x(10) =	 0 ; # TwoLinkGPC_model_rod1_th_c (c)
x(11) =	 0 ; # TwoLinkGPC_model_rod2_J (i)
x(12) =	 0 ; # TwoLinkGPC_model_rod2_th_c (c)

# Observer design
[A,B,C] = TwoLinkPS_sm;		# Get the linearised system
sigma = 0.1;			# Measurement noise variance (pretend)
k = lqe(A,eye(4),C,eye(4),sigma*eye(2))
ObserverGain = k*C;		# This system happens to have a linear output

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPSX_abg.fig version [9ab26d89d5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104








































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3285 1575 3285 1800 3510
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3195 8055 1620 8055 1845 8280
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 3150 1350 2025 1575 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 8325 1350 9450 1575 9225
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 7875 1350 3600 1575 3825
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4729 3379 RODaX:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 4731 8196 RODaX:rod2\001
4 1 4 0 0 0 20 0.0000 4 255 1410 4771 946 SS:[Joint_1]\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5850 945 SS:v_y\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2882 5717 SS:[Joint_2]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3510 3375 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 225 675 3555 8145 [alpha]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1308 8193 1\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1397 1892 SS:[Theta_1]\001
4 1 4 0 0 0 20 0.0000 4 255 1530 1352 9767 SS:[Theta_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 1263 3468 0\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPSX_desc.tex version [61db22c233].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoLinkPSX (TwoLinkPSX_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkPSX} is
   displayed in Figure \Ref{TwoLinkPSX_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkPSX_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkPSX_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkPSX_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkPSX_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkPSX_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPSX_lbl.txt version [b2d7b7efd0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkPSX: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkPSX_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_abg.fig version [7c9d2b5819].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 11700 1800 485 485 11700 1800 11880 2250
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 11700 6300 485 485 11700 6300 12185 6785
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11745 11925 11745 450 45 450 45 11925 11745 11925
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5
	 7650 900 4725 900 4725 3375 3375 3375 3600 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 8505 4950 4230 5175 4455
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 6300 4052 6302 3827 6527
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 4275 6525 4275 8325 3150 8325 3375 8550
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 7652 6300 7427 6525
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6618 1803 6888 1803
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8870 1805 9140 1805
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7743 3378 8013 3378
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7878 1125 7878 3378 8103 3153
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7652 6167 7652 6437
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 6526 7876 8101 8101 7876
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6622 9322 6892 9322
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7747 9322 8017 9322
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8874 9324 9144 9324
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7880 9320 7880 10895 8105 10670
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9005 9320 9005 10895 9230 10670
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6751 4501 6751 8101 6976 7876
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 4501 9001 8101 9226 7876
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 9450 9675 7875 6075 7875 6075 9450 9675 9450
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 7110 9675 5535 6075 5535 6075 7110 9675 7110
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 11925 9675 10350 6075 10350 6075 11925 9675 11925
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6753 1803 6753 3378 6978 3153
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9003 1803 9003 3378 9228 3153
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 4501 7876 6076 8101 5851
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9675 4725 6075 4725 6075 3150 9675 3150 9675 4725
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 9297 6750 10872 6975 10647
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 5850 11925 2250 11475 2250 11475 5850 11925 5850
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 10350 11925 6750 11475 6750 11475 10350 11925 10350
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 10800 1125 12555 1125 12555 1350 10800 1350 10800 1125
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9630 2745 9630 1170 6030 1170 6030 2745 9630 2745
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8910 900 8145 900 8370 1125
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2790 3735 2115 3735 2340 3960
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4725 3960 3330 3960 3555 4185
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 3960 5040 3960 5265 4185
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 8550 2025 8550 2250 8775
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 8775 3150 8775 3375 9000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 8775 4905 8775 5130 9000
4 0 -1 0 0 0 20 0.0000 4 195 135 4863 4053 0\001
4 2 4 0 0 0 20 0.0000 4 255 1410 2702 6392 SS:[Joint_2]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4188 6393 1\001
4 1 -1 0 0 0 20 0.0000 4 255 810 6753 1623 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 7833 6393 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 6758 11348 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 7883 11348 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 9053 11348 SS:F_y\001
4 0 1 1 0 3 20 0.0000 4 210 720 9945 4050 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 9900 6435 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 9900 8865 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 9900 11160 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 9900 1935 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 225 900 7875 3645 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 6750 4455 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 7875 4455 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 9000 4455 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 9000 3645 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 6755 8510 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 7880 8510 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 6757 9187 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 7883 9188 [alpha_b]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 9000 1620 SS:v_y\001
4 1 4 0 0 0 16 0.0000 4 210 495 6750 3645 [x_a]\001
4 0 -1 0 0 0 20 0.0000 4 195 135 7788 993 1\001
4 0 4 0 0 0 20 0.0000 4 255 1410 9046 991 SS:[Joint_1]\001
4 2 4 0 0 0 20 0.0000 4 255 1530 1892 3827 SS:[Theta_1]\001
4 1 4 0 0 0 16 0.0000 4 210 240 2700 3555 [s]\001
4 1 -1 0 0 0 20 1.5708 4 195 780 3154 3731 Sensor\001
4 1 4 0 0 0 16 0.0000 4 225 270 3420 3825 [p]\001
4 1 4 0 0 0 16 0.0000 4 210 270 3330 3195 [v]\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 7879 4009 RODa:rod1\001
4 1 4 0 0 0 16 0.0000 4 225 675 6885 4005 [alpha]\001
4 1 4 0 0 0 16 0.0000 4 210 270 3375 8235 [v]\001
4 1 4 0 0 0 16 0.0000 4 210 240 2655 8460 [s]\001
4 1 -1 0 0 0 20 1.5708 4 195 780 3064 8546 Sensor\001
4 2 4 0 0 0 20 0.0000 4 255 1530 1937 8642 SS:[Theta_2]\001
4 1 4 0 0 0 16 0.0000 4 225 270 3375 8730 [p]\001
4 1 4 0 0 0 16 0.0000 4 225 495 8780 8510 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 225 510 8739 9189 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 675 7065 8820 [alpha]\001
4 1 -1 0 0 0 20 0.0000 4 195 1335 8061 8826 RODa:rod2\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4593 8823 1\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_desc.tex version [72bea7d311].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoLinkPS (TwoLinkPS_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkPS} is
   displayed in Figure \Ref{TwoLinkPS_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkPS_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkPS_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:TwoLinkPS_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:TwoLinkPS_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLinkPS_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_lbl.txt version [23b89fb091].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkPS: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLinkPS_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_r;l_r;j_r;m_r
rod2	none	l_r;l_r;j_r;m_r

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal

%Named ports
[Joint_1]		SS	external,internal
[Joint_2]		SS	external,internal
[Theta_1]		SS	external,0
[Theta_2]		SS	external,0

%Torque/velocity at joints
%f_a1	SS	 external,external
%f_a2	SS	 external,external


Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_obspar.r version [887f4afee4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce  GPC observability function parameters for system TwoLinkPS (TwoLinkPS_obspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTGPCNy := 2;
MTTGPCNu := 0;
Matrix MTTdU(5,1);
MTTdU(1,1) := MTTdU1;
MTTdU(2,1) := MTTdU2;
MTTdU(3,1) := MTTdU3;
MTTdU(4,1) := MTTdU4;
MTTdU(5,1) := MTTdU5;
Matrix MTTUU(2,5);
MTTUU(1,1) := MTTu1;
MTTUU(1,2) := MTTu11;
MTTUU(1,3) := MTTu12;
MTTUU(1,4) := MTTu13;
MTTUU(1,5) := MTTu14;
MTTUU(2,1) := MTTu2;
MTTUU(2,2) := MTTu21;
MTTUU(2,3) := MTTu22;
MTTUU(2,4) := MTTu23;
MTTUU(2,5) := MTTu24;
END;

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_simp.r version [5fa9cf5d7f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce commands to simplify output for system TwoLinkP (TwoLinkP_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LET cos(mttx2) = c_2;
LET sin(mttx2) = s_2;

LET cos(mttx4) = c_4;
LET sin(mttx4) = s_4;

LET cos(mttx2-mttx4) = c;
LET sin(mttx2-mttx4) = s;

END;

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/TwoLinkPS_subs.r version [47554050fc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce  substitution statements for system TwoLinkPSX (TwoLinkPSX_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/03/22 20:13:25  peterg
% %% Trig simplification added
% %%
% %% Revision 1.1  1998/03/22 20:12:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_abg.fig version [9434c7d473].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4050 8100 4050 7875 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9000 4050 10125 4050 9900 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 6975 11475 1125 1125 1125 1125 6975 11475 6975
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 7035 4815 6345 Mass-spring-damper system (position output with extra lag)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001
4 1 -1 0 0 0 20 0.0000 4 195 390 6750 4140 AE\001
4 1 -1 0 0 0 20 0.0000 4 195 690 8550 4140 RC:rc\001
4 0 4 0 0 0 20 0.0000 4 240 960 10260 4140 SS:[out]\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_abg.fig.bak version [783d02bd00].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 6975 8325 1125 1125 1125 1125 6975 8325 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 5355 4815 6345 Mass-spring-damper system (position output)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 0 4 0 0 0 20 0.0000 4 240 960 6660 4140 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_desc.tex version [c342c284c0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system msdPS (msdPS_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msdPS} is
   displayed in Figure \Ref{msdPS_abg} and its label
   file is listed in Section \Ref{sec:msdPS_lbl}.
   The subsystems are listed in Section \Ref{sec:msdPS_sub}.


 \textbf{msdPS} is a simple Mass-Spring-Damper system with 
 force input and position output. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/msdPS_lbl.txt version [79760470ab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY msdPS
%DESCRIPTION <Detailed description here>
%% Label file for system msdPS (msdPS_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_s		lin	effort,c_s

% Component type I
	j_s		lin	flow,j_s

% Component type R
	r_s		lin	flow,r_s

% Component type RC
	rc		none	tau;1

% Component type SS
	[in]		SS	external,internal
	[out]		SS	external,0

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/msdP_abg.fig version [783d02bd00].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 6975 8325 1125 1125 1125 1125 6975 8325 6975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4050 6525 4050 6300 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 2700 5400 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
4 1 -1 0 0 0 20 0.0000 4 195 135 3600 4185 1\001
4 2 4 0 0 0 20 0.0000 4 240 810 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 480 3600 5715 I:j_s\001
4 1 1 1 0 0 20 0.0000 4 255 5355 4815 6345 Mass-spring-damper system (position output)\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 4140 0\001
4 0 4 0 0 0 20 0.0000 4 240 960 6660 4140 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 255 615 3600 2565 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 255 630 5175 2565 C:c_s\001

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/msdP_desc.tex version [be83adfdb1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system msdP (msdP_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msdP} is
   displayed in Figure \Ref{msdP_abg} and its label
   file is listed in Section \Ref{sec:msdP_lbl}.
   The subsystems are listed in Section \Ref{sec:msdP_sub}.


 \textbf{msdP} is a simple Mass-Spring-Damper system with 
 force input and position output. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/GPC/TwoLinkGPC/msdP_lbl.txt version [dee478e657].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY msdP
%DESCRIPTION <Detailed description here>
%% Label file for system msdP (msdP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_s		lin	effort,c_s

% Component type I
	j_s		lin	flow,j_s

% Component type R
	r_s		lin	flow,r_s

% Component type SS
	[in]		SS	external,internal
	[out]		SS	external,0

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Fixed_abg.fig version [59be0b9ae0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 0 0 100 0 18 20 0.0000 4 225 810 5625 1890 SS:z1\001
4 0 0 100 0 18 20 0.0000 4 240 810 5625 2790 SS:z2\001
4 2 4 100 0 18 20 0.0000 4 285 1305 4140 1890 SS:[y_in]\001
4 2 4 100 0 18 20 0.0000 4 285 1860 4140 2790 SS:[theta_in]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Fixed_lbl.txt version [2f6cde2cc7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Fixed (Fixed_lbl.txt)
%SUMMARY Fixed
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	y_in,theta_in

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_in]	SS		external,external
	[y_in]		SS		external,external
	z1		SS		internal,0
	z2		SS		internal,0

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Free_abg.fig version [c03c8c2488].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 2 0 100 0 18 20 0.0000 4 225 810 4140 1890 SS:z1\001
4 2 0 100 0 18 20 0.0000 4 240 810 4140 2790 SS:z2\001
4 0 4 100 0 18 20 0.0000 4 285 1500 5490 1890 SS:[y_out]\001
4 0 4 100 0 18 20 0.0000 4 285 2055 5445 2790 SS:[theta_out]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Free_lbl.txt version [517bb24436].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Free (Free_lbl.txt)
%SUMMARY Free
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	y_out,theta_out

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_out]	SS		external,external
	[y_out]		SS		external,external
	z1		SS		0,internal
	z2		SS		0,internal



Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/Make_figures.m version [7ca19d2a8a].

1
2
3
4




-
-
-
-
#!/bin/sh
## Script file Make_figures.

ppp_1("PPPCantileverBeam",1:2,[1 2;1 3]); # 2 inputs; modes 1 2 and 1 and 3

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_abg.fig version [3a565598a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1125 2700 2250 2700 2025 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8775 2700 9900 2700 9675 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 3825 2700 3600 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4095 6300 4095 4500 4320 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3870 4500 4320 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5850 2700 6975 2700 6750 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7380 2700 8505 2700 8280 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7245 6300 7245 4500 7470 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 7020 4500 7470 4500
4 1 0 100 0 18 20 1.5708 4 225 630 1035 2700 Free\001
4 1 0 100 0 18 20 1.5708 4 225 780 10260 2700 Fixed\001
4 1 0 100 0 18 20 1.5708 4 285 3690 8775 2700 BernoulliEuler:Chunk_3*3\001
4 1 0 100 0 18 20 1.5708 4 285 3690 2610 2700 BernoulliEuler:Chunk_1*3\001
4 1 0 100 0 18 20 1.5708 4 300 3480 4140 2700 pBernoulliEuler:Patch_1\001
4 1 4 100 0 18 16 0.0000 4 240 900 4095 4455 [torque]\001
4 1 0 100 0 18 20 0.0000 4 285 1275 4050 6660 SS:tau_1\001
4 1 0 100 0 18 20 1.5708 4 285 3690 5760 2700 BernoulliEuler:Chunk_2*8\001
4 1 0 100 0 18 20 1.5708 4 300 3480 7290 2700 pBernoulliEuler:Patch_2\001
4 1 4 100 0 18 16 0.0000 4 240 900 7245 4455 [torque]\001
4 1 0 100 0 18 20 0.0000 4 285 1275 7200 6660 SS:tau_2\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_desc.tex version [c5991e9114].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PPPCantileverBeam (PPPCantileverBeam_desc.tex)
% Generated by MTT on Mon Apr 19 07:04:54 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/05/18 04:01:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{PPPCantileverBeam} is displayed in
Figure \Ref{fig:PPPCantileverBeam_abg.ps} and its label file is listed in
Section \Ref{sec:PPPCantileverBeam_lbl}.  The subsystems are listed in Section
\Ref{sec:PPPCantileverBeam_sub}.
   
This example represents the dynamics of a uniform beam with one fixed
and one free end.  The beam is approximated by 16 equal lumps using
the Bernoulli-Euler approximation with damping. The ouputs are taken
to be the 16 lump velocities, the two inputs are taken to be torques
applied to lumps 3 away from each end; this approximates the effect of
two piezoelectric patches.

The system parameters are given in Section
\Ref{sec:PPPCantileverBeam_numpar.tex}.
The system has 32 states (16 modes of vibration), 2 inputs and 12
outputs.
The first 8 modal frequencies are given in Table \ref{tab:modes}.
\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{||c|c||c|c||}
      \hline
      Mode & $\omega_i$ & Mode & $\omega_i$\\
      \hline
      \hline
      1 & 0.0079504 & 5 & 0.4352376\\
      2 & 0.0498140 & 6 & 0.6338899\\
      3 & 0.1386209 & 7 & 0.8573604\\
      4 & 0.2682835 & 8 & 1.0976942\\
      \hline
    \end{tabular}
    \caption{Modal frequencies}
    \label{tab:modes}
  \end{center}
\end{table}

Figure \Ref{fig:PPPCantileverBeam_lmfr.ps} shows the log modulus of the frequency
response and Figure \Ref{fig:PPPCantileverBeam_pppy0.ps} shows the system transient
reponse with no control and an initial unit twist.

Figure \Ref{fig:PPPCantileverBeam_pppy.ps} shows closed loop reponse when
controlled by a PPP controller attempting to damp modes 1 and 2 from
input 1 and modes 1 and three from input 2. Figure
\Ref{fig:PPPCantileverBeam_pppy.ps} shows the corresponding control signals.







Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_input.txt version [d4ae1b0a98].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (PPPCantileverBeam_input.txt)
# Generated by MTT at Thu Apr 22 00:12:54 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
mttu(1) = exp(-t/0.1); 	# tau (PPPCantileverBeam)

# Set the switches

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_lbl.txt version [5eda0fc64e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system PPPCantileverBeam (PPPCantileverBeam_lbl.txt)
%SUMMARY PPPCantileverBeam
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Declare some variables
%VAR Area
%VAR AreaMoment
%VAR BeamLength
%VAR BeamThickness
%VAR BeamWidth
%VAR Density
%VAR N
%VAR Youngs
%VAR EI
%VAR rhoA

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type BenoulliEuler
  Chunk_1
  Patch_1
  Chunk_2
  Patch_2
  Chunk_3


% Component type SS
	tau_1	SS		external,external
	tau_2	SS		external,external

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_numpar.txt version [45ea043915].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (PPPCantileverBeam_numpar.txt)
# Generated by MTT at Mon Apr 19 06:24:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:27:26  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
N = 16;
BeamLength = 0.58;
BeamWidth = 0.05;
BeamThickness = 0.005;
Youngs = 1e6;
Density = 1e5;
Area = BeamWidth*BeamThickness;
AreaMoment = (BeamThickness*pow(BeamWidth,2))/12;


EI= 58.6957			# from Reza
rhoA= 0.7989			# from Reza
 
dz = BeamLength/N;		# Incremental length
dm = rhoA*dz;			# Incremental mass
dk = EI/dz;			# Incremental stiffness
dr = 1e-2;			# Damping

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_rep.txt version [49cce86377].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system PPPCantileverBeam (PPPCantileverBeam_rep.txt)
## Generated by MTT on" Mon Apr 19 06:43:08 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt PPPCantileverBeam abg tex			# The system description
## mtt PPPCantileverBeam cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt PPPCantileverBeam struc tex	        # The system structure
## mtt PPPCantileverBeam dae tex	        # The system dae
## mtt PPPCantileverBeam ode tex	        # The system ode 
## mtt PPPCantileverBeam sspar tex		# Steady-state parameters
## mtt PPPCantileverBeam ss tex 		# Steady state
## mtt PPPCantileverBeam dm tex		# Descriptor matrices (of linearised system)
## mtt PPPCantileverBeam sm tex		# State matrices (of linearised system)
## mtt PPPCantileverBeam tf tex		# Transfer function (of linearised system)
mtt PPPCantileverBeam simpar tex		# Simulation parameters
mtt PPPCantileverBeam numpar tex		# Numerical simulation parameters
## mtt PPPCantileverBeam input tex		# Simulation input
## mtt PPPCantileverBeam odeso ps		# Simulation output
mtt PPPCantileverBeam lmfr ps		# log modulus of frequency response (of linearised system)

mtt PPPCantileverBeam pppy ps		# PPP output
mtt PPPCantileverBeam pppu ps		# PPP input
mtt PPPCantileverBeam pppy0 ps		# PPP open-loop op

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_simpar.txt version [7c1db12c6b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system PPPCantileverBeam (PPPCantileverBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 500;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/PPPCantileverBeam_simpar.txt_old version [df1ea30bc7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system PPPCantileverBeam (PPPCantileverBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
METHOD      = Implicit;   # Integration method
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 500;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/ppp_1.m version [4acd8828e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function  ppp_1(Name,Inputs,Modes);

# Name = "CantileverBeam"
# Inputs = 1:2
# Modes = [1 2;1 3]

  path(path,"~/Research/CGPC/PPP");  
  
  Name,Inputs,Modes

  ## System
  system(sprintf("mtt -q %s numpar m", Name));
  system(sprintf("mtt -q %s sm m", Name));
  par = eval(sprintf("%s_numpar;",Name));
  eval(sprintf("[A,B,C,D]=%s_sm(par);",Name));
  [n_x,n_u,n_y] = abcddim(A,B,C,D)


  ## Change B
  B = B(:,Inputs);
  [junk,n_u]=size(B);
  n_u

  ## Redo C and D to reveal ALL velocities
   n_y = n_x/2
   C = zeros(n_y,n_x);
   for i = 1:n_y
     C(i,2*i-1) = 1;
   endfor

  ## Sort out D
  D = zeros(n_y,n_u);

  e = eig(A);			# Eigenvalues
  N = length(e);
  frequencies = sort(imag(e));
  frequencies = frequencies(N/2+1:N); # Modal frequencies

  ## Controller
  ## Controller design parameters
  t = [0.9:0.01:1.0];		# Optimisation horizon

  ## Specify input basis functions 
  ##  - damped sinusoids with same frequencies as beam
  damping_ratio = [0.1 0.1];		# Damping ratio of inputs
  A_u=[];
#   Modes = [1  3  
# 	   1  2];		# Choose modes to be controlled by each input 
  if n_u == 1			# Put all modes on each input
    Modes = [Modes; Modes];
  endif
  
  Modes

  for i=Inputs
    A_ui = damped_matrix(frequencies(Modes(i,:)),damping_ratio(i)*ones(size(Modes(i,:))));
    A_u = [A_u;A_ui];
    u_0 = ones(n_x,1);		# Initial conditions
  endfor
  

  A_w = 0;			# Setpoint
  Q = ones(n_y,1);		# Output weighting

  ## Design 
  disp("Control design - unconstrained");
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw] = ppp_lin  (A,B,C,D,A_u,A_w,t); # Unconstrained design

  ## Organise some plots
   dt = 0.002;		# Time increment
#   T =  0:dt:t(length(t));	# Time starting at zero but past horizon
   T =  0:dt:1.0;		# Time 

  ## Set up an "typical" initial condition
  x_0 = zeros(n_x,1);
  x_0(2:2:n_x) = ones(1,n_x/2);	# Set initial twist to 1.
#  disp("Computing OL response");
#  [Ys,Us] = ppp_transient (T,A_u,-(K_x*x_0)',u_0,A,B,C,D,x_0); # Compute open-loop control
  
  
  disp("Computing OL response (no control)");
  [Y_0] = ppp_sm2sr(A, B, C, D, T, zeros(n_u,1), x_0); # Compute Closed-loop control
  title("Y (no control)");
  xlabel("Time")
  grid; 
  plot(T,Y_0);
  psfig(sprintf("%s_pppy0",Name));

  disp("Computing Unconstrained CL response");
  [y_u,X_u] = ppp_sm2sr(A-B*k_x, B, C, D, T, zeros(n_u,1), x_0);
  u_u = -k_x*X_u';


  title("Unconstrained closed-loop control - y");
  xlabel("Time")
  grid; 
  plot(T,y_u);
  psfig(sprintf("%s_pppy",Name));

  title("Unconstrained closed-loop control - u");
  xlabel("Time")
  grid; 
  plot(T,u_u);
  psfig(sprintf("%s_pppu",Name));

#   ## Constrained version
  
#   ## Constraints - u
#   Tau_u = [0:0.01:1];
#   one = ones(size(Tau_u));
#   limit = 1e10;
#   Min_u = -limit*one;
#   Max_u =  limit*one;
#   Order_u = 0*one;

#   ## Constraints - y
#   Tau_y = [];
#   one = ones(size(Tau_y));
#   limit = 1e5; 
#   Min_y = -limit*one;
#   Max_y =  limit*one;
#   Order_y = 0*one;

#   ## Simulation

#   ## Constrained - open-loop
#   Gamma = [];
#   gamma = [];
#   for i=1:n_u			# Put same constraints on each input
#     [Gamma_i,gamma_i] = ppp_input_constraint (A_u,Tau_u,Min_u,Max_u,Order_u,i,n_u);
#     Gamma = [Gamma; Gamma_i];
#     gamma = [gamma; gamma_i];
#   endfor


#   disp("Open-loop simulations...");
#   ## Constrained OL simulation
#   W = zeros(n_y,1);
#   [u,U] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma);
#   T = [0:t(2)-t(1):t(length(t))];
#   [ys,us] = ppp_ystar (A,B,C,D,x_0,A_u,U,T);

#   title("Constrained y*");
#   xlabel("t");
#   grid;
#   plot(T,ys)

#   ## Unconstrained OL simulation
#   [uu,Uu] = ppp_qp (x_0,W,J_uu,J_ux,J_uw,Us0,[],[]); 
#   [ysu,usu] = ppp_ystar (A,B,C,D,x_0,A_u,Uu,T);

#   title("Unconstrained y*");
#   xlabel("t");
#   grid;
#   plot(T,ysu)

#   ## Non-linear - closed-loop
#   disp("Closed-loop simulation");
#   Tc = [0:4e-4:1.0];	
#   Delta_ol = 1.0;
#   [yc,uc,J] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, T, Tau_u,Min_u,Max_u,Order_u, Tau_y,Min_y,Max_y,Order_y,W,x_0,Delta_ol);

#   title("y,y*,u and u*");
#   xlabel("t");
#   grid;
#   plot(T1,y,T,ys,T1,u,T,us);

endfunction








Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/pppu_rep.make version [111a3668c7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Make file for the ppp output rep
## Symlinked to:
##	pppy
##	pppy0
##	pppu

all: $(SYS)_pppy.ps $(SYS)_pppy0.ps $(SYS)_pppu.ps

$(SYS)_pppy.ps: Make_figures.m ppp_1.m $(SYS)_sm.m $(SYS)_numpar.m
	octave Make_figures.m
$(SYS)_pppy0.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppy0.ps
$(SYS)_pppu.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppu.ps

$(SYS)_sm.m: 
	mtt $(SYS) sm m

$(SYS)_numpar.m: 
	mtt $(SYS) numpar m

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/pppy0_rep.make version [111a3668c7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Make file for the ppp output rep
## Symlinked to:
##	pppy
##	pppy0
##	pppu

all: $(SYS)_pppy.ps $(SYS)_pppy0.ps $(SYS)_pppu.ps

$(SYS)_pppy.ps: Make_figures.m ppp_1.m $(SYS)_sm.m $(SYS)_numpar.m
	octave Make_figures.m
$(SYS)_pppy0.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppy0.ps
$(SYS)_pppu.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppu.ps

$(SYS)_sm.m: 
	mtt $(SYS) sm m

$(SYS)_numpar.m: 
	mtt $(SYS) numpar m

Deleted mttroot/mtt/lib/examples/Control/PPP/Linear/PPPCantileverBeam/pppy_rep.make version [111a3668c7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Make file for the ppp output rep
## Symlinked to:
##	pppy
##	pppy0
##	pppu

all: $(SYS)_pppy.ps $(SYS)_pppy0.ps $(SYS)_pppu.ps

$(SYS)_pppy.ps: Make_figures.m ppp_1.m $(SYS)_sm.m $(SYS)_numpar.m
	octave Make_figures.m
$(SYS)_pppy0.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppy0.ps
$(SYS)_pppu.ps: $(SYS)_pppy.ps
	touch $(SYS)_pppu.ps

$(SYS)_sm.m: 
	mtt $(SYS) sm m

$(SYS)_numpar.m: 
	mtt $(SYS) numpar m

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AE3_abg.fig version [06166c49e9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4747 5175 6097 5175 5872 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7447 5175 8797 5175 8572 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2677 5175 4027 5175 3802 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6772 3375 6772 4725 6997 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 6750 6750 5400 6975 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 8550 6750 7200 6975 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 1575 6750 2925 6975 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9472 5175 10822 5175 10597 5400
4 1 0 100 0 18 20 0.0000 4 225 405 6750 3240 AE\001
4 1 0 100 0 18 20 0.0000 4 225 405 6750 7110 AE\001
4 1 0 100 0 18 20 0.0000 4 225 405 4365 5265 AE\001
4 1 4 100 0 18 20 0.0000 4 285 975 2115 5265 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1335 6795 1485 SS:[mod]\001
4 1 4 100 0 18 20 0.0000 4 285 1500 6705 8820 SS:[smod]\001
4 1 0 100 0 18 30 0.0000 4 330 660 6750 5265 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 5985 4995 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 7560 4995 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 4590 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 5625 [4]\001
4 1 0 100 0 18 20 0.0000 4 225 405 9135 5265 AE\001
4 1 4 100 0 18 20 0.0000 4 285 1170 11475 5265 SS:[out]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AE3_lbl.txt version [d1dfd6ef4f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system AE3 (AE3_lbl.txt)
%SUMMARY AE3
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	mod	mod
%ALIAS	out	out
%ALIAS	smod	smod

% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	slsin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type R
	r		slsin	-1*l

% Component type SS
	[in]	SS		external,external
	[mod]	SS		external,external
	[out]	SS		external,external
	[smod]	SS		external,external




Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AF3_abg.fig version [bbf355643a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4747 5175 6097 5175 5872 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7447 5175 8797 5175 8572 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2677 5175 4027 5175 3802 5400
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6772 3375 6772 4725 6997 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 6750 6750 5400 6975 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 8550 6750 7200 6975 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 1575 6750 2925 6975 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9472 5175 10822 5175 10597 5400
4 1 0 100 0 18 20 0.0000 4 225 405 6750 3240 AE\001
4 1 0 100 0 18 20 0.0000 4 225 405 6750 7110 AE\001
4 1 4 100 0 18 20 0.0000 4 285 975 2115 5265 SS:[in]\001
4 1 4 100 0 18 20 0.0000 4 285 1335 6795 1485 SS:[mod]\001
4 1 4 100 0 18 20 0.0000 4 285 1500 6705 8820 SS:[smod]\001
4 1 0 100 0 18 30 0.0000 4 330 660 6750 5265 R:r\001
4 1 4 100 0 18 14 0.0000 4 210 270 5985 4995 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 7560 4995 [2]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 4590 [3]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6570 5625 [4]\001
4 1 0 100 0 18 20 0.0000 4 225 390 4365 5310 AF\001
4 1 0 100 0 18 20 0.0000 4 225 390 9135 5265 AF\001
4 1 4 100 0 18 20 0.0000 4 285 1170 11610 5265 SS:[out]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/AF3_lbl.txt version [fe6985b952].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system AE3 (AE3_lbl.txt)
%SUMMARY AE3
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	mod	mod
%ALIAS	out	out
%ALIAS	smod	smod

% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	slsin


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type R
	r		slsin	l

% Component type SS
	[in]	SS		external,external
	[mod]	SS		external,external
	[out]	SS		external,external
	[smod]	SS		external,external

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Cart_abg.fig version [dd76f4c478].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 4950 4275 4725 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5400 3600 5400 3825 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 4950 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3015 3150 4365 3150 4140 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4815 3150 6165 3150 5940 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4590 2925 4590 1575 4815 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4815 1575 4365 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4793 2934 6153 1574 6153 1893
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4387 2947 3027 1587 3346 1587
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 3150 9000 3150 8775 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 4050 3600 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 5400 6750 5400 6525 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6750 5175 6750 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5400 4275 6750 4275 6525 4500
4 2 0 100 0 18 18 0.0000 4 270 2130 3510 4365 Sf:zero_velocity\001
4 1 1 101 0 3 18 0.0000 4 255 1125 5310 4725 y-velocity\001
4 1 1 101 0 3 18 0.0000 4 255 1155 5265 3735 x-velocity\001
4 1 1 101 0 3 18 0.0000 4 255 1905 5175 5940 angular-velocity\001
4 2 0 100 0 18 18 0.0000 4 270 720 3555 5490 R:r_p\001
4 1 0 100 0 18 18 0.0000 4 195 150 4590 3240 1\001
4 1 4 100 0 18 18 0.0000 4 270 765 6390 1440 SS:[x]\001
4 1 0 100 0 18 18 0.0000 4 270 870 4635 1440 IS:m_c\001
4 1 0 100 0 18 18 0.0000 4 270 690 2880 1440 R:r_c\001
4 1 4 100 0 18 18 0.0000 4 270 1290 2250 3240 SS:[drive]\001
4 0 0 100 0 18 18 0.0000 4 210 1560 9090 3240 De:Position\001
4 1 0 100 0 18 18 0.0000 4 210 1035 6975 3240 INTFS:x\001
4 1 0 100 0 18 18 0.0000 4 195 150 5175 5490 1\001
4 1 4 100 0 18 18 0.0000 4 270 780 7245 5490 SS:[a]\001
4 1 0 100 0 18 18 0.0000 4 195 150 5175 4365 1\001
4 1 4 100 0 18 18 0.0000 4 270 765 7245 4365 SS:[y]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Cart_lbl.txt version [53f4dac4d3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Cart (Cart_lbl.txt)
%SUMMARY Cart
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	drive
%ALIAS	pendulum|out	x,y,a

% Argument aliases
%ALIAS	$1	m_c
%ALIAS	$2	r_c
%ALIAS	$3	r_p

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type IS
	m_c		lin	flow,m_c;v_0

% Component type R
	r_c		lin	flow,r_c
	r_p		lin	flow,r_p

% Component type INTFS
	x               none    x_0

% Component type SS
	[a]	SS		internal,0
	[drive]	SS		external,internal
	[x]	SS		0,internal
	[y]	SS		0,internal

% Component type De
	Position		SS	external

% Component type Sf
	zero_velocity		SS	0




Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DCS_abg.fig version [b47c5c7578].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3330 1305 3870 1395
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 1350 3825 1350
-6
6 7965 2475 8505 2565
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8010 2520 8460 2520
-6
6 3330 2475 3420 3015
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3375 2520 3375 2970
-6
6 9810 2475 9900 3015
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9855 2520 9855 2970
-6
6 7965 2430 8055 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8010 2475 8010 2925
-6
6 3735 2430 3825 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3780 2475 3780 2925
-6
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4860 4730 4860 494 2293 494 2293 4730 4860 4730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2036 2724 3371 2724 3063 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2501 3576 1342 3833 1609
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3782 2724 5116 2724 4808 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3576 2947 3576 4106 3833 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6656 2724 7991 2724 7683 2947
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8196 2947 8196 4106 8453 3839
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8453 2724 9788 2724 9480 2947
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9480 4730 9480 494 6913 494 6913 4730 9480 4730
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12150 5175 45 5175 45 316 12150 316 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8190 2501 8190 1341 8447 1609
4 2 4 0 0 0 18 0.0000 4 240 1605 1980 2790 SS:[Electrical]\001
4 1 -1 0 0 0 18 0.0000 4 195 135 3525 2858 1\001
4 1 -1 0 0 0 18 0.0000 4 255 945 5938 2813 GY:k_m\001
4 1 -1 0 0 0 18 0.0000 4 195 135 8196 2813 1\001
4 1 -1 0 0 0 18 0.0000 4 255 630 3525 1252 IS:l_a\001
4 1 -1 0 0 0 18 0.0000 4 255 600 3628 4463 R:r_a\001
4 1 -1 0 0 0 18 0.0000 4 255 735 8248 4463 R:b_m\001
4 1 1 1 0 0 18 0.0000 4 195 1065 3576 5043 Electrical\001
4 1 1 1 0 0 18 0.0000 4 195 1290 8196 5043 Mechanical\001
4 1 1 1 0 0 18 0.0000 4 195 600 10404 3170 Shaft\001
4 1 1 1 0 0 18 0.0000 4 195 1155 1472 3170 Terminals\001
4 0 4 0 0 0 18 0.0000 4 240 1830 9945 2835 SS:[Mechanical]\001
4 1 -1 0 0 0 18 0.0000 4 255 585 8235 1215 I:j_m\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DCS_lbl.txt version [085bf103ca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY DCS: DCS motor 
%DESCRIPTION A special for the inverted pendulum system
%DESCRIPTION Derivative causality on the  shaft
%DESCRIPTION No aliased parameters
%DESCRIPTION Built in causality - speeds things up
%DESCRIPTION Only the armature state and shaft resistance are variable

%ALIAS in	Electrical
%ALIAS out	Mechanical


%% Label file for system DCS (DCS_lbl.txt)


%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin		flow,k_m

% Electrical components
%Inductance
l_a	lin		flow,l_a;i_0

%Resistance
r_a	lin		flow,r_a

% Mechanical components
%Inertia
j_m	lin		flow,j_m

%Friction
b_m	lin		flow,b_m

% Ports
	[Electrical]	SS	external,external
	[Mechanical]	SS	external,external

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_abg.fig version [7ddc7b16cb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3555 4005 3645 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 4050 3600 4500
-6
6 6255 4005 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 4050 6300 4500
-6
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 7650 4725 5850 4725 5850 3825 7650 3825 7650 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 4275 3600 4275 3375 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 4275 6300 4275 6075 4500
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 5175 4725 3375 4725 3375 3825 5175 3825 5175 4725
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 2610 4725 585 4725 585 3825 2610 3825 2610 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 4275 8775 4275 8550 4500
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 10125 4950 10125 2025 225 2025 225 4950 10125 4950
4 1 0 100 0 18 20 0.0000 4 360 1815 1620 4410 OpenLoop\001
4 1 0 100 0 18 20 0.0000 4 285 960 4320 4410 Drive\001
4 1 0 100 0 18 20 0.0000 4 285 765 6795 4410 Cart\001
4 1 0 100 0 18 20 0.0000 4 285 810 9225 4410 Zero\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_input.txt version [b342c864df].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (DriveCart_input.txt)
# Generated by MTT at Thu Aug  5 09:17:30 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
#mttu(1) = 1.0*(t<1) -1.0*((t>=1)&&(t<2)); 	# u (DriveCart_F)
mttu(1) = 1;
mttu(2) = 0;
mttu(3) = 0;
mttu(4) = 0;

# Set the switches

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_lbl.txt version [3e401170aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system DriveCart (DriveCart_lbl.txt)
%SUMMARY DriveCart
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR l_p		#Pendulum length

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----






Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_numpar.txt version [9986736335].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (DriveCart_numpar.txt)
# Generated by MTT at Wed Aug 25 22:57:05 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	1.5;			# Cart friction

# l_p =   0.61;			# Pendulum length
# m_p =   0.210;			# Pendulum mass
# r_p = 	0.0;			# Pendulum friction

# j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

# g = 9.81;			# Gravity


## Sensitivity parameters
# m_cs = 0;			# Cart mass
# b_ms = 0;			# Motor friction 
# r_cs = 0;			# Cart friction
# r_ps = 0;			# Pendulum friction


## Control parameters
k_1 = 1;
k_2 = 0;
k_3 = 0;

## States
i_0 = 0;			# Initial armature current
v_0 = 0;			# Initial cart velocity
x_0 = 0;			# Initial cart position

# omega_0 = 0;			# Initial pendulum velocity
# theta_0 = 0;			# Initial pendulum angle

## Control sensitivity parameters
# k_1s = 0;
# k_2s = 0;
# k_3s = 0;

# ## Argument list
# if (mtt_n_parameters>1)
#   r_cs= mtt_parameters(1);
#   r_c = mtt_parameters(2);
# endif;

# if (mtt_n_parameters>3)
#   m_cs= mtt_parameters(3);
#   m_c = mtt_parameters(4);
# endif;

# if (mtt_n_parameters>5)
#   k_1s= mtt_parameters(5);
#   k_1 = mtt_parameters(6);
# endif;

# if (mtt_n_parameters>7)
#   k_2s= mtt_parameters(7);
#   k_2 = mtt_parameters(8);
# endif;

# if (mtt_n_parameters>9)
#   k_3s= mtt_parameters(9);
#   k_3 = mtt_parameters(10);
# endif;







Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_rep.txt version [5d95394934].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system DriveCart (DriveCart_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:29:11  peterg
## To RCS
##
###############################################################

mtt DriveCart abg tex			# The system description
mtt DriveCart cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt DriveCart struc tex	        # The system structure
mtt DriveCart dae tex	        # The system dae
## mtt DriveCart ode tex	        # The system ode 
## mtt DriveCart sspar tex		# Steady-state parameters
## mtt DriveCart ss tex 		# Steady state
## mtt DriveCart dm tex		# Descriptor matrices (of linearised system)
mtt DriveCart sm tex		# State matrices (of linearised system)
## mtt DriveCart tf tex		# Transfer function (of linearised system)
## mtt DriveCart lmfr ps		# log modulus of frequency response (of linearised system)
mtt DriveCart simpar tex		# Simulation parameters
mtt DriveCart numpar tex		# Numerical simulation parameters
mtt DriveCart input tex		# Simulation input
mtt DriveCart odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/DriveCart_simpar.txt version [c95de2a7c5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system DriveCart (DriveCart_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;      # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1000;		# Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Drive_abg.fig version [12e17c139d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 2475 3825 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 2700 3825 2700 3600 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5625 2700 6975 2700 6750 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 8325 2700 9675 2700 9450 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10575 2700 11925 2700 11700 2925
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 14400 4725 14400 675 225 675 225 4725 14400 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6975 2475 6975 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11925 2475 11925 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9675 2475 9675 2925
4 1 1 101 0 3 20 0.0000 4 255 1530 4590 3330 DC motor\001
4 1 1 101 0 3 20 0.0000 4 330 2745 2205 3330 Power supply unit\001
4 2 4 100 0 18 18 0.0000 4 270 1845 2430 2790 SS:[Electrical]\001
4 1 0 100 0 18 18 0.0000 4 210 1470 4725 2790 DCS:motor\001
4 1 0 100 0 18 18 0.0000 4 270 915 7695 2790 TF:k_g\001
4 1 0 100 0 18 18 0.0000 4 210 540 10125 2790 TF:r\001
4 0 4 100 0 18 18 0.0000 4 270 2115 12015 2790 SS:[Mechanical]\001
4 1 1 101 0 3 20 0.0000 4 330 2010 7515 3330 Internal gear\001
4 1 1 101 0 3 20 0.0000 4 330 1710 10080 3330 Motor gear\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Drive_lbl.txt version [99fb16d915].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Drive (Drive_lbl.txt)
%SUMMARY Drive
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Electrical
%ALIAS	out	Mechanical

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type DC
	motor

% Component type SS
	[Electrical]	SS		external,external
	[Mechanical]	SS		external,external

% Component type TF
	k_g		lin	flow,k_g
	r		lin	flow,r

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/INTFS_abg.fig version [0f2cfc3a7b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10575 4950 45 4950 45 1350 10575 1350 10575 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3150 2475 3150 2250 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 3150 7426 3150 7201 3375
4 1 -1 0 0 0 20 0.0000 4 255 180 4501 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 255 1110 4501 1891 CS:unit\001
4 2 4 0 0 0 20 0.0000 4 315 1455 1530 3240 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 255 825 2925 3240 AF:af\001
4 1 -1 0 0 0 20 0.0000 4 255 900 6075 3240 AE:ae\001
4 0 4 0 0 0 20 0.0000 4 330 3045 7470 3240 SS:[Integrated_flow]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/INTFS_lbl.txt version [566f080c2f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system INTFS (INTFS_lbl.txt)
%SUMMARY	INTFS: flow integrator
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/16 07:35:10  peterg
% %% Aliased version
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow
%ALIAS	out	Integrated_flow

% Argument aliases
%ALIAS	$1 x_0	

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


% Component type CS
	unit			lin		effort,1;x_0

% Component type AE
	ae			lin		1

% Component type AF
	af			lin		1

% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/IS_abg.fig version [833b9d0b1e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 0 100 0 18 20 0.0000 4 270 195 2475 4185 0\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
4 1 0 100 0 18 20 0.0000 4 285 315 2475 2295 I:i\001
4 0 0 100 0 18 20 0.0000 4 360 1035 4185 4185 Sf:f_0\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2475 6030 SS:[in]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/IS_lbl.txt version [fd9f48ad6f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system IS (IS_lbl.txt)
%SUMMARY IS I component with initial state


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	i		lin	flow,i

% Component type SS
	[in]	 SS	external,external

% Component type Sf
	f_0		SS	f_0


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_abg.fig version [f7dd4e7606].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3555 4005 3645 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 4050 3600 4500
-6
6 6255 4005 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 4050 6300 4500
-6
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 7650 4725 5850 4725 5850 3825 7650 3825 7650 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 4275 3600 4275 3375 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 4275 6300 4275 6075 4500
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 5175 4725 3375 4725 3375 3825 5175 3825 5175 4725
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 2610 4725 585 4725 585 3825 2610 3825 2610 4725
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9675 4950 9675 2025 225 2025 225 4950 9675 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3825 7705 2870 7705 3189
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 5
	 6952 3487 8347 2092 8527 2272 7177 3622 6997 3442
4 1 0 100 0 18 20 0.0000 4 360 1815 1620 4410 OpenLoop\001
4 1 0 100 0 18 20 0.0000 4 285 960 4320 4410 Drive\001
4 1 0 100 0 18 20 0.0000 4 285 3255 7830 2835 InvertedPendulum\001
4 1 0 100 0 18 20 0.0000 4 285 765 6795 4410 Cart\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_desc.tex version [bf8d448bf0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system InvertedPendulumOnCart (InvertedPendulumOnCart_desc.tex)
% Generated by MTT on Thu Aug 5 10:38:16 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{InvertedPendulumOnCart} is
   displayed in Figure \Ref{fig:InvertedPendulumOnCart_abg.ps} and its label
   file is listed in Section \Ref{sec:InvertedPendulumOnCart_lbl}.
   The subsystems are listed in Section \Ref{sec:InvertedPendulumOnCart_sub}.

This is a one input, two output nonlinear system comprising an
inverted pendulum attached by a hinge to a cart constrained to move in
the horizontal direction. The input is the horizontal force acting on
the cart, and the two outputs are the horizontal position and the
pendulum angle respectively.

The bond graph in Figure \Ref{InvertedPendulumOnCartPPP_abg} is augmented with the {\em
open-loop\/} controller comprising
\begin{itemize}
\item two effort source \textbf{Se} components ``u1'' and ``u2''
\item two effort amplifier \textbf{AE} components ``ppp\_1'' and `ppp\_2''
\end{itemize}

This is a \emph{nonlinear} system and it is used to illustate
\emph{nonlinear} PPP control. Section
\Ref{sec:InvertedPendulumOnCartPPP_nppp.ps} shows the cart position
$x$ and the pendulum angle $\theta$  when the pendulum starts from the
initial condition of  $\theta = \frac{\pi}{2}$ (ie the pendulum is
horizontal).
 

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_input.txt version [e48379ad1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (InvertedPendulumOnCartPPP_input.txt)
# Generated by MTT at Thu Aug  5 09:17:30 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
#mttu(1) = 1.0*(t<1) -1.0*((t>=1)&&(t<2)); 	# u (InvertedPendulumOnCartPPP_F)
mttu(1) = 1;
mttu(2) = 0;
mttu(3) = 0;
mttu(4) = 0;

# Set the switches

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_lbl.txt version [a0840e2c8b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system InvertedPendulumOnCartPPP (InvertedPendulumOnCartPPP_lbl.txt)
%SUMMARY InvertedPendulumOnCartPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR l_p		#Pendulum length

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----






Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_nppp.m version [95e3aca505].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141













































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Figures.m
## Makes figures for the InvertedPendulumOnCart_PPP exasmple.
## $Log$
## Revision 1.4  2000/08/17 12:34:58  peterg
## *** empty log message ***
##
## Revision 1.3  2000/08/11 16:01:27  peterg
## Fixed documentation error
##
## Revision 1.2  2000/05/21 06:39:40  peterg
## Parameterised _sm
##
## Revision 1.1  2000/05/20 11:30:41  peterg
## Initial revision
##
## Revision 1.2  2000/05/17 16:59:57  peterg
## Revised for Inverted pendulum - it works !!!!
##
## Revision 1.1  2000/05/17 14:07:53  peterg
## Initial revision
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "InvertedPendulumOnCartPPP";

## Uncomment the following the first time
## (Or do ./Make InvertedPendulumOnCartPPP in this directory)

## MTT stuff for the system simulation
##system("Make InvertedPendulumOnCartPPP");

t_s=1.0*[0:0.1:10];
u = [ones(4,length(t_s))];
x_0 = InvertedPendulumOnCartPPP_state;
par  = InvertedPendulumOnCartPPP_numpar;

## Simulate the system
tick=time;
[y,x] = InvertedPendulumOnCartPPP_sim(x_0,u,t_s,par);
Elapsed = time-tick
plot(t_s,y, t_s,x);

## Simulate the system to give just the final few points
t_s1 = 10*[9:0.1:10];
tick=time;
[y,x] = InvertedPendulumOnCartPPP_sim(x_0,u,t_s1,par);
Elapsed = time-tick
plot(t_s1,y,t_s1,x);

## Sensitivity system simulation parameters
x_0s = sInvertedPendulumOnCartPPP_state;
pars  = sInvertedPendulumOnCartPPP_numpar;
sympars  = sInvertedPendulumOnCartPPP_sympar;

## Simulate the sensitivity system
sensitivities = [sympars.ppp_1s,sympars.ppp_2s,sympars.r_cs]
tick=time;
[y,ys] = sInvertedPendulumOnCartPPP_sim(x_0s,u,t_s,pars,sensitivities);
Elapsed = time-tick
plot(t_s,y,t_s,ys);

### PPP parameters
A_w = [0;0];
A_u = laguerre_matrix(4,20); # Specify basis functions: constant &
			     # exp(-5t)
tau = 0.5*[0.9:0.01:1];             # Optimisation interval
t_ol =0.5*[0:0.01:0.2];            # Open-loop interval
N = 20;                          # Number of open-loop intervals in simulation
w = [0;0];                         # Setpoint

## Linear system
## Linear system
[A,B,C,D] = InvertedPendulumOnCartPPP_sm(par);
Q = [1;1];
ppp_lin_plot (A,B(:,1),C,D(:,1),A_u,A_w,tau,Q,w,x_0);
psfig("InvertedPendulumOnCartPPP_lin");

## Simulate non-linear PPP (on this nonlinear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.v = 0;
extras.verbose = 0;

# ##  -- with no optimisation using linear PPP with continuation
# extras.U_initial = "linear";
# extras.U_next = "continuation";
# extras.criterion = 1e-5;
# extras.max_iterations = 0;
# [y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

# ##  -- with no optimisation using linear PPP at each step
# extras.U_initial = "linear";
# extras.U_next = "linear";
# extras.criterion = 1e-5;
# extras.max_iterations = 0;
# [y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with optimisation using nonlinear PPP with continuation
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-4;
extras.max_iterations = 100;
extras.v = 1e-3;
extras.verbose = 0;
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);


## Plots
title("");

## U, U_c and U_l
I = 1:N;
IU1 = [I' U(1,:)'];
IU1_c = [I' U_c(1,:)'];
IU1_l = [I' U_l(1,:)'];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("InvertedPendulumOnCartPPP_U1");

IU2 = [I' U(2,:)'];
IU2_c = [I' U_c(2,:)'];
IU2_l = [I' U_l(2,:)'];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("InvertedPendulumOnCartPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
tu =  [t' u']; 
gplot tu title "Output"
psfig("InvertedPendulumOnCartPPP_u");

gset grid; xlabel "Time (sec)"
ty_th = [t' y(1,:)'] ;
ty_x = [t' y(2,:)'] ;
gplot ty_th title "Theta",ty_x title "x"
psfig("InvertedPendulumOnCartPPP_nppp");

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_numpar.txt version [9aa45f03b2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sInvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Tue Apr 18 18:07:52 BST 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Default parameters
b_m = 	0.0; # sDCS
c = 	0.0; # sC,sC,sCS,sCS
e_0 = 	0.0; # sCS,sCS
e_s = 	0.0; # Se,Se,Se,sSe,sSe,sSe
f_0 = 	0.0; # sIS,sIS,sIS
f_s = 	0.0; # Sf,Sf,Sf,sSf,sSf,sSf
g = 	0.0; # AFe,AFe,sInvertedPendulum,sROD
i = 	0.0; # sI,sI,sI,sI,sI,sI,sIS,sIS,sIS
i_0 = 	0.0; # sDCS
j_m = 	0.0; # sDCS,sROD
j_p = 	0.0; # sInvertedPendulum
ppp_1 = 	1.0; # sOpenLoop
ppp_2 = 	0.0; # sOpenLoop
ppp_3 = 	0.0; # sOpenLoop
ppp_4 = 	0.0; # sOpenLoop
k_g = 	0.0; # sDrive
k_m = 	0.0; # sDCS
l_a = 	0.0; # sDCS,sROD
l_b = 	0.0; # sROD
l_p = 	0.0; # sInvertedPendulum,sInvertedPendulumOnCart
m = 	0.0; # sROD
m_c = 	0.0; # sCart
m_p = 	0.0; # sInvertedPendulum
m_t = 	0.0; # sInvertedPendulum
omega_0 = 	0.0; # sInvertedPendulum,sROD
r = 	0.0; # sDrive,sR,sR
r_a = 	0.0; # sDCS
r_c = 	0.0; # sCart
r_p = 	0.0; # sCart
theta_0 = 	0.0; # sInvertedPendulum,sROD
v_0 = 	0.0; # sCart
x_0 = 	0.0; # sCart,sINTFS,sINTFS


## Pysical Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	1.5;			# Cart friction

l_p =   0.61;			# Pendulum length
m_p =   0.210;			# Pendulum mass
r_p = 	0.0;			# Pendulum friction

j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

g = 9.81;			# Gravity

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_rep.txt version [9c0f6beadc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system InvertedPendulumOnCartPPP (InvertedPendulumOnCartPPP_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:29:10  peterg
## To RCS
##
## Revision 1.3  2000/08/29 13:57:23  peterg
## Zapped some steps which prevent ppp from working ????
##
## Revision 1.2  2000/05/20 17:45:38  peterg
## Tidied
##
## Revision 1.1  2000/05/20 17:43:40  peterg
## Initial revision
##
###############################################################

mtt InvertedPendulumOnCartPPP abg tex # The system description
mtt InvertedPendulumOnCartPPP cbg ps # The causal bond graph
mtt InvertedPendulumOnCartPPP struc tex	# The system structure
mtt InvertedPendulumOnCartPPP dae tex # The system dae
# mtt InvertedPendulumOnCartPPP sm tex # State matrices (of linearised system)

# mtt InvertedPendulumOnCartPPP simpar tex # Simulation parameters
# mtt InvertedPendulumOnCartPPP numpar tex # Numerical simulation parameters
# mtt InvertedPendulumOnCartPPP input tex	# Simulation input
# mtt InvertedPendulumOnCartPPP odeso ps # Simulation output

mtt InvertedPendulumOnCartPPP nppp m # How its done
mtt InvertedPendulumOnCartPPP nppp ps # The PPP output

mtt InvertedPendulumOnCartPPP rep txt # The report outline



Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_simpar.txt version [6ec8d445cd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system InvertedPendulumOnCartPPP (InvertedPendulumOnCartPPP_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;      # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;		# Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulumOnCartPPP_state.txt version [009c83cce5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (InvertedPendulumOnCartPPP_state.txt)
# Generated by MTT at Thu May  4 16:13:13 BST 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the states
mttx(1) 	= 0.0; 	# i (InvertedPendulumOnCartPPP_mtt2_motor_l_a)
mttx(2) 	= 0.0; 	# i (InvertedPendulumOnCartPPP_mtt3_rod_J)
mttx(3) 	= -pi/2; 	# c (InvertedPendulumOnCartPPP_mtt3_rod_th_unit)
mttx(4) 	= 0.0; 	# i (InvertedPendulumOnCartPPP_mtt4_m_c)
mttx(5) 	= 0.0; 	# c (InvertedPendulumOnCartPPP_mtt4_x_unit)

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulum_abg.fig version [66be544a7f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3555 5085 6345 5310
4 1 4 100 0 18 14 0.0000 4 210 510 3825 5265 [x_b]\001
4 1 4 100 0 18 14 0.0000 4 210 525 4950 5265 [y_b]\001
4 1 4 100 0 18 14 0.0000 4 210 525 6075 5265 [a_b]\001
-6
6 3555 4545 6345 4770
4 1 4 100 0 18 14 0.0000 4 210 495 3825 4725 [x_a]\001
4 1 4 100 0 18 14 0.0000 4 210 510 4950 4725 [y_a]\001
4 1 4 100 0 18 14 0.0000 4 210 510 6075 4725 [a_a]\001
-6
6 5805 5355 6345 5445
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5850 5400 6300 5400
-6
6 3600 4455 4140 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3645 4500 4095 4500
-6
6 4635 4455 5175 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4680 4500 5130 4500
-6
6 5805 4455 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5850 4500 6300 4500
-6
6 8505 4680 8595 5220
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8550 4725 8550 5175
-6
6 4770 2790 5040 3060
4 1 0 100 0 18 20 0.0000 4 270 195 4905 3060 1\001
-6
6 3690 2790 3960 3060
4 1 0 100 0 18 20 0.0000 4 270 195 3825 3060 1\001
-6
6 3555 2655 4095 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 2700 4050 2700
-6
6 4680 2655 5220 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 2700 5175 2700
-6
6 4950 2520 5355 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5008 2552 5327 2870
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 4950 8550 4950 8325 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 2700 4950 1350 5175 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2700 3825 1350 4050 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5143 2687 6098 1732 6098 2050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3600 6750 4050 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4725 6750 5175 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 6750 3825 5400 4050 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 6750 4950 5400 5175 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 6750 6075 5400 6300 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 4500 6075 3150 6300 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 4500 4950 3150 5175 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4500 3825 3150 4050 3375
4 1 0 100 0 18 20 0.0000 4 285 1515 4964 5040 ROD:rod\001
4 1 0 100 0 18 18 0.0000 4 270 885 6030 3015 Se:a_0\001
4 1 4 100 0 18 20 0.0000 4 360 1050 3780 7155 SS:[x]\001
4 1 4 100 0 18 20 0.0000 4 360 1080 4950 7155 SS:[y]\001
4 1 4 100 0 18 20 0.0000 4 360 1065 6075 7155 SS:[a]\001
4 1 4 100 0 18 14 0.0000 4 210 270 6300 4995 [a]\001
4 0 0 100 0 18 20 0.0000 4 285 1515 8685 5085 De:theta\001
4 1 0 100 0 18 18 0.0000 4 270 675 4995 1170 I:m_y\001
4 1 0 100 0 18 18 0.0000 4 270 675 3870 1170 I:m_x\001
4 0 0 100 0 18 20 0.0000 4 360 1110 6120 1800 Se:mg\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/InvertedPendulum_lbl.txt version [ff2b5f8890].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system InvertedPendulum (InvertedPendulum_lbl.txt)
%SUMMARY InvertedPendulum
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x,y,a


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


% Component type I
        m_x     lin             flow,m_t
        m_y     lin             flow,m_t

% Component type Se
	mg			SS		m_t*g

% Component type De
	theta			SS	external

% Component type SS
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	a_0	 SS	0

% Component type gRod
	rod	 none		l_p;l_p;j_p;m_p;g;omega_0;theta_0
 

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Make version [e246f48d9d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Makes the files needed for Figures.m
## Copyright (C) 2000 by Peter J. Gawthrop

if [ -z "$1" ]; then
    echo Usage ./Make system_name
    exit
else
    echo "Making simulation for system $1 (for use in Figures.m)"
fi

## System
mtt -q -c -stdin $1 ode2odes out
mtt -q -c -stdin $1 sim m
mtt -q  $1 state m
mtt -q  $1 sympar m
mtt -q  $1 numpar m

## Sensitivity system
mtt -q -c -stdin -s s$1 ode2odes out
mtt -q -c -stdin -s s$1 sim m
mtt -q  -s s$1 state m
mtt -q  -s s$1 sympar m
mtt -q  -s s$1 numpar m

## Additional system reps for PPP
mtt -q  $1 sm m
mtt -q  $1 def m
mtt -q  -s s$1 def m

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/OpenLoop_abg.fig version [014e1e18a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 6570 1530 7200 1935
4 1 1 101 0 3 20 0.0000 4 270 495 6885 1845 u ( )\001
4 1 1 101 0 0 20 0.0000 4 135 150 6840 1800 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 7065 1845 t\001
-6
6 1800 1530 2520 2025
4 1 1 101 0 3 20 0.0000 4 270 555 2160 1845 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 2025 1\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 1800 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 1845 t\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6345 2250 7695 2250 7470 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2250 5850 2250 5625 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 5400 2925 5400 2700 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4545 5400 5895 5400 5670 5625
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 5175 6075 4050 6300 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 3825 2925 3825 2700 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4545 3825 5895 3825 5670 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 3600 6075 2475 6300 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 6975 2925 6975 2700 7200
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4545 6975 5895 6975 5670 7200
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 6750 6075 5625 6300 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2250 2925 2250 2700 2475
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9000 7875 9000 1125 225 1125 225 7875 9000 7875
4 2 0 100 0 18 20 0.0000 4 300 1170 1485 2340 Se:Us_1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 2340 AE:U_1\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 2340 1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 5490 AE:U_3\001
4 2 0 100 0 18 20 0.0000 4 300 1170 1530 5535 Se:Us_3\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 5535 1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 3915 AE:U_2\001
4 2 0 100 0 18 20 0.0000 4 300 1170 1530 3960 Se:Us_2\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 3960 1\001
4 1 0 100 0 18 20 0.0000 4 300 1035 3735 7065 AE:U_4\001
4 2 0 100 0 18 20 0.0000 4 300 1170 1530 7110 Se:Us_4\001
4 1 0 100 0 18 20 0.0000 4 210 165 6075 7110 1\001
4 1 1 101 0 3 20 0.0000 4 270 555 2160 3420 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 3600 2\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 3375 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 3420 t\001
4 1 1 101 0 3 20 0.0000 4 270 555 2160 4995 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 5175 3\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 4950 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 4995 t\001
4 1 1 101 0 3 20 0.0000 4 270 555 2160 6570 U ( )\001
4 1 1 101 0 3 16 0.0000 4 165 120 2070 6750 4\001
4 1 1 101 0 0 20 0.0000 4 135 150 2115 6525 *\001
4 1 1 101 0 32 20 0.0000 4 150 135 2340 6570 t\001
4 0 4 100 0 18 20 0.0000 4 300 1005 7830 2340 SS:[us]\001
4 1 1 101 0 3 20 0.0000 4 285 2370 3825 7695 Open-loop control\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/OpenLoop_lbl.txt version [da3b550155].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system OpenLoop (OpenLoop_lbl.txt)
%SUMMARY OpenLoop
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	us

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	U_1	 lin		ppp_1
	U_2	 lin		ppp_2
	U_3	 lin		ppp_3
	U_4	 lin		ppp_4

% Component type SS
	[us]	SS		external,external

% Component type Se
	Us_1		SS	external
	Us_2		SS	external
	Us_3		SS	external
	Us_4		SS	external


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/ROD_abg.fig version [9da8669d9a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9225 6075 8955 6075
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 5175 2025 3825 2250 3825
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 4950 8550 5400
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 5400
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 6525 3150 7650 3150 7425
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5425 5419 4750 6094 4750 5869
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4273 3823 3148 2698 3373 2698
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 4950 4725 4275 4950 4275
4 1 -1 0 0 0 20 0.0000 4 255 180 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 255 570 6933 5268 IS:J\001
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 255 180 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 255 180 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 330 870 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 330 900 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 255 1440 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 255 1440 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 255 1425 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 255 1425 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000 4 255 180 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 240 675 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000 4 255 1425 4681 5266 INTFS:th\001
4 1 1 1 0 0 20 0.0000 4 255 270 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 195 240 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 255 240 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000 4 240 675 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000 4 240 675 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000 4 240 675 3960 6210 [mod]\001
4 1 4 0 0 0 20 0.0000 4 330 1785 2971 1216 SS:[xTip_a]\001
4 1 4 0 0 0 20 0.0000 4 330 1800 2971 9361 SS:[xTip_b]\001
4 1 4 0 0 0 20 0.0000 4 330 1755 8372 1217 SS:[yTip_a]\001
4 1 4 0 0 0 20 0.0000 4 330 1770 8417 9362 SS:[yTip_b]\001
4 1 4 0 0 0 20 0.0000 4 330 2700 5671 1216 SS:[angularTip_a]\001
4 1 4 0 0 0 20 0.0000 4 330 2715 5671 9361 SS:[angularTip_b]\001
4 1 1 1 0 0 20 0.0000 4 330 765 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000 4 255 1800 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000 4 330 780 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000 4 330 930 9360 6345 Se:mg\001
4 2 4 0 0 0 20 0.0000 4 330 1515 1935 3735 SS:[angle]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/ROD_lbl.txt version [02fb4fd7ae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101





































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	ROD: rigid rod in two dimensions - with gravity and angle port
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS in|Tip_a		xTip_a,angularTip_a,yTip_a 	
%ALIAS out|Tip_b	xTip_b,angularTip_b,yTip_b 	

%ALIAS x_a		xTip_a # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b # Torque/angular velocity at tip b

%ALIAS angle|a		angle	# Angle port

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system ROD (ROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/10/22 02:01:45  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/08/05 08:04:40  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/11/30 10:47:53  peterg
% %% Added extra a_a and a_b aliases
% %%
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m;omega_0
m_x	lin	flow,m
m_y	lin	flow,m

%Integrate angular velocity to get angle
th	none	   theta_0

%Modulated transformers
s1	lsin	flow,l_a
s2	lsin	flow,l_b
c1	lcos	flow,l_a
c2	lcos	flow,l_b


% Component type Se
	mg			SS		m*g

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external
	[angle]			SS		external,external


	

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Zero_abg.fig version [10a50da953].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 4050 2700 3825 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 3375 4050 3375 3825 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
4 1 4 100 0 18 18 0.0000 4 270 765 2160 2790 SS:[x]\001
4 1 0 100 0 18 18 0.0000 4 210 570 4545 2790 Se:x\001
4 1 4 100 0 18 18 0.0000 4 270 765 2160 3465 SS:[y]\001
4 1 0 100 0 18 18 0.0000 4 270 570 4545 3465 Se:y\001
4 1 4 100 0 18 18 0.0000 4 270 780 2160 4140 SS:[a]\001
4 1 0 100 0 18 18 0.0000 4 210 525 4545 4140 Sf:a\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/Zero_lbl.txt version [651d1a7e40].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Zero (Zero_lbl.txt)
%SUMMARY Zero
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x,y,a

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	x	SS		0
	y	SS		0

% Component type Sf
	a	SS		external


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sCart_lbl.txt version [825772b7ca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sCart (sCart_lbl.txt)
%SUMMARY sCart
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	        drive_1,drive_2
%ALIAS	pendulum|out	x_1,x_2,y_1,y_2,a_1,a_2

% Argument aliases
%ALIAS	$1	m_c
%ALIAS	$2	r_c
%ALIAS	$3	r_p

%ALIAS	$4	m_cs
%ALIAS	$5	r_cs
%ALIAS	$6	r_ps

%ALIAS  $7	v_0
%ALIAS  $8	v_0s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	m_c		lin	flow,m_c;v_0;m_cs;v_0s

% Component type R
	r_c		lin	flow,r_c;r_cs
	r_p		lin	flow,r_p;r_ps

% Component type sINTFS
	x               none    x_0;x_0s

% Component type SS
	[a]	SS		external,external
	[drive]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type De
	Position		SS	external;external

% Component type Sf
	zero_velocity		SS	0;0



Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDCS_lbl.txt version [8f818cd526].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY sDCS: DC motor - sensitivity 
%DESCRIPTION A special for the inverted pendulum system
%DESCRIPTION Derivative causality on the  shaft
%DESCRIPTION No aliased parameters
%DESCRIPTION Built in causality - speeds things up
%DESCRIPTION Only the armature state and shaft resistance are variable

%ALIAS in	Electrical_1,Electrical_2
%ALIAS out	Mechanical_1,Mechanical_2


%% Label file for system sDCS (sDCS_lbl.txt)


%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin		flow,k_m;0

% Electrical components
%Inductance
l_a	lin		flow,l_a;i_0;0;i_0s

%Resistance
r_a	lin		flow,r_a;0

% Mechanical components
%Inertia
j_m	lin		flow,j_m;0

%Friction
b_m	lin		flow,b_m;b_ms

% Ports
	[Electrical]	SS	external,external
	[Mechanical]	SS	external,external

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDriveCart_identify.m version [6868c24a26].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function sDriveCart_identify ()

  ## usage:  sDriveCart_identify ()
  ##
  ## 

  ## Identify the Drive/cart friction
  ## 	$Id$	

  system_name = "sDriveCart";	# Name of this system
  input_name = sprintf("%s_input.dat", system_name);
  ## disp("Create programs");
  ## system(sprintf("mtt -q -c -s -stdin %s ode2odes out", system_name)); # Create sim. code
  ## system(sprintf("mtt -q -c -s -stdin %s numpar m", system_name)); # Create sim. code
  ## system(sprintf("mtt -q -c -s -stdin %s def m", system_name)); # Create sim. code

  ## Optimisation parameters
  crite = 1e-5;			# Convergence criterion
  alpha = 0.5;			# Step reduction factor
  max = 30;			# Maximum iterations
  View = 1			# View the optimisation process

  ## Parameters
  global mtt_n_parameters
  mtt_n_parameters = 0;

  eval(sprintf("%s_numpar;", system_name));

  alpha = 0.75;
  criterion = 1e-9;
  max_iterations = 20;

  ## Real data
  disp("Loading data");
  load -force data_020999.dat;
  [N_data,M_data] = size(data_020999);
  M = 10;
  t = data_020999(1:M:N_data,1);
  u = data_020999(1:M:N_data,2);
  y = data_020999(1:M:N_data,3)/100; # convert from cm to m

  gset grid
  gset title ""
  gset xlabel "Time (sec)"
  tu = [t u];
  ty = [t y];
  gplot tu title "input (V)", ty title "output (m)"
  psfig("sDriveCart_yu");


  y_s = [u y];			# u is first o/p of system.
  ## Start time at zero
  t = t-t(1)*ones(size(t));
  
  T_last = 40;
  DT = t(2)-t(1);

  tu = [t u u u u];		# Put same signal on all inputs (only
				# first used
  save -ascii junk.dat tu
  ## zap the octave comments
  system(sprintf("grep -v \'#\' junk.dat > %s; rm -f junk.dat", input_name));

  ## Set up theta
  control = [1 0 0 0];		# Initial control parameters
  unused = 0;			# Unused parameter slot
  r_c = 0;
  parameters = [r_c m_c unused unused unused];
  i_r = 4+1;
  i_m = 4+2;
  state = [0 unused unused 0 0];
  i_v = 4+5+4;
  i_x = 4+5+5;
  i_i = 4+5+1;
  theta_0 = [control parameters state]';

  ## Weighting function - select output, not input
  weight = ones(size(t))*[0 1];

  ## Estimate r only
  free = [i_r i_i i_v i_x];
  disp("Estimate cart friction ...");
  [theta,Theta,Error,Y] = mtt_optimise(system_name,y_s,theta_0,"time",\
				       free,weight,crite,max,alpha,View);

  ## Plot results
#   ix = [its Theta(i_x,:)'];
#   iv = [its Theta(i_v,:)'];
#   ii = [its Theta(i_i,:)'];

#   gplot \
#       ix with linespoints title "x_0",\
#       iv with linespoints title "p_0",\
#       ii with linespoints title "i_0"

#   psfig("sDriveCart_ident_x");

  [N_th,M_th] = size(Theta);
  its = [0:M_th-1]';
  gset grid
  gset title ""
  gset xlabel "Iterations"
  ir = [its Theta(i_r,:)'];
  gplot ir with linespoints title "r"
  psfig("sDriveCart_ident_r");

  r_c = theta(i_r)

endfunction

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDriveCart_numpar.txt version [1efc3b6766].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200








































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sInvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Wed Aug 25 22:57:05 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1999/12/03 00:50:28  peterg
# %% Initial revision
# %%
# %% Revision 1.1  1999/11/12 06:47:50  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Same as sInvertedpendulumOnCart with pendulum stuff removed.

# Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	5.0;			# Cart friction

# l_p =   0.61;			# Pendulum length
# m_p =   0.210;			# Pendulum mass
# r_p = 	0.0;			# Pendulum friction
# j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

# g = +9.81;			# Gravity

# m_t = 0.0; # Tip mass

## Sensitivity parameters
m_cs = 0;			# Cart mass
b_ms = 0;			# Motor friction 
r_cs = 0;			# Cart friction

# j_ps = 0;			# Pendulum inertia
# m_ps = 0;			# Pendulum mass
# r_ps = 0;			# Pendulum friction

# m_ts = 0;			# Tip mass

## Initial states
i_0 = 0;			# Initial armature current
# omega_0 = 0;			# Initial pendulum velocity
# theta_0 = 0;			# Initial pendulum angle
v_0 = 0;			# Initial cart velocity
x_0 = 0;			# Initial cart position

## Sensitivity parameters
i_0s = 0;			# Initial armature current
# omega_0s = 0;			# Initial pendulum velocity
# theta_0s = 0;			# Initial pendulum angle
v_0s = 0;			# Initial cart velocity
x_0s = 0;			# Initial cart position

## Control parameters
k_1 = 1;
k_2 = 0;
k_3 = 0;
k_4 = 0;

## Control sensitivity parameters
k_1s = 0;
k_2s = 0;
k_3s = 0;
k_4s = 0;


## Which sensitivity function? NB all other sens. coeffs MUST be zero -
## see above
if (mtt_n_parameters>=1)
  mtti = mtt_parameters(1);

  if mtti==1
    k_1s = 1;
  endif
  
  if mtti==2
    k_2s = 1;
  endif
  
  if mtti==3
    k_3s = 1;
  endif

  if mtti==4
    k_4s = 1;
  endif

  if mtti==5
    r_cs = 1;
  endif
  
  if mtti==6
    m_cs = 1;
  endif

#   if mtti==7
#     r_ps = 1;
#   endif

#   if mtti==8
#     m_ts = 1;
#   endif

#   if mtti==9
#     j_ps = 1;
#   endif
  
  if mtti==10
    i_0s = 1;			# Initial armature current
  endif
  
#   if mtti==11
#     omega_0s = 1;		# Initial pendulum velocity
#   endif
  
#   if mtti==12
#     theta_0s = 1;		# Initial pendulum position
#   endif
  
  if mtti==13
    v_0s = 1;			# Initial cart velocity
  endif
  
  if mtti==14
    x_0s = 1;			# Initial cart angle
  endif
  
endif;

## Control parameters

if (mtt_n_parameters>=2)
  k_1 = mtt_parameters(2);
endif;

if (mtt_n_parameters>=3)
  k_2 = mtt_parameters(3);
endif;

if (mtt_n_parameters>=4)
  k_3 = mtt_parameters(4);
endif;

if (mtt_n_parameters>=5)
  k_4 = mtt_parameters(5);
endif;

## Physical parameters
if (mtt_n_parameters>=6)
  r_c = mtt_parameters(6);
endif;

if (mtt_n_parameters>=7)
  m_c = mtt_parameters(7);
endif;

# if (mtt_n_parameters>=8)
#   r_p = mtt_parameters(8);
# endif;

# if (mtt_n_parameters>=9)
#   m_t = mtt_parameters(9);
# endif;

# if (mtt_n_parameters>=10)
#   j_p = mtt_parameters(10);
# endif;

## Initial condition parameters - states are read in
if (mtt_n_parameters>=15)	# 
  i_0 = mtt_parameters(11); # Initial armature current
#   omega_0 = mtt_parameters(12); # Initial cart velocity
#   theta_0 = mtt_parameters(13);	# Initial cart position
  v_0 = mtt_parameters(14); # Initial pendulum velocity
  x_0 = mtt_parameters(15); # Initial pendulum angle
endif;

## Simulation stuff

if (mtt_n_parameters>=16)
  LAST = mtt_parameters(16);
endif;
if (mtt_n_parameters>=17)
  DT = mtt_parameters(17);
endif;

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDriveCart_simpar.txt version [66769d1708].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system sDriveCart (sDriveCart_simpar.txt)
# Generated by MTT on Fri Dec 3 10:30:48 EST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 40.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sDrive_lbl.txt version [5a461fb90b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sDrive (sDrive_lbl.txt)
%SUMMARY sDrive
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Electrical_1,Electrical_2
%ALIAS	out	Mechanical_1,Mechanical_2

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type sDCS
	motor

% Component type SS
	[Electrical]	SS		external,external
	[Mechanical]	SS		external,external

% Component type sTF
	k_g		lin	flow,k_g;0
	r		lin	flow,r;0



Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sEMTF_abg.fig version [06c2007d04].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 3555 2295 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 3600 2250 4050
-6
6 2205 7155 2295 7695
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2250 7200 2250 7650
-6
6 3510 4005 4050 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4005 4050 3555 4050
-6
6 3645 5850 4185 5940
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4140 5895 3690 5895
-6
6 8730 5355 9270 5445
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9225 5400 8775 5400
-6
6 3600 7155 4140 7245
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4095 7200 3645 7200
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 7425 3600 7425 3375 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 7425 5400 7425 5175 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 7425 8775 7425 8550 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 7425 10575 7425 10350 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 3825 3600 3825 3375 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 3825 5400 3825 5175 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7425 3825 8775 3825 8550 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9225 3825 10575 3825 10350 4050
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5895 9000 7200 9000 6975
2 1 0 2 -1 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9006 5873 3831 7178 3831 6953
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 450 6300 1800 6525 1575
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2250 6300 3600 6525 3375
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 1800 6525 1800
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 2025 4275 2025 4275 5400 4500 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 3825 5400 4050 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 9000 4050 9000 5400 9225 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 2250 6525 7200 6750 6975
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 2025 8550 2025 8550 5400 8775 5175
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6525 8550 9225 8550 9225 5850 9450 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 4
	 6075 8550 3600 8550 3600 5850 3375 6075
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 10125 6300 8775 6525 9000
2 1 0 2 5 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6075 8775 6525 8775
4 1 4 100 0 18 20 0.0000 4 285 2415 6210 360 SS:[Actual_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6300 2115 0\001
4 1 4 100 0 18 20 0.0000 4 285 1845 1215 7515 SS:[Sens_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 7515 1\001
4 1 0 100 0 18 20 0.0000 4 225 1590 6435 7515 EMTF:sens\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 7515 0\001
4 1 4 100 0 18 20 0.0000 4 285 2040 11790 7515 SS:[Sens_out]\001
4 1 4 100 0 18 20 0.0000 4 285 2055 1215 3915 SS:[Actual_in]\001
4 1 0 100 0 18 20 0.0000 4 210 165 3825 3915 1\001
4 1 0 100 0 18 20 0.0000 4 225 1785 6435 3915 EMTF:actual\001
4 1 0 100 0 18 20 0.0000 4 210 165 9000 3915 0\001
4 1 4 100 0 18 20 0.0000 4 285 2250 11790 3915 SS:[Actual_out]\001
4 1 0 100 0 18 20 0.0000 4 225 1170 8955 5715 AE3:ae3\001
4 1 0 100 0 18 20 0.0000 4 225 1095 3825 5715 AF3:af3\001
4 2 4 100 0 18 14 0.0000 4 210 600 6255 3600 [mod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 6435 7155 [mod]\001
4 1 4 100 0 18 20 0.0000 4 285 2205 6300 10395 SS:[Sens_mod]\001
4 1 5 100 0 18 20 0.0000 4 210 165 6345 8640 0\001
4 2 4 100 0 18 14 0.0000 4 210 720 3420 5985 [smod]\001
4 0 4 100 0 18 14 0.0000 4 210 720 9540 5940 [smod]\001
4 2 4 100 0 18 14 0.0000 4 210 600 8505 5355 [mod]\001
4 0 4 100 0 18 14 0.0000 4 210 600 4455 5400 [mod]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sEMTF_lbl.txt version [740377120d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sEMTF (sEMTF_lbl.txt)
%SUMMARY sEMTF Effort modulated TF - sensitivity version
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Actual_in,Sens_in
%ALIAS	out	Actual_out,Sens_out
%ALIAS	mod	Actual_mod,Sens_mod


% Argument aliases
%ALIAS	$1	l

% CR aliases
%ALIAS	$1	lsin
%ALIAS	$2	slsin

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type EMTF
	actual		lsin	flow,l
	sens		lsin	flow,l

% Component type AE3 (????NB NEGATIVE GAIN HERE!!!!)
	ae3             slsin   l

% Component type AF3
	af3             slsin   l

% Component type SS
	[Actual_in]	SS		external,external
	[Actual_out]	SS		external,external
	[Actual_mod]	SS		external,internal
	[Sens_in]	SS		external,external
	[Sens_out]	SS		external,external
	[Sens_mod]	SS		external,internal



Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sINTFS_abg.fig version [3690b29bfb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3376 3151 4276 3151 4051 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2926 4501 2026 4726 2251
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3151 5626 3151 5401 3376
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 10575 4950 45 4950 45 1350 10575 1350 10575 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3150 2475 3150 2250 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6526 3150 7426 3150 7201 3375
4 1 6 0 0 0 20 0.0000 4 256 181 4502 3242 [1,2]\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4502 3241 0\001
4 1 -1 0 0 0 20 0.0000 4 255 1110 4501 1891 sCS:unit\001
4 2 6 0 0 0 20 0.0000 4 316 1456 1531 3241 [1,2]\001
4 2 4 0 0 0 20 0.0000 4 315 1455 1531 3240 SS:[Flow]\001
4 1 -1 0 0 0 20 0.0000 4 255 825 2925 3240 sAF:af\001
4 1 -1 0 0 0 20 0.0000 4 255 900 6075 3240 sAE:ae\001
4 0 6 0 0 0 20 0.0000 4 331 3046 7471 3241 [1,2]\001
4 0 4 0 0 0 20 0.0000 4 330 3045 7471 3240 SS:[Integrated_flow]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sINTFS_lbl.txt version [04b43b7e2f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sINTFS (sINTFS_lbl.txt)
%SUMMARY	sINTFS: flow integrator
%DESCRIPTION	Port [in]:	Flow to be integrated
%DESCRIPTION	Port [out]:	Effort = integral of flow on port [in]


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/07/16 07:35:10  peterg
% %% Aliased version
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	Flow_1,Flow_2
%ALIAS	out	Integrated_flow_1,Integrated_flow_2

% Argument aliases
%ALIAS	$1 x_0	
%ALIAS	$2 x_0s	

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% CS
	unit			SS		effort,1;x_0;0;x_0s

% Component type AE
	ae			lin		1;0

% Component type AF
	af			lin		1;0


% Component type SS
	[Flow]			SS		external,external
	[Integrated_flow]	SS		external,external

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sIS_abg.fig version [917d2513e9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2340 3915 2610 4185
4 1 6 100 0 18 20 0.0000 4 271 196 2476 4186 [1,2]\001
4 1 0 100 0 18 20 0.0000 4 270 195 2476 4185 0\001
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3825 2475 2475 2700 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 5625 2475 4275 2700 4500
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 4050 4050 4050 3825 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 3825 4050 4275
4 1 0 100 0 18 20 0.0000 4 285 315 2475 2295 sI:i\001
4 0 0 100 0 18 20 0.0000 4 360 1035 4185 4185 sSf:f_0\001
4 1 6 100 0 18 20 0.0000 4 361 1186 2476 6031 [1,2]\001
4 1 4 100 0 18 20 0.0000 4 360 1185 2476 6030 SS:[in]\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sIS_lbl.txt version [9a121bfbfe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sIS (sIS_lbl.txt)
%SUMMARY sIS
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Port aliases
%ALIAS	in	in_1,in_2

% Argument aliases
%ALIAS	$1	flow,i
%ALIAS	$2	f_0
%ALIAS	$3	i_s
%ALIAS	$4	f_0s

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[in]	SS		external,external

% Component type sI
	i       lin             flow,i;i_s

% Component type sSf
	f_0     SS	        f_0;f_0s

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCartPPP_numpar.txt version [7f13064103].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sInvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Tue Apr 18 18:07:52 BST 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Default parameters
b_m = 	0.0; # sDCS
b_ms = 	0.0; # sDCS
c = 	0.0; # sC,sC,sCS,sCS
c_s = 	0.0; # sCS,sCS
e_0 = 	0.0; # sCS,sCS
e_0s = 	0.0; # sCS,sCS
e_s = 	0.0; # Se,Se,Se,sSe,sSe,sSe
f_0 = 	0.0; # sIS,sIS,sIS
f_0s = 	0.0; # sIS,sIS,sIS
f_s = 	0.0; # Sf,Sf,Sf,sSf,sSf,sSf
g = 	0.0; # AFe,AFe,sInvertedPendulum,sROD
i = 	0.0; # sI,sI,sI,sI,sI,sI,sIS,sIS,sIS
i_0 = 	0.0; # sDCS
i_0s = 	0.0; # sDCS
i_s = 	0.0; # sIS,sIS,sIS
j_m = 	0.0; # sDCS,sROD
j_p = 	0.0; # sInvertedPendulum
j_ps = 	0.0; # sInvertedPendulum
j_s = 	0.0; # sROD
k = 	0.0; # sAE,sAE,sAE,sAF,sAF,sGY,sTF
ppp_1 = 	1.0; # sOpenLoop
ppp_1s = 	0.0; # sOpenLoop
ppp_2 = 	0.0; # sOpenLoop
ppp_2s = 	0.0; # sOpenLoop
ppp_3 = 	0.0; # sOpenLoop
ppp_3s = 	0.0; # sOpenLoop
ppp_4 = 	0.0; # sOpenLoop
ppp_4s = 	0.0; # sOpenLoop
k_g = 	0.0; # sDrive
k_m = 	0.0; # sDCS
k_s = 	0.0; # sAE,sAE,sAE,sAF,sAF,sC,sC,sGY,sI,sI,sI,sI,sI,sI,sR,sR,sSe,sSe,sSe,sSf,sSf,sSf,sTF
l = 	0.0; # AE3,AF3,sEMTF
l_a = 	0.0; # sDCS,sROD
l_b = 	0.0; # sROD
l_p = 	0.0; # sInvertedPendulum,sInvertedPendulumOnCart
m = 	0.0; # sROD
m_c = 	0.0; # sCart
m_cs = 	0.0; # sCart
m_p = 	0.0; # sInvertedPendulum
m_ps = 	0.0; # sInvertedPendulum
m_s = 	0.0; # sROD
m_t = 	0.0; # sInvertedPendulum
m_ts = 	0.0; # sInvertedPendulum
omega_0 = 	0.0; # sInvertedPendulum,sROD
omega_0s = 	0.0; # sInvertedPendulum,sROD
r = 	0.0; # sDrive,sR,sR
r_a = 	0.0; # sDCS
r_c = 	0.0; # sCart
r_cs = 	0.0; # sCart
r_p = 	0.0; # sCart
r_ps = 	0.0; # sCart
theta_0 = 	0.0; # sInvertedPendulum,sROD
theta_0s = 	0.0; # sInvertedPendulum,sROD
v_0 = 	0.0; # sCart
v_0s = 	0.0; # sCart
x_0 = 	0.0; # sCart,sINTFS,sINTFS
x_0s = 	0.0; # sCart,sINTFS,sINTFS


## Pysical Parameters
j_m = 	3.87e-7;		# Motor inertia
k_m = 	0.00767;		# Motor constant
r_a = 	2.6;			# Armature resistance
l_a = 	0.18e-3;		# Armature inductance

k_g = 	1/3.7;			# Internal gear ratio 
r = 	0.635e-2;		# Motor gear radius

m_c = 	0.455;			# Cart mass

b_m = 	0.0;			# Motor friction
r_c = 	1.5;			# Cart friction

l_p =   0.61;			# Pendulum length
m_p =   0.210;			# Pendulum mass
r_p = 	0.0;			# Pendulum friction

j_p = m_p*(l_p*l_p)/12;		# Pendulum inertia about cm.

g = 9.81;			# Gravity

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCartPPP_state.txt version [3b214e7bb5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (sInvertedPendulumOnCartPPP_state.txt)
# Generated by MTT at Thu May  4 14:57:10 BST 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the states
mttx(1) 	= 0.0; 	# i_1 (sInvertedPendulumOnCartPPP_mtt2_motor_l_a_i)
mttx(2) 	= 0.0; 	# i_2 (sInvertedPendulumOnCartPPP_mtt2_motor_l_a_i)
mttx(3) 	= 0.0; 	# i_1 (sInvertedPendulumOnCartPPP_mtt3_rod_J_i)
mttx(4) 	= 0.0; 	# i_2 (sInvertedPendulumOnCartPPP_mtt3_rod_J_i)
mttx(5) 	= pi/2; 	# c_1 (sInvertedPendulumOnCartPPP_mtt3_rod_th_unit_c)
mttx(6) 	= 0.0; 	# c_2 (sInvertedPendulumOnCartPPP_mtt3_rod_th_unit_c)
mttx(7) 	= 0.0; 	# i_1 (sInvertedPendulumOnCartPPP_mtt4_m_c_i)
mttx(8) 	= 0.0; 	# i_2 (sInvertedPendulumOnCartPPP_mtt4_m_c_i)
mttx(9) 	= 0.0; 	# c_1 (sInvertedPendulumOnCartPPP_mtt4_x_unit_c)
mttx(10) 	= 0.0; 	# c_2 (sInvertedPendulumOnCartPPP_mtt4_x_unit_c)

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_input.txt version [c3ea90775c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (sInvertedPendulumOnCart_input.txt)
# Generated by MTT at Thu Aug  5 09:17:30 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
# mttu(1) = 1.0*(t<1) -1.0*((t>=1)&&(t<2)); 	# u (sInvertedPendulumOnCart_F)

  ## Doing control
#   if (mtt_n_parameters>=1)	
#     if (mtt_parameters(1)<5)
      mttu(1) = exp(-0.0*t);
      mttu(2) = exp(-2.0*t);
      mttu(3) = exp(-5.0*t);
      mttu(4) = exp(-10.0*t);

#       mttu(1) = 1;
#       mttu(2) = exp(-0.5*t);;
#       mttu(3) = exp(-t);
#       mttu(4) = exp(-2*t);

#       mttu(1) = (t<0.1);
#       mttu(2) = ((t>=0.1)&&(t<0.2));
#       mttu(3) = ((t>=0.2)&&(t<0.3));
#       mttu(4) = ((t>=0.3)&&(t<0.4));
#     else			
#       ## Identification 
#       mttu(1) = (-1*((t>=3.37966)&&(t<= 5.36946)) + ((t>=10.36896)&&(t<=12.36876))); 
#     endif
#   endif


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_lbl.txt version [6c0ec1a387].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sInvertedPendulumOnCart (sInvertedPendulumOnCart_lbl.txt)
%SUMMARY sInvertedPendulumOnCart
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR l_p		#Pendulum length

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_rep.txt version [d081dbadd3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sInvertedPendulumOnCart (sInvertedPendulumOnCart_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:29:10  peterg
## To RCS
##
###############################################################

mtt sInvertedPendulumOnCart abg tex			# The system description
mtt sInvertedPendulumOnCart cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt sInvertedPendulumOnCart struc tex	        # The system structure
mtt sInvertedPendulumOnCart dae tex	        # The system dae
## mtt sInvertedPendulumOnCart ode tex	        # The system ode 
## mtt sInvertedPendulumOnCart sspar tex		# Steady-state parameters
## mtt sInvertedPendulumOnCart ss tex 		# Steady state
## mtt sInvertedPendulumOnCart dm tex		# Descriptor matrices (of linearised system)
mtt sInvertedPendulumOnCart sm tex		# State matrices (of linearised system)
## mtt sInvertedPendulumOnCart tf tex		# Transfer function (of linearised system)
## mtt sInvertedPendulumOnCart lmfr ps		# log modulus of frequency response (of linearised system)
mtt sInvertedPendulumOnCart simpar tex		# Simulation parameters
mtt sInvertedPendulumOnCart numpar tex		# Numerical simulation parameters
mtt sInvertedPendulumOnCart input tex		# Simulation input
mtt -cse sInvertedPendulumOnCart odeso ps		# Simulation output

mtt sInvertedPendulumOnCart ppp ps		# PPP control

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulumOnCart_simpar.txt version [2fbcb7b3c6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system sInvertedPendulumOnCart (sInvertedPendulumOnCart_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;      # Last time in simulation
DT          = 0.05;		# Print interval
STEPFACTOR  = 1;		# Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sInvertedPendulum_lbl.txt version [19c18e9e54].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sInvertedPendulum (sInvertedPendulum_lbl.txt)
%SUMMARY sInvertedPendulum
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x_1,x_2,y_1,y_2,a_1,a_2


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
        m_x     lin             flow,m_t;m_ts
        m_y     lin             flow,m_t;m_ts

% Component type Se
	mg			SS		m_t*g;0

% Component type De
	theta			SS	external;external



% Component type SS
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	a_0	 SS	0;0

% Component type ROD
	rod	 none		l_p;l_p;j_p;m_p;g;omega_0;theta_0;j_ps;m_ps;omega_0s;theta_0s
 

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sOpenLoop_lbl.txt version [6832b95589].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sOpenLoop (sOpenLoop_lbl.txt)
%SUMMARY sOpenLoop
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	us_1,us_2

% Argument aliases
%ALIAS	$1	U_1
%ALIAS	$2	U_1s
%ALIAS	$3	U_2
%ALIAS	$4	U_2s
%ALIAS	$5	U_3
%ALIAS	$6	U_3s
%ALIAS	$7	U_4
%ALIAS	$8	U_4s
%ALIAS	$9	us
%ALIAS	$10	uss
%ALIAS	$11	Us_1
%ALIAS	$12	Us_1s
%ALIAS	$13	Us_2
%ALIAS	$14	Us_2s
%ALIAS	$15	Us_3
%ALIAS	$16	Us_3s
%ALIAS	$17	Us_4
%ALIAS	$18	Us_4s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	[us]	SS		external,external

% Component type AE
	U_1	lin		ppp_1;ppp_1s
	U_2	lin		ppp_2;ppp_2s
	U_3	lin		ppp_3;ppp_3s
	U_4	lin		ppp_4;ppp_4s

% Component type Se
	Us_1	SS		external;0
	Us_2	SS		external;0
	Us_3	SS		external;0
	Us_4	SS		external;0

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sROD_lbl.txt version [710dd08bb5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	sROD: rigid rod in two dimensions - with gravity and angle port
%DESCRIPTION	See Section 10.2 of "Metamodelling"
%DESCRIPTION	Gravity term added at centre

%ALIAS $1	l_a	# length from end a to mass centre
%ALIAS $2	l_b	# length from end b to mass centre
%ALIAS $3	j_m	# inertia about mass centre
%ALIAS $4	m	# mass
%ALIAS $5	g	# gravity

%ALIAS $6	omega_0 # Initial angular velocity 
%ALIAS $7	theta_0 # Initial angular velocity 

## Sensitivities
%ALIAS $8	j_s 
%ALIAS $9	m_s 

%ALIAS $10	omega_0s # Initial angular velocity 
%ALIAS $11	theta_0s # Initial angular velocity 


%ALIAS in|Tip_a		xTip_a_1,xTip_a_2,angularTip_a_1,angularTip_a_2,yTip_a_1,yTip_a_2 	
%ALIAS out|Tip_b	xTip_b_1,xTip_b_2,angularTip_b_1,angularTip_b_2,yTip_b_1,yTip_b_2 	

%ALIAS x_a		xTip_a_1,xTip_a_2 # Force/velocity at tip a in x direction
%ALIAS y_a		yTip_a_1,yTip_a_2 # Force/velocity at tip a in y direction
%ALIAS alpha_a|a_a	angularTip_a_1,angularTip_a_2 # Torque/angular velocity at tip a

%ALIAS x_b		xTip_b_1,xTip_b_2 # Force/velocity at tip b in x direction
%ALIAS y_b		yTip_b_1,yTip_b_2 # Force/velocity at tip b in y direction
%ALIAS alpha_b|a_b	angularTip_b_1,angularTip_b_2 # Torque/angular velocity at tip b

%ALIAS angle|a		angle_1,angle_2	# Angle port

%ALIAS INTF	General/INTF # The flow integration component.

%% Label file for system sROD (sROD_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/10/22 02:01:45  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/08/05 08:04:40  peterg
% %% Initial revision
% %%
% %% Revision 1.3  1998/11/30 10:47:53  peterg
% %% Added extra a_a and a_b aliases
% %%
% %% Revision 1.2  1998/11/25 13:55:42  peterg
% %% Added missig attribute field m*g,internal
% %%
% %% Revision 1.1  1998/11/25 10:48:34  peterg
% %% Initial revision
% %%
% %% Revision 1.5  1998/07/27 12:27:27  peterg
% %% Added vector port aliases
% %%
% %% Revision 1.4  1998/07/27 10:51:20  peterg
% %% Aliased INTF as well.
% %%
% %% Revision 1.3  1998/07/27 10:49:10  peterg
% %% Major revision to include aliases etc
% %%
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,j_m;omega_0;j_s;omega_0s
m_x	lin	flow,m;m_s
m_y	lin	flow,m;m_s

%Integrate angular velocity to get angle
th	   none	   theta_0;theta_0s

%Modulated transformers
s1	lsin;slsin	l_a
s2	lsin;slsin	l_b
c1	lcos;slcos	l_a
c2	lcos;slcos	l_b


% Component type Se
	mg			SS		m*g;0

% Component type SS
	[angularTip_a]		SS		external,external
	[angularTip_b]		SS		external,external
	[xTip_a]		SS		external,external
	[xTip_b]		SS		external,external
	[yTip_a]		SS		external,external
	[yTip_b]		SS		external,external
	[angle]			SS		external,external

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/InvertedPendulumOnCartPPP/sZero_lbl.txt version [c03b79280f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sZero (sZero_lbl.txt)
%SUMMARY sZero
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	x_1,x_2,y_1,y_2,a_1,a_2


%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	x	SS		0;0
	y	SS		0;0

% Component type Sf
	a	SS		0;0

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_abg.fig version [bb4e1ded8d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
6 8550 825 13500 3375
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 1725 11695 1725 11845 1875
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 1350 11695 1350 11845 1500
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 975 11695 975 11845 1125
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 2100 11695 2100 11845 2250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 2475 11695 2475 11845 2625
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 2850 11695 2850 11845 3000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12595 3225 11695 3225 11845 3375
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 10200 2100 9300 2100 9450 2250
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 975 8700 975 8700 1875 8550 1725
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 1275 9000 1275 9000 1875 8850 1725
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 1725 9300 1725 9300 1875 9150 1725
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 3225 8700 3225 8700 2325 8550 2475
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 2925 9000 2925 9000 2325 8850 2475
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 10200 2475 9300 2475 9300 2325 9150 2475
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 2175 AE:ppp_4\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 1800 Se:u_3\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 1800 AE:ppp_3\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 1425 Se:u_2\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 1425 AE:ppp_2\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 1050 Se:u_1\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 1050 AE:ppp_1\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 2550 AE:ppp_5\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 2925 AE:ppp_6\001
4 1 -1 0 0 0 20 0.0000 4 285 1230 10950 3300 AE:ppp_7\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 2550 Se:u_5\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 2925 Se:u_6\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 3300 Se:u_7\001
4 1 -1 0 0 0 20 0.0000 4 285 810 13050 2175 Se:u_4\001
4 1 -1 0 0 0 20 0.0000 4 210 150 9000 2175 1\001
-6
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2706 7206 3606 7206 3456 7356
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2406 7506 2406 8406 2556 8256
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3906 7506 3906 8406 4056 8256
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 7208 8108 7208 7958 7358
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 7208 9608 7208 9458 7358
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8408 7508 8408 8408 8558 8258
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 6908 8108 6008 8108 6233
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 6008 9608 6908 9383 6908
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9909 7509 9909 8409 10059 8259
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6908 7508 6908 8408 7058 8258
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11407 7507 11407 8407 11557 8257
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11406 5706 11406 4806 11556 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 7206 5106 7206 4956 7356
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5406 7506 5406 8406 5556 8256
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 6906 5106 6006 5106 6231
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 5705 5405 4805 5555 4955
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2405 5705 2405 4805 2555 4955
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 7207 12607 7207 12457 7357
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 6007 12607 6907 12382 6907
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2105 4205 2105 3305 2255 3455
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2705 4205 2705 3305 2855 3455
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 7206 6606 7206 6456 7356
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 6006 6606 6906 6381 6906
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2704 6004 3604 6904 3379 6904
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 7208 2108 7208 1958 7358
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 6908 2108 6008 2108 6233
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 681 6006 1131 6006
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 906 6906 906 6006 1056 6156
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12905 6905 12905 6005 13055 6155
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 7207 11107 7207 10957 7357
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 6907 11107 6007 11107 6232
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8400 5700 8625 5700
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12900 6000 13125 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12675 6000 12900 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8175 5700 8400 5700
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 1501 7801 301 7801 301 5401 1501 5401 1501 7801
2 2 1 2 1 7 1 0 -1 6.000 1 0 0 0 0 5
	 1502 2852 3302 2852 3302 5777 1502 5777 1502 2852
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 4501 9001 3301 9001 3301 6301 4501 6301 4501 9001
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 6000 9000 4800 9000 4800 4200 6000 4200 6000 9000
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7501 9001 6301 9001 6301 6301 7501 6301 7501 9001
2 4 1 2 1 7 2 0 -1 6.000 0 0 7 0 0 5
	 9000 9000 7800 9000 7800 4200 9000 4200 9000 9000
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 10501 9001 9301 9001 9301 6301 10501 6301 10501 9001
2 4 1 2 1 -1 1 0 -1 6.000 0 0 7 0 0 5
	 12000 9000 10800 9000 10800 4200 12000 4200 12000 9000
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 13501 7801 12301 7801 12301 5401 13501 5401 13501 7801
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 4
	 8700 2100 8400 2100 8400 5700 8550 5550
2 2 1 2 1 7 101 0 -1 6.000 0 0 -1 0 0 5
	 8100 600 13800 600 13800 3600 8100 3600 8100 600
4 1 -1 0 0 0 20 0.0000 4 210 150 2406 7281 0\001
4 1 -1 0 0 0 20 0.0000 4 285 690 3906 8781 I:m_1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 2405 8780 R:b_1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 2405 6080 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3906 7281 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 8408 7283 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 8408 6083 0\001
4 1 -1 0 0 0 20 0.0000 4 285 705 8483 8783 R:b_3\001
4 1 -1 0 0 0 20 0.0000 4 285 690 9906 8781 I:m_3\001
4 1 -1 0 0 0 20 0.0000 4 285 690 6905 8780 I:m_2\001
4 1 -1 0 0 0 20 0.0000 4 210 150 11407 7282 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 11407 6082 0\001
4 1 -1 0 0 0 20 0.0000 4 285 645 11406 4581 C:k_t\001
4 1 -1 0 0 0 20 0.0000 4 285 645 11482 8782 R:b_t\001
4 1 -1 0 0 0 20 0.0000 4 210 150 5406 7281 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 5406 6081 0\001
4 1 -1 0 0 0 20 0.0000 4 285 705 5481 8781 R:b_2\001
4 1 -1 0 0 0 20 0.0000 4 210 150 12909 7284 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 6908 7283 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 2404 4579 1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 2779 3154 C:p_1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 2104 3154 R:d_1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 910 7285 1\001
4 1 -1 0 0 0 20 0.0000 4 285 765 902 5777 Sf:v_b\001
4 1 -1 0 0 0 20 0.0000 4 285 735 12905 5780 De:f_t\001
4 1 -1 0 0 0 20 0.0000 4 210 150 9909 7284 1\001
4 1 -1 0 0 0 20 0.0000 4 285 705 5405 4580 C:k_2\001
4 1 1 1 0 3 20 0.0000 4 210 1515 3901 9301 Macro mass\001
4 1 1 1 0 3 20 0.0000 4 210 1770 2401 2776 Macro control\001
4 1 1 1 0 3 20 0.0000 4 210 1470 900 8100 Macro base\001
4 1 1 1 0 3 20 0.0000 4 285 1845 5400 4050 Compliant link\001
4 1 1 1 0 3 20 0.0000 4 210 1425 6901 9301 Micro mass\001
4 1 1 1 0 3 20 0.0000 4 210 1860 8475 4050 Micro actuator\001
4 1 1 1 0 3 20 0.0000 4 285 1095 9901 9301 Tip mass\001
4 1 1 1 0 3 20 0.0000 4 285 2940 11400 4050 Compliant environment\001
4 1 1 1 0 3 20 0.0000 4 285 1275 12901 8101 Tip sensor\001
4 1 1 1 0 3 20 0.0000 4 285 2370 6750 1275 Open-loop control\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_desc.tex version [4de8b8a9c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system MacroMicroPPP (MacroMicroPPP_desc.tex)
% Generated by MTT on Tue Dec 9 17:55:41 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/21 16:10:07  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MacroMicroPPP} is
   displayed in Figure \Ref{MacroMicroPPP_abg} and its label
   file is listed in Section \Ref{sec:MacroMicroPPP_lbl}.
   The subsystems are listed in Section \Ref{sec:MacroMicroPPP_sub}.

This is a Bond Graph model of the macro-micro manipulation system
discussed by Sharon in his thesis and BY Sharon, Hogan and Hardt in
various papers.

It can be regarded as a single-input single-output system with input
$e_1$ and output $e_2$.  The bond graph in Figure \Ref{rcPPP_abg} is
augmented with the {\em open-loop\/} controller comprising
\begin{itemize}
\item seven effort source \textbf{Se} components ``u1'' to``u7''
\item seven effort amplifier \textbf{AE} components ``ppp\_1'' to `ppp\_7''
\end{itemize}
This allows up to 7 input basis functions.

This is a \emph{linear} system; but it is used to illustate
\emph{nonlinear} PPP control. 
Section \Ref{sec:rcPPP_nppp.ps} compares
\begin{itemize}
\item linear open-loop PPP control
\item linear closed-loop PPP control
\item nonlinear PPP control
\end{itemize}
as linear open and closed-loop control.

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_lbl.txt version [1618b01e61].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system MacroMicroPPP (MacroMicroPPP_lbl.txt)
%SUMMARY MacroMicroPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/21 16:05:48  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_2
%ALIAS	$3	ppp_3
%ALIAS	$4	ppp_4
%ALIAS	$5	k_2
%ALIAS	$6	k_t
%ALIAS	$7	p_1
%ALIAS	$8	f_t
%ALIAS	$9	m_1
%ALIAS	$10	m_2
%ALIAS	$11	m_3
%ALIAS	$12	b_1
%ALIAS	$13	b_2
%ALIAS	$14	b_3
%ALIAS	$15	b_t
%ALIAS	$16	d_1
%ALIAS	$17	u_1
%ALIAS	$18	u_2
%ALIAS	$19	u_3
%ALIAS	$20	u_4
%ALIAS	$21	v_b

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	ppp_1	lin		ppp_1
	ppp_2	lin		ppp_2
	ppp_3	lin		ppp_3
	ppp_4	lin		ppp_4
	ppp_5	lin		ppp_5
	ppp_6	lin		ppp_6
	ppp_7	lin		ppp_7

% Component type C
	k_2	lin		state,k_2
	k_t	lin		state,k_t
	p_1	lin		state,p_1

% Component type De
	f_t	SS		external

% Component type I
	m_1	lin		flow,m_1
	m_2	lin		flow,m_2
	m_3	lin		flow,m_3

% Component type R
	b_1	lin		flow,b_1
	b_2	lin		flow,b_2
	b_3	lin		flow,b_3
	b_t	lin		flow,b_t
	d_1	lin		flow,d_1

% Component type Se
	u_1	SS		external
	u_2	SS		external
	u_3	SS		external
	u_4	SS		external
	u_5	SS		external
	u_6	SS		external
	u_7	SS		external

% Component type Sf
	v_b	SS		0

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_nppp.m version [cfbc4c4ad7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154


























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## MacroMicroPPP_nppp.m
## Makes figures for the MacroMicro_PPP exasmple.
## $Log$
## Revision 1.4  2000/05/21 16:11:53  peterg
## 7 basis funs.
##
## Revision 1.3  2000/05/21 15:59:34  peterg
## Made into _nppp.m file
## Parameterised _sm
##
## Revision 1.2  2000/05/17 17:01:39  peterg
## Modified for Macro Micro example -- works!!
##
## Revision 1.1  2000/05/17 10:03:04  peterg
## Initial revision
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "MacroMicroPPP";

## Uncomment the following the first time
## (Or do ./Make MacroMicroPPP in this directory)

## MTT stuff for the system simulation
##system("Make MacroMicroPPP");



t_s=0.1*[0:0.01:1];
u = [ones(7,length(t_s))];
x_0 = MacroMicroPPP_state;
par  = MacroMicroPPP_numpar;

## Simulate the system
tick=time;
[y] = MacroMicroPPP_sim(x_0,u,t_s,par);
Elapsed = time-tick
plot(t_s,y)

## Simulate the system to give just the final few point
t_s1 = 0.1*[0.91:0.01:1];
tick=time;
[y,x] = MacroMicroPPP_sim(x_0,u,t_s1,par);
Elapsed = time-tick
plot(t_s1,y,t_s1,x);

## Sensitivity system simulation parameters
x_0s = sMacroMicroPPP_state;
pars  = sMacroMicroPPP_numpar;
sympars  = sMacroMicroPPP_sympar;

## Simulate the sensitivity system
sensitivities = \
    [sympars.ppp_1s,\
     sympars.ppp_2s,\
     sympars.ppp_3s,\
     sympars.ppp_4s,\
     sympars.ppp_5s,\
     sympars.ppp_6s,\
     sympars.ppp_7s]
tick=time;
[y,ys] = sMacroMicroPPP_sim(x_0s,u,t_s,pars,sensitivities);
Elapsed = time-tick
plot(t_s,y,t_s,ys);


### PPP parameters
A_w = 0;
A_u = ppp_aug(A_w,laguerre_matrix(6,25)); # Specify basis functions

tau = 0.5*[0.9:0.01:1];         # Optimisation interval
t_ol = 0.5*[0:0.01:0.1];	# Open-loop interval
N = 10;                          # Number of open-loop intervals in simulation
w = 1;                          # Setpoint

## Linear system
[A,B,C,D] = MacroMicroPPP_sm(par);
Q = 1;
w = 1;
ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau,Q,w,x_0);
psfig("MacroMicroPPP_lin");

## Simulate non-linear PPP (on this linear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-8;
extras.max_iterations = 10;
extras.v = 0.1;
extras.verbose = 0;

##  -- with no optimisation using linear PPP with continuation
extras.U_initial = "linear";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 0;

[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with no optimisation using linear PPP at each step
extras.U_initial = "linear";
extras.U_next = "linear";
extras.criterion = 1e-5;
extras.max_iterations = 0;
[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with optimisation using nonlinear PPP with continuation
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations=100;
extras.verbose = 0;
extras.v = 1e-5;
disp("Non-linear optimisation ....");
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);


## Plots
title("");

## U, U_c and U_l
I = 1:N;
IU1 = [I' U(1,:)'];
IU1_c = [I' U_c(1,:)'];
IU1_l = [I' U_l(1,:)'];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("MacroMicroPPP_U1");

IU2 = [I' U(2,:)'];
IU2_c = [I' U_c(2,:)'];
IU2_l = [I' U_l(2,:)'];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("MacroMicroPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
ty = [t' y'] ; tu =  [t' u']; 
gplot ty title "Output", tu title "Input"

psfig("MacroMicroPPP_yu");

title("");
gset grid; xlabel "Time (sec)"
ty_c = [t' y_c'] ; 
ty_l = [t' y_l'] ; 
ty = [t' y'] ; 
tu =  [t' u']; 
gplot ty_c title "Continuation", ty_l title "Linear", ty title "Optimisation"
psfig("MacroMicroPPP_nppp");



Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_numpar.txt version [7601b7d25d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Dummies
b_1 = 0.0;
b_2 = 0.0;
b_3 = 0.0;
b_t = 0.0;
d_1 = 0.0;
e_s = 0.0;
f_s = 0.0;
k_2 = 0.0;
k_t = 0.0;
m_1 = 0.0;
m_2 = 0.0;
m_3 = 0.0;
p_1 = 0.0;
ppp_1 = 0.0;
ppp_2 = 0.0;
ppp_3 = 0.0;
ppp_4 = 0.0;
ppp_5 = 0.0;
ppp_6 = 0.0;
ppp_7 = 0.0;

m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;


ppp_1 = 1.0;

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/MacroMicroPPP_rep.txt version [24152c31ed].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system MacroMicroPPP (MacroMicroPPP_rep.txt)
## Generated by MTT on" Wed May 10 09:22:52 BST 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/05/20 17:44:47  peterg
## Initial revision
##
###############################################################

mtt MacroMicroPPP abg tex		# The system description
#mtt -s sMacroMicroPPP abg tex		# The system description

mtt MacroMicroPPP struc tex	        # The system structure
mtt -s sMacroMicroPPP struc tex	        # The system structure

mtt MacroMicroPPP nppp m		# How its done
mtt MacroMicroPPP nppp ps	        # PPP output

mtt MacroMicroPPP rep txt	        # The report.

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/Make version [e246f48d9d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Makes the files needed for Figures.m
## Copyright (C) 2000 by Peter J. Gawthrop

if [ -z "$1" ]; then
    echo Usage ./Make system_name
    exit
else
    echo "Making simulation for system $1 (for use in Figures.m)"
fi

## System
mtt -q -c -stdin $1 ode2odes out
mtt -q -c -stdin $1 sim m
mtt -q  $1 state m
mtt -q  $1 sympar m
mtt -q  $1 numpar m

## Sensitivity system
mtt -q -c -stdin -s s$1 ode2odes out
mtt -q -c -stdin -s s$1 sim m
mtt -q  -s s$1 state m
mtt -q  -s s$1 sympar m
mtt -q  -s s$1 numpar m

## Additional system reps for PPP
mtt -q  $1 sm m
mtt -q  $1 def m
mtt -q  -s s$1 def m

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/sMacroMicroPPP_lbl.txt version [510a291607].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sMacroMicroPPP (sMacroMicroPPP_lbl.txt)
%SUMMARY sMacroMicroPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_1s
%ALIAS	$3	ppp_2
%ALIAS	$4	ppp_2s
%ALIAS	$5	ppp_3
%ALIAS	$6	ppp_3s
%ALIAS	$7	ppp_4
%ALIAS	$8	ppp_4s
%ALIAS	$9	k_2
%ALIAS	$10	k_2s
%ALIAS	$11	k_t
%ALIAS	$12	k_ts
%ALIAS	$13	p_1
%ALIAS	$14	p_1s
%ALIAS	$15	f_t
%ALIAS	$16	f_ts
%ALIAS	$17	m_1
%ALIAS	$18	m_1s
%ALIAS	$19	m_2
%ALIAS	$20	m_2s
%ALIAS	$21	m_3
%ALIAS	$22	m_3s
%ALIAS	$23	b_1
%ALIAS	$24	b_1s
%ALIAS	$25	b_2
%ALIAS	$26	b_2s
%ALIAS	$27	b_3
%ALIAS	$28	b_3s
%ALIAS	$29	b_t
%ALIAS	$30	b_ts
%ALIAS	$31	d_1
%ALIAS	$32	d_1s
%ALIAS	$33	u_1
%ALIAS	$34	u_1s
%ALIAS	$35	u_2
%ALIAS	$36	u_2s
%ALIAS	$37	u_3
%ALIAS	$38	u_3s
%ALIAS	$39	u_4
%ALIAS	$40	u_4s
%ALIAS	$41	v_b
%ALIAS	$42	v_bs

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	ppp_1	lin		ppp_1;ppp_1s
	ppp_2	lin		ppp_2;ppp_2s
	ppp_3	lin		ppp_3;ppp_3s
	ppp_4	lin		ppp_4;ppp_4s
	ppp_5	lin		ppp_5;ppp_5s
	ppp_6	lin		ppp_6;ppp_6s
	ppp_7	lin		ppp_7;ppp_7s

% Component type C
	k_2	lin		state,k_2;k_2s
	k_t	lin		state,k_t;k_ts
	p_1	lin		state,p_1;p_1s

% Component type De
	f_t	SS		external

% Component type I
	m_1	lin		flow,m_1;m_1s
	m_2	lin		flow,m_2;m_2s
	m_3	lin		flow,m_3;m_3s

% Component type R
	b_1	lin		flow,b_1;b_1s
	b_2	lin		flow,b_2;b_2s
	b_3	lin		flow,b_3;b_3s
	b_t	lin		flow,b_t;b_ts
	d_1	lin		flow,d_1;d_1s

% Component type Se
	u_1	SS		external;u_1s
	u_2	SS		external;u_2s
	u_3	SS		external;u_3s
	u_4	SS		external;u_4s
	u_5	SS		external;u_5s
	u_6	SS		external;u_6s
	u_7	SS		external;u_7s

% Component type Sf
	v_b	SS		0;0

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/MacroMicroPPP/sMacroMicroPPP_numpar.txt version [cc73edbaf8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Dummies
b_1 = 0.0;
b_1s = 0.0;
b_2 = 0.0;
b_2s = 0.0;
b_3 = 0.0;
b_3s = 0.0;
b_t = 0.0;
b_ts = 0.0;
c = 0.0;
d_1 = 0.0;
d_1s = 0.0;
e_s = 0.0;
f_s = 0.0;
g = 0.0;
i = 0.0;
k = 0.0;
k_2 = 0.0;
k_2s = 0.0;
k_s = 0.0;
k_t = 0.0;
k_ts = 0.0;
m_1 = 0.0;
m_1s = 0.0;
m_2 = 0.0;
m_2s = 0.0;
m_3 = 0.0;
m_3s = 0.0;
p_1 = 0.0;
p_1s = 0.0;
ppp_1 = 0.0;
ppp_1s = 0.0;
ppp_2 = 0.0;
ppp_2s = 0.0;
ppp_3 = 0.0;
ppp_3s = 0.0;
ppp_4 = 0.0;
ppp_4s = 0.0;
ppp_5 = 0.0;
ppp_5s = 0.0;
ppp_6 = 0.0;
ppp_6s = 0.0;
ppp_7 = 0.0;
ppp_7s = 0.0;
r = 0.0;
u_1s = 0.0;
u_2s = 0.0;
u_3s = 0.0;
u_4s = 0.0;
u_5s = 0.0;
u_6s = 0.0;
u_7s = 0.0;

## Physical parameters
m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;

## First gain
ppp_1 = 1.0;


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Figures.m version [0d87023b1f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Figures.m
## Makes figures for the rc_PPP exasmple.
## $Log$
## Revision 1.2  2000/05/17 17:02:58  peterg
## Fixed documentation
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "rcPPP";

## Uncomment the following the first time
## (Or do ./Make rcPPP in this directory)

## MTT stuff for the system simulation
##system("Make rcPPP");

# ## System info
par  = rcPPP_numpar;
simpar  = rcPPP_simpar;
x_0 = rcPPP_state(par);

# ## Set up the input
# t = [0:simpar.dt:simpar.last];
# A_w = 0;
# A_u = ppp_aug(A_w,laguerre_matrix(1,2.0)) # Specify basis functions: constant & exp(-t/T)
# u = ppp_ustar(A_u,1,t,0,0);

# ## Simulate the system
# tick=time;
# [y,x] = rcPPP_sim(x_0,par,simpar,u);
# Elapsed = time-tick
# plot(t,y)

## Sensitivity system simulation parameters
simpars  = srcPPP_simpar;
sympars  = srcPPP_sympar;
pars  = srcPPP_numpar;
x_0s = srcPPP_state(pars);

t = [0:simpars.dt:simpars.last];
A_w = 0;
A_u = ppp_aug(A_w,laguerre_matrix(1,2.0)) # Specify basis functions: constant & exp(-t/T)
u = ppp_ustar(A_u,1,t,0,0);


## Setup the indices of the adjustable stuff
i_ppp = [sympars.ppp_1, sympars.ppp_1s
	 sympars.ppp_2, sympars.ppp_2s]; # PPP params
i_par = [sympars.x_0,  sympars.x_0s
	 sympars.r,    sympars.rs]; # State and r component

## Simulate the sensitivity system
sensitivities = [i_ppp(:,2); i_par(:,2)]
u = ppp_ustar(A_u,1,t,0,0); 
tick=time;
[y,ys,x] = srcPPP_ssim(x_0s,pars,simpars,u,sensitivities);
Elapsed = time-tick
plot(t,y,t,ys);

### PPP parameters
tau = [0.9:0.01:1];		# Optimisation interval
t_ol = [0:0.01:0.2];		# Open-loop interval
N = 10;				# Number of open-loop intervals in simulation
w = 1;				# Setpoint
w_s = w*ones(10,1);                  # The setpoint witnin the horizon

## Linear system
n_Tau = round(simpars.last/simpars.dt);
dtau = simpars.dt;
Tau = [0:n_Tau-1]'*dtau;
[n_tau,n_w] = size(w_s);
tau = Tau(n_Tau-n_tau+1:n_Tau)
[A,B,C,D] = rcPPP_sm(par);
Q = 1;
w = 1;
ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau',Q,w);
psfig("rcPPP_lin");

## Simulate non-linear PPP (on this linear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.alpha = 0.1;
extras.verbose = 0;
extras.v = 1e-5;

##  -- with no optimisation using linear PPP with continuation
extras.U_initial = "linear";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 0;
[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras);

##  -- with no optimisation using linear PPP at each step
extras.U_initial = "linear";
extras.U_next = "linear";
extras.criterion = 1e-5;
extras.max_iterations = 0;
[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras);

##  -- with optimisation using nonlinear PPP with continuation
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 100;
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,i_ppp,i_par,A_u,w_s,N,extras);


## Plots
title("");

## U, U_c and U_l
I = [1:N]';
IU1 = [I U(:,1)];
IU1_c = [I U_c(:,1)];
IU1_l = [I U_l(:,1)];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("rcPPP_U1");

IU2 = [I U(:,2)];
IU2_c = [I U_c(:,2)];
IU2_l = [I U_l(:,2)];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("rcPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
ty = [t y] ; tu =  [t u]; 
gplot ty title "Output", tu title "Input"

psfig("rcPPP_yu");

gset grid; xlabel "Time (sec)"
ty_c = [t y_c] ; 
ty_l = [t y_l] ; 
ty = [t y] ; 
tu =  [t u]; 
gplot ty_c title "Continuation", ty_l title "Linear", ty title "Optimisation"
psfig("rcPPP_ylco");
 

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/Make version [37eadad62c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh

## Makes the files needed for Figures.m
## Copyright (C) 2000 by Peter J. Gawthrop

sys=$1

if [ -z "$2" ]; then
    code=oct
else
    code=$2
fi

if [ -z "$1" ]; then
    echo 'Usage ./Make system_name [m|oct]'
    exit
else
    echo "Making sensitivity simulation for system ${sys} (code ${code})"
fi

if [ "${code}" == "oct" ]; then
    oct='-oct'
fi

echo Switches ${oct}

## System
mtt -q ${sys} sympar m
mtt -q ${sys} simpar m
mtt -q ${sys} numpar m
mtt -q ${sys} state m


## Sensitivity system
mtt -q -stdin -s s${sys} ssim m
mtt -q -stdin -s s${sys} sympar m
mtt -q -stdin -s s${sys} simpar m
mtt -q -stdin ${oct} -s s${sys} input ${code}
mtt -q -stdin ${oct} -s s${sys} ode2odes ${code}
mtt -q -stdin ${oct} -s s${sys} state ${code}
mtt -q -stdin ${oct} -s s${sys} numpar ${code}

## Additional system reps for PPP
mtt -q -stdin  ${sys} sm m
mtt -q -stdin  ${sys} def m
mtt -q -stdin  -s s${sys} def m

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_abg.fig version [34f1b0eb45].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 3600 1125 162 162 3600 1125 3690 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4952 4277 5852 4277 5627 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6302 4277 7202 4277 6977 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 4051 4726 3151 4951 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 4051 6076 3151 6301 3376
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 4275 585 5175 585 5175 765 4275 765 4275 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5850 1215 6300 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5850 1080 6300 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 675 4275 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5175 675 7200 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6075 675 6075 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6075 1215 6075 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 1575 7200 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 945 3600 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3600 1575 3600 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 7200 1530 7200 765
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3866 3414 4502 4050 4184 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3870 5130 4505 4494 4505 4812
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 3375 2702 3375 2477 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 5175 2702 5175 2477 5400
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 5625 8550 225 900 225 900 5625 8550 5625
4 1 -1 0 0 0 20 0.0000 4 210 150 4727 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 210 150 6077 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 285 540 7787 4367 De:y\001
4 1 -1 0 0 0 20 0.0000 4 210 375 4726 2926 R:r\001
4 1 -1 0 0 0 20 0.0000 4 210 555 6076 2926 CS:c\001
4 0 1 1 0 0 20 0.0000 4 150 120 4680 450 r\001
4 0 1 1 0 0 20 0.0000 4 150 135 6480 1215 c\001
4 0 1 1 0 0 20 0.0000 4 150 135 7425 1170 e\001
4 0 1 1 0 0 20 0.0000 4 210 150 7515 1305 2\001
4 0 1 1 0 0 20 0.0000 4 150 135 3060 1170 e\001
4 0 1 1 0 0 20 0.0000 4 210 150 3150 1305 1\001
4 1 1 1 0 0 20 0.0000 4 285 1425 5400 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 210 1275 5400 2025 Schematic\001
4 1 -1 0 0 0 20 0.0000 4 285 930 3285 5265 AE:ppp_2\001
4 1 -1 0 0 0 20 0.0000 4 285 930 3285 3465 AE:ppp_1\001
4 1 -1 0 0 0 20 0.0000 4 210 660 1440 3465 Se:u1\001
4 1 -1 0 0 0 20 0.0000 4 210 660 1440 5265 Se:u2\001

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_desc.tex version [89911249a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system rcPPP (rcPPP_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{rcPPP} is
displayed in Figure \Ref{rcPPP_abg} and its label
file is listed in Section \Ref{sec:rcPPP_lbl}.
The subsystems are listed in Section \Ref{sec:rcPPP_sub}.
The system \textbf{rcPPP} is based on the simple electrical rc circuit shown in
Figure \Ref{rcPPP_abg}. 

It can be regarded as a single-input
single-output system with input $e_1$ and output $e_2$.
The bond graph in Figure \Ref{rcPPP_abg} is augmented with the {\em
open-loop\/} controller comprising
\begin{itemize}
\item two effort source \textbf{Se} components ``u1'' and ``u2''
\item two effort amplifier \textbf{AE} components ``ppp\_1'' and `ppp\_2''
\end{itemize}

This is a \emph{linear} system; but it is used to illustate
\emph{nonlinear} PPP control. Not surprisingly, the \emph{nonlinear}
PPP control gives nearly the same result (Section \Ref{sec:rcPPP_nppp.ps})
as linear open and closed-loop control.





Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_lbl.txt version [3a358dce4f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system rcPPP (rcPPP_lbl.txt)
%SUMMARY rcPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_2
%ALIAS	$3	c
%ALIAS	$4	y
%ALIAS	$5	r
%ALIAS	$6	u1
%ALIAS	$7	u2

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	ppp_1	lin		ppp_1
	ppp_2	lin		ppp_2

% Component type CS
	c	lin	        effort,c;q_0		

% Component type De
	y	SS		external

% Component type R
	r	lin		flow,r

% Component type Se
	u1	SS		external
	u2	SS		external

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_nppp.m version [df8a9ed25f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Figures.m
## Makes figures for the rc_PPP exasmple.
## $Log$
## Revision 1.3  2000/08/12 10:39:33  peterg
## Levenberg-Marquardt version
##
## Revision 1.2  2000/05/21 06:39:23  peterg
## Parameterised _sm
##
## Revision 1.1  2000/05/19 13:15:38  peterg
## Initial revision
##
## Revision 1.2  2000/05/17 17:02:58  peterg
## Fixed documentation
##
## Revision 1.1  2000/05/17 09:14:37  peterg
## Initial revision
##
system_name = "rcPPP";

## Uncomment the following the first time
## (Or do ./Make rcPPP in this directory)

## MTT stuff for the system simulation
##system("Make rcPPP");



t_s=[0:0.1:10];
u = [ones(1,length(t_s));ones(1,length(t_s))];
x_0 = rcPPP_state;
par  = rcPPP_numpar;

## Simulate the system
tick=time;
[y,x] = rcPPP_sim(x_0,u,t_s,par);
Elapsed = time-tick
plot(t_s,y,t_s,x);

## Simulate the system to give just the final few point
t_s1 = [9:0.1:10];
tick=time;
[y,x] = rcPPP_sim(x_0,u,t_s1,par);
Elapsed = time-tick
plot(t_s1,y,t_s1,x);

## Sensitivity system simulation parameters
x_0s = srcPPP_state;
pars  = srcPPP_numpar
sympars  = srcPPP_sympar;

## Simulate the sensitivity system
sensitivities = [sympars.ppp_1s,sympars.ppp_2s,sympars.rs]
tick=time;
[y,ys] = srcPPP_sim(x_0s,u,t_s,[sympars.r,2.0],sensitivities);
Elapsed = time-tick
plot(t_s,y,t_s,ys);

### PPP parameters
A_w = 0;
A_u = ppp_aug(A_w,laguerre_matrix(1,10)); # Specify basis functions: constant & exp(-5t)
tau = [0.9:0.01:1];		# Optimisation interval
t_ol = [0:0.01:0.2];		# Open-loop interval
N = 5;				# Number of open-loop intervals in simulation
w = 1;				# Setpoint

## Linear system
[A,B,C,D] = rcPPP_sm(par);
Q = 1;
w = 1;
ppp_lin_plot (A,B(:,1),C(1,:),D(1,1),A_u,A_w,tau,Q,w,x_0);
psfig("rcPPP_lin");

## Simulate non-linear PPP (on this linear system)
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.v = 0;
extras.verbose = 0;

##  -- with no optimisation using linear PPP with continuation
disp("Linear PPP at time zero with continuation trajectories")
extras.U_initial = "linear";
extras.U_next = "continuation";
extras.criterion = 1e-5;
extras.v = 0;
extras.max_iterations = 0;
[y_c,x,u_c,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with no optimisation using linear PPP at each step
disp("Linear PPP at each step")
extras.U_initial = "linear";
extras.U_next = "linear";
extras.criterion = 1e-5;
extras.max_iterations = 0;
extras.v = 0;
[y_l,x,u_l,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);

##  -- with optimisation using nonlinear PPP with continuation
disp("Nonlinear PPP");
extras.U_initial = "zero";
extras.U_next = "continuation";
extras.v = 1e-5;
extras.criterion = 1e-5;
extras.max_iterations = 100;
extras.verbose = 0;
[y,x,u,t,U,U_c,U_l] = ppp_nlin_sim (system_name,A_u,tau,t_ol,N,w,extras);


## Plots
title("");

## U, U_c and U_l
I = 1:N;
IU1 = [I' U(1,:)'];
IU1_c = [I' U_c(1,:)'];
IU1_l = [I' U_l(1,:)'];
gset grid; xlabel "Interval"
gplot IU1 title "U_1", IU1_c title "U_c1", IU1_l title "U_l1"
psfig("rcPPP_U1");

IU2 = [I' U(2,:)'];
IU2_c = [I' U_c(2,:)'];
IU2_l = [I' U_l(2,:)'];
gset grid; xlabel "Interval "
gplot IU2 title "U_2", IU2_c title "U_c2", IU2_l title "U_l2"
psfig("rcPPP_U2");

## y & u
gset grid; xlabel "Time (sec)"
ty = [t' y'] ; tu =  [t' u']; 
gplot ty title "Output", tu title "Input"

psfig("rcPPP_yu");

title("");
gset grid; xlabel "Time (sec)"
ty_c = [t' y_c'] ; 
ty_l = [t' y_l'] ; 
ty = [t' y'] ; 
tu =  [t' u']; 
gplot ty_c title "Continuation", ty_l title "Linear", ty title "Optimisation"
psfig("rcPPP_nppp");
 

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_numpar.txt version [e921254017].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (rcPPP_numpar.txt)
# Generated by MTT at Tue Apr 18 18:53:40 BST 2000

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:31:27  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c = 	1.0; # CS,rcPPP
## Removed by MTT on Sat May 26 07:46:29 BST 2001: e_0 = 	1.0; # CS
## Removed by MTT on Sat May 26 07:46:29 BST 2001: e_s = 	1.0; # Se

ppp_1 = 	1.0; # rcPPP
ppp_2 = 	0.0; # rcPPP

## Physical parameters
c =     1.0;
q_0 =   0.0;
r =     1.0;

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/rcPPP_rep.txt version [11b8899772].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system rcPPP (rcPPP_rep.txt)
## Generated by MTT on" Wed May 10 09:22:52 BST 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/05/20 17:44:47  peterg
## Initial revision
##
###############################################################

mtt rcPPP abg tex		# The system description
#mtt -s srcPPP abg tex		# The system description

mtt rcPPP struc tex	        # The system structure
mtt -s srcPPP struc tex	        # The system structure

mtt rcPPP nppp m		# How its done
mtt rcPPP nppp ps	        # PPP output

mtt rcPPP rep txt	        # PPP output

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_input.txt version [10068bd604].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (srcPPP_input.txt)
# Generated by MTT at Fri Apr 14 17:44:36 BST 2000
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Set the inputs
mttu(1) = 1.0; 	# u (srcPPP_u1_se_1)
mttu(2) = 0.0;#exp(-mttt); 	# u (srcPPP_u2_se_1)

# Set the switches

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_lbl.txt version [bea2eabf2a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system srcPPP (srcPPP_lbl.txt)
%SUMMARY srcPPP
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:31:27  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	ppp_1
%ALIAS	$2	ppp_1s
%ALIAS	$3	ppp_2
%ALIAS	$4	ppp_2s
%ALIAS	$5	c
%ALIAS	$6	cs
%ALIAS	$7	y
%ALIAS	$8	ys
%ALIAS	$9	r
%ALIAS	$10	rs
%ALIAS	$11	u1
%ALIAS	$12	u1s
%ALIAS	$13	u2
%ALIAS	$14	u2s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
% Component type Ae
	ppp_1	slin		ppp_1;ppp_1s
	ppp_2	slin		ppp_2;ppp_2s

% Component type CS
	c	slin		effort,c;x_0;cs;x_0s

% Component type De
	y	SS		external

% Component type R
	r	slin		flow,r;rs

% Component type Se
	u1	SS		external;0
	u2	SS		external;0


Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_numpar.txt version [00ff26769b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System srcPPP, representation numpar, language txt; 
## File srcPPP_numpar.txt; 
## Generated by MTT on Sat May 26 08:47:19 BST 2001; 


## Parameters
c	= 1.0;
r	= 1.0;

## PPP coefficients
ppp_1	= 0.0; # Default
ppp_2	= 1.0; # Default

## State
x_0	= 0.0; # Default

## Sensitivities
cs	= 0.0; # Default
ppp_1s	= 0.0; # Default
ppp_2s	= 0.0; # Default
rs	= 0.0; # Default
x_0s	= 0.0; # Default

Deleted mttroot/mtt/lib/examples/Control/PPP/Nonlinear/rcPPP/srcPPP_simpar.txt version [370b8dff18].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system srcPPP (srcPPP_simpar.txt)
# Generated by MTT on Fri Apr 14 17:43:36 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:31:27  peterg
## To RCS
##
###############################################################


FIRST        = 0.0;       # Last time in simulation
LAST        = 2.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_abg.fig version [b1632d46ab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2700 2835 4050 3060 3825
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 4725 4500 4725 450 225 450 225 4500 4725 4500
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 4365 R:b\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 765 I:m\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_desc.tex version [f6267dbda0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Cruise (Cruise_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cruise} is
   displayed in Figure \Ref{Cruise_abg} and its label
   file is listed in Section \Ref{sec:Cruise_lbl}.
   The subsystems are listed in Section \Ref{sec:Cruise_sub}.


This is a simple teaching example to illustrare compensator design via
observer/state-feedback methods.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_lbl.txt version [c6eb913146].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Cruise: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system Cruise (Cruise_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/20 16:26:30  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m		lin	flow,m

% Component type R
	b		lin	flow,b

% Component type SS
	u		SS	external,external

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_numpar.txt version [52092fa333].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Cruise_numpar.txt)
# Generated by MTT at Mon Jan 12 15:43:19 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # Parameter b for Cruise
b_m = 	1.0; # Parameter b_m for Cruise
j = 	1.0; # Parameter j for Cruise
j_m = 	1.0; # Parameter j_m for Cruise
k = 	1.0; # Parameter k for Cruise
k_m = 	1.0; # Parameter k_m for Cruise
l = 	1.0; # Parameter l for Cruise
l_a = 	1.0; # Parameter l_a for Cruise
l_m = 	1.0; # Parameter l_m for Cruise
r = 	1.0; # Parameter r for Cruise
r_a = 	1.0; # Parameter r_a for Cruise
r_m = 	1.0; # Parameter r_m for Cruise

# Initial states
x(1) = 	0.0; # Initial state for Cruise_motor (l_a)
x(2) = 	0.0; # Initial state for Cruise_motor (j_m)

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_params.r version [27872281d7].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
%% Parameter file for system Cruise (Cruise_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_rep.txt version [58f8bc4e60].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Cruise (Cruise_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Cruise abg tex

mtt -o Cruise sm tex
mtt -o Cruise tf tex

mtt -o Cruise smc tex
mtt -o Cruise ssk tex

mtt -o Cruise smo tex
mtt -o Cruise ssl tex

mtt -o Cruise ctf tex



Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_simp.r version [8ae10835d9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system Cruise (Cruise_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% System
%J_m := 1; L_m := 0.1; k_m := 1; b_m := 0.1; r_m := 1;

% Controller - poles at -2 and -10
%alpha_c1 := 12; alpha_c2 := 20;

% Observer -  poles at -10 -50
%alpha_o1 := 60; alpha_o2 := 500;

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Cruise/Cruise_sspar.r version [08e36df648].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for Cruise (Cruise_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_abg.fig version [d7820cb52a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2700 2835 4050 3060 3825
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4500 2475 4275 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 6750 2475 6525 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 450 225 450 225 4455 7650 4455
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 4365 R:b\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 765 I:m\001
4 0 -1 0 0 0 20 0.0000000 4 270 570 6930 2565 SS:y\001
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 1 -1 0 0 0 20 0.0000000 4 210 1080 4950 2565 INTF:int\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_desc.tex version [6888f94b02].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system CruiseP (CruiseP_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods.

The system represents a simple model of a vehicle moving along a road.
The vehicle
\begin{itemize}
\item has mass $m$
\item is driven by a force $u=F$
\item has velocity $v$ 
\item has momentum $p=mv$ 
\item has a distance along the road $y=d$
\item The system states are taken to be:
  \begin{equation}
    x = 
    \begin{pmatrix}
      p \\ d
    \end{pmatrix}
  \end{equation}\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_lbl.txt version [78c0dfb69d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CruiseP: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system CruiseP (CruiseP_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m		lin	flow,m

% Component type INTF
	int		lin	flow,int

% Component type R
	b		lin	flow,b

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_numpar.txt version [8f4fd9371e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (CruiseP_numpar.txt)
# Generated by MTT at Fri Feb 13 17:15:12 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # CruiseP
int = 	1.0; # CruiseP
m = 	1.0; # CruiseP

# Initial states
x(1) = 	0.0; # CruiseP (m)
x(2) = 	0.0; # CruiseP_int (3)

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_pic.fig version [7cbcc3e0e1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Inches
1200 2
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 3900 3900 309 309 3900 3900 4209 4209
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 2700 3900 309 309 2700 3900 3009 4209
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 2400 2400 4200 2400 4200 3600 2400 3600 2400 2400
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 4500 2700 5700 2700
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 1200 3000 2400 3000
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 3900 1800 2700 1800
4 0 -1 0 0 3 20 0.0000000 4 270 1380 5700 2400 v (velocity)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1095 525 2700 u (force)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1425 5700 3150 y (position)\001
4 0 -1 0 0 3 20 0.0000000 4 255 1155 2700 3075 m (mass)\001
4 0 -1 0 0 3 20 0.0000000 4 270 2235 3150 1575 bv (friction force)\001
4 0 -1 0 0 3 16 0.0000000 4 195 2490 2325 5100 states:  p=momentum=mv\001
4 0 -1 0 0 3 16 0.0000000 4 210 1725 2325 5442             y=position\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_pic.tex version [e76f40dd94].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
\makebox[5.541in][l]{
  \vbox to 3.458in{
    \vfill
    \special{psfile=CruiseP_pic.ps}
  }
  \vspace{-\baselineskip}
}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_rep.tex version [863e452b9f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


\section{\textbf{CruiseP}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:CruiseP_abg.tex}
\index{\textbf{CruiseP} -- abg}


MTT command:
\begin{verbatim}
mtt CruiseP abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_abg.tex}


\section{\textbf{CruiseP}: representation \textbf{ode}, language \textbf{tex}}
\label{sec:CruiseP_ode.tex}
\index{\textbf{CruiseP} -- ode}


MTT command:
\begin{verbatim}
mtt -o CruiseP ode tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ode.tex}


\section{\textbf{CruiseP}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:CruiseP_sm.tex}
\index{\textbf{CruiseP} -- sm}


MTT command:
\begin{verbatim}
mtt -o CruiseP sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_sm.tex}


\section{\textbf{CruiseP}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:CruiseP_tf.tex}
\index{\textbf{CruiseP} -- tf}


MTT command:
\begin{verbatim}
mtt -o CruiseP tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_tf.tex}


\section{\textbf{CruiseP}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:CruiseP_smc.tex}
\index{\textbf{CruiseP} -- smc}


MTT command:
\begin{verbatim}
mtt -o CruiseP smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_smc.tex}


\section{\textbf{CruiseP}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:CruiseP_ssk.tex}
\index{\textbf{CruiseP} -- ssk}


MTT command:
\begin{verbatim}
mtt -o CruiseP ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ssk.tex}


\section{\textbf{CruiseP}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:CruiseP_smo.tex}
\index{\textbf{CruiseP} -- smo}


MTT command:
\begin{verbatim}
mtt -o CruiseP smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_smo.tex}


\section{\textbf{CruiseP}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:CruiseP_ssl.tex}
\index{\textbf{CruiseP} -- ssl}


MTT command:
\begin{verbatim}
mtt -o CruiseP ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ssl.tex}


\section{\textbf{CruiseP}: representation \textbf{ctf}, language \textbf{tex}}
\label{sec:CruiseP_ctf.tex}
\index{\textbf{CruiseP} -- ctf}


MTT command:
\begin{verbatim}
mtt -o CruiseP ctf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruiseP/MTT_work/CruiseP_ctf.tex}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/CruiseP_rep.txt version [5d5e21401e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system CruiseP (CruiseP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt CruiseP abg tex

mtt -o CruiseP ode tex
mtt -o CruiseP sm tex
mtt -o CruiseP tf tex

mtt -o CruiseP smc tex
mtt -o CruiseP ssk tex

mtt -o CruiseP smo tex
mtt -o CruiseP ssl tex

mtt -o CruiseP ctf tex


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruiseP/Makefile version [02aec829a2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#
# TransFig makefile
#

all: CruiseP_pic.tex 

# translation into ps

CruiseP_pic.tex: CruiseP_pic.ps Makefile
	fig2ps2tex CruiseP_pic.ps >CruiseP_pic.tex
clean::
	rm -f CruiseP_pic.tex

CruiseP_pic.ps: CruiseP_pic.fig Makefile
	fig2dev -L ps CruiseP_pic.fig > CruiseP_pic.ps
clean::
	rm -f CruiseP_pic.ps

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_abg.fig version [d7820cb52a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2700 2835 4050 3060 3825
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2250 2475 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4500 2475 4275 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2475 6750 2475 6525 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 450 225 450 225 4455 7650 4455
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 4365 R:b\001
4 1 -1 0 0 0 20 0.0000000 4 210 435 2880 765 I:m\001
4 0 -1 0 0 0 20 0.0000000 4 270 570 6930 2565 SS:y\001
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 1 -1 0 0 0 20 0.0000000 4 210 1080 4950 2565 INTF:int\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_desc.tex version [820fce3156].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system CruisePN (CruisePN_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods. The equations are presented in
numerical (as opposed to symbolic) form.

The system represents a simple model of a vehicle moving along a road.
The vehicle
\begin{itemize}
\item has mass $m$
\item is driven by a force $u=F$
\item has velocity $v$ 
\item has momentum $p=mv$ 
\item has a distance along the road $y=d$
\item The system states are taken to be:
  \begin{equation}
    x = 
    \begin{pmatrix}
      p \\ d
    \end{pmatrix}
  \end{equation}\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_lbl.txt version [59330369ec].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY CruisePN: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system CruisePN (CruisePN_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m		lin	flow,m

% Component type INTF
	int		lin	flow,int

% Component type R
	b		lin	flow,b

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_numpar.txt version [b93d73c639].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (CruisePN_numpar.txt)
# Generated by MTT at Fri Feb 13 17:15:12 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # CruisePN
int = 	1.0; # CruisePN
m = 	1.0; # CruisePN

# Initial states
x(1) = 	0.0; # CruisePN (m)
x(2) = 	0.0; # CruisePN_int (3)

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_pic.fig version [7cbcc3e0e1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Inches
1200 2
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 3900 3900 309 309 3900 3900 4209 4209
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 2700 3900 309 309 2700 3900 3009 4209
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 2400 2400 4200 2400 4200 3600 2400 3600 2400 2400
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 4500 2700 5700 2700
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 1200 3000 2400 3000
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 3900 1800 2700 1800
4 0 -1 0 0 3 20 0.0000000 4 270 1380 5700 2400 v (velocity)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1095 525 2700 u (force)\001
4 0 -1 0 0 3 20 0.0000000 4 270 1425 5700 3150 y (position)\001
4 0 -1 0 0 3 20 0.0000000 4 255 1155 2700 3075 m (mass)\001
4 0 -1 0 0 3 20 0.0000000 4 270 2235 3150 1575 bv (friction force)\001
4 0 -1 0 0 3 16 0.0000000 4 195 2490 2325 5100 states:  p=momentum=mv\001
4 0 -1 0 0 3 16 0.0000000 4 210 1725 2325 5442             y=position\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_pic.tex version [c999a1fdcd].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
\makebox[5.541in][l]{
  \vbox to 3.458in{
    \vfill
    \special{psfile=CruisePN_pic.ps}
  }
  \vspace{-\baselineskip}
}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_rep.tex version [dd5b960981].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


\section{\textbf{CruisePN}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:CruisePN_abg.tex}
\index{\textbf{CruisePN} -- abg}


MTT command:
\begin{verbatim}
mtt CruisePN abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_abg.tex}


\section{\textbf{CruisePN}: representation \textbf{ode}, language \textbf{tex}}
\label{sec:CruisePN_ode.tex}
\index{\textbf{CruisePN} -- ode}


MTT command:
\begin{verbatim}
mtt -o CruisePN ode tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ode.tex}


\section{\textbf{CruisePN}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:CruisePN_sm.tex}
\index{\textbf{CruisePN} -- sm}


MTT command:
\begin{verbatim}
mtt -o CruisePN sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_sm.tex}


\section{\textbf{CruisePN}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:CruisePN_tf.tex}
\index{\textbf{CruisePN} -- tf}


MTT command:
\begin{verbatim}
mtt -o CruisePN tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_tf.tex}


\section{\textbf{CruisePN}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:CruisePN_smc.tex}
\index{\textbf{CruisePN} -- smc}


MTT command:
\begin{verbatim}
mtt -o CruisePN smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_smc.tex}


\section{\textbf{CruisePN}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:CruisePN_ssk.tex}
\index{\textbf{CruisePN} -- ssk}


MTT command:
\begin{verbatim}
mtt -o CruisePN ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ssk.tex}


\section{\textbf{CruisePN}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:CruisePN_smo.tex}
\index{\textbf{CruisePN} -- smo}


MTT command:
\begin{verbatim}
mtt -o CruisePN smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_smo.tex}


\section{\textbf{CruisePN}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:CruisePN_ssl.tex}
\index{\textbf{CruisePN} -- ssl}


MTT command:
\begin{verbatim}
mtt -o CruisePN ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ssl.tex}


\section{\textbf{CruisePN}: representation \textbf{ctf}, language \textbf{tex}}
\label{sec:CruisePN_ctf.tex}
\index{\textbf{CruisePN} -- ctf}


MTT command:
\begin{verbatim}
mtt -o CruisePN ctf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/CruisePN/MTT_work/CruisePN_ctf.tex}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_rep.txt version [d9e7301ff2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system CruisePN (CruisePN_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt CruisePN abg tex

mtt -o CruisePN ode tex
mtt -o CruisePN sm tex
mtt -o CruisePN tf tex

mtt -o CruisePN smc tex
mtt -o CruisePN ssk tex

mtt -o CruisePN smo tex
mtt -o CruisePN ssl tex

mtt -o CruisePN ctf tex


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_simp.r version [87a70b56bc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system CruisePN (CruisePN_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


m  := 1;
b := 0;

alpha_o1 := 4;
alpha_o2 := 4;

alpha_c1 := 2;
alpha_c2 := 1;

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruisePN_sspar.r version [269881705f].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for CruisePN (CruisePN_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/CruiseP_pic.tex version [e76f40dd94].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
\makebox[5.541in][l]{
  \vbox to 3.458in{
    \vfill
    \special{psfile=CruiseP_pic.ps}
  }
  \vspace{-\baselineskip}
}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/CruisePN/Makefile version [c3cd8e3dfa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#
# TransFig makefile
#

all: CruisePN_pic.tex 

# translation into ps

CruisePN_pic.tex: CruisePN_pic.ps Makefile
	fig2ps2tex CruisePN_pic.ps >CruisePN_pic.tex
clean::
	rm -f CruisePN_pic.tex

CruisePN_pic.ps: CruisePN_pic.fig Makefile
	fig2dev -L ps CruisePN_pic.fig > CruisePN_pic.ps
clean::
	rm -f CruisePN_pic.ps

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DC_abg.fig version [3daa31e601].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4050 4500 4050 225 1800 225 1800 4500 4050 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 2475 2745 2475 2475 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 2250 2925 1080 3150 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3105 2475 4275 2475 4005 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 2700 2925 3870 3150 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 2475 6795 2475 6525 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 2295 6975 1125 7200 1395
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 2700 6975 3870 7200 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 2475 8370 2475 8100 2700
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8100 4500 8100 225 5850 225 5850 4500 8100 4500
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 4950 225 4950 225 45 9450 45 9450 4950
4 1 -1 0 0 0 20 0.0000 4 195 135 2880 2610 1\001
4 1 -1 0 0 0 20 0.0000 4 255 990 4995 2565 GY:k_m\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6975 2565 1\001
4 1 4 0 0 0 20 0.0000 4 240 810 1080 2565 SS:[in]\001
4 1 -1 0 0 0 20 0.0000 4 255 510 2880 990 I:l_a\001
4 1 -1 0 0 0 20 0.0000 4 255 600 7065 990 I:j_m\001
4 1 -1 0 0 0 20 0.0000 4 255 645 2970 4230 R:r_a\001
4 1 -1 0 0 0 20 0.0000 4 255 765 7020 4230 R:b_m\001
4 1 1 1 0 0 20 0.0000 4 195 1095 2925 4815 Electrical\001
4 1 1 1 0 0 20 0.0000 4 195 1335 6975 4815 Mechanical\001
4 1 1 1 0 0 20 0.0000 4 195 630 8910 2925 Shaft\001
4 1 1 1 0 0 20 0.0000 4 195 1170 1080 2925 Terminals\001
4 1 4 0 0 0 20 0.0000 4 240 960 8910 2565 SS:[out]\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DC_desc.tex version [77c4d38d75].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system DC (DC_desc.tex)
% Generated by MTT on Thu Sep 11 10:09:58 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{DC} is
   displayed in Figure \Ref{DC_abg} and its label
   file is listed in Section \Ref{sec:DC_lbl}.
   The subsystems are listed in Section \Ref{sec:DC_sub}.

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|}
        \hline
        Index & Parameter\\
        \hline
         1 & Motor gain ($k_m$) \\
         2 & Armature inductance ($l_a$) \\
         3 & Armature resistance ($r_a$) \\
         4 & Inertia ($j_m$) \\
         5 & Friction coefficient ($b_m$) \\
        \hline
       \end{tabular}
       \caption{DC motor parameters}
       \label{tab:DC_components}
     \end{center}
   \end{table}
{\bf DC} is a two-port component representing a DC motor. It has the 5
parameters listed in Table \Ref{tab:DC_components}.


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DC_lbl.txt version [bd004f0f0a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY DC: DC motor (or generator)
%DESCRIPTION Port [in]: Electrical (in)
%DESCRIPTION Port [out]: Mechanical (out)
%DESCRIPTION Parameter 1: Motor gain (k_m)
%DESCRIPTION Parameter 2: Armature inductance (l_a)
%DESCRIPTION Parameter 3: Armature resistance (r_a)
%DESCRIPTION Parameter 4: Inertia (j_m)
%DESCRIPTION Parameter 5: Friction coefficient (b_m)


%% Label file for system DC (DC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/04  16:01:42  peterg
% %% Documantation added.
% %%
% %% Revision 1.1  1996/12/04  16:00:56  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Motor gain
k_m	lin	flow,$1

% Electrical components
%Inductance
l_a	lin	effort,$2
%Resistance
r_a	lin	flow,$3

% Mechanical components
%Inertia
j_m	lin	flow,$4
%Friction
b_m	lin	flow,$5

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_abg.fig version [d436a5df4d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2475 5175 2475 4950 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 3150 6075 1800 225 1800 225 3150 6075 3150
4 1 -1 0 0 0 20 0.0000000 4 210 1230 3195 2565 DC:motor\001
4 0 -1 0 0 0 20 0.0000000 4 210 570 5310 2565 SS:v\001
4 2 -1 0 0 0 20 0.0000000 4 210 555 1035 2565 SS:e\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_args.new version [5936bc7523].

1

-
 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_desc.tex version [9905aeccc5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system DCexample (DCexample_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods.

The system represents a simple model of a DC motor including armature
resistance $r_m$, armature inductance $l_m$, motor constant $k_m$,
inertia $j_m$ and friction $b_m$.

The DC motor has
\begin{itemize}
\item output angular velocity $y = \omega$
\item input voltage $u = v$
\item $\lambda = Li$ where $i$ is the armature current
\item angular momentum $p=j_m \omega$.
\item system states given by
  \begin{equation}
    x = 
    \begin{pmatrix}
      \lambda \\ \omega
    \end{pmatrix}
  \end{equation}
\end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_lbl.txt version [ee4ead091c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY DCexample: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system DCexample (DCexample_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type DC
	motor		lin	k_m;l_m;r_m;j_m;b_m

% Component type SS
	e		SS	external,internal
	v		SS	0,external

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_numpar.txt version [515bf1c141].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (DCexample_numpar.txt)
# Generated by MTT at Mon Jan 12 15:43:19 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # Parameter b for DCexample
b_m = 	1.0; # Parameter b_m for DCexample
j = 	1.0; # Parameter j for DCexample
j_m = 	1.0; # Parameter j_m for DCexample
k = 	1.0; # Parameter k for DCexample
k_m = 	1.0; # Parameter k_m for DCexample
l = 	1.0; # Parameter l for DCexample
l_a = 	1.0; # Parameter l_a for DCexample
l_m = 	1.0; # Parameter l_m for DCexample
r = 	1.0; # Parameter r for DCexample
r_a = 	1.0; # Parameter r_a for DCexample
r_m = 	1.0; # Parameter r_m for DCexample

# Initial states
x(1) = 	0.0; # Initial state for DCexample_motor (l_a)
x(2) = 	0.0; # Initial state for DCexample_motor (j_m)

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_params.r version [336c7256e5].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
%% Parameter file for system DCexample (DCexample_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_pic.fig version [6593ec6ec8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Inches
1200 2
6 3900 1725 7575 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 4801 1801 5701 1801
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 5701 1726 6601 1726 6601 1876 5701 1876 5701 1726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 6601 1801 7501 1801 7501 2401
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 3901 1726 4801 1726 4801 1876 3901 1876 3901 1726
-6
1 3 0 2 -1 7 0 0 -1 0.0000000 1 0.000 7500 2700 270 270 7500 2700 7650 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 3000 1800 3900 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 7500 3000 7500 3600 3000 3600
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 7950 2625 10800 2625 10800 2775 7950 2775 7950 2625
2 2 0 2 -1 7 0 0 -1 0.000 0 0 0 0 0 5
	 10800 1200 11400 1200 11400 4200 10800 4200 10800 1200
4 0 -1 0 0 3 20 0.0000000 4 150 135 3000 2775 v\001
4 0 -1 0 0 3 20 0.0000000 4 210 90 3300 1650 i\001
4 2 -1 0 0 3 20 0.0000000 4 255 540 6675 2775 k_m\001
4 2 -1 0 0 32 20 0.0000000 4 135 210 6975 2775 w\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_pic.tex version [274fd15af3].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
\makebox[7.055in][l]{
  \vbox to 2.555in{
    \vfill
    \special{psfile=DCexample_pic.ps}
  }
  \vspace{-\baselineskip}
}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_rep.tex version [03d36bd17b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


\section{\textbf{DCexample}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:DCexample_abg.tex}
\index{\textbf{DCexample} -- abg}


MTT command:
\begin{verbatim}
mtt DCexample abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_abg.tex}


\section{\textbf{DCexample}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:DCexample_sm.tex}
\index{\textbf{DCexample} -- sm}


MTT command:
\begin{verbatim}
mtt -o DCexample sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_sm.tex}


\section{\textbf{DCexample}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:DCexample_tf.tex}
\index{\textbf{DCexample} -- tf}


MTT command:
\begin{verbatim}
mtt -o DCexample tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_tf.tex}


\section{\textbf{DCexample}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:DCexample_smc.tex}
\index{\textbf{DCexample} -- smc}


MTT command:
\begin{verbatim}
mtt -o DCexample smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_smc.tex}


\section{\textbf{DCexample}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:DCexample_ssk.tex}
\index{\textbf{DCexample} -- ssk}


MTT command:
\begin{verbatim}
mtt -o DCexample ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_ssk.tex}


\section{\textbf{DCexample}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:DCexample_smo.tex}
\index{\textbf{DCexample} -- smo}


MTT command:
\begin{verbatim}
mtt -o DCexample smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_smo.tex}


\section{\textbf{DCexample}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:DCexample_ssl.tex}
\index{\textbf{DCexample} -- ssl}


MTT command:
\begin{verbatim}
mtt -o DCexample ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/DCexample/MTT_work/DCexample_ssl.tex}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_rep.txt version [9e1428c8ee].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system DCexample (DCexample_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt DCexample abg tex

mtt -o DCexample sm tex
mtt -o DCexample tf tex

mtt -o DCexample smc tex
mtt -o DCexample ssk tex

mtt -o DCexample smo tex
mtt -o DCexample ssl tex


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_simp.r version [f380d89b00].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system DCexample (DCexample_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% System
%J_m := 1; L_m := 0.1; k_m := 1; b_m := 0.1; r_m := 1;

% Controller - poles at -2 and -10
%alpha_c1 := 12; alpha_c2 := 20;

% Observer -  poles at -10 -50
%alpha_o1 := 60; alpha_o2 := 500;

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/DCexample_sspar.r version [559cfc0faa].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for DCexample (DCexample_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/DCexample/Makefile version [902affeab5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#
# TransFig makefile
#

all: DCexample_pic.tex 

# translation into ps

DCexample_pic.tex: DCexample_pic.ps Makefile
	fig2ps2tex DCexample_pic.ps >DCexample_pic.tex
clean::
	rm -f DCexample_pic.tex

DCexample_pic.ps: DCexample_pic.fig Makefile
	fig2dev -L ps DCexample_pic.fig > DCexample_pic.ps
clean::
	rm -f DCexample_pic.ps

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Differential/Differential_abg.fig version [6c87d44baf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2880 2655 2970 3195
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2925 2700 2925 3150
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2700 3150 1350 3375 1575
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3172 3172 3172 4522 3397 4297
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2925 2925 2925 2700 3150
4 1 0 100 0 18 18 0.0000 4 195 150 3150 3015 0\001
4 1 0 100 0 18 18 0.0000 4 270 540 3195 1215 I:j_1\001
4 1 0 100 0 18 18 0.0000 4 270 540 3150 4860 I:j_2\001
4 1 0 100 0 18 18 0.0000 4 270 750 990 3015 SS:yu\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Differential/Differential_rep.txt version [00561dcbde].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Differential (Differential_rep.txt)
## Generated by MTT on" Wed Jan 26 10:13:44 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt Differential abg tex			# The system description
mtt Differential cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt Differential struc tex	        # The system structure
## mtt Differential dae tex	        # The system dae
mtt Differential ode tex	        # The system ode 
## mtt Differential sspar tex		# Steady-state parameters
## mtt Differential ss tex 		# Steady state
## mtt Differential dm tex		# Descriptor matrices (of linearised system)
mtt Differential sm tex		# State matrices (of linearised system)
mtt Differential tf tex		# Transfer function (of linearised

## mtt Differential lmfr ps		# log modulus of frequency response (of linearised system)
## mtt Differential simpar tex		# Simulation parameters
## mtt Differential numpar tex		# Numerical simulation parameters
## mtt Differential input tex		# Simulation input
mtt Differential odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_abg.fig version [d065af5e98].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 8550 1125 485 485 8550 1125 8730 1575
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 8100 9450 225 855 225 855 8100 9450 8100
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3871 3600 5446 3825 5221
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 3871 5850 5446 6075 5221
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 3870 3735 3870
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4590 3825 4860 3825
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5715 3870 5985 3870
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 1125 3735 1125
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4635 2700 4905 2700
4 1 -1 0 0 0 20 0.0000000 4 240 870 3603 948 SS:v_x\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5850 2970 [y_a]\001
4 1 -1 0 0 0 20 0.0000000 4 270 870 5850 945 SS:v_y\001
4 1 -1 0 0 0 20 0.0000000 4 210 1110 4729 3379 ROD:rod\001
4 1 -1 0 0 0 20 0.0000000 4 240 825 3510 5760 SS:f_x\001
4 1 -1 0 0 0 20 0.0000000 4 270 825 5760 5760 SS:f_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 810 4635 5760 SS:f_a\001
4 0 1 1 0 3 20 0.0000000 4 240 720 6750 1260 Joint \001
4 0 1 1 0 3 20 0.0000000 4 210 495 6795 3375 Rod\001
4 1 -1 0 0 0 20 0.0000000 4 210 570 4771 946 SS:u\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_desc.tex version [7fb9ed2fd5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system InvertedPendulumT (InvertedPendulumT_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{InvertedPendulumT} is
   displayed in Figure \Ref{InvertedPendulumT_abg} and its label
   file is listed in Section \Ref{sec:InvertedPendulumT_lbl}.
   The subsystems are listed in Section \Ref{sec:InvertedPendulumT_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to translation
motion) in derivative causality, thus the system is represnted as a
Differential-Algebraic Equation (Section
\Ref{sec:InvertedPendulumT_dae.tex}). Hovever, this is of contrained-state form and
therfore can be written as a set of constrained-state equations (Section
\Ref{sec:InvertedPendulumT_cse.tex}). The corresponding ordinary differential
equation is complicated due to the trig functions involved in
inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:InvertedPendulumT_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_input.txt version [1c6fb421ed].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (InvertedPendulumT_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	(t<1.0);
u(2) =	0.0; # 
u(3) =	0.0; # gravity

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_lbl.txt version [66a8b967a4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY InvertedPendulumT: Pendulum with torque input at lower end

%% Label (InvertedPendulumT_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod	none	l_1;l_1;j_1;m_1

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
f_x	SS	   0,internal
f_a	SS	   0,internal
f_y	SS	   0,internal


%Torque/velocity at joint
u	SS	 external,internal


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_numpar.txt version [43ee56016c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (InvertedPendulumT_numpar.txt)
# Generated by MTT at Mon Jan 19 13:53:15 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
j_1 = 	1.0; # Parameter j_1 for InvertedPendulumT
j_2 = 	1.0; # Parameter j_2 for InvertedPendulumT
l_1 = 	1.0; # Parameter l_1 for InvertedPendulumT
l_2 = 	1.0; # Parameter l_2 for InvertedPendulumT
m_1 = 	1.0; # Parameter m_1 for InvertedPendulumT
m_2 = 	1.0; # Parameter m_2 for InvertedPendulumT

# Initial states
x(1) = 	0.0; # Initial state for InvertedPendulumT_rod1 (J)
x(2) = 	0.0; # Initial state for InvertedPendulumT_rod1_th (3)
x(3) = 	0.0; # Initial state for InvertedPendulumT_rod2 (J)
x(4) = 	0.0; # Initial state for InvertedPendulumT_rod2_th (3)

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_rep.txt version [074582e484].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system InvertedPendulumT (InvertedPendulumT_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt InvertedPendulumT abg tex

mtt -o InvertedPendulumT ode tex
mtt -o InvertedPendulumT sm tex
mtt -o InvertedPendulumT tf tex

mtt -o InvertedPendulumT smc tex
mtt -o InvertedPendulumT ssk tex

mtt -o InvertedPendulumT smo tex
mtt -o InvertedPendulumT ssl tex


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_simp.r version [5cb387141c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system InvertedPendulumT (InvertedPendulumT_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;


m_1 := m;
l_1 := l;
j_1 := j;
mg := m*g;
j := m*l*l/12;

%l:=1;

alpha_c1 := 2;
alpha_c2 := 1;

alpha_o1 := 20;
alpha_o2 := 100;


ORDER s,m,g;


END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/InvertedPendulumT_sspar.r version [37046d7f6d].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for InvertedPendulumT (InvertedPendulumT_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTx1 := 0;
MTTx2 := 0;

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/ROD_abg.fig version [afa8c63279].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4951 6526 5401
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 8550 7650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8685 5265 8415 5535
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1372 3490 1372 3172 3375 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1507 3037 1237 3307
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9180 5724 9180 6042 8544 5406
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 1065 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000000 4 240 1080 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1065 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1080 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1575 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1590 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001
4 1 -1 0 0 0 20 0.0000000 4 270 810 9225 6300 SS:mg\001
4 2 -1 0 0 0 20 0.0000000 4 210 1020 1395 3060 SS:theta\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/ROD_desc.tex version [58e21e2b67].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/InvertedPendulumT/ROD_lbl.txt version [03080ab3ad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system ROD (ROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2

%Gravity
mg	mg	internal

% Angle
theta	external	0

	

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_abg.fig version [3da14bbf94].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1125 2475 2475 2475 2250 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4500 2475 4275 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5872 2497 7222 2497 6997 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 2250 2835 900 3060 1125
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8145 3150 8145 450 270 450 270 3150 8145 3150
4 1 -1 0 0 0 20 0.0000000 4 210 1080 5265 2565 INTF:int\001
4 2 -1 0 0 0 20 0.0000000 4 210 570 1035 2565 SS:u\001
4 0 -1 0 0 0 20 0.0000000 4 270 570 7380 2565 SS:y\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2835 2565 1\001
4 1 -1 0 0 0 20 0.0000000 4 270 285 2880 765 I:j\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_desc.tex version [f32b0f51ab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Satellite (Satellite_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Satellite} is
   displayed in Figure \Ref{Satellite_abg} and its label
   file is listed in Section \Ref{sec:Satellite_lbl}.
   The subsystems are listed in Section \Ref{sec:Satellite_sub}.


This is a simple teaching example to illustrare compensator design via
observer/state-feedback methods.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_lbl.txt version [782e83919f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Satellite: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system Satellite (Satellite_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	j		lin	flow,1

% Component type INTF
	int		

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_numpar.txt version [1f955bd38c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Satellite_numpar.txt)
# Generated by MTT at Mon Jan 12 15:43:19 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b = 	1.0; # Parameter b for Satellite
b_m = 	1.0; # Parameter b_m for Satellite
j = 	1.0; # Parameter j for Satellite
j_m = 	1.0; # Parameter j_m for Satellite
k = 	1.0; # Parameter k for Satellite
k_m = 	1.0; # Parameter k_m for Satellite
l = 	1.0; # Parameter l for Satellite
l_a = 	1.0; # Parameter l_a for Satellite
l_m = 	1.0; # Parameter l_m for Satellite
r = 	1.0; # Parameter r for Satellite
r_a = 	1.0; # Parameter r_a for Satellite
r_m = 	1.0; # Parameter r_m for Satellite

# Initial states
x(1) = 	0.0; # Initial state for Satellite_motor (l_a)
x(2) = 	0.0; # Initial state for Satellite_motor (j_m)

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_rep.txt version [0143a6f353].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Satellite (Satellite_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Satellite abg tex

mtt -o Satellite ode tex
mtt -o Satellite sm tex
mtt -o Satellite tf tex

mtt -o Satellite smc tex
mtt -o Satellite ssk tex

mtt -o Satellite smo tex
mtt -o Satellite ssl tex
mtt -o Satellite ctf tex


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_simp.r version [6ee2a71759].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system Satellite (Satellite_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% System

% Controller - poles -1
alpha_c1 := 2; alpha_c2 := 1;

% Observer -  poles at -1 
alpha_o1 := 2; alpha_o2 := 1;

ON FACTOR;

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/Satellite/Satellite_sspar.r version [0ae589b8c8].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for Satellite (Satellite_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/Makefile version [57b513cffa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#
# TransFig makefile
#

all: TwoTanks_pic.tex 

# translation into ps

TwoTanks_pic.tex: TwoTanks_pic.ps Makefile
	fig2ps2tex TwoTanks_pic.ps >TwoTanks_pic.tex
clean::
	rm -f TwoTanks_pic.tex

TwoTanks_pic.ps: TwoTanks_pic.fig Makefile
	fig2dev -L ps TwoTanks_pic.fig > TwoTanks_pic.ps
clean::
	rm -f TwoTanks_pic.ps

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_abg.fig version [c6ae3ce4c5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1351 4276 2701 4276 2476 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4501 3826 5401 3601 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2971 4051 3871 3151 3871 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 3150 5625 3150 5400 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 5400 5625 5400 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 2925 4051 1575 4276 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 5670 4050 7020 4275 6795
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 2880 5850 1530 6075 1755
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 5670 5850 7020 6075 6795
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 7425 3150 7200 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5400 7425 5400 7200 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 8775 4050 8505 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 5400 8775 4500 8775 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 4275 10351 4275 10126 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1350 4050 1350 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9000 4050 9000 4500
4 1 -1 0 0 0 20 0.0000000 4 210 150 2926 4366 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 4096 5491 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 4096 3241 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5895 3240 1\001
4 1 -1 0 0 0 20 0.0000000 4 240 690 5895 1440 R:r_1\001
4 1 -1 0 0 0 20 0.0000000 4 240 720 4050 1440 C:c_1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5850 5490 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 375 7650 3240 AF\001
4 1 -1 0 0 0 20 0.0000000 4 210 375 7695 5490 AF\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8775 4365 0\001
4 0 -1 0 0 0 20 0.0000000 4 240 825 10620 4320 SS:f_2\001
4 2 -1 0 0 0 20 0.0000000 4 240 825 1260 4365 SS:f_1\001
4 1 -1 0 0 0 20 0.0000000 4 240 720 4005 7335 C:c_2\001
4 1 -1 0 0 0 20 0.0000000 4 240 690 5850 7335 R:r_2\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_desc.tex version [fc1416584e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoTanks (TwoTanks_desc.tex)
% Generated by MTT on Mon Jan 12 16:00:15 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is a simple teaching example to illustrate compensator design via
observer/state-feedback methods.

\begin{itemize}
\item Each tank is identical and of unit cross section.
\item Each tank has an identical inflow $f_1 = u$
\item Each outflow is different and given by $\sigma_i v_i$ for $i=1$
  and $i=2$ where $v_i$ is the volume of liquid in tank i and
  $\sigma_i$ the corresponding discharge coefficient. The net outflow
  is thus $y = f_2 = \sigma_1 v_1 + \sigma_2 v_2$.
\item The system states are taken to be:
  \begin{equation}
    x = 
    \begin{pmatrix}
      v_1 \\ v_2
    \end{pmatrix}
  \end{equation}
\end{itemize}




%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_lbl.txt version [c838a1da5c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoTanks: <brief description here>
%DESCRIPTION <Detailed description here>
%% Label file for system TwoTanks (TwoTanks_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,1
	c_2		lin	effort,1

% Component type R
	r_1		lin	effort,sigma_1
	r_2		lin	effort,sigma_2

% Component type SS
	f_1		SS	internal,external
	f_2		SS	0,external

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_params.r version [e6fd98b650].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
%% Parameter file for system TwoTanks (TwoTanks_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_pic.fig version [9031f3f49a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Inches
1200 2
6 2099 1799 3974 3974
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2100 1800 2100 3900 3900 3900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3300 1800 3300 3600 3900 3600
-6
6 5025 1800 6900 3975
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6899 1801 6899 3901 5099 3901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5699 1801 5699 3601 5099 3601
-6
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 3600 3750 4200 3750 4200 4800
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 5400 3750 4800 3750 4800 4800
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 1800 1050 2400 1050 2400 2100
2 1 1 2 -1 7 0 0 -1 6.000 0 0 -1 1 0 3
	1 1 2.00 120.00 240.00
	 7200 1050 6600 1050 6600 2100
4 0 -1 0 0 3 20 0.0000000 4 270 2610 3225 5250 y=total outflow = f_2\001
4 0 -1 0 0 3 20 0.0000000 4 270 405 1950 900 f_1\001
4 0 -1 0 0 3 20 0.0000000 4 270 405 6825 900 f_1\001
4 0 -1 0 0 3 20 0.0000000 4 270 3525 2775 1500 u= inflow to each tank = f_1\001

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_pic.tex version [d9789ea80b].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
\makebox[4.569in][l]{
  \vbox to 3.861in{
    \vfill
    \special{psfile=TwoTanks_pic.ps}
  }
  \vspace{-\baselineskip}
}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_rep.tex version [c0c0a0dc5d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


\section{\textbf{TwoTanks}: representation \textbf{abg}, language \textbf{tex}}
\label{sec:TwoTanks_abg.tex}
\index{\textbf{TwoTanks} -- abg}


MTT command:
\begin{verbatim}
mtt TwoTanks abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_abg.tex}


\section{\textbf{TwoTanks}: representation \textbf{sm}, language \textbf{tex}}
\label{sec:TwoTanks_sm.tex}
\index{\textbf{TwoTanks} -- sm}


MTT command:
\begin{verbatim}
mtt -o TwoTanks sm tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_sm.tex}


\section{\textbf{TwoTanks}: representation \textbf{tf}, language \textbf{tex}}
\label{sec:TwoTanks_tf.tex}
\index{\textbf{TwoTanks} -- tf}


MTT command:
\begin{verbatim}
mtt -o TwoTanks tf tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_tf.tex}


\section{\textbf{TwoTanks}: representation \textbf{smc}, language \textbf{tex}}
\label{sec:TwoTanks_smc.tex}
\index{\textbf{TwoTanks} -- smc}


MTT command:
\begin{verbatim}
mtt -o TwoTanks smc tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_smc.tex}


\section{\textbf{TwoTanks}: representation \textbf{ssk}, language \textbf{tex}}
\label{sec:TwoTanks_ssk.tex}
\index{\textbf{TwoTanks} -- ssk}


MTT command:
\begin{verbatim}
mtt -o TwoTanks ssk tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_ssk.tex}


\section{\textbf{TwoTanks}: representation \textbf{smo}, language \textbf{tex}}
\label{sec:TwoTanks_smo.tex}
\index{\textbf{TwoTanks} -- smo}


MTT command:
\begin{verbatim}
mtt -o TwoTanks smo tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_smo.tex}


\section{\textbf{TwoTanks}: representation \textbf{ssl}, language \textbf{tex}}
\label{sec:TwoTanks_ssl.tex}
\index{\textbf{TwoTanks} -- ssl}


MTT command:
\begin{verbatim}
mtt -o TwoTanks ssl tex 
\end{verbatim}
  \input{/home/peterg/Research/Modelling/Control/StateSpace/TwoTanks/MTT_work/TwoTanks_ssl.tex}

Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_rep.txt version [6dfe1f9e05].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TwoTanks (TwoTanks_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoTanks abg tex

mtt -o TwoTanks sm tex
mtt -o TwoTanks tf tex

mtt -o TwoTanks smc tex
mtt -o TwoTanks ssk tex

mtt -o TwoTanks smo tex
mtt -o TwoTanks ssl tex


Deleted mttroot/mtt/lib/examples/Control/SimpleStateSpace/TwoTanks/TwoTanks_simp.r version [6a85134c77].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system TwoTanks (TwoTanks_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/RigidBar2D_abg.dia version [98ed84b855].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="2.7,9.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.65,9.6;46.95,22.25"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.7,9.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="44.200000000000003"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="12.550000000000001"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#b1a381"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="2.85,2.75"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.85,1.35;19.9,3.75"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Rigid 2-dimensional bar#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="2.85,2.75"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="0.4375,29.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.3875,29;9.87138,30.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="0.4375,29.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="9.3838834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="5.12944,30.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="4.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.1,19.2;6.2,21.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="5.15,20.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="1.40625,4.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.35625,4.05;8.90263,5.95711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1.40625,4.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.4463834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="5.12944,5.30355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="9.1,19.3"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.05,19.25;11.15,21.1571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="9.1,19.3"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="10.1,20.5036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="24.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.1,19.2;26.2,21.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25.15,20.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="39.05,19.2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39,19.15;41.1,21.0571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39.05,19.2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="40.05,20.4036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="44.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="44.1,19.2;46.2,21.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="44.15,19.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="45.15,20.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="39.95,29.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39.9,29.05;50.2589,30.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39.95,29.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="10.258883476483181"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="45.0794,30.3036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="40.9688,4.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="40.9188,4;49.3402,5.90711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="40.9688,4.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="8.3213834764831809"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="45.1295,5.25355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="8.55,10.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.5,10;11.8589,11.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="8.55,10.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.2588834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:a#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="10.1794,11.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="38.4,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.35,9.95;41.7089,11.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="38.4,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.2588834764831813"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:b#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="40.0294,11.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="24.6,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.55,9.95;26.65,11.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24.6,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25.6,11.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="16.15,14.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.1,14.4;24.5839,16.3071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="16.15,14.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="8.3838834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#I:translational#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="20.3419,15.6536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="27.35,15.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.3,15.1;34.2214,17.0071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="27.35,15.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.8213834764831818"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#I:rotational#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="30.7607,16.3536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a52a2a"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="22,29"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.95,28.95;28.1214,30.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="22,29"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.0713834764831853"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Se:weight#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25.0357,30.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="5.12944,29.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.05578,20.0061;6.34895,29.6561"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="5.12944,29.9536"/>
        <dia:point val="5.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O2" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="5.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.03673,4.85192;6.34932,19.852"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="5.15,20.1536"/>
        <dia:point val="5.12944,5.00355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O3" connection="0"/>
        <dia:connection handle="1" to="O4" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="5.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.59947,18.3087;9.71169,21.0281"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="5.15,20.1536"/>
        <dia:point val="10.1,20.2036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O3" connection="0"/>
        <dia:connection handle="1" to="O5" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="10.1,20.2036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.5498,18.3053;24.7616,21.0031"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="10.1,20.2036"/>
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O5" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.6215,14.2076;25.644,19.8711"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.15,20.1536"/>
        <dia:point val="20.3419,15.3536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O14" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="45.0794,30.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.0326,20.0122;46.3464,29.7122"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="45.0794,30.0036"/>
        <dia:point val="45.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O9" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="45.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.0367,4.80192;46.3493,19.852"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="45.15,20.1536"/>
        <dia:point val="45.1294,4.95355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="45.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="40.4384,18.2586;44.7005,20.9651"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="45.15,20.1536"/>
        <dia:point val="40.05,20.1036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O7" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="40.05,20.1036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.5384,18.2553;39.6002,20.9907"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="40.05,20.1036"/>
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O7" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="10.1,20.2036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.0539,10.8139;11.3751,19.9139"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="10.1,20.2036"/>
        <dia:point val="10.1794,10.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O5" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="10.1794,10.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.6292,9.05523;25.2116,11.7529"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="10.1794,10.9536"/>
        <dia:point val="25.6,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O13" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="25.6,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.8832,9.75738;31.2544,15.7745"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.6,10.9036"/>
        <dia:point val="30.7607,16.0536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O15" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="25.6,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.05,9.0536;39.641,11.7469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.6,10.9036"/>
        <dia:point val="40.0294,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O12" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O30">
      <dia:attribute name="obj_pos">
        <dia:point val="40.0294,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39.9557,10.7509;41.2489,19.8009"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="40.0294,10.9036"/>
        <dia:point val="40.05,20.1036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a52a2a"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O12" connection="0"/>
        <dia:connection handle="1" to="O7" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O31">
      <dia:attribute name="obj_pos">
        <dia:point val="24,24"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.95,23.95;26.05,25.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24,24"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="25,25.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#1e90ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O32">
      <dia:attribute name="obj_pos">
        <dia:point val="25.0357,29.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.9166,25.6986;26.2253,28.6413"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.0357,29.9036"/>
        <dia:point val="25,24.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O16" connection="0"/>
        <dia:connection handle="1" to="O31" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O33">
      <dia:attribute name="obj_pos">
        <dia:point val="25.15,20.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.9507,20.995;26.3035,23.6879"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="25.15,20.1536"/>
        <dia:point val="25,24.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#1e90ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O31" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/RigidBar2D_lbl.txt version [95bc109297].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY RigidBar2D
#DESCRIPTION A rigid bar capable of motion in two directions:
#DESCRIPTION vertical translation and rotation about its centre of gravity.
#DESCRIPTION Parameters "a" and "b" are moment arms,
#DESCRIPTION "m" is the bar's mass and "J" is a moment of inertia.

## System RigidBar2D, representation lbl, language txt
## File RigidBar2D_lbl.txt
## Generated by MTT on Thu Aug 12 21:04:24 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	left_bottom,right_bottom
#ALIAS	out	left_top,right_top

## Argument aliases
#ALIAS	$1	length_a
#ALIAS	$2	length_b
#ALIAS	$3	inertial_mass
#ALIAS	$4	moment_of_inertia

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[left_bottom]	SS		external,external
	[left_top]	SS		external,external
	[right_bottom]	SS		external,external
	[right_top]	SS		external,external

## Component type Se
	weight		SS		inertial_mass*gravity

## Component type I
	rotational	lin		flow,moment_of_inertia		
	translational	lin		flow,inertial_mass	

## Component type TF
	a		lin		flow,length_a		
	b		lin		flow,length_b		

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							
	# 1							
	# 1							

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_abg.dia version [97772ada2d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O0">
        <dia:attribute name="obj_pos">
          <dia:point val="5.16,4.215"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="5.11,4.165;49.41,16.815"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="5.16,4.215"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="44.200000000000003"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="12.550000000000001"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#b1a381"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O1">
          <dia:attribute name="obj_pos">
            <dia:point val="5.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="5.11,27.165;21.21,29.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O2">
          <dia:attribute name="obj_pos">
            <dia:point val="5.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="5.11,17.165;21.21,19.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O3">
          <dia:attribute name="obj_pos">
            <dia:point val="9.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09292,19.1479;9.22708,20.2821"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="9.16,19.215"/>
            <dia:point val="7.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O4">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,20.165;10.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,20.215"/>
            <dia:point val="10.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O5">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,20.1518;10.2232,21.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,20.215"/>
            <dia:point val="7.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O6">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,21.165;10.21,21.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,21.215"/>
            <dia:point val="10.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O7">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,26.165;10.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,26.215"/>
            <dia:point val="10.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O8">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,25.165;10.21,25.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,25.215"/>
            <dia:point val="10.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O9">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,24.165;10.21,24.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,24.215"/>
            <dia:point val="10.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O10">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,23.165;10.21,23.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,23.215"/>
            <dia:point val="10.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O11">
          <dia:attribute name="obj_pos">
            <dia:point val="7.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.11,22.165;10.21,22.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7.16,22.215"/>
            <dia:point val="10.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O12">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,25.1518;10.2232,26.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,25.215"/>
            <dia:point val="7.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O13">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,24.1518;10.2232,25.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,24.215"/>
            <dia:point val="7.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O14">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,23.1518;10.2232,24.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,23.215"/>
            <dia:point val="7.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O15">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,22.1518;10.2232,23.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,22.215"/>
            <dia:point val="7.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O16">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,21.1518;10.2232,22.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,21.215"/>
            <dia:point val="7.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O17">
          <dia:attribute name="obj_pos">
            <dia:point val="10.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="7.09675,26.1518;10.2232,27.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10.16,26.215"/>
            <dia:point val="7.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O18">
          <dia:attribute name="obj_pos">
            <dia:point val="17.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.11,20.165;19.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="17.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O19">
          <dia:attribute name="obj_pos">
            <dia:point val="18.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="18.11,26.165;18.21,27.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18.16,27.215"/>
            <dia:point val="18.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O18" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O20">
          <dia:attribute name="obj_pos">
            <dia:point val="18.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="18.11,19.165;18.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18.16,19.215"/>
            <dia:point val="18.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O18" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O21">
          <dia:attribute name="obj_pos">
            <dia:point val="33.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="33.11,27.165;49.21,29.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O22">
          <dia:attribute name="obj_pos">
            <dia:point val="33.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="33.11,17.165;49.21,19.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33.16,17.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O23">
          <dia:attribute name="obj_pos">
            <dia:point val="37.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0929,19.1479;37.2271,20.2821"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="37.16,19.215"/>
            <dia:point val="35.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O24">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,20.165;38.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,20.215"/>
            <dia:point val="38.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O25">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,20.1518;38.2232,21.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,20.215"/>
            <dia:point val="35.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O26">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,21.165;38.21,21.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,21.215"/>
            <dia:point val="38.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O27">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,26.165;38.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,26.215"/>
            <dia:point val="38.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O28">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,25.165;38.21,25.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,25.215"/>
            <dia:point val="38.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O29">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,24.165;38.21,24.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,24.215"/>
            <dia:point val="38.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O30">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,23.165;38.21,23.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,23.215"/>
            <dia:point val="38.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O31">
          <dia:attribute name="obj_pos">
            <dia:point val="35.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.11,22.165;38.21,22.265"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35.16,22.215"/>
            <dia:point val="38.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O32">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,25.1518;38.2232,26.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,25.215"/>
            <dia:point val="35.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O33">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,24.1518;38.2232,25.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,24.215"/>
            <dia:point val="35.16,25.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O34">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,23.1518;38.2232,24.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,23.215"/>
            <dia:point val="35.16,24.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O35">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,22.1518;38.2232,23.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,22.215"/>
            <dia:point val="35.16,23.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O36">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,21.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,21.1518;38.2232,22.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,21.215"/>
            <dia:point val="35.16,22.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O37">
          <dia:attribute name="obj_pos">
            <dia:point val="38.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="35.0968,26.1518;38.2232,27.2782"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38.16,26.215"/>
            <dia:point val="35.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O38">
          <dia:attribute name="obj_pos">
            <dia:point val="45.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.11,20.165;47.21,26.265"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="45.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O39">
          <dia:attribute name="obj_pos">
            <dia:point val="46.16,27.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="46.11,26.165;46.21,27.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46.16,27.215"/>
            <dia:point val="46.16,26.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O38" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O40">
          <dia:attribute name="obj_pos">
            <dia:point val="46.16,19.215"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="46.11,19.165;46.21,20.265"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46.16,19.215"/>
            <dia:point val="46.16,20.215"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O38" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O41">
        <dia:attribute name="obj_pos">
          <dia:point val="5,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="4.95,28.95;49.25,41.6"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="5,29"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="44.200000000000003"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="12.550000000000001"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#b1a381"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O42">
          <dia:attribute name="obj_pos">
            <dia:point val="5,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,51.95;21.05,54.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,52"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O43">
          <dia:attribute name="obj_pos">
            <dia:point val="5,42"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,41.95;21.05,44.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,42"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O44">
          <dia:attribute name="obj_pos">
            <dia:point val="9,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93292,43.9329;9.06708,45.0671"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="9,44"/>
            <dia:point val="7,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O45">
          <dia:attribute name="obj_pos">
            <dia:point val="7,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,44.95;10.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,45"/>
            <dia:point val="10,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O46">
          <dia:attribute name="obj_pos">
            <dia:point val="10,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,44.9368;10.0632,46.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,45"/>
            <dia:point val="7,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O47">
          <dia:attribute name="obj_pos">
            <dia:point val="7,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,45.95;10.05,46.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,46"/>
            <dia:point val="10,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O48">
          <dia:attribute name="obj_pos">
            <dia:point val="7,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,50.95;10.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,51"/>
            <dia:point val="10,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O49">
          <dia:attribute name="obj_pos">
            <dia:point val="7,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,49.95;10.05,50.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,50"/>
            <dia:point val="10,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O50">
          <dia:attribute name="obj_pos">
            <dia:point val="7,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,48.95;10.05,49.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,49"/>
            <dia:point val="10,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O51">
          <dia:attribute name="obj_pos">
            <dia:point val="7,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,47.95;10.05,48.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,48"/>
            <dia:point val="10,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O52">
          <dia:attribute name="obj_pos">
            <dia:point val="7,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,46.95;10.05,47.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,47"/>
            <dia:point val="10,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O53">
          <dia:attribute name="obj_pos">
            <dia:point val="10,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,49.9368;10.0632,51.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,50"/>
            <dia:point val="7,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O54">
          <dia:attribute name="obj_pos">
            <dia:point val="10,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,48.9368;10.0632,50.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,49"/>
            <dia:point val="7,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O55">
          <dia:attribute name="obj_pos">
            <dia:point val="10,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,47.9368;10.0632,49.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,48"/>
            <dia:point val="7,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O56">
          <dia:attribute name="obj_pos">
            <dia:point val="10,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,46.9368;10.0632,48.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,47"/>
            <dia:point val="7,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O57">
          <dia:attribute name="obj_pos">
            <dia:point val="10,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,45.9368;10.0632,47.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,46"/>
            <dia:point val="7,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O58">
          <dia:attribute name="obj_pos">
            <dia:point val="10,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,50.9368;10.0632,52.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,51"/>
            <dia:point val="7,52"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O59">
          <dia:attribute name="obj_pos">
            <dia:point val="17,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="16.95,44.95;19.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="17,45"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O60">
          <dia:attribute name="obj_pos">
            <dia:point val="18,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,50.95;18.05,52.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,52"/>
            <dia:point val="18,51"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O59" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O61">
          <dia:attribute name="obj_pos">
            <dia:point val="18,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,43.95;18.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,44"/>
            <dia:point val="18,45"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O59" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O62">
          <dia:attribute name="obj_pos">
            <dia:point val="33,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,51.95;49.05,54.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,52"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O63">
          <dia:attribute name="obj_pos">
            <dia:point val="33,42"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,41.95;49.05,44.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,42"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O64">
          <dia:attribute name="obj_pos">
            <dia:point val="37,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9329,43.9329;37.0671,45.0671"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="37,44"/>
            <dia:point val="35,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O65">
          <dia:attribute name="obj_pos">
            <dia:point val="35,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,44.95;38.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,45"/>
            <dia:point val="38,45"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O66">
          <dia:attribute name="obj_pos">
            <dia:point val="38,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,44.9368;38.0632,46.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,45"/>
            <dia:point val="35,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O67">
          <dia:attribute name="obj_pos">
            <dia:point val="35,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,45.95;38.05,46.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,46"/>
            <dia:point val="38,46"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O68">
          <dia:attribute name="obj_pos">
            <dia:point val="35,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,50.95;38.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,51"/>
            <dia:point val="38,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O69">
          <dia:attribute name="obj_pos">
            <dia:point val="35,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,49.95;38.05,50.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,50"/>
            <dia:point val="38,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O70">
          <dia:attribute name="obj_pos">
            <dia:point val="35,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,48.95;38.05,49.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,49"/>
            <dia:point val="38,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O71">
          <dia:attribute name="obj_pos">
            <dia:point val="35,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,47.95;38.05,48.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,48"/>
            <dia:point val="38,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O72">
          <dia:attribute name="obj_pos">
            <dia:point val="35,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,46.95;38.05,47.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,47"/>
            <dia:point val="38,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O73">
          <dia:attribute name="obj_pos">
            <dia:point val="38,50"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,49.9368;38.0632,51.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,50"/>
            <dia:point val="35,51"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O74">
          <dia:attribute name="obj_pos">
            <dia:point val="38,49"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,48.9368;38.0632,50.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,49"/>
            <dia:point val="35,50"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O75">
          <dia:attribute name="obj_pos">
            <dia:point val="38,48"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,47.9368;38.0632,49.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,48"/>
            <dia:point val="35,49"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O76">
          <dia:attribute name="obj_pos">
            <dia:point val="38,47"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,46.9368;38.0632,48.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,47"/>
            <dia:point val="35,48"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O77">
          <dia:attribute name="obj_pos">
            <dia:point val="38,46"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,45.9368;38.0632,47.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,46"/>
            <dia:point val="35,47"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O78">
          <dia:attribute name="obj_pos">
            <dia:point val="38,51"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,50.9368;38.0632,52.0632"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,51"/>
            <dia:point val="35,52"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O79">
          <dia:attribute name="obj_pos">
            <dia:point val="45,45"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="44.95,44.95;47.05,51.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="45,45"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O80">
          <dia:attribute name="obj_pos">
            <dia:point val="46,52"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,50.95;46.05,52.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,52"/>
            <dia:point val="46,51"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O79" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O81">
          <dia:attribute name="obj_pos">
            <dia:point val="46,44"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,43.95;46.05,45.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,44"/>
            <dia:point val="46,45"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O79" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O82">
        <dia:attribute name="obj_pos">
          <dia:point val="5,-21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="4.95,-21.05;49.25,-8.4"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="5,-21"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="44.200000000000003"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="12.550000000000001"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#b1a381"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O83">
          <dia:attribute name="obj_pos">
            <dia:point val="5,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,1.95;21.05,4.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,2"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O84">
          <dia:attribute name="obj_pos">
            <dia:point val="5,-8"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="4.95,-8.05;21.05,-5.95"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="5,-8"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O85">
          <dia:attribute name="obj_pos">
            <dia:point val="9,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93292,-6.06708;9.06708,-4.93292"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="9,-6"/>
            <dia:point val="7,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O86">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-5.05;10.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-5"/>
            <dia:point val="10,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O87">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-5.06325;10.0632,-3.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-5"/>
            <dia:point val="7,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O88">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-4.05;10.05,-3.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-4"/>
            <dia:point val="10,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O89">
          <dia:attribute name="obj_pos">
            <dia:point val="7,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,0.95;10.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,1"/>
            <dia:point val="10,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O90">
          <dia:attribute name="obj_pos">
            <dia:point val="7,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-0.05;10.05,0.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,0"/>
            <dia:point val="10,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O91">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-1.05;10.05,-0.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-1"/>
            <dia:point val="10,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O92">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-2.05;10.05,-1.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-2"/>
            <dia:point val="10,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O93">
          <dia:attribute name="obj_pos">
            <dia:point val="7,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.95,-3.05;10.05,-2.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="7,-3"/>
            <dia:point val="10,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O94">
          <dia:attribute name="obj_pos">
            <dia:point val="10,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-0.0632456;10.0632,1.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,0"/>
            <dia:point val="7,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O95">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-1.06325;10.0632,0.0632456"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-1"/>
            <dia:point val="7,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O96">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-2.06325;10.0632,-0.936754"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-2"/>
            <dia:point val="7,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O97">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-3.06325;10.0632,-1.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-3"/>
            <dia:point val="7,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O98">
          <dia:attribute name="obj_pos">
            <dia:point val="10,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,-4.06325;10.0632,-2.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,-4"/>
            <dia:point val="7,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O99">
          <dia:attribute name="obj_pos">
            <dia:point val="10,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="6.93675,0.936754;10.0632,2.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="10,1"/>
            <dia:point val="7,2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O100">
          <dia:attribute name="obj_pos">
            <dia:point val="17,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="16.95,-5.05;19.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="17,-5"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O101">
          <dia:attribute name="obj_pos">
            <dia:point val="18,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,0.95;18.05,2.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,2"/>
            <dia:point val="18,1"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O100" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O102">
          <dia:attribute name="obj_pos">
            <dia:point val="18,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="17.95,-6.05;18.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="18,-6"/>
            <dia:point val="18,-5"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O100" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
      <dia:group>
        <dia:object type="Standard - Box" version="0" id="O103">
          <dia:attribute name="obj_pos">
            <dia:point val="33,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,1.95;49.05,4.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,2"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O104">
          <dia:attribute name="obj_pos">
            <dia:point val="33,-8"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="32.95,-8.05;49.05,-5.95"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="33,-8"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="16"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O105">
          <dia:attribute name="obj_pos">
            <dia:point val="37,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9329,-6.06708;37.0671,-4.93292"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="37,-6"/>
            <dia:point val="35,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O106">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-5.05;38.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-5"/>
            <dia:point val="38,-5"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O107">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-5.06325;38.0632,-3.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-5"/>
            <dia:point val="35,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O108">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-4.05;38.05,-3.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-4"/>
            <dia:point val="38,-4"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O109">
          <dia:attribute name="obj_pos">
            <dia:point val="35,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,0.95;38.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,1"/>
            <dia:point val="38,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O110">
          <dia:attribute name="obj_pos">
            <dia:point val="35,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-0.05;38.05,0.05"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,0"/>
            <dia:point val="38,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O111">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-1.05;38.05,-0.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-1"/>
            <dia:point val="38,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O112">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-2.05;38.05,-1.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-2"/>
            <dia:point val="38,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O113">
          <dia:attribute name="obj_pos">
            <dia:point val="35,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.95,-3.05;38.05,-2.95"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="35,-3"/>
            <dia:point val="38,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O114">
          <dia:attribute name="obj_pos">
            <dia:point val="38,0"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-0.0632456;38.0632,1.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,0"/>
            <dia:point val="35,1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O115">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-1.06325;38.0632,0.0632456"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-1"/>
            <dia:point val="35,0"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O116">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-2.06325;38.0632,-0.936754"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-2"/>
            <dia:point val="35,-1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O117">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-3"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-3.06325;38.0632,-1.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-3"/>
            <dia:point val="35,-2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O118">
          <dia:attribute name="obj_pos">
            <dia:point val="38,-4"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,-4.06325;38.0632,-2.93675"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,-4"/>
            <dia:point val="35,-3"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - PolyLine" version="0" id="O119">
          <dia:attribute name="obj_pos">
            <dia:point val="38,1"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="34.9368,0.936754;38.0632,2.06325"/>
          </dia:attribute>
          <dia:attribute name="poly_points">
            <dia:point val="38,1"/>
            <dia:point val="35,2"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Box" version="0" id="O120">
          <dia:attribute name="obj_pos">
            <dia:point val="45,-5"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="44.95,-5.05;47.05,1.05"/>
          </dia:attribute>
          <dia:attribute name="elem_corner">
            <dia:point val="45,-5"/>
          </dia:attribute>
          <dia:attribute name="elem_width">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="elem_height">
            <dia:real val="6"/>
          </dia:attribute>
          <dia:attribute name="border_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:attribute name="show_background">
            <dia:boolean val="true"/>
          </dia:attribute>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O121">
          <dia:attribute name="obj_pos">
            <dia:point val="46,2"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,0.95;46.05,2.05"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,2"/>
            <dia:point val="46,1"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O120" connection="6"/>
          </dia:connections>
        </dia:object>
        <dia:object type="Standard - Line" version="0" id="O122">
          <dia:attribute name="obj_pos">
            <dia:point val="46,-6"/>
          </dia:attribute>
          <dia:attribute name="obj_bb">
            <dia:rectangle val="45.95,-6.05;46.05,-4.95"/>
          </dia:attribute>
          <dia:attribute name="conn_endpoints">
            <dia:point val="46,-6"/>
            <dia:point val="46,-5"/>
          </dia:attribute>
          <dia:attribute name="numcp">
            <dia:int val="1"/>
          </dia:attribute>
          <dia:attribute name="line_color">
            <dia:color val="#8b6914"/>
          </dia:attribute>
          <dia:connections>
            <dia:connection handle="1" to="O120" connection="1"/>
          </dia:connections>
        </dia:object>
      </dia:group>
    </dia:group>
    <dia:object type="Standard - Box" version="0" id="O123">
      <dia:attribute name="obj_pos">
        <dia:point val="-10,54"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-10.05,53.95;66.05,67.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-10,54"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="76"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="13"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#90ee90"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O124">
      <dia:attribute name="obj_pos">
        <dia:point val="4,-36"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4,-38.75;41.25,-34"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#A stack of supported bars#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="4,-36"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O125">
      <dia:attribute name="obj_pos">
        <dia:point val="4,33"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="3.95,32.95;49.6839,37.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4,33"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="45.633883476483177"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SupportedBar:bottom#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26.8169,36.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O126">
      <dia:attribute name="obj_pos">
        <dia:point val="4,-17"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="3.95,-17.05;49.6839,-12.1429"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4,-17"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="45.633883476483177"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SupportedBar:top#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26.8169,-13.9464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O127">
      <dia:attribute name="obj_pos">
        <dia:point val="2.125,8"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.075,7.95;51.5589,12.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.125,8"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="49.383883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SupportedBar:middle*3#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26.8169,11.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O128">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,35.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.7236,12.7011;28.0169,32.6561"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,35.4036"/>
        <dia:point val="26.8169,10.4036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O125" connection="0"/>
        <dia:connection handle="1" to="O127" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O129">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,10.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.7236,-14.7464;36.2669,10.1036"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,10.4036"/>
        <dia:point val="26.8169,-14.5964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[left_top,right_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[left_bottom,right_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O127" connection="0"/>
        <dia:connection handle="1" to="O126" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O130">
      <dia:attribute name="obj_pos">
        <dia:point val="-9.3125,58"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-9.3625,57.95;13.6839,62.0036"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-9.3125,58"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="22.946383476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:ground_left#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="2.16069,60.5536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O131">
      <dia:attribute name="obj_pos">
        <dia:point val="39,58"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.95,57.95;64.4339,62.0036"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39,58"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="25.383883476483188"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:ground_right#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="51.6919,60.5536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O132">
      <dia:attribute name="obj_pos">
        <dia:point val="51.6919,59.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.0983,34.2495;52.1777,59.6235"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="51.6919,59.9036"/>
        <dia:point val="26.8169,35.4036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[right_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O131" connection="0"/>
        <dia:connection handle="1" to="O125" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O133">
      <dia:attribute name="obj_pos">
        <dia:point val="5,-34"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.95,-34.05;24.2464,-29.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5,-34"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="19.196383476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:load_left#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="14.5982,-31.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O134">
      <dia:attribute name="obj_pos">
        <dia:point val="28,-34"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.95,-34.05;49.6839,-29.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="28,-34"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="21.633883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:load_right#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="38.8169,-31.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O135">
      <dia:attribute name="obj_pos">
        <dia:point val="16,-26"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.95,-26.05;18.9964,-21.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="16,-26"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.9463834764831822"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865462"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="17.4732,-23.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O136">
      <dia:attribute name="obj_pos">
        <dia:point val="35,-26"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="34.95,-26.05;37.9964,-21.9964"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="35,-26"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.9463834764831951"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="3"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="36.4732,-23.4464"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O137">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,-14.5964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.7141,-25.2314;30.1718,-14.8822"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,-14.5964"/>
        <dia:point val="17.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[left_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O126" connection="0"/>
        <dia:connection handle="1" to="O135" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O138">
      <dia:attribute name="obj_pos">
        <dia:point val="26.8169,-14.5964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.1026,-23.8555;36.9584,-13.8916"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26.8169,-14.5964"/>
        <dia:point val="36.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[right_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O126" connection="0"/>
        <dia:connection handle="1" to="O136" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O139">
      <dia:attribute name="obj_pos">
        <dia:point val="14.5982,-32.0964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.7033,-32.6817;18.4334,-24.2324"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="14.5982,-32.0964"/>
        <dia:point val="17.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O133" connection="0"/>
        <dia:connection handle="1" to="O135" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O140">
      <dia:attribute name="obj_pos">
        <dia:point val="38.8169,-32.0964"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="35.784,-31.9292;39.8279,-24.0389"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="38.8169,-32.0964"/>
        <dia:point val="36.4732,-24.0964"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O134" connection="0"/>
        <dia:connection handle="1" to="O136" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O141">
      <dia:attribute name="obj_pos">
        <dia:point val="2.16069,59.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.44465,35.6464;31.3581,60.6024"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="2.16069,59.9036"/>
        <dia:point val="26.8169,35.4036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[left_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O130" connection="0"/>
        <dia:connection handle="1" to="O125" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_input.txt version [e76dccd8b2].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System StackOfSupportedBars, representation input, language txt; 
## File StackOfSupportedBars_input.txt; 
## Generated by MTT on Fri Aug 13 02:22:37 BST 2004; 



StackOfSupportedBars__ground_left__u	= 0.0;			 # vertical velocity
StackOfSupportedBars__ground_right__u	= 0.0;			 # vertical velocity
StackOfSupportedBars__load_left		= 10.0 * (mttt > 5);	 # vertical load
StackOfSupportedBars__load_right	= 0.0;			 # vertical load

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_lbl.txt version [a98f24e28a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY StackOfSupportedBars
#DESCRIPTION A stack of rigid 2D bars supported by spring-dampers.
#DESCRIPTION The model demonstrates hierarchical modelling in dia
#DESCRIPTION including vector ports, repeated components and
#DESCRIPTION aliasing of parameters and ports.

## System StackOfSupportedBars, representation lbl, language txt
## File StackOfSupportedBars_lbl.txt
## Generated by MTT on Thu Aug 12 21:27:46 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	load_left	SS	external,external		
	load_right	SS	external,external		

## Component type Sf
	ground_left	SS	external		
	ground_right	SS	external		

## Component type SupportedBar
	bottom		none	a;b;m_b;J_b;R_d;K_s
	middle	  	none	a;b;m_b;J_b;R_d;K_s
	top		none	a;b;m_b;J_b;R_d;K_s

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							


Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/StackOfSupportedBars_numpar.txt version [f24ff30a96].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System StackOfSupportedBars, representation numpar, language txt; 
## File StackOfSupportedBars_numpar.txt; 
## Generated by MTT on Fri Aug 13 02:22:33 BST 2004; 



J_b	= 3.0e-3;		# bar's moment of inertia
K_s	= 1.0e3;		# spring's stiffness
R_d	= 1.0;			# damper's resistance
a	= 0.5;			# bar's half-length
b	= 0.5;			# bar's half-length
gravity	= 9,81;			# gravitational acceleration
m_b	= 5.0;			# bar's mass

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/Support_abg.dia version [fa88b774d8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291











































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="13,20"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.95,19.95;29.05,22.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="13,20"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="16"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="13,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.95,9.95;29.05,12.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="13,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="16"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="17,12"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9329,11.9329;17.0671,13.0671"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="17,12"/>
        <dia:point val="15,13"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="15,13"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,12.95;18.05,13.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,13"/>
        <dia:point val="18,13"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="18,13"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,12.9368;18.0632,14.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,13"/>
        <dia:point val="15,14"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="15,14"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,13.95;18.05,14.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,14"/>
        <dia:point val="18,14"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="15,19"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,18.95;18.05,19.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,19"/>
        <dia:point val="18,19"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="15,18"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,17.95;18.05,18.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,18"/>
        <dia:point val="18,18"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="15,17"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,16.95;18.05,17.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,17"/>
        <dia:point val="18,17"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="15,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,15.95;18.05,16.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,16"/>
        <dia:point val="18,16"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,14.95;18.05,15.05"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="15,15"/>
        <dia:point val="18,15"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="18,18"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,17.9368;18.0632,19.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,18"/>
        <dia:point val="15,19"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="18,17"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,16.9368;18.0632,18.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,17"/>
        <dia:point val="15,18"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="18,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,15.9368;18.0632,17.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,16"/>
        <dia:point val="15,17"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="18,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,14.9368;18.0632,16.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,15"/>
        <dia:point val="15,16"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="18,14"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,13.9368;18.0632,15.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,14"/>
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - PolyLine" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="18,19"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.9368,18.9368;18.0632,20.0632"/>
      </dia:attribute>
      <dia:attribute name="poly_points">
        <dia:point val="18,19"/>
        <dia:point val="15,20"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="25,13"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.95,12.95;27.05,19.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="25,13"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="6"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Line" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="26,20"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.95,18.95;26.05,20.05"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,20"/>
        <dia:point val="26,19"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="1" to="O17" connection="6"/>
      </dia:connections>
    </dia:object>
    <dia:object type="Standard - Line" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="26,12"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.95,11.95;26.05,13.05"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,12"/>
        <dia:point val="26,13"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#8b6914"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="1" to="O17" connection="1"/>
      </dia:connections>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="6,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="6,4.6;11.65,7"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Support#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="6,6"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="18.6831,25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.6331,24.95;23.367,26.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="18.6831,25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.6338834764831827"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[in]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,26.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="20,20"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.95,19.95;22.05,21.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20,20"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,21.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.95,14.95;17.05,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="16,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="25,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.95,14.95;27.05,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="25,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="26,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="20,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.95,9.95;22.05,11.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,11.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="18.3393,5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.2893,4.95;23.7107,6.85711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="18.3393,5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3213834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[out]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="21,6.20355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="5,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.95,14.95;10.4964,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.4463834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#C:spring#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="7.72319,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="31,15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="30.95,14.95;37.1214,16.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="31,15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.0713834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#R:damper#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="34.0357,16.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="21,25.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.9067,20.7536;22.2,25.6036"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,25.9036"/>
        <dia:point val="21,20.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O21" connection="0"/>
        <dia:connection handle="1" to="O22" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O30">
      <dia:attribute name="obj_pos">
        <dia:point val="21,20.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.2794,14.7586;21.495,20.6208"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,20.9036"/>
        <dia:point val="16,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O22" connection="0"/>
        <dia:connection handle="1" to="O23" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O31">
      <dia:attribute name="obj_pos">
        <dia:point val="16,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.2828,11.1476;21.495,16.5986"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="16,15.9036"/>
        <dia:point val="21,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O23" connection="0"/>
        <dia:connection handle="1" to="O25" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O32">
      <dia:attribute name="obj_pos">
        <dia:point val="21,10.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.9067,5.75355;22.2,10.6036"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,10.9036"/>
        <dia:point val="21,5.90355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O25" connection="0"/>
        <dia:connection handle="1" to="O26" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O33">
      <dia:attribute name="obj_pos">
        <dia:point val="21,20.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.2828,16.1476;26.495,21.5986"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="21,20.9036"/>
        <dia:point val="26,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O22" connection="0"/>
        <dia:connection handle="1" to="O24" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O34">
      <dia:attribute name="obj_pos">
        <dia:point val="26,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.2794,9.75863;26.495,15.6208"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,15.9036"/>
        <dia:point val="21,10.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O24" connection="0"/>
        <dia:connection handle="1" to="O25" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O35">
      <dia:attribute name="obj_pos">
        <dia:point val="16,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.11159,14.0536;15.55,16.7469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="16,15.9036"/>
        <dia:point val="7.72319,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O23" connection="0"/>
        <dia:connection handle="1" to="O27" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O36">
      <dia:attribute name="obj_pos">
        <dia:point val="26,15.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="26.45,14.0536;33.6473,16.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="26,15.9036"/>
        <dia:point val="34.0357,15.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O24" connection="0"/>
        <dia:connection handle="1" to="O28" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/Support_lbl.txt version [46cbbfd33f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Support
#DESCRIPTION Spring-damper support

## System Support, representation lbl, language txt
## File Support_lbl.txt
## Generated by MTT on Thu Aug 12 21:14:12 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases
#ALIAS	$1	resistance
#ALIAS	$2	stiffness

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[in]	  SS		external,external		
	[out]	  SS		external,external		

## Component type C
	spring	  lin		effort,1/stiffness		

## Component type R
	damper	  lin		flow,resistance		

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/SupportedBar_abg.dia version [084ff9aedc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513









































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="false"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Artwork" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="1,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.95,5.95;45.25,18.6"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="44.200000000000003"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="12.550000000000001"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#b1a381"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O1">
        <dia:attribute name="obj_pos">
          <dia:point val="1,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="0.95,28.95;17.05,31.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1,29"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O2">
        <dia:attribute name="obj_pos">
          <dia:point val="1,19"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="0.95,18.95;17.05,21.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1,19"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O3">
        <dia:attribute name="obj_pos">
          <dia:point val="5,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93292,20.9329;5.06708,22.0671"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="5,21"/>
          <dia:point val="3,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O4">
        <dia:attribute name="obj_pos">
          <dia:point val="3,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,21.95;6.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,22"/>
          <dia:point val="6,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O5">
        <dia:attribute name="obj_pos">
          <dia:point val="6,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,21.9368;6.06325,23.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,22"/>
          <dia:point val="3,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O6">
        <dia:attribute name="obj_pos">
          <dia:point val="3,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,22.95;6.05,23.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,23"/>
          <dia:point val="6,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O7">
        <dia:attribute name="obj_pos">
          <dia:point val="3,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,27.95;6.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,28"/>
          <dia:point val="6,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O8">
        <dia:attribute name="obj_pos">
          <dia:point val="3,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,26.95;6.05,27.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,27"/>
          <dia:point val="6,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O9">
        <dia:attribute name="obj_pos">
          <dia:point val="3,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,25.95;6.05,26.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,26"/>
          <dia:point val="6,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O10">
        <dia:attribute name="obj_pos">
          <dia:point val="3,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,24.95;6.05,25.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,25"/>
          <dia:point val="6,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O11">
        <dia:attribute name="obj_pos">
          <dia:point val="3,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.95,23.95;6.05,24.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="3,24"/>
          <dia:point val="6,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O12">
        <dia:attribute name="obj_pos">
          <dia:point val="6,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,26.9368;6.06325,28.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,27"/>
          <dia:point val="3,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O13">
        <dia:attribute name="obj_pos">
          <dia:point val="6,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,25.9368;6.06325,27.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,26"/>
          <dia:point val="3,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O14">
        <dia:attribute name="obj_pos">
          <dia:point val="6,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,24.9368;6.06325,26.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,25"/>
          <dia:point val="3,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O15">
        <dia:attribute name="obj_pos">
          <dia:point val="6,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,23.9368;6.06325,25.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,24"/>
          <dia:point val="3,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O16">
        <dia:attribute name="obj_pos">
          <dia:point val="6,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,22.9368;6.06325,24.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,23"/>
          <dia:point val="3,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O17">
        <dia:attribute name="obj_pos">
          <dia:point val="6,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.93675,27.9368;6.06325,29.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="6,28"/>
          <dia:point val="3,29"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O18">
        <dia:attribute name="obj_pos">
          <dia:point val="13,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="12.95,21.95;15.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="13,22"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="6"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O19">
        <dia:attribute name="obj_pos">
          <dia:point val="14,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="13.95,27.95;14.05,29.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="14,29"/>
          <dia:point val="14,28"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O18" connection="6"/>
        </dia:connections>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O20">
        <dia:attribute name="obj_pos">
          <dia:point val="14,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="13.95,20.95;14.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="14,21"/>
          <dia:point val="14,22"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O18" connection="1"/>
        </dia:connections>
      </dia:object>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O21">
        <dia:attribute name="obj_pos">
          <dia:point val="29,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="28.95,28.95;45.05,31.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="29,29"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O22">
        <dia:attribute name="obj_pos">
          <dia:point val="29,19"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="28.95,18.95;45.05,21.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="29,19"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="16"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O23">
        <dia:attribute name="obj_pos">
          <dia:point val="33,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9329,20.9329;33.0671,22.0671"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="33,21"/>
          <dia:point val="31,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O24">
        <dia:attribute name="obj_pos">
          <dia:point val="31,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,21.95;34.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,22"/>
          <dia:point val="34,22"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O25">
        <dia:attribute name="obj_pos">
          <dia:point val="34,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,21.9368;34.0632,23.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,22"/>
          <dia:point val="31,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O26">
        <dia:attribute name="obj_pos">
          <dia:point val="31,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,22.95;34.05,23.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,23"/>
          <dia:point val="34,23"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O27">
        <dia:attribute name="obj_pos">
          <dia:point val="31,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,27.95;34.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,28"/>
          <dia:point val="34,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O28">
        <dia:attribute name="obj_pos">
          <dia:point val="31,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,26.95;34.05,27.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,27"/>
          <dia:point val="34,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O29">
        <dia:attribute name="obj_pos">
          <dia:point val="31,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,25.95;34.05,26.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,26"/>
          <dia:point val="34,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O30">
        <dia:attribute name="obj_pos">
          <dia:point val="31,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,24.95;34.05,25.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,25"/>
          <dia:point val="34,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O31">
        <dia:attribute name="obj_pos">
          <dia:point val="31,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.95,23.95;34.05,24.05"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="31,24"/>
          <dia:point val="34,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O32">
        <dia:attribute name="obj_pos">
          <dia:point val="34,27"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,26.9368;34.0632,28.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,27"/>
          <dia:point val="31,28"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O33">
        <dia:attribute name="obj_pos">
          <dia:point val="34,26"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,25.9368;34.0632,27.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,26"/>
          <dia:point val="31,27"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O34">
        <dia:attribute name="obj_pos">
          <dia:point val="34,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,24.9368;34.0632,26.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,25"/>
          <dia:point val="31,26"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O35">
        <dia:attribute name="obj_pos">
          <dia:point val="34,24"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,23.9368;34.0632,25.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,24"/>
          <dia:point val="31,25"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O36">
        <dia:attribute name="obj_pos">
          <dia:point val="34,23"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,22.9368;34.0632,24.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,23"/>
          <dia:point val="31,24"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - PolyLine" version="0" id="O37">
        <dia:attribute name="obj_pos">
          <dia:point val="34,28"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.9368,27.9368;34.0632,29.0632"/>
        </dia:attribute>
        <dia:attribute name="poly_points">
          <dia:point val="34,28"/>
          <dia:point val="31,29"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O38">
        <dia:attribute name="obj_pos">
          <dia:point val="41,22"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="40.95,21.95;43.05,28.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="41,22"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="2"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="6"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O39">
        <dia:attribute name="obj_pos">
          <dia:point val="42,29"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="41.95,27.95;42.05,29.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="42,29"/>
          <dia:point val="42,28"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O38" connection="6"/>
        </dia:connections>
      </dia:object>
      <dia:object type="Standard - Line" version="0" id="O40">
        <dia:attribute name="obj_pos">
          <dia:point val="42,21"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="41.95,20.95;42.05,22.05"/>
        </dia:attribute>
        <dia:attribute name="conn_endpoints">
          <dia:point val="42,21"/>
          <dia:point val="42,22"/>
        </dia:attribute>
        <dia:attribute name="numcp">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="line_color">
          <dia:color val="#8b6914"/>
        </dia:attribute>
        <dia:connections>
          <dia:connection handle="1" to="O38" connection="1"/>
        </dia:connections>
      </dia:object>
    </dia:group>
    <dia:object type="Standard - Text" version="0" id="O41">
      <dia:attribute name="obj_pos">
        <dia:point val="1.205,1.87"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.205,0.47;11.505,2.87"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Supported bar#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="1.205,1.87"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O42">
      <dia:attribute name="obj_pos">
        <dia:point val="9.875,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.825,9.95;35.3089,13.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="9.875,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="25.383883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="3.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#RigidBar2D:bar#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="22.5669,12.3536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O43">
      <dia:attribute name="obj_pos">
        <dia:point val="2.03125,18.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.98125,18.45;15.2151,21.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.03125,18.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.133883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Support:left#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.59819,20.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O44">
      <dia:attribute name="obj_pos">
        <dia:point val="29.6563,18.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="29.6063,18.45;44.4652,21.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="29.6563,18.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="14.758883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="2.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Support:right#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.0357,20.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O45">
      <dia:attribute name="obj_pos">
        <dia:point val="3.8375,33.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="3.7875,33;13.2714,34.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="3.8375,33.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="9.3838834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.52944,34.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O46">
      <dia:attribute name="obj_pos">
        <dia:point val="5.40625,2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.35625,1.95;12.9026,3.85711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5.40625,2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.4463834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865467"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[left_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="9.12944,3.20355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O47">
      <dia:attribute name="obj_pos">
        <dia:point val="31.9,33.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="31.85,33.05;42.2089,34.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="31.9,33.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="10.258883476483179"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_bottom]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.0294,34.3036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O48">
      <dia:attribute name="obj_pos">
        <dia:point val="33.9688,2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="33.9188,1.95;42.3402,3.85711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="33.9688,2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="8.3213834764831809"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865467"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[right_top]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="38.1295,3.20355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O49">
      <dia:attribute name="obj_pos">
        <dia:point val="8.52944,33.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.48631,21.2001;9.78868,32.7055"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.52944,33.9536"/>
        <dia:point val="8.59819,19.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O45" connection="0"/>
        <dia:connection handle="1" to="O43" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O50">
      <dia:attribute name="obj_pos">
        <dia:point val="8.59819,19.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.96384,12.0405;26.7794,20.8964"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.59819,19.9036"/>
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[left_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O43" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O51">
      <dia:attribute name="obj_pos">
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.45587,1.53476;25.6693,11.6947"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="22.5669,11.9036"/>
        <dia:point val="9.12944,2.90355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[left_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O42" connection="0"/>
        <dia:connection handle="1" to="O46" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O52">
      <dia:attribute name="obj_pos">
        <dia:point val="37.0294,34.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.9416,21.2077;38.2348,32.7502"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.0294,34.0036"/>
        <dia:point val="37.0357,19.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O47" connection="0"/>
        <dia:connection handle="1" to="O44" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O53">
      <dia:attribute name="obj_pos">
        <dia:point val="37.0357,19.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.91,10.4454;37.1788,19.7296"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.0357,19.9036"/>
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[right_bottom]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O44" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O54">
      <dia:attribute name="obj_pos">
        <dia:point val="22.5669,11.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9314,3.04226;38.2973,12.8921"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="22.5669,11.9036"/>
        <dia:point val="38.1294,2.90355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="0.5"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[right_top]#</dia:string>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O42" connection="0"/>
        <dia:connection handle="1" to="O48" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/Mechanical-2D/StackOfSupportedBars/SupportedBar_lbl.txt version [cd511778a3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY SupportedBar
#DESCRIPTION Rigid 2D bar with two spring-damper supports.

## System SupportedBar, representation lbl, language txt
## File SupportedBar_lbl.txt
## Generated by MTT on Thu Aug 12 21:17:30 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	left_bottom,right_bottom
#ALIAS	out	left_top,right_top

## Argument aliases
#ALIAS	$1	length_a
#ALIAS	$2	length_b
#ALIAS	$3	inertial_mass
#ALIAS	$4	moment_of_inertia
#ALIAS	$5	resistance
#ALIAS	$6	stiffness

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	[left_bottom]	SS	external,external
	[left_top]	SS	external,external
	[right_bottom]	SS	external,external
	[right_top]	SS	external,external

## Component type RigidBar2D
	bar		none	length_a;length_b;inertial_mass;moment_of_inertia

## Component type Support
	left		none	resistance;stiffness
	right		none	resistance;stiffness

Deleted mttroot/mtt/lib/examples/Dia/doubleOscillator/diaOscillator_abg.dia version [5b84649c7c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
















































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="2,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.95,8.95;5.62138,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.5713834764831831"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865465"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[in]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="3.78569,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="12,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="11.95,8.95;14.05,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="12,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="13,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="11,2"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.95,1.95;14.9964,3.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="11,2"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.9463834764831822"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#I:inductance#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="12.9732,3.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="10,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.95,15.95;15.9339,17.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="10,16"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#R:resistance#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="12.9419,17.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="22,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.95,8.95;24.05,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="22,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="19.55,2.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.5,2;26.1714,3.70711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="19.55,2.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.5713834764831898"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#C:capacitance#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="22.8357,3.10355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="30,9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="29.95,8.95;34.2464,10.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="30,9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.1963834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[out]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="32.0982,10.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="3.78569,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.73569,7.95355;12.1116,10.6469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="3.78569,9.80355"/>
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O0" connection="0"/>
        <dia:connection handle="1" to="O1" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.8835,3.14895;14.1962,8.99896"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="13,9.80355"/>
        <dia:point val="12.9732,2.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O2" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.8564,10.1635;14.1917,16.0136"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="13,9.80355"/>
        <dia:point val="12.9419,16.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="13,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="13.95,7.95355;22.1116,10.6469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="13,9.80355"/>
        <dia:point val="23,9.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O4" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="23,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.7848,4.02881;24.1558,8.12156"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23,9.80355"/>
        <dia:point val="22.8357,2.85355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O4" connection="0"/>
        <dia:connection handle="1" to="O5" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="23,9.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.95,7.95355;31.2098,10.6469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23,9.80355"/>
        <dia:point val="32.0982,9.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O4" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/doubleOscillator/diaOscillator_lbl.txt version [880a7a089a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY diaOscillator
#DESCRIPTION Detailed description here

## System diaOscillator, representation lbl, language txt
## File diaOscillator_lbl.txt
## Generated by MTT on Thu Aug  5 00:44:20 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	capacitance
#ALIAS	$2	inductance
#ALIAS	$3	resistance

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type C
	capacitance	lin		effort,capacitance		

## Component type SS
	[in]		SS		external,external		

## Component type I
	inductance	lin		flow,inductance		

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type R
	resistance	lin		flow,resistance		

## Component type SS
	[out]		SS		external,external		

Deleted mttroot/mtt/lib/examples/Dia/doubleOscillator/doubleOscillator_abg.dia version [bff195aa42].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="2,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.95,5.95;4.99638,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.9463834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:in#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="3.47319,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="11,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.95,5.95;18.1214,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="11,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.0713834764831853"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811864905"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#diaOscillator:do#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="14.5357,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="24,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.95,5.95;31.1214,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="24,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="7.0713834764831791"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#xfigOscillator:xo#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="27.5357,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="37,6"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.95,5.95;40.6214,7.65711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="37,6"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.5713834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.6071067811865483"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:out#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="0.80000000000000004"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="38.7857,7.05355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="3.47319,6.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.42319,4.95355;13.6473,7.64685"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="3.47319,6.80355"/>
        <dia:point val="14.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O0" connection="0"/>
        <dia:connection handle="1" to="O1" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="14.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.4857,4.95355;26.6473,7.64685"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="14.5357,6.80355"/>
        <dia:point val="27.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O2" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="27.5357,6.80355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="28.4857,4.95355;37.8973,7.64685"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="27.5357,6.80355"/>
        <dia:point val="38.7857,6.80355"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O2" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/doubleOscillator/doubleOscillator_lbl.txt version [0873041d17].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY doubleOscillator
#DESCRIPTION Detailed description here

## System doubleOscillator, representation lbl, language txt
## File doubleOscillator_lbl.txt
## Generated by MTT on Thu Aug  5 00:44:56 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases
#ALIAS	$1	capacitance
#ALIAS	$2	inductance
#ALIAS	$3	resistance

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type diaOscillator
	do	lin		C_d;L_d;R_d

## Component type SS
	in	SS		external,external		

## Component type xfigOscillator
	xo	lin		C_x;L_x;R_x

## Component type SS
	out	SS		external,external		

Deleted mttroot/mtt/lib/examples/Dia/doubleOscillator/xfigOscillator_abg.fig version [3b0f42ccdb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2  Produced by xfig version 3.2.5-alpha5
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 720 3105 1620 3420
4 2 4 100 0 18 18 0.0000 4 270 900 1620 3330 SS:[in]\001
-6
6 1800 3150 3240 3465
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1845 3195 3195 3195 2970 3420
-6
6 3420 1530 3780 2970
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3465 2925 3465 1575 3690 1800
-6
6 3150 3510 3510 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3465 3555 3465 4905 3240 4680
-6
6 3780 3150 5220 3465
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 3195 5175 3195 4950 3420
-6
6 3420 3105 3600 3330
4 1 0 100 0 18 18 0.0000 4 195 150 3510 3330 1\001
-6
6 5310 3015 5490 3240
4 1 0 100 0 18 18 0.0000 4 195 150 5400 3240 0\001
-6
6 5400 1440 5760 2880
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5445 2835 5445 1485 5670 1710
-6
6 5670 3150 7110 3465
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 5715 3195 7065 3195 6840 3420
-6
6 7245 3105 8370 3420
4 0 4 100 0 18 18 0.0000 4 270 1095 7245 3330 SS:[out]\001
-6
6 2970 990 4050 1260
4 1 0 100 0 18 18 0.0000 4 210 1005 3510 1260 I:inductance\001
-6
6 4410 990 6480 1350
4 1 0 100 0 18 18 0.0000 4 270 1965 5445 1260 C:capacitance\001
-6
6 2610 5040 4410 5310
4 1 0 100 0 18 18 0.0000 4 210 1725 3510 5310 R:resistance\001
-6

Deleted mttroot/mtt/lib/examples/Dia/doubleOscillator/xfigOscillator_lbl.txt version [294f2256a6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY xfigOscillator
#DESCRIPTION Detailed description here

## System xfigOscillator, representation lbl, language txt
## File xfigOscillator_lbl.txt
## Generated by MTT on Thu Aug  5 00:41:52 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	capacitance
#ALIAS	$2	inductance
#ALIAS	$3	resistance

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							

## Component type 1 (anonymous => default parameters)
	# 1							

## Component type C
	capacitance	lin		effort,capacitance		

## Component type I
	inductance	lin		flow,inductance		

## Component type R
	resistance	lin		flow,resistance		

## Component type SS
	[in]		SS		external,external		
	[out]		SS		external,external		

Deleted mttroot/mtt/lib/examples/Dia/robotrain/make_trajectory.sh version [4193eb4c97].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
mtt -cc -no-reduce robotrain odeso ps
cd MTT_work
#set data style lines
cat <<EOF | gnuplot
set timestamp
set key left
set xlabel 'x'
set ylabel 'y'
set grid 
set title 'MTT model "robotrain": trajectory of trailer links'
plot   'robotrain_odes.dat2' using 4:5   title 'front'
replot 'robotrain_odes.dat2' using 8:9   title 'middle'
replot 'robotrain_odes.dat2' using 12:13 title 'rear'
set terminal postscript eps
set output "trajectory.ps"
replot
EOF
cd ..
cp MTT_work/trajectory.ps .
gv trajectory.ps

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_abg.dia version [b25c902b91].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O0">
        <dia:attribute name="obj_pos">
          <dia:point val="-19.4638,25.0343"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-19.5138,24.9843;-15.7138,25.9843"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-19.4638,25.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O1">
        <dia:attribute name="obj_pos">
          <dia:point val="-19.5338,9.06926"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-19.5838,9.01926;-15.7838,10.0193"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-19.5338,9.06926"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O2">
        <dia:attribute name="obj_pos">
          <dia:point val="-25.5138,10.0343"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-25.5638,9.98426;-9.66383,25.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-25.5138,10.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O3">
        <dia:attribute name="obj_pos">
          <dia:point val="-23.6138,7.18426"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-23.6638,7.13426;-11.5638,9.08426"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-23.6138,7.18426"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O4">
        <dia:attribute name="obj_pos">
          <dia:point val="-23.6131,25.9486"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-23.6631,25.8986;-11.5631,27.8486"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-23.6131,25.9486"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O5">
        <dia:attribute name="obj_pos">
          <dia:point val="-9.71383,16.0343"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-9.76383,15.9843;3.63617,17.9843"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-9.71383,16.0343"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O6">
        <dia:attribute name="obj_pos">
          <dia:point val="-38.8338,16.1193"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-38.8838,16.0693;-25.4838,18.0693"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-38.8338,16.1193"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O7">
        <dia:attribute name="obj_pos">
          <dia:point val="1.98617,16.4843"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="1.93617,16.4343;3.03617,17.5343"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1.98617,16.4843"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O8">
        <dia:attribute name="obj_pos">
          <dia:point val="-38.3138,16.5843"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="-38.3638,16.5343;-37.2638,17.6343"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="-38.3138,16.5843"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
    <dia:object type="Standard - Text" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="-38.601,4.96345"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-38.601,3.8797;-10.2172,6.28095"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Train of passive off-hooked trailers pulled by a tractor#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-38.601,4.96345"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O10">
        <dia:attribute name="obj_pos">
          <dia:point val="21.15,25"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="21.1,24.95;24.9,25.95"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="21.15,25"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O11">
        <dia:attribute name="obj_pos">
          <dia:point val="21.08,9.035"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="21.03,8.985;24.83,9.985"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="21.08,9.035"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O12">
        <dia:attribute name="obj_pos">
          <dia:point val="15.1,10"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="15.05,9.95;30.95,25"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="15.1,10"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O13">
        <dia:attribute name="obj_pos">
          <dia:point val="17,7.15"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="16.95,7.1;29.05,9.05"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="17,7.15"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O14">
        <dia:attribute name="obj_pos">
          <dia:point val="17.0007,25.9143"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="16.9507,25.8643;29.0507,27.8143"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="17.0007,25.9143"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O15">
        <dia:attribute name="obj_pos">
          <dia:point val="30.9,16"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="30.85,15.95;44.25,17.95"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="30.9,16"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O16">
        <dia:attribute name="obj_pos">
          <dia:point val="1.78,16.085"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="1.73,16.035;15.13,18.035"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="1.78,16.085"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O17">
        <dia:attribute name="obj_pos">
          <dia:point val="42.6,16.45"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="42.55,16.4;43.65,17.5"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="42.6,16.45"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O18">
        <dia:attribute name="obj_pos">
          <dia:point val="2.3,16.55"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="2.25,16.5;3.35,17.6"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="2.3,16.55"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O19">
        <dia:attribute name="obj_pos">
          <dia:point val="61.8543,24.9636"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="61.8043,24.9136;65.6043,25.9136"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="61.8543,24.9636"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O20">
        <dia:attribute name="obj_pos">
          <dia:point val="61.7843,8.99855"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="61.7343,8.94855;65.5343,9.94855"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="61.7843,8.99855"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O21">
        <dia:attribute name="obj_pos">
          <dia:point val="55.8043,9.96355"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="55.7543,9.91355;71.6543,24.9636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="55.8043,9.96355"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O22">
        <dia:attribute name="obj_pos">
          <dia:point val="57.7043,7.11355"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="57.6543,7.06355;69.7543,9.01355"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="57.7043,7.11355"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O23">
        <dia:attribute name="obj_pos">
          <dia:point val="57.705,25.8779"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="57.655,25.8279;69.755,27.7779"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="57.705,25.8779"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O24">
        <dia:attribute name="obj_pos">
          <dia:point val="71.6043,15.9636"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="71.5543,15.9136;84.9543,17.9136"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="71.6043,15.9636"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O25">
        <dia:attribute name="obj_pos">
          <dia:point val="42.4843,16.0486"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="42.4343,15.9986;55.8343,17.9986"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="42.4843,16.0486"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O26">
        <dia:attribute name="obj_pos">
          <dia:point val="83.3043,16.4136"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="83.2543,16.3636;84.3543,17.4636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="83.3043,16.4136"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O27">
        <dia:attribute name="obj_pos">
          <dia:point val="43.0043,16.5136"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="42.9543,16.4636;44.0543,17.5636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="43.0043,16.5136"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
    <dia:group>
      <dia:object type="Standard - Box" version="0" id="O28">
        <dia:attribute name="obj_pos">
          <dia:point val="102.295,24.8586"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="102.245,24.8086;106.045,25.8086"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="102.295,24.8586"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O29">
        <dia:attribute name="obj_pos">
          <dia:point val="102.225,8.89358"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="102.175,8.84358;105.975,9.84358"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="102.225,8.89358"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="3.6999999999999957"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="0.90000000000000213"/>
        </dia:attribute>
        <dia:attribute name="border_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O30">
        <dia:attribute name="obj_pos">
          <dia:point val="96.245,9.85858"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="96.195,9.80858;112.095,24.8586"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="96.245,9.85858"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="15.799999999999999"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="14.949999999999999"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O31">
        <dia:attribute name="obj_pos">
          <dia:point val="98.145,7.00858"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="98.095,6.95858;110.195,8.90858"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="98.145,7.00858"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O32">
        <dia:attribute name="obj_pos">
          <dia:point val="98.1457,25.7729"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="98.0957,25.7229;110.196,27.6729"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="98.1457,25.7729"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="12"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.8499999999999996"/>
        </dia:attribute>
        <dia:attribute name="inner_color">
          <dia:color val="#bfbfbf"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="corner_radius">
          <dia:real val="1.1754943508222875e-38"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Box" version="0" id="O33">
        <dia:attribute name="obj_pos">
          <dia:point val="82.925,15.9436"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="82.875,15.8936;96.275,17.8936"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="82.925,15.9436"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="13.299999999999997"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1.9000000000000021"/>
        </dia:attribute>
        <dia:attribute name="show_background">
          <dia:boolean val="true"/>
        </dia:attribute>
      </dia:object>
      <dia:object type="Standard - Ellipse" version="0" id="O34">
        <dia:attribute name="obj_pos">
          <dia:point val="83.696,16.4136"/>
        </dia:attribute>
        <dia:attribute name="obj_bb">
          <dia:rectangle val="83.646,16.3636;84.746,17.4636"/>
        </dia:attribute>
        <dia:attribute name="elem_corner">
          <dia:point val="83.696,16.4136"/>
        </dia:attribute>
        <dia:attribute name="elem_width">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="elem_height">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="aspect">
          <dia:enum val="2"/>
        </dia:attribute>
      </dia:object>
    </dia:group>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O35">
      <dia:attribute name="obj_pos">
        <dia:point val="85.5336,31.7414"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="85.4836,31.6914;116.405,36.895"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="85.5336,31.7414"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="30.821383476483206"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865431"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#tractor:tractor#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="100.944,34.945"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O36">
      <dia:attribute name="obj_pos">
        <dia:point val="48.5625,31.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="48.5125,31.45;74.1839,36.6536"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="48.5625,31.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="25.571383476483181"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#trailer:front#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="61.3482,34.7036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O37">
      <dia:attribute name="obj_pos">
        <dia:point val="-26.1285,31.6414"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-26.1785,31.5914;-2.19462,36.795"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-26.1285,31.6414"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="23.883883476483184"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#trailer:rear#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-14.1866,34.845"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O38">
      <dia:attribute name="obj_pos">
        <dia:point val="7.47476,31.4293"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.42476,31.3793;36.8461,36.5829"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="7.47476,31.4293"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="29.321383476483192"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="4.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#trailer:middle#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="4"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="22.1355,34.6329"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O39">
      <dia:attribute name="obj_pos">
        <dia:point val="100.944,34.145"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="62.1251,32.0597;100.045,34.855"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="100.944,34.145"/>
        <dia:point val="61.3482,33.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.20000000000000001"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O35" connection="0"/>
        <dia:connection handle="1" to="O36" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O40">
      <dia:attribute name="obj_pos">
        <dia:point val="61.3482,33.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9123,31.9846;60.4484,34.7738"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="61.3482,33.9036"/>
        <dia:point val="22.1355,33.8328"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.20000000000000001"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O36" connection="0"/>
        <dia:connection handle="1" to="O38" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O41">
      <dia:attribute name="obj_pos">
        <dia:point val="22.1355,33.8328"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-13.4099,31.9887;21.2361,34.9674"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="22.1355,33.8328"/>
        <dia:point val="-14.1866,34.045"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.20000000000000001"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O38" connection="0"/>
        <dia:connection handle="1" to="O37" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O42">
      <dia:attribute name="obj_pos">
        <dia:point val="-22.8801,23.9695"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-22.9301,23.9195;-18.8212,25.8266"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-22.8801,23.9695"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.0088834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811866759"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:Fx#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-20.8757,25.1731"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O43">
      <dia:attribute name="obj_pos">
        <dia:point val="-22.1529,41.1213"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-22.2029,41.0713;-18.094,42.9784"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-22.1529,41.1213"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.0088834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:Fy#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-20.1485,42.3249"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O44">
      <dia:attribute name="obj_pos">
        <dia:point val="-14.1866,34.045"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-20.3981,24.3239;-12.6063,33.7783"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="-14.1866,34.045"/>
        <dia:point val="-20.8757,24.873"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O37" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O45">
      <dia:attribute name="obj_pos">
        <dia:point val="-14.1866,34.045"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-19.6616,34.2973;-12.6238,42.142"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="-14.1866,34.045"/>
        <dia:point val="-20.1485,42.0249"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O37" connection="0"/>
        <dia:connection handle="1" to="O43" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_abg.ps version [2650070c06].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892




























































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%!PS-Adobe-2.0 EPSF-2.0
%%Title: robotrain_abg.dia
%%Creator: Dia v0.94
%%CreationDate: Tue Sep 14 20:01:52 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 4402 1118
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
38.883800 -42.978407 translate
%%EndProlog


0.749020 0.749020 0.749020 srgb
n -19.463800 25.034300 m -19.463800 25.934300 l -15.763800 25.934300 l -15.763800 25.034300 l f
n -19.463800 25.034300 m -19.463800 25.034300 0.000000 0.000000 180.000000 270.000000 ellipse f
n -15.763800 25.034300 m -15.763800 25.034300 0.000000 0.000000 270.000000 360.000000 ellipse f
n -19.463800 25.034300 m -19.463800 25.934300 l -15.763800 25.934300 l -15.763800 25.034300 l f
n -19.463800 25.934300 m -19.463800 25.934300 0.000000 0.000000 90.000000 180.000000 ellipse f
n -15.763800 25.934300 m -15.763800 25.934300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n -19.463800 25.034300 m -15.763800 25.034300 l s
n -19.463800 25.934300 m -15.763800 25.934300 l s
n -19.463800 25.034300 0.000000 0.000000 180.000000 270.000000 ellipse s
n -15.763800 25.034300 0.000000 0.000000 270.000000 360.000000 ellipse s
n -19.463800 25.034300 m -19.463800 25.934300 l s
n -15.763800 25.034300 m -15.763800 25.934300 l s
n -19.463800 25.934300 0.000000 0.000000 90.000000 180.000000 ellipse s
n -15.763800 25.934300 0.000000 0.000000 0.000000 90.000000 ellipse s
n -19.533800 9.069260 m -19.533800 9.969260 l -15.833800 9.969260 l -15.833800 9.069260 l f
n -19.533800 9.069260 m -19.533800 9.069260 0.000000 0.000000 180.000000 270.000000 ellipse f
n -15.833800 9.069260 m -15.833800 9.069260 0.000000 0.000000 270.000000 360.000000 ellipse f
n -19.533800 9.069260 m -19.533800 9.969260 l -15.833800 9.969260 l -15.833800 9.069260 l f
n -19.533800 9.969260 m -19.533800 9.969260 0.000000 0.000000 90.000000 180.000000 ellipse f
n -15.833800 9.969260 m -15.833800 9.969260 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n -19.533800 9.069260 m -15.833800 9.069260 l s
n -19.533800 9.969260 m -15.833800 9.969260 l s
n -19.533800 9.069260 0.000000 0.000000 180.000000 270.000000 ellipse s
n -15.833800 9.069260 0.000000 0.000000 270.000000 360.000000 ellipse s
n -19.533800 9.069260 m -19.533800 9.969260 l s
n -15.833800 9.069260 m -15.833800 9.969260 l s
n -19.533800 9.969260 0.000000 0.000000 90.000000 180.000000 ellipse s
n -15.833800 9.969260 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n -25.513800 10.034300 m -25.513800 24.984300 l -9.713800 24.984300 l -9.713800 10.034300 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -25.513800 10.034300 m -25.513800 24.984300 l -9.713800 24.984300 l -9.713800 10.034300 l cp s
0.749020 0.749020 0.749020 srgb
n -23.613800 7.184260 m -23.613800 9.034260 l -11.613800 9.034260 l -11.613800 7.184260 l f
n -23.613800 7.184260 m -23.613800 7.184260 0.000000 0.000000 180.000000 270.000000 ellipse f
n -11.613800 7.184260 m -11.613800 7.184260 0.000000 0.000000 270.000000 360.000000 ellipse f
n -23.613800 7.184260 m -23.613800 9.034260 l -11.613800 9.034260 l -11.613800 7.184260 l f
n -23.613800 9.034260 m -23.613800 9.034260 0.000000 0.000000 90.000000 180.000000 ellipse f
n -11.613800 9.034260 m -11.613800 9.034260 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -23.613800 7.184260 m -11.613800 7.184260 l s
n -23.613800 9.034260 m -11.613800 9.034260 l s
n -23.613800 7.184260 0.000000 0.000000 180.000000 270.000000 ellipse s
n -11.613800 7.184260 0.000000 0.000000 270.000000 360.000000 ellipse s
n -23.613800 7.184260 m -23.613800 9.034260 l s
n -11.613800 7.184260 m -11.613800 9.034260 l s
n -23.613800 9.034260 0.000000 0.000000 90.000000 180.000000 ellipse s
n -11.613800 9.034260 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n -23.613100 25.948600 m -23.613100 27.798600 l -11.613100 27.798600 l -11.613100 25.948600 l f
n -23.613100 25.948600 m -23.613100 25.948600 0.000000 0.000000 180.000000 270.000000 ellipse f
n -11.613100 25.948600 m -11.613100 25.948600 0.000000 0.000000 270.000000 360.000000 ellipse f
n -23.613100 25.948600 m -23.613100 27.798600 l -11.613100 27.798600 l -11.613100 25.948600 l f
n -23.613100 27.798600 m -23.613100 27.798600 0.000000 0.000000 90.000000 180.000000 ellipse f
n -11.613100 27.798600 m -11.613100 27.798600 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -23.613100 25.948600 m -11.613100 25.948600 l s
n -23.613100 27.798600 m -11.613100 27.798600 l s
n -23.613100 25.948600 0.000000 0.000000 180.000000 270.000000 ellipse s
n -11.613100 25.948600 0.000000 0.000000 270.000000 360.000000 ellipse s
n -23.613100 25.948600 m -23.613100 27.798600 l s
n -11.613100 25.948600 m -11.613100 27.798600 l s
n -23.613100 27.798600 0.000000 0.000000 90.000000 180.000000 ellipse s
n -11.613100 27.798600 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n -9.713830 16.034300 m -9.713830 17.934300 l 3.586170 17.934300 l 3.586170 16.034300 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -9.713830 16.034300 m -9.713830 17.934300 l 3.586170 17.934300 l 3.586170 16.034300 l cp s
1.000000 1.000000 1.000000 srgb
n -38.833800 16.119300 m -38.833800 18.019300 l -25.533800 18.019300 l -25.533800 16.119300 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n -38.833800 16.119300 m -38.833800 18.019300 l -25.533800 18.019300 l -25.533800 16.119300 l cp s
1.000000 1.000000 1.000000 srgb
n 2.486170 16.984300 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.486170 16.984300 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n -37.813800 17.084300 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n -37.813800 17.084300 0.500000 0.500000 0 360 ellipse cp s
/Helvetica-latin1 ff 1.400000 scf sf
(Train of passive off-hooked trailers pulled by a tractor) -38.601000 4.963450 m gs 1 -1 sc sh gr
0.749020 0.749020 0.749020 srgb
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.000000 m 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.850000 25.000000 m 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.900000 m 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.850000 25.900000 m 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.150000 25.000000 m 24.850000 25.000000 l s
n 21.150000 25.900000 m 24.850000 25.900000 l s
n 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.150000 25.000000 m 21.150000 25.900000 l s
n 24.850000 25.000000 m 24.850000 25.900000 l s
n 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.035000 m 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.780000 9.035000 m 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.935000 m 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.780000 9.935000 m 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.080000 9.035000 m 24.780000 9.035000 l s
n 21.080000 9.935000 m 24.780000 9.935000 l s
n 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l s
n 24.780000 9.035000 m 24.780000 9.935000 l s
n 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l cp s
0.749020 0.749020 0.749020 srgb
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 7.150000 m 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000000 7.150000 m 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 9.000000 m 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000000 9.000000 m 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000000 7.150000 m 29.000000 7.150000 l s
n 17.000000 9.000000 m 29.000000 9.000000 l s
n 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000000 7.150000 m 17.000000 9.000000 l s
n 29.000000 7.150000 m 29.000000 9.000000 l s
n 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 25.914300 m 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000700 25.914300 m 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 27.764300 m 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000700 27.764300 m 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000700 25.914300 m 29.000700 25.914300 l s
n 17.000700 27.764300 m 29.000700 27.764300 l s
n 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000700 25.914300 m 17.000700 27.764300 l s
n 29.000700 25.914300 m 29.000700 27.764300 l s
n 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l cp s
1.000000 1.000000 1.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l cp s
1.000000 1.000000 1.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse cp s
0.749020 0.749020 0.749020 srgb
n 61.854300 24.963600 m 61.854300 25.863600 l 65.554300 25.863600 l 65.554300 24.963600 l f
n 61.854300 24.963600 m 61.854300 24.963600 0.000000 0.000000 180.000000 270.000000 ellipse f
n 65.554300 24.963600 m 65.554300 24.963600 0.000000 0.000000 270.000000 360.000000 ellipse f
n 61.854300 24.963600 m 61.854300 25.863600 l 65.554300 25.863600 l 65.554300 24.963600 l f
n 61.854300 25.863600 m 61.854300 25.863600 0.000000 0.000000 90.000000 180.000000 ellipse f
n 65.554300 25.863600 m 65.554300 25.863600 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 61.854300 24.963600 m 65.554300 24.963600 l s
n 61.854300 25.863600 m 65.554300 25.863600 l s
n 61.854300 24.963600 0.000000 0.000000 180.000000 270.000000 ellipse s
n 65.554300 24.963600 0.000000 0.000000 270.000000 360.000000 ellipse s
n 61.854300 24.963600 m 61.854300 25.863600 l s
n 65.554300 24.963600 m 65.554300 25.863600 l s
n 61.854300 25.863600 0.000000 0.000000 90.000000 180.000000 ellipse s
n 65.554300 25.863600 0.000000 0.000000 0.000000 90.000000 ellipse s
n 61.784300 8.998550 m 61.784300 9.898550 l 65.484300 9.898550 l 65.484300 8.998550 l f
n 61.784300 8.998550 m 61.784300 8.998550 0.000000 0.000000 180.000000 270.000000 ellipse f
n 65.484300 8.998550 m 65.484300 8.998550 0.000000 0.000000 270.000000 360.000000 ellipse f
n 61.784300 8.998550 m 61.784300 9.898550 l 65.484300 9.898550 l 65.484300 8.998550 l f
n 61.784300 9.898550 m 61.784300 9.898550 0.000000 0.000000 90.000000 180.000000 ellipse f
n 65.484300 9.898550 m 65.484300 9.898550 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 61.784300 8.998550 m 65.484300 8.998550 l s
n 61.784300 9.898550 m 65.484300 9.898550 l s
n 61.784300 8.998550 0.000000 0.000000 180.000000 270.000000 ellipse s
n 65.484300 8.998550 0.000000 0.000000 270.000000 360.000000 ellipse s
n 61.784300 8.998550 m 61.784300 9.898550 l s
n 65.484300 8.998550 m 65.484300 9.898550 l s
n 61.784300 9.898550 0.000000 0.000000 90.000000 180.000000 ellipse s
n 65.484300 9.898550 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 55.804300 9.963550 m 55.804300 24.913550 l 71.604300 24.913550 l 71.604300 9.963550 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 55.804300 9.963550 m 55.804300 24.913550 l 71.604300 24.913550 l 71.604300 9.963550 l cp s
0.749020 0.749020 0.749020 srgb
n 57.704300 7.113550 m 57.704300 8.963550 l 69.704300 8.963550 l 69.704300 7.113550 l f
n 57.704300 7.113550 m 57.704300 7.113550 0.000000 0.000000 180.000000 270.000000 ellipse f
n 69.704300 7.113550 m 69.704300 7.113550 0.000000 0.000000 270.000000 360.000000 ellipse f
n 57.704300 7.113550 m 57.704300 8.963550 l 69.704300 8.963550 l 69.704300 7.113550 l f
n 57.704300 8.963550 m 57.704300 8.963550 0.000000 0.000000 90.000000 180.000000 ellipse f
n 69.704300 8.963550 m 69.704300 8.963550 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 57.704300 7.113550 m 69.704300 7.113550 l s
n 57.704300 8.963550 m 69.704300 8.963550 l s
n 57.704300 7.113550 0.000000 0.000000 180.000000 270.000000 ellipse s
n 69.704300 7.113550 0.000000 0.000000 270.000000 360.000000 ellipse s
n 57.704300 7.113550 m 57.704300 8.963550 l s
n 69.704300 7.113550 m 69.704300 8.963550 l s
n 57.704300 8.963550 0.000000 0.000000 90.000000 180.000000 ellipse s
n 69.704300 8.963550 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 57.705000 25.877900 m 57.705000 27.727900 l 69.705000 27.727900 l 69.705000 25.877900 l f
n 57.705000 25.877900 m 57.705000 25.877900 0.000000 0.000000 180.000000 270.000000 ellipse f
n 69.705000 25.877900 m 69.705000 25.877900 0.000000 0.000000 270.000000 360.000000 ellipse f
n 57.705000 25.877900 m 57.705000 27.727900 l 69.705000 27.727900 l 69.705000 25.877900 l f
n 57.705000 27.727900 m 57.705000 27.727900 0.000000 0.000000 90.000000 180.000000 ellipse f
n 69.705000 27.727900 m 69.705000 27.727900 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 57.705000 25.877900 m 69.705000 25.877900 l s
n 57.705000 27.727900 m 69.705000 27.727900 l s
n 57.705000 25.877900 0.000000 0.000000 180.000000 270.000000 ellipse s
n 69.705000 25.877900 0.000000 0.000000 270.000000 360.000000 ellipse s
n 57.705000 25.877900 m 57.705000 27.727900 l s
n 69.705000 25.877900 m 69.705000 27.727900 l s
n 57.705000 27.727900 0.000000 0.000000 90.000000 180.000000 ellipse s
n 69.705000 27.727900 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 71.604300 15.963600 m 71.604300 17.863600 l 84.904300 17.863600 l 84.904300 15.963600 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 71.604300 15.963600 m 71.604300 17.863600 l 84.904300 17.863600 l 84.904300 15.963600 l cp s
1.000000 1.000000 1.000000 srgb
n 42.484300 16.048600 m 42.484300 17.948600 l 55.784300 17.948600 l 55.784300 16.048600 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 42.484300 16.048600 m 42.484300 17.948600 l 55.784300 17.948600 l 55.784300 16.048600 l cp s
1.000000 1.000000 1.000000 srgb
n 83.804300 16.913600 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 83.804300 16.913600 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n 43.504300 17.013600 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 43.504300 17.013600 0.500000 0.500000 0 360 ellipse cp s
0.749020 0.749020 0.749020 srgb
n 102.295000 24.858600 m 102.295000 25.758600 l 105.995000 25.758600 l 105.995000 24.858600 l f
n 102.295000 24.858600 m 102.295000 24.858600 0.000000 0.000000 180.000000 270.000000 ellipse f
n 105.995000 24.858600 m 105.995000 24.858600 0.000000 0.000000 270.000000 360.000000 ellipse f
n 102.295000 24.858600 m 102.295000 25.758600 l 105.995000 25.758600 l 105.995000 24.858600 l f
n 102.295000 25.758600 m 102.295000 25.758600 0.000000 0.000000 90.000000 180.000000 ellipse f
n 105.995000 25.758600 m 105.995000 25.758600 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 102.295000 24.858600 m 105.995000 24.858600 l s
n 102.295000 25.758600 m 105.995000 25.758600 l s
n 102.295000 24.858600 0.000000 0.000000 180.000000 270.000000 ellipse s
n 105.995000 24.858600 0.000000 0.000000 270.000000 360.000000 ellipse s
n 102.295000 24.858600 m 102.295000 25.758600 l s
n 105.995000 24.858600 m 105.995000 25.758600 l s
n 102.295000 25.758600 0.000000 0.000000 90.000000 180.000000 ellipse s
n 105.995000 25.758600 0.000000 0.000000 0.000000 90.000000 ellipse s
n 102.225000 8.893580 m 102.225000 9.793580 l 105.925000 9.793580 l 105.925000 8.893580 l f
n 102.225000 8.893580 m 102.225000 8.893580 0.000000 0.000000 180.000000 270.000000 ellipse f
n 105.925000 8.893580 m 105.925000 8.893580 0.000000 0.000000 270.000000 360.000000 ellipse f
n 102.225000 8.893580 m 102.225000 9.793580 l 105.925000 9.793580 l 105.925000 8.893580 l f
n 102.225000 9.793580 m 102.225000 9.793580 0.000000 0.000000 90.000000 180.000000 ellipse f
n 105.925000 9.793580 m 105.925000 9.793580 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 102.225000 8.893580 m 105.925000 8.893580 l s
n 102.225000 9.793580 m 105.925000 9.793580 l s
n 102.225000 8.893580 0.000000 0.000000 180.000000 270.000000 ellipse s
n 105.925000 8.893580 0.000000 0.000000 270.000000 360.000000 ellipse s
n 102.225000 8.893580 m 102.225000 9.793580 l s
n 105.925000 8.893580 m 105.925000 9.793580 l s
n 102.225000 9.793580 0.000000 0.000000 90.000000 180.000000 ellipse s
n 105.925000 9.793580 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 96.245000 9.858580 m 96.245000 24.808580 l 112.045000 24.808580 l 112.045000 9.858580 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 96.245000 9.858580 m 96.245000 24.808580 l 112.045000 24.808580 l 112.045000 9.858580 l cp s
0.749020 0.749020 0.749020 srgb
n 98.145000 7.008580 m 98.145000 8.858580 l 110.145000 8.858580 l 110.145000 7.008580 l f
n 98.145000 7.008580 m 98.145000 7.008580 0.000000 0.000000 180.000000 270.000000 ellipse f
n 110.145000 7.008580 m 110.145000 7.008580 0.000000 0.000000 270.000000 360.000000 ellipse f
n 98.145000 7.008580 m 98.145000 8.858580 l 110.145000 8.858580 l 110.145000 7.008580 l f
n 98.145000 8.858580 m 98.145000 8.858580 0.000000 0.000000 90.000000 180.000000 ellipse f
n 110.145000 8.858580 m 110.145000 8.858580 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 98.145000 7.008580 m 110.145000 7.008580 l s
n 98.145000 8.858580 m 110.145000 8.858580 l s
n 98.145000 7.008580 0.000000 0.000000 180.000000 270.000000 ellipse s
n 110.145000 7.008580 0.000000 0.000000 270.000000 360.000000 ellipse s
n 98.145000 7.008580 m 98.145000 8.858580 l s
n 110.145000 7.008580 m 110.145000 8.858580 l s
n 98.145000 8.858580 0.000000 0.000000 90.000000 180.000000 ellipse s
n 110.145000 8.858580 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 98.145700 25.772900 m 98.145700 27.622900 l 110.145700 27.622900 l 110.145700 25.772900 l f
n 98.145700 25.772900 m 98.145700 25.772900 0.000000 0.000000 180.000000 270.000000 ellipse f
n 110.145700 25.772900 m 110.145700 25.772900 0.000000 0.000000 270.000000 360.000000 ellipse f
n 98.145700 25.772900 m 98.145700 27.622900 l 110.145700 27.622900 l 110.145700 25.772900 l f
n 98.145700 27.622900 m 98.145700 27.622900 0.000000 0.000000 90.000000 180.000000 ellipse f
n 110.145700 27.622900 m 110.145700 27.622900 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 98.145700 25.772900 m 110.145700 25.772900 l s
n 98.145700 27.622900 m 110.145700 27.622900 l s
n 98.145700 25.772900 0.000000 0.000000 180.000000 270.000000 ellipse s
n 110.145700 25.772900 0.000000 0.000000 270.000000 360.000000 ellipse s
n 98.145700 25.772900 m 98.145700 27.622900 l s
n 110.145700 25.772900 m 110.145700 27.622900 l s
n 98.145700 27.622900 0.000000 0.000000 90.000000 180.000000 ellipse s
n 110.145700 27.622900 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 82.925000 15.943600 m 82.925000 17.843600 l 96.225000 17.843600 l 96.225000 15.943600 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 82.925000 15.943600 m 82.925000 17.843600 l 96.225000 17.843600 l 96.225000 15.943600 l cp s
1.000000 1.000000 1.000000 srgb
n 84.196000 16.913600 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 84.196000 16.913600 0.500000 0.500000 0 360 ellipse cp s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(tractor:tractor) dup sw 2 div 100.944292 ex sub 34.944953 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(trailer:front) dup sw 2 div 61.348192 ex sub 34.703553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(trailer:rear) dup sw 2 div -14.186558 ex sub 34.844953 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 2.800000 scf sf
(trailer:middle) dup sw 2 div 22.135452 ex sub 34.632853 m gs 1 -1 sc sh gr
0.200000 slw
[] 0 sd
[] 0 sd
1 slc
n 84.483555 34.044647 m 75.184070 33.987952 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 75.184070 33.987952 m 76.478511 34.745857 l s
0.200000 slw
[] 0 sd
[] 0 sd
1 slc
n 47.512349 33.878619 m 37.845646 33.861165 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 37.845646 33.861165 m 39.143328 34.613509 l s
0.200000 slw
[] 0 sd
[] 0 sd
1 slc
n 6.428436 33.924563 m -1.194715 33.969099 l s
/Helvetica-latin1 ff 0.560000 scf sf
n -1.194715 33.969099 m 0.108682 34.711497 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:Fx) dup sw 2 div -20.875658 ex sub 25.173053 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:Fy) dup sw 2 div -20.148458 ex sub 42.324853 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n -16.559165 30.791773 m -19.592400 26.632642 l s
n -16.559165 30.791773 m -15.953196 30.349842 l s
n -16.559165 30.791773 m -17.165133 31.233703 l s
n -19.592400 26.632642 m -18.220986 27.240280 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n -16.618011 37.299401 m -18.837856 40.270626 l s
n -16.618011 37.299401 m -16.017180 37.748291 l s
n -16.618011 37.299401 m -17.218842 36.850512 l s
n -18.837856 40.270626 m -17.459526 39.678846 l s
showpage

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_desc.tex version [0e2575aeb0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system robotrain (robotrain_desc.tex)
% Generated by MTT on Sun Sep 12 20:03:30 BST 2004.

The acausal bond graph of system \textbf{robotrain} is
displayed in Figure \Ref{fig:robotrain_abg.ps}.
The model is based on an off-hooked design of a passive multiple
trailer system for indoor service robots
\footnote{{Jaehyoung Lee, Woojin Chung, Munsang Kim, Chongwon Lee and Jeabok-Song,
    A passive multiple trailer system for indoor service robots,
    \emph{Proceedings of the 2001 IEEE/RSJ International Conference on Intelligent Robots and Systems},
    Maui, Hawaii, USA, 2001}}
The equations of motion for each trailer are given by:
\begin{align}
  v_i &= v_{i-1}\cos \phi_i+D_{i-1}\dot\theta_{i-1}\sin \phi_i\\
  \dot\theta_i &= \frac{1}{L_i}\left(v_{i-1}\sin \phi_i+D_{i-1}\dot\theta_{i-1}\cos \phi_i\right)\\
  \phi_i &= \theta_{i-1}-\theta_i
\end{align}
where $v$ and $\dot\theta$ are the translational and rotational velocity of each trailer (in the body axis system), $L$ and $D$ are the lengths of the front and rear moment arms, and the subscripts $_i$ and $_{i-1}$ refer to any trailer and the one in front of it.

The label file is listed in Section \Ref{sec:robotrain_lbl} and the
subsystems are listed in Section \Ref{sec:robotrain_sub}.

\subsection{Trajectory}
The trajectory of each of the trailer hooks in response to a constant forward and rotational velocity is shown in figure \Ref{fig:trajectory.ps}. 
\fig{trajectory}{trajectory.ps}{0.9}{Trajectory of trailer links}
The plot was generated with the following script:
\footnotesize
\verbatiminput{make_trajectory.sh}
\normalsize

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_input.txt version [cac5b175aa].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System robotrain, representation input, language txt; 
## File robotrain_input.txt; 
## Generated by MTT on Fri Sep 10 00:39:34 BST 2004; 

robotrain__Fx			= 0.0;
robotrain__Fy			= 0.0;
robotrain__tractor__omega__u	= 1.0;
robotrain__tractor__v__u	= 1.0;

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_lbl.txt version [c96da6fc3e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY robotrain
#DESCRIPTION Detailed description here

## System robotrain, representation lbl, language txt
## File robotrain_lbl.txt
## Generated by MTT on Sun Sep 12 19:26:13 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases

## Argument aliases
#ALIAS	$1	D
#ALIAS	$2	L

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type SS
	Fx	SS		external,external		
	Fy	SS		external,external		

## Component type tractor
	tractor	lin		D

## Component type trailer
	front	lin		D;L
	middle	lin		D;L
	rear	lin		D;L

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_rep.pdf version [18154cee66].

cannot compute difference between binary files

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_rep.txt version [9f54dfcd22].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system robotrain (robotrain_rep.txt)
## Generated by MTT on" Sun Sep 12 20:02:40 BST 2004.

mtt robotrain abg tex			# The system description
#mtt robotrain cbg ps 		        # The causal bond graph
mtt robotrain struc tex	        # The system structure
mtt robotrain sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt robotrain dae tex	        # The system dae
## mtt robotrain ode tex	        # The system ode 
## mtt robotrain sspar tex		# Steady-state parameters
## mtt robotrain ss tex 		# Steady state
## mtt robotrain dm tex		# Descriptor matrices (of linearised system)
## mtt robotrain sm tex		# State matrices (of linearised system)
## mtt robotrain tf tex		# Transfer function (of linearised system)
## mtt robotrain lmfr ps		# log modulus of frequency response (of linearised system)
## mtt robotrain simpar txt		# Simulation parameters
## mtt robotrain numpar txt		# Numerical simulation parameters
mtt robotrain state txt		# Simulation initial state
mtt robotrain input txt		# Simulation input
## mtt robotrain logic txt		# Logic control
## mtt robotrain odeso ps		# Simulation output

## mtt robotrain rep txt		# This file

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_simpar.txt version [9624a81d99].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system robotrain (robotrain_simpar.txt)
# Generated by MTT on Sun Sep 12 18:45:47 BST 2004.

FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Dia/robotrain/robotrain_state.txt version [4f90410063].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System robotrain, representation state, language txt; 
## File robotrain_state.txt; 
## Generated by MTT on Sun Sep 12 18:46:40 BST 2004; 

robotrain__tractor__yaw__mttC	= 0.0;

robotrain__front__x_e__mttC	= -D;
robotrain__front__y_e__mttC	= 0.0;
robotrain__front__yaw__mttC	= 0.0;

robotrain__middle__x_e__mttC	= -(D+L+D);
robotrain__middle__y_e__mttC	= 0.0;
robotrain__middle__yaw__mttC	= 0.0;

robotrain__rear__x_e__mttC	= -(D+L+D+L+D);
robotrain__rear__y_e__mttC	= 0.0;
robotrain__rear__yaw__mttC	= 0.0;

Deleted mttroot/mtt/lib/examples/Dia/robotrain/rotate_z.cr version [b08e480b1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
operator rotate_z;

let rotate_z (R,~out_causality,1,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% x1
      x2*cos(psi)-y2*sin(psi);

let rotate_z (R,~out_causality,2,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% y1
      x2*sin(psi)+y2*sin(psi);

let rotate_z (R,~out_causality,3,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% x2
      x1*cos(psi)+y1*sin(psi);

let rotate_z (R,~out_causality,4,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% y2
      -x1*sin(psi)+y1*cos(psi);

let rotate_z (R,~out_causality,5,
   ~x1,~causality1,1,
   ~y1,~causality2,2,
   ~x2,~causality3,3,
   ~y2,~causality4,4,
   ~psi,~causality5,5) =>		% x1
      0;

;end;

Deleted mttroot/mtt/lib/examples/Dia/robotrain/rotate_z.pm version [3d31fd12d1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package rotate_z;

#-------------------------------------------------------------------------------
#		rotation of x-y plane about z
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&rotate_z);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub rotate_z_R(@);		# R

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub rotate_z (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    if (/^R|r$/)	{ $retval = rotate_z_R	(@args); }
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# R
#-------------------------------------------------------------------------------
sub rotate_z_R (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 18-1)
    {
	my ($component,
	    $out_causality, $out_port,
	    $x1, $causality1, $port1,
	    $y1, $causality2, $port2,
	    $x2, $causality3, $port3,
	    $y2, $causality4, $port4,
	    $psi, $causality5, $port5) = @args;

	# [ x2 ]   [ +cos(psi) +sin(psi) 0 ] [ x1 ]
	# [ y2 ] = [ -sin(psi) +cos(psi) 0 ] [ y1 ]
	# [ z2 ]   [    0          0     1 ] [ z1 ]

	# for reverse transformation (x2->x1) use psi=-psi
	# note that cos(-psi)=cos(psi) and sin(-psi)=-sin(psi)

	if ($out_port == 1)	# x1
	{
	    $retval = "(($x2)*(+cos($psi))+($y2)*(-sin($psi)))";
	}
	elsif ($out_port == 2)	# y1
	{
	    $retval = "(($x2)*(+sin($psi))+($y2)*(+cos($psi)))";
	}
	elsif ($out_port == 3)	# x2
	{
	    $retval = "(($x1)*(+cos($psi))+($y1)*(+sin($psi)))";
	}
	elsif ($out_port == 4)	# y2
	{
	    $retval = "(($x1)*(-sin($psi))+($y1)*(+cos($psi)))";
	}
	elsif ($out_port == 5)
	{
	    $retval = "(0)";
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true

Deleted mttroot/mtt/lib/examples/Dia/robotrain/rotation_abg.dia version [df991c37a8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:object type="Standard - Text" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="0.9,-1.0125"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.9,-2.4125;13,-0.0125"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Rotation about Z#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="0.9,-1.0125"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="2.14556,1.95"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.09556,1.9;7.57944,3.80711"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.14556,1.95"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3838834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x_1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="4.8375,3.10355"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="4.2875,22.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.2375,22.45;9.65888,24.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="4.2875,22.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3213834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y_1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="6.94819,23.6536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="33.6125,11.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="33.5625,11.05;39.0464,12.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="33.6125,11.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.3838834764832004"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865464"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x_2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="36.3044,12.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="15.75,-2.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.7,-2.1;21.1214,-0.192893"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.75,-2.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.321383476483188"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y_2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.4107,-0.896447"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="16.1562,24.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.1062,24.4;20.7776,26.3071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="16.1562,24.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.5713834764831827"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[psi]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.4419,25.6036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a020f0"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="15.3831,11.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.3331,11;21.567,12.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.3831,11.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.1338834764831853"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186546"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#R:rotation#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.45,12.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a020f0"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="4.8375,2.85355"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.06373,2.70029;10.6949,6.32361"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="4.8375,2.85355"/>
        <dia:point val="11.7419,7.36855"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O1" connection="0"/>
        <dia:connection handle="1" to="O9" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="27.1,11.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="27.05,11.05;28.7839,12.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="27.1,11.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="27.9169,12.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="10.925,6.465"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.875,6.415;12.6089,8.32211"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="10.925,6.465"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="11.7419,7.61855"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="12.025,16.615"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="11.975,16.565;13.7089,18.4721"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="12.025,16.615"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="12.8419,17.7686"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#0000ff"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="17.575,4.565"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.525,4.515;19.2589,6.42211"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.575,4.565"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831678"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865384"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.3919,5.71855"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#ff0000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="6.94819,23.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.53478,18.9813;12.1152,22.7979"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="6.94819,23.4036"/>
        <dia:point val="12.8419,17.5186"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O2" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="27.9169,12.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="29.7336,10.1536;32.6739,12.8469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="27.9169,12.0036"/>
        <dia:point val="36.3044,12.0036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O3" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="18.3919,5.46855"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.312,0.16061;19.6051,3.71831"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.3919,5.46855"/>
        <dia:point val="18.4107,-1.14645"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O4" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="11.7419,7.36855"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.498,6.29215;19.2016,11.4588"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="11.7419,7.36855"/>
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O9" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="12.8419,17.5186"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="13.481,12.5484;19.4854,17.866"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="12.8419,17.5186"/>
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#0000ff"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O10" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.3997,10.1089;27.0286,12.8344"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.45,11.9536"/>
        <dia:point val="27.9169,12.0036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[3]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="18.307,5.80776;20.541,11.1429"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.45,11.9536"/>
        <dia:point val="18.3919,5.46855"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#ff0000"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[4]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O6" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="17.3,17.8"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.25,17.75;19.6714,19.6571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.3,17.8"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="2.3213834764831809"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.80710678118655"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#AE#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.4607,18.9536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#a020f0"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="18.4419,25.3536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.6575,19.057;19.6579,24.557"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.4419,25.3536"/>
        <dia:point val="18.4607,18.7036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a020f0"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O5" connection="0"/>
        <dia:connection handle="1" to="O19" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="18.4607,18.7036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="17.657,12.3017;20.5516,17.9017"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.4607,18.7036"/>
        <dia:point val="18.45,11.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_color">
        <dia:color val="#a020f0"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[5]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O6" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/robotrain/rotation_abg.ps version [aeb5619686].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535























































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%!PS-Adobe-2.0 EPSF-2.0
%%Title: rotation_abg.dia
%%Creator: Dia v0.94+bondgraph
%%CreationDate: Sun Sep 12 21:15:37 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 1082 815
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
-0.900000 -26.307107 translate
%%EndProlog


/Helvetica-latin1 ff 1.400000 scf sf
0.000000 0.000000 0.000000 srgb
(Rotation about Z) 0.900000 -1.012500 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.000000 0.000000 1.000000 srgb
(SS:[x_1]) dup sw 2 div 4.837502 ex sub 3.103553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(SS:[y_1]) dup sw 2 div 6.948192 ex sub 23.653553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
1.000000 0.000000 0.000000 srgb
(SS:[x_2]) dup sw 2 div 36.304442 ex sub 12.253553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(SS:[y_2]) dup sw 2 div 18.410692 ex sub -0.896447 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.627451 0.125490 0.941176 srgb
(SS:[psi]) dup sw 2 div 18.441892 ex sub 25.603553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(R:rotation) dup sw 2 div 18.450042 ex sub 12.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
0.000000 0.000000 1.000000 srgb
n 7.132941 4.354610 m 10.038120 6.254396 l s
n 10.038120 6.254396 m 8.540433 6.171136 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
1.000000 0.000000 0.000000 srgb
(0) dup sw 2 div 27.916942 ex sub 12.253553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.000000 0.000000 1.000000 srgb
(0) dup sw 2 div 11.741942 ex sub 7.618553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(0) dup sw 2 div 12.841942 ex sub 17.768553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
1.000000 0.000000 0.000000 srgb
(0) dup sw 2 div 18.391942 ex sub 5.718553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
0.000000 0.000000 1.000000 srgb
n 8.605490 21.748750 m 11.267337 19.090836 l s
n 11.267337 19.090836 m 10.878037 20.539437 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
1.000000 0.000000 0.000000 srgb
n 29.783602 12.003600 m 32.563514 12.003600 l s
n 32.563514 12.003600 m 31.264476 12.753600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.397452 3.514902 m 18.405148 0.807198 l s
n 18.405148 0.807198 m 19.151453 2.108362 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
0.000000 0.000000 1.000000 srgb
n 13.434240 8.525280 m 16.232361 10.437823 l s
n 16.232361 10.437823 m 14.736688 10.323972 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 14.418753 15.953866 m 16.780386 13.610382 l s
n 16.780386 13.610382 m 16.386571 15.057763 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
1.000000 0.000000 0.000000 srgb
n 22.566713 11.975343 m 26.049616 11.993738 l s
n 26.049616 11.993738 m 24.746634 12.736867 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.432499 10.000119 m 18.409401 7.422031 l s
n 18.409401 7.422031 m 19.171009 8.714298 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
0.627451 0.125490 0.941176 srgb
(AE) dup sw 2 div 18.460692 ex sub 18.953553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.447422 23.400183 m 18.455178 20.657017 l s
n 18.455178 20.657017 m 19.201502 21.958170 l s
n 18.455178 20.657017 m 17.701508 21.953930 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 18.457604 16.750263 m 18.453096 13.906937 l s
n 18.453096 13.906937 m 19.205155 15.204785 l s
n 18.453096 13.906937 m 17.705157 15.207163 l s
showpage

Deleted mttroot/mtt/lib/examples/Dia/robotrain/rotation_desc.tex version [585cc1ed33].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system rotation (rotation_desc.tex)
% Generated by MTT on Sun Sep 12 22:06:34 BST 2004.

The acausal bond graph of system \textbf{rotation} is
displayed in Figure \Ref{fig:rotation_abg.ps}  
.
The label file is listed in Section \Ref{sec:rotation_lbl} and the
subsystems are listed in Section \Ref{sec:rotation_sub}.

\subsubsection{rotate\_z constitutive relationship}
The rotation between body and Earth axes is achieved using the ``rotate\_z'' constitutive relationship which is implemented as a Reduce file (.cr) and a Perl module (.pm) to permit the model to be built with or without MTT's -no-reduce option.

\paragraph{rotate\_z.cr}
\footnotesize
\verbatiminput{rotate_z.cr}
\normalsize

\paragraph{rotate\_z.pm}
\footnotesize
\verbatiminput{rotate_z.pm}
\normalsize

Deleted mttroot/mtt/lib/examples/Dia/robotrain/rotation_lbl.txt version [6ff5537fca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY rotation
#DESCRIPTION Detailed description here

## System rotation, representation lbl, language txt
## File rotation_lbl.txt
## Generated by MTT on Tue Sep  7 16:59:01 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	x_earth,y_earth
#ALIAS	out	x_body,y_body

## Argument aliases

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 0 (anonymous => default parameters)
	# 0							
	# 0							
	# 0							
	# 0							
	# 0							

## Component type AF (anonymous => default parameters)
	# AF							

## Component type R
	rotation	rotate_z

## Component type SS
	[psi]		SS	external,external		
	[x_body]	SS	external,external		
	[x_earth]	SS	external,external		
	[y_body]	SS	external,external		
	[y_earth]	SS	external,external		

Deleted mttroot/mtt/lib/examples/Dia/robotrain/tractor_abg.dia version [68d89c2e44].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458


















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.1,24.95;24.9,25.95"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.03,8.985;24.83,9.985"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.05,9.95;30.95,25"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="15.799999999999999"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="14.949999999999999"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.95,7.1;29.05,9.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.9507,25.8643;29.0507,27.8143"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.73,16.035;15.13,18.035"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.299999999999997"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.9000000000000021"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Ellipse" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.25,16.5;3.35,17.6"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="aspect">
        <dia:enum val="2"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="-3.80407,8.9651"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-3.80407,7.5651;1.24593,9.9651"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Tractor#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-3.80407,8.9651"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="5.15,34.9"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.1,34.85;11.8339,36.7571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5.15,34.9"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.6338834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#rotation:z2#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.46694,36.0536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="14.25,42.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.2,42.4;17.7464,44.3071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="14.25,42.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831915"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865451"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:D#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="15.9732,43.6536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="-5,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-5.05,34.95;-0.128617,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-5,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-2.58931,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.95,27.95;10.8714,29.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.41069,29.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,34.95;24.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="23.4,50.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.35,50.6;25.0839,52.5071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23.4,50.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="24.2169,51.8536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.7216,33.9821;22.0006,36.6842"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,35.9036"/>
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[x_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O12" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="24.2169,51.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.6078,42.558;24.3542,50.9191"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.2169,51.5536"/>
        <dia:point val="15.9732,43.3536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O9" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="15.9732,43.3536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="10.0103,35.9701;15.1712,41.7617"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="15.9732,43.3536"/>
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[y_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O9" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="0.759721,33.9931;5.58945,36.7033"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.46694,35.8036"/>
        <dia:point val="-2.58931,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.60063,30.1977;11.151,34.04"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.46694,35.8036"/>
        <dia:point val="8.41069,28.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O8" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="32,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="31.95,34.95;35.1839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="32,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.1338834764831893"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:v#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="33.5669,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="30.45,50.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="30.4,50.6;36.4464,52.5071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="30.45,50.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.9463834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Sf:omega#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="33.4232,51.8536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="21.25,46.25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.2,46.2;27.1839,48.1071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.25,46.25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831889"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:yaw#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="24.1919,47.4536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="24.2169,51.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.4085,47.4968;25.4112,50.7468"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.2169,51.5536"/>
        <dia:point val="24.1919,47.1536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O21" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="23.4,42"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.35,41.95;25.0839,43.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23.4,42"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.633883476483186"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="24.2169,43.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="24.1919,47.1536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.4066,43.2606;25.411,46.3607"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.1919,47.1536"/>
        <dia:point val="24.2169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O21" connection="0"/>
        <dia:connection handle="1" to="O23" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="18.2857,39.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.05839,34.4316;17.8253,39.551"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.2857,39.9036"/>
        <dia:point val="8.46694,35.8036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[psi]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O28" connection="0"/>
        <dia:connection handle="1" to="O8" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="33.5669,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.7053,34.0536;32.6169,36.7469"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="33.5669,35.9036"/>
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O12" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="33.4232,51.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="25.1053,49.7036;32.4732,52.3969"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="33.4232,51.5536"/>
        <dia:point val="24.2169,51.5536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O20" connection="0"/>
        <dia:connection handle="1" to="O13" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="14.8437,39"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="14.7937,38.95;21.7776,40.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="14.8437,39"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.8838834764831871"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#AE:negative#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="0" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.2856,40.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="24.2169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.1267,38.6341;23.8662,42.4858"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="24.2169,42.9036"/>
        <dia:point val="18.2857,39.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O23" connection="0"/>
        <dia:connection handle="1" to="O28" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/robotrain/tractor_abg.ps version [9f0629015e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642


































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%!PS-Adobe-2.0 EPSF-2.0
%%Title: tractor_abg.dia
%%Creator: Dia v0.94+bondgraph
%%CreationDate: Sun Sep 12 21:15:57 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 1177 1288
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
5.050000 -52.507107 translate
%%EndProlog


0.749020 0.749020 0.749020 srgb
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.000000 m 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.850000 25.000000 m 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.900000 m 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.850000 25.900000 m 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.150000 25.000000 m 24.850000 25.000000 l s
n 21.150000 25.900000 m 24.850000 25.900000 l s
n 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.150000 25.000000 m 21.150000 25.900000 l s
n 24.850000 25.000000 m 24.850000 25.900000 l s
n 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.035000 m 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.780000 9.035000 m 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.935000 m 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.780000 9.935000 m 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.080000 9.035000 m 24.780000 9.035000 l s
n 21.080000 9.935000 m 24.780000 9.935000 l s
n 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l s
n 24.780000 9.035000 m 24.780000 9.935000 l s
n 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l cp s
0.749020 0.749020 0.749020 srgb
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 7.150000 m 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000000 7.150000 m 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 9.000000 m 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000000 9.000000 m 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000000 7.150000 m 29.000000 7.150000 l s
n 17.000000 9.000000 m 29.000000 9.000000 l s
n 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000000 7.150000 m 17.000000 9.000000 l s
n 29.000000 7.150000 m 29.000000 9.000000 l s
n 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 25.914300 m 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000700 25.914300 m 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 27.764300 m 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000700 27.764300 m 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000700 25.914300 m 29.000700 25.914300 l s
n 17.000700 27.764300 m 29.000700 27.764300 l s
n 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000700 25.914300 m 17.000700 27.764300 l s
n 29.000700 25.914300 m 29.000700 27.764300 l s
n 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l cp s
1.000000 1.000000 1.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse cp s
/Helvetica-latin1 ff 1.400000 scf sf
(Tractor) -3.804070 8.965100 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(rotation:z2) dup sw 2 div 8.466942 ex sub 36.053553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(TF:D) dup sw 2 div 15.973192 ex sub 43.653553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[x2]) dup sw 2 div -2.589308 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[y2]) dup sw 2 div 8.410692 ex sub 29.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 23.816942 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 24.216942 ex sub 51.853553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 21.950301 35.891440 m 12.833155 35.832044 l s
n 12.833155 35.832044 m 14.127279 36.590491 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.641483 49.986534 m 17.640695 45.012255 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 17.640695 45.012255 m 18.032772 46.460107 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 14.320247 41.691015 m 10.119893 37.466185 l s
n 10.119893 37.466185 m 11.567648 37.858621 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 4.100304 35.843095 m 0.871380 35.872299 l s
n 4.100304 35.843095 m 4.107087 36.593064 l s
n 4.100304 35.843095 m 4.093521 35.093125 l s
n 0.871380 35.872299 m 2.177148 36.610520 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 8.451012 33.849745 m 8.426618 30.857455 l s
n 8.451012 33.849745 m 9.200987 33.843631 l s
n 8.451012 33.849745 m 7.701037 33.855859 l s
n 8.426618 30.857455 m 9.187183 32.150336 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Sf:v) dup sw 2 div 33.566942 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Sf:omega) dup sw 2 div 33.423192 ex sub 51.853553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF:yaw) dup sw 2 div 24.191942 ex sub 47.453553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 24.205823 49.604007 m 24.202977 49.103193 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 24.202977 49.103193 m 24.960346 50.397949 l s
n 24.202977 49.103193 m 23.460370 50.406472 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(0) dup sw 2 div 24.216942 ex sub 43.203553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 24.203373 45.203178 m 24.205412 44.856616 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 24.205412 44.856616 m 24.947757 46.160043 l s
n 24.205412 44.856616 m 23.447783 46.151220 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 15.079625 38.564846 m 11.673015 37.142354 l s
n 11.673015 37.142354 m 12.582750 38.334991 l s
n 11.673015 37.142354 m 13.160736 36.950819 l s
n 11.673015 37.142354 m 11.384022 37.834440 l s
n 11.673015 37.142354 m 11.962008 36.450268 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 30.950033 35.903600 m 25.683950 35.903600 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 25.683950 35.903600 m 26.982988 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 29.399573 51.553600 m 26.082238 51.553600 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 26.082238 51.553600 m 27.381276 52.303600 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(AE:negative) dup sw 2 div 18.285642 ex sub 40.153553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.457897 42.013896 m 21.061956 41.307830 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 21.061956 41.307830 m 21.882638 42.563410 l s
n 21.061956 41.307830 m 22.559662 41.224889 l s
showpage

Deleted mttroot/mtt/lib/examples/Dia/robotrain/tractor_lbl.txt version [9aa5974a3e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY tractor
#DESCRIPTION Detailed description here

## System tractor, representation lbl, language txt
## File tractor_lbl.txt
## Generated by MTT on Wed Sep  8 00:42:45 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	out	x2,y2

## Argument aliases
#ALIAS	$1	D

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							
	# 1							

## Component type AE
	negative  lin		effort,-1

## Component type INTF
	yaw	  none				

## Component type SS
	[x2]	  SS		external,external		
	[y2]	  SS		external,external		

## Component type Sf
	omega	  SS		external		
	v	  SS		external		

## Component type TF
	D	  lin		flow,-D		

## Component type rotation
	z2	  rotate_z		

Deleted mttroot/mtt/lib/examples/Dia/robotrain/trailer_abg.dia version [39ca1b3683].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
  <dia:diagramdata>
    <dia:attribute name="background">
      <dia:color val="#ffffff"/>
    </dia:attribute>
    <dia:attribute name="pagebreak">
      <dia:color val="#000099"/>
    </dia:attribute>
    <dia:attribute name="paper">
      <dia:composite type="paper">
        <dia:attribute name="name">
          <dia:string>#A4#</dia:string>
        </dia:attribute>
        <dia:attribute name="tmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="bmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="lmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="rmargin">
          <dia:real val="2.8222000598907471"/>
        </dia:attribute>
        <dia:attribute name="is_portrait">
          <dia:boolean val="true"/>
        </dia:attribute>
        <dia:attribute name="scaling">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="fitto">
          <dia:boolean val="false"/>
        </dia:attribute>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="grid">
      <dia:composite type="grid">
        <dia:attribute name="width_x">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="width_y">
          <dia:real val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_x">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:attribute name="visible_y">
          <dia:int val="1"/>
        </dia:attribute>
        <dia:composite type="color"/>
      </dia:composite>
    </dia:attribute>
    <dia:attribute name="color">
      <dia:color val="#d8e5e5"/>
    </dia:attribute>
    <dia:attribute name="guides">
      <dia:composite type="guides">
        <dia:attribute name="hguides"/>
        <dia:attribute name="vguides"/>
      </dia:composite>
    </dia:attribute>
  </dia:diagramdata>
  <dia:layer name="Background" visible="true">
    <dia:object type="Standard - Box" version="0" id="O0">
      <dia:attribute name="obj_pos">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.1,24.95;24.9,25.95"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.15,25"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O1">
      <dia:attribute name="obj_pos">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.03,8.985;24.83,9.985"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.08,9.035"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.6999999999999957"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="0.90000000000000213"/>
      </dia:attribute>
      <dia:attribute name="border_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O2">
      <dia:attribute name="obj_pos">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.05,9.95;30.95,25"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.1,10"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="15.799999999999999"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="14.949999999999999"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O3">
      <dia:attribute name="obj_pos">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.95,7.1;29.05,9.05"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17,7.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O4">
      <dia:attribute name="obj_pos">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="16.9507,25.8643;29.0507,27.8143"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="17.0007,25.9143"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="12"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8499999999999996"/>
      </dia:attribute>
      <dia:attribute name="inner_color">
        <dia:color val="#bfbfbf"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="corner_radius">
        <dia:real val="1.1754943508222875e-38"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O5">
      <dia:attribute name="obj_pos">
        <dia:point val="30.9,16"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="30.85,15.95;44.25,17.95"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="30.9,16"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.299999999999997"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.9000000000000021"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Box" version="0" id="O6">
      <dia:attribute name="obj_pos">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="1.73,16.035;15.13,18.035"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="1.78,16.085"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="13.299999999999997"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.9000000000000021"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Ellipse" version="0" id="O7">
      <dia:attribute name="obj_pos">
        <dia:point val="42.6,16.45"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="42.55,16.4;43.65,17.5"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="42.6,16.45"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="aspect">
        <dia:enum val="2"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Ellipse" version="0" id="O8">
      <dia:attribute name="obj_pos">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="2.25,16.5;3.35,17.6"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="2.3,16.55"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="aspect">
        <dia:enum val="2"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="Standard - Text" version="0" id="O9">
      <dia:attribute name="obj_pos">
        <dia:point val="-3.80407,8.9651"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-3.80407,7.5651;14.3959,9.9651"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Passive off-hooked trailer#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="0" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="2"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-3.80407,8.9651"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="0"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
    </dia:object>
  </dia:layer>
  <dia:layer name="Bond Graph" visible="true">
    <dia:object type="BondGraph - MTT port" version="0" id="O10">
      <dia:attribute name="obj_pos">
        <dia:point val="34,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="33.95,34.95;40.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="34,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.6338834764831827"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#rotation:z1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.3169,36.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O11">
      <dia:attribute name="obj_pos">
        <dia:point val="5,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="4.95,34.95;11.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="5,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.6338834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#rotation:z2#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="sans" style="80" name="Helvetica"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.31694,36.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O12">
      <dia:attribute name="obj_pos">
        <dia:point val="13,42"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="12.95,41.95;16.4964,43.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="13,42"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831915"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865451"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:D#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="14.7232,43.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O13">
      <dia:attribute name="obj_pos">
        <dia:point val="29,43"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="28.95,42.95;32.3714,44.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="29,43"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.3213834764831964"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#TF:L#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="30.6607,44.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O14">
      <dia:attribute name="obj_pos">
        <dia:point val="-4,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-4.05,34.95;0.871383,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="-4,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831835"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="-1.58931,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O15">
      <dia:attribute name="obj_pos">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="5.95,27.95;10.8714,29.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="6,28"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y2]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="8.41069,29.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O16">
      <dia:attribute name="obj_pos">
        <dia:point val="47.4169,36.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.2053,34.0636;46.4674,36.7702"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="47.4169,36.0036"/>
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[x_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O40" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O17">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3084,28.9743"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="37.2224,29.3228;40.0157,35.1021"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3084,28.9743"/>
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[y_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O41" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O18">
      <dia:attribute name="obj_pos">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,34.95;24.6839,36.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,35"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,36.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O19">
      <dia:attribute name="obj_pos">
        <dia:point val="23,52"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,51.95;24.6839,53.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,52"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,53.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O20">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.7053,34.0536;37.8169,36.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3169,35.9036"/>
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O10" connection="0"/>
        <dia:connection handle="1" to="O18" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O21">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="31.1892,36.0902;39.0998,44.1024"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3169,35.9036"/>
        <dia:point val="30.6607,43.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O10" connection="0"/>
        <dia:connection handle="1" to="O13" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O22">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="9.20534,34.0536;22.8669,36.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,35.9036"/>
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[x_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O18" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O23">
      <dia:attribute name="obj_pos">
        <dia:point val="30.6607,43.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.3106,44.6295;31.0106,53.034"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="30.6607,43.9036"/>
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O13" connection="0"/>
        <dia:connection handle="1" to="O19" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O24">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.2855,42.1861;24.0319,52.2344"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,52.9036"/>
        <dia:point val="14.7232,42.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O12" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O25">
      <dia:attribute name="obj_pos">
        <dia:point val="14.7232,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.88165,35.1811;14.9333,42.7766"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="14.7232,42.9036"/>
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[y_1]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O12" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O26">
      <dia:attribute name="obj_pos">
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="-0.700913,34.0536;8.81694,36.7536"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.31694,35.9036"/>
        <dia:point val="-1.58931,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[x_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O14" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O27">
      <dia:attribute name="obj_pos">
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="7.47974,29.2696;11.0302,35.1198"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="8.31694,35.9036"/>
        <dia:point val="8.41069,28.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="start_label">
        <dia:string>#[y_2]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O11" connection="0"/>
        <dia:connection handle="1" to="O15" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O28">
      <dia:attribute name="obj_pos">
        <dia:point val="21.8438,29"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="21.7938,28.95;25.3402,30.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="21.8438,29"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Df:v#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.567,30.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O29">
      <dia:attribute name="obj_pos">
        <dia:point val="20.9,56"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.85,55.95;26.8339,57.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20.9,56"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831844"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#Df:omega#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8419,57.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O30">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.5128,30.2028;24.9742,35.0545"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,35.9036"/>
        <dia:point val="23.567,29.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O18" connection="0"/>
        <dia:connection handle="1" to="O28" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O31">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="23.7295,53.2461;25.0356,56.0961"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,52.9036"/>
        <dia:point val="23.8419,56.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O29" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O32">
      <dia:attribute name="obj_pos">
        <dia:point val="20.8,47.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="20.75,47;26.7339,48.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="20.8,47.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.8838834764831889"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:yaw#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.7419,48.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O33">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,52.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9806,48.2853;25.0016,52.0855"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,52.9036"/>
        <dia:point val="23.7419,47.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O19" connection="0"/>
        <dia:connection handle="1" to="O32" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O34">
      <dia:attribute name="obj_pos">
        <dia:point val="23,42"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.95,41.95;24.6839,43.8571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="23,42"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.633883476483186"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#0#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="23.8169,43.2036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O35">
      <dia:attribute name="obj_pos">
        <dia:point val="23.7419,47.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="22.9857,43.2713;25.0019,47.1715"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.7419,47.9536"/>
        <dia:point val="23.8169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O32" connection="0"/>
        <dia:connection handle="1" to="O34" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O36">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="24.671,35.6422;38.3815,43.7086"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,42.9036"/>
        <dia:point val="37.3169,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[psi]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O34" connection="0"/>
        <dia:connection handle="1" to="O10" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O37">
      <dia:attribute name="obj_pos">
        <dia:point val="18.9357,39.5536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="8.97894,34.4438;18.3801,39.2603"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="18.9357,39.5536"/>
        <dia:point val="8.31694,35.9036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="2"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="end_label">
        <dia:string>#[psi]#</dia:string>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O38" connection="0"/>
        <dia:connection handle="1" to="O11" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O38">
      <dia:attribute name="obj_pos">
        <dia:point val="15.4937,38.65"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="15.4437,38.6;22.4276,40.5071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="15.4937,38.65"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="6.8838834764831871"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#AE:negative#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="0" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="18.9356,39.8036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O39">
      <dia:attribute name="obj_pos">
        <dia:point val="23.8169,42.9036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="19.7084,38.4801;23.6714,42.3725"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="23.8169,42.9036"/>
        <dia:point val="18.9357,39.5536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O34" connection="0"/>
        <dia:connection handle="1" to="O38" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O40">
      <dia:attribute name="obj_pos">
        <dia:point val="46.6,35.1"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.55,35.05;48.2839,36.9571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="46.6,35.1"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="47.4169,36.3036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O41">
      <dia:attribute name="obj_pos">
        <dia:point val="36.4914,28.0707"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.4414,28.0207;38.1753,29.9278"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="36.4914,28.0707"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="1.6338834764831902"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.807106781186548"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#1#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.3083,29.2743"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O42">
      <dia:attribute name="obj_pos">
        <dia:point val="44.6812,39.7"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="44.6312,39.65;50.2401,41.5571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="44.6812,39.7"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.5088834764831933"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:x_e#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="47.4357,40.9036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O43">
      <dia:attribute name="obj_pos">
        <dia:point val="39.7456,28.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="39.6956,28;45.3044,29.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="39.7456,28.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="5.5088834764831791"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#INTF:y_e#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="42.5,29.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O44">
      <dia:attribute name="obj_pos">
        <dia:point val="34.85,20.5"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="34.8,20.45;39.7214,22.3571"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="34.85,20.5"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.821383476483188"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[y1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="37.2607,21.7036"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O45">
      <dia:attribute name="obj_pos">
        <dia:point val="53.7,34.95"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="53.65,34.9;58.5714,36.8071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="53.7,34.95"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="4.8213834764831871"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#SS:[x1]#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="56.1107,36.1536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O46">
      <dia:attribute name="obj_pos">
        <dia:point val="56.1107,35.8536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="48.305,34.021;55.1755,36.8061"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="56.1107,35.8536"/>
        <dia:point val="47.4169,36.0036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O45" connection="0"/>
        <dia:connection handle="1" to="O40" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O47">
      <dia:attribute name="obj_pos">
        <dia:point val="37.2607,21.4036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="36.4167,21.746;38.5021,28.1668"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.2607,21.4036"/>
        <dia:point val="37.3084,28.9743"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="0"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O44" connection="0"/>
        <dia:connection handle="1" to="O41" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O48">
      <dia:attribute name="obj_pos">
        <dia:point val="37.3084,28.9743"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="38.6399,27.1169;40.0535,29.7601"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="37.3084,28.9743"/>
        <dia:point val="42.5,28.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O41" connection="0"/>
        <dia:connection handle="1" to="O43" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O49">
      <dia:attribute name="obj_pos">
        <dia:point val="47.4169,36.0036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.6256,37.2919;48.6277,38.8449"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="47.4169,36.0036"/>
        <dia:point val="47.4357,40.6036"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O40" connection="0"/>
        <dia:connection handle="1" to="O42" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O50">
      <dia:attribute name="obj_pos">
        <dia:point val="46.5983,28.15"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.5483,28.1;50.0947,30.0071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="46.5983,28.15"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.4463834764831773"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865469"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#De:y#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="48.3215,29.3536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT port" version="0" id="O51">
      <dia:attribute name="obj_pos">
        <dia:point val="45.667,44.05"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.617,44;49.2259,45.9071"/>
      </dia:attribute>
      <dia:attribute name="elem_corner">
        <dia:point val="45.667,44.05"/>
      </dia:attribute>
      <dia:attribute name="elem_width">
        <dia:real val="3.5088834764831862"/>
      </dia:attribute>
      <dia:attribute name="elem_height">
        <dia:real val="1.8071067811865476"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.10000000000000001"/>
      </dia:attribute>
      <dia:attribute name="line_colour">
        <dia:color val="#000000"/>
      </dia:attribute>
      <dia:attribute name="fill_colour">
        <dia:color val="#ffffff"/>
      </dia:attribute>
      <dia:attribute name="show_background">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="line_style">
        <dia:enum val="0"/>
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="text">
        <dia:composite type="text">
          <dia:attribute name="string">
            <dia:string>#De:x#</dia:string>
          </dia:attribute>
          <dia:attribute name="font">
            <dia:font family="serif" style="80" name="Times-Roman"/>
          </dia:attribute>
          <dia:attribute name="height">
            <dia:real val="1"/>
          </dia:attribute>
          <dia:attribute name="pos">
            <dia:point val="47.4214,45.2536"/>
          </dia:attribute>
          <dia:attribute name="color">
            <dia:color val="#000000"/>
          </dia:attribute>
          <dia:attribute name="alignment">
            <dia:enum val="1"/>
          </dia:attribute>
        </dia:composite>
      </dia:attribute>
      <dia:attribute name="flip_horizontal">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="flip_vertical">
        <dia:boolean val="false"/>
      </dia:attribute>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O52">
      <dia:attribute name="obj_pos">
        <dia:point val="42.5,28.9536"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="45.5148,27.1565;46.9382,29.8257"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="42.5,28.9536"/>
        <dia:point val="48.3215,29.0536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O43" connection="0"/>
        <dia:connection handle="1" to="O50" connection="0"/>
      </dia:connections>
    </dia:object>
    <dia:object type="BondGraph - MTT bond" version="0" id="O53">
      <dia:attribute name="obj_pos">
        <dia:point val="47.4357,40.6036"/>
      </dia:attribute>
      <dia:attribute name="obj_bb">
        <dia:rectangle val="46.6356,41.6437;48.6293,43.2049"/>
      </dia:attribute>
      <dia:attribute name="conn_endpoints">
        <dia:point val="47.4357,40.6036"/>
        <dia:point val="47.4215,44.9536"/>
      </dia:attribute>
      <dia:attribute name="numcp">
        <dia:int val="1"/>
      </dia:attribute>
      <dia:attribute name="line_width">
        <dia:real val="0.050000000000000003"/>
      </dia:attribute>
      <dia:attribute name="absolute_start_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="absolute_end_gap">
        <dia:real val="1"/>
      </dia:attribute>
      <dia:attribute name="object_edge_start">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="object_edge_end">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="effort_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="flow_causality">
        <dia:enum val="1"/>
      </dia:attribute>
      <dia:attribute name="arrow_on_start">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="signal">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:attribute name="show_labels">
        <dia:boolean val="true"/>
      </dia:attribute>
      <dia:connections>
        <dia:connection handle="0" to="O42" connection="0"/>
        <dia:connection handle="1" to="O51" connection="0"/>
      </dia:connections>
    </dia:object>
  </dia:layer>
</dia:diagram>

Deleted mttroot/mtt/lib/examples/Dia/robotrain/trailer_abg.ps version [a0fab52c92].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854






















































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%!PS-Adobe-2.0 EPSF-2.0
%%Title: trailer_abg.dia
%%Creator: Dia v0.94+bondgraph
%%CreationDate: Sun Sep 12 21:16:23 2004
%%For: geraint
%%Orientation: Portrait
%%Magnification: 1.0000
%%BoundingBox: 0 0 1776 1439
%%BeginSetup
%%EndSetup
%%EndComments
%%BeginProlog
[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E
/F /G /H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W /X /Y
/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
/d /e /f /g /h /i /j /k /l /m
/n /o /p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
/cp {closepath} bind def
/c {curveto} bind def
/f {fill} bind def
/a {arc} bind def
/ef {eofill} bind def
/ex {exch} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth pop} bind def
/tr {translate} bind def

/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse
{ ellipsedict begin
   /endangle exch def
   /startangle exch def
   /yrad exch def
   /xrad exch def
   /y exch def
   /x exch def   /savematrix mtrx currentmatrix def
   x y tr xrad yrad sc
   0 0 1 startangle endangle arc
   savematrix setmatrix
   end
} def

/mergeprocs {
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/Times-Roman-latin1
    /Times-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Italic-latin1
    /Times-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-Bold-latin1
    /Times-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Times-BoldItalic-latin1
    /Times-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Book-latin1
    /AvantGarde-Book findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-BookOblique-latin1
    /AvantGarde-BookOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-Demi-latin1
    /AvantGarde-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/AvantGarde-DemiOblique-latin1
    /AvantGarde-DemiOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Light-latin1
    /Bookman-Light findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-LightItalic-latin1
    /Bookman-LightItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-Demi-latin1
    /Bookman-Demi findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Bookman-DemiItalic-latin1
    /Bookman-DemiItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-latin1
    /Courier findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Oblique-latin1
    /Courier-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-Bold-latin1
    /Courier-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Courier-BoldOblique-latin1
    /Courier-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-latin1
    /Helvetica findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Oblique-latin1
    /Helvetica-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Bold-latin1
    /Helvetica-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-BoldOblique-latin1
    /Helvetica-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-latin1
    /Helvetica-Narrow findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Oblique-latin1
    /Helvetica-Narrow-Oblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-Bold-latin1
    /Helvetica-Narrow-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Helvetica-Narrow-BoldOblique-latin1
    /Helvetica-Narrow-BoldOblique findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Roman-latin1
    /NewCenturySchoolbook-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Italic-latin1
    /NewCenturySchoolbook-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-Bold-latin1
    /NewCenturySchoolbook-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/NewCenturySchoolbook-BoldItalic-latin1
    /NewCenturySchoolbook-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Roman-latin1
    /Palatino-Roman findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Italic-latin1
    /Palatino-Italic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-Bold-latin1
    /Palatino-Bold findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Palatino-BoldItalic-latin1
    /Palatino-BoldItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/Symbol-latin1
    /Symbol findfont
definefont pop
/ZapfChancery-MediumItalic-latin1
    /ZapfChancery-MediumItalic findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
/ZapfDingbats-latin1
    /ZapfDingbats findfont
    dup length dict begin
	{1 index /FID ne {def} {pop pop} ifelse} forall
	/Encoding isolatin1encoding def
    currentdict end
definefont pop
28.346000 -28.346000 scale
4.050000 -57.857107 translate
%%EndProlog


0.749020 0.749020 0.749020 srgb
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.000000 m 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.850000 25.000000 m 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.150000 25.000000 m 21.150000 25.900000 l 24.850000 25.900000 l 24.850000 25.000000 l f
n 21.150000 25.900000 m 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.850000 25.900000 m 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.150000 25.000000 m 24.850000 25.000000 l s
n 21.150000 25.900000 m 24.850000 25.900000 l s
n 21.150000 25.000000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.850000 25.000000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.150000 25.000000 m 21.150000 25.900000 l s
n 24.850000 25.000000 m 24.850000 25.900000 l s
n 21.150000 25.900000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.850000 25.900000 0.000000 0.000000 0.000000 90.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.035000 m 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 24.780000 9.035000 m 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 21.080000 9.035000 m 21.080000 9.935000 l 24.780000 9.935000 l 24.780000 9.035000 l f
n 21.080000 9.935000 m 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 24.780000 9.935000 m 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
n 21.080000 9.035000 m 24.780000 9.035000 l s
n 21.080000 9.935000 m 24.780000 9.935000 l s
n 21.080000 9.035000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 24.780000 9.035000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 21.080000 9.035000 m 21.080000 9.935000 l s
n 24.780000 9.035000 m 24.780000 9.935000 l s
n 21.080000 9.935000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 24.780000 9.935000 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 15.100000 10.000000 m 15.100000 24.950000 l 30.900000 24.950000 l 30.900000 10.000000 l cp s
0.749020 0.749020 0.749020 srgb
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 7.150000 m 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000000 7.150000 m 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000000 7.150000 m 17.000000 9.000000 l 29.000000 9.000000 l 29.000000 7.150000 l f
n 17.000000 9.000000 m 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000000 9.000000 m 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000000 7.150000 m 29.000000 7.150000 l s
n 17.000000 9.000000 m 29.000000 9.000000 l s
n 17.000000 7.150000 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000000 7.150000 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000000 7.150000 m 17.000000 9.000000 l s
n 29.000000 7.150000 m 29.000000 9.000000 l s
n 17.000000 9.000000 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000000 9.000000 0.000000 0.000000 0.000000 90.000000 ellipse s
0.749020 0.749020 0.749020 srgb
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 25.914300 m 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse f
n 29.000700 25.914300 m 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse f
n 17.000700 25.914300 m 17.000700 27.764300 l 29.000700 27.764300 l 29.000700 25.914300 l f
n 17.000700 27.764300 m 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse f
n 29.000700 27.764300 m 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 17.000700 25.914300 m 29.000700 25.914300 l s
n 17.000700 27.764300 m 29.000700 27.764300 l s
n 17.000700 25.914300 0.000000 0.000000 180.000000 270.000000 ellipse s
n 29.000700 25.914300 0.000000 0.000000 270.000000 360.000000 ellipse s
n 17.000700 25.914300 m 17.000700 27.764300 l s
n 29.000700 25.914300 m 29.000700 27.764300 l s
n 17.000700 27.764300 0.000000 0.000000 90.000000 180.000000 ellipse s
n 29.000700 27.764300 0.000000 0.000000 0.000000 90.000000 ellipse s
1.000000 1.000000 1.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 30.900000 16.000000 m 30.900000 17.900000 l 44.200000 17.900000 l 44.200000 16.000000 l cp s
1.000000 1.000000 1.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l f
0.100000 slw
[] 0 sd
[] 0 sd
0 slj
0.000000 0.000000 0.000000 srgb
n 1.780000 16.085000 m 1.780000 17.985000 l 15.080000 17.985000 l 15.080000 16.085000 l cp s
1.000000 1.000000 1.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 43.100000 16.950000 0.500000 0.500000 0 360 ellipse cp s
1.000000 1.000000 1.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse f
0.100000 slw
[] 0 sd
[] 0 sd
0.000000 0.000000 0.000000 srgb
n 2.800000 17.050000 0.500000 0.500000 0 360 ellipse cp s
/Helvetica-latin1 ff 1.400000 scf sf
(Passive off-hooked trailer) -3.804070 8.965100 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(rotation:z1) dup sw 2 div 37.316942 ex sub 36.153553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Helvetica-latin1 ff 0.700000 scf sf
(rotation:z2) dup sw 2 div 8.316942 ex sub 36.153553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(TF:D) dup sw 2 div 14.723192 ex sub 43.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(TF:L) dup sw 2 div 30.660692 ex sub 44.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[x2]) dup sw 2 div -1.589308 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[y2]) dup sw 2 div 8.410692 ex sub 29.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 45.549905 35.985115 m 41.683312 35.946832 l s
n 41.683312 35.946832 m 42.974861 36.709656 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 37.310793 30.925048 m 37.314507 33.952852 l s
n 37.314507 33.952852 m 38.062913 32.652895 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 23.816942 ex sub 36.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 23.816942 ex sub 53.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 32.949728 35.903600 m 25.684133 35.903600 l s
n 32.949728 35.903600 m 32.949728 36.653600 l s
n 32.949728 35.903600 m 32.949728 35.153600 l s
n 25.684133 35.903600 m 26.983171 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 35.883879 37.625929 m 32.093721 42.181271 l s
n 35.883879 37.625929 m 36.460416 38.105622 l s
n 35.883879 37.625929 m 35.307342 37.146236 l s
n 32.093721 42.181271 m 33.501110 41.662373 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 21.949852 35.903600 m 12.681067 35.903600 l s
n 21.949852 35.903600 m 21.949852 36.653600 l s
n 21.949852 35.903600 m 21.949852 35.153600 l s
n 12.681067 35.903600 m 13.980105 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 29.331926 45.651016 m 25.145674 51.156184 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 25.145674 51.156184 m 26.528977 50.576121 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.322407 51.260163 m 16.263229 44.597112 l s
n 16.263229 44.597112 m 17.692081 45.053599 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 13.176908 41.213996 m 9.863232 37.593204 l s
n 13.176908 41.213996 m 13.730183 40.707649 l s
n 13.176908 41.213996 m 12.623633 41.720342 l s
n 9.863232 37.593204 m 11.293525 38.045159 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 3.949758 35.903600 m 1.870928 35.903600 l s
n 3.949758 35.903600 m 3.949758 36.653600 l s
n 3.949758 35.903600 m 3.949758 35.153600 l s
n 1.870928 35.903600 m 3.169966 36.653600 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 8.343080 33.951785 m 8.384550 30.855415 l s
n 8.343080 33.951785 m 9.093013 33.961829 l s
n 8.343080 33.951785 m 7.593148 33.941742 l s
n 8.384550 30.855415 m 9.117086 32.164380 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Df:v) dup sw 2 div 23.566992 ex sub 30.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(Df:omega) dup sw 2 div 23.841942 ex sub 57.203553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.735599 33.951585 m 23.648301 31.855615 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.648301 31.855615 m 24.451710 33.122317 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.829110 54.857194 m 23.829690 54.950006 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.829110 54.857194 m 24.587214 56.151519 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF:yaw) dup sw 2 div 23.741942 ex sub 48.253553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.787299 50.949909 m 23.771501 49.907291 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.771501 49.907291 m 24.541095 51.194817 l s
n 23.771501 49.907291 m 23.041268 51.217542 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(0) dup sw 2 div 23.816942 ex sub 43.203553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 23.770904 46.000671 m 23.787896 44.856529 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 23.787896 44.856529 m 24.518523 46.166562 l s
n 23.787896 44.856529 m 23.018688 46.144287 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 25.571888 41.993606 m 34.593330 37.315821 l s
n 34.593330 37.315821 m 33.785341 38.579607 l s
n 34.593330 37.315821 m 33.094865 37.247975 l s
n 34.593330 37.315821 m 34.938568 37.981637 l s
n 34.593330 37.315821 m 34.248092 36.650006 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 15.214768 38.274599 m 12.037872 37.182601 l s
n 12.037872 37.182601 m 13.022564 38.314140 l s
n 12.037872 37.182601 m 13.510160 36.895602 l s
n 12.037872 37.182601 m 11.794074 37.891870 l s
n 12.037872 37.182601 m 12.281670 36.473332 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(AE:negative) dup sw 2 div 18.935642 ex sub 39.803553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 22.129609 41.745601 m 21.148531 41.072280 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 21.148531 41.072280 m 21.795193 42.425730 l s
n 21.148531 41.072280 m 22.643984 41.188979 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 47.416942 ex sub 36.303553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(1) dup sw 2 div 37.308342 ex sub 29.274253 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF) dup sw 2 div 47.435692 ex sub 40.903553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(INTF) dup sw 2 div 42.499992 ex sub 29.253553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[y1]) dup sw 2 div 37.260692 ex sub 21.703553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(SS:[x1]) dup sw 2 div 56.110692 ex sub 36.153553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 52.650329 35.913304 m 49.283266 35.971398 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 52.650329 35.913304 m 52.663268 36.663193 l s
n 52.650329 35.913304 m 52.637391 35.163416 l s
n 49.283266 35.971398 m 50.595049 36.698877 l s
0.100000 slw
[] 0 sd
[] 0 sd
1 slc
n 37.272986 23.353614 m 37.296114 27.024286 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 37.272986 23.353614 m 38.022971 23.348889 l s
n 37.272986 23.353614 m 36.523001 23.358340 l s
n 37.296114 27.024286 m 38.037914 25.720548 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 39.172814 28.966866 m 39.664062 28.964907 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 39.664062 28.964907 m 38.368025 29.720081 l s
n 39.664062 28.964907 m 38.362044 28.220093 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 47.424885 37.957339 m 47.427716 38.650142 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 47.427716 38.650142 m 48.172401 37.348049 l s
n 47.427716 38.650142 m 46.672413 37.354179 l s
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(De:y) dup sw 2 div 48.321492 ex sub 29.353553 m gs 1 -1 sc sh gr
0.100000 slw
[] 0 sd
[] 0 sd
0 slc
0 slj
0 slc
0 slj
[] 0 sd
/Times-Roman-latin1 ff 0.700000 scf sf
(De:x) dup sw 2 div 47.421442 ex sub 45.253553 m gs 1 -1 sc sh gr
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 45.333284 29.002269 m 45.570649 29.006347 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 45.570649 29.006347 m 44.258922 29.733925 l s
n 45.570649 29.006347 m 44.284684 28.234146 l s
0.050000 slw
[] 0 sd
[] 0 sd
1 slc
n 47.429326 42.556219 m 47.427874 43.000981 l s
/Helvetica-latin1 ff 0.560000 scf sf
n 47.427874 43.000981 m 48.182111 41.704398 l s
n 47.427874 43.000981 m 46.682119 41.699501 l s
showpage

Deleted mttroot/mtt/lib/examples/Dia/robotrain/trailer_lbl.txt version [be088eb97e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY trailer
#DESCRIPTION Detailed description here

## System trailer, representation lbl, language txt
## File trailer_lbl.txt
## Generated by MTT on Wed Sep  8 00:41:53 BST 2004

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

## Port aliases
#ALIAS	in	x1,y1
#ALIAS	out	x2,y2

## Argument aliases
#ALIAS	$1	D
#ALIAS	$2	L

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type 1 (anonymous => default parameters)
	# 1							
	# 1							
	# 1							

## Component type AE
	negative  lin		effort,-1

## Component type De
	x	  SS		external		
	y	  SS		external		

## Component type Df
	omega	  SS		external		
	v	  SS		external		

## Component type INTF
	x_e	  none
	y_e	  none
	yaw	  none				

## Component type SS
	[x1]	  SS		external,external		
	[x2]	  SS		external,external		
	[y1]	  SS		external,external		
	[y2]	  SS		external,external		

## Component type TF
	D	  lin		flow,-D		
	L	  lin		effort,L		

## Component type rotation
	z1	  rotate_z		
	z2	  rotate_z		

Deleted mttroot/mtt/lib/examples/Dia/robotrain/trajectory.ps version [a9bf91e4a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%!PS-Adobe-2.0 EPSF-2.0
%%Title: trajectory.eps
%%Creator: gnuplot 4.0 patchlevel 0
%%CreationDate: Sun Sep 12 19:59:53 2004
%%DocumentFonts: (atend)
%%BoundingBox: 50 50 410 302
%%Orientation: Portrait
%%EndComments
/gnudict 256 dict def
gnudict begin
/Color false def
/Solid false def
/gnulinewidth 5.000 def
/userlinewidth gnulinewidth def
/vshift -46 def
/dl {10.0 mul} def
/hpt_ 31.5 def
/vpt_ 31.5 def
/hpt hpt_ def
/vpt vpt_ def
/Rounded false def
/M {moveto} bind def
/L {lineto} bind def
/R {rmoveto} bind def
/V {rlineto} bind def
/N {newpath moveto} bind def
/C {setrgbcolor} bind def
/f {rlineto fill} bind def
/vpt2 vpt 2 mul def
/hpt2 hpt 2 mul def
/Lshow { currentpoint stroke M
  0 vshift R show } def
/Rshow { currentpoint stroke M
  dup stringwidth pop neg vshift R show } def
/Cshow { currentpoint stroke M
  dup stringwidth pop -2 div vshift R show } def
/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def
  /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def
/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }
 {pop pop pop 0 setgray Solid {pop []} if 0 setdash} ifelse } def
/BL { stroke userlinewidth 2 mul setlinewidth
      Rounded { 1 setlinejoin 1 setlinecap } if } def
/AL { stroke userlinewidth 2 div setlinewidth
      Rounded { 1 setlinejoin 1 setlinecap } if } def
/UL { dup gnulinewidth mul /userlinewidth exch def
      dup 1 lt {pop 1} if 10 mul /udl exch def } def
/PL { stroke userlinewidth setlinewidth
      Rounded { 1 setlinejoin 1 setlinecap } if } def
/LTw { PL [] 1 setgray } def
/LTb { BL [] 0 0 0 DL } def
/LTa { AL [1 udl mul 2 udl mul] 0 setdash 0 0 0 setrgbcolor } def
/LT0 { PL [] 1 0 0 DL } def
/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def
/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def
/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def
/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def
/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def
/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def
/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def
/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def
/Pnt { stroke [] 0 setdash
   gsave 1 setlinecap M 0 0 V stroke grestore } def
/Dia { stroke [] 0 setdash 2 copy vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V closepath stroke
  Pnt } def
/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V
  currentpoint stroke M
  hpt neg vpt neg R hpt2 0 V stroke
  } def
/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M
  0 vpt2 neg V hpt2 0 V 0 vpt2 V
  hpt2 neg 0 V closepath stroke
  Pnt } def
/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M
  hpt2 vpt2 neg V currentpoint stroke M
  hpt2 neg 0 R hpt2 vpt2 V stroke } def
/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V closepath stroke
  Pnt  } def
/Star { 2 copy Pls Crs } def
/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M
  0 vpt2 neg V  hpt2 0 V  0 vpt2 V
  hpt2 neg 0 V  closepath fill } def
/TriUF { stroke [] 0 setdash vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V closepath fill } def
/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V closepath stroke
  Pnt  } def
/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V closepath fill} def
/DiaF { stroke [] 0 setdash vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V closepath fill } def
/Pent { stroke [] 0 setdash 2 copy gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  closepath stroke grestore Pnt } def
/PentF { stroke [] 0 setdash gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  closepath fill grestore } def
/Circle { stroke [] 0 setdash 2 copy
  hpt 0 360 arc stroke Pnt } def
/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def
/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450  arc } bind def
/C1 { BL [] 0 setdash 2 copy        moveto
       2 copy  vpt 0 90 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C2 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 90 180 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C3 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 0 180 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C4 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 180 270 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C5 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 0 90 arc
       2 copy moveto
       2 copy  vpt 180 270 arc closepath fill
               vpt 0 360 arc } bind def
/C6 { BL [] 0 setdash 2 copy moveto
      2 copy  vpt 90 270 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C7 { BL [] 0 setdash 2 copy moveto
      2 copy  vpt 0 270 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C8 { BL [] 0 setdash 2 copy moveto
      2 copy vpt 270 360 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C9 { BL [] 0 setdash 2 copy moveto
      2 copy  vpt 270 450 arc closepath fill
              vpt 0 360 arc closepath } bind def
/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill
       2 copy moveto
       2 copy vpt 90 180 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C11 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 0 180 arc closepath fill
       2 copy moveto
       2 copy  vpt 270 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C12 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 180 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C13 { BL [] 0 setdash  2 copy moveto
       2 copy  vpt 0 90 arc closepath fill
       2 copy moveto
       2 copy  vpt 180 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/C14 { BL [] 0 setdash 2 copy moveto
       2 copy  vpt 90 360 arc closepath fill
               vpt 0 360 arc } bind def
/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill
               vpt 0 360 arc closepath } bind def
/Rec   { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto
       neg 0 rlineto closepath } bind def
/Square { dup Rec } bind def
/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def
/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def
/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def
/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def
/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill
       exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def
/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill
       2 copy vpt Square fill
       Bsquare } bind def
/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def
/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def
/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill
       Bsquare } bind def
/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill
       Bsquare } bind def
/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def
/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
       2 copy vpt Square fill Bsquare } bind def
/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
       2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def
/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def
/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def
/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def
/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def
/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def
/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def
/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def
/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def
/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def
/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def
/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def
/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def
/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def
/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def
/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def
/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def
/DiaE { stroke [] 0 setdash vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V closepath stroke } def
/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M
  0 vpt2 neg V hpt2 0 V 0 vpt2 V
  hpt2 neg 0 V closepath stroke } def
/TriUE { stroke [] 0 setdash vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V closepath stroke } def
/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V closepath stroke } def
/PentE { stroke [] 0 setdash gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  closepath stroke grestore } def
/CircE { stroke [] 0 setdash 
  hpt 0 360 arc stroke } def
/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def
/DiaW { stroke [] 0 setdash vpt add M
  hpt neg vpt neg V hpt vpt neg V
  hpt vpt V hpt neg vpt V Opaque stroke } def
/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M
  0 vpt2 neg V hpt2 0 V 0 vpt2 V
  hpt2 neg 0 V Opaque stroke } def
/TriUW { stroke [] 0 setdash vpt 1.12 mul add M
  hpt neg vpt -1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt 1.62 mul V Opaque stroke } def
/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M
  hpt neg vpt 1.62 mul V
  hpt 2 mul 0 V
  hpt neg vpt -1.62 mul V Opaque stroke } def
/PentW { stroke [] 0 setdash gsave
  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
  Opaque stroke grestore } def
/CircW { stroke [] 0 setdash 
  hpt 0 360 arc Opaque stroke } def
/BoxFill { gsave Rec 1 setgray fill grestore } def
/BoxColFill {
  gsave Rec
  /Fillden exch def
  currentrgbcolor
  /ColB exch def /ColG exch def /ColR exch def
  /ColR ColR Fillden mul Fillden sub 1 add def
  /ColG ColG Fillden mul Fillden sub 1 add def
  /ColB ColB Fillden mul Fillden sub 1 add def
  ColR ColG ColB setrgbcolor
  fill grestore } def
%
% PostScript Level 1 Pattern Fill routine
% Usage: x y w h s a XX PatternFill
%	x,y = lower left corner of box to be filled
%	w,h = width and height of box
%	  a = angle in degrees between lines and x-axis
%	 XX = 0/1 for no/yes cross-hatch
%
/PatternFill { gsave /PFa [ 9 2 roll ] def
    PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate
    PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec
    gsave 1 setgray fill grestore clip
    currentlinewidth 0.5 mul setlinewidth
    /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def
    0 0 M PFa 5 get rotate PFs -2 div dup translate
	0 1 PFs PFa 4 get div 1 add floor cvi
	{ PFa 4 get mul 0 M 0 PFs V } for
    0 PFa 6 get ne {
	0 1 PFs PFa 4 get div 1 add floor cvi
	{ PFa 4 get mul 0 2 1 roll M PFs 0 V } for
    } if
    stroke grestore } def
%
/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont
dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall
currentdict end definefont pop
end
%%EndProlog
gnudict begin
gsave
50 50 translate
0.050 0.050 scale
0 setgray
newpath
(Helvetica) findfont 140 scalefont setfont
1.000 UL
LTb
1.000 UL
LTa
714 560 M
6248 0 V
1.000 UL
LTb
714 560 M
63 0 V
6185 0 R
-63 0 V
630 560 M
gsave 0 setgray
(-1) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 1140 M
6248 0 V
1.000 UL
LTb
714 1140 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
(-0.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 1720 M
6248 0 V
1.000 UL
LTb
714 1720 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 0) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 2300 M
6248 0 V
1.000 UL
LTb
714 2300 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 0.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 2880 M
6248 0 V
1.000 UL
LTb
714 2880 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 1) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 3460 M
6248 0 V
1.000 UL
LTb
714 3460 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 1.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 4040 M
6248 0 V
1.000 UL
LTb
714 4040 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 2) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 4620 M
6248 0 V
1.000 UL
LTb
714 4620 M
63 0 V
6185 0 R
-63 0 V
-6269 0 R
gsave 0 setgray
( 2.5) Rshow
grestore
1.000 UL
LTb
1.000 UL
LTa
714 560 M
0 4060 V
1.000 UL
LTb
714 560 M
0 63 V
0 3997 R
0 -63 V
714 420 M
gsave 0 setgray
(-5) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
1607 560 M
0 3577 V
0 420 R
0 63 V
1.000 UL
LTb
1607 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-4) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
2499 560 M
0 4060 V
1.000 UL
LTb
2499 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-3) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
3392 560 M
0 4060 V
1.000 UL
LTb
3392 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-2) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
4284 560 M
0 4060 V
1.000 UL
LTb
4284 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
(-1) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
5177 560 M
0 4060 V
1.000 UL
LTb
5177 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
( 0) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
6069 560 M
0 4060 V
1.000 UL
LTb
6069 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
( 1) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTa
6962 560 M
0 4060 V
1.000 UL
LTb
6962 560 M
0 63 V
0 3997 R
0 -63 V
0 -4137 R
gsave 0 setgray
( 2) Cshow
grestore
1.000 UL
LTb
1.000 UL
LTb
714 560 M
6248 0 V
0 4060 V
-6248 0 V
714 560 L
LTb
140 2590 M
gsave 0 setgray
currentpoint gsave translate 90 rotate 0 0 M
(y) Cshow
grestore
grestore
LTb
3838 210 M
gsave 0 setgray
(x) Cshow
grestore
LTb
3838 4830 M
gsave 0 setgray
(MTT model "robotrain": trajectory of trailer links) Cshow
grestore
210 70 M
gsave 0 setgray
(Sun Sep 12 19:59:53 2004) Lshow
grestore
1.000 UP
1.000 UP
1.000 UL
LT0
LTb
1302 4487 M
gsave 0 setgray
(front) Rshow
grestore
LT0
4284 1720 Pls
4377 1609 Pls
4479 1511 Pls
4587 1427 Pls
4701 1357 Pls
4820 1302 Pls
4942 1263 Pls
5067 1240 Pls
5193 1234 Pls
5319 1244 Pls
5444 1270 Pls
5566 1312 Pls
5684 1369 Pls
5797 1442 Pls
5904 1529 Pls
6004 1630 Pls
6095 1743 Pls
6178 1867 Pls
6250 2001 Pls
6312 2144 Pls
6362 2294 Pls
6401 2451 Pls
6427 2611 Pls
6441 2774 Pls
6443 2938 Pls
6431 3101 Pls
6408 3262 Pls
6372 3419 Pls
6324 3571 Pls
6265 3716 Pls
6195 3852 Pls
6114 3979 Pls
6025 4094 Pls
5927 4198 Pls
5822 4288 Pls
5710 4364 Pls
5593 4425 Pls
5472 4471 Pls
5347 4500 Pls
5222 4514 Pls
5096 4511 Pls
4970 4492 Pls
4847 4456 Pls
4727 4405 Pls
4612 4338 Pls
4502 4257 Pls
4399 4162 Pls
4304 4054 Pls
4218 3935 Pls
4141 3804 Pls
4075 3665 Pls
4020 3517 Pls
3976 3363 Pls
3945 3205 Pls
3926 3043 Pls
3919 2879 Pls
3925 2715 Pls
3943 2553 Pls
3974 2394 Pls
4017 2240 Pls
4072 2092 Pls
4138 1952 Pls
4214 1821 Pls
4299 1701 Pls
4394 1592 Pls
4496 1496 Pls
4606 1414 Pls
4721 1347 Pls
4840 1295 Pls
4963 1258 Pls
5089 1238 Pls
5215 1234 Pls
5340 1247 Pls
5465 1276 Pls
5586 1320 Pls
5703 1381 Pls
5816 1456 Pls
5921 1545 Pls
6020 1648 Pls
6110 1763 Pls
6190 1889 Pls
6261 2025 Pls
6321 2169 Pls
6369 2320 Pls
6406 2477 Pls
6430 2638 Pls
6442 2801 Pls
6442 2965 Pls
6428 3128 Pls
6403 3289 Pls
6365 3445 Pls
6315 3596 Pls
6254 3740 Pls
6182 3874 Pls
6100 3999 Pls
6009 4113 Pls
5910 4214 Pls
5803 4302 Pls
5690 4375 Pls
5573 4434 Pls
5451 4477 Pls
1585 4487 Pls
1.000 UP
1.000 UL
LT1
LTb
1302 4347 M
gsave 0 setgray
(middle) Rshow
grestore
LT1
2499 1720 Crs
2599 1820 Crs
2715 1882 Crs
2839 1910 Crs
2965 1909 Crs
3090 1884 Crs
3212 1840 Crs
3330 1784 Crs
3446 1719 Crs
3560 1647 Crs
3672 1573 Crs
3784 1497 Crs
3897 1423 Crs
4011 1352 Crs
4126 1285 Crs
4243 1223 Crs
4362 1168 Crs
4483 1121 Crs
4605 1083 Crs
4730 1055 Crs
4855 1037 Crs
4981 1031 Crs
5107 1036 Crs
5233 1054 Crs
5357 1085 Crs
5479 1128 Crs
5597 1184 Crs
5712 1253 Crs
5821 1334 Crs
5925 1428 Crs
6022 1533 Crs
6111 1649 Crs
6192 1775 Crs
6264 1910 Crs
6325 2053 Crs
6377 2203 Crs
6417 2358 Crs
6446 2518 Crs
6463 2680 Crs
6468 2844 Crs
6461 3008 Crs
6442 3170 Crs
6410 3329 Crs
6368 3483 Crs
6313 3631 Crs
6248 3772 Crs
6173 3903 Crs
6088 4025 Crs
5995 4135 Crs
5893 4232 Crs
5785 4317 Crs
5671 4386 Crs
5552 4441 Crs
5430 4481 Crs
5305 4504 Crs
5179 4511 Crs
5053 4502 Crs
4928 4477 Crs
4806 4436 Crs
4688 4379 Crs
4574 4308 Crs
4467 4222 Crs
4366 4122 Crs
4274 4011 Crs
4191 3887 Crs
4117 3754 Crs
4055 3612 Crs
4003 3462 Crs
3963 3306 Crs
3935 3146 Crs
3920 2984 Crs
3917 2820 Crs
3927 2656 Crs
3950 2495 Crs
3984 2337 Crs
4031 2185 Crs
4089 2039 Crs
4157 1902 Crs
4237 1774 Crs
4325 1657 Crs
4422 1552 Crs
4527 1460 Crs
4638 1383 Crs
4754 1320 Crs
4875 1272 Crs
4999 1241 Crs
5124 1225 Crs
5251 1226 Crs
5376 1244 Crs
5500 1277 Crs
5620 1326 Crs
5736 1391 Crs
5846 1471 Crs
5950 1564 Crs
6046 1670 Crs
6133 1789 Crs
6211 1918 Crs
6279 2056 Crs
6335 2203 Crs
6380 2356 Crs
6413 2514 Crs
1585 4347 Crs
1.000 UP
1.000 UL
LT2
LTb
1302 4207 M
gsave 0 setgray
(rear) Rshow
grestore
LT2
714 1720 Star
819 1631 Star
942 1601 Star
1068 1614 Star
1190 1655 Star
1309 1711 Star
1426 1771 Star
1544 1830 Star
1664 1882 Star
1786 1925 Star
1910 1956 Star
2035 1973 Star
2161 1977 Star
2287 1968 Star
2412 1946 Star
2536 1912 Star
2658 1869 Star
2777 1817 Star
2895 1758 Star
3011 1694 Star
3126 1625 Star
3240 1554 Star
3353 1481 Star
3466 1409 Star
3579 1337 Star
3693 1267 Star
3809 1199 Star
3925 1136 Star
4043 1078 Star
4163 1025 Star
4284 979 Star
4406 940 Star
4530 909 Star
4655 887 Star
4781 874 Star
4907 871 Star
5033 879 Star
5159 897 Star
5283 927 Star
5405 968 Star
5524 1021 Star
5641 1085 Star
5752 1161 Star
5859 1249 Star
5960 1347 Star
6055 1455 Star
6142 1574 Star
6221 1702 Star
6292 1838 Star
6353 1981 Star
6404 2131 Star
6444 2287 Star
6474 2446 Star
6492 2608 Star
6499 2772 Star
6494 2936 Star
6478 3099 Star
6450 3259 Star
6411 3414 Star
6360 3565 Star
6299 3708 Star
6227 3843 Star
6146 3969 Star
6056 4084 Star
5958 4187 Star
5853 4278 Star
5742 4355 Star
5625 4417 Star
5504 4465 Star
5381 4497 Star
5255 4513 Star
5129 4513 Star
5003 4497 Star
4880 4465 Star
4759 4417 Star
4642 4355 Star
4531 4277 Star
4426 4186 Star
4329 4082 Star
4240 3965 Star
4160 3838 Star
4090 3702 Star
4031 3557 Star
3984 3405 Star
3948 3247 Star
3925 3086 Star
3914 2923 Star
3915 2759 Star
3929 2596 Star
3955 2436 Star
3994 2279 Star
4044 2129 Star
4106 1986 Star
4178 1851 Star
4260 1727 Star
4351 1614 Star
4451 1513 Star
4557 1425 Star
4670 1352 Star
4788 1294 Star
4910 1251 Star
1585 4207 Star
1.000 UL
LTb
714 560 M
6248 0 V
0 4060 V
-6248 0 V
714 560 L
1.000 UP
stroke
grestore
end
showpage
%%Trailer
%%DocumentFonts: Helvetica

Deleted mttroot/mtt/lib/examples/Electrical/rc/pulse/rc_input.txt version [c92e3fb3b1].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System rc, representation input, language txt; 
## File rc_input.txt; 
## Generated by MTT on Wed May  1 08:47:22 BST 2002; 



rc__e1	= 1.0*(t<1);		# On for t<1

Deleted mttroot/mtt/lib/examples/Electrical/rc/r10/rc_numpar.txt version [e7765b3a02].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System rc, representation numpar, language txt; 
## File rc_numpar.txt; 
## Generated by MTT on Wed May  1 10:18:33 BST 2002; 



c	= 1.0;			# c = 1 F
r	= 10.0;			# r = 10 ohms

Deleted mttroot/mtt/lib/examples/Electrical/rc/rc_abg.fig version [cf0ab5e284].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1215 4500 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1080 4500 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 5400 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 675 4275 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1215 4275 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 5400 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 5400 1530 5400 765
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 5625 6750 225 675 225 675 5625 6750 5625
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 195 660 5987 4367 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 195 375 2926 2926 R:r\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4276 2926 C:c\001
4 1 -1 0 0 0 20 0.0000 4 195 660 1395 4365 SS:e1\001
4 0 1 1 0 0 20 0.0000 4 135 105 2880 450 r\001
4 0 1 1 0 0 20 0.0000 4 135 120 4680 1215 c\001
4 0 1 1 0 0 20 0.0000 4 135 120 5625 1170 e\001
4 0 1 1 0 0 20 0.0000 4 195 135 5715 1305 2\001
4 0 1 1 0 0 20 0.0000 4 135 120 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 195 135 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 255 1350 3600 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 195 1200 3600 2025 Schematic\001

Deleted mttroot/mtt/lib/examples/Electrical/rc/rc_desc.tex version [9fdb693fc1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system rc (rc_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{rc} is
   displayed in Figure \Ref{rc_abg} and its label
   file is listed in Section \Ref{sec:rc_lbl}.
   The subsystems are listed in Section \Ref{sec:rc_sub}.

The system \textbf{rc} is the simple electrical rc circuit shown in
Figure \Ref{rc_abg}. It can be regarded as a single-input
single-output system with input $e_1$ and output $e_2$.

Deleted mttroot/mtt/lib/examples/Electrical/rc/rc_lbl.txt version [e0d18235d2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Label file for system rc (rc_lbl.txt)
#SUMMARY rc a simple rc circuit
#DESCRIPTION A basic linear voltage-in voltage-out RC circuit
#DESCRIPTION A standard test example for MTT

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  2000/12/28 17:40:36  peterg
# ## To RCS
# ##
# ###############################################################


# Port aliases

# Argument aliases
#ALIAS	$1	c
#ALIAS	$2	r

## Each line should be of one of the following forms:
#	     a comment (ie starting with #)
#	     component-name	cr_name	arg1,arg2,..argn
#	     blank

# ---- Component labels ----
	c	lin		effort,c

# Component type R
	r	lin		flow,r

# Component type SS
	e1	SS		external,internal
	e2	SS		external,0

Deleted mttroot/mtt/lib/examples/Electrical/rc/rc_rep.txt version [2fcb8f9572].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system rc (rc_rep.txt)
## Generated by MTT on" Wed May  1 08:56:38 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt rc abg tex			# The system description
mtt rc cbg ps 		        # The causal bond graph
mtt rc struc tex	        # The system structure
mtt rc sympar txt	        # The system parameters
## Uncomment the following lines or add others
## mtt rc dae tex	        # The system dae
mtt rc ode tex			# The system ode 
## mtt rc sspar tex		# Steady-state parameters
## mtt rc ss tex 		# Steady state
## mtt rc dm tex		# Descriptor matrices (of linearised system)
mtt rc sm tex			# State matrices (of linearised system)
mtt rc tf tex			# Transfer function (of linearised system)
mtt rc lmfr ps			# log modulus of frequency response (of linearised system)
mtt rc simpar txt		# Simulation parameters
## mtt rc state tex		# Simulation initial state

## Default
mtt rc numpar txt		# Numerical simulation parameters
mtt rc input txt		# Simulation input
mtt rc odeso ps			# Simulation output

## Step input
mtt -dr step rc input txt	# Simulation input
mtt -dr step rc odeso ps	# Simulation output

## Pulse input
mtt -dr pulse rc input txt	# Simulation input
mtt -dr pulse rc odeso ps	# Simulation output

## r = 10
## Step input
mtt -dr step -dr r10 rc numpar txt # Numerical simulation parameters
mtt -dr step -dr r10 rc input txt # Simulation input
mtt -dr step -dr r10 rc odeso ps # Simulation output

## Pulse input
mtt -dr pulse -dr r10 rc numpar txt # Numerical simulation parameters
mtt -dr pulse -dr r10 rc input txt # Simulation input
mtt -dr pulse -dr r10 rc odeso ps # Simulation output

mtt rc rep txt			# This file

Deleted mttroot/mtt/lib/examples/Electrical/rc/step/rc_input.txt version [ae6bcdc7ad].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System rc, representation input, language txt; 
## File rc_input.txt; 
## Generated by MTT on Wed May  1 08:51:26 BST 2002; 



rc__e1	= 1.0;			# Step

Deleted mttroot/mtt/lib/examples/Electrical/rc2/rc2_abg.fig version [11a0341b79].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 1800 2700 1800 2475 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 1800 8100 1800 7875 2025
4 1 0 100 0 18 18 0.0000 4 270 1050 3330 1890 RC:rc_1\001
4 1 0 100 0 18 18 0.0000 4 270 1050 6075 1890 RC:rc_2\001
4 1 0 100 0 18 18 0.0000 4 270 600 8550 1890 De:y\001
4 1 0 100 0 18 18 0.0000 4 210 600 945 1845 Se:u\001

Deleted mttroot/mtt/lib/examples/Electrical/rc2/rc2_lbl.txt version [a4c4b7c15c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY rc2 Simple example of a heirachical system
#DESCRIPTION Uses 2 copies of the RC subsystem

## System rc2, representation lbl, language txt
## File rc2_lbl.txt
## Generated by MTT on Thu Mar 13 16:27:26 GMT 2003

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################


## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type De
	y	SS		external		

## Component type RC
	rc_1	lin		c_1;r_1
	rc_2	lin		c_2;r_2

## Component type Se
	u	SS		external		

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_abg.fig version [a81a2c225b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 900 2925 2475 2925 2250 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2970 2925 4545 2925 4320 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 2700 1125 2925 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2700 2475 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 2925 7200 2925 6975 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7447 2722 7447 1147 7672 1372
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7650 2925 9225 2925 9000 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7650 2700 7650 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7425 3150 7425 4725 7650 4500
4 1 -1 0 0 0 20 0.0000 4 195 135 2700 3015 1\001
4 2 -1 0 0 0 20 0.0000 4 195 615 855 3015 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 195 375 2745 990 R:r\001
4 1 -1 0 0 0 20 0.0000 4 195 870 5130 3015 CM:cm\001
4 1 -1 0 0 0 20 0.0000 4 195 135 7425 3015 1\001
4 1 -1 0 0 0 20 0.0000 4 195 405 7425 1035 C:k\001
4 0 -1 0 0 0 20 0.0000 4 195 540 9495 3015 SS:v\001
4 1 -1 0 0 0 20 0.0000 4 195 405 7380 5040 R:d\001

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_desc.tex version [fb1246fe80].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Electrostatic (Electrostatic_desc.tex)
% Generated by MTT on Fri Sep 19 18:07:08 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Electrostatic} is
   displayed in Figure \Ref{Electrostatic_abg} and its label
   file is listed in Section \Ref{sec:Electrostatic_lbl}.
   The subsystems are listed in Section \Ref{sec:Electrostatic_sub}.

This is a simple electrostatic speaker using the \textbf{CM}
transducer component together with an electrical \textbf{R} and a
mechanical \textbf{R} and \textbf{C} components to model a compliant
support for the moving plate. See Karnopp, Margolis and Rosenberg
Section 8.2 for a similar example.

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_input.txt version [25020041f1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Electrostatic_input.txt)
# Generated by MTT at Fri Sep 19 17:34:53 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:42:25  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Thu Jun  5 15:47:51 BST 2003: u(1) =	1.0; # V (Default value)
electrostatic__v	= 1.0; # Added by MTT on Thu Jun 05 15:47:54 BST 2003

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_lbl.txt version [f7c965ed2d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Electrostatic: Simple electrostatic speaker model (uses CM)
%DESCRIPTION See Karnopp, Margolis & Rosenberg Section 8.2
%% Label file for system Electrostatic (Electrostatic_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	k		lin	state,k	

% Component type CM
	cm		none	c_0;x_0;m	

% Component type R
	d		lin	flow,d
	r		lin	flow,r

% Component type SS
	V		SS	external,internal
	v		SS	0,external

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_numpar.txt version [6073a2643a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Electrostatic_numpar.txt)
# Generated by MTT at Fri Sep 19 17:43:25 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:42:25  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_0 = 	1.0; # Parameter c_0 for Electrostatic
d = 	1.0; # Parameter d for Electrostatic
k = 	100.0; # Parameter k for Electrostatic
m = 	1.0; # Parameter m for Electrostatic
r = 	1.0; # Parameter r for Electrostatic
x_0 = 	1.0; # Parameter x_0 for Electrostatic

# Initial states
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(1) = 	0.0; # Initial state for Electrostatic (k)
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(2) = 	0.0; # Initial state for Electrostatic_cm (transducer)
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(3) = 	1.0; # Initial state for Electrostatic_cm (transducer)
## Removed by MTT on Thu Jun  5 15:45:05 BST 2003: x(4) = 	0.0; # Initial state for Electrostatic_cm (mass)

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_rep.txt version [6fccff7b53].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Electrostatic (Electrostatic_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:42:25  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Electrostatic abg tex
mtt Electrostatic struc tex
mtt Electrostatic ode tex
mtt Electrostatic numpar txt
mtt Electrostatic input txt
mtt Electrostatic simpar txt
mtt Electrostatic odeso ps

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_simp.r version [d5350ddac2].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system Electrostatic (Electrostatic_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Electromechanical/Electrostatic/Electrostatic_state.txt version [2359358d24].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System Electrostatic, representation state, language txt; 
## File Electrostatic_state.txt; 
## Generated by MTT on Mon Feb  5 16:40:35 GMT 2001; 



## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_cm_1_mass	= 0.0; # Default
## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_cm_1_transducer	= 0.0; # Default
## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: ## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_cm_1_transducer_2	= 1.0; #  plate displacement
## Removed by MTT on Thu Jun  5 15:45:42 BST 2003: Electrostatic_k	= 0.0; # Default
electrostatic__cm__mass	= 0.0; 
electrostatic__cm__transducer	= 0.0;
electrostatic__cm__transducer_2	= 1.0;
electrostatic__k	= 0.0;

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_abg.fig version [41ab75b11d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 6930 405 13770 3600
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8328 2028 9903 2028 9903 2928 8328 2928 8328 2028
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 2475 8190 2475 7965 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11475 2250 11475 1035 11700 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11700 2475 12915 2475 12690 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12915 2250 12915 2700
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 12150 3150 10800 3150 10800 450 12150 450 12150 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10035 2475 11250 2475 11025 2700
4 1 -1 0 0 0 20 0.0000 4 255 1110 9138 2568 DC:gener\001
4 1 1 1 0 3 20 0.0000 4 255 1575 9225 3510 DC generator\001
4 1 -1 0 0 0 20 0.0000 4 195 135 11475 2610 0\001
4 1 -1 0 0 0 20 0.0000 4 195 675 13410 2610 SS:v2\001
4 1 -1 0 0 0 20 0.0000 4 255 585 11475 900 R:r_l\001
4 1 1 1 0 3 20 0.0000 4 210 1575 11475 3510 Resistive load\001
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1170 2475 2385 2475 2160 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4186 2476 5401 2476 5176 2701
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 13185 4275 13185 225 45 225 45 4275 13185 4275
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 2476 2026 4051 2026 4051 2926 2476 2926 2476 2026
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7245 2925 4950 2925 4950 2025 7245 2025 7245 2925
4 1 -1 0 0 0 20 0.0000 4 195 1170 3286 2566 DC:motor\001
4 1 1 1 0 3 20 0.0000 4 195 1155 3285 3510 DC motor\001
4 1 -1 0 0 0 20 0.0000 4 195 1275 6120 2520 Shaft:shaft\001
4 1 1 1 0 3 20 0.0000 4 270 1605 6165 3510 Flexible shaft\001
4 1 4 100 0 18 14 0.0000 4 210 1110 2250 1890 [Electrical]\001
4 1 4 100 0 18 14 0.0000 4 210 1110 10170 1980 [Electrical]\001
4 1 4 100 0 18 14 0.0000 4 210 1335 4140 1890 [Mechanical]\001
4 1 4 100 0 18 14 0.0000 4 210 1335 8325 1980 [Mechanical]\001
4 1 -1 0 0 0 20 0.0000 4 195 885 675 2565 PSU:v1\001

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_desc.tex version [3ad4972bd4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117





















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system MotorGenerator (MotorGenerator_desc.tex)
% Generated by MTT on Thu Nov 16 13:11:36 GMT 2000.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:43:16  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MotorGenerator} is
   displayed in Figure \Ref{fig:MotorGenerator_abg.ps} and its label
   file is listed in Section \Ref{sec:MotorGenerator_lbl}.
   The subsystems are listed in Section \Ref{sec:MotorGenerator_sub}.

This example illustates:
\begin{itemize}
\item The reuse of the DC model as both a motor and a generator
\item The assignment of a \emph{domain} and \emph{units} to component ports.
\end{itemize}

The command:
\begin{verbatim}
mtt -I MotorGenerator ese r
\end{verbatim}
gives the following output (irrelevant parts ommitted)
\begin{verbatim}
MTT (Model Transformation Tools) version 4.8
($Date$)
This is free software with ABSOLUTELY NO WARRANTY.
Type `mtt warranty' for details.

Creating MotorGenerator_rbg.m
Creating MotorGenerator_cmp.m
Creating MotorGenerator_fig.fig
Creating MotorGenerator_sabg.fig
Creating MotorGenerator_alias.txt
Creating MotorGenerator_alias.m
Creating MotorGenerator_sub.sh
Copying DC from /home/peterg/mtt_new/mtt-lib/comp/compound/Electromechanical/DC to .
Creating DC_rbg.m
Creating DC_cmp.m
Creating DC_fig.fig
Creating DC_sabg.fig
Creating DC_alias.txt
Creating DC_alias.m
Creating DC_sub.sh
Creating DC_abg.m
Checking port domains and units
     domains and units are OK

...

Creating PSU_rbg.m
Creating PSU_cmp.m
Creating PSU_fig.fig
Creating PSU_sabg.fig
Creating PSU_alias.txt
Creating PSU_alias.m
Creating PSU_sub.sh
Copying Se from /home/peterg/mtt_new/mtt-lib/comp/compound/General/Se to .
Creating Se_rbg.m
Creating Se_cmp.m
Creating Se_fig.fig
Creating Se_sabg.fig
Creating Se_alias.txt
Creating Se_alias.m
Creating Se_sub.sh
Creating Se_abg.m
Checking port domains and units
  no domains or units declared
.... 

Creating PSU_abg.m
Checking port domains and units
     domains and units are OK
...

Creating Shaft_rbg.m
Creating Shaft_cmp.m
Creating Shaft_fig.fig
Creating Shaft_sabg.fig
Creating Shaft_alias.txt
Creating Shaft_alias.m
Creating Shaft_sub.sh
Creating Shaft_abg.m
Checking port domains and units
     domains and units are OK
....

Creating MotorGenerator_abg.m
Checking port domains and units
  no domains or units declared

Creating MotorGenerator_cbg.m (maximise integral causality)
Creating MotorGenerator_type.sh
 .....
Creating MotorGenerator_ese.r
Creating MotorGenerator_def.r
Creating MotorGenerator_struc.txt
...
INFORMATION: Component MotorGenerator connects ports with units volt and volt
INFORMATION: Component MotorGenerator connects ports with units amp and amp
...
INFORMATION: Component MotorGenerator connects ports with units N*m and N*m
INFORMATION: Component MotorGenerator connects ports with units radians/s and radians/s
...
INFORMATION: Component MotorGenerator connects ports with units N*m and N*m
INFORMATION: Component MotorGenerator connects ports with units radians/s and radians/s
Creating MotorGenerator_aliased.txt
Copying MotorGenerator_ese.r

\end{verbatim}

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_input.txt version [887fa90928].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System MotorGenerator, representation input, language txt; 
## File MotorGenerator_input.txt; 
## Generated by MTT on Mon Dec  9 09:08:54 UTC 2002; 



## Removed by MTT on Thu Jun  5 16:43:47 BST 2003: MotorGenerator_v1_v_u	= 1.0; # Default
motorgenerator__v1__v__u	= 1.0; # Added by MTT on Thu Jun 05 16:43:50 BST 2003

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_lbl.txt version [d4522ab96a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY MotorGenerator: Motor-generator example
%DESCRIPTION A simple example of DC motor driving a generator via
%DESCRIPTION a flexible shaft

%% Label file for system MotorGenerator (MotorGenerator_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/11/16 09:58:49  peterg
% %% Initial revision
% %%
% %% Revision 1.3  2000/05/20 16:38:40  peterg
% %% New SS foramt
% %%
% %% Revision 1.2  1998/04/04 10:51:59  peterg
% %% New version using port coercion
% %%
% %% Revision 1.1  1996/12/04  16:24:01  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Voltage in
v1	SS	external,internal

% Voltage out
v2	SS	external,0

%Motor
motor		lin	k_m;l_m;r_m;j_m;b_m

%Shaft
shaft	        lin     c_s

%Generator
gener		lin	k_g;l_g;r_g;j_g;b_g

% Resistive load
r_l		lin	flow,r_l

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_numpar.txt version [6fa5d2a477].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (MotorGenerator_numpar.txt)
# Generated by MTT at Wed Dec 10 08:29:31 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/04 14:42:47  peterg
# %% Initial revision
# %%
# %% Revision 1.1  2000/08/01 12:26:48  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b_g = 	0.0; # Parameter b_g for MotorGenerator
b_m = 	0.0; # Parameter b_m for MotorGenerator
c_s = 	0.01; # Parameter c_s for MotorGenerator
j_g = 	1.0; # Parameter j_g for MotorGenerator
j_m = 	1.0; # Parameter j_m for MotorGenerator
k_g = 	1.0; # Parameter k_g for MotorGenerator
k_m = 	1.0; # Parameter k_m for MotorGenerator
l_g = 	0.1; # Parameter l_g for MotorGenerator
l_m = 	0.1; # Parameter l_m for MotorGenerator
r_g = 	0.1; # Parameter r_g for MotorGenerator
r_l = 	1.0; # Parameter r_l for MotorGenerator
## Removed by MTT on Mon Dec  4 14:44:19 GMT 2000: r_m_1 = 	0.1; # Parameter r_m for MotorGenerator

r_m	= 0.1; # Added by MTT on Mon Dec 04 14:44:44 GMT 2000

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_rep.txt version [e2275ca135].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system MotorGenerator (MotorGenerator_rep.txt)
## Generated by MTT on" Thu Nov 16 13:37:07 GMT 2000.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt MotorGenerator abg tex			# The system description
mtt MotorGenerator cbg ps 		        # The causal bond graph
mtt MotorGenerator struc tex	        # The system structure
mtt MotorGenerator sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt MotorGenerator dae tex	        # The system dae
mtt MotorGenerator ode tex	        # The system ode 
## mtt MotorGenerator sspar tex		# Steady-state parameters
## mtt MotorGenerator ss tex 		# Steady state
## mtt MotorGenerator dm tex		# Descriptor matrices (of linearised system)
mtt MotorGenerator sm tex		# State matrices (of linearised system)
##mtt MotorGenerator tf tex		# Transfer function (of linearised system)
## mtt MotorGenerator lmfr ps		# log modulus of frequency response (of linearised system)
## mtt MotorGenerator simpar tex		# Simulation parameters
## mtt MotorGenerator numpar tex		# Numerical simulation parameters
## mtt MotorGenerator state tex		# Simulation initial state
## mtt MotorGenerator input tex		# Simulation input
## mtt MotorGenerator logic tex		# Logic control
mtt MotorGenerator odeso ps		# Simulation output

mtt MotorGenerator rep txt		# This file

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/MotorGenerator_simpar.txt version [75937c9851].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system MotorGenerator (MotorGenerator_simpar.txt)
# Generated by MTT on Fri Dec 1 18:03:55 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/PSU_abg.fig version [ee661e106f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 1710 4860 2025
4 0 4 100 0 18 18 0.0000 4 270 1065 3780 1935 SS:[out]\001
-6
6 1530 675 4995 3015
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 4950 2970 1575 2970 1575 720 4950 720 4950 2970
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 1845 3600 1845 3375 2070
4 1 0 100 0 18 18 0.0000 4 210 570 1890 1935 Se:v\001

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/PSU_lbl.txt version [0875be2315].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system PSU (PSU_lbl.txt)
%SUMMARY PSU
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%UNITS out electrical volt amp 
% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[out]	SS		external,external

% Component type Se
	v	SS		external

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/Shaft_abg.fig version [7e87b19fce].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 1440 405 4410 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 2250 2925 1035 3150 1260
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1486 2476 2701 2476 2476 2701
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 3600 3150 2250 3150 2250 450 3600 450 3600 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 4365 2475 4140 2700
4 1 -1 0 0 0 20 0.0000 4 195 135 2925 2565 0\001
4 1 -1 0 0 0 20 0.0000 4 255 630 2925 900 C:c_s\001
4 1 1 1 0 3 20 0.0000 4 270 1605 2925 3510 Flexible shaft\001
-6
6 540 2340 1440 2655
4 2 4 100 0 18 18 0.0000 4 270 870 1440 2565 SS:[in]\001
-6
6 4455 2340 5535 2655
4 0 4 100 0 18 18 0.0000 4 270 1065 4455 2565 SS:[out]\001
-6
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 5850 3825 450 3825 450 225 5850 225 5850 3825

Deleted mttroot/mtt/lib/examples/Electromechanical/MotorGenerator/Shaft_lbl.txt version [b9f5e1ab44].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Shaft (Shaft_lbl.txt)
%SUMMARY Shaft
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:43:16  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases


% Unit definitions
%UNITS in  rotational N*m radians/s
%UNITS out rotational N*m radians/s

% Argument aliases
%ALIAS	$1	c_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	c_s	lin		effort,c_s

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_abg.fig version [0983c47273].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 4 1 7 1 0 -1 0.000 0 0 -1 0 0 4
	 2700 2025 7875 2025 7875 9450 2700 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 6525 5625 7875 5850 7650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3780 5625 5130 5850 4905
2 2 0 2 1 3 1 0 20 0.000 0 0 0 0 0 5
	 2700 5175 7875 5175 7875 6525 2700 6525 2700 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2835 855 2835 5850 3060 5625
2 2 0 2 1 3 1 0 20 0.000 0 0 0 0 0 5
	 2700 1575 2970 1575 2970 5175 2700 5175 2700 1575
2 1 1 2 1 7 1 0 -1 6.000 0 0 -1 0 0 2
	 2700 585 2700 9855
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 10125 9450 225 1125 225 1125 10125 9450 10125
4 1 4 0 0 0 20 0.0000 4 240 3075 5625 8190 [mechanical,mass,thermal]\001
4 1 -1 0 0 0 30 0.0000 4 300 1950 5625 8595 CG:bottom\001
4 1 4 0 0 0 20 0.0000 4 255 3885 5625 6345 [mechanical_b,mass_b,thermal_b]\001
4 1 -1 0 0 0 30 0.0000 4 405 3345 5625 5940 LeakyPiston:piston\001
4 1 -1 0 0 0 30 0.0000 4 405 1260 5625 3285 CG:top\001
4 1 4 0 0 0 20 0.0000 4 240 3075 5625 3600 [mechanical,mass,thermal]\001
4 1 4 0 0 0 20 0.0000 4 255 3750 5625 5400 [mechanical_t,mass_t,thermal_t]\001
4 1 4 0 0 0 20 0.0000 4 240 750 3375 5895 [shaft]\001
4 0 -1 0 0 0 20 0.0000 4 195 975 2925 900 SS:shaft\001

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_desc.tex version [0efd064e91].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system LeakyCylinder (LeakyCylinder_desc.tex)
% Generated by MTT on Tue Nov 25 17:22:29 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:44:35  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{LeakyCylinder} is
   displayed in Figure \Ref{LeakyCylinder_abg} and its label
   file is listed in Section \Ref{sec:LeakyCylinder_lbl}.
   The subsystems are listed in Section \Ref{sec:LeakyCylinder_sub}.

This example roughly corresponds to the Example in section 12.4.3
(Fig. 12.17) of Karnopp, Margolis and Rosenberg (1990). It is a pseudo bond
graph representation based on the ``thermal accumulator'' of  section
12.4.1 and the ``isentropic nozzle'' of section 12.4.2 of that book.

[
Notes added by PJG 10 June 03. 
\begin{enumerate}
\item The parameters/states used in the simulation (odeso) are
  meaningless at the moment.
\item The steady-state parameters (sspar.r) need to be calculated; at
  the moment, the state mattrices (sm) are in terms of the
  steady-state states.  
\end{enumerate}
]

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_input.txt version [8ad664ff23].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (LeakyCylinder_input.txt)
# Generated by MTT at Tue Nov 25 17:00:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	0.0; # shaft

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_lbl.txt version [b1e5813551].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY LeakyCylinder: Pseudo bond graph model of compressible gas dynamics

%DESCRIPTION This example roughly corresponds to the Example in
%DESCRIPTION section 12.4.3 (Fig. 12.17) of Karnopp, Margolis and Rosenberg
%DESCRIPTION (1990). It is a pseudo bond graph representation based on the
%DESCRIPTION "thermal acummulator" of section 12.4.1 and the "isentropic
%DESCRIPTION nozzle" of section 12.4.2 of that book.

%% Label file for system LeakyCylinder (LeakyCylinder_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/04 09:56:05  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CG
	bottom		none	c_v;r
	top		none	c_v;r

% Component type LeakyPiston
	piston		none	m_p;a_b;a_t;gamma;r;0

% Component type SS
	shaft		SS	external,external

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_numpar.txt version [e23dfd6a5b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (LeakyCylinder_numpar.txt)
# Generated by MTT at Mon Dec  1 08:59:51 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:44:35  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
a_b = 	1.0; # Parameter a_b for LeakyCylinder
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: a_l = 	1.0; # Parameter a_l for LeakyCylinder
a_t = 	1.0; # Parameter a_t for LeakyCylinder
c_v = 	1.0; # Parameter c_v for LeakyCylinder
gamma = 	1.0; # Parameter gamma for LeakyCylinder
m_p = 	1.0; # Parameter m_p for LeakyCylinder
r = 	1.0; # Parameter r for LeakyCylinder

# Initial states
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: x(3) = 	0.0; # Initial state for LeakyCylinder_bottom (cg)
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: x(6) = 	0.0; # Initial state for LeakyCylinder_top (cg)
## Removed by MTT on Tue Jun 10 09:55:26 BST 2003: x(7) = 	0.0; # Initial state for LeakyCylinder_piston_piston (m_p)

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_rep.txt version [163616dd5e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system LeakyCylinder (LeakyCylinder_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2003/06/11 15:57:57  gawthrop
% %% Updated examples for latest MTT.
% %%
% %% Revision 1.1  2000/12/28 17:44:35  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt LeakyCylinder abg tex
mtt LeakyCylinder struc tex
mtt LeakyCylinder sympar tex
mtt LeakyCylinder ode tex
mtt LeakyCylinder ss tex
mtt LeakyCylinder sm tex
##mtt LeakyCylinder odeso ps

mtt LeakyCylinder rep txt


Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_simp.r version [163e4c6595].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system LeakyCylinder (LeakyCylinder_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyCylinder_sspar.r version [e6e5a3aadc].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for LeakyCylinder (LeakyCylinder_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyPiston_abg.fig version [c4c5b004af].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 3375 6300 4725 6525 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 3375 7200 4725 7425 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 6075 6300 8122 6525 7897
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7245 6075 7245 8100 7470 7875
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4500 9000 9225 9000
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 450 9000 4050 9000
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4050 9675 4050 450 450 450 450 9675 4050 9675
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9225 9675 4500 9675 4500 450 9225 450 9225 9675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 6300 1575 6525 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 2925 7200 1575 7425 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2925 3150 1575 3375 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 3150 4725 3375 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2056 4711 1101 3756 1101 4074
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 6075 3150 7425 3375 7200
4 0 4 0 0 0 20 0.0000 4 255 1440 7200 5040 [thermal_in]\001
4 1 4 0 0 0 20 0.0000 4 255 1110 6300 5040 [mass_in]\001
4 1 4 0 0 0 20 0.0000 4 255 1260 6300 5895 [mass_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1590 7200 5895 [thermal_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1755 7155 8505 SS:[thermal_b]\001
4 2 4 0 0 0 20 0.0000 4 255 1425 6255 8505 SS:[mass_b]\001
4 1 1 1 0 0 20 0.0000 4 195 1335 6750 9450 Leak model\001
4 1 1 1 0 0 20 0.0000 4 195 1515 2250 9405 Piston Model\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6300 3240 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 7200 3240 0\001
4 2 4 0 0 0 20 0.0000 4 255 2115 3195 1305 SS:[mechanical_t]\001
4 2 4 0 0 0 20 0.0000 4 255 1380 6345 1305 SS:[mass_t]\001
4 0 4 0 0 0 20 0.0000 4 255 1710 7155 1350 SS:[thermal_t]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3150 3240 0\001
4 1 4 0 0 0 20 0.0000 4 255 540 3150 5040 [top]\001
4 1 4 0 0 0 20 0.0000 4 240 750 2070 5040 [shaft]\001
4 1 4 0 0 0 20 0.0000 4 240 1155 1080 3645 SS:[shaft]\001
4 2 4 0 0 0 20 0.0000 4 255 2160 3150 7785 SS:[mechanical_b]\001
4 1 4 0 0 0 20 0.0000 4 240 990 3150 5940 [bottom]\001
4 1 -1 0 0 0 30 0.0000 4 300 1425 6885 5535 RG:leak\001
4 1 -1 0 0 0 30 0.0000 4 405 2295 2700 5535 Piston:piston\001

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyPiston_desc.tex version [56fe000716].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system LeakyPiston (LeakyPiston_desc.tex)
% Generated by MTT on Fri Nov 28 12:09:15 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{LeakyPiston} is
   displayed in Figure \Ref{LeakyPiston_abg} and its label
   file is listed in Section \Ref{sec:LeakyPiston_lbl}.
   The subsystems are listed in Section \Ref{sec:LeakyPiston_sub}.

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/LeakyPiston_lbl.txt version [552b5840bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY LeakyPiston: Leaky piston sub model
%DESCRIPTION <Detailed description here>
%% Label file for system LeakyPiston (LeakyPiston_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/04 10:00:11  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type Piston
	piston		lin	$1;$2;$3

% Component type RG
	leak		lin	$4;$5;$6

% Component type SS
	[mass_b]	SS	external,external
	[mass_t]	SS	external,external
	[mechanical_b]	SS	external,external
	[mechanical_t]	SS	external,external
	[shaft]		SS	external,external
	[thermal_b]	SS	external,external
	[thermal_t]	SS	external,external

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/Piston_abg.fig version [357fe6faa9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 1575 6075 3150 6300 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3600 6075 4275 6300 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 4636 6075 5311 6300 5086
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 4500 4500 4500 4725 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5905 4281 4950 3326 4950 3645
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 5850 6075 7200 6300 6975
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 8100 6975 8100
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6975 8775 6975 900 3375 900 3375 8775 6975 8775
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9945 9225 9945 450 450 450 450 9225 9945 9225
4 1 -1 0 0 0 20 0.0000 4 255 780 6120 3465 TF:a_t\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6075 4590 1\001
4 2 4 0 0 0 20 0.0000 4 240 1155 4905 3240 SS:[shaft]\001
4 1 -1 0 0 0 20 0.0000 4 255 660 4050 4545 I:m_p\001
4 1 -1 0 0 0 20 0.0000 4 255 825 6075 5670 TF:a_b\001
4 2 4 0 0 0 20 0.0000 4 240 1395 6120 7650 SS:[bottom]\001
4 1 1 1 0 0 20 0.0000 4 195 1515 5175 8505 Piston Model\001
4 2 4 0 0 0 20 0.0000 4 255 945 6120 1395 SS:[top]\001

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/Piston_desc.tex version [76d5324126].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Piston (Piston_desc.tex)
% Generated by MTT on Fri Nov 28 12:09:27 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Piston} is
   displayed in Figure \Ref{Piston_abg} and its label
   file is listed in Section \Ref{sec:Piston_lbl}.
   The subsystems are listed in Section \Ref{sec:Piston_sub}.

The two {\bf TF} components convert pressure to force. The {\bf I}
component represents piston inertia.

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/GasDynamics/LeakyCylinder/Piston_lbl.txt version [a07bef4048].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Piston: simple model of the piston
%DESCRIPTION Inludes inertia and pressure effects.
%% Label file for system Piston (Piston_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/04 10:01:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	m_p		lin	flow,$1

% Component type SS
	[bottom]	SS	external,external
	[shaft]		SS	external,external
	[top]		SS	external,external

% Component type TF
	a_b		lin	flow,$2
	a_t		lin	effort,$3

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_abg.fig version [4d929f234d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
6 3150 4410 5940 4995
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 3154 4730 5449 4730 5404 4730
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3379 4730 3154 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3604 4730 3379 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3829 4730 3604 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4054 4730 3829 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4279 4730 4054 4955
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4505 4731 4280 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4730 4731 4505 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4955 4731 4730 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5180 4731 4955 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5405 4731 5180 4956
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 5897 4413 5627 4683
-6
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 4276 2206 612 612 4276 2206 4636 2701
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	0 0 2.00 120.00 240.00
	 5176 1531 4906 1801
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 2475 5175 3600 5175 3330
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2250 2925 2250 3150 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2070 4275 946 4500 1171
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 4275 2475 4500 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4297 4522 4297 5646 4522 5421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3600 7875 3600 7650 3825
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 6300 8775 225 225 225 225 6300 8775 6300
4 2 -1 0 0 2 20 0.0000000 4 240 2130 2835 2250 R:air_resistance\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4276 2341 1\001
4 1 1 1 0 3 20 0.0000000 4 210 525 5176 1441 Ball\001
4 0 -1 0 0 2 20 0.0000000 4 270 1365 5760 2340 SS:gravity\001
4 1 -1 0 0 2 20 0.0000000 4 240 1515 4275 810 I:ball_mass\001
4 1 -1 0 0 2 20 0.0000000 4 270 1710 4320 5940 CSW:ground\001
4 1 1 1 0 3 20 0.0000000 4 210 960 6030 4275 Ground\001
4 1 1 1 0 3 20 0.0000000 4 150 135 4590 3465 v\001
4 1 1 1 0 3 20 0.0000000 4 150 315 4590 5220 -v\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4275 4365 0\001
4 1 -1 0 0 2 20 0.0000000 4 210 1275 5985 3690 INTF:intf\001
4 0 -1 0 0 2 20 0.0000000 4 210 585 8010 3690 SS:x\001

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_desc.tex version [422d8be2ce].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Bounce (Bounce_desc.tex)
% Generated by MTT on Wed Jul 2 10:55:51 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:45:24  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Bounce}, togehter with a
   schematic diagram is
   displayed in Figure \Ref{Bounce_abg} and its label
   file is listed in Section \Ref{sec:Bounce_lbl}.
   The subsystems are listed in Section \Ref{sec:Bounce_sub}.

The model uses the {\bf CSW} switched {\bf C} element to simulate
contact with the ground. The corresponding switching function (See
Section \ref{sec:Bounce_input-noargs.txt}), is based on the height above the
ground $h$ as follows:
\begin{equation}
i_{sw} = 
  \begin{cases}
    0 & \text{if $h > 0$}\\
    -1 & \text{if $h \le 0$}
  \end{cases}
\end{equation}

In other words, the component acts as an ideal spring when the ball is
in contact with the ground yet has no effect when the ball is not in
contact with the ground.

The ball is modelled as a point mass (the \textbf{I} component) and  a
linear resistance to motion (the  (the \textbf{R} component).

The system was simulated for 100 time units and the resultant height
is plotted in Figure \ref{fig:Bounce_odeso-noargs.ps}. The ball was released at zero
velocity from a height of ten units. The bounce height decreases due to
the effect of the modelled air resistance.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_input.txt version [c668d16412].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Bounce_input.txt)
# Generated by MTT at Wed Jul  2 10:47:49 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.4  2001/10/05 11:24:29  gawthrop
# %% Updated for new mtt features - input.txt etc
# %%
# %% Revision 1.3  2000/05/18 11:30:14  peterg
# %% Moved switch logic to logic.txt
# %%
# %% Revision 1.2  1998/10/01 19:20:33  peterg
# %% Cahged switch function
# %%
# %% Revision 1.1  1998/07/25 18:35:02  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Fri Oct  5 10:37:56 BST 2001: mttu(1) = 9.81;


## Removed by MTT on Tue Jun 10 10:22:08 BST 2003: bounce_gravity	= 9.81; # Added by MTT on Fri Oct 05 10:37:59 BST 2001
bounce__gravity	= 9.81;

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_lbl.txt version [3c29396b81].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Bounce: Bouncing ball example (hybrid)
%DESCRIPTION <Detailed description here>
%% Label file for system Bounce (Bounce_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 09:54:22  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type INTF
	intf

% Component type CSW
	ground		lin	state,k_g

% Component type I
	ball_mass		lin	flow,m

% Component type R
	air_resistance		lin	flow,r

% Component type SS
	gravity			SS	external,internal
	x			SS	external,0

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_logic.txt version [68ac8bc9fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Bounce (Bounce_logic.txt)
# Generated by MTT on Thu May 18 12:29:15 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 13:14:12  geraint
## Updated names.
##
## Revision 1.2  2000/12/28 17:45:24  peterg
## To RCS
##
## Revision 1.1  2000/05/18 11:29:58  peterg
## Initial revision
##
###############################################################


# Set the switches

## On when below ground level
bounce__ground__mtt_switch_logic	= (bounce__intf__mttc < 0);

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_numpar.txt version [3190429a19].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Bounce_numpar.txt)
# Generated by MTT at Wed Jul  2 10:47:47 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:45:24  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
k_g = 	100.0; # Ground stiffness
m = 	1.0; # Ball mass
r = 	1.0; # Air resistance

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_rep.txt version [d2abad5353].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Bounce (Bounce_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/19 07:09:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Bounce abg tex
mtt Bounce struc tex
mtt Bounce ode tex


mtt Bounce simpar txt
mtt Bounce input txt
mtt Bounce logic txt
mtt Bounce numpar txt

mtt Bounce odeso ps

mtt Bounce rep txt

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_simpar.txt version [17a4ac93f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Simulation parameters for system Bounce (Bounce_simpar.txt)
# Generated by MTT on Sat Jul 25 15:57:56 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/10/01 19:21:04  peterg
## Initial revision
##
###############################################################
FIRST=0.0;
LAST=10.0;
DT=0.02;
STEPFACTOR=1;

Deleted mttroot/mtt/lib/examples/Hybrid/Bounce/Bounce_state.txt version [975ae5de24].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*-
# Initial state  file (Bounce_state.txt)
# Generated by MTT at Sat Jul 25 15:56:57 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  2002/09/29 13:14:12  geraint
## Updated names.
##
## Revision 1.3  2001/10/05 11:24:30  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.2  1998/07/25 20:34:05  peterg
## *** empty log message ***
##
## Revision 1.1  1998/07/25 14:59:11  peterg
## Initial revision
##
###############################################################

# Set the states
## Removed by MTT on Tue Jun 10 10:23:07 BST 2003: bounce_ball_mass		=  0.0; # 
## Removed by MTT on Tue Jun 10 10:23:07 BST 2003: bounce_ground_mtt_switch	=  0.0; #
## Removed by MTT on Tue Jun 10 10:23:07 BST 2003: bounce_intf_mttc		= 10.0; #
bounce__ball_mass	= 0.0;	# Zero velocity
bounce__ground__mtt_switch	= 0.0; # Not on ground
bounce__intf__mttc	= 10.0; # 10m above ground

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_abg.fig version [c0c525deaf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
6 3513 9498 8733 9858
6 3513 9498 4953 9813
6 3513 9498 4233 9768
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3514 9724 3739 9499
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3739 9724 3964 9499
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3964 9724 4189 9499
-6
6 4189 9499 4909 9769
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4190 9725 4415 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4415 9725 4640 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4640 9725 4865 9500
-6
-6
6 4864 9499 6304 9814
6 4864 9499 5584 9769
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4865 9725 5090 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5090 9725 5315 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5315 9725 5540 9500
-6
6 5540 9500 6260 9770
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5541 9726 5766 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5766 9726 5991 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 5991 9726 6216 9501
-6
-6
6 6214 9499 6934 9769
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6215 9725 6440 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6440 9725 6665 9500
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6665 9725 6890 9500
-6
6 6890 9500 7610 9770
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6891 9726 7116 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7116 9726 7341 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7341 9726 7566 9501
-6
6 7565 9500 8285 9770
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7566 9726 7791 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7791 9726 8016 9501
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 8016 9726 8241 9501
-6
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3514 9499 8689 9499
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 8242 9727 8467 9502
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 8467 9727 8692 9502
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4727 2072 4727 3647 4952 3422
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6077 2072 6077 3647 6302 3422
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 3647 4952 3647
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5852 3647 6302 3647
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7202 3647 7652 3647
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 8823 4728 10398 4953 10173
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 6571 2926 6571 3151 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2251 6797 2251 8372 2476 8147
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9923 6774 9923 8349 10148 8124
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5851 4771 6301 4771
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 8372 4726 6797 4951 7022
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4501 6346 4501 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7651 6346 7651 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7629 6571 9204 6571 8979 6796
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 6347 4726 4772 4951 4997
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2521 4186 4096 4186 3871 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4096 3961 4096 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 4770 7426 6345 7651 6120
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 6795 7426 8370 7651 8145
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 4186 9676 4186 9451 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8101 3961 8101 4411
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 3647 7426 2072 7651 2297
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6076 4772 6076 6347 6301 6122
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 8820 7426 10395 7651 10170
2 2 0 2 1 3 1 0 20 0.000 0 0 0 0 0 5
	 3827 3422 8327 3422 8327 4997 3827 4997 3827 3422
2 1 0 3 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 3.00 180.00 360.00
	 9226 2521 8371 3196
2 1 0 3 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 3.00 180.00 360.00
	 11458 7718 10603 8393
2 1 0 3 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 3.00 180.00 360.00
	 701 7685 1556 8360
4 1 -1 0 0 2 20 0.0000000 4 210 1470 2115 6660 INTF:intfL\001
4 1 -1 0 0 2 20 0.0000000 4 210 1215 6077 4322 ROD:rod\001
4 1 4 0 0 2 20 0.0000000 4 240 360 6077 3962 [p7]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 6077 4637 [p8]\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4727 6662 1\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 7427 6662 1\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 4728 8688 0\001
4 1 -1 0 0 2 20 0.0000000 4 270 1905 4728 10713 CSW:groundL\001
4 1 -1 0 0 2 20 0.0000000 4 210 150 7428 8688 0\001
4 1 -1 0 0 2 20 0.0000000 4 270 1365 6077 6662 SS:gravity\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 10217 4277 SS:aR\001
4 1 -1 0 0 2 20 0.0000000 4 210 1485 10126 6661 INTF:intfR\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 2251 8641 SS:hL\001
4 1 -1 0 0 2 20 0.0000000 4 210 810 9946 8641 SS:hR\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 6077 1937 SS:xC\001
4 1 -1 0 0 2 20 0.0000000 4 270 1920 7426 10711 CSW:groundR\001
4 1 -1 0 0 2 20 0.0000000 4 210 780 4727 1937 SS:xL\001
4 1 -1 0 0 2 20 0.0000000 4 210 795 7427 1937 SS:xR\001
4 1 4 0 0 2 20 0.0000000 4 240 360 4727 3962 [p3]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 7427 3962 [p4]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 4727 4637 [p5]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 7426 4636 [p6]\001
4 1 -1 0 0 2 20 0.0000000 4 210 780 2026 4276 SS:aL\001
4 1 4 0 0 2 20 0.0000000 4 240 360 4411 4276 [p1]\001
4 1 4 0 0 2 20 0.0000000 4 240 360 7876 4321 [p2]\001
4 0 1 1 0 3 30 0.0000000 4 300 1470 5311 10171 Ground\001
4 0 1 1 0 3 30 0.0000000 4 390 2685 8326 2476 Bouncing Rod\001
4 0 1 1 0 3 30 0.0000000 4 390 3315 11026 7651 Height of right tip\001
4 2 1 1 0 3 30 0.0000000 4 390 3000 1800 7515 Height of left tip\001

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_desc.tex version [924a60ed36].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system BouncingRod (BouncingRod_desc.tex)
% Generated by MTT on Sun Jul 6 17:21:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/20 09:36:24  peterg
% %% *** empty log message ***
% %%
% Revision 1.1  1997/07/06  16:35:20  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{BouncingRod} is displayed in
Figure \Ref{BouncingRod_abg} and its label file is listed in Section
\Ref{sec:BouncingRod_lbl}. 
 The subsystems are listed in Section
\Ref{sec:BouncingRod_sub}.

The system consists of a uniform rod of mass 1kg, length 2m (and
therefore of inertia about the mass centre of $\frac{1}{3}
\text{kgm}^2$. The rod is released at an angle of $\frac{\pi}{4}$ from
the vertical, the mass centre is $10\text{m}$ above the ground and all
velocities are initially zero. The gravitational constant is taken as unity.

The ground is modeled as an ideal compliance in the vertical
direction with compliance of $0.1 \text{mN}^{-1}$ and it is assumed
that contact takes place at the rod tips only. There is no
horizontal resistance to motion. This idealised setup is modeled by a
two {\bf CSW} components, one for each rod tip, modulated by the
height of each rod tip above the ground: each  {\bf CSW} is off when
the corresponding height is positive.

The system was simulated for 100 time units and the resultant height
of each tip is plotted in Figure \ref{fig:BouncingRod_odeso-noargs.ps}. The rod was
released at zero velocity from a height of ten units and at an angle
of $\frac{\pi}{4}$ radians to the vertical. The oscillations in height
are due to rod rotation about its mass centre.  The bounce height
changes due to energy transfer to and from the rod rotation about its
mass centre.




%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: "yes"
%%% End: 

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_input.txt version [205c4ea63e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (BouncingRod_input.txt)
# Generated by MTT at Fri Jul  4 14:09:14 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2000/12/04 08:27:42  peterg
# %% New version
# %%
# %% Revision 1.1  1997/07/06 16:17:48  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Mon Dec  4 08:27:04 GMT 2000: u(1) =	9.81; # gravity (Default value)
## Removed by MTT on Tue Jun 10 10:33:30 BST 2003: bouncingrod_gravity	= 9.81; # Added by MTT on Mon Dec 04 08:27:10 GMT 2000
bouncingrod__gravity	= 9.81; # Gravity

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_lbl.txt version [60967407da].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY BouncingRod: Two-dimensional bouncing rod (hybrid)
%DESCRIPTION A uniform rod bounces on a compliant surface -- the
%DESCRIPTION CSW component is used.

%% Label file for system BouncingRod (BouncingRod_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.5  2000/12/04 08:36:23  peterg
% %% Declare pi
% %%
% %% Revision 1.4  2000/05/18 10:30:39  peterg
% %% New SS form
% %%
% %% Revision 1.3  1997/09/11 09:55:25  peterg
% %% Added documentation
% %%
% %% Revision 1.2  1997/09/11 08:37:29  peterg
% %% Added description
% %%
% %% Revision 1.1  1997/07/06 16:18:37  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CSW
	groundL		lin	effort,epsilon
	groundR		lin	effort,epsilon

% Component type INTF
	intfL
	intfR

% Component type ROD
	rod		none	l;l;j;m

% Component type SS
	aL		SS	0,internal
	aR		SS	0,internal
	gravity		SS	external,internal
	hL		SS	external,0
	hR		SS	external,0
	xC		SS	0,internal
	xL		SS	0,internal
	xR		SS	0,internal

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_logic.txt version [dfa5eb6acf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system BouncingRod (BouncingRod_logic.txt)
# Generated by MTT on Thu May 18 12:14:35 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/09/29 15:31:39  geraint
## Updated names.
##
## Revision 1.1  2000/12/28 17:45:59  peterg
## To RCS
##
###############################################################

# Set the switches
## Removed by MTT on Tue Jun 10 10:45:53 BST 2003: bouncingrod_groundl_mtt_switch_logic	= (bouncingrod_intfl_mttc <= 0);
## Removed by MTT on Tue Jun 10 10:45:53 BST 2003: bouncingrod_groundr_mtt_switch_logic	= (bouncingrod_intfr_mttc <= 0);
bouncingrod__groundl__mtt_switch_logic	= (bouncingrod__intfl__mttc <= 0); 
bouncingrod__groundr__mtt_switch_logic	= (bouncingrod__intfr__mttc <= 0);

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_numpar.txt version [653e854f15].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (BouncingRod_numpar.txt)
# Generated by MTT at Fri Jul  4 14:09:11 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2000/12/28 17:45:59  peterg
# %% To RCS
# %%
# %% Revision 1.1  1997/07/06 16:17:27  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
epsilon = 	0.01; 
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	l*l*m/3;



Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_odes.h version [8e08760d76].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
/*
%% Parameter file for system BouncingRod (BouncingRod_odes.h)
%% This file provides the params for simulation:
*/
#define DT 0.1 /* Time step (for printing) */
#define LAST 99.9 /* Last time */
#define STEPFACTOR 1000 /* Integration steps per time step */

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_rep.txt version [1e32455526].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system BouncingRod (BouncingRod_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 17:45:59  peterg
% %% To RCS
% %%
% %% Revision 1.1  1997/07/06 16:20:44  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt BouncingRod abg tex
mtt BouncingRod struc tex
mtt BouncingRod ode tex
mtt BouncingRod numpar txt
mtt BouncingRod input txt
mtt BouncingRod logic txt
mtt BouncingRod odeso ps



Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_simpar.txt version [b247367777].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Simulation parameters for system BouncingRod (BouncingRod_simpar.txt)
# Generated by MTT on Sun Jul 26 12:14:17 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/12/21 08:07:38  peterg
## Initial revision
##
###############################################################

LAST=20;
DT=0.01;
STEPFACTOR=1;


Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/BouncingRod_state.txt version [0f22d94928].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Initial state  file (BouncingRod_state.txt)
# Generated by MTT at Sun Jul 26 12:19:13 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 15:31:39  geraint
## Updated names.
##
## Revision 1.2  2002/05/10 12:38:11  gawthrop
## Updated to new format
##
## Revision 1.1  2000/12/28 17:45:59  peterg
## To RCS
##
###############################################################


# Set the states

## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_groundl_mtt_switch	= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_groundr_mtt_switch	= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_intfl_mttc		= 10 + sin(pi/4);
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_intfr_mttc		= 10 - sin(pi/4);
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_j		= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_m_x		= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_m_y		= 0.0;
## Removed by MTT on Tue Jun 10 10:31:03 BST 2003: bouncingrod_rod_th_mttc		= pi/4;
bouncingrod__groundl__mtt_switch	= 0.0;
bouncingrod__groundr__mtt_switch	= 0.0;
bouncingrod__intfl__mttc	= 10 + sin(pi/4); # Start at 45 degree angle
bouncingrod__intfr__mttc	= 10 - sin(pi/4); # Start at 45 degree angle
bouncingrod__rod__j	= 0.0; 
bouncingrod__rod__m_x	= 0.0; 
bouncingrod__rod__m_y	= 0.0; 
bouncingrod__rod__th__mttc	= pi/4; # Start at 45 degree angle

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/CSW_lbl.txt version [1a99199c4e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY ISW: Switched I component
%DESCRIPTION ISW acts as an I component except when the -s -c option is used.
%DESCRIPTION When the -s -c option is used:
%DESCRIPTION   The component label is used as a variable name (eg Name)
%DESCRIPTION   In the ode simulation:
%DESCRIPTION     Name = 1 implies normal I (closed switch)
%DESCRIPTION     Name = 0 implies state=0 (open switch)
%DESCRIPTION     Name = -1 implies state>0 (Diode)

%% Label file for system ISW (ISW_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/06/03 15:26:09  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	MTT_SWITCH		$1	$1

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/ROD_abg.fig version [34663585aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 3600 675 2250 675 2250 9675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 4 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 4 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 4 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 5625 2700 5400 1800 6300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 5401 5625 9001 5850 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 7875 2925 9000 3195 8730
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 7875 8325 9000 8595 8730
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8550 5400 9450 6300 9225 6300
4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001
4 1 -1 0 0 0 20 0.0000 4 240 720 8372 1217 SS:[p5]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 5671 9361 SS:[p2]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 8417 9362 SS:[p6]\001
4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001
4 1 26 0 0 0 16 0.0000 4 210 270 4501 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4501 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 3826 4051 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6301 4006 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 6211 6526 [mod]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4591 5896 [in]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4591 6841 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 3916 6526 [mod]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 2971 1216 SS:[p3]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 5671 1216 SS:[p1]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 2971 9361 SS:[p4]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4411 5446 [out]\001
4 1 26 0 0 0 16 0.0000 4 210 270 4906 5446 [in]\001
4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001
4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001
4 1 4 1 0 0 20 0.0000 4 255 390 1350 2700 Tip\001
4 1 4 1 0 0 20 0.0000 4 255 390 1350 9855 Tip\001
4 1 4 1 0 0 20 0.0000 4 195 1380 1080 6120 Mass centre\001
4 1 -1 0 0 0 20 0.0000 4 240 720 1710 6615 SS:[p7]\001
4 1 -1 0 0 0 20 0.0000 4 240 720 9495 6570 SS:[p8]\001

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/ROD_desc.tex version [da144b910f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Jul 4 10:30:17 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.


This is a special version just for this problem.

Deleted mttroot/mtt/lib/examples/Hybrid/BouncingRod/ROD_lbl.txt version [77bb98cc7c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	Port [1]:	Angular torque/velocity - end 1
%DESCRIPTION	Port [2]:	Angular torque/velocity - end 2
%DESCRIPTION	Port [3]:	x force/velocity - end 1
%DESCRIPTION	Port [4]:	x force/velocity - end 2
%DESCRIPTION	Port [5]:	y force/velocity - end 1
%DESCRIPTION	Port [6]:	y force/velocity - end 2
%DESCRIPTION	Port [7]:	x force/velocity - centre
%DESCRIPTION	Port [8]:	y force/velocity - centre
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system ROD (ROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2

% ports
	
[p1]	SS	external,external
[p2]	SS	external,external
[p3]	SS	external,external
[p4]	SS	external,external
[p5]	SS	external,external
[p6]	SS	external,external
[p7]	SS	external,external
[p8]	SS	external,external

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_abg.fig version [e07876e4d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 4726 3376 4726 2026 2476 2026 2476 3376 4726 3376
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8101 3376 8101 2026 5851 2026 5851 3376 8101 3376
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11476 3376 11476 2026 9226 2026 9226 3376 11476 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4501 2701 6076 2701 5941 2836
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 2701 9451 2701 9316 2836
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1126 2701 2701 2701 2566 2836
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 5400 11925 225 225 225 225 5400 11925 5400
4 1 -1 0 0 0 20 0.0000 4 195 1170 3511 2791 DC:motor\001
4 1 -1 0 0 0 20 0.0000 4 195 1140 10306 2791 Load:load\001
4 1 -1 0 0 0 20 0.0000 4 195 1290 7021 2791 Drive:drive\001
4 1 -1 0 0 0 20 0.0000 4 195 525 765 2790 SS:e\001

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_desc.tex version [46fab8044d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Clutch (Clutch_desc.tex)
% Generated by MTT on Thu Jul 3 13:57:59 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:46:44  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Clutch} is displayed in
   Figure \Ref{Clutch_abg} and its label file is listed in Section
   \Ref{sec:Clutch_lbl}.  The subsystems are listed in Section
   \Ref{sec:Clutch_sub}.  The details of the DC motor and the load are
   hidden behind a word bond graph so as to focus on the clutch
   mechanism as modelled by the \textbf{CSW} component.
  It is natural to model the clutch shaft by a
compliance to absorb the shock of engaging the clutch; therefore the
drive model contains a \textbf{CSW} component.


Figure \ref{fig:Clutch_odeso-noargs.ps}, shows the angular velocities of the motor
and load.  The clutch is engaged from time $t$ given by $0<t<15$; and
a unit input voltage is applied at time $t=0$. All initial conditions
are zero.

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_input.txt version [bd0caf2748].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Clutch_input.txt)
# Generated by MTT at Thu Jul  3 12:17:46 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2002/09/29 13:47:35  geraint
# %% Updated names.
# %%
# %% Revision 1.1  2000/05/19 07:10:03  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
clutch__e	= 1.0; # e (Default value)

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_lbl.txt version [60b6b4f3da].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Clutch: Simple model of a clutch system (Hybrid)
%DESCRIPTION Uses CSW component to model the clutch/flexi shaft
%% Label file for system Clutch (Clutch_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 09:38:48  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type DC
	motor		lin	k_m;l_a;r_a;j_m;b_m

% Component type Drive
	drive	

% Component type Load
	load	

% Component type SS
	e		SS	external,internal

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_logic.txt version [581d8453ec].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Clutch (Clutch_logic.txt)
# Generated by MTT on Thu May 18 12:29:15 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 13:47:35  geraint
## Updated names.
##
## Revision 1.2  2001/10/05 11:24:35  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.1  2000/05/19 07:11:36  peterg
## Initial revision
##
## Revision 1.1  2000/05/18 11:29:58  peterg
## Initial revision
##
###############################################################

# Set the switches
clutch__drive__clutch__mtt_switch_logic	= ((t >= 5)&&(t < 15)); # 

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_numpar.txt version [240d38c694].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Clutch_numpar.txt)
# Generated by MTT at Thu Jul  3 12:12:35 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
b_m = 	0.1; # Default value
epsilon = 	0.01;
j_l = 	1.0; # Default value
j_m = 	10.0; # Default value
k_m = 	1.0; # Default value
l_a = 	0.1; # Default value
r_a = 	1.0; # Default value
r_l = 	5.0; # Default value

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_rep.txt version [334e6789c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Clutch (Clutch_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/19 07:16:07  peterg
% %% Added logic
% %%
% %% Revision 1.1  1999/02/21 08:18:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt  Clutch abg tex
mtt  Clutch struc tex
mtt  Clutch ode tex
mtt  Clutch dm tex

mtt  Clutch simpar txt
mtt  Clutch input txt
mtt  Clutch logic txt
mtt  Clutch numpar txt

mtt  Clutch odeso ps

mtt  Clutch rep txt

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Clutch_simpar.txt version [e28a1ca3b7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Simulation parameters for system Clutch (Clutch_simpar.txt)
# Generated by MTT on Sun Jul 26 13:26:44 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/12/21 09:13:19  peterg
## Initial revision
##
###############################################################

LAST=20.0;
DT=0.1;
STEPFACTOR=1;

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Drive_abg.fig version [220398ec6b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 2475 2925 2475 2700 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3397 2497 4522 2497 4297 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 2475 6075 2475 5850 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6547 2497 7672 2497 7447 2722
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 2700 3150 3825 3375 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 2700 6300 3825 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4725 2250 4725 1125 4950 1350
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2925 2700 3375 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6030 2700 6525 2700
4 1 -1 0 0 0 20 0.0000 4 195 135 3150 2565 1\001
4 1 -1 0 0 0 20 0.0000 4 195 135 6300 2565 1\001
4 1 4 0 0 0 20 0.0000 4 240 810 1305 2565 SS:[in]\001
4 1 4 0 0 0 20 0.0000 4 240 960 8235 2565 SS:[out]\001
4 1 -1 0 0 0 20 0.0000 4 195 675 3150 4185 SS:v1\001
4 1 -1 0 0 0 20 0.0000 4 195 675 6300 4185 SS:v2\001
4 1 -1 0 0 0 20 0.0000 4 195 135 4725 2610 0\001
4 1 -1 0 0 0 20 0.0000 4 195 1410 4725 945 CSW:clutch\001

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Drive_desc.tex version [f20953ff3a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Drive (Drive_desc.tex)
% Generated by MTT on Thu Jul 3 13:58:26 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Drive} is
   displayed in Figure \Ref{Drive_abg} and its label
   file is listed in Section \Ref{sec:Drive_lbl}.
   The subsystems are listed in Section \Ref{sec:Drive_sub}.

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Drive_lbl.txt version [0bb1dbab24].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Drive: The clutch/shaft drive subsystem
%DESCRIPTION <Detailed description here>
%% Label file for system Drive (Drive_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/18 10:32:32  peterg
% %% New SS form
% %%
% %% Revision 1.1  1997/09/11 09:39:16  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CSW
	clutch		lin	effort,epsilon

% Component type R
%	r_d		lin	flow,r_d

% Component type SS
	v1		SS	0,external
	v2		SS	0,external
	[in]		SS	external,external
	[out]		SS	external,external

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Load_abg.fig version [f6ba5521a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3376 2926 3376 2701 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3151 3151 2251 3376 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3601 3151 4501 3376 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2476 1801 3826 1801 3826 4951 2476 4951 2476 1801
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2026 3151 2476 3151 2476 3601 2026 3601 2026 3151
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 5400 6075 900 495 900 495 5400 6075 5400
4 1 -1 0 0 0 20 0.0000 4 195 135 3151 3466 1\001
4 1 -1 0 0 0 20 0.0000 4 255 450 3151 2161 I:j_l\001
4 1 -1 0 0 0 20 0.0000 4 255 585 3196 4816 R:r_l\001
4 1 4 0 0 0 20 0.0000 4 240 810 1576 3466 SS:[in]\001
4 1 1 1 0 0 20 0.0000 4 255 4395 3331 1531 Rotating load with inertia and friction\001

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Load_desc.tex version [0e613d5fe7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Load (Load_desc.tex)
% Generated by MTT on Thu Jul 3 13:58:38 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Load} is
   displayed in Figure \Ref{Load_abg} and its label
   file is listed in Section \Ref{sec:Load_lbl}.
   The subsystems are listed in Section \Ref{sec:Load_sub}.

Deleted mttroot/mtt/lib/examples/Hybrid/Clutch/Load_lbl.txt version [522a352692].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Load: An inertial/frictional load
%DESCRIPTION <Detailed description here>
%% Label file for system Load (Load_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 09:39:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type I
	j_l		lin	flow,j_l

% Component type R
	r_l		lin	flow,r_l

% Component type SS
	[in]		SS	external,external

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weir_abg.fig version [23c0cd3485].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2025 2475 2025 2250 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1800 2700 675 2925 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 2025 4050 2025 3825 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2025 5625 2025 5400 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 4275 675 4500 900
2 4 0 2 31 7 99 0 -1 6.000 0 0 7 0 0 5
	 6975 3600 6975 180 225 180 225 3600 6975 3600
4 1 0 100 0 0 20 0.0000 4 195 150 2700 2115 1\001
4 1 0 100 0 0 20 0.0000 4 210 1065 2700 585 ISW:isw\001
4 1 4 100 0 0 20 0.0000 4 255 870 765 2115 SS:[in]\001
4 1 4 100 0 0 20 0.0000 4 255 1020 6255 2115 SS:[out]\001
4 1 0 100 0 0 20 0.0000 4 195 150 4275 2115 1\001
4 1 0 100 0 0 20 0.0000 4 195 390 4230 585 R:r\001
4 1 1 99 0 1 20 0.0000 4 270 2250 3375 2835 Simple weir model\001

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weir_desc.tex version [3eff224837].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system Weir (Weir_desc.tex)
% Generated by MTT on Tue Mar 2 22:05:29 GMT 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Weir} is
   displayed in Figure \Ref{Weir_abg} and its label
   file is listed in Section \Ref{sec:Weir_lbl}.
   The subsystems are listed in Section \Ref{sec:Weir_sub}.


The weir is modelled by an \textbf{ISW} component in series with an
\textbf{R} component. Physicaly, the former represents the inertia of
the fluid together with the switching effect of the weir; the latter
represents the flow resistance.

The switching logic is on if the level on either side of the weir
reaches the level of the weir.

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weir_lbl.txt version [17d01f59e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Weir
#DESCRIPTION Detailed description here

## System Weir, representation lbl, language txt
## File Weir_lbl.txt
## Generated by MTT on Fri Oct  5 10:50:46 BST 2001

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.2  2001/07/03 22:59:10  gawthrop
  ## Fixed problems with argument passing for CRs
  ##
  ###############################################################

## Port aliases
#ALIAS	in	in
#ALIAS	out	out

## Argument aliases
#ALIAS	$1	i_s
#ALIAS	$2	r

## Each line should be of one of the following forms:
##	     a comment (ie starting with #)
##	     component-name	cr_name	arg1,arg2,..argn
##	     blank

## ---- Component labels ----

## Component type ISW
	isw	lin		flow,i_s

## Component type R
	r	lin		flow,r		

## Component type R
	[in]	SS		external,external		
	[out]	SS		external,external		









Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_abg.fig version [fea78e06f0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6075 2025 4950 2250 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 675 6300 1800 6300 1530 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 6525 2025 7650 2250 7425
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 675 6075 675 6525
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 7650 2250 7650
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 6525 6750 7200 6570 7200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 6300 3375 6300 3105 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 6300 5625 6300 5355 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 6300 7200 6300 6930 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 6300 9450 6300 9180 6570
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 6076 5851 4951 6076 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5850 6525 5850 7650 6075 7425
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 7650 6075 7650
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9677 6077 9677 4952 9902 5177
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9675 6525 9675 7650 9900 7425
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 7650 9900 7650
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4860 3150 4860 1980
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 7110 3150 7110 1395
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 3
	1 0 2.00 120.00 240.00
	 2610 450 3285 450 3285 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 3060 675 3060 3150 5760 3150
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 5985 3150 8955 3150 8955 675
2 1 0 2 1 7 99 0 -1 0.000 0 0 -1 1 0 2
	1 0 1.00 60.00 120.00
	 5850 2925 5850 3600
4 1 -1 0 0 0 20 0.0000 4 195 150 2025 6390 0\001
4 1 -1 0 0 0 20 0.0000 4 210 960 2025 4815 C:tank1\001
4 1 -1 0 0 0 20 0.0000 4 270 720 1980 7965 SS:p1\001
4 1 -1 0 0 0 20 0.0000 4 210 525 315 6390 SS:f\001
4 0 -1 0 0 0 20 0.0000 4 210 795 6300 7515 R:leak\001
4 1 -1 0 0 0 20 0.0000 4 195 1065 3960 6390 Weir:w1\001
4 1 -1 0 0 0 20 0.0000 4 195 1065 7785 6390 Weir:w2\001
4 1 -1 0 0 0 20 0.0000 4 210 960 5851 4816 C:tank2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5851 6391 0\001
4 1 -1 0 0 0 20 0.0000 4 270 720 5850 7965 SS:p2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 9677 6392 0\001
4 1 -1 0 0 0 20 0.0000 4 210 960 9677 4817 C:tank3\001
4 1 -1 0 0 0 20 0.0000 4 270 720 9630 7965 SS:p3\001
4 1 1 1 0 3 20 0.0000 4 270 105 2970 315 f\001
4 1 1 99 0 1 20 0.0000 4 210 825 3780 2565 Tank 1\001
4 1 1 99 0 1 20 0.0000 4 210 825 5940 2565 Tank 2\001
4 1 1 99 0 1 20 0.0000 4 210 825 8055 2565 Tank 3\001
4 1 1 99 0 1 20 0.0000 4 210 585 5895 3870 Leak\001

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_desc.tex version [75ce1911ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Weirs (Weirs_desc.tex)
% Generated by MTT on Thu Jul 3 10:27:26 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:47:43  peterg
% %% To RCS
% %%
% Revision 1.1  1997/09/11  10:31:48  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Weirs} is
   displayed in Figure \Ref{Weirs_abg} and its label
   file is listed in Section \Ref{sec:Weirs_lbl}.
   The subsystems are listed in Section \Ref{sec:Weirs_sub}.

%Each weir is modeled by two {\bf ISW} components: one for flow
%left-right and one for flow right-left. The switching is such that
%they become non-return valves when the left hand (respectively
%right-hand) level reaches an appropriate value. The parameters appear
%in Section \Ref{sec:Weirs_numpar.txt} and the switching conditions in
%Section \Ref{sec:Weirs_input.txt}.

Aircraft fuel tanks are often fitted with baffles to reduce fuel
slosh. A simple model relating to such a system is shown in Figure
\Ref{Weirs_abg} which corresponds to a single tank containing two
dividing weirs. Liquid with flow rate $f$ enters the left-hand
compartment; liquid leaks out of the centre compartment at a flow rate
determined by gravity and the properties of the corresponding orifice.

The Bond Graph appearing in Figure \Ref{Weirs_abg} represents each of
the three compartments by a \textbf{C} component (labelled tank1 to
tank3), the corresponding pressures are measured by the \textbf{SS}
elements p1--p3. The leak is represented by the \textbf{R} component
labelled leak. The flows over the two weirs are represented by the four
\textbf{ISW} components; each weir has a separate \textbf{ISW}
component for each flow direction. Each \textbf{ISW} component is
switched by the appropriate level.

%It could be argued that, when switched on, each \textbf{ISW} component
%corresponds to flow inertia; but it is admitted that ideal
%\textbf{Sw} components would give a simpler approximation in this
%case. So the modeller has the choice of having a simple simulation
%problem but with four extra states, or a complex simulation with model
%switching but without the four extra states.

The system was simulated for 20 time units and the resultant level of
each tank partition is plotted in Figure \Ref{fig:Weirs_odeso-noargs.ps}. Each
partition has unit cross section, and the two weir heights are $1$ and
$2$ respectively; the inflow $f$ is given by:
\begin{equation}
  f = 
  \begin{cases}
    1 & \text{if $t \le 10$}\\
    0 & \text{if $t > 10$}
  \end{cases}
\end{equation}
and the leak resistance is linear with flow resistance 5.


%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_input.txt version [d802cb3522].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (Weirs_input.txt)
# Generated by MTT at Tue Mar  2 07:48:04 GMT 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2001/10/05 11:24:35  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.1  2000/05/19 07:12:04  peterg
## Initial revision
##
###############################################################

# Set the inputs
## Removed by MTT on Fri Oct  5 10:47:20 BST 2001: mttu(1) = 1.0*(t<10); 	# f (Weirs)



## Removed by MTT on Tue Jun 10 10:53:48 BST 2003: weirs_f	= 1.0*(t<10); # Added by MTT on Fri Oct 05 10:48:01 BST 2001


weirs__f	= 1.0*(t<10);

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_lbl.txt version [2f0e26ecdf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Weirs (Weirs_lbl.txt)
%SUMMARY Weirs Double-weir tanks system (hybrid)
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/03/09 00:12:12  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	tank1
%ALIAS	$2	tank2
%ALIAS	$3	tank3
%ALIAS	$4	leak

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	tank1		lin	effort,c_1
	tank2		lin	effort,c_2
	tank3		lin	effort,c_3

% Component type R
	leak		lin	flow,r_l

% Component type SS
	f	SS		internal,external
	p1	SS		external,0
	p2	SS		external,0
	p3	SS		external,0

% Component type Weir
	w1      none		epsilon_i;epsilon_r
	w2      none		epsilon_i;epsilon_r

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_logic.txt version [85668391bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Weirs (Weirs_logic.txt)
# Generated by MTT on Thu May 18 12:29:15 BST 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  2002/09/29 14:23:16  geraint
## Updated switch names.
##
## Revision 1.2  2001/10/05 11:24:35  gawthrop
## Updated for new mtt features - input.txt etc
##
## Revision 1.1  2000/05/19 07:13:29  peterg
## Initial revision
##
## Revision 1.1  2000/05/18 11:29:58  peterg
## Initial revision
##
###############################################################


# Set the switches
# First weir - height 1
# Second weir - height 2
## Removed by MTT on Tue Jun 10 10:54:35 BST 2003: weirs_w1_isw_mtt_switch_logic	= ((weirs_tank1 > 1) | (weirs_tank2 > 1));
## Removed by MTT on Tue Jun 10 10:54:35 BST 2003: weirs_w2_isw_mtt_switch_logic	= ((weirs_tank2 > 2) | (weirs_tank3 > 2));
weirs__w1__isw__mtt_switch_logic	= ((weirs__tank1 > 1) | (weirs__tank2 > 1));
weirs__w2__isw__mtt_switch_logic	= ((weirs__tank2 > 2) | (weirs__tank3 > 2));

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_numpar.txt version [f82fcef096].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (Weirs_numpar.txt)
# Generated by MTT at Tue Mar  2 07:55:47 GMT 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # Weirs
c_2 = 	1.0; # Weirs
c_3 = 	1.0; # Weirs
epsilon_i = 	0.01; # weir
epsilon_r = 	0.1; # weir
r_l = 	5.0; # Weirs

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_rep.txt version [9f4c394b93].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system Weirs (Weirs_rep.txt)
## Generated by MTT on" Tue Mar  2 22:02:59 GMT 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  2000/05/19 07:15:04  peterg
## Added logic
##
## Revision 1.4  1999/12/21 09:24:26  peterg
## Euler integration - compiled
##
## Revision 1.3  1999/03/02 22:19:22  peterg
## Added switch rep
##
## Revision 1.2  1999/03/02 22:09:49  peterg
## Addded switch rep
##
## Revision 1.1  1999/03/02 22:04:11  peterg
## Initial revision
##
###############################################################

mtt Weirs abg tex			# The system description
## mtt Weirs cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt Weirs struc tex	        # The system structure
## mtt Weirs dae tex	        # The system dae
mtt Weirs ode tex	        # The system ode 
mtt Weirs switch txt	        # The system switches 
## mtt Weirs sspar tex		# Steady-state parameters
## mtt Weirs ss tex 		# Steady state
## mtt Weirs dm tex		# Descriptor matrices (of linearised system)
## mtt Weirs sm tex		# State matrices (of linearised system)
## mtt Weirs tf tex		# Transfer function (of linearised system)
## mtt Weirs lmfr ps		# log modulus of frequency response (of linearised system)
mtt Weirs simpar tex		# Simulation parameters
mtt Weirs numpar tex		# Numerical simulation parameters
mtt Weirs input tex		# Simulation input
mtt Weirs logic tex		# Switch logic
mtt Weirs odeso ps		# Simulation output

mtt Weirs rep txt

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/Weirs_simpar.txt version [9ebb65f3fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Simulation parameters for system Weirs (Weirs_simpar.txt)
# Generated by MTT on Sun Jul 26 13:55:27 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/12/21 09:22:43  peterg
## Initial revision
##
###############################################################


LAST=19.9;
DT=0.01;
STEPFACTOR=1;

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/weir_abg.fig version [9adb302ec2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1350 2025 2475 2025 2250 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 1800 2700 675 2925 900
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2700 2250 2700 3375 2925 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 2025 4050 2025 3825 2250
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2025 5625 2025 5400 2250
4 1 0 100 0 0 20 0.0000 4 195 150 2700 2115 1\001
4 1 0 100 0 0 20 0.0000 4 210 1065 2700 585 ISW:isw\001
4 1 0 100 0 0 20 0.0000 4 195 390 2700 3690 R:r\001
4 1 0 100 0 0 20 0.0000 4 255 870 765 2115 SS:[in]\001
4 1 0 100 0 0 20 0.0000 4 255 1020 6255 2115 SS:[out]\001
4 1 0 100 0 0 20 0.0000 4 195 150 4275 2115 1\001

Deleted mttroot/mtt/lib/examples/Hybrid/Weirs/weir_lbl.txt version [d74bf1486c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system weir (weir_lbl.txt)
%SUMMARY weir
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	r

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type ISW
	isw             lin     effort,epsilon_i

% Component type R
	r		lin	flow,epsilon_r

% Component type SS
	[in]	SS		external,external
	[out]	SS		external,external


Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/README version [64f32ec93d].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
This is the example from:
@Article{Gaw00c,
  author =       {Peter J Gawthrop},
  title =        {Sensitivity Bond Graphs},
  journal =      JFI,
  year =         {2000}
}


NB Compile with -i euler

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/conical.cr version [91a01114ea].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
%% CR for conical tank example

OPERATOR conical;
%% State input.
FOR ALL COMP, rho,g,V_0,V LET
    conical(COMP, rho,g,V_0,effort,1,V,state,1) = rho*g*(12*(V+V_0)/pi)^(1/3);


END;;

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/discharge.cr version [aa3df12262].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
%% CR for pipe discharge


OPERATOR discharge;
%% Flow input
FOR ALL COMP, alpha,beta,F LET
    discharge(COMP, alpha,beta,effort,1,F,flow,1) = beta*F^alpha;

%% Effort input
FOR ALL COMP, alpha,beta,P LET
    discharge(COMP, alpha,beta,flow,1,P,effort,1) = (P/beta)^(1/alpha);

END;;

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_abg.fig version [62dde3975f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1575 2925 2745 2925 2520 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2925 4320 2925 4095 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4725 2925 5895 2925 5670 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2925 7470 2925 7245 3150
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 2700 2925 1530 3150 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2700 4500 1530 4725 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 2700 6075 1530 6300 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7650 2700 7650 1530 7875 1755
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 6075 4320 6300 4095
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1575 2700 1575 3150
4 1 0 100 0 18 20 0.0000 4 270 195 2925 3015 0\001
4 1 0 100 0 18 20 0.0000 4 270 195 4500 3015 1\001
4 1 0 100 0 18 20 0.0000 4 270 195 7650 3015 1\001
4 1 0 100 0 18 20 0.0000 4 285 705 2925 1440 C:t1\001
4 1 0 100 0 18 20 0.0000 4 360 780 4545 1440 R:p1\001
4 1 0 100 0 18 20 0.0000 4 360 780 7695 1440 R:p2\001
4 1 0 100 0 18 20 0.0000 4 285 705 6075 1440 C:t2\001
4 1 0 100 0 18 20 0.0000 4 270 195 6075 3015 0\001
4 1 0 100 0 18 20 0.0000 4 360 825 6075 4680 De:y\001
4 1 0 100 0 18 20 0.0000 4 285 720 1125 3060 Sf:u\001

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_desc.tex version [3e4f2fb3e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system idNonlinearTanks (idRC_desc.tex)
% Generated by MTT on Thu Apr 5 11:04:33 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{idNonlinearTanks} is
   displayed in Figure \Ref{fig:idRC_abg.ps} and its label
   file is listed in Section \Ref{sec:idRC_lbl}.
   The subsystems are listed in Section \Ref{sec:idRC_sub}.

   
   This example illustrates the sensitivity approach to model-based
   system identification\footnote{Peter J Gawthrop, \emph{Sensitivity
       Bond Graphs}, Journal Franklin Institute, \textbf{337}, 2000,
     pp 907--922}.

   The system compprises two non-linear tanks (see the paper for details).
   The method identifies four parameters: the two initial states ans
   the two parameters of the non-linear flow resistance.

   To see the results, type: 
\begin{verbatim}
mtt -oct -i euler -pdf idNonlinearTanks ippp view
\end{verbatim}

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_ippp.m version [3864de3022].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

## Set up parameters
name = "idNonlinearTanks";
sim = sidNonlinearTanks_simpar;	# Simulation parameter
sym = sidNonlinearTanks_sympar;	# Parameter names
par = sidNonlinearTanks_numpar;	# Parameter values
x0  = sidNonlinearTanks_state(par); # Initial state

## Simulation of "actual" system
t = [0:sim.dt:sim.last]';
T = 5;				# Period
u = ones(size(t));
y_0 = sidNonlinearTanks_ssim(x0,par,sim,u,2);

plot(t,y_0);

## The initial parameters
par_0 = par;
par_0(sym.V_1) = 2.0;
par_0(sym.V_2) = 1.0;
par_0(sym.alpha) = 1.0;
par_0(sym.beta) = 2.0;

## Identify
extras.criterion = 1e-5;
extras.max_iterations = 10;
extras.v = 10;			# Use a really big initial value
extras.verbose = 1;		# Show what is going on
[par,Par,Error,Y] = ppp_identify (name,u,y_0,["V_1  ";"V_2  ";"alpha";"beta "],par_0,extras);

par = par

grid;
xlabel("Time")
title("Output");
plot(t,y_0);
figfig("idNonlinearTanks_output","pdf");
figfig("idNonlinearTanks_output","ps");
grid;

xlabel("Time")
title("Estimated output");
plot(t,y_0,t,Y);
figfig("idNonlinearTanks_outputs","pdf");
figfig("idNonlinearTanks_outputs","ps");

xlabel("Iteration")
title("Estimation error");
plot(Error);
figfig("idNonlinearTanks_error","pdf");
figfig("idNonlinearTanks_error","ps");

xlabel("Iteration")
title("Estimated Parameter");
plot(Par');
figfig("idNonlinearTanks_parameters","pdf");
figfig("idNonlinearTanks_parameters","ps");

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_lbl.txt version [833116b223].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system idNonlinearTanks (NonlinearTanks_lbl.txt)
%SUMMARY NonlinearTanks
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Component type C
	t1		conical		rho,g,V_1
	t2		conical		rho,g,V_2

% Component type R
	p1		discharge	alpha,beta
	p2		discharge	alpha,beta

% Component type Sf
        u		SS		external

% Component type De
        y		SS		external

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_numpar.txt version [01084da6b8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sNonlinearTanks_numpar.txt)
# Generated by MTT at Mon Nov 29 17:36:54 EST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Parameters

## States 
v_1 = 	0.5;			# Tank 1
v_2 = 	0.25;			# Tank 2

## Tank parameters
g = 	1;			#Gravity
rho = 	1;			# sC,sNonlinearTanks
alpha = 	1.5;

## Pipe parameters
beta = 	1; 


Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_rep.tex version [d07140a9ae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


\section{\textbf{abg.tex}: System idNonlinearTanks, representation \textbf{abg}, language \textbf{tex}}
\label{sec:idNonlinearTanks_abg.tex}
\index{\textbf{idNonlinearTanks} -- abg}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks abg tex 
\end{verbatim}
  \input{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_abg.tex}


\section{\textbf{cbg.ps}: System idNonlinearTanks, representation \textbf{cbg}, language \textbf{ps}}
\label{sec:idNonlinearTanks_cbg.ps}
\index{\textbf{idNonlinearTanks} -- cbg}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks cbg ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:idNonlinearTanks_cbg.ps}.
\fig{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_cbg}
    {idNonlinearTanks_cbg.ps}
    {0.9}
    {System \textbf{idNonlinearTanks}, representation cbg}


\section{\textbf{struc.tex}: System idNonlinearTanks, representation \textbf{struc}, language \textbf{tex}}
\label{sec:idNonlinearTanks_struc.tex}
\index{\textbf{idNonlinearTanks} -- struc}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks struc tex 
\end{verbatim}
  \input{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_struc.tex}


\section{\textbf{sympar.tex}: System idNonlinearTanks, representation \textbf{sympar}, language \textbf{tex}}
\label{sec:idNonlinearTanks_sympar.tex}
\index{\textbf{idNonlinearTanks} -- sympar}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks sympar tex 
\end{verbatim}
  \input{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_sympar.tex}


\section{\textbf{odeso.ps}: System sidNonlinearTanks, representation \textbf{odeso}, language \textbf{ps}}
\label{sec:sidNonlinearTanks_odeso.ps}
\index{\textbf{sidNonlinearTanks} -- odeso}


MTT command:
\begin{verbatim}
mtt -oct -s sidNonlinearTanks odeso ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:sidNonlinearTanks_odeso.ps}.
\fig{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/sidNonlinearTanks_odeso}
    {sidNonlinearTanks_odeso.ps}
    {0.9}
    {System \textbf{sidNonlinearTanks}, representation odeso}


\section{\textbf{ippp.ps}: System idNonlinearTanks, representation \textbf{ippp}, language \textbf{ps}}
\label{sec:idNonlinearTanks_ippp.ps}
\index{\textbf{idNonlinearTanks} -- ippp}


MTT command:
\begin{verbatim}
mtt -oct -i euler idNonlinearTanks ippp ps 
\end{verbatim}
This representation is given as Figure \Ref{fig:idNonlinearTanks_ippp.ps}.
\fig{/home/peterg/Research/Identification/MTT/idNonlinearTanks/MTT_work/idNonlinearTanks_ippp}
    {idNonlinearTanks_ippp.ps}
    {0.9}
    {System \textbf{idNonlinearTanks}, representation ippp}


\section{\textbf{rep.txt}: System idNonlinearTanks, representation \textbf{rep}, language \textbf{txt}}
\label{sec:idNonlinearTanks_rep.txt}
\index{\textbf{idNonlinearTanks} -- rep}


MTT command:
\begin{verbatim}
mtt idNonlinearTanks rep txt 
\end{verbatim}
  \begin{verbatim}
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system idNonlinearTanks (idRC_rep.txt)
## Generated by MTT on" Thu Apr  5 11:17:27 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt idNonlinearTanks abg tex			# The system description
mtt idNonlinearTanks cbg ps 		        # The causal bond graph
mtt idNonlinearTanks struc tex	        # The system structure
mtt idNonlinearTanks sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt idNonlinearTanks dae tex	        # The system dae
## mtt idNonlinearTanks ode tex	        # The system ode 
## mtt idNonlinearTanks sspar tex		# Steady-state parameters
## mtt idNonlinearTanks ss tex 		# Steady state
## mtt idNonlinearTanks dm tex		# Descriptor matrices (of linearised system)
## mtt idNonlinearTanks sm tex		# State matrices (of linearised system)
## mtt idNonlinearTanks tf tex		# Transfer function (of linearised system)
## mtt idNonlinearTanks lmfr ps		# log modulus of frequency response (of linearised system)
## mtt idNonlinearTanks simpar tex		# Simulation parameters
## mtt idNonlinearTanks numpar tex		# Numerical simulation parameters
## mtt idNonlinearTanks state tex		# Simulation initial state
## mtt idNonlinearTanks input tex		# Simulation input
## mtt idNonlinearTanks logic tex		# Logic control
 mtt -oct -s sidNonlinearTanks odeso ps		# Simulation output
 mtt -oct -i euler idNonlinearTanks ippp ps

mtt idNonlinearTanks rep txt		# This file
  \end{verbatim}

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_rep.txt version [b96574c869].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system idNonlinearTanks (idRC_rep.txt)
## Generated by MTT on" Thu Apr  5 11:17:27 BST 2001.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2001/04/05 12:00:18  gawthrop
## Identification example
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt idNonlinearTanks abg tex			# The system description
mtt idNonlinearTanks cbg ps 		        # The causal bond graph
mtt idNonlinearTanks struc tex	        # The system structure
mtt idNonlinearTanks sympar tex	        # The system parameters
## Uncomment the following lines or add others
##mtt idNonlinearTanks dae tex	        # The system dae
 mtt idNonlinearTanks ode tex	        # The system ode 
## mtt idNonlinearTanks sspar tex		# Steady-state parameters
## mtt idNonlinearTanks ss tex 		# Steady state
## mtt idNonlinearTanks dm tex		# Descriptor matrices (of linearised system)
## mtt idNonlinearTanks sm tex		# State matrices (of linearised system)
## mtt idNonlinearTanks tf tex		# Transfer function (of linearised system)
## mtt idNonlinearTanks lmfr ps		# log modulus of frequency response (of linearised system)
## mtt idNonlinearTanks simpar tex		# Simulation parameters
## mtt idNonlinearTanks numpar tex		# Numerical simulation parameters
## mtt idNonlinearTanks state tex		# Simulation initial state
## mtt idNonlinearTanks input tex		# Simulation input
## mtt idNonlinearTanks logic tex		# Logic control
## mtt -oct -s sidNonlinearTanks odeso ps		# Simulation output
 mtt -i euler idNonlinearTanks ident ps

mtt idNonlinearTanks rep txt		# This file

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_simpar.txt version [1629ef8da3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system idNonlinearTanks (sidNonlinearTanks_simpar.txt)
# Generated by MTT on Wed Apr 4 15:25:33 BST 2001.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_subs.r version [254628ce3b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Default SUBS file
% File idRC_subs.r
% Generated by MTT on Tue Apr  3 09:43:38 BST 2001.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2001/04/05 12:00:18  gawthrop
% %% Identification example
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Put algebraic substitution commands here

%The following is now done automatically
% FOR ALL x,y LET x^y = pow(x,y);
END;

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sC_abg.fig version [28ce05ebfc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3105 3105 3195 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3150 3150 3150 3600
-6
6 6705 3105 6795 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6750 3150 6750 3600
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 450 4950 3465 C:c\001

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sC_lbl.txt version [d300c10d36].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sC (sC_lbl.txt)
%SUMMARY sC
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	rho,g,V_0,V_0s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	c	sconical 	rho,g,V_0,V_0s

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sR_abg.fig version [7ee767975f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 4455 3105 4545 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4500 3150 4500 3600
-6
6 5355 3105 5445 3645
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 3150 5400 3600
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 5400 3375 5625 3600
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 3375 4500 3375 4275 3600
4 1 4 100 0 18 14 0.0000 4 210 270 4410 3105 [1]\001
4 1 4 100 0 18 14 0.0000 4 210 270 5535 3105 [2]\001
4 0 4 100 0 18 18 0.0000 4 270 1935 6840 3465 SS:[sensitivity]\001
4 2 4 100 0 18 18 0.0000 4 270 1410 3060 3465 SS:[actual]\001
4 1 0 100 0 18 18 0.0000 4 210 390 4950 3465 R:r\001

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sR_lbl.txt version [663f556b3d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sR (sR_lbl.txt)
%SUMMARY sR
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	actual,sensitivity

% Argument aliases
%ALIAS	$1	alpha,beta,alpha_s,beta_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	r	sdischarge 	alpha,beta,alpha_s,beta_s

% Component type SS
	[actual]	SS		external,external
	[sensitivity]	SS		external,external

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sconical.cr version [8f55376ab8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% CR for conical tank example - sensitivity

in "conical.cr";

OPERATOR sconical;
%% The actual port (1) 
FOR ALL COMP, rho,g,V_0,V_0s,V,sV LET
    sconical(COMP, rho,g,V_0,V_0s,effort,1,
               V,state,1,
               sV,state,2)
    = conical(COMP, rho,g,V_0,effort,1,V,state,1);

%% The sensitivity port (2) 
FOR ALL COMP, rho,g,V_0,V_0s,V,sV LET
    sconical(COMP, rho,g,V_0,V_0s,effort,2,
               V,state,1,
               sV,state,2)
    = df(conical(COMP, rho,g,V_0,effort,1,V,state,1),V) * sV
    + df(conical(COMP, rho,g,V_0,effort,1,V,state,1),V_0)* V_0s;

END;;

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sdischarge.cr version [12ca25468f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% CR file for the sR component. - 2 port.
%% Special version just for this example.

%% CR for non-linear pipe discharge
%% Just do for flow input causality.

in "discharge.cr";

PROCEDURE l_discharge(COMP, alpha,beta,P);
BEGIN
  result := sub({x=P},df(discharge(COMP, alpha,beta,flow,1,x,effort,1), x));
  return result;
END;

OPERATOR sdischarge;
%% The actual port (1) -- Pressure input
FOR ALL COMP, alpha,beta,alpha_s,beta_s,P,sP LET
    sdischarge(COMP, alpha,beta,alpha_s,beta_s,flow,1,
               P,effort,1,
               sP,effort,2)
    = discharge(COMP, alpha,beta,flow,1,P,effort,1);

%% The sensitivity port (2) -- Pressure input
FOR ALL COMP, alpha,beta,alpha_s,beta_s,P,sP LET
    sdischarge(COMP, alpha,beta,alpha_s,beta_s,flow,2,
               P,effort,1,
               sP,effort,2)
    =  l_discharge(COMP, alpha,beta,P) * sP
    + df(discharge(COMP, alpha,beta,flow,1,P,effort,1), alpha)* alpha_s
    + df(discharge(COMP, alpha,beta,flow,1,P,effort,1), beta) * beta_s;
END;;

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_lbl.txt version [fe01918d62].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system NonlinearTanks (NonlinearTanks_lbl.txt)
%SUMMARY NonlinearTanks
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	t1		sconical	rho,g,V_1,V_1s
	t2		sconical	rho,g,V_2,V_2s

% Component type R
	p1		sdischarge	alpha,beta,alphas,betas
	p2		sdischarge	alpha,beta,alphas,betas

% Component type Sf
        u		SS		external;0

% Component type De
        y		SS		external;external

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_numpar.txt version [9e73863b4f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (sNonlinearTanks_numpar.txt)
# Generated by MTT at Mon Nov 29 17:36:54 EST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2001/04/05 12:00:18  gawthrop
# %% Identification example
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Parameters

## States 
v_1 = 	2.0;			# Tank 1
v_2 = 	1.0;			# Tank 2

## Tank parameters
g = 	1;			#Gravity
rho = 	1;			# sC,sNonlinearTanks
alpha = 	1.0;

## Pipe parameters
beta = 	2.0; 

## Sensitivity.
v_1s = 	0;			# Tank 1
v_2s = 	0;			# Tank 2

alphas = 	0;
betas  = 	0;

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_simpar.txt version [a95d2a72de].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system sidNonlinearTanks (sidNonlinearTanks_simpar.txt)
# Generated by MTT on Wed Apr 4 15:25:33 BST 2001.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.1;        # Print interval
LAST        = 10.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Identification/idNonlinearTanks/sidNonlinearTanks_subs.r version [2949fe13a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Default SUBS file
% File idRC_subs.r
% Generated by MTT on Tue Apr  3 09:43:38 BST 2001.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Put algebraic substitution commands here

FOR ALL x,y LET x^y = pow(x,y); % Use the pow function

ON ROUNDED; % No integer output

END;

Deleted mttroot/mtt/lib/examples/Identification/idRC/create_data.m version [0dc531b79c].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
## Create some data
  c = 1;
  r = 5;
  tau = r*c;

  t = [0:0.1:10]';		# time
  one = ones(size(t));
  u = one;			# Step input
  y = one - exp(-t/tau);	# Exact step response

  save idRC_ident_data.dat y u t

Deleted mttroot/mtt/lib/examples/Identification/idRC/idRC_abg.fig version [d7e806eb37].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2250 2475 3600 2475 3375 2700
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4500 2475 5850 2475 5625 2700
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6975 3600 1125 3600 1125 1800 6975 1800 6975 3600
4 1 0 100 0 18 18 0.0000 4 210 600 1800 2565 Se:u\001
4 1 0 100 0 18 18 0.0000 4 210 750 4050 2565 RC:rc\001
4 1 0 100 0 18 18 0.0000 4 270 600 6345 2565 De:y\001

Deleted mttroot/mtt/lib/examples/Identification/idRC/idRC_desc.tex version [fe46d73a25].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system idRC (idRC_desc.tex)
% Generated by MTT on Thu Apr 5 11:04:33 BST 2001.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2003/08/18 08:06:11  gawthrop
% %% A working version with more explantion
% %%
% %% Revision 1.2  2002/09/23 11:16:27  gawthrop
% %% New example for ident representation
% %%
% %% Revision 1.1  2001/04/05 11:57:29  gawthrop
% %% Identification example
% %%
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{idRC} is
   displayed in Figure \Ref{fig:idRC_abg.ps} and its label
   file is listed in Section \Ref{sec:idRC_lbl}.
   The subsystems are listed in Section \Ref{sec:idRC_sub}.

   
   This example illustrates the sensitivity approach to model-based
   system identification\footnote{Peter J Gawthrop, \emph{Sensitivity
       Bond Graphs}, Journal Franklin Institute, \textbf{337}, 2000,
     pp 907--922}.

   The system is a simple RC circuit with zero initial condition; the
   method identifies the resitance $r$.

   The data is created by typing:
\begin{verbatim}
make
\end{verbatim}
To see the results, type: 
\begin{verbatim}
mtt -oct -i euler  idRC ident view
\end{verbatim}

   \paragraph{NB} All sensitivity coefficients in idRC\_simpar.txt must
   be set to zero.

Deleted mttroot/mtt/lib/examples/Identification/idRC/idRC_ident_numpar.m version [1e49a50185].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [y,u,t,par_names,Q,extras] = idRC_ident_numpar;

  ## usage: [y,u,t,par_names,Q,extras] = idRC_ident_numpar;
  ## Edit for your own requirements
  ## Created by MTT on 

    
  ## This section sets up the data source
  ## simulate = 0  Real data (you supply idRC_ident_data.dat)
  ## simulate = 1  Real data input, simulated output
  ## simulate = 2  Unit step input, simulated output
  simulate = 0;
  

  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = idRC_def;
  simpars = sidRC_simpar;

  ## Access or create data
  if (simulate<2)		# Get the real data
    if (exist("idRC_ident_data.dat")==2)
      printf("Loading idRC_ident_data.dat\n");
      load idRC_ident_data.dat
    else
      printf("Please create a loadable file idRC_ident_data.dat containing y,u and t\n");
      return
    endif
  else 
    switch simulate
      case 2			# Step simulation
	t = [0:simpars.dt:simpars.last]';
	u = ones(size(t));
      otherwise
	error(sprintf("simulate = %i not implemented", simulate));
    endswitch
  endif
  
  if (simulate>0)
    par = idRC_numpar();
    x_0 = idRC_state(par);
    dt = t(2)-t(1);
    simpars.dt = dt;
    simpars.last = t(length(t));
    y =  idRC_sim(zeros(n_x,1), par, simpars, u);
  endif

  ## Default parameter names - Put in your own here
  sympar = idRC_sympar;	# Symbolic params as structure
  par_names = struct_elements (sympar);	# Symbolic params as strings
  [n,m] = size(par_names);	# Size the string list

  ## Sort by index
  for [i,name] = sympar
    par_names(i,:) = sprintf("%s%s",name, blanks(m-length(name)));
  endfor
  
  par_names = "r";		# Estimate r only

  ## Output weighting vector
  Q = ones(n_y,1);
  
  ## Extra parameters
  extras.criterion = 1e-5;
  extras.emulate_timing = 0;
  extras.max_iterations = 10;
  extras.simulate = simulate;
  extras.v =  1e-2;
  extras.verbose = 1;
  extras.visual = 1;

endfunction

Deleted mttroot/mtt/lib/examples/Identification/idRC/idRC_rep.txt version [643d9abc64].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system idRC (idRC_rep.txt)
## Generated by MTT on" Thu Jun 27 17:03:00 BST 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/09/23 11:42:14  gawthrop
## Example uses simulated data from idRC_ident_data
##
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt idRC abg tex			# The system description
##mtt idRC cbg ps 		        # The causal bond graph
mtt idRC struc tex	        # The system structure
mtt idRC sympar tex	        # The system parameters

## Uncomment the following lines or add others
## mtt idRC dae tex	        # The system dae
## mtt idRC ode tex	        # The system ode 
## mtt idRC sspar tex		# Steady-state parameters
## mtt idRC ss tex 		# Steady state
## mtt idRC dm tex		# Descriptor matrices (of linearised system)
## mtt idRC sm tex		# State matrices (of linearised system)
## mtt idRC tf tex		# Transfer function (of linearised system)
## mtt idRC lmfr ps		# log modulus of frequency response (of linearised system)
## mtt idRC simpar txt		# Simulation parameters
## mtt idRC numpar txt		# Numerical simulation parameters
## mtt idRC state txt		# Simulation initial state
## mtt idRC input txt		# Simulation input
## mtt idRC logic txt		# Logic control
## mtt idRC odeso ps		# Simulation output


## Linear identificationm
##mtt idRC ident_numpar tex
mtt idRC ident ps
##mtt idRC ident_comparison ps
mtt idRC ident_par tex

mtt idRC rep txt		# This file

Deleted mttroot/mtt/lib/examples/Identification/idRC/sidRC_numpar.txt version [118b6b97f6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System sidRC, representation numpar, language txt; 
## File sidRC_numpar.txt; 
## Generated by MTT on Mon Sep 23 11:39:27 BST 2002; 



c	= 1.0; # Default
cs	= 0.0; # MUST BE ZERO
r	= 1.0; # Default
rs	= 0.0; # MUST BE ZERO
us	= 0.0; # MUST BE ZERO

Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/Make version [d0363e1a1b].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
%Makes the figures for the paper/report.
mtt macmic cbg ps
mtt imacmic cbg ps
mtt imacmic sm  m
mtt imacmic numpar m

octave figures.m

Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/figures.m version [6e0d24fe3b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Set up the parameters
imacmic_numpar;   

% Range of damping for the macro controller
D_1 = [0:0.1:2];

% Compute the damping factor d and save in arrray DD
% -- uses zeros of system
% $$$ DD = [];
% $$$ for d_1 = D_1
% $$$  [A,B,C,D] = macmic_dm(m_1,m_2,b_1,b_2,k_2,k_t,b_t,b_3,m_3,p_1,d_1);
% $$$  zz = ss2zp(A,B,C,D,1);
% $$$  z = (zz(:,2));
% $$$  re = sort(real(z));
% $$$  im = sort(imag(z));
% $$$  d = -re./sqrt(re.^2 + im.^2);
% $$$  d = sort(d);
% $$$  DD = [DD d];
% $$$ end;
% $$$ 
% $$$ plot(D_1,min(DD)); grid
% $$$ xlabel('Derivative gain');
% $$$ ylabel('Damping factor');
% $$$ 
% $$$ 

% Compute the damping factor d and save in arrray DD
% -- uses poles of inverse system
DD1 = [];
for d_1 = D_1
 [A] = imacmic_sm;
 z = eig(A);

 re = (real(z));
 im = (imag(z));
 d = -re./sqrt(re.^2 + im.^2);
 d = sort(d);
 DD1 = [DD1 d];
end;
minDD1 = min(DD1);

plot(D_1,minDD1); grid
xlabel('Derivative gain');
ylabel('Damping factor');

Maximum_Damping = max(minDD1)
index = minDD1 == Maximum_Damping*ones(size(minDD1));
Opt_gain = index*D_1'

% Plot on disk
set term postscript
set output "damping.ps"
plot(D_1,minDD1); grid


 

Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_abg.fig version [cf9545f928].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2706 4806 3606 4806 3456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2406 5106 2406 6006 2556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3906 5106 3906 6006 4056 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4808 8108 4808 7958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 4808 9608 4808 9458 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8408 5108 8408 6008 8558 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4508 8108 3608 8108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 3608 9608 4508 9383 4508
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9909 5109 9909 6009 10059 5859
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6908 5108 6908 6008 7058 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8405 2405 8405 3305 8555 3155
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11407 5107 11407 6007 11557 5857
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11406 3306 11406 2406 11556 2556
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4806 5106 4806 4956 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5406 5106 5406 6006 5556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4506 5106 3606 5106 3831
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 3305 5405 2405 5555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2405 3305 2405 2405 2555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 4807 12607 4807 12457 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 3607 12607 4507 12382 4507
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2105 1805 2105 905 2255 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2705 1805 2705 905 2855 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 4806 6606 4806 6456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 3606 6606 4506 6381 4506
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2704 3604 3604 4504 3379 4504
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4808 2108 4808 1958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4508 2108 3608 2108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 681 3606 1131 3606
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 906 4506 906 3606 1056 3756
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12905 4505 12905 3605 13055 3755
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4807 11107 4807 10957 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4507 11107 3607 11107 3832
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8400 3300 8625 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12900 3600 13125 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12675 4500 12900 4500
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8175 2400 8400 2400
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 1501 5401 301 5401 301 3001 1501 3001 1501 5401
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 3300 2700 1500 2700 1500 450 3300 450 3300 2700
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 3000 6600 1800 6600 1800 3000 3000 3000 3000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 4501 6601 3301 6601 3301 3901 4501 3901 4501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 6000 6600 4800 6600 4800 1800 6000 1800 6000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7501 6601 6301 6601 6301 3901 7501 3901 7501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9000 6600 7800 6600 7800 1800 9000 1800 9000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 10501 6601 9301 6601 9301 3901 10501 3901 10501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 12000 6600 10800 6600 10800 1800 12000 1800 12000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 13501 5401 12301 5401 12301 3001 13501 3001 13501 5401
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11700 4575 11700 4800
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 12600 4800 12600 5025
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 10200 4575 10200 4800
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 11100 4800 11100 5025
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9600 4500 9450 4650
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8700 3600 8850 3450
4 1 -1 0 0 0 20 0.0000 4 195 150 2406 4881 0\001
4 1 -1 0 0 0 20 0.0000 4 195 585 3906 6381 I:m1\001
4 1 -1 0 0 0 20 0.0000 4 210 585 2405 6380 R:b1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2405 3680 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3906 4881 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 8408 4883 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 8408 3683 0\001
4 1 -1 0 0 0 20 0.0000 4 210 585 8483 6383 R:b3\001
4 1 -1 0 0 0 20 0.0000 4 210 675 8407 2182 SS:f2\001
4 1 -1 0 0 0 20 0.0000 4 195 585 9906 6381 I:m3\001
4 1 -1 0 0 0 20 0.0000 4 195 585 6905 6380 I:m2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 11407 4882 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 11407 3682 0\001
4 1 -1 0 0 0 20 0.0000 4 210 525 11406 2181 C:kt\001
4 1 -1 0 0 0 20 0.0000 4 210 525 11482 6382 R:bt\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5406 4881 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5406 3681 0\001
4 1 -1 0 0 0 20 0.0000 4 210 585 5481 6381 R:b2\001
4 1 -1 0 0 0 20 0.0000 4 195 150 12909 4884 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 6908 4883 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2404 2179 1\001
4 1 -1 0 0 0 20 0.0000 4 255 585 2779 754 C:p1\001
4 1 -1 0 0 0 20 0.0000 4 210 585 2104 754 R:d1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 910 4885 1\001
4 1 -1 0 0 0 20 0.0000 4 210 675 902 3377 SS:fb\001
4 1 -1 0 0 0 20 0.0000 4 210 615 12905 3380 SS:ft\001
4 1 -1 0 0 0 20 0.0000 4 195 150 9909 4884 1\001
4 1 -1 0 0 0 20 0.0000 4 210 585 5405 2180 C:k2\001
4 1 1 1 0 3 20 0.0000 4 210 1455 900 5700 Macro base\001
4 1 1 1 0 3 20 0.0000 4 210 1800 2401 376 Macro control\001
4 1 1 1 0 3 20 0.0000 4 195 1950 2400 6900 Macro actuator\001
4 1 1 1 0 3 20 0.0000 4 195 1530 3900 3825 Macro mass\001
4 1 1 1 0 3 20 0.0000 4 195 1470 6900 3825 Micro mass\001
4 1 1 1 0 3 20 0.0000 4 270 1890 5400 1650 Compliant link\001
4 1 1 1 0 3 20 0.0000 4 195 1890 8475 1650 Micro actuator\001
4 1 1 1 0 3 20 0.0000 4 255 1125 9900 3825 Tip mass\001
4 1 1 1 0 3 20 0.0000 4 270 2985 11400 1650 Compliant environment\001
4 1 1 1 0 3 20 0.0000 4 255 1305 12901 5701 Tip sensor\001

Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_desc.tex version [52d78b057e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system iMacroMicro (iMacroMicro_desc.tex)
% Generated by MTT on Tue Dec 9 18:13:04 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/02/22 22:24:27  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iMacroMicro} is
   displayed in Figure \Ref{iMacroMicro_abg} and its label
   file is listed in Section \Ref{sec:iMacroMicro_lbl}.
   The subsystems are listed in Section \Ref{sec:iMacroMicro_sub}.

This is a Bond Graph model of the macro-micro manipulation system
discussed by Sharon in his thesis and by Sharon, Hogan and Hardt in
various papers. The micro loop is inverted whilst leaving the macro
control in place. This {\em partial inverse\/} gives information about
the {\em zero dynamics\/} of the micro control system with the
particular macro controller in place and allows desidn of the macro
controller to ease the design of the micro controller.


%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_lbl.txt version [eda41e1822].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file (macmic_lbl.txt)
%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Masses
m1	lin	flow,m_1
m2	lin	flow,m_2
m3	lin	flow,m_3

%Springs
k2	lin	state,k_2
kt	lin	state,k_t

%Dampers
b1	lin	flow,b_1
b2	lin	flow,b_2
b3	lin	flow,b_3
bt	lin	flow,b_t

%Source/sensors
f2	SS	external,internal
ft	SS	external,0
fb	SS	internal,0

%Control
p1	lin	flow,p_1
d1	lin	flow,d_1



Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_numpar.txt version [b385767fcd].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;

Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_rep.txt version [e84c5723e2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system iMacroMicro (iMacroMicro_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:49:22  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iMacroMicro abg tex
mtt iMacroMicro cbg ps
mtt iMacroMicro struc tex
mtt iMacroMicro dae tex
mtt iMacroMicro dm tex
mtt iMacroMicro tf tex
mtt iMacroMicro numpar txt
mtt iMacroMicro lmfr ps 
mtt iMacroMicro lpfr ps 
mtt iMacroMicro sro ps 
mtt iMacroMicro odeso ps 

Deleted mttroot/mtt/lib/examples/Inverse/iMacroMicro/iMacroMicro_simpar.txt version [1372589ac1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system iMacroMicro (iMacroMicro_simpar.txt)
# Generated by MTT on Wed Nov 18 10:08:20 GMT 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -2;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/NMP/NMP_abg.fig version [514aa7b44f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3903 2403 4803 2403 4653 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5403 2403 6303 2403 6153 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 2103 3603 1203 3753 1353
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3002 3302 2402 3302 2627
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3905 4201 4805 4201 4655 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 4201 6305 4201 6155 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3605 4501 3605 5401 3755 5251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3602 3302 4202 3077 4202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7803 3302 8703 3302 8553 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1203 3302 2103 3302 1953 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2101 3076 2101 3301
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2101 3301 2101 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8701 3076 8701 3301
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8701 3301 8701 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5103 2103 5103 1203 5253 1353
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 3000 5700 600 3000 600 3000 3000 5700 3000
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 6000 5700 3600 3000 3600 3000 6000 5700 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4200 7650 3600 7650 3825
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7052 2402 7652 3002 7427 3002
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5100 4500 5100 5400 5250 5250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4800 4501 4164 5137 4376 5137
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 2478 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 2478 0\001
4 1 -1 0 0 0 20 0.0000 4 240 660 3602 1052 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2402 3377 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 4278 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 4278 0\001
4 1 -1 0 0 0 20 0.0000 4 195 720 6603 4278 AE:m\001
4 1 -1 0 0 0 20 0.0000 4 240 645 3603 5778 R:r_f\001
4 1 -1 0 0 0 20 0.0000 4 195 150 7577 3377 1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 751 3376 SS:e1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 9151 3376 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 240 690 5102 1052 C:c_s\001
4 1 1 1 0 3 20 0.0000 4 270 1515 4200 375 Slow system\001
4 1 1 1 0 3 20 0.0000 4 255 1470 4200 6450 Fast system\001
4 1 -1 0 0 0 20 0.0000 4 255 630 6678 2478 AE:p\001
4 1 -1 0 0 0 20 0.0000 4 240 675 5104 5779 C:c_f\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4203 5478 R:r\001

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/NMP/NMP_desc.tex version [f95b4585ef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system NMP (NMP_desc.tex)
% Generated by MTT on Tue Dec 9 17:34:06 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{NMP} is
   displayed in Figure \Ref{NMP_abg} and its label
   file is listed in Section \Ref{sec:NMP_lbl}.
   The subsystems are listed in Section \Ref{sec:NMP_sub}.

This is a simple non-minimum phase system with an inverse-type
response.  It is the standard fast negative and slow positive systems
in parallel. The corresponding inverse system \textbf{iNMP} is
unstable.


Deleted mttroot/mtt/lib/examples/Inverse/iNMP/NMP/NMP_lbl.txt version [dfd1521cff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system NMP (NMP_lbl.txt)
%SUMMARY NMP A simple non-minimum phase system
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/20 16:40:54  peterg
% %% New SS format
% %%
% %% Revision 1.1  1999/03/09 00:08:21  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	c_f
%ALIAS	$2	c_s
%ALIAS	$3	r_f
%ALIAS	$4	r_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	m		lin	-1
	p		lin	1

% Component type C
	c_f		lin	effort,c_f
	c_s		lin	effort,c_s

% Component type R
	r		lin	flow,r
	r_f		lin	flow,r_f
	r_s		lin	flow,r_s

% Component type SS
	e1		SS	external,internal
	e2		SS	external,0

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/NMP/NMP_numpar.txt version [1d7033f948].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (NMP_numpar.txt)
# Generated by MTT at Thu Oct  8 09:25:16 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_f = 	0.5; # NMP
c_s = 	1.0; # NMP
r = 	1.0; # NMP
r_f = 	1.0; # NMP
r_s = 	1.0; # NMP

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/NMP/NMP_rep.txt version [0e160c8365].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system NMP (NMP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt NMP abg tex
mtt NMP struc tex
mtt NMP ode tex
mtt NMP sm tex
mtt NMP tf tex

mtt NMP sro ps
mtt NMP lmfr ps
mtt NMP lpfr ps

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_abg.fig version [ac324604a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Inches
A4      
100.00
Single
-2
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3903 2403 4803 2403 4653 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5403 2403 6303 2403 6153 2553
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 2103 3603 1203 3753 1353
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3002 3302 2402 3302 2627
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3905 4201 4805 4201 4655 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 4201 6305 4201 6155 4351
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3605 4501 3605 5401 3755 5251
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2702 3602 3302 4202 3077 4202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7803 3302 8703 3302 8553 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1203 3302 2103 3302 1953 3452
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2101 3301 2101 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8701 3301 8701 3526
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5103 2103 5103 1203 5253 1353
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 3000 5700 600 3000 600 3000 3000 5700 3000
2 4 1 2 -1 7 0 0 -1 6.000 0 0 7 0 0 5
	 5700 6000 5700 3600 3000 3600 3000 6000 5700 6000
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 4200 7650 3600 7650 3825
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7052 2402 7652 3002 7427 3002
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5100 4500 5100 5400 5250 5250
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4800 4501 4164 5137 4376 5137
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1200 3075 1200 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7800 3075 7800 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6300 2400 6300 2625
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5400 2175 5400 2400
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 2478 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 2478 0\001
4 1 -1 0 0 0 20 0.0000 4 240 660 3602 1052 R:r_s\001
4 1 -1 0 0 0 20 0.0000 4 195 150 2402 3377 0\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3603 4278 1\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5103 4278 0\001
4 1 -1 0 0 0 20 0.0000 4 195 720 6603 4278 AE:m\001
4 1 -1 0 0 0 20 0.0000 4 240 645 3603 5778 R:r_f\001
4 1 -1 0 0 0 20 0.0000 4 195 150 7577 3377 1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 751 3376 SS:e1\001
4 1 -1 0 0 0 20 0.0000 4 210 705 9151 3376 SS:e2\001
4 1 -1 0 0 0 20 0.0000 4 240 690 5102 1052 C:c_s\001
4 1 1 1 0 3 20 0.0000 4 270 1515 4200 375 Slow system\001
4 1 1 1 0 3 20 0.0000 4 255 1470 4200 6450 Fast system\001
4 1 -1 0 0 0 20 0.0000 4 255 630 6678 2478 AE:p\001
4 1 -1 0 0 0 20 0.0000 4 240 675 5104 5779 C:c_f\001
4 1 -1 0 0 0 20 0.0000 4 195 390 4203 5478 R:r\001

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_desc.tex version [183722d9b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system iNMP (iNMP_desc.tex)
% Generated by MTT on Tue Dec 9 17:34:06 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iNMP} is
   displayed in Figure \Ref{iNMP_abg} and its label
   file is listed in Section \Ref{sec:iNMP_lbl}.
   The subsystems are listed in Section \Ref{sec:iNMP_sub}.

This is a simple non-minimum phase system with an inverse-type
response.  It is the standard fast negative and slow positive systems
in parallel. The corresponding inverse system \textbf{iiNMP} is
unstable.


Deleted mttroot/mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_lbl.txt version [2b065592af].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system iNMP (iNMP_lbl.txt)
%SUMMARY iNMP Inverse simple non-minimum phase system
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/20 16:42:42  peterg
% %% New SS format
% %%
% %% Revision 1.1  1999/03/09 00:10:07  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases
%ALIAS	$1	c_f
%ALIAS	$2	c_s
%ALIAS	$3	r_f
%ALIAS	$4	r_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type AE
	m		lin	-1
	p		lin	1

% Component type C
	c_f		lin	effort,c_f
	c_s		lin	effort,c_s

% Component type R
	r		lin	flow,r
	r_f		lin	flow,r_f
	r_s		lin	flow,r_s

% Component type SS
	e1		SS	external,internal
	e2		SS	external,0

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_numpar.txt version [1d7033f948].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (NMP_numpar.txt)
# Generated by MTT at Thu Oct  8 09:25:16 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_f = 	0.5; # NMP
c_s = 	1.0; # NMP
r = 	1.0; # NMP
r_f = 	1.0; # NMP
r_s = 	1.0; # NMP

Deleted mttroot/mtt/lib/examples/Inverse/iNMP/iNMP/iNMP_rep.txt version [1261b95adc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system iNMP (iNMP_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iNMP abg tex
mtt iNMP struc tex
mtt iNMP ode tex
mtt iNMP dm tex
mtt iNMP tf tex

mtt iNMP lmfr ps
mtt iNMP lpfr ps

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_abg.fig version [88a5a6ef61].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3600 3375 3600 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3375 5175 2475 5400 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 3376 8325 2476 8550 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3600 4950 3600 4725 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 3601 8100 3601 7875 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 3780 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3600 6525 3600 6300 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3345 3600 2445 3825 2670
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3346 6750 2446 6975 2671
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 3780 2475 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 3600 2475 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 3375 3780 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3780 4050 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4995 3375 5310 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8145 3375 8460 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6615 2475 6930 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 3600 6525 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7200 3780 7200 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7200 3555 7200 3375
4 0 -1 0 0 2 20 0.0000000 4 210 150 5085 3735 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3510 3690 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6660 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8235 3736 0\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 3465 2250 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4995 2250 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 6525 2250 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8100 2295 C:c_2\001
4 2 -1 0 0 2 20 0.0000000 4 270 750 2385 3690 SS:uy\001

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_desc.tex version [5eddc121b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system iRC2c (iRC2c_desc.tex)
% Generated by MTT on Mon Apr 6 10:46:00 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iRC2c} is
   displayed in Figure \Ref{iRC2c_abg} and its label
   file is listed in Section \Ref{sec:iRC2c_lbl}.
   The subsystems are listed in Section \Ref{sec:iRC2c_sub}.

This example gives the inverse of a double RC circuit with
\emph{collocated} sensor/actuator pairing.


Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_input.txt version [bae2b6c20a].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (iRC2c_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	 1 ; # iRC2c (u_s)

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_lbl.txt version [970ccd463e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY iRC2c Inverse of double RC circuit with collocated io
%DESCRIPTION <Detailed description here>
%% Label file for system iRC2c (iRC2c_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_2		lin	effort,c_2

% Component type R
	r_1		lin	flow,r_1
	r_2		lin	flow,r_2

% Component type SS
	uy		SS	external,external


Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_numpar.txt version [434e56074d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (iRC2c_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # iRC2c
c_1s = 	0.1; # iRC2c
c_2 = 	1.0; # iRC2c
c_2s = 	0.1; # iRC2c
r_1 = 	1.0; # iRC2c
r_1s = 	1.0; # iRC2c
r_2 = 	1.0; # iRC2c
r_2s = 	1.0; # iRC2c

# Initial states
x(1) = 	0.0; # iRC2c (c_1)
x(2) = 	0.0; # iRC2c (c_1s)
x(3) = 	0.0; # iRC2c (c_2)
x(4) = 	0.0; # iRC2c (c_2s)

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2c/iRC2c_rep.txt version [0627609c1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system iRC2c (iRC2c_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iRC2c abg tex
mtt iRC2c struc tex
mtt iRC2c dae tex
mtt iRC2c dm tex
mtt iRC2c tf tex


Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_abg.fig version [094799a629].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5625 3600 5625 3420
2 1 2 2 1 7 1 0 -1 4.500 0 0 7 0 0 4
	 9585 3465 8325 3465 8190 3375 8190 2565
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3600 3375 3600 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3375 5175 2475 5400 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 3376 8325 2476 8550 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3600 4950 3600 4725 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7200 3601 8100 3601 7875 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8775 3601 9675 3601 9450 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3465 3375 3780 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5040 2475 5355 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6615 3375 6930 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8190 2475 8505 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 3600 2475 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3375 3780 3375 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 3780 4950 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 3780 6525 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3600 6525 3600 6300 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7200 3600 7200 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8100 3780 8100 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8775 3600 8775 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 3600 9675 3780
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3345 3600 2445 3825 2670
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3346 6750 2446 6975 2671
2 1 1 1 1 7 1 0 -1 4.000 0 0 7 0 0 4
	 9585 3510 5400 3510 5310 3420 5310 2790
2 1 2 2 1 -1 1 0 -1 3.000 0 0 7 0 0 9
	 8392 2632 8392 3712 6862 3712 6862 2497 6727 2362 6592 2497
	 6592 3442 5242 3442 5242 2632
4 0 -1 0 0 2 20 0.0000000 4 210 150 5085 3735 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3510 3690 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6660 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8235 3736 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 2295 3645 SS:u\001
4 0 -1 0 0 2 20 0.0000000 4 270 585 9810 3690 SS:y\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 3465 2250 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4995 2250 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 6525 2250 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8100 2295 C:c_2\001

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_desc.tex version [9163d2db1b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system iRC2n (iRC2n_desc.tex)
% Generated by MTT on Mon Apr 6 10:46:52 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iRC2n} is
   displayed in Figure \Ref{iRC2n_abg} and its label
   file is listed in Section \Ref{sec:iRC2n_lbl}.
   The subsystems are listed in Section \Ref{sec:iRC2n_sub}.

This example gives the inverse of a double RC circuit with
\emph{non-collocated} sensor/actuator pairing.

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_input.txt version [8fa4a991b7].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (iRC2n_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	 1 ; # iRC2n (u_s)

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_lbl.txt version [3c4a501e9c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY iRC2n Inverse of double RC circuit with non-collocated io
%DESCRIPTION <Detailed description here>
%% Label file for system iRC2n (iRC2n_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/05/20 16:43:52  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_2		lin	effort,c_2

% Component type R
	r_1		lin	flow,r_1
	r_2		lin	flow,r_2

% Component type SS
	u		SS	external,internal
	y		SS	external,0

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_numpar.txt version [3f9b896142].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (iRC2n_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # iRC2n
c_1s = 	0.1; # iRC2n
c_2 = 	1.0; # iRC2n
c_2s = 	0.1; # iRC2n
r_1 = 	1.0; # iRC2n
r_1s = 	1.0; # iRC2n
r_2 = 	1.0; # iRC2n
r_2s = 	1.0; # iRC2n

# Initial states
x(1) = 	0.0; # iRC2n (c_1)
x(2) = 	0.0; # iRC2n (c_1s)
x(3) = 	0.0; # iRC2n (c_2)
x(4) = 	0.0; # iRC2n (c_2s)

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_rep.txt version [683a8983e4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system iRC2n (iRC2n_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iRC2n abg tex
mtt iRC2n struc tex
mtt iRC2n dae tex
mtt iRC2n dm tex
mtt iRC2n tf tex



Deleted mttroot/mtt/lib/examples/Inverse/iRC2/iRC2n/iRC2n_simp.r version [a8454e246a].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce commands to simplify output for system iRC2n (iRC2n_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MTTu1 := y;

END;

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_abg.fig version [64973640f8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134






































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3601 4051 3601 3826 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3376 5851 2476 6076 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 3377 9001 2477 9226 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3601 5626 3601 5401 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 3602 8776 3602 8551 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 3601 4726 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3781 7201 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3601 7201 3601 6976 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 3346 4276 2446 4501 2671
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 3347 7426 2447 7651 2672
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 3376 5986 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 3376 9136 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 2476 7606 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3601 7201 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 3781 7876 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 3825 2925 4725 3150 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 5175 2925 6075 3150 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 6301 4051 6301 3826 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 6076 5851 5176 6076 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 6077 9001 5177 9226 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 6301 5626 6301 5401 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 6302 8776 6302 8551 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6301 4726 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6481 7201 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 6301 7201 6301 6976 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 6046 4276 5146 4501 5371
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 6047 7426 5147 7651 5372
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6481 3151 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6301 3151 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 6076 4456 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6481 4726 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 6076 5986 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 6076 9136 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 5176 7606 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6301 7201 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 6481 7876 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1756 6301 2656 6301 2431 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3780 4050 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 2475 4456 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 3781 4725 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 3645 7875 3465
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 6300 7875 6120
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3375 2700 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3600 2701 3600 2476 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3105 5175 2925 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2925 5175 2745 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 6480 1755 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 6300 1755 6120
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 4050 9900 1530 3600 1530 3600 4050 9900 4050
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 7020 9900 4500 3600 4500 3600 7020 9900 7020
4 2 -1 0 0 2 20 0.0000000 4 240 870 1710 3645 SS:u_s\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 3692 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 3737 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 3736 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 6392 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 6437 0\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4141 4951 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 5671 4951 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 7201 4951 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 6391 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 6436 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 1665 6345 SS:u\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8775 4950 C:c_2\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 4141 2251 R:r_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 5671 2251 C:c_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 7201 2251 R:r_2s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 8775 2250 C:c_2s\001
4 0 -1 0 0 2 20 0.0000000 4 210 390 2835 5040 AF\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 6391 0\001
4 1 1 1 0 0 20 0.0000000 4 210 450 2565 4455 e=0\001
4 1 1 1 0 0 20 0.0000000 4 210 420 2070 6570 f=0\001
4 1 1 1 0 0 20 0.0000000 4 270 2550 6750 1845 Specification system\001
4 1 1 1 0 0 20 0.0000000 4 270 1830 6615 6840 Inverse system\001

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_desc.tex version [b9cbbd7602].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system saRC2c (saRC2c_desc.tex)
% Generated by MTT on Mon Apr 6 10:47:43 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{saRC2c} is
   displayed in Figure \Ref{saRC2c_abg} and its label
   file is listed in Section \Ref{sec:saRC2c_lbl}.
   The subsystems are listed in Section \Ref{sec:saRC2c_sub}.

This example gives the inverse of a double RC circuit with
\begin{itemize}
\item specification system,
\item amplifier connection and
\item collocated sensor/actuator pairing.
\end{itemize}


Deleted mttroot/mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_input.txt version [5f23f78e18].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (saRC2c_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:53:33  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 16:20:22 BST 2003: u(1) =	 1 ; # saRC2c (u_s)
sarc2c__u_s	= 1.0; 

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_lbl.txt version [a4d16b5d03].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY saRC2c
%DESCRIPTION <Detailed description here>
%% Label file for system saRC2c (saRC2c_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_1s		lin	effort,c_1s
	c_2		lin	effort,c_2
	c_2s		lin	effort,c_2s

% Component type R
	r_1		lin	flow,r_1
	r_1s		lin	flow,r_1s
	r_2		lin	flow,r_2
	r_2s		lin	flow,r_2s

% Component type SS
	u		SS	external,0
	u_s		SS	external,external

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_numpar.txt version [f33e6310a9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (saRC2c_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:53:33  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # saRC2c
c_1s = 	0.1; # saRC2c
c_2 = 	1.0; # saRC2c
c_2s = 	0.1; # saRC2c
r_1 = 	1.0; # saRC2c
r_1s = 	1.0; # saRC2c
r_2 = 	1.0; # saRC2c
r_2s = 	1.0; # saRC2c

# Initial states
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(1) = 	0.0; # saRC2c (c_1)
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(2) = 	0.0; # saRC2c (c_1s)
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(3) = 	0.0; # saRC2c (c_2)
## Removed by MTT on Tue Jun 10 16:19:14 BST 2003: x(4) = 	0.0; # saRC2c (c_2s)

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/saRC2c/saRC2c_rep.txt version [89a6a7bd2f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system saRC2c (saRC2c_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:53:33  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt saRC2c abg tex
mtt saRC2c struc tex
mtt saRC2c dae tex
mtt saRC2c dm tex
mtt saRC2c tf tex

mtt saRC2c odeso ps
mtt saRC2c lmfr ps


Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_abg.fig version [ac27af0e16].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141













































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 3601 4051 3601 3826 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3376 5851 2476 6076 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 3377 9001 2477 9226 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3601 5626 3601 5401 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 3602 8776 3602 8551 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 3601 4726 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3781 7201 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 3601 7201 3601 6976 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 3346 4276 2446 4501 2671
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 3347 7426 2447 7651 2672
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 3376 5986 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 3376 9136 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 2476 7606 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 3601 7201 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 3781 7876 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 3825 2925 4725 3150 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2925 5175 2925 6075 3150 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3151 6301 4051 6301 3826 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 6076 5851 5176 6076 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9001 6077 9001 5177 9226 5402
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 6301 5626 6301 5401 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7876 6302 8776 6302 8551 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6301 4726 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6481 7201 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 6301 7201 6301 6976 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 6046 4276 5146 4501 5371
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7426 6047 7426 5147 7651 5372
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6481 3151 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 6301 3151 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 6076 4456 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4726 6481 4726 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5671 6076 5986 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8821 6076 9136 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7291 5176 7606 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7201 6301 7201 6121
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7876 6481 7876 6301
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1756 6301 2656 6301 2431 6526
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 4950 2701 4950 2476 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 4770
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 5130 1800 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2655 6480 2655 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3780 4050 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 3600 4050 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4141 2475 4456 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4725 3781 4725 3601
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 3645 7875 3465
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 6300 7875 6120
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3375 2700 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1801 3600 2701 3600 2476 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 3825 3150 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2925 6075 2745 6075
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3105 5175 2925 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 6300 1755 6120
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 4275 9900 1125 3600 1125 3600 4275 9900 4275
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9900 7650 9900 4500 3600 4500 3600 7650 9900 7650
4 2 -1 0 0 2 20 0.0000000 4 240 870 1710 3645 SS:u_s\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 3692 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 3737 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 3736 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 7336 6392 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8911 6437 0\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4141 4951 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 5671 4951 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 7201 4951 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4231 6391 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 5806 6436 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 1665 6345 SS:u\001
4 2 -1 0 0 2 20 0.0000000 4 210 990 1620 5040 SS:zero\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 8775 4950 C:c_2\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 3691 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 2835 5040 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 150 3016 6391 1\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 4141 2251 R:r_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 5671 2251 C:c_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 7201 2251 R:r_2s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 8775 2250 C:c_2s\001
4 1 1 1 0 3 20 0.0000000 4 210 450 2250 4860 e=0\001
4 1 1 1 0 3 20 0.0000000 4 270 420 2250 5220 f=0\001
4 1 1 1 0 3 20 0.0000000 4 270 1845 6525 7110 Inverse system\001
4 1 1 1 0 3 20 0.0000000 4 270 2565 6660 1665 Specification system\001

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_desc.tex version [26c739d9e0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system szRC2c (szRC2c_desc.tex)
% Generated by MTT on Mon Apr 6 10:50:51 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{szRC2c} is
   displayed in Figure \Ref{szRC2c_abg} and its label
   file is listed in Section \Ref{sec:szRC2c_lbl}.
   The subsystems are listed in Section \Ref{sec:szRC2c_sub}.


This example gives the inverse of a double RC circuit with
\begin{itemize}
\item specification system,
\item zero-zero \textbf{SS} connection and
\item collocated sensor/actuator pairing.
\end{itemize}

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_input.txt version [979b0df214].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (szRC2c_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:15  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 16:39:19 BST 2003: u(1) =	 1 ; # szRC2c (u_s)
szrc2c__u_s	= 1.0; 

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_lbl.txt version [6c7ddb1b45].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY szRC2c Specification inverse of double RC circuit with collocated io
%DESCRIPTION <Detailed description here>
%% Label file for system szRC2c (szRC2c_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:15  peterg
% %% To RCS
% %%
% %% Revision 1.1  2000/05/20 16:44:55  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_1s		lin	effort,c_1s
	c_2		lin	effort,c_2
	c_2s		lin	effort,c_2s

% Component type R
	r_1		lin	flow,r_1
	r_1s		lin	flow,r_1s
	r_2		lin	flow,r_2
	r_2s		lin	flow,r_2s

% Component type SS
	u_s		SS	external,external
	zero		SS	0,0
	u		SS	external,internal

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_numpar.txt version [f4e95e7050].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (szRC2c_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:15  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # szRC2c
c_1s = 	0.1; # szRC2c
c_2 = 	1.0; # szRC2c
c_2s = 	0.1; # szRC2c
r_1 = 	1.0; # szRC2c
r_1s = 	1.0; # szRC2c
r_2 = 	1.0; # szRC2c
r_2s = 	1.0; # szRC2c

# Initial states
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(1) = 	0.0; # szRC2c (c_1)
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(2) = 	0.0; # szRC2c (c_1s)
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(3) = 	0.0; # szRC2c (c_2)
## Removed by MTT on Tue Jun 10 16:38:56 BST 2003: x(4) = 	0.0; # szRC2c (c_2s)

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2c/szRC2c_rep.txt version [2a2641f9d2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system szRC2c (szRC2c_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:15  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt szRC2c abg tex
mtt szRC2c struc tex
mtt szRC2c dae tex
mtt szRC2c dm tex
mtt szRC2c tf tex

mtt zRC2c odeso ps
mtt szRC2c lmfr ps


Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_abg.fig version [2bd65cadb4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2251 4726 3151 4726 2926 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 4501 4951 3601 5176 3826
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 4502 8101 3602 8326 3827
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4726 4726 4726 4501 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 4727 7876 4727 7651 4952
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 4727 9451 4727 9226 4952
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3151 4906 3151 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4726 3826 4546
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6301 4906 6301 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5401 4726 6301 4726 6076 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6976 4726 6976 4546
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 4905 3825 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4770 4500 5085 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6345 3600 6660 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 4905 6975 4725
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7920 4500 8235 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 4725 9450 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 4680 9450 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10126 6301 9901 6076 11026 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9901 6076 9901 5896
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11026 6256 11026 6076
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9675 4950 9675 5850 9900 5625
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5402 7427 5402 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 7427 3152 7427 2927 7652
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4952 7202 4952 6302 5177 6527
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8102 7203 8102 6303 8327 6528
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3827 7427 4727 7427 4502 7652
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 7428 7877 7428 7652 7653
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8552 7428 9452 7428 9227 7653
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3242 7202 3557 7202
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4817 6302 5132 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6392 7202 6707 7202
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7967 6302 8282 6302
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2252 7427 2252 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3152 7607 3152 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3827 7427 3827 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4727 7607 4727 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6302 7607 6302 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5402 7427 6302 7427 6077 7652
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6977 7427 6977 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7877 7607 7877 7427
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8552 7427 8552 7247
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3377 7172 3377 6272 3602 6497
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6527 7173 6527 6273 6752 6498
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9450 7425 9450 7605
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 4725 3150 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3240 3600 3555 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9901 4725 10801 4725 10576 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10800 4725 10800 4905
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 10800 4725 10800 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 4516 3375 3616 3600 3841
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 4517 6525 3617 6750 3842
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9495 5850 9810 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 6300 9855 6300
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9675 6313 9675 7213 9900 6988
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9675 7245 9495 7245
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9045 5355 9045 2250 2475 2250 2475 5355 9045 5355
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 9045 8730 9045 5625 2475 5625 2475 8730 9045 8730
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6300 4680 6300 4500
4 0 -1 0 0 2 20 0.0000000 4 210 150 4861 4861 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3286 4816 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6436 4817 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8011 4862 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 9586 4816 0\001
4 2 -1 0 0 2 20 0.0000000 4 240 870 2071 4771 SS:u_s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 3241 3376 R:r_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 6301 3376 R:r_2s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 4771 3376 C:c_1s\001
4 0 -1 0 0 2 20 0.0000000 4 240 870 7875 3375 C:c_2s\001
4 0 -1 0 0 2 20 0.0000000 4 210 990 11206 6166 SS:zero\001
4 1 1 1 0 3 20 0.0000000 4 210 450 10441 5986 e=0\001
4 1 1 1 0 3 20 0.0000000 4 270 420 10441 6346 f=0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 9585 6210 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 4862 7562 0\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 3287 7517 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 6437 7518 1\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 8012 7563 0\001
4 2 -1 0 0 2 20 0.0000000 4 210 600 2072 7472 SS:u\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 3242 6077 R:r_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 4772 6077 C:c_1\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 6302 6077 R:r_2\001
4 0 -1 0 0 2 20 0.0000000 4 240 750 7876 6076 C:c_2\001
4 0 -1 0 0 2 20 0.0000000 4 210 150 9630 7515 0\001
4 0 -1 0 0 2 20 0.0000000 4 270 855 10935 4815 SS:y_s\001
4 1 1 1 0 3 20 0.0000000 4 270 420 10260 5085 f=0\001
4 1 1 1 0 3 20 0.0000000 4 270 2565 5625 2745 Specification system\001
4 1 1 1 0 3 20 0.0000000 4 270 1845 5535 8280 Inverse system\001

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_desc.tex version [c87760ad0d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system szRC2n (szRC2n_desc.tex)
% Generated by MTT on Mon Apr 6 10:52:26 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{szRC2n} is
   displayed in Figure \Ref{szRC2n_abg} and its label
   file is listed in Section \Ref{sec:szRC2n_lbl}.
   The subsystems are listed in Section \Ref{sec:szRC2n_sub}.

This example gives the inverse of a double RC circuit with
\begin{itemize}
\item specification system,
\item zero-zero \textbf{SS} connection and
\item non-collocated sensor/actuator pairing.
\end{itemize}



%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_input.txt version [b039d69e85].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (szRC2n_input.txt)
# Generated by MTT at Mon Mar  2 15:42:48 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:46  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 16:43:05 BST 2003: u(1) =	 1 ; # szRC2n (u_s)
szrc2n__u_s	= 1.0; 

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_lbl.txt version [3ac9c98526].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY szRC2n Specification inverse of double RC circuit with noncollocated io
%DESCRIPTION <Detailed description here>
%% Label file for system szRC2n (szRC2n_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:46  peterg
% %% To RCS
% %%
% %% Revision 1.1  2000/05/20 16:45:37  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	c_1		lin	effort,c_1
	c_1s		lin	effort,c_1s
	c_2		lin	effort,c_2
	c_2s		lin	effort,c_2s

% Component type R
	r_1		lin	flow,r_1
	r_1s		lin	flow,r_1s
	r_2		lin	flow,r_2
	r_2s		lin	flow,r_2s

% Component type SS
	u_s		SS	external,internal
	y_s		SS	external,0
	zero		SS	0,0
	u		SS	external,internal

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_numpar.txt version [73f4af03d4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (szRC2n_numpar.txt)
# Generated by MTT at Mon Mar  2 15:41:26 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:54:46  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_1 = 	1.0; # szRC2n
c_1s = 	0.1; # szRC2n
c_2 = 	1.0; # szRC2n
c_2s = 	0.1; # szRC2n
r_1 = 	1.0; # szRC2n
r_1s = 	1.0; # szRC2n
r_2 = 	1.0; # szRC2n
r_2s = 	1.0; # szRC2n

# Initial states
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(1) = 	0.0; # szRC2n (c_1)
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(2) = 	0.0; # szRC2n (c_1s)
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(3) = 	0.0; # szRC2n (c_2)
## Removed by MTT on Tue Jun 10 16:42:56 BST 2003: x(4) = 	0.0; # szRC2n (c_2s)

Deleted mttroot/mtt/lib/examples/Inverse/iRC2/szRC2n/szRC2n_rep.txt version [57d3f6478f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system szRC2n (szRC2n_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:54:46  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt szRC2n abg tex
mtt szRC2n struc tex
mtt szRC2n dae tex
mtt szRC2n dm tex
mtt szRC2n tf tex

mtt szRC2n odeso ps
mtt szRC2n lmfr ps


Deleted mttroot/mtt/lib/examples/Inverse/iTanks/iTanks_abg.fig version [4413ea1185].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 900 3150 2025 3150 1755 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 3150 3600 3150 3330 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 2925 2250 1800 2520 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7201 3151 8326 3151 8056 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8776 3151 9901 3151 9631 3421
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6976 2926 6976 1801 7246 2071
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 2926 8551 1801 8821 2071
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 3150 5175 3150 4905 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5625 3150 6750 3150 6480 3420
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2925 3825 1800 4095 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 2925 5400 1800 5670 2070
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3375 6975 4500 7245 4230
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11295 5625 11295 450 45 450 45 5625 11295 5625
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 3150 1125 3150 2700 1305 2700
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 4
	 4500 1125 4500 2700 6300 2700 6300 1125
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 3
	 7650 1125 7650 2700 9675 2700
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1350 3600 9720 3600
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 3375 3825 4500 4095 4230
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 900 2925 900 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2025 3150 2025 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 3375 3825 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 4500 4095 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2925 9900 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8775 3150 8775 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6705 3375 6930 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 4500 7200 4500
4 1 -1 0 0 2 20 0.0000 4 195 135 2250 3240 1\001
4 1 -1 0 0 2 20 0.0000 4 195 210 2250 1665 R\001
4 1 -1 0 0 2 20 0.0000 4 195 135 8551 3241 1\001
4 1 -1 0 0 2 20 0.0000 4 195 135 6976 3241 0\001
4 1 -1 0 0 2 20 0.0000 4 195 210 8551 1666 R\001
4 1 -1 0 0 2 20 0.0000 4 195 210 6976 1666 C\001
4 1 -1 0 0 2 20 0.0000 4 195 135 5400 3240 1\001
4 1 -1 0 0 2 20 0.0000 4 195 135 3825 3240 0\001
4 1 -1 0 0 2 20 0.0000 4 195 210 5400 1665 R\001
4 1 -1 0 0 2 20 0.0000 4 195 210 3825 1665 C\001
4 1 -1 0 0 2 20 0.0000 4 195 705 495 3240 SS:u1\001
4 1 -1 0 0 2 20 0.0000 4 195 705 10440 3240 SS:u2\001
4 1 -1 0 0 2 20 0.0000 4 255 675 3825 4725 SS:y1\001
4 1 -1 0 0 2 20 0.0000 4 255 675 6975 4770 SS:y2\001
4 1 1 1 0 3 20 0.0000 4 270 510 2295 1125 Pipe\001
4 1 1 1 0 3 20 0.0000 4 270 510 5445 1125 Pipe\001
4 1 1 1 0 3 20 0.0000 4 270 510 8595 1125 Pipe\001
4 1 1 1 0 3 20 0.0000 4 210 600 3870 1125 Tank\001
4 1 1 1 0 3 20 0.0000 4 210 600 6975 1125 Tank\001
4 1 1 1 0 3 20 0.0000 4 270 1665 5265 5445 System inverse\001

Deleted mttroot/mtt/lib/examples/Inverse/iTanks/iTanks_desc.tex version [d912f0defd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system iTanks (iTanks_desc.tex)
% Generated by MTT on Wed Nov 18 11:04:33 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Figure \Ref{iTanks_abg} shows the bond graph of a two-tank system
superimposed on a schematic diagram. 
The two \textbf{C} components corresponds to the fluid storage and how
it relates to the pressure at the base of the tanks. In this case, for
simplicity, each tank ($i=1$ or $i=2$) is assumed to have a unity constitutive relationship:
\begin{equation}
  \text{pressure} = p_i = v_i = \text{volume}
\end{equation}
The volumetric flow rate into the first, and out of the second, tank
is represented by the two unlabelled \textbf{R} components. Again,
each is assumed to have a unit constitutive relationship:
\begin{equation}
  \text{flow} = f_i = \Delta_i = \text{pressure drop}
\end{equation}
The volumetric flow rate between the first and the second  tanks
is represented  \textbf{R} component labelled $k$. The constitutive relationship is assumed
linear of the form:
\begin{equation}
  \text{flow} = f = k \Delta  = \text{pressure drop}
\end{equation}

The system has two inputs:
\begin{equation}
  \begin{aligned}
    u_1 &= \text{input pressure at left-hand pipe} \\
    u_2 &= \text{input pressure at right-hand pipe} 
  \end{aligned}
\end{equation}
and two outputs:
\begin{equation}
  \begin{aligned}
    y_1 &= p_1 = \text{pressure at left-hand tank} \\
    y_2 &= p_2 = \text{pressure at right-hand tank} 
  \end{aligned}
\end{equation}
The system transfer-function matrix is given by:
\begin{equation}
  \begin{aligned}
G_{11} = G_{22} &= \frac{(s + k + 1)}{(s^2 + 2 s {(k + 1)} + 2 k + 1)}\\
G_{12} = G_{21} &= \frac{k}{(s^2 + 2 s {(k + 1)} + 2 k + 1)}
\end{aligned}
\end{equation}

However, Figure \Ref{iTanks_abg} shows the causality of the
\textbf{SS} components to \emph{invert} the system with respect to its
inputs and outputs. Figure \Ref{fig:iTanks_cbg.ps} shows the causally
complete bond graph; this system has no dynamic components in integral
causality -- the inverse has no poles and therefore the system has no
zeros.

Some further representations of the inverse appear in the following
sections.


Deleted mttroot/mtt/lib/examples/Inverse/iTanks/iTanks_lbl.txt version [51b222a0af].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY iTanks: Inversion of a two-tanks system
%DESCRIPTION This inverse system has no poles thus
%DESCRIPTION the system itself has no (multivariable) zeros
%% Label file for system iTanks (iTanks_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	u1		SS	external,internal
	u2		SS	external,internal
	y1		SS	external,0
	y2		SS	external,0

Deleted mttroot/mtt/lib/examples/Inverse/iTanks/iTanks_rep.txt version [a71249d1e5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system iTanks (iTanks_rep.txt)
# Generated by MTT on" Wed Nov 18 10:44:55 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt iTanks abg tex			# The system description
mtt iTanks cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
 mtt iTanks struc tex	        # The system structure
# mtt iTanks dae tex	        # The system dae
# mtt iTanks ode tex	        # The system ode 
# mtt iTanks sspar tex		# Steady-state parameters
# mtt iTanks ss tex 		# Steady state
mtt iTanks dm tex			# Descriptor matrices (of linearised system)
mtt iTanks tf tex
mtt iTanks lmfr ps		# log modulus of frequency response (of linearised system)
mtt iTanks lpfr ps		# log modulus of frequency response (of linearised system)
# mtt iTanks simpar tex		# Simulation parameters
# mtt iTanks numpar tex		# Numerical simulation parameters
# mtt iTanks input tex		# Simulation input
# mtt iTanks odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/ROD_abg.fig version [81af279f2a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123



























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 4950 5850 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 4950 8550 5400
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 1065 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000000 4 240 1080 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1065 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1080 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1575 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1590 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/ROD_desc.tex version [740b974979].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system ROD (ROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ROD} is
   displayed in Figure \Ref{ROD_abg} and its label
   file is listed in Section \Ref{sec:ROD_lbl}.
   The subsystems are listed in Section \Ref{sec:ROD_sub}.

{\bf ROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/ROD_lbl.txt version [1f86f162c8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	ROD: rigid rod in two dimensions
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system ROD (ROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2


	

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_abg.fig version [b300b8132c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 2476 4951 2701 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4051 3376 4051 4726 4276 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3781 4726 4276 4726
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2476 4726 2476 5221
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4951 5626 4951 5401 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6526 4681 6526 5176
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 2250 2475 2250 2700 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 675 4050 2025 4275 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3780 2025 4275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2025 2475 2520
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4275 2250 5625 2250 5400 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 1980 6525 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 2250 7875 2250 7650 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 4950 7875 4950 7650 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8371 3376 7876 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8101 3376 8101 4726 8326 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8326 4726 8326 5221
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8370 675 7875 675
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8100 675 8100 2025 8325 1800
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8325 2025 8325 2520
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 5175 6075 675 6075 675 225 5175 225 5175 6075
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 675 5625 5175 5625
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 11475 6075 6975 6075 6975 225 11475 225 11475 6075
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 6975 5625 11475 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 2250 9450 3375 9225 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8325 4950 9450 3825 9225 3825
4 1 -1 0 0 0 20 0.0000000 4 210 150 4051 5041 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 4050 2340 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 780 4050 585 SS:t1s\001
4 1 -1 0 0 0 20 0.0000000 4 210 750 6120 2340 AF:a1\001
4 1 -1 0 0 0 20 0.0000000 4 270 1290 1845 2340 msd:spec1\001
4 1 -1 0 0 0 20 0.0000000 4 270 1290 1846 5041 msd:spec2\001
4 1 -1 0 0 0 20 0.0000000 4 210 780 4051 3286 SS:t2s\001
4 1 -1 0 0 0 20 0.0000000 4 210 750 6121 5041 AF:a2\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8101 5041 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8100 2340 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 660 8100 585 SS:t1\001
4 1 1 1 0 0 20 0.0000000 4 270 1620 2880 5940 Specification\001
4 1 1 1 0 0 20 0.0000000 4 270 900 9270 5940 System\001
4 1 -1 0 0 0 20 0.0000000 4 210 660 8101 3286 SS:t2\001
4 1 -1 0 0 0 20 0.0000000 4 270 1500 9900 3690 twolink:syst\001
4 0 4 0 0 0 20 0.0000000 4 270 1080 9585 3330 [joint_1]\001
4 0 4 0 0 0 20 0.0000000 4 270 1080 9540 4140 [joint_2]\001

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_desc.tex version [81019ef0b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system iTwoLink (iTwoLink_desc.tex)
% Generated by MTT on Mon Nov 17 10:42:48 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/01/19 10:08:21  peterg
% %% Added comment about linearisation point
% %%
% %% Revision 1.2  1998/01/19 09:57:26  peterg
% %% Added a discussion of the relevance of G(s).
% %%
% Revision 1.1  1997/12/09  16:53:27  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{iTwoLink} is
   displayed in Figure \Ref{iTwoLink_abg} and its label
   file is listed in Section \Ref{sec:iTwoLink_lbl}.
   The subsystems are listed in Section \Ref{sec:iTwoLink_sub}.

This example illustrates the inversion of  two link manipulator
dynamics using two identical  simple mass-spring-damper systems as
specification systems.

The velocities $\omega_1=\omega_2$ specified by the specification
systems are given in Figure \Ref{fig:iTwoLink_odeso.ps-iTwoLink-t1s}
together with the input defined in Section \Ref{sec:iTwoLink_input.txt}.
The torques $\tau_1$ and $\tau_2$ required to give the these
velocities specified by the specification system are given in Figures
\Ref{fig:iTwoLink_odeso.ps-iTwoLink-t1} and
\Ref{fig:iTwoLink_odeso.ps-iTwoLink-t2} respectively.

The corresponding velocity/torque diagrams for joints 1 and 2 appear in
Figures \Ref{fig:iTwoLink_odeso.ps-iTwoLink-t1s:iTwoLink-t1}
\Ref{fig:iTwoLink_odeso.ps-iTwoLink-t2s:iTwoLink-t2} respectively.
Such diagrams can be used for actuator sizing in terms of torque,
velocity and power.

 
This non-linear system can be linearised (about the various
configurations) and small-signal frequency response methods applied.
For example, the four transfer functions $G_11$ to $G_22$ in Section
\Ref{sec:iTwoLink_tf} (representing the system linearised about zero
angles and velocities), give the small-signal relations between the
two spec. torques and the required system torques. Used together with
$G_31$ and $G_42$ (relating the spec. torques and the joint
velocities) gives, in principle, a method for evaluating actuator
requirements (for small signals) as a function of frequency.

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_input.txt version [86101d6ed8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (iTwoLink_input.txt)
# Generated by MTT at Mon Nov 17 10:40:37 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:56:50  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Mon Aug 18 18:15:41 BST 2003: u(1) =	1.0 - 2.0*(t>5.0) + 2.0*(t>15.0);; # t1s input torque
## Removed by MTT on Mon Aug 18 18:15:41 BST 2003: u(2) =	1.0 - 2.0*(t>5.0) + (t>15.0); # t2s input torque
itwolink__t1s	=	1.0 - 2.0*(t>5.0) + 2.0*(t>15.0); # t1s input torque
itwolink__t2s	=	1.0 - 2.0*(t>5.0) + (t>15.0); # t2s input torque

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_lbl.txt version [d83014c071].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY iTwoLink: Inverse of two-link manipulator
%DESCRIPTION Uses the specification system idea to get an ordinary
%DESCRIPTION differential equation inverse.
%% Label file for system iTwoLink (iTwoLink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/17 15:50:45  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ALIAS INTF	General/INTF

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type AF
	a1		lin	flow,1
	a2		lin	flow,1

% Component type SS
	t1		SS	external,0
	t2		SS	external,0
	t1s		SS	external,external
	t2s		SS	external,external

% Component type msd
	spec1
	spec2

% Component type onelink
	syst

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_numpar.txt version [8f4f09e883].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (iTwoLink_numpar.txt)
# Generated by MTT at Mon Nov 17 10:40:34 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
d_s = 	1.0; # Parameter d_s for msd
k_s = 	1.0; # Parameter k_s for msd
m_s = 	1.0; # Parameter m_s for msd
j_s = 	1.0; # Parameter j_s for twolink
l = 	1.0; # Parameter l for twolink
m_s = 	1.0; # Parameter m_s for twolink

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_rep.txt version [7215155dba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system iTwoLink (iTwoLink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 17:56:50  peterg
% %% To RCS
% %%
% %% Revision 1.1  1997/12/09 16:53:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt iTwoLink abg tex
mtt iTwoLink struc tex
mtt iTwoLink simp r
mtt iTwoLink dae tex
mtt iTwoLink ode tex
mtt iTwoLink sspar r
mtt iTwoLink sm tex
mtt iTwoLink tf tex

mtt iTwoLink numpar txt
mtt iTwoLink input txt
mtt iTwoLink odeso ps  'iTwoLink__t1'
mtt iTwoLink odeso ps  'iTwoLink__t2'
mtt iTwoLink odeso ps  'iTwoLink__t1s'
mtt iTwoLink odeso ps  'iTwoLink__t1s:iTwoLink__t1'
mtt iTwoLink odeso ps  'iTwoLink__t2s:iTwoLink__t2'






Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_simp.r version [654a42ab54].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system twolink (twolink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/iTwoLink_sspar.r version [d89c4eea57].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for ionelink (ionelink_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mttx1 := 0;
mttx2 := 0;
mttx3 := 0;
mttx4 := 0;
mttx5 := 0;
mttx6 := 0;

END;

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/itwolink_rep.txt version [e6822537da].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system itwolink (itwolink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -c itwolink abg tex
mtt -c itwolink struc tex
mtt -c itwolink simp r
mtt -c itwolink dae tex
mtt -c itwolink cse tex
mtt -c itwolink ode tex
mtt -c itwolink sspar r
mtt -c itwolink dm tex
mtt -c itwolink sm tex
mtt -c itwolink tf tex
mtt -c itwolink lmfr ps

mtt -c itwolink odes h
mtt -c itwolink numpar txt
mtt -c itwolink input txt
mtt -c itwolink odeso ps  'itwolink_t1'
mtt -c itwolink odeso ps  'itwolink_t2'
mtt -c itwolink odeso ps  'itwolink_t1s'
mtt -c itwolink odeso ps  'itwolink_t1s:itwolink_t1'
mtt -c itwolink odeso ps  'itwolink_t1s:itwolink_t2'
mtt -c itwolink rep txt





Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/msd_abg.fig version [97c8be2457].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 4050 4950 4050 4725 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3825 3600 2700 3825 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4275 3600 5400 3825 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2250 4050 3375 4050 3150 4275
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 6975 6750 1125 900 1125 900 6975 6750 6975
4 1 -1 0 0 0 20 0.0000000 4 210 150 3600 4185 1\001
4 0 -1 0 0 0 20 0.0000000 4 270 1200 5085 4140 R:damper\001
4 1 1 1 0 0 20 0.0000000 4 270 3585 3555 6300 Mass-spring-damper system\001
4 2 4 0 0 0 20 0.0000000 4 240 870 2160 4140 SS:[in]\001
4 1 -1 0 0 0 20 0.0000000 4 210 990 3600 5715 I:inertia\001
4 1 -1 0 0 0 20 0.0000000 4 270 1050 3555 2610 C:spring\001

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/msd_desc.tex version [47aeb1c32d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system msd (msd_desc.tex)
% Generated by MTT on Thu Nov 13 09:38:17 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{msd} is
   displayed in Figure \Ref{msd_abg} and its label
   file is listed in Section \Ref{sec:msd_lbl}.
   The subsystems are listed in Section \Ref{sec:msd_sub}.


 \textbf{msd} is a simple Mass-Spring-Damper system with collocated
 force and velocity. It is set up to provide a specification system
 for each link of the two-link maipulator. This is appropriate because
 \begin{itemize}
 \item  it has compatible physical behaviour with the system itself,
 \item it specifies two decoupled systems,
 \item it has linear behaviour and
 \item it has a simple performance interpretation in terms of system
   rise-time and overshoot.
 \end{itemize}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/msd_lbl.txt version [4ba1d7187e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY msd: Simple mass-spring damper
%DESCRIPTION <Detailed description here>
%% Label file for system msd (msd_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type C
	spring		lin	state,k_s

% Component type I
	inertia		lin	flow,m_s

% Component type R
	damper		lin	flow,d_s

% Component type SS
	[in]		SS	external,external

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/oldROD_abg.fig version [81af279f2a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123



























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 4278 5403 4953 5178 4953
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5854 5404 6529 6079 6304 6079
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 6078 5403 5403 5403 5628
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 4953 6528 4278 6528 4503
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 1
	 4277 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 2702 4277 3827 4052 3827
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 6527 8102 7652 7877 7652
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 7652 4277 6527 4277 6752
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3827 8102 2702 8102 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5852 5177 6527 5177 6392 5312
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 2927 2927 4952 3152 4727
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5402 2927 7427 3152 7202
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2701 5176 2026 5176 2161 5311
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 1351 2926 2476 3196 2206
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 7876 2926 9001 3196 8731
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 2928 8328 4953 8553 4728
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8328 5403 8328 7428 8553 7203
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 1352 8327 2477 8597 2207
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8327 7877 8327 9002 8597 8732
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 1351 5626 4951 5851 4726
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5626 5401 5626 9001 5851 8776
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8551 5176 9226 5176 9091 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 4951 6526 4051 6436 4231
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3826 4996 3826 5356
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 5176 3826 5176 3961 5311
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3826 5401 6301 6301 6121 6301
2 1 0 1 5 -1 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 5401 4051 6301 3826 6301
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 4951 4051 4051 4051 4276
2 1 0 1 5 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5536 5176 5086 5176 5221 5311
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6300 9675 6300 675 4950 675 4950 9675 6300 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 9000 9675 9000 675 7650 675 7650 9675 9000 9675
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11025 10305 11025 225 225 225 225 10305 11025 10305
2 4 0 1 1 7 0 0 -1 0.000 0 0 7 0 0 5
	 3600 9675 2250 9675 2250 675 3600 675 3600 9675
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 2250 990 2250 990 900 10125 900 10125 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 5850 990 5850 990 4500 10125 4500 10125 5850
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 10125 9450 990 9450 990 8100 10125 8100 10125 9450
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2700 4950 2700 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5850 4950 5850 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8550 4950 8550 5400
4 1 -1 0 0 0 20 0.0000000 4 210 150 5628 5268 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 315 6933 5268 I:J\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 5312 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2972 2792 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2927 7742 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 5313 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8373 2793 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8328 7743 0\001
4 1 -1 0 0 0 20 0.0000000 4 270 735 9676 5266 I:m_y\001
4 1 -1 0 0 0 20 0.0000000 4 240 735 1531 5221 I:m_x\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4636 4141 EMTF:c1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1170 4681 6391 EMTF:c2\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 4141 EMTF:s1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1155 7156 6391 EMTF:s2\001
4 1 5 0 0 0 20 0.0000000 4 210 150 3603 5313 0\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 4456 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 3781 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 6751 6076 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 6751 6706 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 570 6211 6526 [mod]\001
4 1 5 0 0 0 20 0.0000000 4 210 990 4681 5266 INTF:th\001
4 1 1 1 0 0 20 0.0000000 4 210 210 2925 10035 X\001
4 1 1 1 0 32 20 0.0000000 4 135 195 5580 9990 a\001
4 1 1 1 0 0 20 0.0000000 4 210 210 8280 9990 Y\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 4140 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 6345 4095 [mod]\001
4 2 26 0 0 0 16 0.0000000 4 195 570 3960 6210 [mod]\001
4 1 26 0 0 0 16 0.0000000 4 195 330 4590 4455 [in]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4545 3780 [out]\001
4 1 26 0 0 0 16 0.0000000 4 195 450 4590 6660 [out]\001
4 0 26 0 0 0 16 0.0000000 4 195 330 4365 6030 [in]\001
4 1 4 0 0 0 20 0.0000000 4 240 1065 2971 1216 SS:[x_a]\001
4 1 4 0 0 0 20 0.0000000 4 240 1080 2971 9361 SS:[x_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1065 8372 1217 SS:[y_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1080 8417 9362 SS:[y_b]\001
4 1 4 0 0 0 20 0.0000000 4 270 1575 5671 1216 SS:[alpha_a]\001
4 1 4 0 0 0 20 0.0000000 4 270 1590 5671 9361 SS:[alpha_b]\001
4 1 1 1 0 0 20 0.0000000 4 270 630 1350 2700 Tip a\001
4 1 1 1 0 0 20 0.0000000 4 240 1470 1260 6300 Mass centre\001
4 1 1 1 0 0 20 0.0000000 4 270 645 1350 9855 Tip b\001

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/oldROD_desc.tex version [995adfaa28].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system oldROD (oldROD_desc.tex)
% Generated by MTT on Fri Aug 15 09:53:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  09:41:19  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{oldROD} is
   displayed in Figure \Ref{oldROD_abg} and its label
   file is listed in Section \Ref{sec:oldROD_lbl}.
   The subsystems are listed in Section \Ref{sec:oldROD_sub}.

{\bf oldROD} is essentially as described in Figure 10.2 of
``Metamodelling''.

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/oldROD_lbl.txt version [0ac94f22b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY	oldROD: rigid rod in two dimensions
%DESCRIPTION	Port [alpha_a]:	Angular torque/velocity - end a
%DESCRIPTION	Port [alpha_b]:	Angular torque/velocity - end b
%DESCRIPTION	Port [x_a]:	x force/velocity - end a
%DESCRIPTION	Port [x_b]:	x force/velocity - end b
%DESCRIPTION	Port [y_a]:	y force/velocity - end a
%DESCRIPTION	Port [y_b]:	y force/velocity - end b
%DESCRIPTION
%DESCRIPTION	Parameter 1:	length from end 1 to mass centre
%DESCRIPTION	Parameter 2:	length from end 2 to mass centre
%DESCRIPTION	Parameter 3:	inertia about mass centre
%DESCRIPTION	Parameter 4:	mass
%DESCRIPTION	See Section 10.2 of "Metamodelling"


%% Label file for system oldROD (oldROD_lbl.txt)



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:43:06  peterg
% %% Now has lablelled (as opposed to numbered) ports.
% %%
% Revision 1.1  1996/11/07  10:57:17  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Inertias
J	lin	flow,$3
m_x	lin	flow,$4
m_y	lin	flow,$4

%Integrate angular velocity to get angle
th

%Modulated transformers
s1	lsin	flow,$1
s2	lsin	flow,$2
c1	lcos	flow,$1
c2	lcos	flow,$2


	

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/twolink_abg.fig version [4bb685d60b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 5625 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 2025 2250 4725 2250 4725 2700 4950 2475
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001
4 2 4 0 0 0 20 0.0000 4 255 1380 1936 2341 SS:[joint_1]\001
4 2 4 0 0 0 20 0.0000 4 255 1380 1936 5716 SS:[joint_2]\001
4 1 -1 0 0 0 20 0.0000 4 255 810 5808 948 SS:v_y\001

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/twolink_desc.tex version [40badf236c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system twolink (twolink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{twolink} is
   displayed in Figure \Ref{twolink_abg} and its label
   file is listed in Section \Ref{sec:twolink_lbl}.
   The subsystems are listed in Section \Ref{sec:twolink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses two compound components: {\bf ROD} and {\bf
GRAV}.  {\bf ROD} is essentially as described in Figure 10.2 {\bf
GRAV} represents gravity by a vertical accelleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Inverse/iTwoLink/twolink_lbl.txt version [d7401fba34].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY twolink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (twolink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j_s;m_s
rod2	none	l;l;j_s;m_s

%Zero velocity sources
v_x	 SS     internal,0
v_y	 SS	internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal


%Torque at joints
%f_a1	SS external,external
%f_a2	SS external,external

%Gravity
%g

Deleted mttroot/mtt/lib/examples/Makefile version [96c3362987].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/make -f

# DESTDIR prefix required by Debian build process
INSTDIR=$(DESTDIR)/usr/share/mtt/lib/examples

configure: configure-stamp
configure-stamp:
	@touch configure-stamp

build: configure build-stamp
build-stamp:
	@touch build-stamp

clean:
	@touch clean.sh
	@-chmod a+x clean.sh
	@./clean.sh
	@rm -f clean.sh

distclean: clean

install: build clean.sh
	@install -d $(INSTDIR)
	@cp -a $(filter-out CVS Makefile debian, $(wildcard *)) $(INSTDIR)

.PHONY: FORCE

clean.sh: FORCE
	@echo '#! /bin/sh'					>>clean.sh
	@echo '# This file is auto-generated - do not edit'	>>clean.sh
	@echo "rm -f  $(INSTDIR)/examples"			>>clean.sh

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_abg.fig version [fc9a7335dd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1125 2700 2250 2700 2025 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2745 2700 3870 2700 3645 2925
4 1 0 100 0 18 20 1.5708 4 225 675 1035 2700 Free\001
4 1 0 100 0 18 20 1.5708 4 300 3405 2610 2700 BernoulliEuler:Lump*20\001
4 1 0 100 0 18 20 1.5708 4 225 795 4230 2700 Fixed\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_desc.tex version [b37e0425c2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system CantileverBeam (CantileverBeam_desc.tex)
% Generated by MTT on Mon Apr 19 07:04:54 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/05/18 04:01:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{CantileverBeam} is displayed in
Figure \Ref{fig:CantileverBeam_abg.ps} and its label file is listed in
Section \Ref{sec:CantileverBeam_lbl}.  The subsystems are listed in Section
\Ref{sec:CantileverBeam_sub}.
   
This example represents the dynamics of a uniform beam with one fixed
and one free end.  The beam is approximated by 20 equal lumps using
the Bernoulli-Euler approximation with damping. 
The input is the angular velocity of the fixed end, the output is the
linear velocity of the free end.

The system parameters are given in Section
\Ref{sec:CantileverBeam_numpar.tex}. Note that the numer of ban
segments has been set to 21. 

 The system has 20 states (10
modes of vibration), 1 inputs and 1 outputs.

The first 5 vibration frequencies are given in Table \ref{tab:freq}
togtherr with the theoretical (based on the Bernoulli-Euler beam with
the same values of $EI$ and $\rho A$. 
\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{||l|l|l||}
      \hline
      \hline
      Mode & Frequency & Theoretical frequency\\
      \hline
      1 &  76.14 &  76.14\\
      2 & 477.11 & 484.50\\
      3 &1330.62 &1334.55\\
      4 &2586.77 &2617.19\\
      5 &4225.14 &4323.77\\
       \hline
      \hline
    \end{tabular}
    \caption{Mode frequencies (rad $s^{-1}$)}
    \label{tab:freq}
  \end{center}
\end{table}





Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_input.txt version [0c2d8a210e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (CantileverBeam_input.txt)
# Generated by MTT at Thu Apr 22 00:12:54 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2003/05/08 18:48:49  gawthrop
## Modified for new format with __
##
## Revision 1.1  2000/12/28 17:58:27  peterg
## To RCS
##
###############################################################

# Set the inputs
## Removed by MTT on Thu May  8 16:55:10 BST 2003: mttu(1) = exp(-t/0.1); 	# tau (CantileverBeam)
cantileverbeam__mttfixed__u__u	= exp(-t/0.1); 	# tau (CantileverBeam)

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_lbl.txt version [948cc2e88c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system CantileverBeam (CantileverBeam_lbl.txt)
%SUMMARY CantileverBeam
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR n
%VAR BeamLength
%VAR BeamWidth
%VAR BeamThickness
%VAR Youngs
%VAR Density
%VAR Area
%VAR AreaMoment
%VAR EI
%VAR rhoA
%VAR k

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type BernoulliEuler
	Lump

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_numpar.txt version [c6d8e94627].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (CantileverBeam_numpar.txt)
# Generated by MTT at Mon Apr 19 06:24:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 17:58:27  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
N = 21;
BeamLength = 0.58;
BeamWidth = 0.05;
BeamThickness = 0.005;
Youngs = 68.94e9;
Density =  2712.8;
Area = BeamWidth*BeamThickness;
AreaMoment = (BeamWidth*pow(BeamThickness,3))/12;

EI = Youngs*AreaMoment;
rhoA = Density*Area;

dz = BeamLength/N;		# Incremental length
dm = rhoA*dz;			# Incremental mass
dk = EI/dz;			# Incremental stiffness
dr = 0;				# Damping

K = sqrt(EI/rhoA)/pow(BeamLength,2);	# Normalising factor


# EI= 58.6957			# from Reza
# rhoA= 0.7989			# from Reza
 







Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_rep.txt version [f61fd41422].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system CantileverBeam (CantileverBeam_rep.txt)
## Generated by MTT on" Mon Apr 19 06:43:08 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt CantileverBeam abg tex			# The system description
## mtt CantileverBeam cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt CantileverBeam struc tex	        # The system structure
## mtt CantileverBeam dae tex	        # The system dae
## mtt CantileverBeam ode tex	        # The system ode 
## mtt CantileverBeam sspar tex		# Steady-state parameters
## mtt CantileverBeam ss tex 		# Steady state
## mtt CantileverBeam dm tex		# Descriptor matrices (of linearised system)
## mtt CantileverBeam sm tex		# State matrices (of linearised system)
## mtt CantileverBeam tf tex		# Transfer function (of linearised system)
mtt CantileverBeam simpar tex		# Simulation parameters
mtt CantileverBeam numpar tex		# Numerical simulation parameters
## mtt CantileverBeam input tex		# Simulation input
## mtt CantileverBeam odeso ps		# Simulation output
mtt CantileverBeam lmfr ps		# log modulus of frequency response (of linearised system)

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/CantileverBeam_simpar.txt version [bbb93af30e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system CantileverBeam (CantileverBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.001;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 200;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Fixed_abg.fig version [e0ba4ffe54].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 0 0 100 0 18 20 0.0000 4 225 1065 5625 1890 Sf:zero\001
4 0 0 100 0 18 20 0.0000 4 225 585 5625 2790 Sf:u\001
4 2 4 100 0 18 20 0.0000 4 300 1230 4140 1890 SS:[y_in]\001
4 2 4 100 0 18 20 0.0000 4 300 1785 4140 2790 SS:[theta_in]\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Fixed_lbl.txt version [8de3fd38c9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Fixed (Fixed_lbl.txt)
%SUMMARY Fixed
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	y_in,theta_in

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_in]	SS		external,external
	[y_in]		SS		external,external

% Component type Sf
	u		SS		external
	zero		SS		0

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Free_abg.fig version [6e75a503c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 1800 5400 1800 5175 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4230 2700 5355 2700 5130 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5400 2475 5400 2925
4 2 0 100 0 18 20 0.0000 4 300 585 4140 1890 Df:y\001
4 2 0 100 0 18 20 0.0000 4 225 1125 4140 2790 Se:zero\001
4 0 4 100 0 18 20 0.0000 4 300 1440 5490 1890 SS:[y_out]\001
4 0 4 100 0 18 20 0.0000 4 300 1995 5445 2790 SS:[theta_out]\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/Free_lbl.txt version [623dab72b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Free (Free_lbl.txt)
%SUMMARY Free
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	y_out,theta_out

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Df
	y	SS	external

% Component type SS
	[theta_out]	SS		external,external
	[y_out]		SS		external,external

% Component type Se
	zero		SS		0


Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/CantileverBeam/frequencies.m version [2bba72298d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [w_r,w_a,n_null] = frequencies (A,B,C,D)

  ## usage:  [w_r,w_a] = frequencies (A,B,C,D)
  ##
  ## Resonant and antiresonant frequencies for undampled beam

  poles = eig(A);
  Np = length(poles);
  zeros = tzero(A,B,C,D);
  Nz = length(zeros);
  w_r = sort(imag(poles)); w_r = w_r(Np/2+1:Np);
  w_a = sort(imag(zeros)); w_a = nozeros(w_a(Nz/2+1:Nz))';
  n_null = (Nz/2-length(w_a))*2;
endfunction

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/Fixed_lbl.txt version [8de3fd38c9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Fixed (Fixed_lbl.txt)
%SUMMARY Fixed
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	y_in,theta_in

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[theta_in]	SS		external,external
	[y_in]		SS		external,external

% Component type Sf
	u		SS		external
	zero		SS		0

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/Free_lbl.txt version [623dab72b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Free (Free_lbl.txt)
%SUMMARY Free
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	y_out,theta_out

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Df
	y	SS	external

% Component type SS
	[theta_out]	SS		external,external
	[y_out]		SS		external,external

% Component type Se
	zero		SS		0


Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/MakeFreqTable.m version [71cecf4031].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# ## Makes the table of resonant frequencies

# ## Actual resonant freqs
# fr_measured = [
# 	2.0683e+01
# 	7.5310e+01
# 	1.7080e+02
# 	3.0532e+02
# 	4.7414e+02];

# fa_measured = [
# 	 2.0896e+01
# 	 7.6867e+01
# 	 1.7794e+02
# 	 3.1890e+02
# 	 4.8768e+02];

## Parameters - ideal pinned beam
PinnedBeam_numpar;

## Ideal pinned beam - theory
[fr_theory] = beam_frequencies("pinned",ei,rhoa,beamlength)/(2*pi);
[fa_theory] = beam_frequencies("clamped-pinned",ei,rhoa,beamlength)/(2*pi);

## SM form to get poles and zeros of the model
# ## Ideal pinned
# [A,B,C,D] = PinnedBeam_sm;
# fr_model_ideal  = frequencies(A,B,C,D)/(2*pi);

# ## Actual with non-ideal pins 
# PinnedBeam_numpar;

[A,B,C,D] = PinnedBeam_sm;

[w_r, w_a]  = frequencies(A,B,C,D);
fr_model = w_r/(2*pi);
fa_model = w_a/(2*pi);


printf("\nIndex \t& Theory   \t& Model \t& Theory  \t& Model \\\\ \n");
printf("\\hline\n");
for i = 1:5
  printf("%i \t& %3.2f \t& %3.2f \t& %3.2f  \t& %3.2f\\\\ \n", i, \
	 fr_theory(i), fr_model(i), fa_theory(i), fa_model(i));
endfor

# printf("\nMode \t& Theory   \t& Model(ideal) \t& Model  \t& Actual \\\\ \n");
# printf("\\hline\n");
# for i = 1:5
#   printf("%i \t& %3.2f \t& %3.2f \t& %3.2f  \t& %3.2f\\\\ \n", i, fr_theory(i), \
# 	 fr_model_ideal(i), fr_model(i), fr_measured(i));
# endfor
	 
# printf("\nMode  \t& Theory  \t& Model  \t& Actual \\\\ \n");
# printf("\\hline\n");
# for i = 1:5
#   printf("%i \t& %3.2f \t& %3.2f \t& %3.2f \\\\ \n", i, fa_theory(i), fa_model(i), fa_measured(i));
# endfor
	





Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_abg.fig version [624a6ece3a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2925 1980 3015 2520
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2970 2025 2970 2475
-6
6 4005 2880 4095 3420
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 2925 4050 3375
-6
6 8955 1980 9045 2520
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 9000 2025 9000 2475
-6
6 7830 2880 7920 3420
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 7875 2925 7875 3375
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4770 2700 5895 2700 5670 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6300 2700 7425 2700 7200 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2970 2250 4095 2250 3870 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 3150 4050 3150 3825 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 2250 9000 2250 8775 2475
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 7875 3150 9000 3150 8775 3375
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 1125 225 1125 5400 10800 5400 10800 225 1125 225
4 1 0 100 0 18 20 1.5708 4 360 3855 4635 2700 BernoulliEuler:LumpL\001
4 1 0 100 0 18 20 1.5708 4 360 4170 6165 2700 BernoulliEuler:Lump*18\001
4 1 0 100 0 18 20 1.5708 4 360 3885 7740 2700 BernoulliEuler:LumpR\001
4 2 4 100 0 18 14 0.0000 4 210 585 3915 2070 [y_in]\001
4 2 4 100 0 18 14 0.0000 4 210 990 3915 2970 [theta_in]\001
4 0 4 100 0 18 14 0.0000 4 210 735 7965 1980 [y_out]\001
4 0 4 100 0 18 14 0.0000 4 210 1140 7965 2970 [theta_out]\001
4 2 0 100 0 18 20 0.0000 4 285 1230 2835 3285 SS:ssL\001
4 0 0 100 0 18 20 0.0000 4 285 1515 9135 2385 Sf:zeroR\001
4 0 0 100 0 18 20 0.0000 4 285 1260 9135 3285 SS:ssR\001
4 2 0 100 0 18 20 0.0000 4 285 1485 2835 2385 Sf:zeroL\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_desc.tex version [81085b5b72].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101





































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system PinnedBeam (PinnedBeam_desc.tex)
% Generated by MTT on Mon Apr 19 07:04:54 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/11/24 22:17:26  peterg
% %% Updated to correspond to Reza's beam
% %%
% %% Revision 1.1  1999/10/11 05:08:14  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/05/18 04:01:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The acausal bond graph of system \textbf{PinnedBeam} is displayed in
Figure \Ref{fig:PinnedBeam_abg.ps} and its label file is listed in
Section \Ref{sec:PinnedBeam_lbl}.  The subsystems are listed in Section
\Ref{sec:PinnedBeam_sub}.
   
This example represents the dynamics of a uniform beam with two pinned
ends. The left-hand end is driven by a torque input and the
corresponding collocated angular velocity is measured.  The beam is
approximated by 20 equal lumps using the Bernoulli-Euler.  Because the
two end lumps have different causality to the rest of the beam lumps,
they are represented seperately.  The system has 40 states (20 modes
of vibration), 1 input and 1 output.

\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{|l|l|}
      \hline
      Name & Value\\
      \hline
      Beam Length, $L$       & 0.60 m\\
      Beam Width $w$             & 0.05 m\\
      Beam Thickness $t_b$   & 0.003\\
      Young's Modulus  $E$       & $68.94 \times 10^9$ \\
      Density          $\rho$    & 2712.8\\
      \hline
      Derived quantities & \\
      \hline
      $EI$                     & 7.76\\
      $\rho A$   & 0.40692 \\
      \hline
    \end{tabular}
    \caption{Beam parameters}
    \label{tab:beam}
  \end{center}
\end{table}


The beam was made of aluminium with physical dimensions and constants
given in Table \ref{tab:beam}. The derived beam constants are given by the
formulae:
\begin{equation}
  \label{eq:formulae}
  \begin{align}
    EI &= E \times w \frac{1}{12} t_b^3\\
    \rho A &= \rho \times w t_b
  \end{align}
\end{equation}

The system parameters are also given in Section
\Ref{sec:PinnedBeam_numpar.tex}.


\begin{table}[htbp]
  \begin{center}
    \begin{tabular}{||l|l|l|l|l||}
      \hline
      \hline
Index   & $f_r$ (theory) & $f_r$ (model)& $f_a$ (theory) & $f_a$ (model) \\ 
\hline
1       & 19.05         & 19.01         & 29.72         & 31.28\\ 
2       & 76.24         & 75.57         & 96.50         & 100.80\\ 
3       & 171.58        & 168.29        & 200.73        & 208.20\\ 
4       & 304.76        & 294.89        & 344.13        & 350.88\\ 
5       & 476.34        & 452.25        & 524.98        & 525.23\\ 
      \hline
      \hline
    \end{tabular}
    \caption{Resonant and anti-resonant frequencies (Hz)}
    \label{tab:freq}
  \end{center}
\end{table}

Standard modal analysis give the theoretical system resonant
frequencies $f_r$ (based on the Bernoulli-Euler beam with the same values of
$EI$ and $\rho A$). The system anti-resonances $f_a$ correspond to those of
the \emph{inverse} system with reversed causality, that the driven
pinned end is replaced by a clamped end; again modal analysis of the
inverse system gives the system anti resonances. The model and
theoretical values are compared in Table \ref{tab:freq} for the first
5 modes. (This table was generated using the script MakeFreqTable.m)

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_input.txt version [5d573c78a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (PinnedBeam_input.txt)
# Generated by MTT at Thu Apr 22 00:12:54 BST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 17:59:05  peterg
## To RCS
##
###############################################################

# Set the inputs
pinnedbeam__mttfixed__u__u = exp(-t/0.1); 	# tau (PinnedBeam)

# Set the switches

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_lbl.txt version [a9ffe495c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system PinnedBeam (PinnedBeam_lbl.txt)
%SUMMARY PinnedBeam
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/08/01 12:11:57  peterg
% %% Added %Vars
% %%
% %% Revision 1.1  1999/10/11 05:08:22  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%VAR Lumps
%VAR BeamLength
%VAR BeamWidth
%VAR BeamThickness
%VAR Youngs
%VAR Density
%VAR Area
%VAR AreaMoment
%VAR EI
%VAR rhoA

% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type BernoulliEuler
	Lump
	LumpL
	LumpR

% Component type SS
	ssL	SS		external,external
	ssR	SS		0,internal

% Component type Sf
	zeroL	 none		0
	zeroR	 none		0


Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_numpar.txt version [ff4455d3d9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (pPinnedBeam_numpar.txt)
# Generated by MTT at Mon Apr 19 06:24:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2003/06/11 16:03:06  gawthrop
# %% Updated examples for latest MTT.
# %%
# %% Revision 1.1  2000/12/28 17:59:05  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Number of lumps
Lumps = 20;			# Number of lumps

## Beam physical parameters
BeamLength = 0.60;
BeamWidth  = 0.05;
BeamThickness = 0.003;
Youngs = 68.94e9;
Density =  2712.8;
Area = BeamWidth*BeamThickness;
AreaMoment = (BeamWidth*pow(BeamThickness,3))/12;
EI = Youngs*AreaMoment;
rhoA = Density*Area;

## Segments
dz = BeamLength/Lumps;	        # Incremental length
dm = rhoA*dz;			# Incremental mass
dk = EI/dz;			# Incremental stiffness
dr = 0;				# Damping

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_rep.txt version [b3b35e35ca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system PinnedBeam (PinnedBeam_rep.txt)
## Generated by MTT on" Mon Apr 19 06:43:08 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt PinnedBeam abg tex			# The system description
## mtt PinnedBeam cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt PinnedBeam struc tex	        # The system structure
## mtt PinnedBeam dae tex	        # The system dae
## mtt PinnedBeam ode tex	        # The system ode 
## mtt PinnedBeam sspar tex		# Steady-state parameters
## mtt PinnedBeam ss tex 		# Steady state
## mtt PinnedBeam dm tex		# Descriptor matrices (of linearised system)
## mtt PinnedBeam sm tex		# State matrices (of linearised system)
## mtt PinnedBeam tf tex		# Transfer function (of linearised system)
mtt PinnedBeam simpar tex		# Simulation parameters
mtt PinnedBeam numpar tex		# Numerical simulation parameters
## mtt PinnedBeam input tex		# Simulation input
## mtt PinnedBeam odeso ps		# Simulation output
mtt PinnedBeam lmfr ps		# log modulus of frequency response (of linearised system)

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/Beams/PinnedBeam/PinnedBeam_simpar.txt version [3f7404ca28].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system PinnedBeam (PinnedBeam_simpar.txt)
# Generated by MTT on Mon Apr 19 06:32:42 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 1.0;       # Last time in simulation
DT          = 0.01;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 4;          # Maximum frequency = 10^WMAX
WSTEPS      = 200;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_abg.fig version [7358b66296].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132




































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Inches
1200 2
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2706 4806 3606 4806 3456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2406 5106 2406 6006 2556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3906 5106 3906 6006 4056 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4808 8108 4808 7958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 4808 9608 4808 9458 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8408 5108 8408 6008 8558 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7208 4508 8108 3608 8108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8708 3608 9608 4508 9383 4508
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9909 5109 9909 6009 10059 5859
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6908 5108 6908 6008 7058 5858
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 8405 2405 8405 3305 8555 3155
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11407 5107 11407 6007 11557 5857
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11406 3306 11406 2406 11556 2556
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4806 5106 4806 4956 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5406 5106 5406 6006 5556 5856
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4206 4506 5106 3606 5106 3831
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5405 3305 5405 2405 5555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2405 3305 2405 2405 2555 2555
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 4807 12607 4807 12457 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11707 3607 12607 4507 12382 4507
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2105 1805 2105 905 2255 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2705 1805 2705 905 2855 1055
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 4806 6606 4806 6456 4956
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5706 3606 6606 4506 6381 4506
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2704 3604 3604 4504 3379 4504
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4808 2108 4808 1958 4958
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1208 4508 2108 3608 2108 3833
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 681 3606 1131 3606
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 906 4506 906 3606 1056 3756
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12905 4505 12905 3605 13055 3755
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4807 11107 4807 10957 4957
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10207 4507 11107 3607 11107 3832
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8400 3300 8625 3300
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12900 3600 13125 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12675 3600 12900 3600
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8175 3300 8400 3300
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 1501 5401 301 5401 301 3001 1501 3001 1501 5401
2 2 1 2 1 7 1 0 -1 6.000 1 0 0 0 0 5
	 1502 452 3302 452 3302 3377 1502 3377 1502 452
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 4501 6601 3301 6601 3301 3901 4501 3901 4501 6601
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 6000 6600 4800 6600 4800 1800 6000 1800 6000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 7501 6601 6301 6601 6301 3901 7501 3901 7501 6601
2 4 1 2 1 7 2 0 -1 6.000 0 0 7 0 0 5
	 9000 6600 7800 6600 7800 1800 9000 1800 9000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 10501 6601 9301 6601 9301 3901 10501 3901 10501 6601
2 4 1 2 1 -1 1 0 -1 6.000 0 0 7 0 0 5
	 12000 6600 10800 6600 10800 1800 12000 1800 12000 6600
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 13501 5401 12301 5401 12301 3001 13501 3001 13501 5401
4 1 -1 0 0 0 20 0.0000000 4 210 150 2406 4881 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 3906 6381 I:m1\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 2405 6380 R:b1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2405 3680 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 3906 4881 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8408 4883 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 8408 3683 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 8483 6383 R:b3\001
4 1 -1 0 0 0 20 0.0000000 4 210 675 8407 2182 SS:f2\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 9906 6381 I:m3\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 6905 6380 I:m2\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 11407 4882 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 11407 3682 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 525 11406 2181 C:kt\001
4 1 -1 0 0 0 20 0.0000000 4 210 525 11482 6382 R:bt\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5406 4881 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5406 3681 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 5481 6381 R:b2\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 12909 4884 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 6908 4883 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 2404 2179 1\001
4 1 -1 0 0 0 20 0.0000000 4 270 585 2779 754 C:p1\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 2104 754 R:d1\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 910 4885 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 675 902 3377 SS:fb\001
4 1 -1 0 0 0 20 0.0000000 4 210 615 12905 3380 SS:ft\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 9909 4884 1\001
4 1 -1 0 0 0 20 0.0000000 4 210 585 5405 2180 C:k2\001
4 1 1 1 0 3 20 0.0000000 4 240 1530 3901 6901 Macro mass\001
4 1 1 1 0 3 20 0.0000000 4 240 1800 2401 376 Macro control\001
4 1 1 1 0 3 20 0.0000000 4 240 1455 900 5700 Macro base\001
4 1 1 1 0 3 20 0.0000000 4 270 1890 5400 1650 Compliant link\001
4 1 1 1 0 3 20 0.0000000 4 240 1470 6901 6901 Micro mass\001
4 1 1 1 0 3 20 0.0000000 4 240 1890 8475 1650 Micro actuator\001
4 1 1 1 0 3 20 0.0000000 4 270 1125 9901 6901 Tip mass\001
4 1 1 1 0 3 20 0.0000000 4 270 2985 11400 1650 Compliant environment\001
4 1 1 1 0 3 20 0.0000000 4 270 1305 12901 5701 Tip sensor\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_desc.tex version [3e936ec3d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system MacroMicro (MacroMicro_desc.tex)
% Generated by MTT on Tue Dec 9 17:55:41 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{MacroMicro} is
   displayed in Figure \Ref{MacroMicro_abg} and its label
   file is listed in Section \Ref{sec:MacroMicro_lbl}.
   The subsystems are listed in Section \Ref{sec:MacroMicro_sub}.

This is a Bond Graph model of the macro-micro manipulation system
discussed by Sharon in his thesis and BY Sharon, Hogan and Hardt in
various papers.

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_lbl.txt version [eda41e1822].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file (macmic_lbl.txt)
%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Masses
m1	lin	flow,m_1
m2	lin	flow,m_2
m3	lin	flow,m_3

%Springs
k2	lin	state,k_2
kt	lin	state,k_t

%Dampers
b1	lin	flow,b_1
b2	lin	flow,b_2
b3	lin	flow,b_3
bt	lin	flow,b_t

%Source/sensors
f2	SS	external,internal
ft	SS	external,0
fb	SS	internal,0

%Control
p1	lin	flow,p_1
d1	lin	flow,d_1



Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_numpar.txt version [d5d101b825].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-

m_1 = 0.0169;		# m_1;
m_2 = 0.0169;		# m_2;
b_1 = 0.13;		# b_1;
b_2 = 0.013;		# b_2;
k_2 = 24;	        # k_2;
k_t = 150;		# k_t;
b_t = 0.16;		# b_t;
b_3 = 0.13;		# b_3;
m_3 = 0.005;		# m_3;
p_1 = 10;		# p_1;
d_1 = 0.9;		# d_1;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_rep.txt version [420def6255].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system MacroMicro (MacroMicro_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt MacroMicro abg tex
mtt MacroMicro cbg ps
mtt MacroMicro struc tex
mtt MacroMicro dae tex
mtt MacroMicro dm tex
mtt MacroMicro tf tex
mtt MacroMicro numpar txt
mtt MacroMicro lmfr ps 
mtt MacroMicro sro ps 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_simpar.txt version [479d1e287e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system MacroMicro (MacroMicro_simpar.txt)
# Generated by MTT on Thu Nov 9 15:19:17 GMT 2000.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


FIRST        = 0.0;       # First time in simulation output
DT          = 0.01;        # Print interval
LAST        = 1.0;       # Last time in simulation
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/MacroMicro/MacroMicro_state.txt version [7abde731cb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System MacroMicro, representation state, language txt; 
## File MacroMicro_state.txt; 
## Generated by MTT on Thu Nov  9 15:19:28 GMT 2000; 


MacroMicro_k2	= 0.0; # Default
MacroMicro_kt	= 0.0; # Default
MacroMicro_m1	= 0.0; # Default
MacroMicro_m2	= 0.0; # Default
MacroMicro_m3	= 0.0; # Default
MacroMicro_p1	= 0.0; # Default

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_abg.fig version [6195b18731].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
0 32 #969296
0 33 #e7e7cf
0 34 #9e9a9e
0 35 #cf9200
0 36 #f761ae
0 37 #7171ff
0 38 #595d59
1 3 0 3 1 7 55 0 -1 0.000 1 0.0000 1845 2430 186 186 1845 2430 2031 2430
2 2 0 1 1 7 55 0 47 0.000 0 0 -1 0 0 5
	 1800 2475 4500 2475 4500 2925 1800 2925 1800 2475
2 1 0 3 1 7 55 0 -1 0.000 0 0 -1 0 0 2
	 1830 2467 3180 129
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 5625 4725 5625 4500 5850
2 1 0 3 1 7 55 0 -1 0.000 0 0 -1 0 0 12
	 4453 2442 4177 1964 3884 2024 4282 1579 3700 1707 4103 1268
	 3521 1396 3914 946 3337 1077 3749 632 3445 696 3158 215
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2925 5625 1575 5625 1800 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 5400 3150 4050 3375 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 7200 3150 5850 3375 6075
4 1 1 55 0 32 30 0.0000 4 315 240 2385 2295 q\001
4 0 1 55 0 3 30 0.0000 4 300 270 2025 1260 L\001
4 0 1 55 0 3 30 0.0000 4 300 270 3105 3510 L\001
4 1 1 55 0 32 30 0.0000 4 225 195 1530 2250 t\001
4 1 0 100 0 18 18 0.0000 4 195 150 3150 5715 1\001
4 1 0 100 0 18 18 0.0000 4 210 390 3195 3915 R:r\001
4 1 4 100 0 18 18 0.0000 4 270 930 3060 7515 SS:[yu]\001
4 1 0 100 0 18 18 0.0000 4 270 240 1305 5715 I:j\001
4 0 0 100 0 18 18 0.0000 4 270 8610 4860 5715 C:k:mtt_e=k*(l^2)*cos(mtt_f/2)*2*(sin(mtt_f/2)-sin(alpha/2))+0*eta\001
4 0 1 101 0 3 20 0.0000 4 270 3255 4950 675 Rod (length L) hinged at left\001
4 0 1 101 0 3 20 0.0000 4 270 4275 4950 1125 Spring (stiffness k) unstretched when \001
4 0 1 101 0 32 20 0.0000 4 210 510 9225 1125 q=a\001
4 0 1 101 0 3 20 0.0000 4 270 3120 4950 1575 eta is the equilibrium angle\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_desc.tex version [84c725288d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system NonlinearMSD (NonlinearMSD_desc.tex)
% Generated by MTT on Thu Mar 7 14:48:47 GMT 2002.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 09:13:38  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This example illustrates the use of \textbf{MTT} to \emph{linaerise} a
nonlinear system -- a non-linear mass-spring-damper system called
\textbf{NonlinearMSD}. The model is considered in Section
\ref{sec:model} and linearisation in Section \Ref{sec:linearisation}.

Further work is suggested in Section \Ref{sec:further}.

\subsection{Bond Graph model}\label{sec:model}

The schematic diagram  of the system
\textbf{NonlinearMSD} is displayed in Figure
\ref{fig:NonlinearMSD_abg.ps}. The system comprises
\begin{itemize}
\item a rigid foundation,
\item a rod of length $L$ hinged at the left-hand end and
\item a linear spring of stiffness $k$ attached to the rigid
  foundation a distance $L$ from the hinge and to the free end of the rod.
\end{itemize}
The spring is unstretched when the rod makes an angle $\theta = \alpa
= \frac{pi}{3}$ with the foundation.

Using elementary geometry, the effectice angular spring generates a
torque $\tau$ given by (\ref{eq:spring})
\begin{equation}\label{eq:spring}
  \tau = -2kl^2 \cos{\frac{\theta}{2}} (\sin{\frac{\theta}{2}}-\sin{\frac{\alpha}{2}})
\end{equation}

The acausal bond graph of system \textbf{NonlinearMSD} is also
displayed in Figure \Ref{fig:NonlinearMSD_abg.ps}. This shows the
three bond graph components representing the friction \textbf{R}, the
inertia \textbf{I} and the spring \textbf{C} components. The
non-linear spring characteristic is given explicitly\footnote{The
  additional 0*eta term has no effect - it merely introduced the
  variable $\eta$ -- the equilibrium angle -- into the model}.

The (nonlinear) system ordinary differential equation is given by
\textbf{MTT} in Section \Ref{sec:NonlinearMSD_ode.tex}. This is a
special case of the general non-linear ordinary differential equation:
\begin{equation}
  \label{eq:non-state}
  \begin{cases}
    \dot{x} = f(x,u)\\
    y = g(x,u)
  \end{cases}
\end{equation}

\subsection{Linearisation}
\label{sec:linearisation}

The first step in linearisation is to determine a set of (constant)
states $x_e$ and (constant) inputs $u_e$ so that the system is in
equilibrium - that is
\begin{equation}
  \label{eq:eqilibrium}
 \dot{x} = f(x_e,u_e) = 0
\end{equation}

In this case, choosing an angle $\theta=\eta$ and an input:
\begin{equation}\label{eq:u_e}
  u_e = -\tau = 2kl^2 \cos{\frac{\eta}{2}} (\sin{\frac{\eta}{2}}-\sin{\frac{\alpha}{2}})
\end{equation}
together with zero velocity gives an equilibrium.

With this choice
The linearised system is given in terms of the $A$, $B$, $C$ and $D$
matrices appearing in the state equation:
\begin{equation}
  \label{eq:state}
  \begin{cases}
    \dot{x} = Ax + Bu\\
    y = Cx + Du
  \end{cases}
\end{equation}

\textbf{MTT} automatically generates these matrices -- see Section
\Ref{sec:NonlinearMSD_sm.tex}.

\subsection{Further work}
\label{sec:further}
\begin{enumerate}
\item Derive the system ordinary differential equation appearing in
  Section \Ref{sec:NonlinearMSD_ode.tex}.
\item Explain how the input of (\ref{eq:u_e}) gives equilibrium for
  all $\eta$.
\item Explain how the elements of the $A$, $B$, $C$ and $D$ appearing
  Section \Ref{sec:NonlinearMSD_sm.tex} arise from the ordinary
  differential equation of Section \Ref{sec:NonlinearMSD_ode.tex}
  together with the input of (\ref{eq:u_e}).
\item Setting up parameters, inputs and initial state as in Sections
  \Ref{sec:NonlinearMSD_numpar.tex}, \Ref{sec:NonlinearMSD_input.tex}
  and \Ref{sec:NonlinearMSD_state.tex}, perform simulations as in
  Section \Ref{sec:NonlinearMSD_state.tex} - the figure shows the
  angular \emph{velocity} $\dot{\theta}$.
\item Repeat the simulation with different perturbations by modifying
  the file ``NonlinearMSD\_input.tex'' (see Section
  \Ref{sec:NonlinearMSD_input.tex})
  \begin{enumerate}
  \item note that for smaller perturbations, the graphs are of similar
    shape (scaled by the perturbation input)
  \item note that for larger perturbations the graphs are quite
    different - this is a non-linear system.
  \end{enumerate}
\item \label{item:1} Repeat the simulation with different equilibrium angles $\eta$ by modifying
  the file ``NonlinearMSD\_numpar.tex'' (see Section
  \Ref{sec:NonlinearMSD_numpar.tex}) appropriately. Note that when
  $\eta=\pi$, the linearised system is \emph{unstable}.
\item The (2,1) element of the $A$ matrix in Section
  \Ref{sec:NonlinearMSD_sm.tex} is the \emph{linearised} stiffness
  $k_l$. Plot this against $\eta$ and explain the observation in item
  \ref{item:1}.
\end{enumerate}


Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_input.txt version [2e637411bf].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System NonlinearMSD, representation input, language txt; 
## File NonlinearMSD_input.txt; 
## Generated by MTT on Thu Mar  7 10:50:46 GMT 2002; 

## First term is the equilibrium input; last term is the perturbation input.

nonlinearmsd__yu = k*(pow(l,2))*cos(eta/2)*2*(sin(eta/2)-sin(alpha/2)) + 1e-2;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_numpar.txt version [da778d0db5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System NonlinearMSD, representation numpar, language txt; 
## File NonlinearMSD_numpar.txt; 
## Generated by MTT on Thu Mar  7 14:03:19 GMT 2002; 



alpha	= pi/3; # Angle for unstretched string
eta	= pi/3; #  Equilibrium angle
j	= 1.0; # Inertia
k	= 1.0; # Spring constant
l	= 1.0; # Rod length
r	= 1.0; # Rotational resistance

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_rep.txt version [b54172b254].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system NonlinearMSD (NonlinearMSD_rep.txt)
## Generated by MTT on" Thu Mar  7 14:44:37 GMT 2002.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 11:58:07  peterg
## Put under RCS
##
###############################################################

mtt NonlinearMSD abg tex			# The system description
mtt NonlinearMSD sympar tex	        # The system parameters
## Uncomment the following lines or add others
## mtt NonlinearMSD dae tex	        # The system dae
mtt NonlinearMSD ode tex	        # The system ode 
mtt NonlinearMSD sspar tex		# Steady-state parameters
mtt NonlinearMSD ss tex 		# Steady state
## mtt NonlinearMSD dm tex		# Descriptor matrices (of linearised system)
mtt NonlinearMSD sm tex		# State matrices (of linearised system)
## mtt NonlinearMSD tf tex		# Transfer function (of linearised system)
## mtt NonlinearMSD lmfr ps		# log modulus of frequency response (of linearised system)
## mtt NonlinearMSD simpar tex		# Simulation parameters
mtt NonlinearMSD numpar tex		# Numerical simulation parameters
mtt NonlinearMSD state tex		# Simulation initial state
mtt NonlinearMSD input tex		# Simulation input
## mtt NonlinearMSD logic tex		# Logic control
mtt NonlinearMSD odeso ps		# Simulation output

## mtt NonlinearMSD rep txt		# This file

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_sspar.r version [7911451fd5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (NonlinearMSD_sspar.r)
% Generated by MTT at Thu Mar  7 10:39:15 GMT 2002

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 09:32:04  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% This one corresponds to the unstretched spring at theta = pi/3 
%% Note that U is calculated to give equilibrium for all angles

alpha := pi/3;

% Steady-state states
MTTX1 := 	eta;     %Initial angle (corresponds to u=0)
MTTX2 := 	0;        %Initial anglular velocity
% Steady-state inputs
MTTU1 := 	k*(l^2)*cos(MTTX1/2)*2*(sin(MTTX1/2)-sin(alpha/2));
;;END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/NonlinearMSD_state.txt version [9a3645e5d6].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System NonlinearMSD, representation state, language txt; 
## File NonlinearMSD_state.txt; 
## Generated by MTT on Thu Mar  7 10:50:45 GMT 2002; 



## Removed by MTT on Tue Jun 10 16:51:50 BST 2003: NonlinearMSD_j	= 0.0;  % Initial angular momentum
## Removed by MTT on Tue Jun 10 16:51:50 BST 2003: NonlinearMSD_k	= eta; % Initial angle
nonlinearmsd__j	= 0.0; # Added by MTT on Tue Jun 10 16:51:52 BST 2003
nonlinearmsd__k	= eta;		# initial angle

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-1D/NonlinearMSD/plot_k.m version [7f6ea9ee11].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## Plots the effective spring constant.

p = NonlinearMSD_numpar;	# Numerical parameters
s = NonlinearMSD_sympar		# Symbolic parameters

Eta = eta=[0:0.01:1]*pi; K = [];
for eta=Eta
  p(s.eta) = eta;		# Change the eta parameter
  A = NonlinearMSD_sm(p);	# SS A matrix
  k = -A(2,1);
  K = [K k];
endfor

grid;
ylabel("k");
xlabel("eta");
plot(Eta,K);
figfig("k","eps");

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_abg.fig version [dd7eb4aed9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4050 2925 4050 1575 4275 1800
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 3150 5625 3150 5400 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4950 5625 4950 5400 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2475 3825 2475 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 3150 3825 3150 3600 3375
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 4950 2475 4950 2700 5175
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 2925 2870 1970 2870 2289
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4288 2957 5243 2002 5243 2320
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6525 3150 7875 3150 7650 3375
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9900 5850 225 5850 225 900 9900 900 9900 5850
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 4050 3825 4050 3600 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5625 4050 5400 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4275 3780 4275 4230
4 1 1 101 0 3 20 0.0000 4 270 1215 4140 3600 x-velocity\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 3240 1\001
4 1 4 100 0 18 20 0.0000 4 285 1425 1710 3240 SS:[drive]\001
4 1 1 101 0 3 20 0.0000 4 270 1200 4185 4500 y-velocity\001
4 1 1 101 0 3 20 0.0000 4 270 2055 4050 5490 angular-velocity\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 5040 1\001
4 1 4 100 0 18 20 0.0000 4 285 870 6165 5040 SS:[a]\001
4 2 0 100 0 18 20 0.0000 4 300 780 2430 5040 R:r_p\001
4 1 0 100 0 18 20 0.0000 4 285 765 2835 1845 R:r_c\001
4 1 4 100 0 18 20 0.0000 4 285 870 4050 1440 SS:[x]\001
4 1 0 100 0 18 20 0.0000 4 285 795 5355 1845 I:m_c\001
4 1 0 100 0 18 20 0.0000 4 225 660 6075 3240 INTF\001
4 0 0 100 0 18 20 0.0000 4 225 1665 8010 3240 De:Position\001
4 1 0 100 0 18 20 0.0000 4 210 165 4050 4140 1\001
4 1 4 100 0 18 20 0.0000 4 285 870 6165 4140 SS:[y]\001
4 2 0 100 0 18 20 0.0000 4 285 2310 2430 4140 Sf:zero_velocity\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_lbl.txt version [947eebb4f2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Cart (Cart_lbl.txt)
%SUMMARY Cart
%DESCRIPTION Simple cart model

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	drive
%ALIAS	pendulum|out	x,y,a
%UNITS  drive     translational N m/s
b%UNITS  x         translational N m/s
%UNITS  y         translational N m/s
%UNITS  a         rotational N*m radian/s


% Argument aliases
%ALIAS	$1	m_c

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type I
	m_c		lin	flow,m_c

% Component type R
	r_c		lin	flow,r_c
	r_p		lin	flow,r_p

% Component type SS
	[a]	SS		external,external
	[drive]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type De
	Position			SS	external

% Component type Sf
	zero_velocity		SS	0



Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_abg.fig version [95293b57ef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 4005 3870 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 3825 4050 3825 4500
-6
1 4 0 2 1 7 51 0 -1 0.000 1 0.0000 3700 4909 203 203 3497 4909 3903 4909
1 4 0 2 1 7 51 0 -1 0.000 1 0.0000 4817 4902 203 203 4614 4902 5020 4902
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 2475 4275 3825 4275 3600 4500
2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5
	 5175 4725 3375 4725 3375 3825 5175 3825 5175 4725
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4275 4050 5230 3095 5230 3414
2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 5
	 4477 3712 5872 2317 6052 2497 4702 3847 4522 3667
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 6750 5400 1125 5400 1125 2025 6750 2025 6750 5400
4 1 0 100 0 18 20 0.0000 4 210 570 4275 4365 Cart\001
4 1 0 100 0 18 20 0.0000 4 270 840 2070 4365 SS:[F]\001
4 1 0 100 0 18 20 0.0000 4 210 2445 5355 3060 InvertedPendulum\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_desc.tex version [1fb76406fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system InvertedPendulumOnCart (InvertedPendulumOnCart_desc.tex)
% Generated by MTT on Thu Aug 5 10:38:16 BST 1999.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{InvertedPendulumOnCart} is
   displayed in Figure \Ref{fig:InvertedPendulumOnCart_abg.ps} and its label
   file is listed in Section \Ref{sec:InvertedPendulumOnCart_lbl}.
   The subsystems are listed in Section \Ref{sec:InvertedPendulumOnCart_sub}.

This is a one input, two output nonlinear system comprising an
inverted pendulum attached by a hinge to a cart constrained to move in
the horizontal direction. The input is the horizontal force acting on
the cart, and the two outputs are the horizontal position and the
pendulum angle respectively.

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_input.txt version [eed0316c02].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode ##
 
## 
## System InvertedPendulumOnCart, representation input, language txt; 
## File idInvertedPendulumOnCart_input.txt; 
## Generated by MTT on Thu Apr  5 15:27:30 BST 2001; 



InvertedPendulumOnCart_f	= 1.0*(t<1); # Force for 1 sec

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_lbl.txt version [f7c8e12ace].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system InvertedPendulumOnCart (InvertedPendulumOnCart_lbl.txt)
%SUMMARY InvertedPendulumOnCart
%DESCRIPTION An Inverted Pendulum on a Cart

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS in   F
%UNITS F    translational  N m/s

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type SS
	[F]   SS	 external,internal




Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_numpar.txt version [553e3e5c8b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (InvertedPendulumOnCart_numpar.txt)
# Generated by MTT at Thu Aug  5 10:07:08 BST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: e_s = 	1.0;			# Se
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: f_s = 	1.0;			# Sf
g = 	1.0;			# Pendulum,gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: j_m = 	1.0;			# gRODa
j_r = 	1.0;			# Pendulum
l = 	1.0;			# Pendulum
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: l_a = 	1.0;			# gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: ## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: l_b = 	1.0;			# gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: m = 	1.0;			# gRODa
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: m_c = 	1.0;			# Cart
## Removed by MTT on Thu Nov  9 17:21:31 GMT 2000: m_r = 	1.0;			# Pendulum
r_c = 	0.1;			# Cart
r_p = 	0.1;			# Cart
m_c	= 1.0; # Added by MTT on Thu Nov 09 17:22:55 GMT 2000
m_r	= 1.0; # Added by MTT on Thu Nov 09 17:22:55 GMT 2000

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_rep.txt version [7bce6ceacb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system InvertedPendulumOnCart (InvertedPendulumOnCart_rep.txt)
## Generated by MTT on" Fri Oct 22 09:03:14 EST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:00:45  peterg
## To RCS
##
###############################################################

mtt InvertedPendulumOnCart abg tex			# The system description
mtt InvertedPendulumOnCart cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt InvertedPendulumOnCart struc tex	        # The system structure
mtt InvertedPendulumOnCart dae tex	        # The system dae
## mtt InvertedPendulumOnCart ode tex	        # The system ode 
## mtt InvertedPendulumOnCart sspar tex		# Steady-state parameters
## mtt InvertedPendulumOnCart ss tex 		# Steady state
## mtt InvertedPendulumOnCart dm tex		# Descriptor matrices (of linearised system)
## mtt InvertedPendulumOnCart dm tex		# State matrices (of linearised system)
## mtt InvertedPendulumOnCart tf tex		# Transfer function (of linearised system)
## mtt InvertedPendulumOnCart lmfr ps		# log modulus of frequency response (of linearised system)
## mtt InvertedPendulumOnCart simpar tex		# Simulation parameters
## mtt InvertedPendulumOnCart numpar tex		# Numerical simulation parameters
## mtt InvertedPendulumOnCart input tex		# Simulation input
## mtt InvertedPendulumOnCart odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_simpar.txt version [fa514a3154].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system InvertedPendulumOnCart (InvertedPendulumOnCart_simpar.txt)
# Generated by MTT on Thu Aug 5 09:17:05 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 100.0;      # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_subs.r version [752962d684].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Default SUBS file
% File InvertedPendulumOnCart_subs.r
% Generated by MTT on Thu Nov  9 18:55:44 GMT 2000.


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2001/04/02 10:57:57  gawthrop
% %% Added missing ;
% %%
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Put algebraic substitution commands here

for all x let cos(x)^2+sin(x)^2 = 1;

FOR ALL x,y LET x^y = pow(x,y); % Use the pow function

ON ROUNDED; % No integer output

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_abg.fig version [b643b2a567].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 3780 3105 6345 4545
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 3150 4950 4500 5175 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 6075 4500 6300 4275
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 3150 3825 4500 4050 4275
-6
6 3780 5355 6345 6795
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 4950 5400 4950 6750 5175 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6075 5400 6075 6750 6300 6525
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3825 5400 3825 6750 4050 6525
-6
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 6840 4950 8190 4950 7965 5175
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 9675 7425 3150 7425 3150 2475 9675 2475 9675 7425
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 4050 6750 3600 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5175 6750 4725 6750
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 6300 5400 5850 5400
4 1 4 100 0 18 20 0.0000 4 285 870 3825 7065 SS:[x]\001
4 1 4 100 0 18 20 0.0000 4 285 870 4950 7065 SS:[y]\001
4 1 4 100 0 18 20 0.0000 4 285 870 6075 7065 SS:[a]\001
4 1 0 100 0 18 20 0.0000 4 285 1590 4964 5040 gRODa:rod\001
4 1 0 100 0 18 20 0.0000 4 285 960 3825 3015 Se:x_0\001
4 1 0 100 0 18 20 0.0000 4 285 960 4950 3015 Se:y_0\001
4 1 0 100 0 18 20 0.0000 4 285 960 6030 3015 Se:a_0\001
4 1 4 100 0 18 14 0.0000 4 195 270 6660 4995 [a]\001
4 1 0 100 0 18 20 0.0000 4 225 1200 8865 5040 De:theta\001
4 1 4 100 0 18 14 0.0000 4 195 510 3825 4725 [x_a]\001
4 1 4 100 0 18 14 0.0000 4 195 510 4950 4725 [y_a]\001
4 1 4 100 0 18 14 0.0000 4 195 510 6075 4725 [a_a]\001
4 1 4 100 0 18 14 0.0000 4 195 525 3825 5265 [x_b]\001
4 1 4 100 0 18 14 0.0000 4 195 525 4950 5265 [y_b]\001
4 1 4 100 0 18 14 0.0000 4 195 525 6075 5265 [a_b]\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_lbl.txt version [4d5db894bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system InvertedPendulum (InvertedPendulum_lbl.txt)
%SUMMARY InvertedPendulum
%DESCRIPTION <Detailed description here>

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:00:45  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%UNITS  x         translational N m/s
%UNITS  y         translational N m/s
%UNITS  a         rotational N*m radian/s


%ALIAS	in|cart	x,y,a


% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type De
	theta			SS	external

% Component type SS
	[a]	SS		external,external
	[x]	SS		external,external
	[y]	SS		external,external

% Component type Se
	a_0	 SS	0
	x_0      SS     0
	y_0      SS     0

% Component type gRod
	rod	 none		l;l;j_r;m_r;g
 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_abg.fig version [795633633a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3017 1577 3287 1577
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5269 1579 5539 1579
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 1577 3152 3152 3377 2927
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4142 3152 4412 3152
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4277 1577 4277 3152 4502 2927
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5402 1577 5402 3152 5627 2927
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3019 4279 3289 4279
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4144 4279 4414 4279
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5271 4281 5541 4281
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4277 4277 4277 5852 4502 5627
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5402 4277 5402 5852 5627 5627
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 2250 7200 675 1575 675 1575 2250 7200 2250
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 4500 7200 2925 1575 2925 1575 4500 7200 4500
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 6750 7200 5175 1575 5175 1575 6750 7200 6750
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3150 4299 3150 5874 3375 5649
4 1 -1 0 0 0 20 0.0000000 4 240 870 3152 1397 SS:v_x\001
4 1 -1 0 0 0 20 0.0000000 4 240 810 4277 1397 SS:f_a\001
4 1 -1 0 0 0 20 0.0000000 4 210 1110 4278 3828 ROD:rod\001
4 1 -1 0 0 0 20 0.0000000 4 240 885 3155 6305 SS:F_x\001
4 1 -1 0 0 0 20 0.0000000 4 240 870 4280 6305 SS:F_a\001
4 1 -1 0 0 0 20 0.0000000 4 270 885 5450 6305 SS:F_y\001
4 1 -1 0 0 0 20 0.0000000 4 270 1920 5986 1396 ACCEL:gravity\001
4 1 1 1 0 3 20 0.0000000 4 240 1245 7965 1440 Fixed end\001
4 1 1 1 0 3 20 0.0000000 4 240 1110 7920 6075 Free end\001
4 1 1 1 0 3 20 0.0000000 4 270 1755 8280 3735 Rod dynamics\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3152 3467 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4277 3467 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5402 3467 [y_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3154 4144 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4280 4145 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5406 4146 [y_b]\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_desc.tex version [8fffb820c7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Pendulum (Pendulum_desc.tex)
% Generated by MTT on Fri Aug 15 09:52:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Pendulum} is
   displayed in Figure \Ref{Pendulum_abg} and its label
   file is listed in Section \Ref{sec:Pendulum_lbl}.
   The subsystems are listed in Section \Ref{sec:Pendulum_sub}.

This is a heirachical version of the example from Section 10.3 of
``Metamodelling''.  It uses two compound components: {\bf ROD} and {\bf
GRAV}. {\bf ROD} is
essentially as described in Figure 10.2 {\bf GRAV} represents gravity by a
vertical accelleration as in Section 10.9 of "Metamodelling".

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_input.txt version [d36e078d3f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode' 
# Numerical parameter file (Pendulum_input.txt)
# Generated by MTT at Fri Aug 15 09:02:02 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  1998/07/27 11:27:05  peterg
# %% Reformatted
# %%
# Revision 1.1  1997/08/15  08:04:01  peterg
# Initial revision
#
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 17:17:50 BST 2003: u(1) =	0.0;			# no torque at joint
## Removed by MTT on Tue Jun 10 17:17:50 BST 2003: u(2) =	9.81;			# g
pendulum__f_a	= 0.0;		# No joint torque
pendulum__gravity__force	= 9.81;	# g

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_lbl.txt version [a4f4c9c248].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Pendulum: Pendulum example from Section 10.3 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.3 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling".

%ALIAS ACCEL	Mechanical-2D/ACCEL # Constant acceleration
%% Label file for system pend (pend_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1997/08/15  09:46:22  peterg
% %% New labeled ports version
% %%
% Revision 1.1  1996/11/09  18:44:58  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters
rod	none	l;l;j;m

%Zero velocity sources
v_x	SS     internal,0

%Zero force/torque sources
F_x	SS	   0,internal
F_y	SS	   0,internal
F_a	SS	   0,internal

%Torque at end
f_a	SS external,external

%Gravity
gravity





Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_numpar.txt version [1aa95a298a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (Pendulum_numpar.txt)
# Generated by MTT at Mon Jul 27 12:38:25 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0;			# Pendulum
m = 	1.0;			# Pendulum
j = 	m*l*l/12.0;		# Pendulum

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_rep.txt version [706ef8c12b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Pendulum (Pendulum_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/19 17:34:30  peterg
% %% Put in -c
% %%
% %% Revision 1.1  1999/02/22 09:17:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt Pendulum abg tex
mtt Pendulum struc tex
mtt Pendulum dae tex
mtt Pendulum cse tex
## mtt Pendulum rfe tex
mtt Pendulum ode tex
mtt Pendulum input txt
mtt Pendulum numpar txt
mtt Pendulum odeso ps

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_simpar.txt version [18a566dbec].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system Pendulum (Pendulum_simpar.txt)
# Generated by MTT on Mon Jul 27 12:27:43 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1999/12/23 20:16:47  peterg
## Removed MTHOD
##
## Revision 1.2  1999/02/22 10:08:05  peterg
## 
##
## Revision 1.1  1998/07/27 11:29:13  peterg
## Initial revision
##
###############################################################


LAST=10.0;			# Last time in simulation
DT=0.1;				# Print interval
STEPFACTOR=10;			# Integration steps per print interval

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_state.txt version [57d68aa055].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (Pendulum_state.txt)
# Generated by MTT at Mon Jul 27 12:34:12 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/27 11:41:39  peterg
## Initial revision
##
###############################################################

# Set the states
## Removed by MTT on Tue Jun 10 17:16:38 BST 2003: mttx(1) 	= 0.0; 	# J (Pendulum_rod)
## Removed by MTT on Tue Jun 10 17:16:38 BST 2003: mttx(2) 	= pi/4;	# 3 (Pendulum_rod_th)
## Removed by MTT on Tue Jun 10 17:16:38 BST 2003: mttx(3) 	= 0.0; 	# 2 (Pendulum_gravity)
pendulum__gravity__mtti	= 0.0;
pendulum__rod__j	= 0.0;
pendulum__rod__th__mttc	= pi/4;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/Pendulum/Pendulum_subs.r version [7a6dcb4fcb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to sunstitute in system Pendulum (Pendulum_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_abg.fig version [e0aed8f131].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.0000000 1 0.000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 7650 450 9405 450 9405 675 7650 675 7650 450
4 1 -1 0 0 0 20 0.0000000 4 240 870 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000000 4 210 150 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000000 4 240 960 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000000 4 240 885 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000000 4 240 870 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000000 4 270 885 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000000 4 210 1260 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000000 4 210 1260 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000000 4 240 960 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000000 4 240 810 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000000 4 240 870 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000000 4 240 810 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000000 4 270 420 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000000 4 240 870 6750 1260 Joint 1\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 885 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000000 4 210 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000000 4 195 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 900 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000000 4 210 510 5859 8514 [y_b]\001
4 1 -1 0 0 0 20 0.0000000 4 270 870 5850 945 SS:v_y\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_desc.tex version [1b0381b9ba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoLink (TwoLink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLink} is
   displayed in Figure \Ref{TwoLink_abg} and its label
   file is listed in Section \Ref{sec:TwoLink_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
There is no gravity included in this model.

This system has a number of dynamic elements (those corresponding to
translation motion) in derivative causality, thus the system is
represnted as a Differential-Algebraic Equation (Section
\Ref{sec:TwoLink_dae.tex}). Hovever, this is of contrained-state form
and therfore can be written as a set of constrained-state equations
(Section \Ref{sec:TwoLink_cse.tex}). The corresponding ordinary
differential equation is complicated due to the trig functions
involved in inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:TwoLink_rfe}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_input.txt version [9c3ec92995].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLink_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/07/27 10:44:59  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Tue Jun 10 17:24:08 BST 2003: u(1) =	(t<1.0);		# Torque on Joint 1
## Removed by MTT on Tue Jun 10 17:24:08 BST 2003: u(2) =	-(t>10.0)&&(t<11.0);	# Torque on Joint 2
## Removed by MTT on Tue Jun 10 17:24:08 BST 2003: u(3) =	0.0;			# Gravity
twolink__f_a1	= (t<1.0);		# Torque on Joint 1
twolink__f_a2	= -(t>10.0)&&(t<11.0);	# Torque on Joint 2

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_lbl.txt version [9f787960d1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (TwoLink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/27 10:45:22  peterg
% %% Initial revision
% %%
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - uniform rods
rod1	none	l_1;l_1;j_1;m_1
rod2	none	l_2;l_2;j_2;m_2

%Zero velocity sources
v_x	SS     internal,0
v_y	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal


%Torque/velocity at joints
f_a1	SS	 external,external
f_a2	SS	 external,external


Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_numpar.txt version [0fbe82c500].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLink_numpar.txt)
# Generated by MTT at Mon Jan 19 13:53:15 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
j_1 = 	1.0; # Parameter j_1 for TwoLink
j_2 = 	1.0; # Parameter j_2 for TwoLink
l_1 = 	1.0; # Parameter l_1 for TwoLink
l_2 = 	1.0; # Parameter l_2 for TwoLink
m_1 = 	1.0; # Parameter m_1 for TwoLink
m_2 = 	1.0; # Parameter m_2 for TwoLink

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_rep.txt version [21a223e372].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TwoLink (TwoLink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  2000/05/19 17:35:34  peterg
% %% -c
% %%
% %% Revision 1.3  1999/02/22 09:18:33  peterg
% %% Removed -c
% %%
% %% Revision 1.2  1998/01/19 14:21:21  peterg
% %% Removed ordinary differential equation representation - its to
% %% verbose.
% %%
% %% Revision 1.1  1998/01/19 14:15:52  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLink abg tex
mtt TwoLink struc tex
mtt TwoLink sympar tex
mtt TwoLink dae tex
mtt TwoLink cse tex
## mtt TwoLink rfe tex

mtt TwoLink input txt
mtt TwoLink numpar txt
mtt -i euler TwoLink odeso ps

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_simp.r version [78d66bdfd1].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system TwoLink (TwoLink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_simpar.txt version [825ca8bdde].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Simulation parameters for system TwoLink (TwoLink_simpar.txt)
# Generated by MTT on Mon Jul 27 08:16:50 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$

## Revision 1.3  1999/02/22 10:07:24  peterg
## Step facttor 10
##
## Revision 1.2  1999/02/22 10:06:13  peterg
##
## Revision 1.1  1998/07/27 10:46:30  peterg
## Initial revision
##
###############################################################


LAST=50.0;
DT=0.1;
STEPFACTOR=10;


Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/TwoLink_subs.r version [cceaeb9eae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce  substitution statements for system TwoLink (TwoLink_subs.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/03/22 20:12:51  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_desc.tex version [bb657d852c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system twolink (twolink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{twolink} is
   displayed in Figure \Ref{twolink_abg} and its label
   file is listed in Section \Ref{sec:twolink_lbl}.
   The subsystems are listed in Section \Ref{sec:twolink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses two compound components: {\bf ROD} and {\bf
GRAV}.  {\bf ROD} is essentially as described in Figure 10.2 {\bf
GRAV} represents gravity by a vertical accelleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_lbl.txt version [e8bd693d1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY twolink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (twolink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m
rod2	none	l;l;j;m

%Zero velocity sources
v_x	internal	0


%Zero force/torque sources
F_x	0	internal
F_a	0	internal
F_y	0	internal


%Torque at joints
f_a1	external external
f_a2	external external


%Gravity
g

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_params.r version [eb6c0cbeba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Parameter file for system twolink (twolink_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Useful trig simplifications


        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

% Some simplifications -- see book
j := m*l*l/3;

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_rep.txt version [26658efeb2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Outline report file for system twolink (twolink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

abg tex
struc tex
dae tex
csm tex
sro ps
lmfr ps
odeso ps
input txt
numpar txt

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLink/twolink_simp.r version [322b9f1b83].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system twolink (twolink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%simplify the output equations
% Joint  angles
mttx2 := theta_1;
mttx4 := theta_1 + theta_2;
END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_abg.fig version [b1caa985f3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 900 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000 4 255 900 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1170 5850 945 ACCEL:g\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_desc.tex version [6281d6e316].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoLinkxyc (TwoLinkxyc_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkxyc} is
   displayed in Figure \Ref{TwoLinkxyc_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkxyc_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkxyc_sub}.

This system is identical to  \textbf{twolink} except that the two
colocated {\bf SS} components act at the tip in the $x$ and $y$
directions instead of at the two joints.

It uses two compound components: {\bf ROD} and {\bf GRAV}.  {\bf ROD}
is essentially as described in Figure 10.2 of "Metamodelling" and {\bf
GRAV} represents gravity by a vertical acceleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_input.txt version [c8c2ef8960].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkxyc_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:02:44  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Jun 11 14:02:21 BST 2003: u(1) =	(t<1.0);
## Removed by MTT on Wed Jun 11 14:02:21 BST 2003: u(2) =	0.0; # 
## Removed by MTT on Wed Jun 11 14:02:21 BST 2003: u(3) =	0.0; # gravity
twolinkxyc__f_x	= (t<1.0);
twolinkxyc__f_y	= 0.0; 
twolinkxyc__g__force	= 0.0;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_lbl.txt version [3994ea9709].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkxyc: two-link manipulator with collocated tip source-sensors.
%DESCRIPTION This is related to a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"
%DESCRIPTION except that the  collocated  source-sensors act at the
%DESCRIPTION tip rather than at the joints.

%% Label (TwoLinkxyc_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/06  15:56:31  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m;mg
rod2	none	l;l;j;m;mg

%Zero velocity sources
v_x	SS     internal,0


%Zero force/torque sources
F_a	SS	   0,internal


%Torque at joints
f_a1	SS	0,internal
f_a2	SS	0,internal

%Forces at tip
F_x	SS	external,external
F_y	SS	external,external


%Gravity
g

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_numpar.txt version [7b7519bf11].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkxyc_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.2  2000/05/20 15:44:26  peterg
# %% Split from old numpar file
# %%
# %% Revision 1.1  2000/05/20 15:43:27  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	m*l*l/12.0; # Uniform rod
mg	= m*9.81;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_rep.txt version [5d1a320820].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TwoLinkxyc (TwoLinkxyc_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:02:44  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkxyc abg tex
mtt TwoLinkxyc struc tex
mtt TwoLinkxyc dae tex
mtt TwoLinkxyc cse tex
mtt TwoLinkxyc input txt
mtt TwoLinkxyc numpar txt
mtt  -i euler TwoLinkxyc odeso ps

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_simp.r version [e44c55285d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system TwoLinkxyc (TwoLinkxyc_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_simpar.txt version [2d422722b4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system TwoLinkxyc (TwoLinkxyc_simpar.txt)
# Generated by MTT on Mon Feb 22 09:44:37 GMT 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1999/02/22 10:09:34  peterg
## Initial revision
##
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_sspar.r version [77f6d0b61a].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for TwoLinkxyc (TwoLinkxyc_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyc/TwoLinkxyc_state.txt version [e1fccc7ae9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# State initialisation file  file (TwoLinkxyc_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/05/20 15:44:48  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(1) = 	0.0; # Initial state for TwoLinkxyc_rod1 (J)
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(2) = 	0.0; # Initial state for TwoLinkxyc_rod1_th (3)
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(3) = 	0.0; # Initial state for TwoLinkxyc_rod2 (J)
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(4) = 	3.142/4; # Initial state for TwoLinkxyc_rod2_th (3) - 45 deg.
## Removed by MTT on Wed Jun 11 14:05:13 BST 2003: x(5) = 	0.0; # Initial state for TwoLinkxyc_g (2)
twolinkxyc__g__mtti	= 0.0; 
twolinkxyc__rod1__j	= 0.0; 
twolinkxyc__rod1__th__mttc	= 0.0;
twolinkxyc__rod2__j	= 0.0; 
twolinkxyc__rod2__th__mttc	= 3.142/4;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_abg.fig version [b1caa985f3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 900 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000 4 255 900 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1170 5850 945 ACCEL:g\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_desc.tex version [4b8a2c615b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TwoLinkxyn (TwoLinkxyn_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1998/01/06  17:36:33  peterg
% Initial revision
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TwoLinkxyn} is
   displayed in Figure \Ref{TwoLinkxyn_abg} and its label
   file is listed in Section \Ref{sec:TwoLinkxyn_lbl}.
   The subsystems are listed in Section \Ref{sec:TwoLinkxyn_sub}.

This system is identical to  \textbf{twolink} except that there are
now two non-collocated input-output pairs: The torque input to joint 1
-- x velocity of the tip and the torque input to joint 2
-- y velocity of the tip. 

It uses two compound components: {\bf ROD} and {\bf GRAV}.  {\bf ROD}
is essentially as described in Figure 10.2 of "Metamodelling" and {\bf
GRAV} represents gravity by a vertical acceleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_input.txt version [5266242257].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkxyn_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:03:12  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Jun 11 14:14:40 BST 2003: u(1) =	(t<1.0);
## Removed by MTT on Wed Jun 11 14:14:40 BST 2003: u(2) =	0.0; # 
## Removed by MTT on Wed Jun 11 14:14:40 BST 2003: u(3) =	0.0; # gravity
twolinkxyn__f_a1	= (t<1.0);
twolinkxyn__f_a2	= 0.0;
twolinkxyn__g__force	= 0.0;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_lbl.txt version [2f9773334c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TwoLinkxyn: two-link manipulator with collocated tip source-sensors.
%DESCRIPTION This is related to a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"
%DESCRIPTION except that the source sensors are not collocated:
%DESCRIPTION sources at the joints, sensors at the xy motion of the tip.

%% Label (TwoLinkxyn_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/06  17:37:55  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m;mg
rod2	none	l;l;j;m;mg

%Zero velocity sources
v_x	SS     internal,0


%Zero force/torque sources
F_a	SS	   0,internal


%Torque at joints
f_a1	SS	external,internal
f_a2	SS	external,internal

%Forces at tip
F_x	SS	0,external
F_y	SS	0,external


%Gravity
g

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_numpar.txt version [394b813c98].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (TwoLinkxyn_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/05/20 15:50:31  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	m*l*l/12.0; # Uniform rod
mg	= m*9.81;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_rep.txt version [af9435c555].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TwoLinkxyn (TwoLinkxyn_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/05/19 17:36:55  peterg
% %% -c
% %%
% %% Revision 1.1  1999/02/22 10:01:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt TwoLinkxyn abg tex
mtt TwoLinkxyn struc tex
mtt TwoLinkxyn dae tex
mtt TwoLinkxyn cse tex
##mtt TwoLinkxyn rfe tex
##mtt TwoLinkxyn ode tex
mtt TwoLinkxyn input txt
mtt TwoLinkxyn numpar txt
mtt -i euler TwoLinkxyn odeso ps

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_simp.r version [f03e08b08b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system TwoLinkxyn (TwoLinkxyn_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_simpar.txt version [5eae2d65c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system TwoLinkxyn (TwoLinkxyn_simpar.txt)
# Generated by MTT on Mon Feb 22 09:53:04 GMT 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 10;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_sspar.r version [f8140e05f7].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce steady-state parameter file for TwoLinkxyn (TwoLinkxyn_sspar.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/TwoLinkxyn/TwoLinkxyn_state.txt version [cdad8f6fcb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# State file (TwoLinkxyn_state.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/05/20 15:50:57  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(1) = 	0.0; # Initial state for TwoLinkxyn_rod1 (J)
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(2) = 	0.0; # Initial state for TwoLinkxyn_rod1_th (3)
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(3) = 	0.0; # Initial state for TwoLinkxyn_rod2 (J)
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(4) = 	3.142/4; # Initial state for TwoLinkxyn_rod2_th (3) - 45 deg.
## Removed by MTT on Wed Jun 11 14:15:48 BST 2003: x(5) = 	0.0; # Initial state for TwoLinkxyn_g (2)
twolinkxyn__g__mtti	= 0.0;
twolinkxyn__rod1__j	= 0.0;
twolinkxyn__rod1__th__mttc	= 0.0;
twolinkxyn__rod2__j	= 0.0;
twolinkxyn__rod2__th__mttc	= 3.142/4;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_abg.fig version [b1caa985f3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 1125 485 485 8550 1125 8730 1575
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 8550 5625 485 485 8550 5625 9035 6110
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3468 1128 3738 1128
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5720 1130 5990 1130
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4593 2703 4863 2703
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4728 1128 4728 2703 4953 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4502 5492 4502 5762
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2927 5627 4502 5627 4277 5852
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 5851 4726 7426 4951 7201
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3472 8647 3742 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4597 8647 4867 8647
2 1 0 1 25 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5724 8649 5994 8649
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4730 8645 4730 10220 4955 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5855 8645 5855 10220 6080 9995
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3601 3826 3601 7426 3826 7201
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5851 3826 5851 7426 6076 7201
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 8775 6525 7200 2925 7200 2925 8775 6525 8775
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 2025 6525 450 2925 450 2925 2025 6525 2025
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 6435 6525 4860 2925 4860 2925 6435 6525 6435
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 11250 6525 9675 2925 9675 2925 11250 6525 11250
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 11475 9450 225 180 225 180 11475 9450 11475
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3603 1128 3603 2703 3828 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5853 1128 5853 2703 6078 2478
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4726 3826 4726 5401 4951 5176
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 6525 4050 2925 4050 2925 2475 6525 2475 6525 4050
2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 8622 3600 10197 3825 9972
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 5175 8775 1575 8325 1575 8325 5175 8775 5175
2 4 0 2 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 8775 9675 8775 6075 8325 6075 8325 9675 8775 9675
4 1 -1 0 0 0 20 0.0000 4 255 810 3603 948 SS:v_x\001
4 0 -1 0 0 0 20 0.0000 4 195 135 4683 5718 0\001
4 1 -1 0 0 0 20 0.0000 4 255 900 2432 5717 SS:f_a2\001
4 1 -1 0 0 0 20 0.0000 4 255 840 3608 10673 SS:F_x\001
4 1 -1 0 0 0 20 0.0000 4 255 840 4733 10673 SS:F_a\001
4 1 -1 0 0 0 20 0.0000 4 255 840 5903 10673 SS:F_y\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4729 3379 ROD:rod1\001
4 1 -1 0 0 0 20 0.0000 4 195 1200 4731 8196 ROD:rod2\001
4 1 -1 0 0 0 20 0.0000 4 255 900 4771 946 SS:f_a1\001
4 0 1 1 0 3 20 0.0000 4 210 720 6795 3375 Link 1\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 5760 Joint 2\001
4 0 1 1 0 3 20 0.0000 4 210 720 6750 8190 Link 2\001
4 0 1 1 0 3 20 0.0000 4 270 375 6750 10485 Tip\001
4 0 1 1 0 3 20 0.0000 4 225 795 6750 1260 Joint 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1170 5850 945 ACCEL:g\001
4 1 4 0 0 0 16 0.0000 4 210 495 3600 2970 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4725 2970 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3600 3780 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4725 3780 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5850 3780 [y_b]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5850 2970 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 495 3605 7835 [x_a]\001
4 1 4 0 0 0 16 0.0000 4 225 900 4730 7835 [alpha_a]\001
4 1 4 0 0 0 16 0.0000 4 225 495 5855 7835 [y_a]\001
4 1 4 0 0 0 16 0.0000 4 210 510 3607 8512 [x_b]\001
4 1 4 0 0 0 16 0.0000 4 225 915 4733 8513 [alpha_b]\001
4 1 4 0 0 0 16 0.0000 4 225 510 5859 8514 [y_b]\001

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_desc.tex version [c73da6dfdc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system gTwoLink (gTwoLink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/01/19 14:20:07  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/08/15  13:31:00  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{gTwoLink} is
   displayed in Figure \Ref{gTwoLink_abg} and its label
   file is listed in Section \Ref{sec:gTwoLink_lbl}.
   The subsystems are listed in Section \Ref{sec:gTwoLink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses the compound components: {\bf ROD}.  {\bf
ROD} is essentially as described in Figure 10.2.
Gravity is included as discussed in "Metamodelling" by accelerating
the manipulator vertically using the {\bf ACCEL} component.

This system has a number of dynamic elements (those corresponding to
translation motion) in derivative causality, thus the system is
represnted as a Differential-Algebraic Equation (Section
\Ref{sec:gTwoLink_dae.tex}). Hovever, this
is of contrained-state form and therfore can be written as a set of
constrained-state equations (Section \Ref{sec:gTwoLink_cse.tex}). The
corresponding ordinary differential equation is complicated due to the
trig functions involved in inverting the E matrix.

As well as the standard representation the ``robot-form'' equations
appear in Section  \Ref{sec:gTwoLink_rfe.tex}. 

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_input.txt version [c054ad63f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (gTwoLink_input.txt)
# Generated by MTT at Fri Jun 13 16:56:09 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:03:41  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Jun 11 14:23:00 BST 2003: u(1) =	(t<1.0);
## Removed by MTT on Wed Jun 11 14:23:00 BST 2003: u(2) =	0.0; # 
## Removed by MTT on Wed Jun 11 14:23:00 BST 2003: u(3) =	0.0; # gravity
gtwolink__f_a1	= (t<1.0);
gtwolink__f_a2	= 0.0;
gtwolink__g__force	= 0.0;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_lbl.txt version [ef35e2beef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY gTwoLink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (gTwoLink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/12/05  12:39:49  peterg
% %% Documentation
% %%
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m;mg
rod2	none	l;l;j;m;mg

%Zero velocity sources
v_x	SS     internal,0


%Zero force/torque sources
F_x	SS	   0,internal
F_a	SS	   0,internal
F_y	SS	   0,internal


%Torque at joints
f_a1	SS	external,external
f_a2	SS	external,external

%Gravity
g

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_numpar.txt version [545d5baf0d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (gTwoLink_numpar.txt)
# Generated by MTT at Fri Jun 13 16:39:41 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:03:41  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
l = 	1.0; # Default value
m = 	1.0; # Default value
j = 	m*l*l/12.0; # Uniform rod

mg	= m*9.81; 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_rep.txt version [abfc1962b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system gTwoLink (gTwoLink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:03:41  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/22 09:18:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt gTwoLink abg tex
mtt gTwoLink struc tex
mtt gTwoLink sympar tex
mtt gTwoLink dae tex
mtt gTwoLink cse tex
mtt gTwoLink input txt
mtt gTwoLink numpar txt
mtt -i euler gTwoLink odeso ps

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_simp.r version [db95ebfddb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system gTwoLink (gTwoLink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_simpar.txt version [d1bd9350e6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Simulation parameters for system gTwoLink (gTwoLink_simpar.txt)
# Generated by MTT on Mon Jul 27 08:11:02 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1999/12/23 20:18:54  peterg
## Removed METHOD
##
## Revision 1.1  1999/02/22 10:06:54  peterg
## Initial revision
##
###############################################################


LAST=5.0;
DT=0.1;
STEPFACTOR=10;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/gTwoLink_state.txt version [c5b2ae4018].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Initial state  file (gTwoLink_state.txt)
# Generated by MTT at Mon Jul 27 07:54:23 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/07/27 06:59:25  peterg
## Initial revision
##
###############################################################

# Set the states
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(1) 	= 0.0; 	# J (gTwoLink_rod1)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(2) 	= 0.0; 	# 3 (gTwoLink_rod1_th)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(3) 	= 0.0; 	# J (gTwoLink_rod2)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(4) 	= pi/4;	# 3 (gTwoLink_rod2_th)
## Removed by MTT on Wed Jun 11 14:22:12 BST 2003: mttx(5) 	= 0.0; 	# 2 (gTwoLink_g)
gtwolink__g__mtti	= 0.0; 
gtwolink__rod1__j	= 0.0; 
gtwolink__rod1__th__mttc	= 0.0;
gtwolink__rod2__j	= 0.0; 
gtwolink__rod2__th__mttc	= pi/4;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_desc.tex version [bb657d852c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system twolink (twolink_desc.tex)
% Generated by MTT on Fri Jun 13 16:30:23 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{twolink} is
   displayed in Figure \Ref{twolink_abg} and its label
   file is listed in Section \Ref{sec:twolink_lbl}.
   The subsystems are listed in Section \Ref{sec:twolink_sub}.

This is a heirachical version of the example from Section 10.5 of
"Metamodelling".  It uses two compound components: {\bf ROD} and {\bf
GRAV}.  {\bf ROD} is essentially as described in Figure 10.2 {\bf
GRAV} represents gravity by a vertical accelleration as in Section
10.9 of "Metamodelling"

%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_lbl.txt version [e8bd693d1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY twolink: two-link manipulator from Section 10.5 of "Metamodelling"
%DESCRIPTION This is a heirachical version of the 
%DESCRIPTION example from Section 10.5 of "Metamodelling".
%DESCRIPTION It uses two compound components: ROD and GRA
%DESCRIPTION ROD is essentially as described in Figure 10.2
%DESCRIPTION GRAV represents gravity by a vertical accelleration
%DESCRIPTION as in Section 10.9 of "Metamodelling"


%% Label (twolink_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1996/12/05 12:17:15  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1996/11/14  10:48:42  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%Rod parameters - identical rods
rod1	none	l;l;j;m
rod2	none	l;l;j;m

%Zero velocity sources
v_x	internal	0


%Zero force/torque sources
F_x	0	internal
F_a	0	internal
F_y	0	internal


%Torque at joints
f_a1	external external
f_a2	external external


%Gravity
g

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_params.r version [eb6c0cbeba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Parameter file for system twolink (twolink_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Useful trig simplifications


        trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
                  cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
                  sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
                  cos(~x)^2       => (1+cos(2*x))/2,
                  sin(~x)^2       => (1-cos(2*x))/2};
       LET trig1;

% Some simplifications -- see book
j := m*l*l/3;

END;

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_rep.txt version [26658efeb2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Outline report file for system twolink (twolink_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

abg tex
struc tex
dae tex
csm tex
sro ps
lmfr ps
odeso ps
input txt
numpar txt

Deleted mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/gTwoLink/twolink_simp.r version [322b9f1b83].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system twolink (twolink_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%simplify the output equations
% Joint  angles
mttx2 := theta_1;
mttx4 := theta_1 + theta_2;
END;

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCc/sRCc_abg.fig version [ccb1b9cb1f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1215 4500 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1080 4500 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 5400 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 675 4275 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1215 4275 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 5400 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 5400 1530 5400 765
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 5625 6750 225 675 225 675 5625 6750 5625
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 255 600 2926 2926 sR:r\001
4 1 -1 0 0 0 20 0.0000 4 255 645 4276 2926 sC:c\001
4 1 -1 0 0 0 20 0.0000 4 255 945 1395 4365 sSe:e1\001
4 0 1 1 0 0 20 0.0000 4 180 120 2880 450 r\001
4 0 1 1 0 0 20 0.0000 4 180 165 4680 1215 c\001
4 0 1 1 0 0 20 0.0000 4 180 165 5625 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 5715 1305 2\001
4 0 1 1 0 0 20 0.0000 4 180 165 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 330 1725 3600 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 255 1545 3600 2025 Schematic\001
4 1 -1 0 0 0 20 0.0000 4 255 1005 5987 4367 sDe:e2\001
4 1 4 100 0 18 4 0.0000 4 120 270 4500 4005 [1,2]\001
4 1 4 100 0 18 4 0.0000 4 120 270 3105 4005 [1,2]\001

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCc/sRCc_desc.tex version [765c3fe2e6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system sRCc (sRCc_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 05:17:04  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sRCc} is
   displayed in Figure \Ref{sRCc_abg} and its label
   file is listed in Section \Ref{sec:sRCc_lbl}.
   The subsystems are listed in Section \Ref{sec:sRCc_sub}.

The system \textbf{sRCc} is the the sensitivity version of the simple
electrical sRCc circuit shown in Figure \Ref{sRCc_abg}. The circuit itself can be
regarded as a single-input single-output system with input $e_1$ and
output $e_2$; the sensitivity system has {\em two\/} outputs: $e_2$
and $\frac{\partial e_2}{\partial r}$.

All bonds are two-bond vector bonds, and the {\bf sR} and {\bf sC}
components are two-port versions of the usual {\bf R} and {\bf C}
components respectively. One port conveys the usual effort/flow pair;
the other port conveys the sensitivity of the effort and flow with
respect to the $c$ parameter.

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCc/sRCc_lbl.txt version [3400946923].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sRCc (sRCc_lbl.txt)
%SUMMARY sRCc Sensitivity of output of RC circuit wrt value of r
%DESCRIPTION Uses the sR and sC components and vector bonds

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/10/18 07:34:32  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1999/07/29 05:18:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type sSe
	e1       slin		external;0	

% Component type sDe
	e2

% Component type sC
	c	 slin		effort,c;1

% Component type sR
	r	 slin		flow,r;0

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCc/sRCc_rep.txt version [17b4c98377].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sRCc (sRCc_rep.txt)
## Generated by MTT on" Thu Jul 29 06:02:47 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt sRCc abg tex			# The system description
## mtt sRCc cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt sRCc struc tex	        # The system structure
## mtt sRCc dae tex	        # The system dae
mtt sRCc ode tex	        # The system ode 
## mtt sRCc sspar tex		# Steady-state parameters
## mtt sRCc ss tex 		# Steady state
## mtt sRCc dm tex		# Descriptor matrices (of linearised system)
mtt sRCc sm tex		# State matrices (of linearised system)
mtt sRCc tf tex		# Transfer function (of linearised system)
mtt sRCc lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sRCc simpar tex		# Simulation parameters
## mtt sRCc numpar tex		# Numerical simulation parameters
## mtt sRCc input tex		# Simulation input
 mtt sRCc odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCr/sRCr_abg.fig version [d99238c53e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
1 3 0 2 1 7 1 0 -1 0.000 1 0.0000 1800 1125 162 162 1800 1125 1890 1260
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1802 4277 2702 4277 2477 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 4277 4052 4277 3827 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4277 5402 4277 5177 4502
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2926 4051 2926 3151 3151 3376
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4276 4051 4276 3151 4501 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4276 2701 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4051 5401 4276
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5401 4276 5401 4501
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2701 4051 2701 4276
2 2 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 5
	 2475 585 3375 585 3375 765 2475 765 2475 585
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1215 4500 1215
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4050 1080 4500 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 675 2475 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 3375 675 5400 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 675 4275 1080
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 4275 1215 4275 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 5400 1575
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 945 1800 675
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 0 0 2
	 1800 1575 1800 1260
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 1 2.00 120.00 240.00
	 5400 1530 5400 765
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6750 5625 6750 225 675 225 675 5625 6750 5625
4 1 -1 0 0 0 20 0.0000 4 255 180 2927 4367 1\001
4 1 -1 0 0 0 20 0.0000 4 255 180 4277 4367 0\001
4 1 -1 0 0 0 20 0.0000 4 255 600 2926 2926 sR:r\001
4 1 -1 0 0 0 20 0.0000 4 255 645 4276 2926 sC:c\001
4 1 -1 0 0 0 20 0.0000 4 255 945 1395 4365 sSe:e1\001
4 0 1 1 0 0 20 0.0000 4 180 120 2880 450 r\001
4 0 1 1 0 0 20 0.0000 4 180 165 4680 1215 c\001
4 0 1 1 0 0 20 0.0000 4 180 165 5625 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 5715 1305 2\001
4 0 1 1 0 0 20 0.0000 4 180 165 1260 1170 e\001
4 0 1 1 0 0 20 0.0000 4 255 180 1350 1305 1\001
4 1 1 1 0 0 20 0.0000 4 330 1725 3600 4995 Bond graph\001
4 1 1 1 0 0 20 0.0000 4 255 1545 3600 2025 Schematic\001
4 1 -1 0 0 0 20 0.0000 4 255 1005 5987 4367 sDe:e2\001
4 1 4 100 0 18 10 0.0000 4 150 345 4545 4005 [1,2]\001
4 1 4 100 0 18 10 0.0000 4 150 345 3195 4005 [1,2]\001

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCr/sRCr_desc.tex version [78a9a2ed8d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system sRCr (sRCr_desc.tex)
% Generated by MTT on Sun Aug 24 11:03:55 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1999/07/29 05:17:04  peterg
% %% Initial revision
% %%
% %% Revision 1.1  1997/08/24 10:27:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{sRCr} is
   displayed in Figure \Ref{sRCr_abg} and its label
   file is listed in Section \Ref{sec:sRCr_lbl}.
   The subsystems are listed in Section \Ref{sec:sRCr_sub}.

The system \textbf{sRCr} is the the sensitivity version  of the simple
electrical sRCr circuit shown in Figure \Ref{sRCr_abg}. The circuit itself can be
regarded as a single-input single-output system with input $e_1$ and
output $e_2$; the sensitivity system has {\em two\/} outputs: $e_2$
and $\frac{\partial e_2}{\partial r}$.

All bonds are two-bond vector bonds, and the {\bf sR} and {\bf sC}
components are two-port versions of the usual {\bf R} and {\bf C}
components respectively. One port conveys the usual effort/flow pair;
the other port conveys the sensitivity of the effort and flow with
respect to the $r$ parameter.

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCr/sRCr_lbl.txt version [8da53abbab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system sRCr (sRCr_lbl.txt)
%SUMMARY sRCr Sensitivity of output of RC circuit wrt value of r
%DESCRIPTION Uses the sR and sC components and vector bonds

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:04:59  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/07/29 05:18:59  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases

% Argument aliases

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type sSe
	e1       slin		external;0	

% Component type sDe
	e2

% Component type sC
	c	 slin		effort,c;0

% Component type sR
	r	 slin		flow,r;1

Deleted mttroot/mtt/lib/examples/Sensitivity/sRCr/sRCr_rep.txt version [e24284fd27].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
## -*-octave-*- Put Emacs into octave-mode
## Outline report file for system sRCr (sRCr_rep.txt)
## Generated by MTT on" Thu Jul 29 06:02:47 BST 1999.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt sRCr abg tex			# The system description
## mtt sRCr cbg ps 		        # The causal bond graph
## Uncomment the following lines or add others
mtt sRCr struc tex	        # The system structure
## mtt sRCr dae tex	        # The system dae
mtt sRCr ode tex	        # The system ode 
## mtt sRCr sspar tex		# Steady-state parameters
## mtt sRCr ss tex 		# Steady state
## mtt sRCr dm tex		# Descriptor matrices (of linearised system)
mtt sRCr sm tex		# State matrices (of linearised system)
mtt sRCr tf tex		# Transfer function (of linearised system)
mtt sRCr lmfr ps		# log modulus of frequency response (of linearised system)
## mtt sRCr simpar tex		# Simulation parameters
## mtt sRCr numpar tex		# Numerical simulation parameters
## mtt sRCr input tex		# Simulation input
 mtt sRCr odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_abg.fig version [f4fec756c1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3150 5850 3150 5625 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4275 5850 4275 5625 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 2925 3150 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 4050 1800 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1777 4275 3127 4275 2902 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 4095 4500 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 8325 3150 8100 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 2925 6975 3375
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2925 2025 4725 2025 4725 5400 2925 5400 2925 2025
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 5850 9450 1575 450 1575 450 5850 9450 5850
4 0 -1 0 0 0 20 0.0000000 4 240 870 6030 3240 RT:r_2\001
4 2 4 0 0 0 20 0.0000000 4 240 690 2835 3060 [t_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 840 4770 3015 [t_out]\001
4 2 4 0 0 0 20 0.0000000 4 240 735 2880 4185 [e_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 885 4770 4185 [e_out]\001
4 2 -1 0 0 0 20 0.0000000 4 240 900 1620 3240 SS:T_1\001
4 0 -1 0 0 0 20 0.0000000 4 240 900 8460 3240 SS:T_2\001
4 2 -1 0 0 0 20 0.0000000 4 240 780 1665 4365 SS:I_r\001
4 0 -1 0 0 0 20 0.0000000 4 240 930 5985 4365 SS:V_0\001
4 1 -1 0 0 0 20 0.0000000 4 270 1575 3780 3825 Segment:s*100\001

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_input.txt version [c54d6fa852].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (BigHeatedRod_input.txt)
# Generated by MTT at Thu Sep  4 16:11:06 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:06:11  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Sun Aug 17 13:03:18 BST 2003: u(1) =	10.0*(t<5.0); # I_r 
bigheatedrod__i_r	=	10.0*(t<5.0); # I_r 

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_lbl.txt version [a943d5cb3b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY BigHeatedRod: Thermal/Electrical model of Electric rod
#DESCRIPTION Introduces the idea of the ES component which
#DESCRIPTION transforms a relative-temperature/enthalpy pseudo bond 
#DESCRIPTION (at the [e]port) into an absolute-temperature/enntropy 
#DESCRIPTION energy bond (at the [s] port) and vice versa.

#PAR rod_length
#PAR rod_radius
#PAR electrical_resistivity
#PAR thermal_resistivity
#PAR thermal_capacity
#PAR segments
#PAR area
#PAR delta_x
#PAR volume
#PAR density
#PAR mass
#PAR pi

## Label file for system BigHeatedRod (BigHeatedRod_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  2000/12/28 18:06:11  peterg
# ## To RCS
# ##
# ## Revision 1.1  1997/09/11 16:16:29  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type RT
	r_2		lin	flow,r_2

# Component type SS
	I_r	SS	internal,external
	T_1	SS	t_0,internal
	T_2	SS	t_0,internal
	V_0	SS	internal,internal

# Component type Segment
	s

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_numpar.txt version [92cb1f9ee5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (BigHeatedRod_numpar.txt)
# Generated by MTT at Thu Sep  4 16:11:04 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:06:11  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Constants for copper
density = 8.96;
rod_length = 1.0;
rod_radius = 1e-3;
electrical_resistivity = 16.8*0.000000001;
thermal_resistivity = 1/390.0;
thermal_capacity = 380.0;

pi = 3.142;

segments = 100;
area = pi*rod_radius*rod_radius;
delta_x = rod_length/segments;
volume = area*delta_x;
mass = volume*density;

# Parameters
c_t = 	thermal_capacity*mass;
r = 	electrical_resistivity*delta_x/area;
r_t = 	thermal_resistivity*delta_x/area;
r_2 = 	r_t;
t_0 = 	300; # Ambient




Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_rep.txt version [47c8424834].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system BigHeatedRod (BigHeatedRod_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2003/08/17 17:02:31  gawthrop
% %% Updated for new MTT
% %%
% %% Revision 1.1  1998/11/23 13:37:55  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o BigHeatedRod abg tex

mtt -o BigHeatedRod numpar txt
mtt -o BigHeatedRod input txt
mtt -o BigHeatedRod odeso ps

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_simpar.txt version [4609d162a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system BigHeatedRod (BigHeatedRod_simpar.txt)
# Generated by MTT on Tue Aug 24 01:20:41 BST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10.0;       # Last time in simulation
DT          = 0.1;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

DT          = 1.0;        # Print interval

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/BigHeatedRod_state.txt version [d77a055614].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214






















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (BigHeatedRod_state.txt)
# Generated by MTT at Friday August 14 18:38:47 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:06:11  peterg
## To RCS
##
###############################################################

# Set the states
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(1) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(2) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(3) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(4) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(5) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(6) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(7) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(8) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(9) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(10) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(11) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(12) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(13) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(14) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(15) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(16) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(17) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(18) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(19) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(20) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(21) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(22) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(23) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(24) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(25) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(26) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(27) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(28) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(29) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(30) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(31) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(32) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(33) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(34) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(35) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(36) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(37) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(38) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(39) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(40) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(41) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(42) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(43) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(44) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(45) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(46) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(47) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(48) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(49) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(50) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(51) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(52) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(53) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(54) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(55) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(56) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(57) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(58) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(59) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(60) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(61) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(62) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(63) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(64) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(65) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(66) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(67) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(68) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(69) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(70) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(71) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(72) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(73) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(74) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(75) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(76) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(77) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(78) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(79) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(80) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(81) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(82) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(83) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(84) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(85) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(86) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(87) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(88) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(89) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(90) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(91) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(92) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(93) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(94) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(95) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(96) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(97) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(98) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(99) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
## Removed by MTT on Sun Aug 17 13:05:21 BST 2003: mttx(100) 	= c_t*t_0; 	# c (BigHeatedRod_s_c_t)
bigheatedrod__s__100__c_t__c	=  c_t*t_0;
bigheatedrod__s__10__c_t__c	=  c_t*t_0;
bigheatedrod__s__11__c_t__c	=  c_t*t_0;
bigheatedrod__s__12__c_t__c	=  c_t*t_0;
bigheatedrod__s__13__c_t__c	=  c_t*t_0;
bigheatedrod__s__14__c_t__c	=  c_t*t_0;
bigheatedrod__s__15__c_t__c	=  c_t*t_0;
bigheatedrod__s__16__c_t__c	=  c_t*t_0;
bigheatedrod__s__17__c_t__c	=  c_t*t_0;
bigheatedrod__s__18__c_t__c	=  c_t*t_0;
bigheatedrod__s__19__c_t__c	=  c_t*t_0;
bigheatedrod__s__20__c_t__c	=  c_t*t_0;
bigheatedrod__s__21__c_t__c	=  c_t*t_0;
bigheatedrod__s__22__c_t__c	=  c_t*t_0;
bigheatedrod__s__23__c_t__c	=  c_t*t_0;
bigheatedrod__s__24__c_t__c	=  c_t*t_0;
bigheatedrod__s__25__c_t__c	=  c_t*t_0;
bigheatedrod__s__26__c_t__c	=  c_t*t_0;
bigheatedrod__s__27__c_t__c	=  c_t*t_0;
bigheatedrod__s__28__c_t__c	=  c_t*t_0;
bigheatedrod__s__29__c_t__c	=  c_t*t_0;
bigheatedrod__s__2__c_t__c	=  c_t*t_0;
bigheatedrod__s__30__c_t__c	=  c_t*t_0;
bigheatedrod__s__31__c_t__c	=  c_t*t_0;
bigheatedrod__s__32__c_t__c	=  c_t*t_0;
bigheatedrod__s__33__c_t__c	=  c_t*t_0;
bigheatedrod__s__34__c_t__c	=  c_t*t_0;
bigheatedrod__s__35__c_t__c	=  c_t*t_0;
bigheatedrod__s__36__c_t__c	=  c_t*t_0;
bigheatedrod__s__37__c_t__c	=  c_t*t_0;
bigheatedrod__s__38__c_t__c	=  c_t*t_0;
bigheatedrod__s__39__c_t__c	=  c_t*t_0;
bigheatedrod__s__3__c_t__c	=  c_t*t_0;
bigheatedrod__s__40__c_t__c	=  c_t*t_0;
bigheatedrod__s__41__c_t__c	=  c_t*t_0;
bigheatedrod__s__42__c_t__c	=  c_t*t_0;
bigheatedrod__s__43__c_t__c	=  c_t*t_0;
bigheatedrod__s__44__c_t__c	=  c_t*t_0;
bigheatedrod__s__45__c_t__c	=  c_t*t_0;
bigheatedrod__s__46__c_t__c	=  c_t*t_0;
bigheatedrod__s__47__c_t__c	=  c_t*t_0;
bigheatedrod__s__48__c_t__c	=  c_t*t_0;
bigheatedrod__s__49__c_t__c	=  c_t*t_0;
bigheatedrod__s__4__c_t__c	=  c_t*t_0;
bigheatedrod__s__50__c_t__c	=  c_t*t_0;
bigheatedrod__s__51__c_t__c	=  c_t*t_0;
bigheatedrod__s__52__c_t__c	=  c_t*t_0;
bigheatedrod__s__53__c_t__c	=  c_t*t_0;
bigheatedrod__s__54__c_t__c	=  c_t*t_0;
bigheatedrod__s__55__c_t__c	=  c_t*t_0;
bigheatedrod__s__56__c_t__c	=  c_t*t_0;
bigheatedrod__s__57__c_t__c	=  c_t*t_0;
bigheatedrod__s__58__c_t__c	=  c_t*t_0;
bigheatedrod__s__59__c_t__c	=  c_t*t_0;
bigheatedrod__s__5__c_t__c	=  c_t*t_0;
bigheatedrod__s__60__c_t__c	=  c_t*t_0;
bigheatedrod__s__61__c_t__c	=  c_t*t_0;
bigheatedrod__s__62__c_t__c	=  c_t*t_0;
bigheatedrod__s__63__c_t__c	=  c_t*t_0;
bigheatedrod__s__64__c_t__c	=  c_t*t_0;
bigheatedrod__s__65__c_t__c	=  c_t*t_0;
bigheatedrod__s__66__c_t__c	=  c_t*t_0;
bigheatedrod__s__67__c_t__c	=  c_t*t_0;
bigheatedrod__s__68__c_t__c	=  c_t*t_0;
bigheatedrod__s__69__c_t__c	=  c_t*t_0;
bigheatedrod__s__6__c_t__c	=  c_t*t_0;
bigheatedrod__s__70__c_t__c	=  c_t*t_0;
bigheatedrod__s__71__c_t__c	=  c_t*t_0;
bigheatedrod__s__72__c_t__c	=  c_t*t_0;
bigheatedrod__s__73__c_t__c	=  c_t*t_0;
bigheatedrod__s__74__c_t__c	=  c_t*t_0;
bigheatedrod__s__75__c_t__c	=  c_t*t_0;
bigheatedrod__s__76__c_t__c	=  c_t*t_0;
bigheatedrod__s__77__c_t__c	=  c_t*t_0;
bigheatedrod__s__78__c_t__c	=  c_t*t_0;
bigheatedrod__s__79__c_t__c	=  c_t*t_0;
bigheatedrod__s__7__c_t__c	=  c_t*t_0;
bigheatedrod__s__80__c_t__c	=  c_t*t_0;
bigheatedrod__s__81__c_t__c	=  c_t*t_0;
bigheatedrod__s__82__c_t__c	=  c_t*t_0;
bigheatedrod__s__83__c_t__c	=  c_t*t_0;
bigheatedrod__s__84__c_t__c	=  c_t*t_0;
bigheatedrod__s__85__c_t__c	=  c_t*t_0;
bigheatedrod__s__86__c_t__c	=  c_t*t_0;
bigheatedrod__s__87__c_t__c	=  c_t*t_0;
bigheatedrod__s__88__c_t__c	=  c_t*t_0;
bigheatedrod__s__89__c_t__c	=  c_t*t_0;
bigheatedrod__s__8__c_t__c	=  c_t*t_0;
bigheatedrod__s__90__c_t__c	=  c_t*t_0;
bigheatedrod__s__91__c_t__c	=  c_t*t_0;
bigheatedrod__s__92__c_t__c	=  c_t*t_0;
bigheatedrod__s__93__c_t__c	=  c_t*t_0;
bigheatedrod__s__94__c_t__c	=  c_t*t_0;
bigheatedrod__s__95__c_t__c	=  c_t*t_0;
bigheatedrod__s__96__c_t__c	=  c_t*t_0;
bigheatedrod__s__97__c_t__c	=  c_t*t_0;
bigheatedrod__s__98__c_t__c	=  c_t*t_0;
bigheatedrod__s__99__c_t__c	=  c_t*t_0;
bigheatedrod__s__9__c_t__c	=  c_t*t_0;
bigheatedrod__s__c_t__c	=  c_t*t_0;

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/HR_input.txt version [e8bdef2d26].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (HR_input.txt)
# Generated by MTT at Thu Sep  4 16:11:06 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
u(1) =	10.0*(t<5.0); # I_r 

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/HR_numpar.txt version [c4b7dfe06b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (HR_numpar.txt)
# Generated by MTT at Thu Sep  4 16:11:04 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Constants for copper
density = 8.96;
rod_length = 1.0;
rod_radius = 1e-3;
electrical_resistivity = 16.8*0.000000001;
thermal_resistivity = 1/390.0;
thermal_capacity = 380.0;


segments = 2;
area = pi*rod_radius*rod_radius;
delta_x = rod_length/segments;
volume = area*delta_x;
mass = volume*density;

# Parameters
c_t = 	thermal_capacity*mass;
r = 	electrical_resistivity*delta_x/area;
r_t = 	thermal_resistivity*delta_x/area;
r_2 = 	r_t/100;
t_0 = 	300; # Ambient




Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/HR_simpar.txt version [8e33457c64].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system HR (HR_simpar.txt)
# Generated by MTT on Wednesday July 29 13:59:50 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 10;       # Last time in simulation
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps

STEPFACTOR = 1; # Added automatically
METHOD = IMPLICIT;         # Added automatically
DT = 0.25;                 # Added automatically

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/HeatedRod_desc.tex version [ca122af254].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system HeatedRod (HeatedRod_desc.tex)
% Generated by MTT on Thu Sep 4 18:05:09 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





   The acausal bond graph of system \textbf{HeatedRod} is
   displayed in Figure \Ref{HeatedRod_abg} and its label
   file is listed in Section \Ref{sec:HeatedRod_lbl}.
The subsystems are listed in Section \Ref{sec:HeatedRod_sub}.

 System \textbf{HeatedRod} is a model of a rod of copper with an
 electric current passing through it which warms it up. The two ends of
 the rod are fixed at ambient temperature; this is where all the heat
 loss occurs. 

 This system introduces the idea of the {\bf ES} component which
 transforms a relative-temperature/enthalpy pseudo bond (at the [e]
 port) into an absolute-temperature/enntropy energy bond (at the [s]
 port) and vice versa.

 The model is similar to that described in chapter 8 of
 Cellier's book. However, instead of representing the thermal
 resistance by {\bf RS} components and reinserting the entropy flow,
 the {\bf RT} component uses two {\bf ES} components to convert from
 true to pseudo bonds and back again. Similary, the thermal capacity is
 modelled by the {\bf CT} component.


 The rod parameters are given in the numpar file and the input current
 in the input file.

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/HeatedRod_lbl.txt version [bce0ff1c0a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY HeatedRod: Thermal/Electrical model of Electric rod
%DESCRIPTION Introduces the idea of the ES component which
%DESCRIPTION transforms a relative-temperature/enthalpy pseudo bond 
%DESCRIPTION (at the [e]port) into an absolute-temperature/enntropy 
%DESCRIPTION energy bond (at the [s] port) and vice versa.

%% Label file for system HeatedRod (HeatedRod_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RT
	r_2		lin	flow,r_2

% Component type SS
	I_r		internal	external
	T_1		t_0		internal
	T_2		t_0		internal
	V_0		0		internal

% Component type Segment
	s

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/Run version [5d09d2ea7c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# Shell script for running the large HeatedRod systems to compare
# four integration methods.
# Usage example: Run 100 0.25 runf the 100 segment example at interval 0.25

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/08/17 09:42:26  peterg
## Third argument gives the desired methods.
##
## Revision 1.2  1998/08/15 14:07:11  peterg
## Don't do ImplicitL
##
## Revision 1.1  1998/08/15 13:58:27  peterg
## Initial revision
##
###############################################################


n=$1
DT=$2

if [ -z "$n" ]; then
    echo "First argument is N: number of segments (eg 100)"
    exit
fi
if [ -z "$DT" ]; then
    echo "Second argument is DT: the sample interval (eg 0.25)"
    exit
fi
if [ -z "$3" ]; then
    METHODS='ImplicitS Euler Implicit'
else
    METHODS=$3
fi

echo "Running system HR$1 with DT = $DT"
echo "using methods $METHODS"

#Create the system
mtt -q rename HR HR$n >/dev/null
rm -f MTT_work/HR$1_state.* #Why ??

# Is it already correct?
count=`grep -c "*$n" HR$1_abg.fig`

# if not, then set the correct number of segments
if [ "$count" = "0" ]; then
    echo Setting number of segments to $n
    mv HR$1_abg.fig  HR$1_abg.old
    sed "s/\*[0-9]*/*$1/"<HR$1_abg.old>HR$1_abg.fig

    mv HR$1_numpar.txt  HR$1_numpar.old
    sed "s/segments = [0-9]*/segments = $1/"<HR$1_numpar.old >HR$1_numpar.txt

   echo "Making the default HR$1_state.txt"
   rm -f HR$1_state.txt MTT_work/HR$1_state.txt
   mtt -q  HR$1 state txt
   echo "Setting $n states to c_t*t_0"
   mv HR$1_state.txt  HR$1_state.old
   sed "s/0.0/c_t*t_0/"<HR$1_state.old >HR$1_state.txt
fi






rm -f HR$1_table.txt

#Do the methods of interest

for METHOD in $METHODS; do

case $METHOD in
    Euler)
    # What is the minimum step size for Euler?
    mtt -q HR$n numpar m
    mtt -q HR$n sm m
octave -q <<EOF >HR$1.tmp1
    HR$1_numpar;
    A=HR$1_sm;
    Max_Eig=max(eig(-A))
    STEPFACTOR=ceil( Max_Eig*$DT/2 )
EOF
    MinSTEPFACTOR=`gawk '{if ($1=="STEPFACTOR") print $3}' HR$1.tmp1`
    STEPFACTOR=$MinSTEPFACTOR
	;;
    ImplicitS)
    # What is the empirical step size for sparse method?
    octave -q <<EOF >HR$1.tmp1
    if $n>100 
      SparseSTEPFACTOR=10*$n
    else
      SparseSTEPFACTOR=5*$n
    endif
EOF
     SparseSTEPFACTOR=`gawk '{if ($1=="SparseSTEPFACTOR") print $3}' HR$1.tmp1`

		STEPFACTOR=$SparseSTEPFACTOR
	;;
    *)
		STEPFACTOR=1
	;;
esac


  echo "Doing HR$1 with DT=$DT using $METHOD (STEPFACTOR = $STEPFACTOR)"

  # Modify the simpar.txt files
  grep -v 'STEPFACTOR' HR_simpar.txt | grep -v 'METHOD' | grep -v 'DT' > HR$1_simpar.txt
  echo "STEPFACTOR = $STEPFACTOR; # Added automatically" >>HR$1_simpar.txt
  echo "METHOD = $METHOD;         # Added automatically" >>HR$1_simpar.txt
  echo "DT = $DT;                 # Added automatically" >>HR$1_simpar.txt
  mtt -q -c -o HR$1 odeso ps > junk 2>>junk #HR$1_$METHOD.tmp
  grep user junk |\
     gawk '{print System " &\t" METHOD " &\t"  DT " &\t"  STEPFACTOR " &\t" $2 "\\\\"}'\
      METHOD=$METHOD STEPFACTOR=$STEPFACTOR System=HR$1 DT=$DT >> HR$1_table.txt

  cp HR$1_odeso.ps  HR$1.$METHOD.$DT.ps
done

cat HR$1_table.txt



Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/Run_All version [2d96bc44fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# Generates the tables of timings
# PJG 17/8/98

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


Run 2	0.25	'ImplicitS Implicit Euler'
Run 10	0.25	'ImplicitS Implicit Euler'
Run 20	0.25	'ImplicitS Implicit Euler'
Run 50	0.25	'ImplicitS Implicit Euler'
Run 100	0.25	'ImplicitS Implicit Euler'
Run 200 0.25	'ImplicitS Implicit'

cat Run*_table.txt | sort

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/Segment_abg.fig version [1d5850b4e4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2835 2205 2925 2745
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 2880 2250 2880 2700
-6
6 8505 2250 8595 2790
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 8550 2295 8550 2745
-6
6 5310 6255 5400 6795
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5355 6300 5355 6750
-6
6 5805 6255 5895 6795
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 5850 6300 5850 6750
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1306 2476 2881 2476 2656 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3781 2476 5356 2476 5131 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5761 2476 8550 2475 8325 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 4276 5581 2701 5806 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 6301 5581 4726 5806 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 6525 5356 6526 5131 6751
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 6526 8550 6525 8325 6750
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 2701 6920 3815 6601 3815
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 2251 5581 676 5806 901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5356 676 5806 676
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 7425 9900 90 45 90 45 7425 9900 7425
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 1800 1575 1800 1575 4455 7650 4455
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 6975 7650 4545 1575 4545 1575 6975 7650 6975
4 1 -1 0 0 0 20 0.0000 4 240 810 3331 2566 RT:r_t\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5581 2566 0\001
4 1 -1 0 0 0 20 0.0000 4 210 555 5581 4591 RS:r\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5581 6616 1\001
4 1 -1 0 0 0 20 0.0000 4 240 840 7021 4141 CT:c_t\001
4 1 -1 0 0 0 20 0.0000 4 255 870 5581 586 SS:T_s\001
4 2 4 0 0 0 20 0.0000 4 255 1110 1261 2566 SS:[t_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1260 8685 2565 SS:[t_out]\001
4 2 4 0 0 0 20 0.0000 4 255 1155 1260 6615 SS:[e_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1305 8685 6615 SS:[e_out]\001
4 0 1 1 0 0 20 0.0000 4 210 1875 1845 4050 Thermal model\001
4 0 1 1 0 0 20 0.0000 4 210 2025 1800 5175 Electrical model\001
4 0 1 1 0 0 20 0.0000 4 255 2415 6075 585 Temperature sensor\001

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/Segment_lbl.txt version [ffb638c19b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Segment: Segment of HeatedRod
%DESCRIPTION Part of the HeatedRod example.
%% Label file for system Segment (Segment_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/08/10 12:29:48  peterg
% %% Added missing ports.
% %%
% %% Revision 1.1  1997/09/11 16:17:14  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Component type CT
	c_t		lin	effort,c_t

% Component type RS
	r		lin	flow,r

% Component type RT
	r_t		lin	flow,r_t

% Component type SS
	T_s		SS		external,0
	[t_in]		SS		external,internal
	[t_out]		SS		internal,external
	[e_in]		SS		external,internal
	[e_out]		SS		external,internal

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/examples.m version [ccb8cc8f8c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

mttdt = 1;
mttx=(zeros(200,1));
mttu=(zeros(200,1));
BigHeatedRod_numpar;
alpha = BigHeatedRod_smx(mttx,mttu,mttdt);
show_matrix (alpha);
psfig("sparsity.ps");


[N,junk] = size(alpha);
A =  eye(N) - alpha;
plot(log10(abs(eig(A))))
grid;
xlabel("i");
ylabel("e_i");
psfig("eig.ps");

Deleted mttroot/mtt/lib/examples/Simulation/BigHeatedRod/time_svdlu.m version [d2d86013f2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [N,Ts,Tl]=time_svdlu;

  N=[100:100:700];

  Ts=[]; Tl=[];
  for n=N
    n
    M=rand(n,n);
    ts=time; svd(M); ts=time-ts
    tl=time; lu(M); tl=time-tl
    Ts=[Ts,ts];
    Tl=[Tl,tl];
  endfor;

endfunction;
  

Deleted mttroot/mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_abg.fig version [ed25703b7d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 900 3150 2250 3150 2025 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 3150 4950 3150 4725 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 3150 7425 3150 7200 3375
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 5175 8550 900 45 900 45 5175 8550 5175
4 1 -1 0 0 10 20 0.0000 4 210 570 495 3240 Se:u\001
4 1 -1 0 0 10 20 0.0000 4 210 1095 2925 3240 RC:slow\001
4 1 -1 0 0 10 20 0.0000 4 210 1005 5535 3240 RC:fast\001
4 1 -1 0 0 10 20 0.0000 4 270 600 7830 3240 De:y\001

Deleted mttroot/mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_desc.tex version [a6bf3f22eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168








































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- Put EMACS into LaTeX-mode
% Verbal description for system ImplicitRC (ImplicitRC_desc.tex)
% Generated by MTT on Wednesday June 24 09:50:17 BST 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:06:50  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This report describes the \emph{implicit} integration methods
available in MTT. They are introduced to provide  simulation
of systems within the following context:
\begin{enumerate}
\item The system may be stiff with a mixture of slow and fast
  (possibly due to approximating algebraic loops) subsystems.
\item The fast parts of the response are of no interest
\item A fixed sample interval is required -- possibly for real-time
  simulation or control
\item The system is nonlinear.
\item The solution of nonlinear algebraic equations is to be avaided.
\end{enumerate}

The following sections consider the linear and nonlinear versions
respectively. The ideas are based on a standard textbook
\footnote{Press et al: \emph{Numerical Recipes in C}, 2nd edition,
  1992. Cambridge, Section 16.6}.
 

\subsection{Implicit integration - the linear case}
\label{sec:linear}

Consider the \emph{linear} system:
\begin{equation}
  \label{eq:sys}
    \dot x = A x + B u
\end{equation}

For the purposes of simulation, it can be discretised (with sample
interval $\Delta t$) in at least two
ways:
\begin{enumerate}
\item $ \dot x \approx \frac{x_{i+1} - x_{i}}{\Delta t}$
\item $ \dot x \approx \frac{x_{i} - x_{i-1}}{\Delta t}$
\end{enumerate}
The former is gives rise to the \emph{forward} Euler or \emph{explicit}
integration scheme:
\begin{equation}
   x_{i+1} =  x_{i} + \Delta t \left [ A x_{i} + B_{i} u \right ]
\end{equation}
and the latter gives rise to the \emph{backward} Euler or \emph{implicit}
integration scheme:
\begin{equation}
   x_{i} =  x_{i-1} + \Delta t \left [ A x_{i} + B_{i} u \right ]
\end{equation}
which must be rewritten as:
\begin{equation}
   x_{i} =   \left [ I -  \Delta t A \right ]^{-1} x_{i-1} + \Delta t  B_{i} u
\end{equation}
for the purposes of implementation.

The explicit method gives simple implementation whereas the implicit
method requires matrix inversion. However, the explicit method is only
stable if:
\begin{equation}
  \Delta t < \frac{2}{| \lambda |}
\end{equation}
where $\lambda$ is the \emph{largest} eigenvalue of $A$. If this
largest eigenvalue is real so $\lambda = \frac{1}{\tau}$ where $\tau$
is the \emph{smallest} system time constant:
\begin{equation}
  \Delta t < 2 \tau
\end{equation}

If the system is stiff, that is it contains at least one small time
constant relative to the dominant time constants, Euler integration is
not feasible due to the very small sample interval $\Delta t$
required.

In contrast, the implicit method is stable.


\subsubsection{Example}
   The acausal bond graph of system \textbf{ImplicitRC} is
   displayed in Figure \Ref{fig:ImplicitRC_abg.ps} and its label
   file is listed in Section \Ref{sec:ImplicitRC_lbl}
   The subsystems are listed in Section \Ref{sec:ImplicitRC_sub}.

The system represents two simple RC circuits in series with
differential equations as given in Section \Ref{sec:ImplicitRC_ode-noargs.tex} and
transfer function  as given in Section \Ref{sec:ImplicitRC_tf-noargs.tex}.

For the purposes of this example the two time constants are $1$ and
$\epsilon=10^{-3}$ -- this is a stiff system. All of the simulations
use a sample interval of $\Delta t = 0.1$ ang the input is a unit
step.  Section \Ref{sec:ImplicitRC_sro-noargs.ps} shows the exact (computed from
the matrix exponential) solution, and  Section {sec:ImplicitRC_odeso-cc.ps}
shows the solution by implicit integration.

The explicit solution is not shown, but was found to be unstable for
$\Delta t > 0.002$ as predicted.

\subsection{Implicit integration - the nonlinear case}}
\label{sec:nonlinear}

Consider the \emph{nonlinear} system:
\begin{equation}
  \label{eq:sys}
    \dot x = f(x,u)
\end{equation}
and suppose it can be linearised about any state and input to give:
\begin{equation}
  A(x,u) = \frac{\partial f(x,u)}{\partial x}
\end{equation}

The corresponding \emph{implicit} scheme is:
\begin{equation}
   x_{i} =  x_{i-1} + \Delta t f(x_{i},u_{i})
\end{equation}
This is not easy to solve in general due to the set of non-linear
equations that need to be solved. To avoid this, consider a further
approximation:
\begin{equation}
  f(x_{i},u_{i}) \approx f(x_{i-1},u_{i}) + A(x_{i-1},u_i) ( x_{i} -  x_{i-1} )
\end{equation}
This then gives the \emph{semi-implicit} scheme
\begin{equation}
  x_{i} =  x_{i-1} + \Delta t \left [  f(x_{i-1},u_{i}) + A(x_{i-1},u_i) (
    x_{i} -  x_{i-1} ) \right ]
\end{equation}
which can be rewritten as:
\begin{equation}\label{eq:implicit}
   x_{i} =  \left [ I -  \Delta t A(x_{i-1},u_i) \right ]^{-1} 
    \Delta t \left [  f(x_{i-1},u_{i}) - A(x_{i-1},u_i) x_{i-1}  \right ]
\end{equation}


Because of the approximations invoved, Equation \ref{eq:implicit} is
not guarenteed to be stable. Nevertheless, it should do a much better
job than the corresponding \emph{explicit} method for reasonably
smooth systems.
This method is chosen by setting 
\begin{verbatim}
METHOD='Implicit'
\end{verbatim}
in the MTT simpar.txt file.

A further approximation arises by setting  $A(x_{i-1},u_i) =
A(x_{0},u_0)$ ie computing it one only at the beginning of the
simulation.
This method is chosen by setting 
\begin{verbatim}
METHOD='ImplicitL'
\end{verbatim}
in the MTT simpar.txt file.

Both methods make use of the \textbf{smx} ``state-matrix with state $x$''
representation of MTT which is generated symbolically from the system
bond graph.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_lbl.txt version [e8ed754f2f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY ImplicitRC
%DESCRIPTION <Detailed description here>
%% Label file for system ImplicitRC (ImplicitRC_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RC
	fast		lin	epsilon;1
	slow		lin	1;1

% Component type SS
	u		SS	external
	y		SS	external





Deleted mttroot/mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_numpar.txt version [f5c254b34d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (ImplicitRC_numpar.txt)
# Generated by MTT at Wednesday June 24 09:21:23 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:06:50  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
epsilon = 	1e-3; # ImplicitRC
## Removed by MTT on Sun Aug 17 13:59:26 BST 2003: ## Removed by MTT on Sun Aug 17 13:59:26 BST 2003: c =		1.0;
## Removed by MTT on Sun Aug 17 13:59:26 BST 2003: r =		1.0;

Deleted mttroot/mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_rep.txt version [13bcda6c54].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system ImplicitRC (ImplicitRC_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2003/08/17 17:03:02  gawthrop
% %% Updated for new MTT
% %%
% %% Revision 1.1  2000/12/28 18:06:50  peterg
% %% To RCS
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt ImplicitRC abg tex
mtt ImplicitRC struc tex
mtt ImplicitRC ode tex
mtt ImplicitRC sm tex
mtt ImplicitRC sm m
mtt ImplicitRC tf tex

mtt ImplicitRC sro ps

mtt ImplicitRC numpar tex

mtt ImplicitRC simpar tex
mtt ImplicitRC odeso ps

Deleted mttroot/mtt/lib/examples/Simulation/ImplicitRC/ImplicitRC_simpar.txt version [8d36b2a6d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system ImplicitRC (ImplicitRC_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/08/12 13:29:02  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=10.0
DT=0.1
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Simulation/ImplicitRC/examples.sh version [4fe342f5cf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

mv ImplicitRC_simpar.txt SAVE
Delta="0.01 0.2 1.0"
for delta in $Delta; do
    echo Doing with sample interval = $delta

    cp SAVE ImplicitRC_simpar.txt 
cat <<EOF >>ImplicitRC_simpar.txt 
DT=$delta
EOF
    mtt -q ImplicitRC odeso dat
    cp ImplicitRC_odeso.dat ImplicitRC_odeso.$delta
done

gnuplot <<EOF 
set term postscript
set output "ImplicitRC.ps"
set grid
plot "ImplicitRC_odeso.0.01" with lines, \
     "ImplicitRC_odeso.0.2" with linespoints, \
     "ImplicitRC_odeso.1.0" with linespoints
EOF
mv SAVE ImplicitRC_simpar.txt 

ghostview ImplicitRC.ps

mv ImplicitRC.ps ../../Figs

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Fuel_abg.fig version [91a602d65e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6303 2703 6303 3844 6528 3619
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 1128 6301 2269 6526 2044
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 2475 7425 2475 7200 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6075 2250 6525 2250
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6525 2250 6525 2700
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12377 4725 12377 225 450 225 450 4725 12377 4725
4 1 -1 0 0 22 20 0.0000 4 210 765 6300 990 Se:T3\001
4 0 -1 0 0 22 20 0.0000 4 210 1035 7605 2565 Df:Heat\001
4 1 -1 0 0 22 20 0.0000 4 210 390 6255 2565 PS\001
4 0 4 0 0 2 12 0.0000 4 180 630 6660 2385 [power]\001
4 1 4 100 0 18 18 0.0000 4 270 1065 6390 4185 SS:[out]\001

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Fuel_lbl.txt version [ea89d593a7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Fuel (Fuel_lbl.txt)
%SUMMARY Fuel
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	Heat
%ALIAS	$2	T3

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type Df
 	Heat	SS		external

% Component type SS
	[out]	SS		external,external

% Component type Se
	T3	SS		external

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/In_abg.fig version [7eb82b8438].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 2253 3198 2253 3018 2433
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3196 2026 3196 2476
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5400 5625 5400 1530 675 1530 675 5625 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3195 4725 3195 5175
4 0 4 0 0 0 20 0.0000 4 255 1440 3332 5042 SS:[Hy_out]\001
4 0 4 0 0 0 20 0.0000 4 255 1425 3377 2342 SS:[Th_out]\001
4 2 -1 0 0 0 20 0.0000 4 255 1095 2026 2341 SS:Th_in\001
4 2 -1 0 0 0 20 0.0000 4 255 1110 2071 5041 SS:Hy_in\001

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/In_desc.tex version [0c97485c1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/In_lbl.txt version [b98a7bad58].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY In: Inflow conditions
%DESCRIPTION <Detailed description here>
%ALIAS	in|out Th_out,Hy_out
%% Label file for system In (In_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/07/04 09:41:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hy_out]	SS	external,external
	[Th_out]	SS	external,external
	Hy_in		SS	p_1,internal
	Th_in		SS	t_1,internal

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Load_abg.fig version [f6adaf70fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 900 2700 2250 2925 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2700 2700 2700 4050 2925 3825
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4050 2475 5400 2475 5175 2700
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6795 5175 6795 225 1350 225 1350 5175 6795 5175
4 1 4 0 0 22 20 0.0000 4 270 900 2745 720 SS:[in]\001
4 1 -1 0 0 22 20 0.0000 4 210 2325 2880 2565 PS:PowerSensor\001
4 1 4 0 0 22 20 0.0000 4 270 420 2385 2250 [in]\001
4 1 4 0 0 22 20 0.0000 4 270 615 2385 2835 [out]\001
4 1 4 0 0 22 20 0.0000 4 270 1035 3735 2250 [power]\001
4 1 -1 0 0 22 20 0.0000 4 210 1095 6030 2565 Df:Work\001
4 1 -1 0 0 22 20 0.0000 4 270 630 2655 4410 R:r_l\001

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Load_lbl.txt version [cd55430fc2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Load (Load_lbl.txt)
%SUMMARY Load
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in

% Argument aliases
%ALIAS	$1	r_l

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----


	PowerSensor			

% Component type Df
	Work	SS		external

% Component type R
	r_l	lin		flow,r_l

% Component type SS
	[in]	SS		external,external

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Out_abg.fig version [34cc41cc19].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 5400 5625 5400 1530 675 1530 675 5625 5400 5625
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2205 2250 3150 2250 2970 2430
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 2250 2250 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 1980 2250 2250
4 0 -1 0 0 0 20 0.0000000 4 240 1290 3465 2340 SS:Th_out\001
4 0 -1 0 0 0 20 0.0000000 4 270 1320 3375 5040 SS:Hy_out\001
4 2 4 0 0 0 20 0.0000000 4 270 1380 2160 5040 SS:[Hy_in]\001
4 2 4 0 0 0 20 0.0000000 4 240 1350 2115 2340 SS:[Th_in]\001

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Out_desc.tex version [3dd57dc573].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Out_lbl.txt version [19b6550ba8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Out: Outflow conditions
%DESCRIPTION <Detailed description here>
%ALIAS	in  Th_in,Hy_in
%% Label file for system Out (Out_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type SS
	[Hy_in]		SS	external,external
	[Th_in]		SS	external,external
	Hy_out		SS	p_1,internal
	Th_out		SS	t_1,internal

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Shaft_abg.fig version [598a000ebe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 1620 2700 2970 2700 2745 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2700 4725 2700 4500 2925
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2925 3150 4275 3375 4050
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3150 2475 3150 1125 3375 1350
2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5
	 6075 4950 6075 450 450 450 450 4950 6075 4950
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 3375 2475 4330 1520 4330 1839
4 1 0 100 0 18 18 0.0000 4 195 150 3150 2790 1\001
4 1 0 100 0 18 18 0.0000 4 270 540 3150 990 I:j_s\001
4 1 4 100 0 18 18 0.0000 4 270 870 1170 2790 SS:[in]\001
4 1 4 100 0 18 18 0.0000 4 270 1065 5310 2790 SS:[out]\001
4 1 4 100 0 18 18 0.0000 4 270 1215 3195 4680 SS:[load]\001
4 1 0 100 0 18 18 0.0000 4 270 1245 4455 1395 Df:speed\001

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/Shaft_lbl.txt version [93c7018fae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system Shaft (Shaft_lbl.txt)
%SUMMARY Shaft
%DESCRIPTION 

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in	in
%ALIAS	load	load
%ALIAS	out	out

% Argument aliases
%ALIAS	$1	j_s

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----
	speed	SS		external

% Component type I
	j_s	lin		flow,j_s

% Component type SS
	[in]	SS		external,external
	[load]	SS		external,external
	[out]	SS		external,external

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_abg.fig version [9abd037150].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6078 1803 6078 2944 6303 2719
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4230 3375 5584 3375 5359 3600
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6750 3375 8104 3375 7879 3600
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1575 3375 2704 3375 2479 3600
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9450 3375 10579 3375 10354 3600
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4
	 8550 3870 8550 5850 6975 5850 7200 6075
2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4
	 5175 5850 3375 5850 3375 3825 3600 4050
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6075 6284 6075 7425 6300 7200
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12152 8550 12152 675 225 675 225 8550 12152 8550
4 1 4 0 0 2 12 0.0000 4 180 540 8510 3740 [Shaft]\001
4 1 4 0 0 2 12 0.0000 4 180 540 3379 3739 [Shaft]\001
4 1 1 1 0 2 30 0.0000 4 300 210 2162 3017 1\001
4 1 1 1 0 2 30 0.0000 4 300 210 4817 3017 2\001
4 1 1 1 0 2 30 0.0000 4 300 210 7292 3017 3\001
4 1 1 1 0 2 30 0.0000 4 300 210 9947 3017 4\001
4 1 4 0 0 2 12 0.0000 4 180 540 6078 3198 [Heat]\001
4 1 -1 0 0 22 20 0.0000 4 210 570 1217 3467 In:in\001
4 1 -1 0 0 2 20 0.0000 4 195 1050 6167 3467 Comb:c1\001
4 0 -1 0 0 22 20 0.0000 4 210 1005 10758 3468 Out:out\001
4 1 -1 0 0 2 20 0.0000 4 255 1455 3469 3469 Pump:comp\001
4 1 -1 0 0 2 20 0.0000 4 255 1335 8780 3470 Pump:turb\001
4 1 4 0 0 2 12 0.0000 4 180 465 6075 6165 [load]\001
4 1 -1 0 0 22 20 0.0000 4 210 1500 6078 5943 Shaft:shaft\001
4 1 -1 0 0 22 20 0.0000 4 210 1380 6075 7740 Load:load\001
4 1 1 1 0 3 25 0.0000 4 270 1425 6030 8145 Work out\001
4 1 -1 0 0 22 20 0.0000 4 210 1185 6030 1665 Fuel:fuel\001
4 1 1 1 0 3 25 0.0000 4 270 1140 5985 1215 Heat in\001

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_desc.tex version [3351a658e2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123



























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system SimpleGasTurbine (SimpleGasTurbine_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/05/18 15:45:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{SimpleGasTurbine} is
   displayed in Figure \Ref{SimpleGasTurbine_abg} and its label
   file is listed in Section \Ref{sec:SimpleGasTurbine_lbl}.
   The subsystems are listed in Section \Ref{sec:SimpleGasTurbine_sub}.
   
   \textbf{SimpleGasTurbine} can be regarded as an single-spool gas
   turbine (producing shaft power) with an ideal-gas working fluid. It
   corresponds to the simple Joule Cycle as described in Chapter 12 of
   Rogers and Mayhew and in Chapter 2 of Cohen, Rogers and
   Saravanamutto. However, unlike those examples, the system is
   written with dynamics in mind.
   
   The system is described using an energy Bond Graph- this ensures
   that the first law is observed. In particular transformers are used
   to explicitly convert between energy covariables. Although this is
   a simple model, I believe that it provides the basis for building
   complex thermodynamic systems involving gas power cycles.


There are five main components:
\begin{enumerate}
\item p1 -- a \textbf{Pump} component representing the compressor
  stage. This converts shaft work to energy flow in the working fluid.
\item c1 -- a \textbf{Comb} component representing the combustion
  chamber. This converts the heat obtained by burning fuel to energy
  flow in the working fluid.
\item t1 -- a \textbf{Turb} component representing the turbine
  component. This converts the energy flow in the working fluid to
  shaft work
\item j\_s -- an \textbf{I} component representing the combined inertia
  of the shaft and compressor and turbine rotors.
\item a \textbf{Load} component to absorb the shaft power.
\end{enumerate}
The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

Both \textbf{Pump} and \textbf{Turb} are implemented with the
\emph{polytropic} constitutive relationship with index $n$. When
$n=\gamma=\frac{c_p}{c_v}$ this corresponds to isentropic compression
and expansion and thus the \textbf{SimpleGasTurbine} achieves its
cycle efficiency. However, other values of $n$ can be used to account
for isentropic efficiency of less than unity.

To obtain a very simple dynamic model (and to avoid the need for an
accurate combustion chamber model) there are no dynamics associated
with the combustion chamber, but rahter it is assumed that the
corresponding temperature is imposed on the component (that is $T_3$
is the system input) the corresponding heat flow is then an output.

Both heat input and work output are measured using the \textbf{PS}
(power sensor) component, that for work output is embedded in the
\textbf{Load} component. These can be monitored to give the efficiency
of the \textbf{SimpleGasTurbine}.

A symbolic steady-state for the model was computed -- see Section
\ref{sec:SimpleGasTurbine_ss.tex}. In particular, the load
resistance was chosen to absorb all the generated work at the steady
state and the shaft inertia was chosen to give a unit time constant
for the linearised system. The mass flow and shaft speeds were taken
as unity.

For the purposed of simulation, the numerical values given in Examples
12.1 of Chapter 12 of Rogers and Mayhew, except that the isentropic
efficiencies are 100\% ($n=\gamma$) -- see Section
\ref{sec:SimpleGasTurbine_numpar.tex}.

Simulations were performed starting at the steady state and increasing
the combustion chamber temperature by 10\% at $t=1$ and reducing by
10\% at $t=5$. Graphs of the various outputs are plotted:
\begin{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-comp-1-T,SimpleGasTurbine-c1-1-T,SimpleGasTurbine-turb-1-T.ps}
  -- the temperatures at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-fuel-1-Heat-1-y,SimpleGasTurbine-load-1-Work-1-y.ps}
  -- the heat input and work output
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-shaft-1-speed-1-y.ps} -- the shaft speed and
\item Figure
  \Ref{fig:SimpleGasTurbine_odeso-SimpleGasTurbine-c1-1-P.ps}
  -- the pressure at the output of the
  \begin{itemize}
  \item compressor,
  \item combustion chamber and
  \item turbine
  \end{itemize}
\end{itemize}

This model can be modified extended in various ways to yield related
dynamic systems. For example:
\begin{itemize}
\item an air cooler is obtained by changing the direction of heat and
  work flows
\item additional \textbf{Turb} and \textbf{Comb} components add reheat
  to the cycle
\item an isentropic nozzle can be added and the work output removed
  to give a jet engine.
\end{itemize}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_input.txt version [74f8083ef6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (SimpleGasTurbine_input.txt)
# Generated by MTT at Tue Mar 31 12:38:39 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:08:28  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

t_3 = 1000;

# Set the inputs
## Removed by MTT on Mon Nov 27 15:18:54 GMT 2000: u(1) =	 t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); # SimpleGasTurbine (T3)
## Removed by MTT on Wed Jun 11 15:42:11 BST 2003: simplegasturbine_fuel_1_t3_1_u	= t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); 

simplegasturbine__fuel__t3__u	= t_3 + 0.1*t_3*(t>1) -  0.2*t_3*(t>5); 

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_lbl.txt version [ae2470155f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY SimpleGasTurbine: single-spool gas turbine producing shaft power
#DESCRIPTION SimpleGasTurbine can be regarded as an single-spool gas
#DESCRIPTION turbine (producing shaft power) with an ideal-gas working fluid. It
#DESCRIPTION corresponds to the simple Joule Cycle as described in Chapter 12 of
#DESCRIPTION Rogers and Mayhew and in Chapter 2 of Cohen, Rogers and
#DESCRIPTION Saravanamutto. However, unlike those examples, the system is
#DESCRIPTION written with dynamics in mind.

## Explicitly copy appropriate components
#ALIAS	Pump	CompressibleFlow/Pump
#ALIAS	Comb	CompressibleFlow/Comb

#PAR t_2
#PAR t_3
#PAR t_4
#PAR p_2
#PAR p_3
#PAR p_4
#PAR mdot
#PAR gamma_0
#PAR q_0
#PAR w_0
#PAR omega_0
#PAR r_p
#PAR c_p
#PAR mom_0

#NOTPAR 	density
#NOTPAR	ideal_gas
#NOTPAR	q_0

## Label file for system SimpleGasTurbine (SimpleGasTurbine_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.5  2000/12/28 18:08:28  peterg
# ## To RCS
# ##
# ## Revision 1.4  1998/07/30 15:27:42  peterg
# ## Use #VAR inplace of dummy component.
# ##
# ## Revision 1.3  1998/07/03 14:54:45  peterg
# ## k_p --> k
# ## k_t --> k
# ##
# ## Revision 1.2  1998/07/03 14:53:38  peterg
# ## Renames tank to comb to be consistent.
# ##
# ## Revision 1.1  1998/05/18 15:46:02  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank

# Component type Fuel
	fuel

# Component type In
	in

# Component type Pump
	comp		none		c_v;density,ideal_gas,r;alpha;effort,k

# Component type Comb
	c1		none		m_c;v_c;r

# Component type Pump
	turb		none		c_v;density,ideal_gas,r;alpha;effort,k

# Component type Out
	out

# Component type Shaft
        shaft		none		j_s

# Component type Load
	load		none		r_l







Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_numpar.txt version [9ec8ae8fc7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (SimpleGasTurbine_numpar.txt)
# Generated by MTT at Tue Mar 31 12:15:00 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:08:28  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_p = 	1005.0;
c_v = 	718.0; 
gamma_0 =  c_p/c_v;
alpha = (gamma_0-1)/gamma_0;
k = 	1.0;
p_1 = 	1e5; # 1 bar
p_4 = 	p_1; 
r = 	c_p-c_v;
t_1 = 	288.0; # In
v_c = 	1.0;

%Set the CC pressure and temperature
t_3 = 1000.0;
r_p = 6.0;
p_3 = r_p*p_1;

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c = (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 = p_1;
p_2 = p_3;

%Compute ss temperatures (isentropic)
t_2 = t_1*pow((p_2/p_1),alpha);
t_4 = t_3*pow((p_4/p_3),alpha);

%Find the steady-state work output
w_0 = c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Unit mass flow
mdot = 1;

%Corresponding shaft speed
omega_0 = mdot/k;

%Compute the corresponding load resistance (to absorb that work)
r_l = w_0/pow((omega_0),2);

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s = r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 =  omega_0*j_s;

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_rep.txt version [906aa92cc8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system SimpleGasTurbine (SimpleGasTurbine_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  2003/06/11 16:10:37  gawthrop
% %% Updated examples for latest MTT.
% %%
% %% Revision 1.2  2000/12/28 18:08:28  peterg
% %% To RCS
% %%
% %% Revision 1.1  2000/11/27 18:16:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss SimpleGasTurbine abg tex
mtt -o -ss SimpleGasTurbine struc tex
mtt -o -ss SimpleGasTurbine sympar tex
mtt -o -ss SimpleGasTurbine ode tex

mtt -o -ss SimpleGasTurbine sspar r
mtt -o -ss SimpleGasTurbine ss tex
mtt -o -ss SimpleGasTurbine sm tex

mtt -o -ss SimpleGasTurbine numpar tex
mtt -o -ss SimpleGasTurbine input tex
mtt -o -ss SimpleGasTurbine state tex
mtt -o -ss SimpleGasTurbine simpar tex
mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine__comp__T,SimpleGasTurbine__c1__T,SimpleGasTurbine__turb__T'

mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine_fuel_1_Heat_1_y,SimpleGasTurbine_load_1_Work_1_y'

mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine_shaft_1_speed_1_y'

mtt -o -ss SimpleGasTurbine odeso ps 'SimpleGasTurbine_c1_1_P'





Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_simp.r version [81a3a4cecb].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
%% Reduce commands to simplify output for system SimpleGasTurbine (SimpleGasTurbine_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LET c_v = c_p - r;
END;

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_sspar.r version [36ca0ccda1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (SimpleGasTurbine_sspar.r)
% Generated by MTT at Thu Mar 26 16:28:59 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 18:08:28  peterg
% % To RCS
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Find stored mass to give combustion chamber pressure p_3 (at
% temperature t_3
m_c := (p_3*v_c)/(t_3*r);

%Equate pressures
p_4 := p_1;
p_2 := p_3;

%Compute ss temperatures (isentropic)
t_2 := t_1*pow((p_2/p_1),alpha);
t_4 := t_3*pow((p_4/p_3),alpha);

%Find the steady-state work output
w_0 := c_p*(t_3-t_4) - c_p*(t_2-t_1);

%Compute the corresponding load resistance (to absorb that work)
r_l := w_0/pow((omega_0),2);

%Unit mass flow
mdot := 1;

%Corresponding shaft speed
omega_0 := mdot/k;

%Compute shaft inertia to give unit time constant (j_s*r_l)
j_s := r_l;

%Find angular momentum to give shaft speed omega_0
mom_0 :=  omega_0*j_s;

% Steady-state states
MTTX1 := 	mom_0;

% Steady-state inputs - combustion temperature
MTTU1 := 	t_3; % SimpleGasTurbine (T3)

;;END;

Deleted mttroot/mtt/lib/examples/Thermal/GasTurbines/SimpleGasTurbine/SimpleGasTurbine_state.txt version [c5243379dd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# State initialisation file (SimpleGasTurbine_state.txt)
# Generated by MTT at Tue Mar 31 12:37:17 BST 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:08:28  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Set the states
## Removed by MTT on Mon Nov 27 15:20:21 GMT 2000: x(1) =	 j_s/k ; # SimpleGasTurbine (j_s)

## Removed by MTT on Wed Jun 11 15:41:26 BST 2003: simplegasturbine_shaft_1_j_s	= j_s/k ;
simplegasturbine__shaft__j_s	= j_s/k;

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPipe/TestPipe_abg.fig version [546701647b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 1351 4051 1351 3826 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4051 1126 4051 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2702 4052 2702 3827 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 2702 6976 2702 6751 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 1351 6976 1351 6751 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 3375 8550 405 450 405 450 3375 8550 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 2475 4050 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2475 4950 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 1125 4950 1575
4 2 4 0 0 0 20 0.0000000 4 240 930 4096 991 [Th_in]\001
4 2 -1 0 0 22 20 0.0000000 4 285 1065 1936 1441 SS:Th_in\001
4 2 -1 0 0 22 20 0.0000000 4 285 1080 1937 2792 SS:Hy_in\001
4 2 4 0 0 0 20 0.0000000 4 270 960 4097 2342 [Hy_in]\001
4 0 -1 0 0 22 20 0.0000000 4 285 1215 7111 1441 SS:Th_out\001
4 0 4 0 0 0 20 0.0000000 4 240 1080 4951 991 [Th_out]\001
4 0 4 0 0 0 20 0.0000000 4 270 1110 4951 2342 [Hy_out]\001
4 0 -1 0 0 22 20 0.0000000 4 285 1230 7111 2792 SS:Hy_out\001
4 1 -1 0 0 22 20 0.0000000 4 285 1110 4545 1980 Pipe:pipe\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPipe/TestPipe_lbl.txt version [151ff03f63].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TestPipe
%DESCRIPTION <Detailed description here>
%% Label file for system TestPipe (TestPipe_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/11/20 08:02:53  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS Pipe IncompressibleFlow/Pipe

% Component type Pipe
	pipe		lin		rho;c_p;lin,r

% Component type SS
	Hy_in		SS	external,external
	Hy_out		SS	external,external
	Th_in		SS	external,external
	Th_out		SS	external,external

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPipe/TestPipe_rep.txt version [864bebdd7e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TestPipe (TestPipe_rep.txt)
# Generated by MTT on" Fri Nov 20 08:16:40 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt TestPipe abg tex			# The system description
mtt TestPipe cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
mtt TestPipe struc tex	        # The system structure
mtt TestPipe dae tex	        # The system dae
# mtt TestPipe ode tex	        # The system ode 
# mtt TestPipe sspar tex		# Steady-state parameters
# mtt TestPipe ss tex 		# Steady state
# mtt TestPipe dm tex			# Descriptor matrices (of linearised system)
# mtt TestPipe sm tex			# State matrices (of linearised system)
# mtt TestPipe tf tex			# Transfer function (of linearised system)
# mtt TestPipe lmfr ps		# log modulus of frequency response (of linearised system)
# mtt TestPipe simpar tex		# Simulation parameters
# mtt TestPipe numpar tex		# Numerical simulation parameters
# mtt TestPipe input tex		# Simulation input
# mtt TestPipe odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPump/TestPump_abg.fig version [1e77e038d9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 1351 4051 1351 3826 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2702 4052 2702 3827 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 2702 6976 2702 6751 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 1351 6976 1351 6751 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 3375 8550 405 450 405 450 3375 8550 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4500 4500 2475 4725 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4275 4500 4725 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 2475 4050 2925
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2476 4950 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 1125 4950 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 1125 4050 1575
4 2 4 0 0 0 20 0.0000 4 255 870 4096 991 [Th_in]\001
4 2 -1 0 0 22 20 0.0000 4 270 1200 1936 1441 SS:Th_in\001
4 2 -1 0 0 22 20 0.0000 4 270 1245 1937 2792 SS:Hy_in\001
4 0 -1 0 0 22 20 0.0000 4 270 1395 7111 1441 SS:Th_out\001
4 0 4 0 0 0 20 0.0000 4 255 1020 4951 991 [Th_out]\001
4 0 -1 0 0 22 20 0.0000 4 270 1440 7111 2792 SS:Hy_out\001
4 2 4 0 0 0 20 0.0000 4 255 885 3735 2565 [Hy_in]\001
4 0 4 0 0 0 20 0.0000 4 255 1035 5355 2565 [Hy_out]\001
4 1 4 0 0 0 20 0.0000 4 240 810 4545 2340 [Shaft]\001
4 1 -1 0 0 22 20 0.0000 4 210 1200 4500 4815 SS:Shaft\001
4 1 -1 0 0 22 20 0.0000 4 270 1740 4545 1980 lPump:pump\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPump/TestPump_lbl.txt version [0beeb5c1ed].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TestPump: test of incompressible-flow pump component
%DESCRIPTION
%% Label file for system TestPump (TestPump_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.5  1998/11/20 13:00:27  peterg
% %% Replaces Pump by lPump in ALIAS
% %%
% %% Revision 1.4  1998/11/20 08:31:24  peterg
% %% Fixed alias error
% %%
% %% Revision 1.3  1998/11/20 08:28:41  peterg
% %% Tidied
% %%
% %% Revision 1.2  1998/11/20 08:09:57  peterg
% %% Added alias for Pump
% %%
% %% Revision 1.1  1998/11/20 08:06:28  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS lPump IncompressibleFlow/lPump


% Component type lPump
	pump		lin;lin		rho;c_p;flow,r_p;k_p;flow,r_l

% Component type SS
	Hy_in		SS	external,external
	Hy_out		SS	external,external
	Shaft		SS	external,external
	Th_in		SS	external,external
	Th_out		SS	external,external

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestPump/TestPump_rep.txt version [a84c161cd8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TestPump (TestPump_rep.txt)
# Generated by MTT on" Fri Nov 20 08:19:56 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt TestPump abg tex			# The system description
mtt TestPump cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
mtt TestPump struc tex	        # The system structure
#mtt TestPump dae tex	        # The system dae
mtt TestPump ode tex	        # The system ode 
# mtt TestPump sspar tex		# Steady-state parameters
# mtt TestPump ss tex 		# Steady state
# mtt TestPump dm tex			# Descriptor matrices (of linearised system)
# mtt TestPump sm tex			# State matrices (of linearised system)
# mtt TestPump tf tex			# Transfer function (of linearised system)
# mtt TestPump lmfr ps		# log modulus of frequency response (of linearised system)
# mtt TestPump simpar tex		# Simulation parameters
# mtt TestPump numpar tex		# Numerical simulation parameters
# mtt TestPump input tex		# Simulation input
# mtt TestPump odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestTank/TestTank_abg.fig version [39fee160b3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 1351 4051 1351 3826 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2027 2702 4052 2702 3827 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 2702 6976 2702 6751 2927
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4951 1351 6976 1351 6751 1576
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8550 3375 8550 405 450 405 450 3375 8550 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2025 1125 2025 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 1126 6975 1576
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 2476 6975 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2025 2476 2025 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4502 4500 4502 2475 4727 2700
4 2 4 0 0 0 20 0.0000000 4 240 930 4096 991 [Th_in]\001
4 2 -1 0 0 22 20 0.0000000 4 285 1065 1936 1441 SS:Th_in\001
4 2 -1 0 0 22 20 0.0000000 4 285 1080 1937 2792 SS:Hy_in\001
4 0 -1 0 0 22 20 0.0000000 4 285 1215 7111 1441 SS:Th_out\001
4 0 4 0 0 0 20 0.0000000 4 240 1080 4951 991 [Th_out]\001
4 0 -1 0 0 22 20 0.0000000 4 285 1230 7111 2792 SS:Hy_out\001
4 1 -1 0 0 22 20 0.0000000 4 225 1140 4545 1980 Tank:tank\001
4 1 4 0 0 0 20 0.0000000 4 240 1170 4590 2295 [Heat_in]\001
4 2 4 0 0 0 20 0.0000000 4 270 960 3915 2565 [Hy_in]\001
4 0 4 0 0 0 20 0.0000000 4 270 1110 5130 2565 [Hy_out]\001
4 1 -1 0 0 0 20 0.0000000 4 240 1590 4500 4860 SS:[Heat_in]\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestTank/TestTank_lbl.txt version [f62d6e747b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY TestTank: Equations for incompressible-flow Tank component
%DESCRIPTION
%% Label file for system TestTank (TestTank_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/11/20 08:36:30  peterg
% %% Corrected alias
% %%
% %% Revision 1.2  1998/11/20 08:09:20  peterg
% %% Added alias for Tank
% %%
% %% Revision 1.1  1998/11/20 08:07:20  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS Tank IncompressibleFlow/Tank

% Component type SS
	Heat_in		SS	external,external
	Hy_in		SS	external,external
	Hy_out		SS	external,external
	Th_in		SS	external,external
	Th_out		SS	external,external

% Component type Tank
	tank		none		rho;c_p;c

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Components/TestTank/TestTank_rep.txt version [92aadf89bd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system TestTank (TestTank_rep.txt)
# Generated by MTT on" Fri Nov 20 08:11:01 GMT 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

mtt TestTank abg tex			# The system description
mtt TestTank cbg ps 		        # The causal bond graph
# Uncomment the following lines or add others
mtt TestTank struc tex	        # The system structure
# mtt TestTank dae tex	        # The system dae
mtt TestTank ode tex	        # The system ode 
# mtt TestTank sspar tex		# Steady-state parameters
# mtt TestTank ss tex 		# Steady state
# mtt TestTank dm tex			# Descriptor matrices (of linearised system)
# mtt TestTank sm tex			# State matrices (of linearised system)
# mtt TestTank tf tex			# Transfer function (of linearised system)
# mtt TestTank lmfr ps		# log modulus of frequency response (of linearised system)
# mtt TestTank simpar tex		# Simulation parameters
# mtt TestTank numpar tex		# Numerical simulation parameters
# mtt TestTank input tex		# Simulation input
# mtt TestTank odeso ps		# Simulation output

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/In_abg.fig version [991e0796f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 2253 3198 2253 3018 2433
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3196 2026 3196 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3195 4725 3195 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 4950 4547 4950 4367 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 2250 4547 2250 4367 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 5670 7200 1530 675 1530 675 5670 7200 5670
4 2 -1 0 0 0 20 0.0000 4 255 1095 2026 2341 SS:Th_in\001
4 2 -1 0 0 0 20 0.0000 4 255 1110 2071 5041 SS:Hy_in\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3376 5041 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3376 2341 0\001
4 0 4 0 0 0 20 0.0000 4 255 2235 4727 5042 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 255 2085 4772 2342 SS:[Thermal_out]\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/In_desc.tex version [0c97485c1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/In_lbl.txt version [3db8aa0e33].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY In: Inflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system In (In_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	out Thermal_out,Hydraulic_out
%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out



% Component type SS
	Hy_in			SS	p_0,external
	Th_in			SS	t_0,external
	[Hydraulic_out]		SS	external,external
	[Thermal_out]		SS	external,external

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_abg.fig version [1fdbc1249e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6302 1127 6302 2252 6527 2027
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6077 1127 6527 1127
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9495 2700 10534 2703 10309 2928
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 6075 5175 3600 5175 3600 3150 3849 3399
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6076 5401 6526 5401
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 4950 6300 4050 6525 4275
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 4
	 8775 3150 8775 5175 6525 5175 6750 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6301 6299 6301 5399 6526 5624
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3060 2700 2835 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4497 2698 5715 2700 5490 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6930 2700 8145 2700 7920 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 7200 11925 225 900 225 900 7200 11925 7200
4 1 4 0 0 2 16 0.0000 4 210 750 3602 3062 [Shaft]\001
4 1 4 0 0 2 16 0.0000 4 225 1005 6302 2477 [Heat_in]\001
4 1 4 0 0 2 16 0.0000 4 210 750 8733 3063 [Shaft]\001
4 1 -1 0 0 2 20 0.0000 4 255 1185 3737 2792 lPump:p1\001
4 1 -1 0 0 22 20 0.0000 4 210 1110 6257 1037 SS:Heat\001
4 1 -1 0 0 22 20 0.0000 4 195 150 6301 5266 1\001
4 1 -1 0 0 22 20 0.0000 4 210 1170 6391 6751 SS:Work\001
4 1 -1 0 0 22 20 0.0000 4 270 555 6300 3915 I:j_s\001
4 1 -1 0 0 2 20 0.0000 4 195 1065 6302 2792 Tank:C1\001
4 1 -1 0 0 2 20 0.0000 4 255 1140 8868 2793 lPump:t1\001
4 1 -1 0 0 22 20 0.0000 4 210 570 1620 2790 In:in\001
4 1 -1 0 0 22 20 0.0000 4 210 1005 11116 2791 Out:out\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_desc.tex version [4d57456af9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system LiquidTurbine (LiquidTurbine_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{LiquidTurbine} is
   displayed in Figure \Ref{LiquidTurbine_abg} and its label
   file is listed in Section \Ref{sec:LiquidTurbine_lbl}.
   The subsystems are listed in Section \Ref{sec:LiquidTurbine_sub}.

\textbf{LiquidTurbine} can be regarded as a single-spool gas turbine
with an incompressible working fluid. Of course, such a device cannot
convert heat to work; however, it provides a useful first step towards
modelling a gas turbine.

There are three main components:
\begin{enumerate}
\item p1 -- a leaky pump \textbf{lPump} component. This is analogous
  to the gas turbine compressor.
\item c1 -- a tank \textbf{Tank} component. This is analogous
  to the gas turbine combustion chamber.
\item t1 -- a leaky turbine \textbf{lTurb} component. This is analogous
  to the gas turbine turbine.
\end{enumerate}
The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_lbl.txt version [e86e85fc85].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY LiquidTurbine
%DESCRIPTION <Detailed description here>
%% Label file for system LiquidTurbine (LiquidTurbine_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ALIAS	lPump	IncompressibleFlow/lPump
%ALIAS	Tank	IncompressibleFlow/Tank

%VAR p_0
%VAR q_0
%VAR t_0


%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

% Component type I
	j_s		lin		flow,j_s

% Component type Pump
	p1		lin;lin		rho;c_p;flow,r_p;k_p;flow,r_pl

% Component type SS
	Heat		SS	external,external
	Work		SS	external,external

% Component type Turb
	t1		lin;lin		rho;c_p;flow,r_t;k_t;flow,r_tl

% Component type Tank
	C1		none		rho;c_p;c_t

% Component type In
	in

% Component type Out
	out

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_numpar.txt version [e0fc2ac7f4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (LiquidTurbine_numpar.txt)
# Generated by MTT at Mon Mar  9 09:16:28 GMT 1998

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:11:16  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_p = 	1.0; # LiquidTurbine
c_t = 	1.0; # LiquidTurbine
j_s = 	1.0; # LiquidTurbine
k_p = 	1.0; # LiquidTurbine
k_t = 	1.0; # LiquidTurbine
p_0 = 	1e5; # In,Out
q_0 = 	1e5; # Heat in 
r_p = 	1.0; # LiquidTurbine
r_pl = 	100.0; # LiquidTurbine
r_t = 	1.0; # LiquidTurbine
r_tl = 	100.0; # LiquidTurbine
rho = 	1.0; # LiquidTurbine
t_0 = 	300.0; # In,Out

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_rep.txt version [4a1d6d995c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system LiquidTurbine (LiquidTurbine_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/21 23:50:25  peterg
% %% Use compiled version
% %%
% %% Revision 1.1  1999/02/21 02:13:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss LiquidTurbine abg tex
mtt -o -ss LiquidTurbine struc tex
mtt -o -ss LiquidTurbine sympar tex
mtt -o -ss LiquidTurbine ss tex
mtt -o -ss LiquidTurbine ode tex


mtt -o -ss LiquidTurbine numpar txt
mtt -o -ss LiquidTurbine input txt

mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__Heat'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__Work'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__in__Hy_in'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__out__Hy_out'
mtt -o -ss LiquidTurbine odeso ps 'LiquidTurbine__out__Th_out'

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/LiquidTurbine_sspar.r version [d37fe0362d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (LiquidTurbine_sspar.r)
% Generated by MTT at Fri Nov 20 11:42:16 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 18:11:16  peterg
% % To RCS
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	1; % LiquidTurbine (j_s)
MTTX2 := 	p_0*c_t/rho; % LiquidTurbine_C1 (tank) - pressure = p0
MTTX3 := 	t_0*p_0*c_t*c_p; % LiquidTurbine_C1 (tank) - temp = t0
% Steady-state inputs
MTTU1 := 	q_0; % LiquidTurbine (Heat)
MTTU2 := 	0; % LiquidTurbine (Work)
;;END;

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/Out_abg.fig version [50c38b16c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2205 2250 3150 2250 2970 2430
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2205 2025 2205 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4950 4545 4950 4365 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3555 2250 4500 2250 4320 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 5850 6075 1530 45 1530 45 5850 6075 5850
4 2 4 0 0 0 20 0.0000 4 255 2085 2160 5040 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 255 1935 2115 2340 SS:[Thermal_in]\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 5040 0\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 2340 0\001
4 0 -1 0 0 0 20 0.0000 4 255 1245 4590 2340 SS:Th_out\001
4 0 -1 0 0 0 20 0.0000 4 255 1260 4635 5040 SS:Hy_out\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/Out_desc.tex version [3dd57dc573].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/LiquidTurbine/Out_lbl.txt version [36c671bdc9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Out: Outflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system Out (Out_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in


% Component type SS
	Hy_out		SS	p_0,external
	Th_out		SS	t_0,external
	[Hydraulic_in]	SS	external,external
	[Thermal_in]	SS	external,external

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/In_abg.fig version [695cb8cbc2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2253 2253 3198 2253 3018 2433
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3196 2026 3196 2476
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 4950 4547 4950 4367 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3602 2250 4547 2250 4367 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 7200 5670 7200 1530 675 1530 675 5670 7200 5670
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
4 2 -1 0 0 0 20 0.0000 4 285 1140 2026 2341 SS:Th_in\001
4 2 -1 0 0 0 20 0.0000 4 285 1125 2071 5041 SS:Hy_in\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3376 5041 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3376 2341 0\001
4 0 4 0 0 0 20 0.0000 4 285 2295 4727 5042 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 285 2175 4772 2342 SS:[Thermal_out]\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/In_desc.tex version [0c97485c1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system In (In_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:36 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{In} is
   displayed in Figure \Ref{In_abg} and its label
   file is listed in Section \Ref{sec:In_lbl}.
   The subsystems are listed in Section \Ref{sec:In_sub}.

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/In_lbl.txt version [7b70ce34dc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY In: Inflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system In (In_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	out Thermal_out,Hydraulic_out
%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out



% Component type SS
	Hy_in			SS	internal,external
	Th_in			SS	external,internal
	[Hydraulic_out]		SS	external,external
	[Thermal_out]		SS	external,external

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/Out_abg.fig version [168ef8465c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2252 4952 3197 4952 3017 5132
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2205 2250 3150 2250 2970 2430
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2250 4725 2250 5175
2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2205 2025 2205 2475
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 4950 4545 4950 4365 5130
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3555 2250 4500 2250 4320 2430
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 6075 5850 6075 1530 45 1530 45 5850 6075 5850
4 2 4 0 0 0 20 0.0000 4 285 2145 2160 5040 SS:[Hydraulic_in]\001
4 2 4 0 0 0 20 0.0000 4 285 2025 2115 2340 SS:[Thermal_in]\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3375 5040 0\001
4 1 -1 0 0 0 20 0.0000 4 210 150 3375 2340 0\001
4 0 -1 0 0 0 20 0.0000 4 285 1290 4590 2340 SS:Th_out\001
4 0 -1 0 0 0 20 0.0000 4 285 1275 4635 5040 SS:Hy_out\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/Out_desc.tex version [3dd57dc573].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Out (Out_desc.tex)
% Generated by MTT on Tue Jan 13 18:02:44 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Out} is
   displayed in Figure \Ref{Out_abg} and its label
   file is listed in Section \Ref{sec:Out_lbl}.
   The subsystems are listed in Section \Ref{sec:Out_sub}.

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/Out_lbl.txt version [6454b3a5a6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Out: Outflow conditions
%DESCRIPTION <Detailed description here>
%% Label file for system Out (Out_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank

%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in


% Component type SS
	Hy_out		SS        p_0,internal
	Th_out		SS        t_0,internal
	[Hydraulic_in]	SS	external,external
	[Thermal_in]	SS	external,external

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_abg.fig version [5d0413d6f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 6210 4140 6390 4365
4 1 0 100 0 18 18 0.0000 4 195 150 6300 4365 0\001
-6
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9495 2700 10534 2703 10309 2928
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2025 2700 3060 2700 2835 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4497 2698 5715 2700 5490 2925
2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6930 2700 8145 2700 7920 2925
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 11925 7200 11925 225 900 225 900 7200 11925 7200
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6300 4050 6300 2925 6525 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6525 4275 7650 4275 7425 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4950 4275 6075 4275 5850 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2475 4275 3600 4275 3375 4500
4 1 4 0 0 2 16 0.0000 4 240 1020 6302 2477 [Heat_in]\001
4 1 -1 0 0 2 20 0.0000 4 210 1245 6302 2792 TankC:t1\001
4 1 -1 0 0 2 20 0.0000 4 285 945 8868 2793 Pipe:p2\001
4 1 -1 0 0 22 20 0.0000 4 225 600 1620 2790 In:in\001
4 1 -1 0 0 22 20 0.0000 4 225 1080 11116 2791 Out:out\001
4 1 -1 0 0 2 20 0.0000 4 285 945 3737 2792 Pipe:p1\001
4 1 0 100 0 18 18 0.0000 4 210 1305 4275 4365 RS:heater\001
4 1 0 100 0 18 18 0.0000 4 270 1020 1935 4365 Se:V_in\001
4 1 0 100 0 18 18 0.0000 4 270 1215 8280 4365 De:T_out\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_desc.tex version [51759f48f8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% -*-latex-*- used to set EMACS into LaTeX-mode
% Verbal description for system ShowerHeater (ShowerHeater_desc.tex)
% Generated by MTT on Tue Jan 13 18:01:55 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{ShowerHeater} is
   displayed in Figure \Ref{ShowerHeater_abg} and its label
   file is listed in Section \Ref{sec:ShowerHeater_lbl}.
   The subsystems are listed in Section \Ref{sec:ShowerHeater_sub}.

\textbf{ShowerHeater} is a very elementary model of an electric heater suitable for
a shower. It illustates the use of bond graph components which are
internally pseudo, but externally true bond graphs
(temperature/entropy flow).

There are three main components:
\begin{enumerate}
\item p1 and p2 -- a \textbf{Pipe} component (see Section
  \Ref{sec:Pipe}). It is assumed that the pipes have zero flow
  resistance and thus do not generate heat via flow resistance.
\item t1 -- a tank \textbf{Tank} component. 
\item Heater -- a resistive heater modelled by the thermodynamic
  \textbf{R} component \textbf{RS}.
\end{enumerate}
Other components could be added to represent thermal conduction and
thermal capacities.

The components \textbf{In} and \textbf{Out} provide the inlet and
outlet conditions.

The three inputs are
\begin{description}
\item[$u_1$] The flow rate
\item[$u_2$] The inlet temperature
\item[$u_3$] The voltage across the heating element.
\end{description}
The single output is
\begin{description}
\item[$y_1$] The outflow temperature
\end{description}
and the state is 
\begin{description}
\item[$x_1$] The heat contained in the tank.
\end{description}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_input.txt version [6978dbd547].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Input specification (ShowerHeater_input.txt)
# Generated by MTT at Tue Dec 14 10:03:59 EST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:11:47  peterg
## To RCS
##
###############################################################

# Set the inputs
showerheater__in__hy_in	= 1e-4*(t>30); # Inflow
showerheater__in__th_in	=  280; # In temperature
showerheater__v_in__u	= 240*((t<60)&&(t>1)); # Input voltage

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_lbl.txt version [ba8dee801c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY ShowerHeater
#DESCRIPTION <Detailed description here>
## Label file for system ShowerHeater (ShowerHeater_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.1  2000/12/28 18:11:47  peterg
# ## To RCS
# ##
# ###############################################################

#NOTPAR t_0

#ALIAS	Pipe	IncompressibleFlow/Pipe

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank


# Component type Pipe
	p1		lin	        rho;c_p;flow,0
	p2		lin	        rho;c_p;flow,0


# Component type TankC
	t1		TankC		rho;c_p;v

# Component type In
	in

# Component type Out
	out

# Component type RS
        heater	        lin		flow,r_h

# Component type Se
        V_in             SS              external

# Component type De
        T_out            SS              external

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_numpar.txt version [efdd8b1ce9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Numerical parameter file (ShowerHeater_numpar.txt)
# Generated by MTT at Tue Dec 14 09:52:42 EST 1999

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:11:47  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Parameters
c_p = 	4.184*1e3;		# Specific heat
p_0 = 	0.0;			# Ambient pressure
r_h = 	10.0;			# Heater resistance
rho = 	1e3;			# Density
v = 	1e-3;			# Volume (1 lit)
t_0	= 1.0; # Added by MTT on Wed Aug 06 19:05:01 BST 2003

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_rep.txt version [4288f558fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system ShowerHeater (ShowerHeater_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  2000/12/28 18:11:47  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:13:25  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt  ShowerHeater abg tex
mtt  ShowerHeater struc tex
mtt  ShowerHeater sympar tex
mtt  ShowerHeater ode tex


mtt  ShowerHeater numpar txt
mtt  ShowerHeater input txt

mtt  ShowerHeater odeso ps 

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_simpar.txt version [3b623625a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ShowerHeater (ShowerHeater_simpar.txt)
# Generated by MTT on Tue Dec 14 10:05:57 EST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 100.0;		# Last time in simulation
DT          = 0.5;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_simpar.txt_old version [3b623625a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system ShowerHeater (ShowerHeater_simpar.txt)
# Generated by MTT on Tue Dec 14 10:05:57 EST 1999.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


LAST        = 100.0;		# Last time in simulation
DT          = 0.5;        # Print interval
STEPFACTOR  = 1;          # Integration steps per print interval
WMIN        = -1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps
INPUT       = 1;          # Index of the input

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_sspar.r version [c5e3a0b620].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (ShowerHeater_sspar.r)
% Generated by MTT at Fri Nov 20 11:42:16 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	1; % ShowerHeater (j_s)
MTTX2 := 	p_0*c/rho; % ShowerHeater_C1 (tank) - pressure = p0
MTTX3 := 	t_0*p_0*c*c_p; % ShowerHeater_C1 (tank) - temp = t0
% Steady-state inputs
MTTU1 := 	q_0; % ShowerHeater (Heat)
MTTU2 := 	0; % ShowerHeater (Work)
;;END;

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/ShowerHeater_state.txt version [154b053b6b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (ShowerHeater_state.txt)
# Generated by MTT at Tue Dec 14 10:06:08 EST 1999
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:11:47  peterg
## To RCS
##
###############################################################

# Set the states
## Removed by MTT on Wed Aug  6 19:07:29 BST 2003: mttx(1) 	
showerheater__t1__tank	= 280*rho*v*c_p; # Initial heat in tank

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_TankC_abg.fig version [61a9baa3f5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2430 2070 3600 3105
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2445 2477 3570 2477 3345 2702
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2297 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 2387 1\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 3062 1\001
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2927 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2850 2657 .\001
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 2477 6990 2477 6765 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 5627 6990 5627 6765 5852
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 2478 8565 2478 8340 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9241 2479 10366 2479 10141 2704
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 5626 10365 5626 10140 5851
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8609 6571 5864 6571 5864 1801 8609 1801 8609 6571
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6989 2701 7439 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7214 2702 7214 3827 7439 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 5850 4050 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 1127 3825 2252 4050 2027
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 2475 5190 2475 4965 2700
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12825 7155 12825 225 225 225 225 7155 12825 7155
4 0 4 0 0 0 20 0.0000 4 285 2295 10546 5719 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 285 2175 10501 2569 SS:[Thermal_out]\001
4 2 4 0 0 0 20 0.0000 4 285 2145 4019 5716 SS:[Hydraulic_in]\001
4 1 -1 0 0 22 20 0.0000 4 225 390 5550 2567 ES\001
4 1 1 1 0 3 20 0.0000 4 210 150 4606 5538 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 4471 5808 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 4471 5448 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 4471 6078 V\001
4 1 4 0 0 0 20 0.0000 4 270 300 5280 2252 [s]\001
4 1 4 0 0 0 20 0.0000 4 270 315 5820 2252 [e]\001
4 1 1 1 0 3 20 0.0000 4 210 150 6406 2388 1\001
4 1 1 1 0 3 20 0.0000 4 210 660 6584 2206 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 6899 2386 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 6497 2659 .\001
4 1 1 1 0 3 20 0.0000 4 210 195 6497 2929 E\001
4 1 -1 0 0 22 20 0.0000 4 225 915 7214 4186 C:tank\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7215 5762 0\001
4 1 -1 0 0 22 20 0.0000 4 225 390 8925 2568 ES\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 5811 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 5451 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 9648 6081 V\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 5541 2\001
4 1 1 1 0 3 20 0.0000 4 210 195 7846 2930 E\001
4 1 4 0 0 0 20 0.0000 4 270 315 8655 2208 [e]\001
4 1 4 0 0 0 20 0.0000 4 270 300 9150 2208 [s]\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2301 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 2391 2\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2931 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 2661 .\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 3066 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 7846 2660 .\001
4 1 1 1 0 3 20 0.0000 4 210 660 7936 2209 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 8251 2389 0\001
4 1 1 1 0 3 20 0.0000 4 210 150 7758 2391 2\001
4 1 1 1 0 3 20 0.0000 4 285 2550 7259 6346 Pseudo Bond Graph\001
4 1 4 0 0 0 20 0.0000 4 285 1530 3870 945 SS:[Heat_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7245 2565 0\001
4 1 -1 0 0 22 20 0.0000 4 210 165 3825 2565 0\001
4 2 4 0 0 0 20 0.0000 4 285 2025 2385 2565 SS:[Thermal_in]\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_abg.fig version [61a9baa3f5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
6 2430 2070 3600 3105
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2445 2477 3570 2477 3345 2702
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2297 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 2387 1\001
4 1 1 1 0 3 20 0.0000 4 210 150 2985 3062 1\001
4 1 1 1 0 3 20 0.0000 4 210 180 2850 2927 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 2850 2657 .\001
-6
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5865 2477 6990 2477 6765 2702
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 5627 6990 5627 6765 5852
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 2478 8565 2478 8340 2703
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 9241 2479 10366 2479 10141 2704
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7440 5626 10365 5626 10140 5851
2 4 1 2 1 7 1 0 -1 6.000 0 0 7 0 0 5
	 8609 6571 5864 6571 5864 1801 8609 1801 8609 6571
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6989 2701 7439 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7214 2702 7214 3827 7439 3602
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4050 5850 4050 5400
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3825 1127 3825 2252 4050 2027
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4065 2475 5190 2475 4965 2700
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 12825 7155 12825 225 225 225 225 7155 12825 7155
4 0 4 0 0 0 20 0.0000 4 285 2295 10546 5719 SS:[Hydraulic_out]\001
4 0 4 0 0 0 20 0.0000 4 285 2175 10501 2569 SS:[Thermal_out]\001
4 2 4 0 0 0 20 0.0000 4 285 2145 4019 5716 SS:[Hydraulic_in]\001
4 1 -1 0 0 22 20 0.0000 4 225 390 5550 2567 ES\001
4 1 1 1 0 3 20 0.0000 4 210 150 4606 5538 1\001
4 1 1 1 0 3 30 0.0000 4 60 120 4471 5808 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 4471 5448 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 4471 6078 V\001
4 1 4 0 0 0 20 0.0000 4 270 300 5280 2252 [s]\001
4 1 4 0 0 0 20 0.0000 4 270 315 5820 2252 [e]\001
4 1 1 1 0 3 20 0.0000 4 210 150 6406 2388 1\001
4 1 1 1 0 3 20 0.0000 4 210 660 6584 2206 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 6899 2386 0\001
4 1 1 1 0 3 30 0.0000 4 60 120 6497 2659 .\001
4 1 1 1 0 3 20 0.0000 4 210 195 6497 2929 E\001
4 1 -1 0 0 22 20 0.0000 4 225 915 7214 4186 C:tank\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7215 5762 0\001
4 1 -1 0 0 22 20 0.0000 4 225 390 8925 2568 ES\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 5811 .\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 5451 P\001
4 1 1 1 0 3 20 0.0000 4 210 210 9648 6081 V\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 5541 2\001
4 1 1 1 0 3 20 0.0000 4 210 195 7846 2930 E\001
4 1 4 0 0 0 20 0.0000 4 270 315 8655 2208 [e]\001
4 1 4 0 0 0 20 0.0000 4 270 300 9150 2208 [s]\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2301 T\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 2391 2\001
4 1 1 1 0 3 20 0.0000 4 210 180 9648 2931 S\001
4 1 1 1 0 3 30 0.0000 4 60 120 9648 2661 .\001
4 1 1 1 0 3 20 0.0000 4 210 150 9783 3066 2\001
4 1 1 1 0 3 30 0.0000 4 60 120 7846 2660 .\001
4 1 1 1 0 3 20 0.0000 4 210 660 7936 2209 T - T\001
4 1 1 1 0 3 20 0.0000 4 210 150 8251 2389 0\001
4 1 1 1 0 3 20 0.0000 4 210 150 7758 2391 2\001
4 1 1 1 0 3 20 0.0000 4 285 2550 7259 6346 Pseudo Bond Graph\001
4 1 4 0 0 0 20 0.0000 4 285 1530 3870 945 SS:[Heat_in]\001
4 1 -1 0 0 22 20 0.0000 4 210 165 7245 2565 0\001
4 1 -1 0 0 22 20 0.0000 4 210 165 3825 2565 0\001
4 2 4 0 0 0 20 0.0000 4 285 2025 2385 2565 SS:[Thermal_in]\001

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_cr.r version [dab3fcf1b4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Constitutive relation file for TankC (TankC_cr.r)
% Generated by MTT at Thu Mar  5 10:30:23 GMT 1998

OPERATOR TankC;

%Pressure
% -- not relevant here

%Temperature
FOR ALL COMP,rho,c_p,volume,Energy
LET TankC(COMP,rho,c_p,volume,effort,1,
	Energy,state,1
	) = Energy/(volume*rho*c_p);

END;

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_desc.tex version [944934a0ef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system TankC (TankC_desc.tex)
% Generated by MTT on Tue Jan 13 18:03:04 GMT 1998.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{TankC} is
   displayed in Figure \Ref{TankC_abg} and its label
   file is listed in Section \Ref{sec:TankC_lbl}.
   The subsystems are listed in Section \Ref{sec:TankC_sub}.

Deleted mttroot/mtt/lib/examples/Thermal/Incompressible/Incompressible-Systems/ShowerHeater/TankC_lbl.txt version [649a90bba0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Label file for system TankC (TankC_lbl.txt)
%SUMMARY TankC: TankC of hot incompressible liquid - fixed volume
%DESCRIPTION rho - density; c_p - specific heat; v - volume
%DESCRIPTION Typical lable: tank  TankC  rho;c_p;v

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/11/20 13:20:27  peterg
% %% Aliased ports
% %%
% %% Revision 1.2  1998/11/20 09:46:34  peterg
% %% Modernised lbl syntax
% %%
% %% Revision 1.1  1998/11/20 08:57:19  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Port aliases
%ALIAS	in  Thermal_in,Hydraulic_in
%ALIAS	out Thermal_out,Hydraulic_out

%ALIAS	Th_in  Thermal_in
%ALIAS	Hy_in  Hydraulic_in

%ALIAS	Th_out  Thermal_out
%ALIAS	Hy_out  Hydraulic_out

%ALIAS	Heat	Heat_in

% Argument aliases
%ALIAS	$1	rho
%ALIAS	$2	c_p
%ALIAS	$3	v

%% Each line should be of one of the following forms:
%	     a comment (ie starting with %)
%	     component-name	cr_name	arg1,arg2,..argn
%	     blank

% ---- Component labels ----

% Component type C
	tank		TankC	       rho,c_p,v

% Component type SS
	[Heat_in]	SS	external,external
	[Hydraulic_in]	SS	external,external
	[Hydraulic_out]	SS	external,external
	[Thermal_in]	SS	external,external
	[Thermal_out]	SS	external,external



Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_abg.fig version [ebaa782f1c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 3150 5850 3150 5625 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 4500 4275 5850 4275 5625 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1800 3150 3150 3150 2925 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 2925 3150 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1800 4050 1800 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1777 4275 3127 4275 2902 4500
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4500 4095 4500 4545
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6975 3150 8325 3150 8100 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6975 2925 6975 3375
2 2 0 2 1 7 1 0 -1 0.000 0 0 0 0 0 5
	 2925 2025 4725 2025 4725 5400 2925 5400 2925 2025
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9450 5850 9450 1575 450 1575 450 5850 9450 5850
4 0 -1 0 0 0 20 0.0000000 4 240 870 6030 3240 RT:r_2\001
4 2 4 0 0 0 20 0.0000000 4 240 690 2835 3060 [t_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 840 4770 3015 [t_out]\001
4 2 4 0 0 0 20 0.0000000 4 240 735 2880 4185 [e_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 885 4770 4185 [e_out]\001
4 2 -1 0 0 0 20 0.0000000 4 240 900 1620 3240 SS:T_1\001
4 0 -1 0 0 0 20 0.0000000 4 240 900 8460 3240 SS:T_2\001
4 2 -1 0 0 0 20 0.0000000 4 240 780 1665 4365 SS:I_r\001
4 0 -1 0 0 0 20 0.0000000 4 240 930 5985 4365 SS:V_0\001
4 1 -1 0 0 0 20 0.0000000 4 270 1575 3780 3825 Segment:s*20\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_desc.tex version [4a2a8618be].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system HeatedRod (HeatedRod_desc.tex)
% Generated by MTT on Thu Sep 4 18:05:09 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 16:16:50  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{table}[htbp]
  \begin{center}
    \leavevmode
    \begin{tabular}{l l l}
      \hline
      Parameter & Symbol & Value  \\
      \hline
      Length & $L_r$ & 1m \\
      Diameter & $D_r$ & 1mm \\
      Resistivity & $\rho$ & $1.68\times10^{-9} \Omega$m \\
      Thermal conductivity & $\sigma$ & 390 W$\text{m}^{-1}$\\
      Thermal capacity & $\kappa$ & 380 J$\text{m}^{-3}$\\
      \hline
    \end{tabular}
    \caption{Heated rod parameters}
    \label{tab:rod}
  \end{center}
\end{table}

 System \textbf{HeatedRod} is a model of a well-insulated rod of copper with an
 electric current passing through it which warms it up. The two ends of
 the rod are fixed at ambient temperature; this is where all the heat
 loss occurs. 
 
 This example introduces the idea of the {\bf FP}, \textbf{RT} and
 \textbf{CT} components in the context of thermal conduction.
 
 The model is similar to that described in chapter 8 of \citeN{Cel91}.
 However, instead of representing the thermal resistance by {\bf RS}
 components and reinserting the entropy flow, the {\bf RT} component
 uses two {\bf FP} components to convert from true to pseudo bonds and
 back again. Similary, the thermal capacity is modelled by the {\bf
   CT} component.
 
 This distributed system (which strictly speaking has a partial
 differential equation model) is approximated by an ordinary
 diffferential equation model by modelling the system by a number of
 discrete segments of length $\Delta x$. Each segment model consists
 of two conceptual parts.
 \begin{itemize}
 \item An ideal lump of copper with no thermal resistance but with the
   normal attributes of electrical resistance (modelled by the
   \textbf{RS} component and thermal capacity (modelled by the
   \textbf{CF} component).
 \item A thin lump wtih thermal resistance but no thermal capacity or
   electrical resistance (modeled by the \textbf{RT} component).
 \end{itemize}
At this level of the hierarchy, all bonds are true energy bonds and
thus energy conservation is assured. Note that the \textbf{RS}
component correctely transforms electrical to thermal energy.

The system was simulated with a total of nine lumps whilst passing a
current of 1A though the rod for a total of 10s. The initial
temperature and the end temperatures were all set at 300K.

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_input.txt version [dbd86998eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (HeatedRod_input.txt)
# Generated by MTT at Thu Sep  4 16:11:06 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:12:41  peterg
# %% To RCS
# %%
# %% Revision 1.1  1998/08/15 13:40:20  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Thu Jun 12 14:33:52 BST 2003: u() =	10.0*(t<5.0); # I_r 
heatedrod__i_r	= 10.0*(t<5.0); # I_r 

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_lbl.txt version [d5b6ca5013].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY HeatedRod: Thermal/Electrical model of Electric rod
%DESCRIPTION Introduces the idea of the ES component which
%DESCRIPTION transforms a relative-temperature/enthalpy pseudo bond 
%DESCRIPTION (at the [e]port) into an absolute-temperature/enntropy 
%DESCRIPTION energy bond (at the [s] port) and vice versa.

%VAR rod_length
%VAR rod_radius
%VAR electrical_resistivity
%VAR thermal_resistivity
%VAR thermal_capacity
%VAR segments
%VAR area
%VAR delta_x
%VAR volume
%VAR density
%VAR mass

%% Label file for system HeatedRod (HeatedRod_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1997/09/11 16:16:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type RT
	r_2		lin	flow,r_2

% Component type SS
	I_r	SS	internal,external
	T_1	SS	t_0,internal
	T_2	SS	t_0,internal
	V_0	SS	internal,internal

% Component type Segment
	s

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_numpar.txt version [a9f0752d97].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (HeatedRod_numpar.txt)
# Generated by MTT at Thu Sep  4 16:11:04 BST 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/08/15 13:40:33  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


# Constants for copper
density = 8.96;
rod_length = 1.0;
rod_radius = 1e-3;
electrical_resistivity = 16.8*0.000000001;
thermal_resistivity = 1/390.0;
thermal_capacity = 380.0;


segments = 20;
area = pi*rod_radius*rod_radius;
delta_x = rod_length/segments;
volume = area*delta_x;
mass = volume*density;

# Parameters
c_t = 	thermal_capacity*mass;
r = 	electrical_resistivity*delta_x/area;
r_t = 	thermal_resistivity*delta_x/area;
r_2 = 	r_t;
t_0 = 	300; # Ambient




Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_rep.txt version [d8fe1963e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system HeatedRod (HeatedRod_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1999/12/21 23:53:04  peterg
% %% Compiled version
% %%
% %% Revision 1.1  1999/02/21 02:14:29  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss HeatedRod abg tex
mtt -o -ss HeatedRod struc tex
mtt -o -ss HeatedRod ode tex
mtt -o -ss HeatedRod ss tex
mtt -o -ss HeatedRod sm tex
mtt -o -ss HeatedRod lmfr ps

mtt -o -ss HeatedRod numpar txt
mtt -o -ss HeatedRod input txt
mtt -o -ss HeatedRod odeso ps

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_simpar.txt version [b039d6f9cd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Simulation parameters for system HR (HR_simpar.txt)
# Generated by MTT on Wednesday July 29 13:59:50 BST 1998.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/08/15 13:40:47  peterg
## Initial revision
##
###############################################################


LAST        = 10;       # Last time in simulation
WMIN        = 1;         # Minimum frequency = 10^WMIN
WMAX        = 2;          # Maximum frequency = 10^WMAX
WSTEPS      = 100;        # Number of frequency steps

STEPFACTOR = 1; # Added automatically
DT = 0.1;                 # Added automatically

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_sspar.r version [a711759aa0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (HeatedRod_sspar.r)
% Generated by MTT at Thu Jun 25 09:32:38 BST 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Steady-state states
MTTX1 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX2 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX3 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX4 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX5 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX6 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX7 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX8 := 	t_0*c_t; % HeatedRod_s_c_t (c)
MTTX9 := 	t_0*c_t; % HeatedRod_s_c_t (c)

% Steady-state inputs
MTTU1 := 	1.0; % HeatedRod (I_r)

;;END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/HeatedRod_state.txt version [d44ad0a9b8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-octave-*- Put Emacs into octave-mode
# Initial state  file (HeatedRod_state.txt)
# Generated by MTT at Sat Aug 15 15:34:41 BST 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  2000/12/28 18:12:41  peterg
## To RCS
##
###############################################################

# Set the states
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(1) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(2) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(3) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(4) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(5) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(6) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(7) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(8) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(9) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(10) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(11) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(12) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(13) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(14) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(15) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(16) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(17) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(18) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(19) 	= c_t*t_0; 	# c (HeatedRod_s_c_t)
## Removed by MTT on Thu Jun 12 14:34:50 BST 2003: mttx(20) 	=
## c_t*t_0; 	# c (HeatedRod_s_c_t)

heatedrod__s__10__c_t__c	= c_t*t_0;
heatedrod__s__11__c_t__c	= c_t*t_0;
heatedrod__s__12__c_t__c	= c_t*t_0;
heatedrod__s__13__c_t__c	= c_t*t_0;
heatedrod__s__14__c_t__c	= c_t*t_0;
heatedrod__s__15__c_t__c	= c_t*t_0;
heatedrod__s__16__c_t__c	= c_t*t_0;
heatedrod__s__17__c_t__c	= c_t*t_0;
heatedrod__s__18__c_t__c	= c_t*t_0;
heatedrod__s__19__c_t__c	= c_t*t_0;
heatedrod__s__20__c_t__c	= c_t*t_0;
heatedrod__s__2__c_t__c	= c_t*t_0;
heatedrod__s__3__c_t__c	= c_t*t_0;
heatedrod__s__4__c_t__c	= c_t*t_0;
heatedrod__s__5__c_t__c	= c_t*t_0;
heatedrod__s__6__c_t__c	= c_t*t_0;
heatedrod__s__7__c_t__c	= c_t*t_0;
heatedrod__s__8__c_t__c	= c_t*t_0;
heatedrod__s__9__c_t__c	= c_t*t_0;
heatedrod__s__c_t__c	= c_t*t_0;

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/Segment_abg.fig version [b5d0a0a3ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1306 2476 2881 2476 2656 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3781 2476 5356 2476 5131 2701
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5761 2476 8550 2475 8325 2700
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 4276 5581 2701 5806 2926
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 6301 5581 4726 5806 4951
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1350 6525 5356 6526 5131 6751
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 6526 8550 6525 8325 6750
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5806 2701 6920 3815 6601 3815
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5581 2251 5581 676 5806 901
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5356 676 5806 676
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 7425 9900 90 45 90 45 7425 9900 7425
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 4455 7650 1800 1575 1800 1575 4455 7650 4455
2 4 0 1 1 7 1 0 -1 0.000 0 0 7 0 0 5
	 7650 6975 7650 4545 1575 4545 1575 6975 7650 6975
4 1 -1 0 0 0 20 0.0000000 4 240 810 3331 2566 RT:r_t\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5581 2566 0\001
4 1 -1 0 0 0 20 0.0000000 4 210 555 5581 4591 RS:r\001
4 1 -1 0 0 0 20 0.0000000 4 210 150 5581 6616 1\001
4 1 -1 0 0 0 20 0.0000000 4 240 840 7021 4141 CT:c_t\001
4 1 -1 0 0 0 20 0.0000000 4 240 870 5581 586 SS:T_s\001
4 2 4 0 0 0 20 0.0000000 4 240 1020 1261 2566 SS:[t_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 1020 8685 2565 SS:[t_out]\001
4 2 4 0 0 0 20 0.0000000 4 240 1065 1260 6615 SS:[e_in]\001
4 0 4 0 0 0 20 0.0000000 4 240 1065 8685 6615 SS:[e_out]\001
4 0 1 1 0 0 20 0.0000000 4 240 1875 1845 4050 Thermal model\001
4 0 1 1 0 0 20 0.0000000 4 240 2025 1800 5175 Electrical model\001
4 0 1 1 0 0 20 0.0000000 4 270 2415 6075 585 Temperature sensor\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/Segment_desc.tex version [6387facfb7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Segment (Segment_desc.tex)
% Generated by MTT on Thu Sep 4 18:05:43 BST 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



   The acausal bond graph of system \textbf{Segment} is
   displayed in Figure \ref{Segment_abg} and its label
   file is listed in Section \ref{sec:Segment_lbl}.
   The subsystems are listed in Section \ref{sec:Segment_sub}.



Deleted mttroot/mtt/lib/examples/Thermal/ThermalConduction/HeatedRod/Segment_lbl.txt version [1cb8b4681d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%SUMMARY Segment: Segment of HeatedRod
%DESCRIPTION Part of the HeatedRod example.
%% Label file for system Segment (Segment_lbl.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/08/10 12:29:48  peterg
% %% Added missing ports.
% %%
% %% Revision 1.1  1997/09/11 16:17:14  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Each line should be of one of the following forms:
%	a comment (ie starting with %)
%	Component-name	CR_name	arg1,arg2,..argn
%	blank



% Component type CT
	c_t		lin	effort,c_t

% Component type RS
	r		lin	flow,r

% Component type RT
	r_t		lin	flow,r_t

% Component type SS
	T_s		SS		external,0
	[t_in]		SS		external,external
	[t_out]		SS		external,external
	[e_in]		SS		external,external
	[e_out]		SS		external,external

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_abg.fig version [3bd0451b28].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3827 3152 5402 3152 5177 3377
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 6977 3152 8552 3152 8327 3377
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 8552 2927 8552 3377
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 902 3150 2477 3150 2252 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2475 2925 2475 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3825 2925 3825 3375
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3152 1125 3152 2700 2927 2475
2 4 0 2 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 9900 5175 -450 5175 -450 450 9900 450 9900 5175
4 1 -1 0 0 0 20 0.0000 4 285 1440 6212 3242 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000 4 210 1050 8687 3242 Sf:Work\001
4 1 1 1 0 3 20 0.0000 4 210 735 4456 3466 dS/dT\001
4 1 1 1 0 3 20 0.0000 4 195 180 4501 2926 T\001
4 1 1 1 0 3 20 0.0000 4 195 180 7921 2926 P\001
4 1 1 1 0 3 20 0.0000 4 210 765 7786 3466 dV/dT\001
4 1 1 1 0 3 30 0.0000 4 405 2325 5085 4635 Carnot cycle\001
4 2 -1 0 0 0 20 0.0000 4 210 975 810 3240 Se:Heat\001
4 1 -1 0 0 0 20 0.0000 4 195 1005 3150 3240 FMRT:r\001
4 1 4 100 0 18 14 0.0000 4 195 600 3150 2925 [mod]\001
4 1 -1 0 0 0 20 0.0000 4 210 1170 3150 990 Sf:switch\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_desc.tex version [2f3b6bc5ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system CarnotCycle (CarnotCycle_desc.tex)
% Generated by MTT on Tue Dec 9 12:13:57 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{CarnotCycle} is
   displayed in Figure \Ref{CarnotCycle_abg} and its label
   file is listed in Section \Ref{sec:CarnotCycle_lbl}.
   The subsystems are listed in Section \Ref{sec:CarnotCycle_sub}.

The Carnot cycle is a simple closed thermodynamic cycle with four parts:
\begin{enumerate}
\item Isentropic compression
\item Heat injection at constant temperature
\item Isentropic expansion
\item Heat extraction at constant temperature
\end{enumerate}

The subsystem \textbf{Cycle} (Section \Ref{sec:Cycle}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

In contast to the Otto cycle (see Table
\Ref{tab:cycles} where each table entry gives the causality on the
heat and work ports respectively). The ideal Carnot cycle has
derivative causality on the {\bf [Heat]} port for two parts of the
cycle.

To avoid this causlity change, the Carnot cycle is approximated by
applying the heat from a temperature source via a thermal resistance
{\bf RT} component. During the {\em heat injection\/} and {\em heat
extraction\/} parts of the cycle, the resistance parameter $r\approx
0$, but during the {\em isentropic compression\/} and {\em isentropic
expansion\/} parts of the cycle, the resistance parameter $r\approx
\inf$.

The simulation parameters appear in Section
\Ref{sec:CarnotCycle_numpar.txt}. The results are plotted against time
as follows:
\begin{itemize}
\item Volume (Figure \Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-V})
\item Pressure (Figure
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-P})
\item Entropy (Figure \Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-S})
\item Temperature (Figure
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-T})
\end{itemize}

These values are replotted as the standard PV and TS diagrams in
Figures
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-V:CarnotCycle-cycle-P}
and
\Ref{fig:CarnotCycle_odeso.ps-CarnotCycle-cycle-S:CarnotCycle-cycle-T}
respectively.

The PV diagram shows the long and thin form typical of the Carnot
cycle -- this implies a poor work ratio. The TS diagram is not
informative; it is not the expected rectangle because both T and S
change in a stepwise manner.




Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_input.txt version [3f74ca255c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Input file (CarnotCycle_input.txt)
# Generated by MTT at Mon Dec  8 20:05:30 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:14:40  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


alpha = 0.553;

# Set the inputs
if ((t>=0.0)&&(t<1.0))		#Cooling
  carnotcycle__heat__u= 300.0;	# Source temperature
  carnotcycle__switch__u    = 1e10; # Large conductance - isothermal
  carnotcycle__work__u = -alpha;	# Volume rate-of-change
endif;

if ((t>=1.0)&&(t<2.0))		#Compression
  carnotcycle__heat__u = 300.0;	# Source temperature 
  carnotcycle__switch__u    = 0; # Small conductance -- isentropic
  carnotcycle__work__u = -(0.8-alpha); # Volume rate-of-change
endif;

if ((t>=2.0)&&(t<3.0))		#Heating
  TopTemp = x(1)/(m_g*c_v);
  carnotcycle__heat__u = TopTemp;	# Source temperature
  carnotcycle__switch__u    = 1e10; # Large conductance - isothermal
  carnotcycle__work__u = (0.8-alpha); # Volume rate-of-change
endif;

if (t>=3.0)			#Cooling
  carnotcycle__heat__u = 300.0;	# Source temperature
  carnotcycle__switch__u    = 0; # Small conductance -- isentropic
  carnotcycle__work__u = alpha;	# Volume rate-of-change
endif;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_lbl.txt version [530e8f67dd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY CarnotCycle: a simple closed thermodynamic cycle
#DESCRIPTION The Carnot cycle is a simple closed thermodynamic cycle
#DESCRIPTION with four parts:
#DESCRIPTION o Isentropic compression
#DESCRIPTION o Heat injection at constant temperature
#DESCRIPTION o Isentropic expansion
#DESCRIPTION o Heat extraction at constant temperature

#PAR P_0
#PAR T_0
#PAR V_0
#PAR alpha
#PAR TopTemp


#NOTPAR ideal_gas

## Label file for system CarnotCycle (CarnotCycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.3  2003/08/13 17:03:00  gawthrop
# ## Updated for new MTT
# ## Use FMR in place of R
# ## Fixed bug in sspar
# ##
# ## Revision 1.2  1998/08/10 16:40:07  peterg
# ## Added VARs and parametrs
# ##
# ## Revision 1.1  1998/07/21 15:18:18  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g

# Component type RT
	r		lin	flow,1

# Component type Se
	Heat	SS	external

# Component type Sf
	Work    SS	external
	switch  SS	external

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_numpar.txt version [229858da3a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (CarnotCycle_numpar.txt)
# Generated by MTT at Mon Dec  8 20:02:31 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.3  2003/08/13 17:03:10  gawthrop
# %% Updated for new MTT
# %% Use FMR in place of R
# %% Fixed bug in sspar
# %%
# %% Revision 1.2  2000/12/28 18:14:40  peterg
# %% To RCS
# %%
# %% Revision 1.1  1998/03/04 11:49:01  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0;			# Parameter c_v for CU
gamma_g = 1.4;			# Parameter gamma for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

## Use in input.txt
alpha	= 1.0; # Added by MTT on Thu Aug 14 11:42:15 BST 2003
toptemp	= 1.0; # Added by MTT on Thu Aug 14 11:42:15 BST 2003

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_params.r version [20ff45d443].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
%% Parameter file for system CarnotCycle (CarnotCycle_params.r)
%% This file provides symbolic parameters for simplification

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_rep.txt version [84cd324287].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system CarnotCycle (CarnotCycle_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:14:40  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:15:05  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -ss -o CarnotCycle abg tex
mtt -ss -o CarnotCycle struc tex
mtt -ss -o CarnotCycle ode tex
mtt -ss -o CarnotCycle ss tex

mtt -ss -o CarnotCycle numpar txt
mtt -ss -o CarnotCycle input txt

mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__V'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__P'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__S'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__T'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__V:CarnotCycle__cycle__P'
mtt -ss -o CarnotCycle odeso ps 'CarnotCycle__cycle__S:CarnotCycle__cycle__T'

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_simp.r version [8c64ed9a32].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce comands to simplify output for system CarnotCycle (CarnotCycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_simpar.txt version [4178b56134].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system OttoCycle (OttoCycle_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=4.0
DT=0.01
STEPFACTOR=10

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/CarnotCycle/CarnotCycle_sspar.r version [5c712e6db1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (CarnotCycle_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.2  2000/12/28 18:14:40  peterg
% % To RCS
% %
% % Revision 1.1  1998/03/04 11:49:14  peterg
% % Initial revision
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Set a pressure of 1 bar
%P_0 := 10^5;

% Unit initial volume
%V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
%T_0 := 300;

% Deduce the mass of gas
m_g :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % CarnotCycle_cycle_gas (c)
MTTX2 := 	V_0;         % CarnotCycle_cycle_gas (c)
MTTX3 := 	S_0;         % CarnotCycle_cycle_volume (3)
MTTX4 := 	V_0;         % CarnotCycle_cycle_entropy (3)

% Steady-state inputs
MTTU1 := 	T_0; % CarnotCycle (Heat)
MTTU2 := 	0; % CarnotCycle (Work)
MTTU3 := 	0; % Switch (conduction)
;;END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_abg.fig version [8f0ef21ff3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
4 1 -1 0 0 0 20 0.0000 4 285 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000 4 210 1050 6886 3241 Sf:Work\001
4 2 -1 0 0 0 20 0.0000 4 210 945 1936 3241 Sf:Heat\001
4 1 1 1 0 3 20 0.0000 4 210 735 2655 3465 dS/dT\001
4 1 1 1 0 3 20 0.0000 4 195 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000 4 195 180 6120 2925 P\001
4 1 1 1 0 3 20 0.0000 4 210 765 5985 3465 dV/dT\001
4 1 1 1 0 3 30 0.0000 4 405 1815 4365 4770 Otto cycle\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_desc.tex version [0e04e9a7ae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system OttoCycle (OttoCycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{OttoCycle} is
   displayed in Figure \Ref{OttoCycle_abg} and its label
   file is listed in Section \Ref{sec:OttoCycle_lbl}.
   The subsystems are listed in Section \Ref{sec:OttoCycle_sub}.


The Otto cycle is a simple closed thermodynamic cycle with four parts:
\begin{enumerate}
\item Isentropic compression
\item Heating at constant volume
\item Isentropic expansion
\item Cooling at constant volume
\end{enumerate}

The subsystem \textbf{Cycle} (Section \Ref{sec:Cycle}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

In Bond Graph terms, each of the four parts of the Otto cycle
correspond to integral causality as in each case a \emph{flow} is
constrained. This is in contrast to other cycles listed in Table
\Ref{tab:cycles} where each table entry gives the causality on the
heat and work ports respectively. This is possibly why the Otto cycle
is conceptually and practically simple.

The simulation parameters appear in Section
\Ref{sec:OttoCycle_numpar.txt}. The results are plotted against time
as follows:
\begin{itemize}
\item Volume (Figure \Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-V})
\item Pressure (Figure
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-P})
\item Entropy (Figure \Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-S})
\item Temperature (Figure
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-T})
\end{itemize}

These values are replotted as the standard PV and TS diagrams in
Figures
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-V:OttoCycle-cycle-P}
and
\Ref{fig:OttoCycle_odeso.ps-OttoCycle-cycle-S:OttoCycle-cycle-T}
respectively.





Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_input.txt version [a1dff1c564].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (OttoCycle_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.3  2000/12/28 18:42:16  peterg
# %% New input definition.
# %% NB Needs to handle mutiports properly and state.txt modified accordingly
# %%
# %% Revision 1.2  2000/12/28 18:15:52  peterg
# %% To RCS
# %%
# %% Revision 1.1  1998/08/10 14:42:13  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs

if ((t>=0.0)&&(t<1.0))		#Compression
  OttoCycle__Heat__u = 0.0;	# Entropy flow
  OttoCycle__Work__u = -0.8;	# Volume rate-of-change
endif;

if ((t>=1.0)&&(t<2.0))		#Heating
  OttoCycle__Heat__u = 1000;	# Entropy flow
  OttoCycle__Work__u = 0.0;	# Volume rate-of-change
endif;

if ((t>=2.0)&&(t<3.0))		#Expansion
  OttoCycle__Heat__u = 0.0;	# Entropy flow
  OttoCycle__Work__u = 0.8;	# Volume rate-of-change
endif;

if (t>=3.0)			#Cooling
  OttoCycle__Heat__u = -1000;	# Entropy flow
  OttoCycle__Work__u = 0.0;	# Volume rate-of-change
endif;




Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_lbl.txt version [241819f0d8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY OttoCycle: a simple closed thermodynamic cycle
#DESCRIPTION The Otto cycle is a simple closed thermodynamic cycle
#DESCRIPTION with four parts:
#DESCRIPTION o Isentropic compression
#DESCRIPTION o Heating at constant volume
#DESCRIPTION o Isentropic expansion
#DESCRIPTION o Cooling at constant volume
  
#PAR P_0
#PAR T_0
#PAR V_0
#NOTPAR ideal_gas


## Label file for system OttoCycle (OttoCycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.4  2000/12/28 18:42:17  peterg
# ## New input definition.
# ## NB Needs to handle mutiports properly and state.txt modified accordingly
# ##
# ## Revision 1.3  1998/08/10 16:05:52  peterg
# ## Added VARs and parameters
# ##
# ## Revision 1.2  1998/07/21 15:15:27  peterg
# ## Documentation + new format
# ##
# ## Revision 1.1  1998/07/21 15:12:21  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type Sf
	Heat	SS	external
	Work	SS	external

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_numpar.txt version [b464fa9930].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (OttoCycle_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an appropriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;			

# Parameters
c_v = 	718.0;			# Parameter c_v for CU
gamma_g = 1.4;			# Parameter gamma for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v);# Parameter m for CU

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_rep.txt version [c1e59d4735].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system OttoCycle (OttoCycle_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:15:52  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:16:17  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss OttoCycle abg tex
mtt -o -ss OttoCycle struc tex
mtt -o -ss OttoCycle ode tex
mtt -o -ss OttoCycle ss tex

mtt -o -ss OttoCycle numpar txt
mtt -o -ss OttoCycle input txt

mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__V'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__P'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__S'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__T'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__V:OttoCycle__cycle__P'
mtt -o -ss OttoCycle odeso ps 'OttoCycle__cycle__S:OttoCycle__cycle__T'




Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicCycles/OttoCycle/OttoCycle_sspar.r version [28a921ee9f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (OttoCycle_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% % Revision 1.1  2000/12/28 18:15:52  peterg
% % To RCS
% %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
%%P_0 := 10^5;

% Unit initial volume
%%V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
%%T_0 := 300;

% Deduce the mass of gas
m_g :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % OttoCycle_cycle_gas (c)
MTTX2 := 	V_0;         % OttoCycle_cycle_gas (c)
MTTX3 := 	S_0;         % OttoCycle_cycle_entropy (3)
MTTX4 := 	V_0;         % OttoCycle_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % OttoCycle (Heat)
MTTU2 := 	0; % OttoCycle (Work)
;;END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_abg.fig version [5d72c6d9ef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 3360 4365 4770 Isentropic process\001
4 1 1 1 0 3 20 0.0000000 4 210 480 2700 3555 S=0\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2565 3330 .\001
4 1 1 1 0 3 20 0.0000000 4 210 195 6120 3555 V\001
4 1 1 1 0 3 30 0.0000000 4 60 105 6165 3285 .\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_desc.tex version [ff2532462b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Isentropic (Isentropic_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_input.txt version [3384727177].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isentropic_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:16:47  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 10:14:17 BST 2003:   u(1) = -0.8;     # Volume rate-of-change
isentropic__work	= -0.8;     # Volume rate-of-change

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_lbl.txt version [fe7dd91d36].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Isentropic: Isentropic thermodynamic process - ideal gas
#DESCRIPTION A dynamic simulation of an isentropic process using
#DESCRIPTION the Cycle component and the two-prt CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas



## Label file for system Isentropic (Isentropic_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:16:47  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:27:44  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat	SS	internal,0
	Work	SS	internal,external

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_numpar.txt version [561c815b07].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isentropic_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_rep.txt version [330cdb1720].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Isentropic (Isentropic_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:16:47  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:18:41  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss Isentropic abg tex
mtt -o -ss Isentropic struc tex
mtt -o -ss Isentropic ode tex
mtt -o -ss Isentropic ss tex

mtt -o -ss Isentropic numpar txt
mtt -o -ss Isentropic input txt

mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__V'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__P'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__S'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__T'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__V:Isentropic__cycle__P'
mtt -o -ss Isentropic odeso ps 'Isentropic__cycle__S:Isentropic__cycle__T'

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_simpar.txt version [ac622df4b8].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isentropic (Isentropic_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_simpar.txt_old version [ac622df4b8].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isentropic (Isentropic_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isentropic/Isentropic_sspar.r version [b36b93a55f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (Isentropic_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % Isentropic_cycle_gas (c)
MTTX2 := 	V_0;         % Isentropic_cycle_gas (c)
MTTX3 := 	S_0;         % Isentropic_cycle_entropy (3)
MTTX4 := 	V_0;         % Isentropic_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isentropic (Heat)
MTTU2 := 	0; % Isentropic (Work)
;;END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_abg.fig version [21bfb6f246].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1800 6750 1800 6525 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2025 5175 3375 5400 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 5175 5400 4950
2 2 0 3 1 7 1 0 -1 0.000 1 0 -1 0 0 5
	 6075 900 9000 900 9000 2700 6075 2700 6075 900
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8325 900 8550 900 8550 2700 8325 2700 8325 900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3825 10125 5175 10350 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 1800 9900 1800 9675 2025
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8550 1665 9585 1665 9585 1935 8550 1935 8550 1665
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 4725 1440 5805 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 9675 1440 10755 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 7785 3465 8415 2835
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 1800 4950 1800 4725 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1755 1800 3105 1800 2880 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 2025 3375 5175 3600 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 5175 3600 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10350 1800 11700 1800 11475 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 1800 13500 1800 13275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11700 5175 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11925 2025 11925 5175 12150 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 2025 10125 3375 10350 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2025 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 10350 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 5175 10350 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 5400 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5400 1575 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 7875 1575 7875 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 1755 1575 1755 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 12150 1575 12150 2025
4 1 -1 0 0 0 20 0.0000 4 255 915 7290 1890 CU:gas\001
4 1 -1 0 0 0 20 0.0000 4 195 150 5175 1890 1\001
4 1 -1 0 0 0 20 0.0000 4 270 1695 5175 3690 INTF:entropy\001
4 1 -1 0 0 0 20 0.0000 4 195 150 10125 1890 1\001
4 1 1 1 0 3 20 0.0000 4 270 1140 7200 1440 Ideal gas\001
4 1 1 1 0 3 20 0.0000 4 195 945 4635 1305 Heat in\001
4 1 1 1 0 3 20 0.0000 4 210 1170 10170 1305 Work out\001
4 1 1 1 0 3 20 0.0000 4 270 1980 5130 5895 Entropy change\001
4 1 1 1 0 3 20 0.0000 4 270 1485 7110 3690 Ideal piston\001
4 1 -1 0 0 0 20 0.0000 4 210 1680 10125 3690 INTF:volume\001
4 1 -1 0 0 0 20 0.0000 4 195 150 3375 1890 0\001
4 2 4 0 0 0 20 0.0000 4 255 1215 1575 1890 SS:[Heat]\001
4 1 -1 0 0 0 20 0.0000 4 210 600 3375 5490 SS:T\001
4 1 1 1 0 3 20 0.0000 4 255 1620 3240 5895 Temperature\001
4 1 -1 0 0 0 20 0.0000 4 210 585 5130 5490 SS:S\001
4 1 -1 0 0 0 20 0.0000 4 210 645 10125 5490 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 210 585 11880 5490 SS:P\001
4 0 4 0 0 0 20 0.0000 4 255 1320 13680 1890 SS:[Work]\001
4 1 1 1 0 3 20 0.0000 4 270 1950 10080 5850 Volume change\001
4 1 1 1 0 3 20 0.0000 4 195 1095 11925 5850 Pressure\001
4 1 -1 0 0 0 20 0.0000 4 195 150 11925 1890 0\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_desc.tex version [9decb9a7b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Cycle (Cycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/06/30 12:46:49  peterg
% %% Changed CT2 to CU
% %%
% %% Revision 1.1  1998/06/30 12:46:24  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cycle} is
   displayed in Figure \Ref{Cycle_abg} and its label
   file is listed in Section \Ref{sec:Cycle_lbl}.
   The subsystems are listed in Section \Ref{sec:Cycle_sub}.

The system has two heat engine ports: 
\begin{enumerate}
\item \textbf{[Heat]} and
\item \textbf{[Work]}
\end{enumerate}
By convention, energy flows in to the \textbf{[Heat]} port and out of
the \textbf{[Work]} port. Both ports are true energy ports.


The subsystem \textbf{CU} (Section \Ref{sec:CU}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

Four \textbf{SS} components are set up as sensors to measure the
important quantities pertaining to the cycle:
\begin{enumerate}
\item \textbf{S} to measure the integrated entropy flow
\item \textbf{T} to measure the (absolute) temperature
\item \textbf{V} to measure the integrated volume change
\item \textbf{P} to measure the pressure
\end{enumerate}

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|l|l|l|}
         \hline
         Cycle & Compression & Heating & Expansion & Cooling \\
         \hline
         Otto & II & II & II & II \\
         Carnot & II & DI & II & DI \\
         Diesel & II & ID & II & II \\
         Joule & II & ID & II & ID \\
         \hline
       \end{tabular}
       \caption{Cycles and their causality}
       \label{tab:cycles}
     \end{center}
   \end{table}
   
   A number of cycles can be built depending on the causality of the
   two ports \textbf{[Heat]} and \textbf{[Work]} of \textbf{Cycle}
   Some possible cycles listed in Tables \Ref{tab:cycles} where each
   table entry gives the causality on the heat and work ports
   respectively.

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_lbl.txt version [d82e73d04d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Cycle: Closed cycle with ideal gas
#DESCRIPTION Uses the CU two-port thermal capacitor.

#ALIAS in	Heat
#ALIAS out	Work

#ALIAS $1	ideal_gas
#ALIAS $2	c_v
#ALIAS $3	gamma_g
#ALIAS $4	m_g

## Label file for system Cycle (Cycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1998/07/21 14:21:04  peterg
# ## New style file
# ##
# ## Revision 1.1  1997/12/08 20:24:43  peterg
# ## Initial revision
# ##
# ## Revision 1.1  1997/12/07 20:38:05  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank




# Component type CU
	gas	CU	ideal_gas,c_v,gamma_g,m_g

# Component type INTF
	entropy
	volume

# Component type SS
	S	SS	external,0
	T	SS	external,0
	V	SS	external,0
	P	SS	external,0
	[Heat]	SS	external,external
	[Work]	SS	external,external



Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Cycle_simp.r version [b8f003f5e9].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce commands to simplify output for system Cycle (Cycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_abg.fig version [476d13332f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 5175 2925 5175 3375
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 3015 4365 4770 Isobaric process\001
4 1 1 1 0 3 20 0.0000000 4 210 480 2700 3555 S=0\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2565 3330 .\001
4 1 1 1 0 3 20 0.0000000 4 210 195 6120 3555 V\001
4 1 1 1 0 3 30 0.0000000 4 60 105 6165 3285 .\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_desc.tex version [b3e2d1ccc2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Isobaric (Isobaric_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_input.txt version [bfb9bb0e91].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isobaric_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:17:13  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 11:41:46 BST 2003:   u(1) = 1000;     #Entropy flow 
isobaric__heat	= 1000;     #Entropy flow 

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_lbl.txt version [eac4d49411].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Isobaric: Isobaric thermodynamic process - ideal gas 
#DESCRIPTION A dynamic simulation of an isobaric (constant pressure)
#DESCRIPTION  process using the Cycle component and the two-port CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas 

## Label file for system Isobaric (Isobaric_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:17:13  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:32:49  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat	SS	internal,external
	Work	SS	P_0,internal

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_numpar.txt version [fbce8cfc6e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isobaric_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma_g for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_rep.txt version [3ca4977ae4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Isobaric (Isobaric_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:17:13  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:19:31  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt  -ss Isobaric abg tex
mtt  -ss Isobaric struc tex
mtt  -ss Isobaric ode tex
mtt  -ss Isobaric ss tex

mtt  -ss Isobaric numpar txt
mtt  -ss Isobaric input txt

mtt  -ss Isobaric odeso ps 'Isobaric__cycle__V'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__P'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__S'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__T'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__V:Isobaric__cycle__P'
mtt  -ss Isobaric odeso ps 'Isobaric__cycle__S:Isobaric__cycle__T'




Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_simpar.txt version [545a74e285].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isobaric (Isobaric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_simpar.txt_old version [545a74e285].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isobaric (Isobaric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isobaric/Isobaric_sspar.r version [c0e371332c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (Isobaric_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % Isobaric_cycle_gas (c)
%MTTX2 := 	V_0;         % Isobaric_cycle_gas (c)
MTTX2 := 	S_0;         % Isobaric_cycle_entropy (3)
MTTX3 := 	V_0;         % Isobaric_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isobaric (Heat)
;;END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_abg.fig version [8fdef28898].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5400 1800 6750 1800 6525 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 2025 5175 3375 5400 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5175 3825 5175 5175 5400 4950
2 2 0 3 1 7 1 0 -1 0.000 1 0 -1 0 0 5
	 6075 900 9000 900 9000 2700 6075 2700 6075 900
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8325 900 8550 900 8550 2700 8325 2700 8325 900
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 3825 10125 5175 10350 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 7875 1800 9900 1800 9675 2025
2 2 0 2 1 3 1 0 20 0.000 0 0 -1 0 0 5
	 8550 1665 9585 1665 9585 1935 8550 1935 8550 1665
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 4725 1440 5805 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 9675 1440 10755 1440
2 1 0 2 1 7 1 0 -1 0.000 0 0 -1 1 0 2
	1 0 2.00 120.00 240.00
	 7785 3465 8415 2835
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3600 1800 4950 1800 4725 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 1755 1800 3105 1800 2880 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 3375 2025 3375 5175 3600 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3150 5175 3600 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10350 1800 11700 1800 11475 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 12150 1800 13500 1800 13275 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 11700 5175 12150 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 11925 2025 11925 5175 12150 4950
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 10125 2025 10125 3375 10350 3150
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 2025 5400 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 10350 2025
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 5175 10350 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 4950 5175 5400 5175
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6750 2025 6750 1575
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 9900 2025 9900 1575
4 1 -1 0 0 0 20 0.0000 4 255 855 7290 1890 CU:gas\001
4 1 -1 0 0 0 20 0.0000 4 195 135 5175 1890 1\001
4 1 -1 0 0 0 20 0.0000 4 255 1590 5175 3690 INTF:entropy\001
4 1 -1 0 0 0 20 0.0000 4 195 135 10125 1890 1\001
4 1 1 1 0 3 20 0.0000 4 270 1035 7200 1440 Ideal gas\001
4 1 1 1 0 3 20 0.0000 4 210 885 4635 1305 Heat in\001
4 1 1 1 0 3 20 0.0000 4 210 1080 10170 1305 Work out\001
4 1 1 1 0 3 20 0.0000 4 270 1800 5130 5895 Entropy change\001
4 1 1 1 0 3 20 0.0000 4 270 1365 7110 3690 Ideal piston\001
4 1 -1 0 0 0 20 0.0000 4 195 1560 10125 3690 INTF:volume\001
4 1 -1 0 0 0 20 0.0000 4 195 135 3375 1890 0\001
4 2 4 0 0 0 20 0.0000 4 240 1140 1575 1890 SS:[Heat]\001
4 1 -1 0 0 0 20 0.0000 4 195 585 3375 5490 SS:T\001
4 1 1 1 0 3 20 0.0000 4 255 1485 3240 5895 Temperature\001
4 1 -1 0 0 0 20 0.0000 4 195 570 5130 5490 SS:S\001
4 1 -1 0 0 0 20 0.0000 4 195 615 10125 5490 SS:V\001
4 1 -1 0 0 0 20 0.0000 4 195 570 11880 5490 SS:P\001
4 0 4 0 0 0 20 0.0000 4 240 1230 13680 1890 SS:[Work]\001
4 1 1 1 0 3 20 0.0000 4 270 1815 10080 5850 Volume change\001
4 1 1 1 0 3 20 0.0000 4 195 975 11925 5850 Pressure\001
4 1 -1 0 0 0 20 0.0000 4 195 135 11925 1890 0\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_desc.tex version [9decb9a7b6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Cycle (Cycle_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1998/06/30 12:46:49  peterg
% %% Changed CT2 to CU
% %%
% %% Revision 1.1  1998/06/30 12:46:24  peterg
% %% Initial revision
% %%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   The acausal bond graph of system \textbf{Cycle} is
   displayed in Figure \Ref{Cycle_abg} and its label
   file is listed in Section \Ref{sec:Cycle_lbl}.
   The subsystems are listed in Section \Ref{sec:Cycle_sub}.

The system has two heat engine ports: 
\begin{enumerate}
\item \textbf{[Heat]} and
\item \textbf{[Work]}
\end{enumerate}
By convention, energy flows in to the \textbf{[Heat]} port and out of
the \textbf{[Work]} port. Both ports are true energy ports.


The subsystem \textbf{CU} (Section \Ref{sec:CU}) is a two-port
component describing an ideal gas. It has two energy ports which, with
integral causality correspond to
\begin{enumerate}
\item Entropy flow in; temperature out
\item Volume rate of change in; pressure out
\end{enumerate}

Four \textbf{SS} components are set up as sensors to measure the
important quantities pertaining to the cycle:
\begin{enumerate}
\item \textbf{S} to measure the integrated entropy flow
\item \textbf{T} to measure the (absolute) temperature
\item \textbf{V} to measure the integrated volume change
\item \textbf{P} to measure the pressure
\end{enumerate}

   \begin{table}[htbp]
     \begin{center}
       \leavevmode
       \begin{tabular}{|l|l|l|l|l|}
         \hline
         Cycle & Compression & Heating & Expansion & Cooling \\
         \hline
         Otto & II & II & II & II \\
         Carnot & II & DI & II & DI \\
         Diesel & II & ID & II & II \\
         Joule & II & ID & II & ID \\
         \hline
       \end{tabular}
       \caption{Cycles and their causality}
       \label{tab:cycles}
     \end{center}
   \end{table}
   
   A number of cycles can be built depending on the causality of the
   two ports \textbf{[Heat]} and \textbf{[Work]} of \textbf{Cycle}
   Some possible cycles listed in Tables \Ref{tab:cycles} where each
   table entry gives the causality on the heat and work ports
   respectively.

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_lbl.txt version [d82e73d04d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Cycle: Closed cycle with ideal gas
#DESCRIPTION Uses the CU two-port thermal capacitor.

#ALIAS in	Heat
#ALIAS out	Work

#ALIAS $1	ideal_gas
#ALIAS $2	c_v
#ALIAS $3	gamma_g
#ALIAS $4	m_g

## Label file for system Cycle (Cycle_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  1998/07/21 14:21:04  peterg
# ## New style file
# ##
# ## Revision 1.1  1997/12/08 20:24:43  peterg
# ## Initial revision
# ##
# ## Revision 1.1  1997/12/07 20:38:05  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank




# Component type CU
	gas	CU	ideal_gas,c_v,gamma_g,m_g

# Component type INTF
	entropy
	volume

# Component type SS
	S	SS	external,0
	T	SS	external,0
	V	SS	external,0
	P	SS	external,0
	[Heat]	SS	external,external
	[Work]	SS	external,external



Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Cycle_simp.r version [b8f003f5e9].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
%% Reduce commands to simplify output for system Cycle (Cycle_simp.r)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_abg.fig version [a9b0aef23c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 3600 2925 3600 3375
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 3510 4365 4770 Isothermal process\001
4 1 1 1 0 3 20 0.0000000 4 210 195 6120 3555 V\001
4 1 1 1 0 3 30 0.0000000 4 60 105 6165 3285 .\001
4 1 1 1 0 3 20 0.0000000 4 210 165 2700 3555 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2700 3285 .\001
4 1 1 1 0 3 20 0.0000000 4 210 1005 2700 2925 T=const\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_desc.tex version [ccb4c49b18].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Isothermal (Isothermal_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_input.txt version [65539a7718].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isothermal_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:17:37  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 10:47:34 BST 2003:   u(1) = -0.8;     # Volume rate-of-change
isothermal__work	= -0.8;     # Volume rate-of-change

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_lbl.txt version [ca0038f1d8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Isothermal: Isothermal thermodynamic process - ideal gas
#DESCRIPTION A dynamic simulation of an isothermal process using
#DESCRIPTION the Cycle component and the two-port CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas 

## Label file for system Isothermal (Isothermal_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:17:37  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:30:29  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat		SS	T_0,internal
	Work		SS	internal,external

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_numpar.txt version [7bdc15640d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isothermal_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma_g for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_rep.txt version [2eeec12cdd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Isothermal (Isothermal_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:17:37  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:20:18  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -ss Isothermal abg tex
mtt -ss Isothermal struc tex
mtt -ss Isothermal ode tex
mtt -ss Isothermal ss tex

mtt -ss Isothermal numpar txt
mtt -ss Isothermal input txt

mtt -ss Isothermal odeso ps 'Isothermal__cycle__V'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__P'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__S'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__T'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__V:Isothermal__cycle__P'
mtt -ss Isothermal odeso ps 'Isothermal__cycle__S:Isothermal__cycle__T'




Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_simpar.txt version [ba2a940038].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isothermal (Isothermal_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_simpar.txt_old version [ba2a940038].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isothermal (Isothermal_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isothermal/Isothermal_sspar.r version [14b711f7a3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (Isothermal_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	V_0;         % Isothermal_cycle_gas (c)
MTTX2 := 	S_0;         % Isothermal_cycle_entropy (3)
MTTX3 := 	V_0;         % Isothermal_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isothermal (Work)
;;END;

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_abg.fig version [4deb859011].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#FIG 3.1
Portrait
Center
Metric
1200 2
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 2026 3151 3601 3151 3376 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 3
	 5176 3151 6751 3151 6526 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 6751 2926 6751 3376
2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
	 2026 2926 2026 3376
2 4 0 1 31 7 1 0 -1 0.000 0 0 7 0 0 5
	 8325 5850 8325 450 675 450 675 5850 8325 5850
4 1 -1 0 0 0 20 0.0000000 4 270 1440 4411 3241 Cycle:cycle\001
4 0 -1 0 0 0 20 0.0000000 4 210 1110 6886 3241 SS:Work\001
4 2 -1 0 0 0 20 0.0000000 4 210 990 1936 3241 SS:Heat\001
4 1 1 1 0 3 20 0.0000000 4 210 180 2700 2925 T\001
4 1 1 1 0 3 20 0.0000000 4 210 180 6120 2925 P\001
4 1 1 1 0 3 30 0.0000000 4 390 4020 4365 4770 Isovolumetric process\001
4 1 1 1 0 3 20 0.0000000 4 210 510 6120 3555 V=0\001
4 1 1 1 0 3 30 0.0000000 4 60 105 5940 3285 .\001
4 1 1 1 0 3 20 0.0000000 4 210 165 2700 3555 S\001
4 1 1 1 0 3 30 0.0000000 4 60 105 2700 3285 .\001

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_desc.tex version [6670b4774d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Verbal description for system Isovolumetric (Isovolumetric_desc.tex)
% Generated by MTT on Thu Dec 4 15:59:55 GMT 1997.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% Revision 1.1  1997/12/09  12:30:26  peterg
% Initial revision
%
% Revision 1.1  1997/12/08  09:37:04  peterg
% Initial revision
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_input.txt version [b9136199c8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isovolumetric_input.txt)
# Generated by MTT at Thu Dec  4 11:17:09 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  2000/12/28 18:17:57  peterg
# %% To RCS
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Set the inputs
## Removed by MTT on Wed Aug  6 11:04:07 BST 2003:   u(1) = 1000;     #Entropy flow 
isovolumetric__heat	 = 1000;     #Entropy flow 

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_lbl.txt version [d8583137d5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#SUMMARY Isovolumetric: Isovolumetric thermodynamic process - ideal gas 
#DESCRIPTION A dynamic simulation of an Isovolumetric (constant volume)
#DESCRIPTION  process using the Cycle component and the two-port CU component.
#DESCRIPTION 
#DESCRIPTION the Cycle component and the two-port CU component.

#PAR P_0
#PAR T_0
#PAR V_0

#NOTPAR ideal_gas 

## Label file for system Isovolumetric (Isovolumetric_lbl.txt)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.2  2000/12/28 18:17:57  peterg
# ## To RCS
# ##
# ## Revision 1.1  1998/07/21 14:37:03  peterg
# ## Initial revision
# ##
# ###############################################################

## Each line should be of one of the following forms:
#	a comment (ie starting with #)
#	Component-name	CR_name	arg1,arg2,..argn
#	blank



# Component type Cycle
	cycle	none	ideal_gas;c_v;gamma_g;m_g	

# Component type SS
	Heat	SS	internal,external
	Work	SS	internal,0

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_numpar.txt version [df377cc85f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Numerical parameter file (Isovolumetric_numpar.txt)
# Generated by MTT at Thu Dec  4 11:44:46 GMT 1997

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.1  1998/03/04 11:45:49  peterg
# %% Initial revision
# %%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# Initial states -- needed to choose an approppriate mass
P_0 = 1e5;
V_0 = 1;
T_0 = 300;

# Parameters
c_v = 	718.0; # Parameter c_v for CU
gamma_g = 1.4; # Parameter gamma_g for CU
m_g = 	P_0*V_0/(T_0*(gamma_g-1)*c_v); # Parameter m for CU

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_rep.txt version [6651c44452].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# Outline report file for system Isovolumetric (Isovolumetric_rep.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  2000/12/28 18:17:57  peterg
% %% To RCS
% %%
% %% Revision 1.1  1999/02/21 02:21:03  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mtt -o -ss Isovolumetric abg tex
mtt -o -ss Isovolumetric struc tex
mtt -o -ss Isovolumetric ode tex
mtt -o -ss Isovolumetric ss tex

mtt -o -ss Isovolumetric numpar txt
mtt -o -ss Isovolumetric input txt

mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__V'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__P'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__S'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__T'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__V:Isovolumetric__cycle__P'
mtt -o -ss Isovolumetric odeso ps 'Isovolumetric__cycle__S:Isovolumetric__cycle__T'




Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_simpar.txt version [669617cdc7].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isovolumetric (Isovolumetric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_simpar.txt_old version [669617cdc7].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
%% Simulation parameters for system Isovolumetric (Isovolumetric_simpar.txt)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LAST=1.0
DT=0.01
STEPFACTOR=1

Deleted mttroot/mtt/lib/examples/Thermal/ThermodynamicProcesses/Isovolumetric/Isovolumetric_sspar.r version [cfb7ef7827].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
% Steady-state parameter file (Isovolumetric_sspar.r)
% Generated by MTT at Wed Mar  4 11:02:40 GMT 1998

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % $Id$
% % $Log$
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Set a pressure of 1 bar
P_0 := 10^5;

% Unit initial volume
V_0 := 1;

% Internal energy
U_0 := P_0*V_0/(gamma_g-1);

% Set initial temperature of 300k
T_0 := 300;

% Deduce the mass of gas
m :=  U_0/(T_0*c_v);

% Entropy
S_0 := U_0/T_0;

% Steady-state states
MTTX1 := 	U_0;         % Isovolumetric_cycle_gas (c)
MTTX2 := 	V_0;         % Isovolumetric_cycle_gas (c)
MTTX3 := 	S_0;         % Isovolumetric_cycle_entropy (3)
MTTX4 := 	V_0;         % Isovolumetric_cycle_volume (3)

% Steady-state inputs
MTTU1 := 	0; % Isovolumetric (Heat)
MTTU2 := 	0; % Isovolumetric (Work)
;;END;

Deleted mttroot/mtt/lib/examples/debian/README.Debian version [dac8a18a37].

1
2
3
4
5
6






-
-
-
-
-
-
mtt-examples for Debian
-----------------------

Library of examples for MTT (Model Transformation Tools).

 -- Geraint Paul Bevan <geraint@users.sourceforge.net>, Wed, 18 Feb 2004 22:47:08 +0000

Deleted mttroot/mtt/lib/examples/debian/changelog version [43ade6029e].

1
2
3
4
5
6






-
-
-
-
-
-
mtt-examples (5.0-1) unstable; urgency=low

  * Initial Release.

 -- Geraint Paul Bevan <geraint@users.sourceforge.net>  Wed, 18 Feb 2004 22:47:08 +0000

Deleted mttroot/mtt/lib/examples/debian/compat version [0c3ec9639d].

1

-
4

Deleted mttroot/mtt/lib/examples/debian/conffiles.ex version [d832dbb182].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
#
# If you want to use this conffile, remove all comments and put files that
# you want dpkg to process here using their absolute pathnames.
# See the policy manual
#
# for example:
# /etc/mtt-examples/mtt-examples.conf

Deleted mttroot/mtt/lib/examples/debian/control version [59260d425c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Source: mtt-examples
Section: contrib/math
Priority: optional
Maintainer: Geraint Paul Bevan <geraint@users.sourceforge.net>
Build-Depends: debhelper (>= 4.0.0)
Standards-Version: 3.6.0

Package: mtt-examples
Architecture: all
Depends: mtt
Description: Library of examples for Model Transformation Tools
 A library of examples containing models of systems which span a range of physical domains (including chemical, electrical, hydraulic, mechanical and thermal) and which demonstrate several uses of bond graph modelling with MTT, such as analysis, control and simulation.
 .
 The MTT homepage is located at http://mtt.sourceforge.net. An on-line manual is available at http://mtt.sourceforge.net/doc.
 .

Deleted mttroot/mtt/lib/examples/debian/copyright version [1acaedb686].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
This package was debianized by Geraint Paul Bevan <geraint@users.sourceforge.net> on
Wed, 18 Feb 2004 22:47:08 +0000.

It was downloaded from http://sourceforge.net/projects/mtt

Upstream Author(s): Peter Gawthrop <mtt@gawthrop.net>

Copyright:

mtt-examples is copyright (c) 1989-2004 by Peter J. Gawthrop.

You are free to distribute this software under the terms of the
GNU General Public License (GPL).

On Debian systems, the complete text of the GNU General Public License
can be found in /usr/share/common-licenses/GPL.

Deleted mttroot/mtt/lib/examples/debian/cron.d.ex version [2c98fb387d].

1
2
3
4




-
-
-
-
#
# Regular cron jobs for the mtt-examples package
#
0 4	* * *	root	mtt-examples_maintenance

Deleted mttroot/mtt/lib/examples/debian/dirs version [b541042ac0].

1
2


-
-
usr/bin

Deleted mttroot/mtt/lib/examples/debian/docs version [a7ffc6f8bf].

Deleted mttroot/mtt/lib/examples/debian/emacsen-install.ex version [f82ffb9b9c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh -e
# /usr/lib/emacsen-common/packages/install/mtt-examples

# Written by Jim Van Zandt <jrv@vanzandt.mv.com>, borrowing heavily
# from the install scripts for gettext by Santiago Vila
# <sanvila@ctv.es> and octave by Dirk Eddelbuettel <edd@debian.org>.

FLAVOR=$1
PACKAGE=mtt-examples

if [ ${FLAVOR} = emacs ]; then exit 0; fi

echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}

#FLAVORTEST=`echo $FLAVOR | cut -c-6`
#if [ ${FLAVORTEST} = xemacs ] ; then
#    SITEFLAG="-no-site-file"
#else
#    SITEFLAG="--no-site-file"
#fi
FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}

# Install-info-altdir does not actually exist. 
# Maybe somebody will write it.
if test -x /usr/sbin/install-info-altdir; then
    echo install/${PACKAGE}: install Info links for ${FLAVOR}
    install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/info/${PACKAGE}.info.gz
fi

install -m 755 -d ${ELCDIR}
cd ${ELDIR}
FILES=`echo *.el`
cp ${FILES} ${ELCDIR}
cd ${ELCDIR}

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF
${FLAVOR} ${FLAGS} ${FILES}
rm -f *.el path.el

exit 0

Deleted mttroot/mtt/lib/examples/debian/emacsen-remove.ex version [336be314aa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh -e
# /usr/lib/emacsen-common/packages/remove/mtt-examples

FLAVOR=$1
PACKAGE=mtt-examples

if [ ${FLAVOR} != emacs ]; then
    if test -x /usr/sbin/install-info-altdir; then
        echo remove/${PACKAGE}: removing Info links for ${FLAVOR}
        install-info-altdir --quiet --remove --dirname=${FLAVOR} /usr/info/mtt-examples.info.gz
    fi

    echo remove/${PACKAGE}: purging byte-compiled files for ${FLAVOR}
    rm -rf /usr/share/${FLAVOR}/site-lisp/${PACKAGE}
fi

Deleted mttroot/mtt/lib/examples/debian/emacsen-startup.ex version [0d279cfd52].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
;; -*-emacs-lisp-*-
;;
;; Emacs startup file for the Debian mtt-examples package
;;
;; Originally contributed by Nils Naumann <naumann@unileoben.ac.at>
;; Modified by Dirk Eddelbuettel <edd@debian.org>
;; Adapted for dh-make by Jim Van Zandt <jrv@vanzandt.mv.com>

;; The mtt-examples package follows the Debian/GNU Linux 'emacsen' policy and
;; byte-compiles its elisp files for each 'emacs flavor' (emacs19,
;; xemacs19, emacs20, xemacs20...).  The compiled code is then
;; installed in a subdirectory of the respective site-lisp directory.
;; We have to add this to the load-path:
(let ((package-dir (concat "/usr/share/"
                           (symbol-name flavor)
                           "/site-lisp/mtt-examples")))
  (when (file-directory-p package-dir)
        (setq load-path (cons package-dir load-path))))

Deleted mttroot/mtt/lib/examples/debian/init.d.ex version [958a43e196].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian 
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mtt-examples
NAME=mtt-examples
DESC=mtt-examples

test -x $DAEMON || exit 0

# Include mtt-examples defaults if available
if [ -f /etc/default/mtt-examples ] ; then
	. /etc/default/mtt-examples
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo "$NAME."
	;;
  #reload)
	#
	#	If the daemon can reload its config files on the fly
	#	for example by sending it SIGHUP, do it here.
	#
	#	If the daemon responds to changes in its config file
	#	directly anyway, make this a do-nothing entry.
	#
	# echo "Reloading $DESC configuration files."
	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
	#	/var/run/$NAME.pid --exec $DAEMON
  #;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0

Deleted mttroot/mtt/lib/examples/debian/manpage.1.ex version [2f4204b36f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MTT-EXAMPLES SECTION "February 18, 2004"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mtt-examples \- program to do something
.SH SYNOPSIS
.B mtt-examples
.RI [ options ] " files" ...
.br
.B bar
.RI [ options ] " files" ...
.SH DESCRIPTION
This manual page documents briefly the
.B mtt-examples
and
.B bar
commands.
This manual page was written for the Debian distribution
because the original program does not have a manual page.
Instead, it has documentation in the GNU Info format; see below.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
.\" respectively.
\fBmtt-examples\fP is a program that...
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH SEE ALSO
.BR bar (1),
.BR baz (1).
.br
The programs are documented fully by
.IR "The Rise and Fall of a Fooish Bar" ,
available via the Info system.
.SH AUTHOR
This manual page was written by Geraint Paul Bevan <geraint@users.sourceforge.net>,
for the Debian project (but may be used by others).

Deleted mttroot/mtt/lib/examples/debian/manpage.sgml.ex version [97d6404147].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156




























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Process this file with docbook-to-man to generate an nroff manual
     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
     less'.  A typical entry in a Makefile or Makefile.am is:

manpage.1: manpage.sgml
	docbook-to-man $< > $@

    
	The docbook-to-man binary is found in the docbook-to-man package.
	Please remember that if you create the nroff version in one of the
	debian/rules file targets (such as build), you will need to include
	docbook-to-man in your Build-Depends control field.

  -->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
  <!ENTITY dhsurname   "<surname>SURNAME</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>February 18, 2004</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>SECTION</manvolnum>">
  <!ENTITY dhemail     "<email>geraint@users.sourceforge.net</email>">
  <!ENTITY dhusername  "Geraint Paul Bevan">
  <!ENTITY dhucpackage "<refentrytitle>MTT-EXAMPLES</refentrytitle>">
  <!ENTITY dhpackage   "mtt-examples">

  <!ENTITY debian      "<productname>Debian</productname>">
  <!ENTITY gnu         "<acronym>GNU</acronym>">
  <!ENTITY gpl         "&gnu; <acronym>GPL</acronym>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2003</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>&dhpackage;</refname>

    <refpurpose>program to do something</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&dhpackage;</command>

      <arg><option>-e <replaceable>this</replaceable></option></arg>

      <arg><option>--example <replaceable>that</replaceable></option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>This manual page documents briefly the
      <command>&dhpackage;</command> and <command>bar</command>
      commands.</para>

    <para>This manual page was written for the &debian; distribution
      because the original program does not have a manual page.
      Instead, it has documentation in the &gnu;
      <application>Info</application> format; see below.</para>

    <para><command>&dhpackage;</command> is a program that...</para>

  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <para>These programs follow the usual &gnu; command line syntax,
      with long options starting with two dashes (`-').  A summary of
      options is included below.  For a complete description, see the
      <application>Info</application> files.</para>

    <variablelist>
      <varlistentry>
        <term><option>-h</option>
          <option>--help</option>
        </term>
        <listitem>
          <para>Show summary of options.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-v</option>
          <option>--version</option>
        </term>
        <listitem>
          <para>Show version of program.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>bar (1), baz (1).</para>

    <para>The programs are documented fully by <citetitle>The Rise and
      Fall of a Fooish Bar</citetitle> available via the
      <application>Info</application> system.</para>
  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (but may be used by others).  Permission is
      granted to copy, distribute and/or modify this document under
      the terms of the &gnu; General Public License, Version 2 any 
	  later version published by the Free Software Foundation.
    </para>
	<para>
	  On Debian systems, the complete text of the GNU General Public
	  License can be found in /usr/share/common-licenses/GPL.
	</para>

  </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->


Deleted mttroot/mtt/lib/examples/debian/manpage.xml.ex version [3091db28f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148




















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [

<!--

Process this file with an XSLT processor: `xsltproc \
-''-nonet /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/\
manpages/docbook.xsl manpage.dbk'.  A manual page
<package>.<section> will be generated.  You may view the
manual page with: nroff -man <package>.<section> | less'.  A
typical entry in a Makefile or Makefile.am is:

DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/\
manpages/docbook.xsl
XP=xsltproc -''-nonet

manpage.1: manpage.dbk
        $(XP) $(DB2MAN) $<
    
The xsltproc binary is found in the xsltproc package.  The
XSL files are in docbook-xsl.  Please remember that if you
create the nroff version in one of the debian/rules file
targets (such as build), you will need to include xsltproc
and docbook-xsl in your Build-Depends control field.

-->

  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
  <!ENTITY dhsurname   "<surname>SURNAME</surname>">
  <!-- Please adjust the date whenever revising the manpage. -->
  <!ENTITY dhdate      "<date>February 18, 2004</date>">
  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
       allowed: see man(7), man(1). -->
  <!ENTITY dhsection   "<manvolnum>SECTION</manvolnum>">
  <!ENTITY dhemail     "<email>geraint@users.sourceforge.net</email>">
  <!ENTITY dhusername  "Geraint Paul Bevan">
  <!ENTITY dhucpackage "<refentrytitle>MTT-EXAMPLES</refentrytitle>">
  <!ENTITY dhpackage   "mtt-examples">

  <!ENTITY debian      "<productname>Debian</productname>">
  <!ENTITY gnu         "<acronym>GNU</acronym>">
  <!ENTITY gpl         "&gnu; <acronym>GPL</acronym>">
]>

<refentry>
  <refentryinfo>
    <address>
      &dhemail;
    </address>
    <author>
      &dhfirstname;
      &dhsurname;
    </author>
    <copyright>
      <year>2003</year>
      <holder>&dhusername;</holder>
    </copyright>
    &dhdate;
  </refentryinfo>
  <refmeta>
    &dhucpackage;

    &dhsection;
  </refmeta>
  <refnamediv>
    <refname>&dhpackage;</refname>

    <refpurpose>program to do something</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&dhpackage;</command>

      <arg><option>-e <replaceable>this</replaceable></option></arg>

      <arg><option>--example <replaceable>that</replaceable></option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  <refsect1>
    <title>DESCRIPTION</title>

    <para>This manual page documents briefly the
      <command>&dhpackage;</command> and <command>bar</command>
      commands.</para>

    <para>This manual page was written for the &debian; distribution
      because the original program does not have a manual page.
      Instead, it has documentation in the &gnu;
      <application>Info</application> format; see below.</para>

    <para><command>&dhpackage;</command> is a program that...</para>

  </refsect1>
  <refsect1>
    <title>OPTIONS</title>

    <para>These programs follow the usual &gnu; command line syntax,
      with long options starting with two dashes (`-').  A summary of
      options is included below.  For a complete description, see the
      <application>Info</application> files.</para>

    <variablelist>
      <varlistentry>
        <term><option>-h</option>
          <option>--help</option>
        </term>
        <listitem>
          <para>Show summary of options.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><option>-v</option>
          <option>--version</option>
        </term>
        <listitem>
          <para>Show version of program.</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>SEE ALSO</title>

    <para>bar (1), baz (1).</para>

    <para>The programs are documented fully by <citetitle>The Rise and
      Fall of a Fooish Bar</citetitle> available via the
      <application>Info</application> system.</para>
  </refsect1>
  <refsect1>
    <title>AUTHOR</title>

    <para>This manual page was written by &dhusername; &dhemail; for
      the &debian; system (but may be used by others).  Permission is
      granted to copy, distribute and/or modify this document under
      the terms of the &gnu; General Public License, Version 2 any 
	  later version published by the Free Software Foundation.
    </para>
	<para>
	  On Debian systems, the complete text of the GNU General Public
	  License can be found in /usr/share/common-licenses/GPL.
	</para>

  </refsect1>
</refentry>

Deleted mttroot/mtt/lib/examples/debian/menu.ex version [50c60cd5ce].

1
2


-
-
?package(mtt-examples):needs=X11|text|vc|wm section=Apps/see-menu-manual\
  title="mtt-examples" command="/usr/bin/mtt-examples"

Deleted mttroot/mtt/lib/examples/debian/mtt-examples-default.ex version [05a379d706].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
# Defaults for mtt-examples initscript
# sourced by /etc/init.d/mtt-examples
# installed at /etc/default/mtt-examples by the maintainer scripts

#
# This is a POSIX shell fragment
#

# Additional options that are passed to the Daemon.
DAEMON_OPTS=""

Deleted mttroot/mtt/lib/examples/debian/mtt-examples.doc-base.EX version [45f81688d7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Document: mtt-examples
Title: Debian mtt-examples Manual
Author: <insert document author here>
Abstract: This manual describes what mtt-examples is
 and how it can be used to
 manage online manuals on Debian systems.
Section: unknown

Format: debiandoc-sgml
Files: /usr/share/doc/mtt-examples/mtt-examples.sgml.gz

Format: postscript
Files: /usr/share/doc/mtt-examples/mtt-examples.ps.gz

Format: text
Files: /usr/share/doc/mtt-examples/mtt-examples.text.gz

Format: HTML
Index: /usr/share/doc/mtt-examples/html/index.html
Files: /usr/share/doc/mtt-examples/html/*.html

  

Deleted mttroot/mtt/lib/examples/debian/postinst.ex version [fc24fc87dc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# postinst script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#

case "$1" in
    configure)

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/lib/examples/debian/postrm.ex version [71b1621095].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# postrm script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
       purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)


        ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

Deleted mttroot/mtt/lib/examples/debian/preinst.ex version [fa7af07255].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# preinst script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
#
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    install|upgrade)
#        if [ "$1" = "upgrade" ]
#        then
#            start-stop-daemon --stop --quiet --oknodo  \
#                --pidfile /var/run/mtt-examples.pid  \
#                --exec /usr/sbin/mtt-examples 2>/dev/null || true
#        fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/lib/examples/debian/prerm.ex version [2e6b5a3d99].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
# prerm script for mtt-examples
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    remove|upgrade|deconfigure)
#       install-info --quiet --remove /usr/info/mtt-examples.info.gz
        ;;
    failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


Deleted mttroot/mtt/lib/examples/debian/rules version [6acbd63d43].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1




CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.

	touch configure-stamp


build: build-stamp

build-stamp: configure-stamp 
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)
	#/usr/bin/docbook-to-man debian/mtt-examples.sgml > mtt-examples.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) clean

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Add here commands to install the package into debian/mtt-examples.
	$(MAKE) install DESTDIR=$(CURDIR)/debian/mtt-examples


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
#	dh_installdocs
	dh_installexamples
#	dh_install
#	dh_installmenu
#	dh_installdebconf	
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_python
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

Deleted mttroot/mtt/lib/examples/debian/watch.ex version [366a56825c].

1
2
3
4
5
6






-
-
-
-
-
-
# Example watch control file for uscan
# Rename this file to "watch" and then you can run the "uscan" command
# to check for upstream updates and more.
# Site		Directory		Pattern			Version	Script
version=2
sunsite.unc.edu	/pub/Linux/Incoming	mtt-examples-(.*)\.tar\.gz	debian	uupdate

Deleted mttroot/mtt/lib/latex/bg.sty version [d6c82b5f87].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Bond Graph commands
\newcommand{\B}[1]{\text{\sffamily\textbf{#1}}}
\newcommand{\AmpE}{\B{AE }}
\newcommand{\AF}{\B{AF }}
\newcommand{\C}{\B{C }}
\newcommand{\CSW}{\B{CSW }}
\newcommand{\De}{\B{De }}
\newcommand{\Df}{\B{Df }}
\newcommand{\I}{\B{I }}
\newcommand{\INTF}{\B{INTF }}
\newcommand{\ISW}{\B{ISW }}
\newcommand{\R}{\B{R }}
\newcommand{\Se}{\B{Se }}
\newcommand{\Sf}{\B{Sf }}
\newcommand{\Ss}{\B{SS }}
\newcommand{\one}{\B{1 }}
\newcommand{\zero}{\B{0 }}
\newcommand{\TF}{\B{TF }}
\newcommand{\GY}{\B{GY }}

%% Bond Graph components with label
\newcommand{\BB}[2]{$\B{#1}$:$\mathbf{#2}$} %Generic

\newcommand{\BC}[1]{\BB{C}{#1}}
\newcommand{\BI}[1]{\BB{I}{#1}}
\newcommand{\BR}[1]{\BB{R}{#1}}

\newcommand{\BSS}[1]{\BB{SS}{#1}}
\newcommand{\BSe}[1]{\BB{Se}{#1}}
\newcommand{\BSf}[1]{\BB{Sf}{#1}}
\newcommand{\BDe}[1]{\BB{De}{#1}}
\newcommand{\BDf}[1]{\BB{Df}{#1}}

\newcommand{\BTF}[1]{\BB{TF}{#1}}
\newcommand{\BGY}[1]{\BB{TF}{#1}}

Deleted mttroot/mtt/lib/octave/.octaverc version [04e2bb682d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Startup file for Octave for use with MTT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

implicit_str_to_num_ok = 1;
empty_list_elements_ok = 1;
warn_string_concat = 0;

## Turn off irrelevant warnings
warning off Octave:possible-matlab-short-circuit-operator
warning off Octave:deprecated-syntax

## No more core dumps
crash_dumps_octave_core(0)
sigterm_dumps_octave_core(0)
sighup_dumps_octave_core(0)

Deleted mttroot/mtt/lib/octave/README version [b32763b888].

1

-
This contains some octave specific helps to MTT

Deleted mttroot/mtt/lib/octave/mkoctfile version [e7f6db0ac4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202










































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh
#
# mkoctfile -- create a .oct file suitable for dynamic linking by
# Octave.
echo mkoctfile with optimisation level 0
# Exit immediately on any error.

set -e

# Default values for these variables are filled in when Octave is
# compiled. 

: ${CPPFLAGS=""}
: ${INCFLAGS="-I/usr/include -I/usr/include/octave-2.0.16"}
: ${F77="g77"}
: ${FFLAGS="-O0"}
: ${FPICFLAG="-fPIC"}
: ${CC="gcc"}
: ${CFLAGS="-DHAVE_CONFIG_H -mieee-fp -O0"}
: ${CPICFLAG="-fPIC"}
: ${CXX="c++"}
: ${CXXFLAGS="-O0"}
: ${CXXPICFLAG="-fPIC"}
: ${XTRA_CFLAGS="-mieee-fp -fno-rtti -fno-exceptions -fno-implicit-templates"}
: ${XTRA_CXXFLAGS="-mieee-fp -fno-rtti -fno-exceptions -fno-implicit-templates"}

: ${SH_LD="c++"}
: ${SH_LDFLAGS="-shared"}

: ${ALL_FFLAGS="$FFLAGS"}

: ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"}

: ${ALL_CXXFLAGS="$INCFLAGS $XTRA_CXXFLAGS $CXXFLAGS"}

# Local variables.

usage_msg="usage: mkoctfile [options] file ..."

cfiles=
ccfiles=
f77files=
objfiles=
octfiles=
octfile=
incflags=
defs=
ldflags=
dbg=:
strip=false

if [ $# -eq 0 ]; then
  echo $usage_msg
  exit 1;
fi

while [ $# -gt 0 ]; do
  file=
  case "$1" in
    *.c)
      file=$1
      cfiles="$cfiles $file"
    ;;
    *.cc | *.C | *.cpp)
      file=$1
      ccfiles="$ccfiles $file"
    ;;
    *.f | *.F)
      file=$1
      f77files="$f77files $file"
    ;;
    *.o)
      file=$1
      objfiles="$objfiles $file"
    ;;
    -d | --debug | -v | --verbose)
      dbg=echo
    ;;
    -h | -\? | --help)
      echo $usage_msg
      cat << EOF

Options:

  -h, -?, --help          Print this message.
  -IDIR                   Add -IDIR to compile commands.
  -DDEF                   Add -DDEF to compile commands.
  -lLIB                   Add library LIB to link command.
  -LDIR                   Add -LDIR to link command.
  -o FILE, --output FILE  Output file name.  Default extension is .oct.
  -s, --strip             Strip output file.
  -v, --verbose           Echo commands as they are executed.

  FILE                    Compile or link FILE.  Recognized file types are:

			    .c    C source
			    .cc   C++ source
			    .C    C++ source
			    .cpp  C++ source
			    .f    Fortran source
			    .F    Fortran source
			    .o    object file

EOF
      exit 0
    ;;
    -I*)
      incflags="$incflags $1"
    ;;
    -D*)
      defs="$defs $1"
    ;;
    -[lL]*)
      ldflags="$ldflags $1"
    ;;
    -o | --output)
      shift
      if [ $# -gt 0 ]; then
        octfile=`echo $1 | sed 's,\.[^.]*$,,'`.oct
      else
        echo "mkoctfile: output file name missing"
      fi
    ;;
    -s | --strip)
      strip=true
    ;;
    *)
      echo "mkoctfile: unrecognized argument $1"
      exit 1
    ;;
  esac
  if [ -n "$file" ]; then
    if [ -z "$octfile" ]; then
      octfile=`echo $file | sed 's,\.[^.]*$,,'`.oct
    fi
  fi
  shift
done

# Compile Fortran, C, and C++ files.  Add the name of each object file
# that is produced to the overall list of object files.

if [ -n "$f77files" ]; then
  for f in $f77files; do
    case $f in
      *.f)
        b=`echo $f | sed 's,\.f$,,'`
      ;;
      *.F)
        b=`echo $f | sed 's,\.F$,,'`
      ;;
    esac
    o=$b.o
    objfiles="$objfiles $o"
    $dbg $F77 -c $FPICFLAG $ALL_FFLAGS $f -o $o
    eval $F77 -c $FPICFLAG $ALL_FFLAGS $f -o $o
  done
fi

if [ -n "$cfiles" ]; then
  for f in $cfiles; do
    b=`echo $f | sed 's,\.c$,,'`
    o=$b.o
    objfiles="$objfiles $o"
    $dbg $CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $incflags $defs $f -o $o
    eval $CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $incflags $defs $f -o $o
  done
fi

if [ -n "$ccfiles" ]; then
  for f in $ccfiles; do
    case $f in
      *.cc)
        b=`echo $f | sed 's,\.cc$,,'`
      ;;
      *.C)
        b=`echo $f | sed 's,\.C$,,'`
      ;;
      *.cpp)
        b=`echo $f | sed 's,\.cpp$,,'`
      ;;
    esac
    o=$b.o
    objfiles="$objfiles $o"
    $dbg $CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $incflags $defs $f -o $o
    eval $CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $incflags $defs $f -o $o
  done
fi

# Link all the object files.

$dbg $SH_LD $SH_LDFLAGS -o $octfile $objfiles $ldflags
eval $SH_LD $SH_LDFLAGS -o $octfile $objfiles $ldflags

# Maybe strip it.

if $strip; then
  $dbg strip $octfile
  eval strip $octfile
fi

exit 0

Deleted mttroot/mtt/lib/reduce/fix_c.r version [4c2ca104c3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%% Fixes for c-code generation

%% Set PI explicitly here to avoid later conflict with cc headers
%% if PI is not already a number (i.e. on rounded has not been set)
IF NOT NUMBERP (pi) THEN LET PI = 3.14159$

ON ROUNDED$ % No integer output

%% Changes x^y to pow(x,y)
 OPERATOR pow$
 FOR ALL x,y LET x^y = pow(x,y)$ % Use the pow function
 FOR ALL x,y LET x**y = pow(x,y)$ % Use the pow function
 
 %% Derivatives
 FOR ALL f,g,x LET df(pow(f,g),x)=
 	   pow(f,g-1) * (df(f,x)*g + df(g,x)*f*log(f))$

 %% Special cases
 FOR ALL x LET pow(x,0) = 1$
 FOR ALL x LET pow(x,1) = x$

OPERATOR fabs$
FOR ALL x let abs(x) = fabs(x)$


END$

Deleted mttroot/mtt/lib/reduce/reserved_words.make version [58b98880d4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

reduce_reserved_word_manual_page=${1:-"/usr/local/reduce/doc/manual/appenda.tex"}
output="reserved_words.txt"

cat $reduce_reserved_word_manual_page                   |\
    tr "\n" " "                                         |\
    sed 's/\\\_/_/g'                                    |\
    sed 's/\\tt\ \([A-Za-z0-9_]*\)/\"\1\"/g'            |\
    tr " " "\n"                                         |\
    sed 's/\{//g'                                       |\
    sed 's/\}//g'                                       |\
    gawk -F\" '(NF==3) { printf "%s\n",$2 }'            |\
    sort -u						\
> $output

Deleted mttroot/mtt/lib/reduce/reserved_words.txt version [727a3fd398].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ABS
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ADJPREC
ALGEBRAIC
ALGINT
ALLBRANCH
ALLFAC
AND
ANTISYMMETRIC
APPEND
ARGLENGTH
ARRAY
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
BEGIN
BFSPACE
BYE
CARD_NO
CEILING
CLEAR
CLEARRULES
COEFF
COEFFN
COFACTOR
COMBINEEXPT
COMBINELOGS
COMMENT
COMP
COMPLEX
CONJ
CONS
CONT
COS
COSH
COT
COTH
CRAMER
CREF
CSC
CSCH
DECOMPOSE
DEFINE
DEFN
DEG
DEMO
DEN
DEPEND
DET
DF
DIFFERENCE
DILOG
DISPLAY
DIV
DO
E
ECHO
ED
EDITDEF
EI
END
EPS
EQ
EQUAL
ERF
ERRCONT
EVALLHSEQP
EVAL_MODE
EVEN
EVENP
EXP
EXPANDLOGS
EXPR
EXPT
EZGCD
FACTOR
FACTORIAL
FACTORIZE
FEXPR
FIRST
FIX
FIXP
FLOOR
FOR
FORALL
FOREACH
FORT
FORT_WIDTH
FREEOF
FULLROOTS
G
GCD
GEQ
GO
GOTO
GREATERP
HIGH_POW
HYPOT
I
IF
IFACTOR
IMPART
IN
INDEX
INFINITY
INFIX
INPUT
INT
INTEGER
INTERPOL
INTSTR
K
KORDER
LAMBDA
LCM
LCOF
LENGTH
LEQ
LESSP
LET
LHS
LINEAR
LINELENGTH
LISP
LIST
LISTARGP
LISTARGS
LN
LOAD
LOAD_PACKAGE
LOG
LOG10
LOGB
LOW_POW
LTERM
MACRO
MAINVAR
MASS
MAT
MATCH
MATEIGEN
MATRIX
MAX
MCD
MEMBER
MEMQ
MIN
MINUS
MKID
MODULAR
MSG
MSHELL
MULTIPLICITIES
NAT
NEQ
NERO
NEXTPRIME
NIL
NODEPEND
NONCOM
NONZERO
NOSPLIT
NOSPUR
NULLSPACE
NUM
NUMBERP
ODD
OFF
ON
OPERATOR
OR
ORDER
ORDP
OUT
OUTPUT
PART
PAUSE
PERIOD
PF
PI
PLUS
PRECEDENCE
PRECISE
PRECISION
PRET
PRI
PRIMEP
PRINT_PRECISION
PROCEDURE
PRODUCT
QUIT
QUOTIENT
RANDOM
RANDOM_NEW_SEED
RANK
RAT
RATARG
RATIONAL
RATIONALIZE
RATPRI
REAL
REDERR
REDUCT
REMAINDER
REMFAC
REMIND
REPART
REPEAT
REST
RESULTANT
RETRY
RETURN
REVERSE
REVPRI
RHS
RLISP88
ROOT_MULTIPLICITY
ROUND
ROUNDALL
ROUNDBF
ROUNDED
SAVEAS
SAVESTRUCTR
SCALAR
SEC
SECH
SECOND
SET
SETMOD
SETQ
SHARE
SHOWRULES
SHOWTIME
SHUT
SIGN
SIN
SINH
SMACRO
SOLVE
SOLVESINGULAR
SPUR
SQRT
STRUCTR
SUB
SUM
SYMBOLIC
SYMMETRIC
T
TAN
TANH
THIRD
TIME
TIMES
TP
TRA
TRACE
TRFAC
TRIGFORM
TRINT
UNTIL
VARNAME
VECDIM
VECTOR
WEIGHT
WHEN
WHERE
WHILE
WRITE
WS
WTLEVEL

Deleted mttroot/mtt/lib/rep/cxxsim.cc version [e39d33615e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/*  cxxsim:  creates a C++ simulation from MTT elementary system equations
 *  Copyright (C) 2000,2002  Geraint Paul Bevan
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <string>

namespace cxxsim {

  class cr {
    
  public:

    cr		(std::string system_name);
    
    void read	(std::ifstream &file);
    void write	(std::ofstream &file);
   
    friend std::ifstream &operator>> (std::ifstream &file, cr &c);
    friend std::ofstream &operator<< (std::ofstream &file, cr &c);
    
  private:

    std::string			name;

    std::list<std::string>	L;
  };

  class equations {

  public:

    equations	(std::string system_name);    

    void read	(std::ifstream &file);
    void write	(std::ofstream &file);
   
    friend std::ifstream &operator>> (std::ifstream &file, equations &e);
    friend std::ofstream &operator<< (std::ofstream &file, equations &e);

  private:
    
    void descend	(std::string s);
    void parse		(void);

    std::string				name; // system name

    // list of statements collected by reader
    std::list<std::string>		statements;

    std::list<std::string>		leqn; // final expressions
    std::list<std::string>		lvar; // intermediate expressions
    std::list<std::string>		loop; // algebraic loops

    // table of final and intermediate expressions
    std::map<std::string, std::string>	meqn; // lhs, rhs mapping
    std::map<std::string, std::string>	mvar;

    // tag is symbol denoting an intermediate variable
    std::string				tag; // denotes intermediates

    // token delimiters (not ([{.`'" or alphanumeric)
    std::string				delim;
  };

  class parameter {

  public:

    parameter	(std::string system_name);

    void read	(std::ifstream &file);
    void write	(std::ofstream &file);

    friend std::ifstream &operator>> (std::ifstream &file, parameter &p);
    friend std::ofstream &operator<< (std::ofstream &file, parameter &p);

  private:

    std::string		name;

    struct record {
      std::string	variable;
      std::string	component;
    };
    
    typedef struct record record_t;
    std::list<record_t>			L;
  };

  class structure {
    
  public:

    structure		(std::string system_name);

    void read		(std::ifstream &file);
    void write		(std::ofstream &file);

    friend std::ifstream &operator>> (std::ifstream &file, structure &s);
    friend std::ofstream &operator<< (std::ofstream &file, structure &s);

  private:

    void write_declare	(std::ofstream &file);
    void write_input	(std::ofstream &file);
    void write_logic	(std::ofstream &file);
    void write_state	(std::ofstream &file);

    std::string		name;

    struct record {
      std::string	vec;	// vector: u, x, y, yz
      unsigned int	num;	// position of element in vector
      std::string	cmp;	// component
      std::string	fnm;	// full name
      unsigned int	rpt;	// number of repetitions
      std::string	cty;	// causality
    };

    typedef struct record record_t;
    std::list<record_t>			Lu;
    std::list<record_t>			Lx;
    std::list<record_t>			Ly;
    std::list<record_t>			Lyz;
    std::list<record_t>::iterator	i;    
  };

  cr::cr (std::string system_name){
    name = system_name;
  }

  void
  cr::read (std::ifstream &file){
    std::string r;
    while (file >> r){
      L.push_back(r);
    }
  }

  void
  cr::write (std::ofstream &file){
    file << "enum causality { effort, flow, state };" << std::endl
	 << "typedef enum causality causality_t;" << std::endl;
    std::list<std::string>::iterator i;
    for (i = L.begin(); i != L.end(); i++){
      if ((*i != "SS") && (*i != "ISW")){
	file << "#include <" << *i << ".hh>" << std::endl;
      }
    }
    file << std::endl;
  }

  std::ifstream &operator>> (std::ifstream &file, cr &c){
    c.read(file);
    return file;
  }
  
  std::ofstream &operator<< (std::ofstream &file, cr &c){
    c.write(file);
    return file;
  }

  equations::equations (std::string system_name){
    name = system_name;
    tag = system_name;
    delim = "~!@#$%^&*)-+=]}\\|;:,<>/?";
  };

  void
  equations::read (std::ifstream &file){
    
    char				c;
    std::string				s;
    std::string				t;

    unsigned int			i;

    //    file.unsetf(std::ios::skipws);
    file.setf(std::ios::skipws);

    // read lines from file (no max length, unlike std::getline)
    while (file >> c){
      s = "";
      while (c != ';' && file){
	if (c == '%'){
	  file.unsetf(std::ios::skipws);
	  while ((c != '\n') && file){
	    file >> c;			     // eat comment
	  }
	  file.setf(std::ios::skipws);
	} else {
	  if ((c != ' ') && (c != '\t')){    // strip whitespace
	    s += c;
	  }
	  file >> c;
	}
      }
      
      // fix vector references
      t = "MTTu(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 5, "mttu[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      t = "MTTx(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 5, "mttx[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      t = "MTTdX(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 6, "mttdx[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      t = "MTTy(";
      while ((i = s.find(t)) < s.length()){
	s.replace(i, 5, "mtty[");
	i += s.substr(i, s.length()).find(",1)");
	s.replace(i, 3, "]");
      }
      
      // strip newlines
      while ((i = s.find('\n')) < s.length()){
	s.replace(i, 1, "");
      }

      if ((s != "") && (s != "END")){
	// add statement to list
	statements.push_back(s);
      }
    }

    // finished reading, time to comprehend ...
    this->parse();
  }
  
  void
  equations::write (std::ofstream &file){

    std::list<std::string>::iterator	eqn;

    file << "void"					<< std::endl
	 << this->name << "_ode(const double t,"	<< std::endl
	 << "\tdouble *mttu,"				<< std::endl
	 << "\tdouble *mttx,"				<< std::endl
	 << "\tdouble *mttdx,"				<< std::endl
	 << "\tdouble *mtty)"				<< std::endl
	 << "{"						<< std::endl;
    for (eqn = leqn.begin(); eqn != leqn.end(); eqn++){
      file << *eqn << " = " << meqn[*eqn] << ";" << std::endl;
    }
    file << "} // " << this->name << "_ode"		<< std::endl;
  };

  void
  equations::descend (std::string s){

    char		c;
    unsigned int	i;
    bool		cont;

    std::list<std::string>::iterator	var;

    loop.push_back(s);

    // find algebraic loops
    for (var = loop.begin(); var != loop.end(); var++){
      if ((i = mvar[s].find(*var)) < mvar[s].length()){
	c = mvar[s].c_str()[i + var->length()];
	if (delim.find(c) < delim.length()){
	  std::cerr << std::endl
		    << "warning: algebraic loop" << std::endl
		    << '\t' << s << " = " << mvar[s].substr(0, 60);
	  if (mvar[s].length() > 60){
	    std::cerr << " ...";
	  }
	  std::cerr << std::endl << std::endl;
	  mvar[s] = s + "____loop";
	}
      }
    }

    // substitutes intermediate variables for their expansion
    do {
      cont = false;
      for (var = lvar.begin(); var != lvar.end(); var++){
	// check for token match
	while ((i = mvar[s].find(*var)) < mvar[s].length()){
	  // ensure exact match
	  c = mvar[s].c_str()[i + var->length()];
	  if (delim.find(c) < delim.length()){
	    // expand expression recursively
	    this->descend(*var);
	    // check match again, map may have changed
	    if ((i = mvar[s].find(*var)) < mvar[s].length()){
	      c = mvar[s].c_str()[i + var->length()];
	      if (delim.find(c) < delim.length()){
	    	// substitute expression
		mvar[s].replace(i, var->length(), mvar[*var]);
		// continue
		cont = true;
	      }
	    }	    
	  }
	}
      }
    } while (cont);
    loop.pop_back();
  }
  
  void
  equations::parse (void){
    
    char		c;
    unsigned int	i;

    std::string		lhs;
    std::string		rhs;
    
    std::list<std::string>::iterator	s;

    std::list<std::string>::iterator	eqn;
    std::list<std::string>::iterator	var;

    for (s = statements.begin(); s != statements.end(); s++){
      // parse statement
      if ((i = s->find(":=")) < s->length()){
	lhs = s->substr(0, i);
	rhs = s->substr(i+2, s->length());
	
	// separate intermediate and final variables
	if (s->substr(0, tag.length()) == tag){
	  // add to table of intermediate variables
	  lvar.push_back(lhs);
	  mvar[lhs] = "(" + rhs + ")";
	} else {
	  // add to table of final variables
	  leqn.push_back(lhs);
	  meqn[lhs] = rhs + ";";
	}
      } else {
	std::cerr << std::endl
		  << "warning: non-assignment -- ignoring"
		  << std::endl
		  << '\t' << *s << std::endl
		  << std::endl;
      }
    }
      
    // expand rhs of intermediate variables
    for (var = lvar.begin(); var != lvar.end(); var++){
      loop.clear();
      descend(*var);
    }
    
    // substitute expanded expressions into final equations
    for (eqn = leqn.begin(); eqn != leqn.end(); eqn++){
      for (var = lvar.begin(); var != lvar.end(); var++){
	while ((i = meqn[*eqn].find(*var)) < meqn[*eqn].length()){
	  c = meqn[*eqn].c_str()[i + var->length()];
	  if (delim.find(c) < delim.length()){
	    meqn[*eqn].replace(i, var->length(), mvar[*var]);
	  }
	}
      }
    }
  }

    std::ifstream &operator>> (std::ifstream &file, equations &e){
    e.read(file);
    return file;
  }
  
  std::ofstream &operator<< (std::ofstream &file, equations &e){
    e.write(file);
    return file;
  }

  parameter::parameter (std::string system_name){
    name = system_name;
  };

  void
  parameter::read (std::ifstream &file){
    record_t r;
    while (file >> r.variable >> r.component){
      if (r.variable.find("#") == 0){
	file.unsetf(std::ios::skipws);
	char c = '\0';
	while (c != '\n'){
	  file >> c;
	}
	file.setf(std::ios::skipws);
      } else {
	L.push_back(r);
      }
    }
  }

  void
  parameter::write (std::ofstream &file){
    std::list<record_t>::iterator i;
    std::string type;
    std::string value;
    for (i = L.begin(); i != L.end(); i++){
      if (i->variable.substr(0, 6) == "bool__"){
	type = "bool";
	value = "false";
      } else if (i->variable.substr(0, 6) == "char__"){
	type = "char";
	value = "\0";
      } else if (i->variable.substr(0, 8) == "double__"){
	type = "double";
	value = "1.0";
      } else if (i->variable.substr(0, 7) == "float__"){
	type = "float";
	value = "1.0";
      } else if (i->variable.substr(0, 5) == "int__"){
	type = "int";
	value = "1";
      } else if (i->variable.substr(0, 7) == "string__"){
	type = "std::string";
	value = "hello world!";
      } else {
	type = "double";
	value = "1.0";
      }
      file << "static " << type << "\t" << i->variable << " = " << value
	   << ";\t// " << i->component << std::endl;
    }
    file << std::endl;
  }

  std::ifstream &operator>> (std::ifstream &file, parameter &p){
    p.read(file);
    return file;
  }

  std::ofstream &operator<< (std::ofstream &file, parameter &p){
    p.write(file);
    return file;
  }

  structure::structure (std::string system_name){
    name = system_name;
  };
  
  void
  structure::read (std::ifstream &file){
    std::list<record_t> *p;
    record_t r;
    if (! file){
      std::cerr << "warning: no structure data found (empty file)" << std::endl;
    }
    while (file >> r.vec >> r.num >> r.cmp >> r.fnm >> r.rpt >> r.cty){
      if (r.vec == "input"){
	p = &(this->Lu);
      } else if (r.vec == "state"){
	p = &(this->Lx);
      } else if (r.vec == "output"){
	p = &(this->Ly);
      } else {
	p = &(this->Lyz);
      }
      p->push_back(r);
    }
  };

  void
  structure::write (std::ofstream &file){
    this->write_declare(file);
    file << std::endl;
    this->write_input(file);
    file << std::endl;
    this->write_logic(file);
    file << std::endl;
    this->write_state(file);
    file << std::endl;
  }

  void
  structure::write_declare (std::ofstream &file){
    file << "const int mttNu\t= " << this->Lu.size() + 1 << ";"	<< std::endl
	 << "const int mttNx\t= " << this->Lx.size() + 1 << ";"	<< std::endl
	 << "const int mttNy\t= " << this->Ly.size() + 1 << ";"	<< std::endl
	 << "static double mttu[mttNu];"			<< std::endl
	 << "static double mttx[mttNx];"			<< std::endl
	 << "static double mtty[mttNy];"			<< std::endl
	 << "static double mttdx[mttNx];"			<< std::endl
	 << std::endl;
  }

  void
  structure::write_input (std::ofstream &file){
    file << "void"					<< std::endl
	 << this->name << "_input(const double t,"	<< std::endl
	 << "\tdouble *mttu,"				<< std::endl
	 << "\tdouble *mttx,"				<< std::endl
	 << "\tdouble *mtty)"				<< std::endl
	 << "{"						<< std::endl;
    for (i = Lu.begin(); i != Lu.end(); i++){
      file << "\tmttu["	<< i->num << "]\t= 1.0;"
	   << "\t// "	<< i->cmp
	   << "\t("	<< i->fnm << ")"		<< std::endl;
    }
    file << "} // " << this->name << "_input"		<< std::endl;
  }

  void
  structure::write_logic (std::ofstream &file){
    file << "void"					<< std::endl
	 << this->name << "_logic(const double t,"	<< std::endl
	 << "\tdouble *mttu,"				<< std::endl
	 << "\tdouble *mttx,"				<< std::endl
	 << "\tdouble *mttdx,"				<< std::endl
	 << "\tdouble *mtty)"				<< std::endl
	 << "{"						<< std::endl;
    for (i = Lx.begin(); i != Lx.end(); i++){
      if (i->cmp == "MTT_SWITCH"){
	file << "int " << i->fnm << " = 1;"		<< std::endl
	     << "if ((" << i->fnm << " == 0)"
	     << " || ((" << i->fnm << " < 0)"
	     << " && (mttx[" << i->num << "] < 0.0))){"	<< std::endl
	     << "\tmttx[" << i->num << "]\t = 0.0;"	<< std::endl
	     << "\tmttdx[" << i->num << "]\t = 0.0;"	<< std::endl
	     << "}"					<< std::endl;
      }
    }
    file << "} // " << this->name << "_logic"		<< std::endl;
  }

  void
  structure::write_state (std::ofstream &file){
    file << "void"					<< std::endl
	 << this->name << "_state(double *mttx)"	<< std::endl
	 << "{"						<< std::endl;
    for (i = Lx.begin(); i != Lx.end(); i++){
      file << "\tmttx["	<< i->num << "]\t= 0.0;"
	   << "\t// "	<< i->cmp
	   << "\t("	<< i->fnm << ")"		<< std::endl;
    }    
    file << "} // " << this->name << "_state"		<< std::endl;      
  }

  std::ifstream &operator>> (std::ifstream &file, structure &s){
    s.read(file);
    return file;
  }

  std::ofstream &operator<< (std::ofstream &file, structure &s){
    s.write(file);
    return file;
  }

};

void
usage(const char *program){
  std::cerr << std::endl
	    << "usage: " << program << " system" << std::endl
	    << std::endl;
}

int main(int argc, char *argv[])
{
  // check usage
  if (argc != 2){
    usage(argv[0]);
    return 1;
  }
  std::string system_name = argv[1];
  
  // open files for reading and writing
  std::string cr_filename		= system_name + "_cr.txt";
  std::string parameter_filename	= system_name + "_sympar.txt";
  std::string structure_filename	= system_name + "_struc.txt";
  std::string equations_filename	= system_name + "_ese.r";
  std::string cxxsim_filename		= system_name + "_cxxsim.cc";

  std::ifstream cr_file	      (cr_filename.c_str());
  std::ifstream parameter_file(parameter_filename.c_str());
  std::ifstream structure_file(structure_filename.c_str());
  std::ifstream equations_file(equations_filename.c_str());
  std::ofstream cxxsim_file(cxxsim_filename.c_str());

  // announce transformation
  std::clog << "Creating " << cxxsim_filename << std::endl;
  
  // do transformations (abracadabra!)
  cxxsim::cr	    system_cr	    (system_name);
  cxxsim::parameter system_parameter(system_name);
  cxxsim::structure system_structure(system_name);
  cxxsim::equations system_equations(system_name);

  cr_file	 >> system_cr;
  parameter_file >> system_parameter;
  structure_file >> system_structure;
  equations_file >> system_equations;
  
  
  cxxsim_file << system_cr
	      << system_parameter
	      << system_structure 
	      << system_equations
	      << std::endl;

  cxxsim_file << std::endl
	      << "int"								<< std::endl
	      << "main(void){"							<< std::endl
	      << std::endl
	      << "  double mttdt = 0.1; // integration time step"		<< std::endl
	      << "  double mttt;"						<< std::endl
	      << "  int i;"							<< std::endl
	      << std::endl
	      << "  for (mttt = 0.0; mttt <= 10.0; mttt += mttdt){"		<< std::endl
	      << std::endl
	      << "    // get inputs and rates"					<< std::endl
	      << "    " << system_name << "_input(mttt,mttu,mttx,mtty);"	<< std::endl
	      << "    " << system_name << "_ode(mttt,mttu,mttx,mttdx,mtty);"	<< std::endl
	      << std::endl
	      << "    // integrate states (euler)"				<< std::endl
	      << "    for (i = 1; i <= mttNx; i++){"				<< std::endl
	      << "      mttx[i] += mttdx[i] * mttdt;"				<< std::endl
	      << "    }"							<< std::endl
	      << std::endl
	      << "    // overwrite switch states"				<< std::endl
	      << "    " << system_name << "_logic(mttt,mttu,mttx,mttdx,mtty);"	<< std::endl
	      << std::endl
	      << "    // write: time outputs time states"			<< std::endl
	      << "    std::cout << mttt << '\\t';"				<< std::endl
	      << "    for (i = 1; i <= mttNy; i++){"				<< std::endl
	      << "      std::cout << mtty[i] << ' ';"				<< std::endl 
	      << "    }"							<< std::endl
	      << "    std::cout << '\\t' << mttt;"				<< std::endl
	      << "    for (i = 1; i <= mttNx; i++){"				<< std::endl
	      << "      std::cout << ' ' << mttx[i];"				<< std::endl 
	      << "    }"							<< std::endl
	      << "    std::cout << std::endl;"					<< std::endl
	      << "  }"								<< std::endl
	      << "  return 0;"							<< std::endl
	      << "}"								<< std::endl;

  // close files
  cr_file.close();
  parameter_file.close();
  structure_file.close();
  equations_file.close();
  cxxsim_file.close();

  return 0;
}

Deleted mttroot/mtt/lib/rep/cxxsim_rep.make version [40e5a5430e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-makefile-*-

# usage: mtt <sys> cxxsim view

# example:
# mtt copy MotorGenerator && cd MotorGenerator && mtt MotorGenerator cxxsim view

# cxxsim creates a very simple C++ simulation without using Reduce
# it doesn't use MTT's normal .txt files so the resultant .cc must be edited 
# manually to alter parameter, input and logic values

# a more intelligent version would just do ese_r2cc to create <sys>_ese.cc
# this could then be embedded into MTT's normal code like <sys>_ode.cc
# maybe another day ...

CC=g++

INCLUDE=-I. -I${MTT_LIB}/cr/hh
OPTIMISE=-O3
WARNINGS=-Wall -ansi -pedantic

ifeq ("","$(MTT_ARG)")
TARGET=$(MTT_SYS)_cxxsim.$(MTT_LANG)
else
TARGET=$(MTT_SYS)_cxxsim-$(MTT_ARG).$(MTT_LANG)
endif

all: $(TARGET)

# rule copied from gnuplot_rep.make
# need it here to prevent MTT using the default route (via dae)
$(MTT_SYS)_cxxsim.gnuplot: $(MTT_SYS)_gnuplot.wish $(MTT_SYS)_odes.dat2
	sh $(MTT_SYS)_gnuplot.wish		|\
		tee gnuplot_in.log		|\
		 gnuplot -geometry 400x300	\
		 > gnuplot_out.log 2> gnuplot_err.log &

$(MTT_SYS)_cxxsim.view: $(MTT_SYS)_cxxsim-odes.ps $(MTT_SYS)_cxxsim-odeso.ps
	${PSVIEW} $(MTT_SYS)_cxxsim-odes.ps
	${PSVIEW} $(MTT_SYS)_cxxsim-odeso.ps

$(MTT_SYS)_cxxsim.ps: $(MTT_SYS)_cxxsim-odeso.ps
	cp $< $@

$(MTT_SYS)_cxxsim-ode%.ps: $(MTT_SYS)_ode%.fig
	fig2dev -Leps $(MTT_SYS)_ode$*.fig $@

$(MTT_SYS)_ode%.fig: $(MTT_SYS)_ode%.gdat
	gdat2fig $(MTT_SYS)_ode$*

$(MTT_SYS)_ode%.gdat: $(MTT_SYS)_ode%.dat
	dat2gdat $(MTT_SYS) ode$*

$(MTT_SYS)_ode%.dat: $(MTT_SYS)_def.r $(MTT_SYS)_odes.dat2
	dat22dat $(MTT_SYS) ode $*

$(MTT_SYS)_odes.dat2: $(MTT_SYS)_cxxsim.exe
	./$< > $@

$(MTT_SYS)_cxxsim.exe: $(MTT_SYS)_cxxsim.cc
	echo Creating $(MTT_SYS)_cxxsim.exe
	$(CC) -o $@ $^ $(OPTIMISE) $(WARNINGS) $(INCLUDE)

$(MTT_SYS)_cxxsim.cc: $(MTT_SYS)_cr.txt $(MTT_SYS)_ese.r $(MTT_SYS)_struc.txt $(MTT_SYS)_sympar.txt cxxsim
	./cxxsim $(MTT_SYS)
	cp $@ ..

cxxsim: ${MTT_LIB}/rep/cxxsim.cc
	echo creating $@
	echo Compiling $^
	$(CC) -o $@ $^ $(OPTIMISE) $(WARNINGS) $(INCLUDE)

# list of constitutive relationships
$(MTT_SYS)_cr.txt:
	mtt -q $(MTT_OPTS) $(MTT_SYS) cr txt

# array sizes
$(MTT_SYS)_def.r:
	mtt -q $(MTT_OPTS) $(MTT_SYS) def r

# elementary system equations
$(MTT_SYS)_ese.r:
	mtt -q $(MTT_OPTS) $(MTT_SYS) ese r

# system structure
$(MTT_SYS)_struc.txt:
	mtt -q $(MTT_OPTS) $(MTT_SYS) struc txt

# list of symbolic parameters
$(MTT_SYS)_sympar.txt:
	mtt -q $(MTT_OPTS) $(MTT_SYS) sympar txt

# gnuplot script
$(MTT_SYS)_gnuplot.wish:
	mtt -q $(MTT_OPTS) $(MTT_SYS) gnuplot wish

Deleted mttroot/mtt/lib/rep/gnuplot_rep.make version [d922043d89].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-makefile-*-
# create a gnuplot input file

MTTFLAGS	= $(MTT_OPTS)

all: $(MTT_SYS)_gnuplot.$(MTT_LANG)

$(MTT_SYS)_gnuplot.view: $(MTT_SYS)_gnuplot.wish
	mtt $(MTT_OPTS) $(MTT_SYS) odes dat2
	sh $(MTT_SYS)_gnuplot.wish				|\
		tee gnuplot_in.log				|\
		 gnuplot -name $(MTT_SYS) -geometry 400x300	\
		 > gnuplot_out.log 2> gnuplot_err.log &

$(MTT_SYS)_gnuplot.wish: $(MTT_SYS)_struc.txt
	$(MTTPATH)/trans/struc2gnuplot_txt2wish $(MTT_SYS)

$(MTT_SYS)_struc.txt:
	mtt $(MTTFLAGS) $(MTT_SYS) struc txt


Deleted mttroot/mtt/lib/rep/ident_rep.make version [e8f9bdae3f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-makefile-*-

#SUMMARY 	Identification
#DESCRIPTION 	Partially know system identification using
#DESCRIPTION    using bond graphs

# Makefile for representation ident
# File ident_rep.make

#Copyright (C) 2000,2001,2002 by Peter J. Gawthrop

## Model targets
model_reps =  ${MTT_SYS}_sympar.m ${MTT_SYS}_simpar.m ${MTT_SYS}_state.m 
model_reps += ${MTT_SYS}_numpar.m ${MTT_SYS}_input.m ${MTT_SYS}_ode2odes.m  
model_reps += ${MTT_SYS}_def.m 

## Prepend s to get the sensitivity targets
sensitivity_reps = ${model_reps:%=s%}

## Model prerequisites
model_pre =  ${MTT_SYS}_abg.fig ${MTT_SYS}_lbl.txt 
model_pre += ${MTT_SYS}_rdae.r ${MTT_SYS}_numpar.txt

## Prepend s to get the sensitivity targets
sensitivity_pre = ${model_pre:%=s%}


## Simulation targets
sims = ${MTT_SYS}_sim.m s${MTT_SYS}_ssim.m

## m-files needed for ident
ident_m = ${MTT_SYS}_ident.m ${MTT_SYS}_ident_numpar.m 

## The input data
ident_data = ${MTT_SYS}_ident_data.dat

## Targets for the ident simulation
ident_reps = ${ident_m} ${sims} ${model_reps} ${sensitivity_reps}

## ps output files etc
psfile = ${MTT_SYS}_ident.ps
psfiles = ${MTT_SYS}_ident.ps ${MTT_SYS}_ident.comparison.ps ${MTT_SYS}_ident_pars.ps
figfiles = ${psfiles:%.ps=%.fig}
gdatfiles = ${psfiles:%.ps=%.gdat}
datfiles = ${psfiles:%.ps=%.dat2}

## LaTeX files etc
latexfiles = ${MTT_SYS}_ident_par.tex

all: ${MTT_SYS}_ident.${MTT_LANG}

echo:
	echo "sims: ${sims}"
	echo "model_reps: ${model_reps}"
	echo "sensitivity_reps: ${sensitivity_reps}"
	echo "ident_reps: ${ident_reps}"

${MTT_SYS}_ident.view: ${psfiles}
	ident_rep.sh ${MTT_SYS} view

${psfiles}: ${figfiles}
	ident_rep.sh ${MTT_SYS} ps
	touch ${psfiles}

${figfiles}: ${gdatfiles}
	ident_rep.sh ${MTT_SYS} fig
	touch ${figfiles}

${gdatfiles}: ${datfiles}
	ident_rep.sh ${MTT_SYS} gdat
	touch ${gdatfiles}

${datfiles} ${latexfiles}: ${ident_reps} ${ident_data} 
	ident_rep.sh ${MTT_SYS} dat2
	touch ${datfiles}

${MTT_SYS}_ident.m: 
	ident_rep.sh ${MTT_SYS} m

${MTT_SYS}_ident_numpar.m:
	ident_rep.sh ${MTT_SYS} numpar.m

## System model reps
## Generic txt files 
${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* txt

## Specific m files
${MTT_SYS}_ode2odes.m: ${model_pre}
	mtt -q -stdin ${MTT_OPTS} ${MTT_SYS} ode2odes m

${MTT_SYS}_sim.m: ${MTT_SYS}_ode2odes.m
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} sim m

## Numpar files
${MTT_SYS}_numpar.m:
	mtt ${MTT_SYS} numpar m

## Sympar files
${MTT_SYS}_sympar.m:
	mtt ${MTT_SYS} sympar m

## Generic txt to m
${MTT_SYS}_%.m: ${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* m

## r files
${MTT_SYS}_def.r: ${MTT_SYS}_abg.fig
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} def r

${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} rdae r

## Sensitivity model reps
## Generic txt files 
s${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} $* txt

## Specific m files
## Numpar files
s${MTT_SYS}_numpar.m:
	mtt -s s${MTT_SYS} numpar m

## Sympar files
s${MTT_SYS}_sympar.m:
	mtt -s s${MTT_SYS} sympar m

s${MTT_SYS}_ode2odes.m: ${sensitivity_pre}
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ode2odes m

s${MTT_SYS}_ssim.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ssim m

s${MTT_SYS}_def.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} def m


## Generic txt to m
s${MTT_SYS}_%.m: s${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* m

## r files
s${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} rdae r

Deleted mttroot/mtt/lib/rep/ident_rep.sh version [13f8601111].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293





































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

## ident_rep.sh
## DIY representation "ident" for mtt
# Copyright (C) 2002 by Peter J. Gawthrop

ps=ps

sys=$1
rep=ident
lang=$2
mtt_parameters=$3
rep_parameters=$4

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_ident.dat2
dat2s_file=${sys}_idents.dat2
ident_numpar_file=${sys}_ident_numpar.m
option_file=${sys}_ident_mtt_options.txt

## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

check_new_options() {
    if [ -f "${option_file}" ]; then
	old_options=`cat ${option_file}`
        if [ "${mtt_options}" != "${old_options}" ]; then
	   echo ${mtt_options} > ${option_file}
	fi
    else
	echo ${mtt_options} > ${option_file}
    fi
}

## Make the _ident.m file
make_ident() {
filename=${sys}_${rep}.m
date=`date`
echo Creating ${filename}

cat > ${filename} <<EOF    
function [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)

  ## usage:  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras)
  ##
  ## last      last time in run
  ## ppp_names Column vector of names of ppp params
  ## par_names Column vector of names of estimated params
  ## extras    Structure containing additional info
  ##
  ## Created by MTT on ${date}
 
  ## Sensitivity system name
  system_name = "s${sys}"

  ##Sanity check
  if nargin<3
    printf("Usage: [y,u,t] = ${sys}_ident(y,u,t,par_names,Q,extras);");
    return
  endif

  if nargin<6
    ## Set up optional parameters
    extras.criterion = 1e-3;
    extras.emulate_timing = 0;
    extras.max_iterations = 10;
    extras.simulate = 2;
    extras.v =  1e-2;
    extras.verbose = 1;
    extras.visual = 1;
  endif
  
  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  sympar  = ${sys}_sympar;
  simpar  = ${sys}_simpar;
  sympars  = s${sys}_sympar;
  simpars  = s${sys}_simpar;

  ## Parameter indices
  i_par = ppp_indices (par_names,sympar,sympars);

  ## Initial model state
  x_0 = zeros(2*n_x,1);

  ## Initial model parameters
  par_0 = s${sys}_numpar;

  ## Reset simulation parameters
  [n_data,m_data] = size(y);
  dt = t(2)-t(1);
  simpars.last = (n_data-1)*dt;
  simpars.dt = dt;

  ## Identification
  [epar,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpars,u,y,i_par,Q,extras);
  
  ## Do some plots
  figure(1);
  grid;
  title("Comparison of data");
  xlabel("t");
  ylabel("y");
  [N,M] = size(Y);
  y_est = Y(:,M-n_y+1:M);
  plot(t,y_est,"1;Estimated;", t,y,"3;Actual;");
  figfig("${sys}_ident_comparison");

  figure(2);
  [n_par,m_par] = size(Par);
  grid;
  title("Parameter estimates");
  xlabel("Iteration");
  ylabel("Estimates");
  plot(0:m_par-1, Par, 0:m_par-1, Par,"x");
  figfig("${sys}_ident_pars");

  ## Create a table of the parameters
  [n_par,m_par] = size(i_par);
  fid = fopen("${sys}_ident_par.tex", "w");
  fprintf(fid,"\\\\begin{table}[htbp]\\n");
  fprintf(fid," \\\\centering\\n");
  fprintf(fid," \\\\begin{tabular}{|l|l|}\\n");
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"  Name & Value \\\\\\\\ \\n");
  fprintf(fid,"  \\\\hline\\n");
  for i = 1:n_par
    fprintf(fid,"$%s$ & %4.2f \\\\\\\\ \\n", par_names(i,:), epar(i_par(i,1)));
  endfor
  fprintf(fid,"  \\\\hline\\n");
  fprintf(fid,"\\\\end{tabular}\\n");
  fprintf(fid,"\\\\caption{Estimated Parameters}\\n");
  fprintf(fid,"\\\\end{table}\\n");
  fclose(fid);

  ## Save the data for later use.
   par_values = epar(i_par(:,1));
   save ${sys}_ident_est_data.dat y_est Y par_names par_values
endfunction
EOF
}

make_ident_numpar() {
echo Creating ${ident_numpar_file}
cat > ${sys}_ident_numpar.m <<EOF
function [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;

  ## usage: [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  ## Edit for your own requirements
  ## Created by MTT on ${date}

    
  ## This section sets up the data source
  ## simulate = 0  Real data (you supply ${sys}_ident_data.dat)
  ## simulate = 1  Real data input, simulated output
  ## simulate = 2  Unit step input, simulated output
  simulate = 2;
  

  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  simpars = s${sys}_simpar;

  ## Access or create data
  if (simulate<2)		# Get the real data
    if (exist("${sys}_ident_data.dat")==2)
      printf("Loading ${sys}_ident_data.dat\n");
      load ${sys}_ident_data.dat
    else
      printf("Please create a loadable file ${sys}_ident_data.dat containing y,u and t\n");
      return
    endif
  else 
    switch simulate
      case 2			# Step simulation
	t = [0:simpars.dt:simpars.last]';
	u = ones(size(t));
      otherwise
	error(sprintf("simulate = %i not implemented", simulate));
    endswitch
  endif
  
  if (simulate>0)
    par = ${sys}_numpar();
    x_0 = ${sys}_state(par);
    dt = t(2)-t(1);
    simpars.dt = dt;
    simpars.last = t(length(t));
    y =  ${sys}_sim(zeros(n_x,1), par, simpars, u);
  endif

  ## Default parameter names - Put in your own here
  sympar = ${sys}_sympar;	# Symbolic params as structure
  par_names = struct_elements (sympar);	# Symbolic params as strings
  [n,m] = size(par_names);	# Size the string list

  ## Sort by index
  for [i,name] = sympar
    par_names(i,:) = sprintf("%s%s",name, blanks(m-length(name)));
  endfor
  
  ## Output weighting vector
  Q = ones(n_y,1);
  
  ## Extra parameters
  extras.criterion = 1e-5;
  extras.emulate_timing = 0;
  extras.max_iterations = 10;
  extras.simulate = simulate;
  extras.v =  1e-2;
  extras.verbose = 1;
  extras.visual = 1;
  extras.domain = "time";

endfunction
EOF
}

make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [y,u,t,par_names,Q,extras] = ${sys}_ident_numpar;
  [epar,Y] = ${sys}_ident (y,u,t,par_names,Q,extras);
  [N,M] = size(Y);
  y_est = Y(:,M);
  data = [t,y_est,u];
  save -ascii ${dat2_file} data
EOF

## Tidy up the latex stuff - convert foo_123 to foo_{123}
cat ${sys}_ident_par.tex > mtt_junk
sed  -e "s/_\([a-z0-9,]*\)/_{\1}/g" < mtt_junk >${sys}_ident_par.tex
rm mtt_junk
}

case ${lang} in
    numpar.m)
        ## Make the numpar stuff
        make_ident_numpar;
	;;
    m)
        ## Make the code
        make_ident;
	;;
    dat2)
        ## The dat2 language (output data) & fig file
	make_dat2; 
	;;
    gdat)
        cp ${dat2_file} ${dat2s_file} 
	dat22dat ${sys} ${rep} 
        dat2gdat ${sys} ${rep}
	;;
    fig)
        gdat2fig ${sys}_${rep}
	;;
    ps)
        figs=`ls ${sys}_ident*.fig | sed -e 's/\.fig//'`
	for fig in ${figs}; do
            fig2dev -Leps ${fig}.fig > ${fig}.ps
	done
	texs=`ls ${sys}_ident*.tex | sed -e 's/\.tex//'`
	for tex in ${texs}; do
          makedoc "" "${sys}" "ident_par" "tex" "" "" "$ps"
          doc2$ps ${sys}_ident_par "$documenttype"
	done
	;;
    view)
	pss=`ls ${sys}_ident*.ps` 
        echo Viewing ${pss}
        for ps in ${pss}; do
          ${PSVIEW} ${ps}&
	done
	;;
    *)
	echo Language ${lang} not supported by ${rep} representation
        exit 3
esac


Deleted mttroot/mtt/lib/rep/ippp_rep.make version [7bb6eededb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-makefile-*-
# Makefile for representation ippp - ppp system identification
# File ippp_rep.make

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.5  2002/12/12 17:18:42  geraint
  ## Fixed [ 647664 ] Namespace clash: LANG
  ## Prepended MTT_ to SYS, OPTS and LANG environment variables.
  ##
  ## Revision 1.4  2001/04/23 15:06:21  gawthrop
  ## Removed stdin bug workaround
  ##
  ## Revision 1.3  2001/04/11 07:52:45  gawthrop
  ## Temporary fix to avoid incorrect _input.cc with stdin
  ##
  ## Revision 1.2  2001/04/05 11:49:07  gawthrop
  ## Fixed a number of bugs to as to work with reports.
  ##
  ## Revision 1.1  2001/04/04 10:05:38  gawthrop
  ## Reresentation for system identification for ppp
  ##
  ###############################################################

#Copyright (C) 2000 by Peter J. Gawthrop

all: $(MTT_SYS)_ippp.$(MTT_LANG)

$(MTT_SYS)_ippp.view:  $(MTT_SYS)_ippp.pdf
	acroread *.pdf

$(MTT_SYS)_ippp.ps: $(MTT_SYS)_parameters.ps $(MTT_SYS)_error.ps $(MTT_SYS)_outputs.ps $(MTT_SYS)_ippp.pdf
	cp $(MTT_SYS)_parameters.ps $(MTT_SYS)_ippp.ps

$(MTT_SYS)_ippp.pdf: $(MTT_SYS)_parameters.pdf $(MTT_SYS)_error.pdf $(MTT_SYS)_outputs.pdf
	cp $(MTT_SYS)_parameters.pdf $(MTT_SYS)_ippp.pdf

$(MTT_SYS)_parameters.ps: s$(MTT_SYS)_ode2odes.m s$(MTT_SYS)_ssim.m $(MTT_SYS)_ippp.m s$(MTT_SYS)_sympar.m s$(MTT_SYS)_simpar.m
	octave $(MTT_SYS)_ippp.m

$(MTT_SYS)_error.ps: $(MTT_SYS)_parameters.ps
	touch $(MTT_SYS)_error.ps

$(MTT_SYS)_outputs.ps: $(MTT_SYS)_parameters.ps
	touch $(MTT_SYS)_outputs.ps

$(MTT_SYS)_parameters.pdf: s$(MTT_SYS)_ode2odes.m s$(MTT_SYS)_ssim.m $(MTT_SYS)_ippp.m s$(MTT_SYS)_sympar.m s$(MTT_SYS)_simpar.m
	octave $(MTT_SYS)_ippp.m

$(MTT_SYS)_error.pdf: $(MTT_SYS)_parameters.pdf
	touch $(MTT_SYS)_error.pdf

$(MTT_SYS)_outputs.pdf: $(MTT_SYS)_parameters.pdf
	touch $(MTT_SYS)_outputs.pdf

s$(MTT_SYS)_ode2odes.m: 
	echo Starting creation of s$(MTT_SYS)_ode2odes.m with options $(MTT_OPTS)
	mtt -q $(MTT_OPTS) -stdin -s s$(MTT_SYS) ode2odes m

s$(MTT_SYS)_ssim.m: s$(MTT_SYS)_def.m
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) ssim m

s$(MTT_SYS)_sympar.m:
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) sympar m

s$(MTT_SYS)_simpar.m:
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) simpar m

s$(MTT_SYS)_def.m:
	mtt -q $(MTT_OPTS) -s s$(MTT_SYS) def m

Deleted mttroot/mtt/lib/rep/mtt_rep_diy version [8134d7ef8f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138










































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

rep_name="diy"

help_message="
	A representation you can create all by yourself!

	The purpose of this representation is to help in the creation of a new DIY rep structure.
	Eventually it should form a template for creating new representations.
"

non_standard_options="
	--crash:	make the computer crash, wiping the hard drive in the process
	--recover:	attempt to recover data after crash (by crying very loudly for 10 minutes)
"

texi_message="
This message should be really, really helpful.
@node Stuff, More Stuff, Top, Top
Stuff!
@node More Stuff, Top, Top, Top
More Stuff
"

# function definitions for non-standard options (should have same name)
crash () {
    touch .crash
    echo "IDIOT!"
    exit 99
}
recover () {
    if [ -f .crash ]; then
	cat <<EOF
A long time ago
in galaxy far away
data can't be found
EOF
    else
	echo "Recovery worked - your data is safe!"
    fi
}
hello () {
    echo "Hello ${USER}!"
}

languages="ada c c++ fortran m pascal ps" # this is used for documentation only
process_language () {
    Language=$1
    case ${Language} in
	'c')
	    echo "C is a good language"
	    ;;
	'c')
	    echo "C++ is a great language"
	    ;;
	*)
	    exit ${ELanguageUnknown}
	    ;;
    esac
}

#####################################################################
###  It should not be necessary to edit anything below this line  ###
#####################################################################

# Error codes
ELanguageUnknown="-2"		# MTT will continue from here
ENoLanguageSpecified="-10"

help () {
    cat <<EOF

$0: help

	MTT representation ${rep_name}
${help_message}
EOF
}

usage () {
    cat <<EOF

$0: usage

	mtt [mtt_options] ${rep_name} [options] lang

	standard options:

	--help:		print useful help message
	--usage:	print this useful message
	--texi:		print very useful message

	additional options:
${non_standard_options}
EOF
}

texi () {
    cat <<EOF
@settitle MTT: ${rep_name} representation
${texi_message}
EOF
}

error () {
    cat <<EOF
*** Error: MTT (${rep_name}): $1 : exiting ($2)
EOF
    exit $2
}

warn () {
    cat <<EOF
*** Warning: MTT (${rep_name}): $1 : continuing
EOF
}

process_arguments () {
    if [ $# -eq 0 ]; then
	help
	usage
    else
	while [ -n "`echo $1 | grep '^--'`" ]; do
	    option=`echo $1 | sed 's/\-\-\(.*\)/\1/'`
	    ${option} 2> /dev/null || warn "option --${option} unknown"
	    shift
	done   
	export Language="$*"
    fi
}

process_arguments $*
if [ ! "${Language}" ]; then
    error "no language specified" ${NoLanguageSpecified}
fi

process_language ${Language}
	

Deleted mttroot/mtt/lib/rep/nppp_rep.make version [53790be183].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-makefile-*-

#SUMMARY 	Nonlinear pole-placement predictive control (nPPP)
#DESCRIPTION 	

# Makefile for representation nppp
# File nppp_rep.make

#Copyright (C) 2000,2001,2002 by Peter J. Gawthrop

## Model targets
model_reps =  ${MTT_SYS}_sympar.m ${MTT_SYS}_simpar.m ${MTT_SYS}_state.m 
model_reps += ${MTT_SYS}_numpar.m ${MTT_SYS}_input.m ${MTT_SYS}_ode2odes.m  
model_reps += ${MTT_SYS}_def.m

## Prepend s to get the sensitivity targets
sensitivity_reps = ${model_reps:%=s%}

## Simulation targets
sims = ${MTT_SYS}_sim.m s${MTT_SYS}_ssim.m

## m-files needed for nppp
nppp_m = ${MTT_SYS}_nppp.m ${MTT_SYS}_nppp_numpar.m 

## Targets for the nppp simulation
nppp_reps = ${nppp_m} ${sims} ${model_reps} ${sensitivity_reps}

## ps output files
psfiles = ${MTT_SYS}_nppp.ps ${MTT_SYS}_nppp.basis.ps ${MTT_SYS}_nppp.par.ps ${MTT_SYS}_nppp.U.ps
figfiles = ${psfiles:%.ps=%.fig}

all: ${MTT_SYS}_nppp.${MTT_LANG}

echo:
	echo "sims: ${sims}"
	echo "model_reps: ${model_reps}"
	echo "sensitivity_reps: ${sensitivity_reps}"
	echo "nppp_reps: ${nppp_reps}"

${MTT_SYS}_nppp.view: ${MTT_SYS}_nppp.ps
	nppp_rep.sh ${MTT_SYS} view

${psfiles}: ${MTT_SYS}_nppp.fig
	nppp_rep.sh ${MTT_SYS} ps

${MTT_SYS}_nppp.gdat: ${MTT_SYS}_nppp.dat2
	nppp_rep.sh ${MTT_SYS} gdat

${MTT_SYS}_nppp.fig ${MTT_SYS}_nppp.dat2: ${nppp_reps}
	nppp_rep.sh ${MTT_SYS} dat2

${MTT_SYS}_nppp.m: 
	nppp_rep.sh ${MTT_SYS} m

${MTT_SYS}_nppp_numpar.m:
	nppp_rep.sh ${MTT_SYS} numpar.m

## System model reps
## Generic txt files 
${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* txt

## Specific m files
${MTT_SYS}_ode2odes.m: ${MTT_SYS}_rdae.r
	mtt -q -stdin ${MTT_OPTS} ${MTT_SYS} ode2odes m

${MTT_SYS}_sim.m: ${MTT_SYS}_ode2odes.m
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} sim m

## Generic txt to m
${MTT_SYS}_%.m: ${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} $* m

## r files
${MTT_SYS}_def.r: ${MTT_SYS}_abg.fig
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} def r

${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin ${MTT_SYS} rdae r

## Sensitivity model reps
## Generic txt files 
s${MTT_SYS}_%.txt:
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* txt

## Specific m files
s${MTT_SYS}_ode2odes.m: s${MTT_SYS}_rdae.r
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ode2odes m

s${MTT_SYS}_ssim.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} ssim m

s${MTT_SYS}_def.m:
	mtt -q -stdin ${MTT_OPTS} -s s${MTT_SYS} def m


## Generic txt to m
s${MTT_SYS}_%.m: s${MTT_SYS}_%.txt
	mtt ${MTT_OPTS} -q -stdin s${MTT_SYS} $* m


## r files
s${MTT_SYS}_rdae.r: 
	mtt ${MTT_OPTS} -q -stdin -s s${MTT_SYS} rdae r


Deleted mttroot/mtt/lib/rep/nppp_rep.sh version [08291d0b19].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331











































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

## nppp_rep.sh
## DIY representation "nppp" for mtt
# Copyright (C) 2002 by Peter J. Gawthrop

sys=$1
rep=nppp
lang=$2
mtt_parameters=$3
rep_parameters=$4

## Some names
target=${sys}_${rep}.${lang}
def_file=${sys}_def.r
dat2_file=${sys}_nppp.dat2
dat2s_file=${sys}_nppps.dat2
nppp_numpar_file=${sys}_nppp_numpar.m
option_file=${sys}_nppp_mtt_options.txt

## Get system information
if [ -f "${def_file}" ]; then
 echo Using ${def_file}
else
  mtt -q ${sys} def r
fi

ny=`mtt_getsize $1 y`
nu=`mtt_getsize $1 u`

check_new_options() {
    if [ -f "${option_file}" ]; then
	old_options=`cat ${option_file}`
        if [ "${mtt_options}" != "${old_options}" ]; then
	   echo ${mtt_options} > ${option_file}
	fi
    else
	echo ${mtt_options} > ${option_file}
    fi
}

## Make the _nppp.m file
make_nppp() {
filename=${sys}_${rep}.m
echo Creating ${filename}

cat > ${filename} <<EOF    
function [y,u,t] = ${sys}_nppp (last, ppp_names, par_names, A_u, A_w, w, Q, extras)

  ## usage:  [y,u,t] = ${sys}_nppp (last, ppp_names, par_names, A_u, A_w, w, Q, extras)
  ##
  ## last      last time in run
  ## ppp_names Column vector of names of ppp params
  ## par_names Column vector of names of estimated params
  ## extras    Structure containing additional info

  ##Sanity check
  if nargin<2
    printf("Usage: [y,u,t] = ${sys}_nppp(N, ppp_names[, par_names, extras])\n");
    return
  endif

  if nargin<4
    ## Set up optional parameters
    extras.criterion = 1e-3;
    extras.emulate_timing = 0;
    extras.max_iterations = 15;
    extras.simulate = 1;
    extras.v =  1e-6;
    extras.verbose = 0;
    extras.visual = 1;
  endif
  
  ## System info
  [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def;
  sympar  = ${sys}_sympar;
  simpar  = ${sys}_simpar;
  sympars  = s${sys}_sympar;
  simpars  = s${sys}_simpar;
  t_ol = simpar.last;
    
  ## Number of intervals needed
  N = ceil(last/t_ol);

  ## Setpoints
  if extras.verbose
    printf("Open-loop interval %3.2f \n", simpar.last);
    printf(" -- using info in ${sys}_simpar.txt\n");
    printf("PPP optimisation from %3.2f to %3.2f\n", simpars.first, simpars.last);
    printf(" -- using info in s${sys}_simpar.txt\n");
  endif
  
  t_horizon = [simpars.first+simpars.dt:simpars.dt:simpars.last]';
  w_s = ones(length(t_horizon)-1,1)*w';

  ## Setup the indices of the adjustable stuff
  if nargin<2
    i_ppp = []
  else
    i_ppp = ppp_indices (ppp_names,sympar,sympars); # Parameters
  endif

  n_ppp = length(i_ppp(:,1));

  if nargin<3
    i_par = []
  else
    i_par = ppp_indices (par_names,sympar,sympars); # Parameters
  endif
  
    ## Do some simulations to check things out
    ## System itself
    par = ${sys}_numpar;
    x_0_ol = ${sys}_state(par);
    [y_ol,x_ol, t_ol] =  ${sys}_sim(x_0_ol, par, simpar, ones(1,n_u));
    simpar_OL = simpar;
    simpar_OL.last = simpars.last;
    [y_OL,x_OL, t_OL] =  ${sys}_sim(x_0_ol, par, simpar_OL, ones(1,n_u));

    pars = s${sys}_numpar;
    x_0_ppp = s${sys}_state(pars);
    [y_ppp,y_par,x_ppp, t_ppp] =  s${sys}_ssim(x_0_ppp, pars, simpars, ones(1,n_u));

    simpar_PPP = simpars;
    simpar_PPP.first = simpar.first;
    [y_PPP,y_par,x_PPP, t_PPP] =  s${sys}_ssim(x_0_ppp, pars, simpar_PPP, ones(1,n_u));

    ## Basis functions
    Us = ppp_ustar(A_u,1,t_OL',0,0)';


  if extras.visual		#Show some graphs
    figure(2); 	
    grid; title("Outputs of ${sys}_sim and s${sys}_ssim");
    plot(t_ol,y_ol, '*', t_ppp, y_ppp, '+', t_OL, y_OL, t_PPP, y_PPP);


    figure(3); 	
    grid; title("Basis functions");
    plot(t_OL, Us);

  endif



  ## Do it
  [y,u,t,P,U,t_open,t_ppp,t_est,its_ppp,its_est] \
      = ppp_nlin_run ("${sys}",i_ppp,i_par,A_u,w_s,N,Q,extras);

  ## Compute values at ends of ol intervals
  T_open = cumsum(t_open);
  T_open = T_open(1:length(T_open)-1); # Last point not in t
  j=[];
  for i = 1:length(T_open)
    j = [j; find(T_open(i)*ones(size(t))==t)];
  endfor
  y_open = y(j,:);
  u_open = u(j,:);

  ## Plots

    gset nokey
    gset nogrid
    #eval(sprintf("gset xtics %g", simpar.last));
    #gset noytics
    gset format x "%.1f"
    gset format y "%.2f"
    gset term fig monochrome portrait fontsize 20 size 20 20 metric \
	     thickness 4
    gset output "${sys}_nppp.fig"

    title("");
    xlabel("Time (s)");
    ylabel("u");
    subplot(2,1,2); plot(t,u,'-',  T_open, u_open,"+");
    #subplot(2,1,2); plot(t,u);   
    ylabel("y");
    subplot(2,1,1); plot(t,y,'-',  T_open, y_open,"+"); 
    #subplot(2,1,1); plot(t,y); 
    oneplot;
    gset term fig monochrome portrait fontsize 20 size 20 10 metric \
	     thickness 4
    gset output "${sys}_nppp.basis.fig"
    title("");
    xlabel("Time (s)");
    ylabel("Basis functions");
    plot(t_OL, Us);


    ## Create plot against time
    TTT = [ [0;T_open] [T_open; last] ]';
    TT = TTT(:);

    [n,m] = size(P);
    if m>0
      P = P(1:n-1,:);  # Loose last point
      PP = [];
      for j=1:m
        pp = [P(:,j) P(:,j)]';
        PP = [PP pp(:)];
      endfor

      oneplot;
      gset output "${sys}_nppp.par.fig"
      title("");
      xlabel("Time (s)");
      ylabel("Parameters");
      plot(TT,PP);
    endif

    [n,m] = size(U);
    if m>0    oneplot;
      gset output "${sys}_nppp.U.fig"
      title("");
      xlabel("Time (s)");
      ylabel("U");
      [n,m] = size(U);
      U = U(1:n-1,:);  # Loose last point
      UU = [];
      for j=1:m
        uu = [U(:,j) U(:,j)]';
        UU = [UU uu(:)];
      endfor
      plot(TT,UU);
    endif

endfunction

EOF
}

make_nppp_numpar() {
echo Creating ${nppp_numpar_file}
cat > ${sys}_nppp_numpar.m <<EOF
function [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar 

## usage:  [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar ()
##
## 

  ## Last time of run
  last = 10;

  ## Specify basis functions
  A_w = zeros(1,1);
  n_ppp = ${nu};
  A_u = ppp_aug(A_w,laguerre_matrix(n_ppp-1,2.0));

 
  ## Names of ppp parameters
  ppp_names = "";
  for i=1:n_ppp
    name = sprintf("ppp_%i", i);
    ppp_names = [ppp_names; name];
  endfor

  ## Estimated parameters
  par_names = [];

  ## Weights
  Q = ones(${ny},1);

  ## Setpoint
  w = zeros(${ny},1); w(1) = 1;

  ## Set up optional parameters
  extras.criterion = 1e-3;
  extras.emulate_timing = 0;
  extras.max_iterations = 15;
  extras.simulate = 1;
  extras.v =  1e-6;
  extras.verbose = 0;
  extras.visual = 0;

endfunction
EOF
}

make_dat2() {

## Inform user
echo Creating ${dat2_file}

## Use octave to generate the data
octave -q <<EOF
  [last, ppp_names, par_names, A_u, A_w, w, Q, extras] = ${sys}_nppp_numpar;
  [y,u,t] = ${sys}_nppp(last, ppp_names, par_names, A_u, A_w, w, Q, extras);
  data = [t,y,u];
  save -ascii ${dat2_file} data
EOF
}

case ${lang} in
    numpar.m)
        ## Make the numpar stuff
        make_nppp_numpar;
	;;
    m)
        ## Make the code
        make_nppp;
	;;
    dat2|fig|basis.fig|par.fig|U.fig)
        ## The dat2 language (output data) & fig file
        rm ${sys}_nppp*.fig
	make_dat2; 
	;;
    gdat)
        cp ${dat2_file} ${dat2s_file} 
	dat22dat ${sys} ${rep} 
        dat2gdat ${sys} ${rep}
	;;
    ps|basis.ps|par.ps|U.ps)
        figs=`ls ${sys}_nppp*.fig | sed -e 's/\.fig//'`
        echo $figs
	for fig in ${figs}; do
            fig2dev -Leps ${fig}.fig > ${fig}.ps
	done
	;;
    view)
	pss=`ls ${sys}_nppp*.ps` 
        echo Viewing ${pss}
        for ps in ${pss}; do
          gv ${ps}&
	done
	;;
    *)
	echo Language ${lang} not supported by ${rep} representation
        exit 3
esac


Deleted mttroot/mtt/lib/rep/odeso_rep.make version [069699a344].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
# -*-makefile-*-

all: ${MTT_SYS}_odeso.${MTT_LANG}

${MTT_SYS}_odeso.gnuplot:
	@mtt -q ${MTT_OPTS} ${MTT_SYS} gnuplot view

ifneq ("${MTT_LANG}","gnuplot")
${MTT_SYS}_odeso.${MTT_LANG}:
	@touch odeso_rep.make.ignore
	@mtt -q ${MTT_OPTS} ${MTT_SYS} odeso ${MTT_LANG}
	@rm odeso_rep.make.ignore
endif

Deleted mttroot/mtt/lib/rep/sfun_rep.make version [a81b02cdc5].

1
2
3
4




-
-
-
-
# -*-makefile-*-

all:
	${MTT_REP}/sfun_rep.sh "$(MTT_OPTS)" "$(MTT_SYS)" "$(MTT_LANG)"

Deleted mttroot/mtt/lib/rep/sfun_rep.sh version [4e120748b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /bin/sh

set -e

#
# function definitions
#


set_debug ()
{
    debug=$1
    if ( $debug ); then
	set -x
	make_debug='--debug=a'
    else
	set +x
	make_debug=''
    fi
}

exit_error ()
{
    message="$1"
    case $message in
	"Invalid Input"		) errno =  2 ;;
	"Unknown Template"	) errno =  3 ;;
	*			) errno = -1 ;;
    esac
    echo "#Error: " $message
    exit errno;
}       

check_for_valid_input ()
{
    return 0;
}

#
# file templates
#

# template_README      	compilation instructions
# template_mdk		simulink sub-system model

# template_mex_ae_c
# template_sfun_c
# template_sfun_debug_h
# template_sfun_input_c
# template_sfun_interface_c

write_template ()
{
    filename="$1"

    case $filename in

	README)

	    cat <<EOF
To build a Simulink funtion of the <mtt_model_name> model without using MTT:

mex <mtt_model_name>_sfun.c

The input block can be created with:

mex <mtt_model_name>_sfun_input.c

If numerical solution of algebraic equations is also required:

mex <mtt_model_name>_sfun_ae.c

The interface block can be created with

mex <mtt_model_name>_sfun_interface.c

EOF
	    ;;

	mdl)

	    cat <<EOF
Model {
  Name			  "<mtt_model_name>"
  Version		  4.00
  SampleTimeColors	  off
  LibraryLinkDisplay	  "all"
  WideLines		  off
  ShowLineDimensions	  on
  ShowPortDataTypes	  off
  ShowStorageClass	  off
  ExecutionOrder	  off
  RecordCoverage	  off
  CovPath		  "/"
  CovSaveName		  "covdata"
  CovMetricSettings	  "dw"
  CovNameIncrementing	  off
  CovHtmlReporting	  on
  BlockNameDataTip	  off
  BlockParametersDataTip  off
  BlockDescriptionStringDataTip	off
  ToolBar		  on
  StatusBar		  on
  BrowserShowLibraryLinks off
  BrowserLookUnderMasks	  off
  Created		  "Mon May 20 13:21:21 2002"
  Creator		  "geraint"
  UpdateHistory		  "UpdateHistoryNever"
  ModifiedByFormat	  "%<Auto>"
  LastModifiedBy	  "geraint"
  ModifiedDateFormat	  "%<Auto>"
  LastModifiedDate	  "Thu May 23 16:35:42 2002"
  ModelVersionFormat	  "1.%<AutoIncrement:13>"
  ConfigurationManager	  "None"
  SimParamPage		  "Solver"
  StartTime		  "0.0"
  StopTime		  "10.0"
  SolverMode		  "Auto"
  Solver		  "ode45"
  RelTol		  "1e-3"
  AbsTol		  "auto"
  Refine		  "1"
  MaxStep		  "auto"
  MinStep		  "auto"
  MaxNumMinSteps	  "-1"
  InitialStep		  "auto"
  FixedStep		  "auto"
  MaxOrder		  5
  OutputOption		  "RefineOutputTimes"
  OutputTimes		  "[]"
  LoadExternalInput	  off
  ExternalInput		  "[t, u]"
  SaveTime		  on
  TimeSaveName		  "tout"
  SaveState		  off
  StateSaveName		  "xout"
  SaveOutput		  on
  OutputSaveName	  "yout"
  LoadInitialState	  off
  InitialState		  "xInitial"
  SaveFinalState	  off
  FinalStateName	  "xFinal"
  SaveFormat		  "Array"
  LimitDataPoints	  on
  MaxDataPoints		  "1000"
  Decimation		  "1"
  AlgebraicLoopMsg	  "warning"
  MinStepSizeMsg	  "warning"
  UnconnectedInputMsg	  "warning"
  UnconnectedOutputMsg	  "warning"
  UnconnectedLineMsg	  "warning"
  InheritedTsInSrcMsg	  "warning"
  SingleTaskRateTransMsg  "none"
  MultiTaskRateTransMsg	  "error"
  IntegerOverflowMsg	  "warning"
  CheckForMatrixSingularity "none"
  UnnecessaryDatatypeConvMsg "none"
  Int32ToFloatConvMsg	  "warning"
  InvalidFcnCallConnMsg	  "error"
  SignalLabelMismatchMsg  "none"
  LinearizationMsg	  "none"
  VectorMatrixConversionMsg "none"
  SfunCompatibilityCheckMsg "none"
  BlockPriorityViolationMsg "warning"
  ArrayBoundsChecking	  "none"
  ConsistencyChecking	  "none"
  ZeroCross		  on
  Profile		  off
  SimulationMode	  "normal"
  RTWSystemTargetFile	  "grt.tlc"
  RTWInlineParameters	  off
  RTWRetainRTWFile	  off
  RTWTemplateMakefile	  "grt_default_tmf"
  RTWMakeCommand	  "make_rtw"
  RTWGenerateCodeOnly	  off
  TLCProfiler		  off
  TLCDebug		  off
  TLCCoverage		  off
  AccelSystemTargetFile	  "accel.tlc"
  AccelTemplateMakefile	  "accel_default_tmf"
  AccelMakeCommand	  "make_rtw"
  TryForcingSFcnDF	  off
  ExtModeMexFile	  "ext_comm"
  ExtModeBatchMode	  off
  ExtModeTrigType	  "manual"
  ExtModeTrigMode	  "normal"
  ExtModeTrigPort	  "1"
  ExtModeTrigElement	  "any"
  ExtModeTrigDuration	  1000
  ExtModeTrigHoldOff	  0
  ExtModeTrigDelay	  0
  ExtModeTrigDirection	  "rising"
  ExtModeTrigLevel	  0
  ExtModeArchiveMode	  "off"
  ExtModeAutoIncOneShot	  off
  ExtModeIncDirWhenArm	  off
  ExtModeAddSuffixToVar	  off
  ExtModeWriteAllDataToWs off
  ExtModeArmWhenConnect	  on
  ExtModeSkipDownloadWhenConnect off
  ExtModeLogAll		  on
  ExtModeAutoUpdateStatusClock off
  OptimizeBlockIOStorage  on
  BufferReuse		  on
  ParameterPooling	  on
  BlockReductionOpt	  on
  RTWExpressionDepthLimit 5
  BooleanDataType	  off
  BlockDefaults {
    Orientation		    "right"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    NamePlacement	    "normal"
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
    ShowName		    on
  }
  AnnotationDefaults {
    HorizontalAlignment	    "center"
    VerticalAlignment	    "middle"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  LineDefaults {
    FontName		    "Helvetica"
    FontSize		    9
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  System {
    Name		    "<mtt_model_name>"
    Location		    [51, 441, 346, 574]
    Open		    on
    ModelBrowserVisibility  off
    ModelBrowserWidth	    200
    ScreenColor		    "white"
    PaperOrientation	    "landscape"
    PaperPositionMode	    "auto"
    PaperType		    "usletter"
    PaperUnits		    "inches"
    ZoomFactor		    "100"
    ReportName		    "simulink-default.rpt"
    Block {
      BlockType		      Inport
      Name		      "In1"
      Position		      [25, 43, 55, 57]
      Port		      "1"
      LatchInput	      off
      DataType		      "double"
      SignalType	      "real"
      Interpolate	      on
    }
    Block {
      BlockType		      SubSystem
      Name		      "MTT Model\n<mtt_model_name>"
      Ports		      [1, 1]
      Position		      [100, 20, 140, 80]
      ForegroundColor	      "blue"
      BackgroundColor	      "lightBlue"
      ShowPortLabels	      on
      TreatAsAtomicUnit	      off
      RTWSystemCode	      "Auto"
      RTWFcnNameOpts	      "Auto"
      RTWFileNameOpts	      "Auto"
      System {
	Name			"MTT Model\n<mtt_model_name>"
	Location		[45, 448, 1008, 720]
	Open			off
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"white"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"usletter"
	PaperUnits		"inches"
	ZoomFactor		"100"
	Block {
	  BlockType		  Inport
	  Name			  "In1"
	  Position		  [590, 203, 620, 217]
	  Port			  "1"
	  LatchInput		  off
	  DataType		  "double"
	  SignalType		  "real"
	  Interpolate		  on
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Model Inputs"
	  Ports			  [1, 1]
	  Position		  [390, 59, 565, 91]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_input"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT  Model Inputs: MTTU"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Plant Model"
	  Ports			  [1, 2]
	  Position		  [65, 61, 250, 199]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT Model States: MTTX"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	  Port {
	    PortNumber		    2
	    Name		    "MTT Model Outputs: MTTY"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "S-Function"
	  Ports			  [4, 2]
	  Position		  [710, 47, 840, 238]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_interface"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	}
	Block {
	  BlockType		  Outport
	  Name			  "Out1"
	  Position		  [905, 183, 935, 197]
	  Port			  "1"
	  OutputWhenDisabled	  "held"
	  InitialOutput		  "[]"
	}
	Line {
	  Name			  "MTT Model States: MTTX"
	  Labels		  [2, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  1
	  Points		  [0, 0; 105, 0]
	  Branch {
	    Points		    [0, -20]
	    DstBlock		    "MTT Model Inputs"
	    DstPort		    1
	  }
	  Branch {
	    Points		    [0, 25]
	    DstBlock		    "S-Function"
	    DstPort		    2
	  }
	}
	Line {
	  Name			  "MTT Model Outputs: MTTY"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  2
	  DstBlock		  "S-Function"
	  DstPort		  3
	}
	Line {
	  Name			  "MTT  Model Inputs: MTTU"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Model Inputs"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  1
	  Points		  [30, 0; 0, -70; -850, 0; 0, 105]
	  DstBlock		  "MTT Plant Model"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "In1"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  4
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  2
	  DstBlock		  "Out1"
	  DstPort		  1
	}
      }
    }
    Block {
      BlockType		      Outport
      Name		      "Out1"
      Position		      [185, 43, 215, 57]
      Port		      "1"
      OutputWhenDisabled      "held"
      InitialOutput	      "[]"
    }
    Line {
      SrcBlock		      "MTT Model\n<mtt_model_name>"
      SrcPort		      1
      DstBlock		      "Out1"
      DstPort		      1
    }
    Line {
      SrcBlock		      "In1"
      SrcPort		      1
      DstBlock		      "MTT Model\n<mtt_model_name>"
      DstPort		      1
    }
  }
}

EOF
	    ;;

	mex_ae.c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_ae.c:
 * Matlab mex algebraic equations for <mtt_model_name>
 */

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <mex.h>
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

/* utility procedures */

double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

/* system equations */

static double *
<mtt_model_name>_ae (double *mttyz,
		     const double *mttx,
		     const double *mttu,
		     const double mttt,
		     const double *mttpar)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

/* generic mex function */

#ifdef __cplusplus
extern "C" {
#endif

void
mexFunction (int nlhs, mxArray *plhs[],
	     int nrhs, const mxArray *prhs[])
{
  double *mttyz;		/* residuals */

  double *mttx;			/* states */
  double *mttu;			/* known + unknown inputs */
  double mttt;			/* time */
  double *mttpar;		/* parameters */

  unsigned int i;
  double *p;

  PRINT_ENTER;

  mttyz		= array_of_double (MTTNYZ);

  mttx		= array_of_double (MTTNX);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttpar	= array_of_double (MTTNPAR);

  /* get trial values */
  p = mxGetPr (prhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* get states */
  p = mxGetPr (prhs[1]);
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = p[i];
  }

  /* get known inputs */
  p = mxGetPr (prhs[2]);
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = p[i];
  }

  /* get time */
  p = mxGetPr (prhs[3]);
  mttt = *p;

  /* get parameters */
  p = mxGetPr (prhs[4]);
  for (i = 0; i < MTTNPAR; i++) {
    mttpar[i] = p[i];
  }
  
  /* evaluate residuals */
  <mtt_model_name>_ae (mttyz, mttx, mttu, mttt, mttpar);
  
  /* return residuals */
  plhs[0] = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  p = mxGetPr (plhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = mttyz[i];
  }

  /* release memory */
  free (mttx);
  free (mttu);
  free (mttpar);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef __cplusplus
}
#endif

EOF
	    ;;

	sfun_c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun.c:
 * Matlab S-function simulation of <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttdx;		/* pointer to rates */
static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double *mttyz;		/* pointer to residuals */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_ae (void)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_ode (void)
{
#include "<mtt_model_name>_ode.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_odeo (void)
{
#include "<mtt_model_name>_odeo.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_state (void)
{
#include "<mtt_model_name>_state.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttdx		= array_of_double (MTTNX);
  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);
  mttyz		= array_of_double (MTTNYZ);

  PRINT_LEAVE;
}

static void
update_states_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = ssGetContStates (S)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_solver (void)
{
  mxArray *MTT_MATLAB_P;
  mxArray *MTT_MATLAB_T;
  mxArray *MTT_MATLAB_U;
  mxArray *MTT_MATLAB_Ui;
  mxArray *MTT_MATLAB_X;

  double *p;

  PRINT_ENTER;

  /* starting value for solver - start with zero */
  MTT_MATLAB_Ui = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  mxSetName (MTT_MATLAB_Ui, "MTT_Ui");
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = 0.0;
  }
  mexPutArray (MTT_MATLAB_Ui, "base");

  /* put states into matlab workspace */
  MTT_MATLAB_X = mxCreateDoubleMatrix (MTTNX, 1, mxREAL);
  mxSetName (MTT_MATLAB_X, "MTT_X");
  p = mxGetPr (MTT_MATLAB_X);
  for (i = 0; i < MTTNX; i++) {
    p[i] = mttx[i];
  }
  mexPutArray (MTT_MATLAB_X, "base");

  /* put known inputs into matlab workspace */
  MTT_MATLAB_U = mxCreateDoubleMatrix (MTTNU, 1, mxREAL);
  mxSetName (MTT_MATLAB_U, "MTT_U");
  p = mxGetPr (MTT_MATLAB_U);
  for (i = 0; i < MTTNU; i++) {
    p[i] = mttu[i];
  }
  mexPutArray (MTT_MATLAB_U, "base");

  /* put time into matlab workspace */
  MTT_MATLAB_T = mxCreateDoubleMatrix (1, 1, mxREAL);
  mxSetName (MTT_MATLAB_T, "MTT_T");
  *mxGetPr (MTT_MATLAB_T) = mttt;
  mexPutArray (MTT_MATLAB_T, "base");

  /* put parameters into matlab workspace */
  MTT_MATLAB_P = mxCreateDoubleMatrix (MTTNPAR, 1, mxREAL);
  mxSetName (MTT_MATLAB_P, "MTT_P");
  p = mxGetPr (MTT_MATLAB_P);
  for (i = 0; i < MTTNPAR; i++) {
    p[i] = mttpar[i];
  }
  mexPutArray (MTT_MATLAB_P, "base");

  /* call fsolve */
  mexEvalString ("MTT_Ui = fsolve (@<mtt_model_name>_sfun_ae, MTT_Ui, optimset('display','off'), MTT_X, MTT_U, MTT_T, MTT_P);");

  /* retrieve result */
  MTT_MATLAB_Ui = mexGetArray ("MTT_Ui", "base");
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* free memory */
  mxDestroyArray (MTT_MATLAB_P);
  mxDestroyArray (MTT_MATLAB_T);
  mxDestroyArray (MTT_MATLAB_U);
  mxDestroyArray (MTT_MATLAB_Ui);
  mxDestroyArray (MTT_MATLAB_X);

  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, MTTNX);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortDirectFeedThrough(S, 0, 1);

  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNX);
  ssSetOutputPortWidth(S, 1, MTTNY);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);

  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;

  <mtt_model_name>_numpar ();
  <mtt_model_name>_state ();

  for (i = 0; i < MTTNX; i++) {
    ssGetContStates (S)[i] = mttx[i];
  }

  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  }
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_odeo ();

  for (i = 0; i < MTTNX; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttx[i];
  }

  for (i = 0; i < MTTNY; i++) {
      ssGetOutputPortRealSignal (S, 1)[i] = mtty[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
    
  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  } 
  update_simtime_from_simulink (S);

  <mtt_model_name>_ode ();

  for (i = 0; i < MTTNX; i++) {
    ssGetdX (S)[i] = mttdx[i];
  }

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;
  UNUSED_ARG(S);

  free (mttdx);
  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

EOF
	    ;;

	sfun_debug.h)

	    cat <<EOF

#ifndef HAVE_SFUN_DEBUG_H
#define HAVE_SFUN_DEBUG_H


#if defined DEBUG && defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered '%s'\n", __FUNCTION__);
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving '%s'\n", __FUNCTION__);

#elif defined DEBUG && ! defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered a function\n");
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving a function\n");

#elif ! defined DEBUG

#define PRINT_ENTER
#define PRINT_LEAVE

#else

#error "Momentary lapse of logic : unreachable statement reached"

#endif


#endif /* HAVE_SFUN_DEBUG_H */

EOF
	    ;;

	sfun_input.c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_input.c:
 * Matlab S-function inputs for <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun_input
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_input (void)
{
#include "<mtt_model_name>_input.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNX);
  ssSetInputPortDirectFeedThrough(S, 0, 1);
    
  if (!ssSetNumOutputPorts(S, 1)) return;
  ssSetOutputPortWidth(S, 0, MTTNU);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_input ();

  for (i = 0; i < MTTNU; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

EOF
	    ;;

	sfun_interface.c)

	    cat <<EOF
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_interface.c:
 * Matlab S-function to process inputs and outputs of <mtt_model_name>
 */


#define S_FUNCTION_NAME <mtt_model_name>_sfun_interface
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static double *controller_inputs;
static double *controller_outputs;

static unsigned int i;		/* loop counter */

/* Start EDIT */
/* Edit this block to define the number of controller inputs, outputs and parameters */
const int NumberOfControllerInputs	= 1; /* inputs TO controller */
const int NumberOfControllerOutputs	= 1; /* outputs FROM controller */
/* End EDIT */

static void
<mtt_model_name>_process_inputs (void)
{
  /* insert <mtt_model_name>_struc.c */

  /* Start EDIT */
  /* Edit this block to process the model inputs and outputs */
  
  /* Remove the following line */
  fprintf (stderr, "*** Error: <mtt_model_name>_sfun_interface.c has not been customised!\n"); return;

  /* simple example follows */

  /* Get total of all outputs and input to controller */
  controller_inputs[0] = 0.0;
  for (i = 0; i < MTTNY; i++) {
    controller_inputs[0] += mtty[i];
  }

  /* overwrite first model input with output from controller */
  mttu[0] = controller_outputs[0];

  /* End EDIT */
}


/******************************************************************************
 *                DO NOT EDIT ANYTHING BELOW THIS LINE                        *
 ******************************************************************************/

/* system equations */

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  controller_inputs	= array_of_double (NumberOfControllerInputs);
  controller_outputs	= array_of_double (NumberOfControllerOutputs);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 1)[i];
  }
  for (i = 0; i < MTTNY; i++) {
    mtty[i] = *ssGetInputPortRealSignalPtrs (S, 2)[i];
  }
  for (i = 0; i < NumberOfControllerOutputs; i++) {
    controller_outputs[i] = *ssGetInputPortRealSignalPtrs (S, 3)[i];
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 4)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortWidth(S, 1, MTTNX);
  ssSetInputPortWidth(S, 2, MTTNY);
  ssSetInputPortWidth(S, 3, NumberOfControllerOutputs);	/* inputs from controller */
  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetInputPortDirectFeedThrough(S, 1, 1);
  ssSetInputPortDirectFeedThrough(S, 2, 1);
  ssSetInputPortDirectFeedThrough(S, 3, 1);
    
  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNU); /* altered inputs */
  ssSetOutputPortWidth(S, 1, NumberOfControllerInputs); /* outputs to controller */
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  <mtt_model_name>_process_inputs ();

  UNUSED_ARG(tid); /* not used in single tasking mode */

  for (i = 0; i < MTTNU; i++) {
    ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }
  
  for (i = 0; i < NumberOfControllerInputs; i++) {
    ssGetOutputPortRealSignal (S, 1)[i] = controller_inputs[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  free (controller_inputs);
  free (controller_outputs);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

EOF
	    ;;

	*)
	    exit_error "Unknown Template";
	    ;;

    esac
}	    







### main program

set_debug false
check_for_valid_input "$*"

MTT_OPTS="$1" MTT_SYS="$2" MTT_LANG="$3" make $make_debug -f ${MTT_REP}/sfun_rep/Makefile ${2}_sfun.${3}
exit 0

Deleted mttroot/mtt/lib/rep/sfun_rep/Makefile version [b56d0c54fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#! /usr/bin/make -f

all: $(MTT_SYS)_sfun.mexglx

$(MTT_SYS)_sfun.mexglx: $(MTT_SYS)_sfun.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h $(MTT_SYS)_numpar.c $(MTT_SYS)_ode.c $(MTT_SYS)_odeo.c $(MTT_SYS)_state.c $(MTT_SYS)_sfun_ae.mexglx $(MTT_SYS)_sfun_input.mexglx $(MTT_SYS)_sfun_interface.mexglx $(MTT_SYS).mdl
	echo Creating $@
	mex $(MTT_SYS)_sfun.c
	cp *_sfun*mexglx $(MTT_SYS).mdl ..

$(MTT_SYS)_sfun.c:: ${MTT_REP}/sfun_rep/sfun.c.tmpl $(MTT_SYS)_def.r
	echo Creating $@
	cat $< | sed 's/<mtt_model_name>/$(MTT_SYS)/g' |\
	sed s/\<have_algebraic_equations\>/`mtt_getsize $(MTT_SYS) yz`/ > $@

$(MTT_SYS)_sfun_ae.mexglx: $(MTT_SYS)_sfun_ae.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h $(MTT_SYS)_ae.c
	echo Creating $@
	mex $(MTT_SYS)_sfun_ae.c

$(MTT_SYS)_sfun_ae.c:: ${MTT_REP}/sfun_rep/mex_ae.c.tmpl $(MTT_SYS)_def.r
	echo Creating $@
	cat $< | sed 's/<mtt_model_name>/$(MTT_SYS)/g' |\
	sed s/\<have_algebraic_equations\>/`mtt_getsize $(MTT_SYS) yz`/ > $@

$(MTT_SYS)_sfun_input.mexglx: $(MTT_SYS)_sfun_input.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h $(MTT_SYS)_input.c $(MTT_SYS)_numpar.c
	echo Creating $@
	mex $(MTT_SYS)_sfun_input.c

$(MTT_SYS)_sfun_input.c:: ${MTT_REP}/sfun_rep/sfun_input.c.tmpl
	echo Creating $@
	cat $^ | sed 's/<mtt_model_name>/$(MTT_SYS)/g' > $@

$(MTT_SYS)_sfun_interface.mexglx: $(MTT_SYS)_sfun_interface.c sfun_debug.h useful-functions.hh $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_numpar.c
	echo Creating $@
	mex $(MTT_SYS)_sfun_interface.c

$(MTT_SYS)_sfun_interface.c: ${MTT_REP}/sfun_rep/sfun_interface.c.tmpl $(MTT_SYS)_struc.c
	echo Creating $@
	cat ${MTT_REP}/sfun_rep/sfun_interface.c.tmpl	|\
	 sed 's/<mtt_model_name>/$(MTT_SYS)/g'		|\
	 ${MTT_REP}/sfun_rep/insert_file.sh > $@

$(MTT_SYS)_sfun.zip: $(MTT_SYS)_sfun.c sfun_debug.h useful-functions.hh $(MTT_SYS)_sfun_ae.c $(MTT_SYS)_sfun_input.c $(MTT_SYS)_sfun_interface.c \
	 $(MTT_SYS)_def.h $(MTT_SYS)_sympar.h $(MTT_SYS)_cr.h\
	 $(MTT_SYS)_ae.c $(MTT_SYS)_input.c $(MTT_SYS)_numpar.c $(MTT_SYS)_ode.c $(MTT_SYS)_odeo.c $(MTT_SYS)_state.c \
	 $(MTT_SYS).mdl README
	echo Creating $@
	zip $@ $^

$(MTT_SYS).mdl: ${MTT_REP}/sfun_rep/mdl.tmpl
	echo Creating $@
	cat $^ | sed 's/<mtt_model_name>/$(MTT_SYS)/g' > $@

README:: ${MTT_REP}/sfun_rep/README.tmpl README.CVS
	echo Creating $@
	date > $@
	cat $^ | sed 's/<mtt_model_name>/$(MTT_SYS)/g' >> $@
	rm -f README.CVS

README.CVS:
	echo Getting CVS status
	(cvs status ../$(MTT_SYS)_abg.fig || echo -e "\n$(MTT_SYS)_abg.fig is not under CVS\n") > $@ 2>1

$(MTT_SYS)_ae.c: $(MTT_SYS)_ae.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) ae c cat 

$(MTT_SYS)_input.c: $(MTT_SYS)_input.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) input c cat 

$(MTT_SYS)_numpar.c: $(MTT_SYS)_numpar.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) numpar c cat

$(MTT_SYS)_ode.c: $(MTT_SYS)_ode.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) ode c cat

$(MTT_SYS)_odeo.c: $(MTT_SYS)_odeo.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) odeo c cat

$(MTT_SYS)_state.c: $(MTT_SYS)_state.m
	echo Creating $@
	${MTT_CC}/mtt_m2cc.sh $(MTT_SYS) state c cat

$(MTT_SYS)_struc.c: $(MTT_SYS)_struc.txt
	echo Creating $@
	gawk '\
($$1 == "input")  { printf "         double *%s\t= &(mttu[%d]);\t/* input and output */\n", $$4, $$2-1 }\
($$1 == "state")  { printf "   const double *_%s\t= &(mttx[%d]);\t/* input */\n", $$4, $$2-1 }\
($$1 == "output") { printf "   const double *_%s\t= &(mtty[%d]);\t/* input */\n", $$4, $$2-1 }\
($$1 != "input" && $$1 != "state" && $$1 != "output") { }\
	' $^ > $@

sfun_debug.h:: ${MTT_REP}/sfun_rep/sfun_debug.h
	echo Copying $@
	cp $^ $@

useful-functions.hh:: ${MTT_CC}/include/useful-functions.hh
	echo Copying $@
	cp $^ $@

%::
	mtt -cc -q $(MTT_OPTS) `echo $* | sed 's/\(.*\)_\(.*\)\.\(.*\)/\1 \2 \3/'`

Deleted mttroot/mtt/lib/rep/sfun_rep/README.tmpl version [b5c86b874f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

To build a Simulink funtion of the <mtt_model_name> model without using MTT:

mex -I. <mtt_model_name>_sfun.c

The input block can be created with:

mex -I. <mtt_model_name>_sfun_input.c

If numerical solution of algebraic equations is also required:

mex -I. <mtt_model_name>_sfun_ae.c

The interface block can be created with

mex -I. <mtt_model_name>_sfun_interface.c

Deleted mttroot/mtt/lib/rep/sfun_rep/insert_file.sh version [25cb36fec8].

1
2
3
4




-
-
-
-
#! /usr/bin/gawk -f
# script to replace the line: "/* insert filename */" with the contents of file "filename"
($1 != "/*" || $2 != "insert" || $4 != "*/") { print }
($1 == "/*" && $2 == "insert" && $4 == "*/") { cmd = "cat " $3 ; system(cmd) }

Deleted mttroot/mtt/lib/rep/sfun_rep/mdl.tmpl version [97145b618f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381





























































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Model {
  Name			  "mdl"
  Version		  4.00
  SampleTimeColors	  off
  LibraryLinkDisplay	  "all"
  WideLines		  off
  ShowLineDimensions	  on
  ShowPortDataTypes	  off
  ShowStorageClass	  off
  ExecutionOrder	  off
  RecordCoverage	  off
  CovPath		  "/"
  CovSaveName		  "covdata"
  CovMetricSettings	  "dw"
  CovNameIncrementing	  off
  CovHtmlReporting	  on
  BlockNameDataTip	  off
  BlockParametersDataTip  off
  BlockDescriptionStringDataTip	off
  ToolBar		  on
  StatusBar		  on
  BrowserShowLibraryLinks off
  BrowserLookUnderMasks	  off
  Created		  "Mon May 20 13:21:21 2002"
  Creator		  "geraint"
  UpdateHistory		  "UpdateHistoryNever"
  ModifiedByFormat	  "%<Auto>"
  LastModifiedBy	  "geraint"
  ModifiedDateFormat	  "%<Auto>"
  LastModifiedDate	  "Tue Jun 18 18:49:28 2002"
  ModelVersionFormat	  "1.%<AutoIncrement:14>"
  ConfigurationManager	  "None"
  SimParamPage		  "Solver"
  StartTime		  "0.0"
  StopTime		  "10.0"
  SolverMode		  "Auto"
  Solver		  "ode45"
  RelTol		  "1e-3"
  AbsTol		  "auto"
  Refine		  "1"
  MaxStep		  "auto"
  MinStep		  "auto"
  MaxNumMinSteps	  "-1"
  InitialStep		  "auto"
  FixedStep		  "auto"
  MaxOrder		  5
  OutputOption		  "RefineOutputTimes"
  OutputTimes		  "[]"
  LoadExternalInput	  off
  ExternalInput		  "[t, u]"
  SaveTime		  on
  TimeSaveName		  "tout"
  SaveState		  off
  StateSaveName		  "xout"
  SaveOutput		  on
  OutputSaveName	  "yout"
  LoadInitialState	  off
  InitialState		  "xInitial"
  SaveFinalState	  off
  FinalStateName	  "xFinal"
  SaveFormat		  "Array"
  LimitDataPoints	  on
  MaxDataPoints		  "1000"
  Decimation		  "1"
  AlgebraicLoopMsg	  "warning"
  MinStepSizeMsg	  "warning"
  UnconnectedInputMsg	  "warning"
  UnconnectedOutputMsg	  "warning"
  UnconnectedLineMsg	  "warning"
  InheritedTsInSrcMsg	  "warning"
  SingleTaskRateTransMsg  "none"
  MultiTaskRateTransMsg	  "error"
  IntegerOverflowMsg	  "warning"
  CheckForMatrixSingularity "none"
  UnnecessaryDatatypeConvMsg "none"
  Int32ToFloatConvMsg	  "warning"
  InvalidFcnCallConnMsg	  "error"
  SignalLabelMismatchMsg  "none"
  LinearizationMsg	  "none"
  VectorMatrixConversionMsg "none"
  SfunCompatibilityCheckMsg "none"
  BlockPriorityViolationMsg "warning"
  ArrayBoundsChecking	  "none"
  ConsistencyChecking	  "none"
  ZeroCross		  on
  Profile		  off
  SimulationMode	  "normal"
  RTWSystemTargetFile	  "grt.tlc"
  RTWInlineParameters	  off
  RTWRetainRTWFile	  off
  RTWTemplateMakefile	  "grt_default_tmf"
  RTWMakeCommand	  "make_rtw"
  RTWGenerateCodeOnly	  off
  TLCProfiler		  off
  TLCDebug		  off
  TLCCoverage		  off
  AccelSystemTargetFile	  "accel.tlc"
  AccelTemplateMakefile	  "accel_default_tmf"
  AccelMakeCommand	  "make_rtw"
  TryForcingSFcnDF	  off
  ExtModeMexFile	  "ext_comm"
  ExtModeBatchMode	  off
  ExtModeTrigType	  "manual"
  ExtModeTrigMode	  "normal"
  ExtModeTrigPort	  "1"
  ExtModeTrigElement	  "any"
  ExtModeTrigDuration	  1000
  ExtModeTrigHoldOff	  0
  ExtModeTrigDelay	  0
  ExtModeTrigDirection	  "rising"
  ExtModeTrigLevel	  0
  ExtModeArchiveMode	  "off"
  ExtModeAutoIncOneShot	  off
  ExtModeIncDirWhenArm	  off
  ExtModeAddSuffixToVar	  off
  ExtModeWriteAllDataToWs off
  ExtModeArmWhenConnect	  on
  ExtModeSkipDownloadWhenConnect off
  ExtModeLogAll		  on
  ExtModeAutoUpdateStatusClock off
  OptimizeBlockIOStorage  on
  BufferReuse		  on
  ParameterPooling	  on
  BlockReductionOpt	  on
  RTWExpressionDepthLimit 5
  BooleanDataType	  off
  BlockDefaults {
    Orientation		    "right"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    NamePlacement	    "normal"
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
    ShowName		    on
  }
  AnnotationDefaults {
    HorizontalAlignment	    "center"
    VerticalAlignment	    "middle"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  LineDefaults {
    FontName		    "Helvetica"
    FontSize		    9
    FontWeight		    "normal"
    FontAngle		    "normal"
  }
  System {
    Name		    "mdl"
    Location		    [61, 487, 356, 620]
    Open		    on
    ModelBrowserVisibility  off
    ModelBrowserWidth	    200
    ScreenColor		    "white"
    PaperOrientation	    "landscape"
    PaperPositionMode	    "auto"
    PaperType		    "usletter"
    PaperUnits		    "inches"
    ZoomFactor		    "100"
    ReportName		    "simulink-default.rpt"
    Block {
      BlockType		      Inport
      Name		      "In1"
      Position		      [25, 43, 55, 57]
      Port		      "1"
      LatchInput	      off
      DataType		      "double"
      SignalType	      "real"
      Interpolate	      on
    }
    Block {
      BlockType		      SubSystem
      Name		      "MTT Model\n<mtt_model_name>"
      Ports		      [1, 1]
      Position		      [100, 20, 140, 80]
      ForegroundColor	      "blue"
      BackgroundColor	      "lightBlue"
      ShowPortLabels	      on
      TreatAsAtomicUnit	      off
      RTWSystemCode	      "Auto"
      RTWFcnNameOpts	      "Auto"
      RTWFileNameOpts	      "Auto"
      System {
	Name			"MTT Model\n<mtt_model_name>"
	Location		[55, 494, 1018, 766]
	Open			off
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"white"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"usletter"
	PaperUnits		"inches"
	ZoomFactor		"100"
	Block {
	  BlockType		  Inport
	  Name			  "In1"
	  Position		  [590, 203, 620, 217]
	  Port			  "1"
	  LatchInput		  off
	  DataType		  "double"
	  SignalType		  "real"
	  Interpolate		  on
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Model Inputs"
	  Ports			  [1, 1]
	  Position		  [390, 59, 565, 91]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_input"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT  Model Inputs: MTTU"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MTT Plant Model"
	  Ports			  [1, 2]
	  Position		  [65, 61, 250, 199]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	  Port {
	    PortNumber		    1
	    Name		    "MTT Model States: MTTX"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	  Port {
	    PortNumber		    2
	    Name		    "MTT Model Outputs: MTTY"
	    TestPoint		    off
	    LinearAnalysisOutput    off
	    LinearAnalysisInput	    off
	    RTWStorageClass	    "Auto"
	  }
	}
	Block {
	  BlockType		  Memory
	  Name			  "Memory"
	  Position		  [870, 80, 900, 110]
	  X0			  "0"
	  InheritSampleTime	  off
	  RTWStateStorageClass	  "Auto"
	}
	Block {
	  BlockType		  Memory
	  Name			  "Memory1"
	  Position		  [860, 175, 890, 205]
	  X0			  "0"
	  InheritSampleTime	  off
	  RTWStateStorageClass	  "Auto"
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "S-Function"
	  Ports			  [4, 2]
	  Position		  [710, 47, 840, 238]
	  BackgroundColor	  "lightBlue"
	  DropShadow		  on
	  FunctionName		  "<mtt_model_name>_sfun_interface"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	}
	Block {
	  BlockType		  Outport
	  Name			  "Out1"
	  Position		  [905, 183, 935, 197]
	  Port			  "1"
	  OutputWhenDisabled	  "held"
	  InitialOutput		  "[]"
	}
	Line {
	  Name			  "MTT Model States: MTTX"
	  Labels		  [2, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  1
	  Points		  [0, 0; 105, 0]
	  Branch {
	    Points		    [0, -20]
	    DstBlock		    "MTT Model Inputs"
	    DstPort		    1
	  }
	  Branch {
	    Points		    [0, 25]
	    DstBlock		    "S-Function"
	    DstPort		    2
	  }
	}
	Line {
	  Name			  "MTT Model Outputs: MTTY"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Plant Model"
	  SrcPort		  2
	  DstBlock		  "S-Function"
	  DstPort		  3
	}
	Line {
	  Name			  "MTT  Model Inputs: MTTU"
	  Labels		  [1, 0]
	  SrcBlock		  "MTT Model Inputs"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "In1"
	  SrcPort		  1
	  DstBlock		  "S-Function"
	  DstPort		  4
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  1
	  DstBlock		  "Memory"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Memory"
	  SrcPort		  1
	  Points		  [0, -55; -855, 0]
	  DstBlock		  "MTT Plant Model"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Memory1"
	  SrcPort		  1
	  DstBlock		  "Out1"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  2
	  DstBlock		  "Memory1"
	  DstPort		  1
	}
      }
    }
    Block {
      BlockType		      Outport
      Name		      "Out1"
      Position		      [185, 43, 215, 57]
      Port		      "1"
      OutputWhenDisabled      "held"
      InitialOutput	      "[]"
    }
    Line {
      SrcBlock		      "MTT Model\n<mtt_model_name>"
      SrcPort		      1
      DstBlock		      "Out1"
      DstPort		      1
    }
    Line {
      SrcBlock		      "In1"
      SrcPort		      1
      DstBlock		      "MTT Model\n<mtt_model_name>"
      DstPort		      1
    }
  }
}

Deleted mttroot/mtt/lib/rep/sfun_rep/mex_ae.c.tmpl version [ca0d3e6d3b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_ae.c:
 * Matlab mex algebraic equations for <mtt_model_name>
 */

#if <have_algebraic_equations> /* have_algebraic_equations */

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <mex.h>
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"
#include "<mtt_model_name>_cr.h"

/* utility procedures */

double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

/* system equations */

static void
<mtt_model_name>_ae (double *mttyz,
		     const double *mttx,
		     const double *mttu,
		     const double mttt,
		     const double *mttpar)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

/* generic mex function */

#ifdef __cplusplus
extern "C" {
#endif

void
mexFunction (int nlhs, mxArray *plhs[],
	     int nrhs, const mxArray *prhs[])
{
  double *mttyz;		/* residuals */

  double *mttx;			/* states */
  double *mttu;			/* known + unknown inputs */
  double mttt;			/* time */
  double *mttpar;		/* parameters */

  unsigned int i;
  double *p;

  PRINT_ENTER;

  mttyz		= array_of_double (MTTNYZ);

  mttx		= array_of_double (MTTNX);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttpar	= array_of_double (MTTNPAR);

  /* get trial values */
  p = mxGetPr (prhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* get states */
  p = mxGetPr (prhs[1]);
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = p[i];
  }

  /* get known inputs */
  p = mxGetPr (prhs[2]);
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = p[i];
  }

  /* get time */
  p = mxGetPr (prhs[3]);
  mttt = *p;

  /* get parameters */
  p = mxGetPr (prhs[4]);
  for (i = 0; i < MTTNPAR; i++) {
    mttpar[i] = p[i];
  }
  
  /* evaluate residuals */
  <mtt_model_name>_ae (mttyz, mttx, mttu, mttt, mttpar);
  
  /* return residuals */
  plhs[0] = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  p = mxGetPr (plhs[0]);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = mttyz[i];
  }

  /* release memory */
  free (mttx);
  free (mttu);
  free (mttpar);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef __cplusplus
}
#endif

#endif /* have_algebraic_equations */

Deleted mttroot/mtt/lib/rep/sfun_rep/sfun.c.tmpl version [f43285b0f1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322


































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun.c:
 * Matlab S-function simulation of <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"
#include "<mtt_model_name>_cr.h"

static double *mttdx;		/* pointer to rates */
static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double *mttyz;		/* pointer to residuals */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_ae (void)
{
#include "<mtt_model_name>_ae.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_ode (void)
{
#include "<mtt_model_name>_ode.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_odeo (void)
{
#include "<mtt_model_name>_odeo.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_state (void)
{
#include "<mtt_model_name>_state.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttdx		= array_of_double (MTTNX);
  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);
  mttyz		= array_of_double (MTTNYZ);

  PRINT_LEAVE;
}

static void
update_states_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = ssGetContStates (S)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_inputs_from_solver (void)
{
#if <have_algebraic_equations> /* have_algebraic_equations */
  mxArray *MTT_MATLAB_P;
  mxArray *MTT_MATLAB_T;
  mxArray *MTT_MATLAB_U;
  mxArray *MTT_MATLAB_Ui;
  mxArray *MTT_MATLAB_X;

  double *p;

  PRINT_ENTER;

  /* starting value for solver - start with zero */
  MTT_MATLAB_Ui = mxCreateDoubleMatrix (MTTNYZ, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    p[i] = 0.0;
  }
  mexPutVariable ("base", "MTT_Ui", MTT_MATLAB_Ui);

  /* put states into matlab workspace */
  MTT_MATLAB_X = mxCreateDoubleMatrix (MTTNX, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_X);
  for (i = 0; i < MTTNX; i++) {
    p[i] = mttx[i];
  }
  mexPutVariable ("base", "MTT_X", MTT_MATLAB_X);

  /* put known inputs into matlab workspace */
  MTT_MATLAB_U = mxCreateDoubleMatrix (MTTNU, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_U);
  for (i = 0; i < MTTNU; i++) {
    p[i] = mttu[i];
  }
  mexPutVariable ("base", "MTT_U", MTT_MATLAB_U);

  /* put time into matlab workspace */
  MTT_MATLAB_T = mxCreateDoubleMatrix (1, 1, mxREAL);
  *mxGetPr (MTT_MATLAB_T) = mttt;
  mexPutVariable ("base", "MTT_T", MTT_MATLAB_T);

  /* put parameters into matlab workspace */
  MTT_MATLAB_P = mxCreateDoubleMatrix (MTTNPAR, 1, mxREAL);
  p = mxGetPr (MTT_MATLAB_P);
  for (i = 0; i < MTTNPAR; i++) {
    p[i] = mttpar[i];
  }
  mexPutVariable ("base", "MTT_P", MTT_MATLAB_P);

  /* call solver */
  mexEvalString ("MTT_Ui = lsqnonlin (@<mtt_model_name>_sfun_ae, MTT_Ui, [], [], optimset('display','off','diagnostics','off','TolX',1e-2,'TolFun',1e-2), MTT_X, MTT_U, MTT_T, MTT_P);");

  /* retrieve result */
  MTT_MATLAB_Ui = mexGetVariable ("base", "MTT_Ui");
  p = mxGetPr (MTT_MATLAB_Ui);
  for (i = 0; i < MTTNYZ; i++) {
    mttu[MTTNU + i] = p[i];
  }

  /* free memory */
  mxDestroyArray (MTT_MATLAB_P);
  mxDestroyArray (MTT_MATLAB_T);
  mxDestroyArray (MTT_MATLAB_U);
  mxDestroyArray (MTT_MATLAB_Ui);
  mxDestroyArray (MTT_MATLAB_X);

  PRINT_LEAVE;
#endif /* have_algebraic_equations */
  ;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, MTTNX);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortDirectFeedThrough(S, 0, 1);

  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNX);
  ssSetOutputPortWidth(S, 1, MTTNY);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);

  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;

  <mtt_model_name>_numpar ();
  <mtt_model_name>_state ();

  for (i = 0; i < MTTNX; i++) {
    ssGetContStates (S)[i] = mttx[i];
  }

  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  }
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_odeo ();

  for (i = 0; i < MTTNX; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttx[i];
  }

  for (i = 0; i < MTTNY; i++) {
      ssGetOutputPortRealSignal (S, 1)[i] = mtty[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
    
  update_states_from_simulink (S);
  update_inputs_from_simulink (S);
  if (MTTNYZ > 0) {
    update_inputs_from_solver ();
  } 
  update_simtime_from_simulink (S);

  <mtt_model_name>_ode ();

  for (i = 0; i < MTTNX; i++) {
    ssGetdX (S)[i] = mttdx[i];
  }

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;
  UNUSED_ARG(S);

  free (mttdx);
  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);
  free (mttyz);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

Deleted mttroot/mtt/lib/rep/sfun_rep/sfun_debug.h version [484e8ce3d6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30






























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

#ifndef HAVE_SFUN_DEBUG_H
#define HAVE_SFUN_DEBUG_H


#if defined DEBUG && defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered '%s'\n", __FUNCTION__);
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving '%s'\n", __FUNCTION__);

#elif defined DEBUG && ! defined __GNUC__

#include <stdio.h>
#define PRINT_ENTER fprintf (stderr, "debug> Entered a function\n");
#define PRINT_LEAVE fprintf (stderr, "debug> Leaving a function\n");

#elif ! defined DEBUG

#define PRINT_ENTER
#define PRINT_LEAVE

#else

#error "Momentary lapse of logic : unreachable statement reached"

#endif


#endif /* HAVE_SFUN_DEBUG_H */

Deleted mttroot/mtt/lib/rep/sfun_rep/sfun_input.c.tmpl version [37d9259f60].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_input.c:
 * Matlab S-function inputs for <mtt_model_name>
 */

#define S_FUNCTION_NAME <mtt_model_name>_sfun_input
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"
#include "<mtt_model_name>_cr.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static unsigned int i;		/* loop counter */

/* system equations */

static void
<mtt_model_name>_input (void)
{
#include "<mtt_model_name>_input.c"
  PRINT_LEAVE;
}

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, MTTNX);
  ssSetInputPortDirectFeedThrough(S, 0, 1);
    
  if (!ssSetNumOutputPorts(S, 1)) return;
  ssSetOutputPortWidth(S, 0, MTTNU);
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  <mtt_model_name>_input ();

  for (i = 0; i < MTTNU; i++) {
      ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

Deleted mttroot/mtt/lib/rep/sfun_rep/sfun_interface.c.tmpl version [8f8ea00a46].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275



















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* -*-c-*-	Put emacs into c-mode
 * <mtt_model_name>_sfun_interface.c:
 * Matlab S-function to process inputs and outputs of <mtt_model_name>
 */


#define S_FUNCTION_NAME <mtt_model_name>_sfun_interface
#define S_FUNCTION_LEVEL 2

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "simstruc.h"
#include "sfun_debug.h"
#include "useful-functions.hh"
#include "<mtt_model_name>_def.h"
#include "<mtt_model_name>_sympar.h"

static double *mttu;		/* pointer to inputs */
static double *mttpar;		/* pointer to parameters */
static double *mttx;		/* pointer to states */
static double *mtty;		/* pointer to outputs */
static double  mttt;		/* time */

static double *MTT_outputs;
static double *MTT_inputs;

static unsigned int i;		/* loop counter */

/* Start EDIT */
/* Edit this block to define the number of simulink inputs, outputs and parameters */
#define NumberOfSimulinkInputs	MTTNY /* MTT outputs */
#define NumberOfSimulinkOutputs	MTTNU /* MTT inputs */
/* End EDIT */

static void
<mtt_model_name>_process_inputs (SimStruct *S)
{
  /* insert <mtt_model_name>_struc.c */

  /* Start EDIT */
  /* Edit this block to process the model inputs and outputs */
  
  /* Error messages can be set using the following line */
  /*  ssSetErrorStatus (S, "<mtt_model_name>_some error message!\n"); */

  /* Default is to expose all MTT inputs, outputs and states */

  /* Get all the MTT model outputs and pass them to simulink */
  for (i = 0; i < NumberOfSimulinkInputs; i++) {
    MTT_outputs[i] = mtty[i];
  }

  /* Get all inputs from Simulink and pass them to the MTT model */
  /* Any inputs not over-written here will be read from <mtt_model_name>_input.c  */
  for (i = 0; i < NumberOfSimulinkOutputs; i++) {
    mttu[i] = MTT_inputs[i];
  }

  /* End EDIT */
}


/******************************************************************************
 *                DO NOT EDIT ANYTHING BELOW THIS LINE                        *
 ******************************************************************************/

/* system equations */

static void
<mtt_model_name>_numpar (void)
{
#include "<mtt_model_name>_numpar.c"
  PRINT_LEAVE;
}

/* utility procedures */

static double *
array_of_double (size_t n)
{
  void *p = calloc (n, sizeof (double));
  if (! p) {
    fprintf (stderr, "*** Error: failed to allocate memory\n");
  }
  return (double *) p;
}

static void
check_finite(SimStruct *S, double *array, unsigned int index)
{
  const char *array_name;
  char warning[128];
  if ((array[index] <= 0.0) || (array[index] >= 0.0)) {
    ; /* no problem */
  } else {
    if (array == mttpar) {
      array_name = "mttpar";
    } else if (array == mttu) {
      array_name = "mttu";
    } else if (array == mttx) {
      array_name = "mttx";
    } else if (array == mtty) {
      array_name = "mtty";
    } else if (array == MTT_outputs) {
      array_name = "MTT_outputs";
    } else if (array == MTT_inputs) {
      array_name = "MTT_inputs";
    } else {
      array_name = "unknown_array";
    }
    sprintf(warning, "(time %f) Non-finite array element: %s[%d]\n", mttt, array_name, index);
    ssWarning(S, warning);
  }
}

static void
initialise_arrays (void)
{
  PRINT_ENTER;

  mttpar	= array_of_double (MTTNPAR);
  mttu		= array_of_double (MTTNU + MTTNYZ);
  mttx		= array_of_double (MTTNX);
  mtty		= array_of_double (MTTNY);

  MTT_outputs	= array_of_double (NumberOfSimulinkInputs);
  MTT_inputs	= array_of_double (NumberOfSimulinkOutputs);

  PRINT_LEAVE;
}

static void
update_inputs_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  for (i = 0; i < MTTNU; i++) {
    mttu[i] = *ssGetInputPortRealSignalPtrs (S, 0)[i];
    check_finite(S, mttu, i);
  }
  for (i = 0; i < MTTNX; i++) {
    mttx[i] = *ssGetInputPortRealSignalPtrs (S, 1)[i];
    check_finite(S, mttx, i);
  }
  for (i = 0; i < MTTNY; i++) {
    mtty[i] = *ssGetInputPortRealSignalPtrs (S, 2)[i];
    check_finite(S, mtty, i);
  }
  for (i = 0; i < NumberOfSimulinkOutputs; i++) {
    MTT_inputs[i] = *ssGetInputPortRealSignalPtrs (S, 3)[i];
    check_finite(S, MTT_inputs, i);
  }
  PRINT_LEAVE;
}

static void
update_simtime_from_simulink (SimStruct *S)
{
  PRINT_ENTER;
  mttt = ssGetT (S);
  PRINT_LEAVE;
}

/* S-function methods */

static void mdlInitializeSizes(SimStruct *S)
{
  PRINT_ENTER;

  ssSetNumSFcnParams(S, 0); 
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    PRINT_LEAVE;
    return;
  }
  
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  
  if (!ssSetNumInputPorts(S, 4)) return;
  ssSetInputPortWidth(S, 0, MTTNU);
  ssSetInputPortWidth(S, 1, MTTNX);
  ssSetInputPortWidth(S, 2, MTTNY);
  ssSetInputPortWidth(S, 3, NumberOfSimulinkOutputs);	/* inputs from simulink */
  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetInputPortDirectFeedThrough(S, 1, 1);
  ssSetInputPortDirectFeedThrough(S, 2, 1);
  ssSetInputPortDirectFeedThrough(S, 3, 1);
    
  if (!ssSetNumOutputPorts(S, 2)) return;
  ssSetOutputPortWidth(S, 0, MTTNU); /* altered inputs */
  ssSetOutputPortWidth(S, 1, NumberOfSimulinkInputs); /* outputs to simulink */
    
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
  
  initialise_arrays ();

  PRINT_LEAVE;
}

static void mdlInitializeSampleTimes(SimStruct *S)
{
  PRINT_ENTER;
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
  PRINT_LEAVE;
}

#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
  PRINT_ENTER;
  <mtt_model_name>_numpar ();
  PRINT_LEAVE;
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  PRINT_ENTER;

  update_inputs_from_simulink (S);
  update_simtime_from_simulink (S);

  <mtt_model_name>_process_inputs (S);

  UNUSED_ARG(tid); /* not used in single tasking mode */

  for (i = 0; i < MTTNU; i++) {
    check_finite(S, mttu, i);
    ssGetOutputPortRealSignal (S, 0)[i] = mttu[i];
  }
  
  for (i = 0; i < NumberOfSimulinkInputs; i++) {
    check_finite(S, MTT_outputs, i);
    ssGetOutputPortRealSignal (S, 1)[i] = MTT_outputs[i];
  }

  PRINT_LEAVE;
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  PRINT_ENTER;
  PRINT_LEAVE;
}

static void mdlTerminate(SimStruct *S)
{
  PRINT_ENTER;

  UNUSED_ARG(S);

  free (mttpar);
  free (mttu);
  free (mttx);
  free (mtty);

  free (MTT_outputs);
  free (MTT_inputs);

  PRINT_LEAVE;
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

Deleted mttroot/mtt/lib/xfig/Basic/0.fig version [fc409194ef].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 0\001

Deleted mttroot/mtt/lib/xfig/Basic/1.fig version [fa271395bb].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 1\001

Deleted mttroot/mtt/lib/xfig/Basic/AE.fig version [63cbbf46d6].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AE:ae_1\001

Deleted mttroot/mtt/lib/xfig/Basic/AEf.fig version [cd581c11ab].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AEf:aef_1\001

Deleted mttroot/mtt/lib/xfig/Basic/AF.fig version [d3d62f06c4].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AF:af_1\001

Deleted mttroot/mtt/lib/xfig/Basic/AFe.fig version [e76fcd7f46].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 AFe:afe_1\001

Deleted mttroot/mtt/lib/xfig/Basic/C.fig version [7ff23716fc].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 C:c_1\001

Deleted mttroot/mtt/lib/xfig/Basic/De.fig version [453a3f3f0b].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 De:de_1\001

Deleted mttroot/mtt/lib/xfig/Basic/DescriptiveText.fig version [174032c291].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 1 101 0 3 20 0.0000 4 255 2025 1395 630 Descriptive text.\001

Deleted mttroot/mtt/lib/xfig/Basic/Df.fig version [371772784b].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Df:df_1\001

Deleted mttroot/mtt/lib/xfig/Basic/EMTF.fig version [3d87d41331].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 EMTF:emtf_1\001

Deleted mttroot/mtt/lib/xfig/Basic/GY.fig version [a49e410bdc].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 GY:gy_1\001

Deleted mttroot/mtt/lib/xfig/Basic/I.fig version [2989eccd82].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 I:i_1\001

Deleted mttroot/mtt/lib/xfig/Basic/INTF.fig version [ecff474a22].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 INTF:intf_1\001

Deleted mttroot/mtt/lib/xfig/Basic/InPort.fig version [fd70624acc].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 2 4 100 0 18 18 0.0000 4 270 870 1890 855 SS:[in]\001

Deleted mttroot/mtt/lib/xfig/Basic/MAKE_COMPONENT version [e7c52bd3fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
## Makes a new component

if [ -z "$2" ]; then
  label=$1
else
  label=$2    
fi

case $1 in
    0)
	echo Making new component $1 with no label
        sed "s/TEXT/$1/" <template.txt >$1.fig
	;;
    1)
	echo Making new component $1 with no label
        sed "s/TEXT/$1/" <template.txt >$1.fig
	;;
    *)
  echo Making new component $1 with label $label
  sed "s/TEXT/$1:$label/" <template.txt >$1.fig
esac

Deleted mttroot/mtt/lib/xfig/Basic/MAKE_COMPONENTS version [e2b32f5799].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
## Makes all components

./MAKE_COMPONENT R r_1
./MAKE_COMPONENT C c_1
./MAKE_COMPONENT I i_1

./MAKE_COMPONENT 0
./MAKE_COMPONENT 1

./MAKE_COMPONENT SS ss_1
./MAKE_COMPONENT Se se_1
./MAKE_COMPONENT Sf sf_1
./MAKE_COMPONENT De de_1
./MAKE_COMPONENT Df df_1

./MAKE_COMPONENT TF tf_1
./MAKE_COMPONENT GY gy_1
./MAKE_COMPONENT AE ae_1
./MAKE_COMPONENT AEf aef_1
./MAKE_COMPONENT AF af_1
./MAKE_COMPONENT AFe afe_1


./MAKE_COMPONENT EMTF emtf_1
./MAKE_COMPONENT INTF intf_1

./MAKE_COMPONENT Subsystem sub_1

Deleted mttroot/mtt/lib/xfig/Basic/OutPort.fig version [9c5dd9c690].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 0 4 100 0 18 18 0.0000 4 270 1065 1890 855 SS:[out]\001

Deleted mttroot/mtt/lib/xfig/Basic/Port.fig version [6321cfa21c].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 4 100 0 18 18 0.0000 4 300 1620 1890 855 SS:[port_1]\001

Deleted mttroot/mtt/lib/xfig/Basic/PortLabel.fig version [cb5b36e605].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 4 100 0 18 14 0.0000 4 210 825 855 630 [port_1]\001

Deleted mttroot/mtt/lib/xfig/Basic/PortLabel.txt version [cb5b36e605].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 4 100 0 18 14 0.0000 4 210 825 855 630 [port_1]\001

Deleted mttroot/mtt/lib/xfig/Basic/R.fig version [654cc51222].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 R:r_1\001

Deleted mttroot/mtt/lib/xfig/Basic/SS.fig version [9f614e5774].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 SS:ss_1\001

Deleted mttroot/mtt/lib/xfig/Basic/Se.fig version [6de4ea567d].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Se:se_1\001

Deleted mttroot/mtt/lib/xfig/Basic/Sf.fig version [6e96816a11].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Sf:sf_1\001

Deleted mttroot/mtt/lib/xfig/Basic/Subsystem.fig version [37c513eb5f].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 Subsystem:sub_1\001

Deleted mttroot/mtt/lib/xfig/Basic/TF.fig version [86e02d055f].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 TF:tf_1\001

Deleted mttroot/mtt/lib/xfig/Basic/blue-box.fig version [de5f3c52ac].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 1 2 1 7 101 0 -1 6.000 0 0 7 0 0 5
	 3825 2700 450 2700 450 450 3825 450 3825 2700

Deleted mttroot/mtt/lib/xfig/Basic/bond.fig version [320851a75c].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3
	 900 675 2250 675 2025 900

Deleted mttroot/mtt/lib/xfig/Basic/gold-box.fig version [68e5946bc3].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5
	 3825 2700 450 2700 450 450 3825 450 3825 2700

Deleted mttroot/mtt/lib/xfig/Basic/halfstroke.fig version [1fdeb37f4d].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 1350 1125 1350 1350

Deleted mttroot/mtt/lib/xfig/Basic/stroke.fig version [4fd3498223].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2
	 675 675 675 1125

Deleted mttroot/mtt/lib/xfig/Basic/template.txt version [b2d9218f91].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 TEXT\001

Deleted mttroot/mtt/lib/xfig/Thermal/CT.fig version [fc7936d9f9].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 CT:ct_1\001

Deleted mttroot/mtt/lib/xfig/Thermal/MAKE_COMPONENT version [9f63b6b6f6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
## Makes a new component

if [ -z "$2" ]; then
  label=$1
else
  label=$2    
fi

if [ "$1" = "0" ]||[ "$1" = "1" ]; then
  echo Making new component $1 with no label
  sed "s/TEXT/$1/" <template.txt >$1.fig
else
  echo Making new component $1 with label $label
  sed "s/TEXT/$1:$label/" <template.txt >$1.fig
fi

Deleted mttroot/mtt/lib/xfig/Thermal/MAKE_COMPONENTS version [ab85a0e8eb].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
#!/bin/sh
## Makes all components

./MAKE_COMPONENT RS rs_1
./MAKE_COMPONENT RT rt_1
./MAKE_COMPONENT CT ct_1

Deleted mttroot/mtt/lib/xfig/Thermal/RS.fig version [d967438bbf].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 RS:rs_1\001

Deleted mttroot/mtt/lib/xfig/Thermal/RT.fig version [434299c19a].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 RT:rt_1\001

Deleted mttroot/mtt/lib/xfig/Thermal/template.txt version [b2d9218f91].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
#FIG 3.2
Portrait
Center
Metric
A4      
100.00
Single
-2
1200 2
4 1 0 100 0 18 18 0.0000 4 285 765 900 765 TEXT\001

Deleted mttroot/mtt/lib/xfig/libs.txt version [021119315b].

1
2
3
4




-
-
-
-
/home/peterg/mtt_new/mtt/lib/xfig/Basic  Basic
/home/peterg/mtt_new/mtt/lib/comp/compound/Electrical Electrical
/home/peterg/mtt_new/mtt/lib/comp/compound/Thermal Thermal

Deleted mttroot/ntt/COPYING version [8252cc0f12].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358






































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

    ntt: new transformation tools for using bond graphs with Matlab
    Copyright (C) 2003  Dr. Dominic J. Diston

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
^L
		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

		    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

			    NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS

	    How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year  name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

Deleted mttroot/ntt/bin/make_abg.m version [44a307073f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function abg = make_abg(system)
global mtt_environment

start_time = mttGetTime ;

input = [] ;
abg = [] ;


switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    


if strcmp(input,'spec')
    mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;

    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

mttAssert(strcmp(input,'abg'),'Input representation not recognised') ;

if isempty(abg)
    mttWriteNewLine ;
    mttNotify('Copying "abg" representation') ;
    mttWriteNewLine ;
    
    mttNotify('...INFO: Input already defined as a "abg": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    abg = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Deleted mttroot/ntt/bin/make_cbg.m version [d10c4751f3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function cbg = make_cbg(system)
global mtt_environment

start_time = mttGetTime ;

input = [] ;
abg = [] ;
cbg = [] ;


switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    


if strcmp(input,'spec')
    mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;

    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

mttAssert(strcmp(input,'cbg'),'Input representation not recognised') ;

if isempty(cbg)
    mttWriteNewLine ;
    mttNotify('Copying "cbg" representation') ;
    mttWriteNewLine ;

    mttNotify('...INFO: Input already defined as a "cbg": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    cbg = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Deleted mttroot/ntt/bin/make_env.m version [bd8ec0bc89].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function make_env(system)
global mtt_environment

start_time = mttGetTime ;

input = [] ;
env = [] ;


switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

if strcmp(input,'spec')
    mttWriteNewLine ;
    mttNotify('Making "env" representation') ;
    mttWriteNewLine ;

    env = mttCreateEnvironment(system) ;
    input = 'env' ;
end

mttAssert(strcmp(input,'env'),'Input representation not recognised') ;

if isempty(env)
    mttWriteNewLine ;
    mttNotify('Copying "env" representation') ;
    mttWriteNewLine ;

    mttNotify('...INFO: Input already defined as a "env": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    env = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;


mtt_environment = env ;

Deleted mttroot/ntt/bin/make_ese.m version [2b8c245d06].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ese = make_ese(system,sorter_on)
global mtt_environment

if nargin<2
    sorter_on = 1 ;
end

switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

start_time = mttGetTime ;

abg = [] ;
cbg = [] ;
ese = [] ;

if strcmp(input,'spec')
 	mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;
    
    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

if strcmp(input,'cbg')
    if isempty(cbg)
        cbg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "cbg" to "ese"') ;
    mttWriteNewLine ;
    ese = mttCreateElementaryEquations(cbg,sorter_on) ;
    input = 'ese' ;
end

mttAssert(strcmp(input,'ese'),'Input representation not recognised') ;

if isempty(ese)
    mttWriteNewLine ;
    mttNotify('Making "ese" representation') ;
    mttWriteNewLine ;

    mttNotify('Input already defined as a "ese": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    ese = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Deleted mttroot/ntt/bin/make_mdl.m version [8f904e7563].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function make_sfun(system,sorter_on)
global mtt_environment

if nargin<2
    sorter_on = 1 ;
end

switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

start_time = mttGetTime ;

abg = [] ;
cbg = [] ;
ese = [] ;

if strcmp(input,'spec')
 	mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;
    
    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

if strcmp(input,'cbg')
    if isempty(cbg)
        cbg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "cbg" to "ese"') ;
    mttWriteNewLine ;
    ese = mttCreateElementaryEquations(cbg,sorter_on) ;
    input = 'ese' ;
end

mttAssert(strcmp(input,'ese'),'Input representation not recognised') ;

if isempty(ese)
    ese = system ;
end
mttCreateSystemMdl(ese) ;
    

elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Deleted mttroot/ntt/bin/make_sfun.m version [9b2b6d6f69].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function make_sfun(system,sorter_on)
global mtt_environment

if nargin<2
    sorter_on = 1 ;
end

switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

start_time = mttGetTime ;

abg = [] ;
cbg = [] ;
ese = [] ;

if strcmp(input,'spec')
 	mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;
    
    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

if strcmp(input,'cbg')
    if isempty(cbg)
        cbg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "cbg" to "ese"') ;
    mttWriteNewLine ;
    ese = mttCreateElementaryEquations(cbg,sorter_on) ;
    input = 'ese' ;
end

mttAssert(strcmp(input,'ese'),'Input representation not recognised') ;

if isempty(ese)
    ese = system ;
end
mttWriteSystemEquations(ese) ;
mttWriteSystemDefinitions(ese) ;
mttWriteSystemInitialisation(ese) ;
mttWriteSystemMapping(ese) ;

ese = mttCreateApps(ese) ;
mttWriteSystemApps(ese) ;
mttWriteSystemSfun(ese) ;
    

elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Deleted mttroot/ntt/bin/trans/m/mttApplyInterfaceCausality.m version [028f9372f5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200








































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttApplyInterfaceCausality(model,specified_rule,branch) ;
    is_root_model = (nargin==2) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttApplyInterfaceCausality(object,specified_rule,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        else
            if ~isempty(object.cr)
                if is_root_model
                    branch = mttDetachText(model.source,'/') ;
                end
                here = [branch,':',object_name] ;
                
                port_names = mttGetFieldNames(object.cr.interface,'port') ;
                
                for j = 1:length(port_names)
                    port_name = port_names{j} ;
                    port = getfield(object.cr.interface,'port',port_name) ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    for k = 1:mttGetFieldLength(port,'causality')
                        rule = port.causality(k).rule ;
                        definition = port.causality(k).def ;
                        association = port.causality(k).with ;
                        not_applied = ~port.causality(k).applied ;
                        
                        switch rule
                        case 'assert',  is_assertion = 1 ;
                        case 'prefer',  is_assertion = 0 ;
                        otherwise
                            error(['Unrecognised rule "',port_causality.rule,'" in ',here]) ;
                        end
                        
                        apply_rule = strcmp(specified_rule,rule) & not_applied ;
                        if apply_rule
                            
                            switch definition
%                            case 'effort_state',
%                                mttAssert(mttIsEqual(port.is_flow_state,0),...
%                                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
%                                port.is_effort_state = 1 ;
                                
%                            case 'flow_state',
%                                mttAssert(mttIsEqual(port.is_effort_state,0),...
%                                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
%                                port.is_flow_state = 1 ;
                                
                            case {'effort_in_flow_out','flow_in_effort_out','flow_out_effort_in','effort_out_flow_in'}
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                switch definition
                                case {'effort_in_flow_out','flow_out_effort_in'},
                                    [model,inbond_ok] = mttUpdateBondCausality(model,inbond,1,1,1) ; 
                                    [model,outbond_ok] = mttUpdateBondCausality(model,outbond,0,0,1) ;
                                case {'flow_in_effort_out','effort_out_flow_in'},
                                    [model,inbond_ok] = mttUpdateBondCausality(model,inbond,0,0,1) ; 
                                    [model,outbond_ok] = mttUpdateBondCausality(model,outbond,1,1,1) ;
                                end

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'effort_in'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,1,[],1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,0,[],1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'effort_out'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,0,[],1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,1,[],1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'flow_in'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,[],0,1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,[],1,1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'flow_out'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,[],1,1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,[],0,1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'unicausal',
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,[],[],1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,[],[],1) ;
                                
                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case {'equicausal','anticausal'}
                                mttAssert(length(association)==1,...
                                    ['Incorrect constraint at port "',port_name,'" in ',here]) ;
                                
                                associated_port_name = association{1} ;
                                associated_port = getfield(cr.interface,'port',associated_port_name) ;
                                
                                associated_inbond = associated_port.in ;
                                associated_outbond = associated_port.out ;
                                
                                mttAsert(xor(isempty(inbond),isempty(outbond)),...
                                    ['Causal rule expects unique bond at port "',port_name,'" in ',here]) ;
                                mttAsert(xor(isempty(associated_inbond),isempty(associated_outbond)),...
                                    ['Causal rule expects unique bond at port "',associated_port_name,'" in ',here]) ;
                                
                                if isempty(associated_inbond)
                                    a = associated_outbond ;
                                else
                                    a = associated_inbond ;
                                end
                                
                                if isempty(inbond)
                                    b = outbond ;
                                else
                                    b = inbond ;
                                end
                                
                                switch definition
                                case 'equicausal',
                                    [model,bond_ok] = mttUpdateBondCausality(model,b,...
                                        model.bond(a).effort,model.bond(a).flow,model.bond(a).unicausal) ; 
                                    [model,associated_bond_ok] = mttUpdateBondCausality(model,a,...
                                        model.bond(b).effort,~model.bond(b).flow,model.bond(b).unicausal) ;
                                case 'anticausal',
                                    [model,bond_ok] = mttUpdateBondCausality(model,b,...
                                        ~model.bond(a).effort,model.bond(a).flow,model.bond(a).unicausal) ; 
                                    [model,associated_bond_ok] = mttUpdateBondCausality(model,a,...
                                        ~model.bond(b).effort,~model.bond(b).flow,model.bond(b).unicausal) ;
                                end
                                
                                ok = bond_ok & associated_bond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict between ports "',port_name,...
                                            'and',associated_port_name,'" in ',here]) ;
                                end
                                
                            otherwise,
                                error(['Unrecognised constraint "',definition,'" in ',here]) ;
                            end
                            
                            port.causality(k).applied = 1 ;
                            object = setfield(object,'cr','interface','port',port_name,port) ;
                            model = setfield(model,'obj',object_name,object) ;
                        end                    
                    end
                end
            end
        end
    end
    

Deleted mttroot/ntt/bin/trans/m/mttApplyInterfaceDomains.m version [bfc53eba3d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttApplyInterfaceDomains(model,branch) ;
    is_root_model = (nargin==1) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttApplyInterfaceDomains(object,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        else
            if ~isempty(object.cr)
                if is_root_model
                    branch = mttDetachText(model.source,'/') ;
                end
                here = [branch,':',object_name] ;
                
                port_names = mttGetFieldNames(object.cr.interface,'port') ;
                
                for j = 1:length(port_names)
                    port_name = port_names{j} ;
                    port = getfield(object.cr.interface,'port',port_name) ;
                    
                    predefined_domain = port.domain ;
                    predefined_domain_item = port.domain_item ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    if isempty(inbond)
                        bond_number = outbond ;
                    else
                        bond_number = inbond ;
                    end
                    
                    [model,ok] = mttUpdateBondDomain(model,bond_number,predefined_domain,predefined_domain_item) ;
                    
                    mttAssert(ok,['Domain conflict at port "',port_name,'" in ',here]) ;
                end
            end
        end
    end
    

Deleted mttroot/ntt/bin/trans/m/mttCreateAcausalBondgraph.m version [a4799dbea4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131



































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttCreateAcausalBondgraph(system,root)
global mtt_environment


switch nargin
case 0,
    model = [] ; return ;
case 1,
    root = [] ;
    is_root_model = 1 ;
otherwise,
    is_root_model = 0 ;
end

if is_root_model
    model = intialise_model(system) ;
    
    directory_name = identify_directory_name(system) ;
    source_name = identify_source_name(system,directory_name) ;
    
    mttNotify('...acquiring "abg" source definitions') ;
    mttWriteNewLine ;
else
    model = propagate_root_data(root) ;
    source_name = system ;
end

specification_filename = [source_name,'_abg.txt'] ;
specification = mttFetchSpecification(specification_filename) ;
specification = mttSetFieldDefault(specification,'bondgraph',system) ;
    
[local_system_name,rubbish] = mttDetachText(system,'/') ;
if isempty(local_system_name)
    local_system_name = system ;
end


if is_root_model
    source_name = identify_source_name(specification.bondgraph,directory_name) ;
else
    source_name = specification.bondgraph ;
end
source_name = mttCutText(source_name,'_abg.fig') ;

bondgraph_filename = [source_name,'_abg.fig'] ;
bondgraph = mttFetchBondgraph(bondgraph_filename) ;

model = mttCreateUnifiedModel(model,bondgraph,specification) ;
model = mttDeleteField(model,'branch') ;
model = mttDeleteField(model,'leaf') ;


if is_root_model
    mttWriteNewLine ;
    mttNotify('...acquiring "cr" source definitions') ;
    mttWriteNewLine ;
    
    for n = 1:length(model.crs)
        source_name = model.crs{n} ;
        cr_filename = [source_name,'_cr.txt'] ;
        
        if ~mttFileExists(cr_filename)
            cr_short_name = mttDetachText(source_name,'/') ;
            
            mttNotify(['   ...ERROR: "',cr_short_name,'_cr" source does not exist']) ;
            mttWriteNewLine ;
            mttNotify(['   ...finding dependencies for ',source_name,':']) ;
            mttWriteNewLine ;
            
            prefix = mttDetachText(system,'/') ;
            if isempty(prefix)
                prefix = system ;
            end
            
            cr_user = model.cr_usage(n).obj ;
            for i = 1:length(cr_user)
                mttNotify(['         ',prefix,'/',cr_user{i}]) ;
                mttWriteNewLine ;
            end
        end
        
        model.cr(n) = mttFetchInterfaceDefinition(cr_filename) ;
    end
    
    model = mttDeleteField(model,'cr_usage') ;
    model = mttDeleteField(model,'crs') ;
    model = mttDeleteField(model,'abgs') ;
end

model.env = mtt_environment ;



function model = intialise_model(system)
    model.representation = 'abg' ;
    model.abgs = [] ;
    model.crs = [] ;
    model.cr_usage = [] ;
    model.branch = [] ;
    model.leaf = [] ;
    
function model = propagate_root_data(root)
    model.abgs = root.abgs ;
    model.crs = root.crs ;
    model.cr_usage = root.cr_usage ;
    model.branch = root.branch ;
    model.leaf = root.leaf ;

function directory = identify_directory_name(system)
    mttAssert(ischar(system),'System must be specified by name') ;
    working_directory  = pwd ;
    working_directory = strrep(working_directory,'\','/') ;
    
    [system_name,local_directory] = mttDetachText(system,'/') ;
    if isempty(system_name)
        local_directory = [] ;
    end
    
    if isempty(local_directory)
        directory = working_directory ;
    else
        directory = mttLocateDirectory(working_directory,local_directory) ;
    end
    
function source = identify_source_name(system,directory)
    [system_name,local_directory] = mttDetachText(system,'/') ;
    if isempty(system_name)
        system_name = system ;
        local_directory = [] ;
    end
    source = [directory,'/',system_name] ;

Deleted mttroot/ntt/bin/trans/m/mttCreateApps.m version [dd7bd6b560].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttCreateApps(model)

apps_filename = [model.source,'_apps.txt'] ;
apps = mttFetchApps(apps_filename) ;

if isempty(apps)
    return ;
end

for i = 1:length(apps.app)
    app_source = apps.app{i} ;
    
    [rubbish,working_directory] = mttDetachText(model.source,'/') ;
    [name,path_spec] = mttDetachText(app_source,'/') ;
    
    if isempty(name)
        source_name = [working_directory,'/',domain_source] ;
    else
        directory = identify_directory(working_directory,path_spec,model) ;
        source_name = [directory,'/',name] ;
    end
    
    app_filename = [source_name,'_app.h'] ;
    model.app{i} = app_filename ;
end

    
function directory = identify_directory(working_directory,path_spec,model)
	path_names = mttGetFieldNames(model.env,'path') ;

    if isempty(path_spec)
		directory = [] ;
    else
        if path_spec(1)=='$'
            [path_alias,path_branch] = mttCutText(path_spec,'/') ;
            path_alias(1) = [] ;
            
            mttAssert(ismember(path_alias,path_names),...
                ['Path "',path_alias,'" not recognised']) ;
            
            path_root = getfield(model.env,'path',path_alias) ;
            
            if isempty(path_branch)
                directory = path_root ;
            else
                directory = [path_root,'/',path_branch] ;
            end
        else
            [name,local_directory] = mttDetachText(path_spec,'/') ;
            
            directory_located = 0 ;
            if strcmp(local_directory,'.')
                if isempty(name)
                    directory = working_directory ;
                    directory_located = 1 ;
                else
                    local_directory = name ;
                end
            else
                local_directory = path_spec ;
            end
            
            if ~directory_located
                directory = mttLocateDirectory(working_directory,local_directory) ;
            end
        end
    end
    




Deleted mttroot/ntt/bin/trans/m/mttCreateCausalBondgraph.m version [88053c538d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452




































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttCreateCausalBondgraph(model)

model.representation = 'cbg' ;

model = incorporate_interface_definitions(model) ;
model = establish_abg_dependencies(model) ;
model = create_object_hierarchy(model) ;
model = assign_sympar_values(model) ;
model = complete_causal_assignment(model) ;
model = complete_domain_assignment(model) ;
model = overwrite_implicit_domains(model) ;


function model = incorporate_interface_definitions(model)
	mttNotify('...incorporating "cr" definitions') ;
    mttWriteNewLine ;
    
    mttNotify(['   ...processing ',model.source]) ;
    mttWriteNewLine ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~mttIsFoundationClass(object.class)
            mttAssert(xor(isempty(object.abg),isempty(object.cr)),...
                ['"',object_name,'" must exclusively have a "cr" or an "abg" representation']) ;
        end
        
        if isempty(object.cr)
            object = mttDeleteField(object,'cr_item') ;
            model = setfield(model,'obj',object_name,object) ;
        else
            model = mttEmbedInterfaceDefinition(model,object_name) ;
        end
    end
    
    for i = 1:mttGetFieldLength(model,'abg')
        component_type = mttDetachText(model.abg(i).source,'/') ;
        mttNotify(['   ...processing "#',num2str(i),':',component_type,'" ',model.abg(i).source]) ;
        mttWriteNewLine ;
        
        objects = mttGetFieldNames(model.abg(i),'obj') ;
        for j = 1:length(objects)
	        object_name = objects{j} ;
            object = getfield(model,'abg',{i},'obj',object_name) ;
            
    	    if ~mttIsFoundationClass(object.class)
	            mttAssert(xor(isempty(object.abg),isempty(object.cr)),...
        	        ['abg[',num2str(i),']: "',object_name,'" must exclusively have a "cr" or an "abg" representation']) ;
            end
            
            if isempty(object.cr)
                object = mttDeleteField(object,'cr_item') ;
                model = setfield(model,'abg',{i},'obj',object_name,object) ;
            else
                model.abg(i) = mttEmbedInterfaceDefinition(model.abg(i),object_name,model) ;
            end
        end
        model.abg(i).invokes = [] ;
        model.abg(i).invoked_by = [] ;
    end
    model = mttDeleteField(model,'cr') ;
    
    
function model = establish_abg_dependencies(model)
	mttNotify('...establishing "abg" dependencies') ;
    mttWriteNewLine ;
    
    for i = 1:mttGetFieldLength(model,'abg')
        objects = mttGetFieldNames(model.abg(i),'obj') ;
        for j = 1:length(objects)
            object_name = objects{j} ;
            object = getfield(model.abg(i).obj,object_name) ;
            
            if isempty(object.cr)	%... still within object hierarchy
                if ~mttIsFoundationClass(object.class)
                    existing_dependencies = model.abg(i).invokes ;
                    
                    if isempty(existing_dependencies)
                        new_dependency = 1 ;
                    else
                        new_dependency = isempty(find(existing_dependencies==object.abg)) ;
                    end
                    
                    if new_dependency
                        model.abg(i).invokes = [existing_dependencies,object.abg] ;
                    end
                    
                    existing_dependencies = model.abg(object.abg).invoked_by ;
                    if isempty(existing_dependencies)
                        new_dependency = 1 ;
                    else
                        new_dependency = isempty(find(existing_dependencies==i)) ;
                    end
                    
                    if new_dependency
                        model.abg(object.abg).invoked_by = [existing_dependencies,i] ;
                    end
                end
            end
        end
    end
    
    model.invokes = [] ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for j = 1:length(objects)
        object_name = objects{j} ;
        object = getfield(model.obj,object_name) ;
        
        if ~isempty(object.abg)
            if ~mttIsFoundationClass(object.class)
                existing_dependencies = model.invokes ;
                
                if isempty(existing_dependencies)
                    new_dependency = 1 ;
                else
                    new_dependency = isempty(find(existing_dependencies==object.abg)) ;
                end
                
                if new_dependency
                    model.invokes = [existing_dependencies,object.abg] ;
                end
            end
        end
    end
    
    
function model = create_object_hierarchy(model) ;
	mttNotify('...creating object hierarchy') ;
    mttWriteNewLine ;
    
    top_level_model = mttDetachText(model.source,'/') ;
    
    if isfield(model,'abg')
        is_embedded = zeros(1,length(model.abg)) ;
        embedding = 1 ;
    else
        embedding = 0 ;
    end
    
    component = 0 ;

    embedding = isfield(model,'abg') ;
    while embedding
        component = 1 + mod(component,length(model.abg)) ;
        if ~is_embedded(component)            
            if isempty(model.abg(component).invokes)
                number_of_systems = length(model.abg(component).invoked_by) ;
                
                for n = 1:number_of_systems
                    system = model.abg(component).invoked_by(n) ;
                    component_type = mttDetachText(model.abg(component).source,'/') ;
                    system_type = mttDetachText(model.abg(system).source,'/') ;
                    mttNotify(['   ...embedding "#',num2str(component),':',component_type,...
                            '" definition within "#',num2str(system),':',system_type,'" objects']) ;
                    mttWriteNewLine ;
                    
                    model = mttEmbedAcausalBondgraph(model,component,system) ;
                end
                model.abg(component).invoked_by = [] ;
                
                if ~isempty(find(model.invokes==component))
                    component_type = mttDetachText(model.abg(component).source,'/') ;
                    mttNotify(['   ...embedding "#',num2str(component),':',component_type,...
                            '" definition within "',top_level_model,'"']) ;
                    mttWriteNewLine ;
                    
                    model = mttEmbedAcausalBondgraph(model,component) ;
                end
                is_embedded(component) = 1 ;
            end
        end
        embedding = any(~is_embedded) ;
    end
    
    model = mttDeleteField(model,'abg') ;
    model = mttDeleteField(model,'invokes') ;
    
    
function model = assign_sympar_values(model) 
	mttNotify('...assigning "sympar" values') ;
    mttWriteNewLine ;
    
    model_name = mttDetachText(model.source,'/') ;
    current_branch = model_name ;
    
    sympars = model.sympar ;
    defaults = model.sympar_default ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~mttIsPassiveClass(object.class)
            for j = 1:length(object.parameter)
                object_parameter = object.parameter{j} ;
                if ischar(object_parameter)
                    index = strmatch(object_parameter,sympars,'exact') ;
                    
                    new_parameter = 0 ;
                    
                    if isempty(index)
                        new_parameter = 1 ;
                    else
                        default_value = defaults{index} ;
                        if isempty(default_value)
                            new_parameter = 1 ;
                        else
                            object.parameter{j} = default_value ;
                        end
                    end
                    
                    if new_parameter
                        object.parameter{j} = [current_branch,'___',object_parameter] ;
                    end
                end
            end
            
            branch = [model_name,'__',object_name] ;
            object = assign_object_sympar_values(object,branch) ;
            
            model = setfield(model,'obj',object_name,object) ;
        end
    end
    
    
function model = assign_object_sympar_values(model,branch)
    current_branch = branch ;
    
	sympars = model.sympar ;
    parameters = model.parameter ;
    
    if ~isempty(model.abg)
        objects = mttGetFieldNames(model,'obj') ;
        for i = 1:length(objects)
            object_name = objects{i} ;
            object = getfield(model,'obj',object_name) ;
            
            if ~mttIsPassiveClass(object.class)
                for j = 1:length(object.parameter)
                    object_parameter = object.parameter{j} ;
                    if ischar(object_parameter)
                        index = strmatch(object_parameter,sympars,'exact') ;
                        if isempty(index)
                            object.parameter{j} = [current_branch,'___',object_parameter] ;
                        else
                            object.parameter{j} = parameters{index} ;
                        end
                    end
                end
                
                branch = [current_branch,'__',object_name] ;
                object = assign_object_sympar_values(object,branch) ;
                
                model = setfield(model,'obj',object_name,object) ;
            end
        end
    elseif ~isempty(model.cr)
        model.cr.parameter = model.parameter ;
    end
    
    
function model = complete_causal_assignment(model)
    mttWriteNewLine ;
	mttNotify('...summarising model content') ;
    mttWriteNewLine ;
    
    model = mttCountObjects(model) ;
    mttNotifyNumberOfObjects(model) ;
    mttWriteNewLine ;
    model = mttDeleteField(model,'count') ;
    
    model = mttMeasureCausalCompletion(model) ;
	mttNotifyNumberOfBonds(model) ;
    mttWriteNewLine ;
    
    mttWriteNewLine ;
	mttNotify('...analysing predefined causality') ;
    mttWriteNewLine ;
    
	mttNotifyCausalCompletion(model) ;
    mttWriteNewLine ;
    
	if model.causal_completion.is_causal
        mttNotify('...applying CR constraints') ;
        mttWriteNewLine ;
        model = incorporate_cr_rules(model,'assert') ;
    else    
        mttNotify('...completing causality') ;
        mttWriteNewLine ;
        
        iterations = 0 ;
        
        propagating = 1 ;
        while propagating
            iterations = iterations + 1 ;
            previous_causal_completion = model.causal_completion ;
            
            model = mttApplyInterfaceCausality(model,'assert') ;
            model = mttPropagateCausality(model) ;
            model = mttApplyInterfaceCausality(model,'prefer') ;
            model = mttPropagateCausality(model) ;
            model = mttMeasureCausalCompletion(model) ;
            
            is_stable = mttCompareCausalCompletion(model.causal_completion,previous_causal_completion) ;
            propagating = (~is_stable) ;
            
            if propagating
                mttNotify(['...iteration ',num2str(iterations)]) ;
                mttWriteNewLine ;
                mttNotifyCausalCompletion(model) ;
            end
            
            propagating = propagating & (~model.causal_completion.is_causal) ;
        end
    end
    
    
    if ~model.causal_completion.is_causal
        mttWriteNewLine ;
        mttNotify('...causality not complete') ;
        mttWriteNewLine ;
        mttWriteNewLine ;
        
        mttIdentifyUndercausalBonds(model) ;
    end
    
    model = mttDeleteField(model,'causal_completion') ;
    
    
function model = complete_domain_assignment(model)
    mttWriteNewLine ;
	mttNotify('...allocating domain definitions') ;
    mttWriteNewLine ;
    
    model = mttMeasureDomainCompletion(model) ;
    
    iterations = 0 ;
    
    propagating = 1 ;
    while propagating
        iterations = iterations + 1 ;
        previous_domain_completion = model.domain_completion ;
        
        model = mttApplyInterfaceDomains(model) ;
        model = mttPropagateDomains(model) ;
        model = mttMeasureDomainCompletion(model) ;
        
        is_stable = mttCompareDomainCompletion(model.domain_completion,previous_domain_completion) ;
        propagating = (~is_stable) ;
        
        if propagating
            mttNotify(['...iteration ',num2str(iterations)]) ;
            mttWriteNewLine ;
            mttNotifyDomainCompletion(model) ;
        end
        
        propagating = propagating & (~model.domain_completion.is_done) ;
    end
    
    model = mttDeleteField(model,'domain_completion') ;
    
    
function model = overwrite_implicit_domains(model)
    mttWriteNewLine ;
	mttNotify('...overwriting implicit domain definitions') ;
    mttWriteNewLine ;
    
    model = mttOverwriteImplicitDomains(model) ;
    
    
function model = mttOverwriteImplicitDomains(root,model,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        model = root ;
        env = root.env ;
    end
        
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~isempty(object.abg)
            object = mttOverwriteImplicitDomains(model,object,env) ;
        end
        
        if ~isempty(object.cr)
            interface_ports = mttGetFieldNames(object.cr.interface,'port') ;
            for j = 1:length(interface_ports)
                port_name = interface_ports{j} ;
                port = getfield(object.cr.interface,'port',port_name) ;
                
                if isempty(port.domain)
                    if isempty(port.in)
                        bond_number = port.out ;
                    else
                        bond_number = port.in ;
                    end
                    
                    actual_domain = model.bond(bond_number).domain ;
                    actual_domain_item = model.bond(bond_number).domain_item ;
                    
                    port.domain = actual_domain ;
                    port.domain_item = actual_domain_item ;
	                object.cr.interface = setfield(object.cr.interface,'port',port_name,port) ;
                    
                    number_of_operators = mttGetFieldLength(object.cr,'operator') ;
                    for op_counter = 1:number_of_operators
                        operator = object.cr.operator(op_counter) ;
                        
                        matching_links = strmatch(port_name,{operator.link.name},'exact') ;
                        
                        number_of_equations = mttGetFieldLength(operator,'equation') ;
                        
                        for eq_counter = 1:number_of_equations
                            equation = operator.equation(eq_counter) ;
%                            if isempty(equation.domain)
                                
                                number_of_chunks = mttGetFieldLength(equation,'chunk') ;
                                for chunk_counter = 1:number_of_chunks
                                    chunk = equation.chunk{chunk_counter} ;
                                    
                                    if iscell(chunk)
                                        if strcmp(chunk{1},'link')
                                            link = chunk{2} ;
                                            
                                            if any(link==matching_links)
                                                covar = chunk{3} ;
                                                chunk{3} = ['generic___',covar] ;
                                            end
                                        end
	                                    equation.chunk{chunk_counter} = chunk ;
                                    end
                                end
                                operator.equation(eq_counter) = equation ;
%                            end
                        end
                        object.cr.operator(op_counter) = operator ;
                    end
                end
            end
        end
        
        model = setfield(model,'obj',object_name,object) ;
    end
    

Deleted mttroot/ntt/bin/trans/m/mttCreateElementaryEquations.m version [170ccc2756].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttCreateElementaryEquations(model,sorter_on)

model.representation = 'ese' ;

[model,ese,namelist] = specify_equations(model) ;
if sorter_on
    [sse,counter] = sort_equations(ese,model,namelist) ;
else
    sse = ese ;
    counter = 0 ;
end

model.equation = sse ;
model.sorted_equations = counter ;
model.namelist = namelist ;



function [model,ese,namelist] = specify_equations(model,branch,root_namelist)
    is_root_model = (nargin==1) ;

    if is_root_model
        mttNotify('...specifying equations') ;
    	mttWriteNewLine ;
        
        branch = mttDetachText(model.source,'/') ;
        
        name_counter = 1 ;
        namelist(name_counter).var = '0' ;
        namelist(name_counter).domain = [] ;
        namelist(name_counter).domain_item = [] ;
    else
        namelist = root_namelist ;
        name_counter = length(namelist) ;
    end
        
    mttNotify(['   ...processing ',branch]) ;
   	mttWriteNewLine ;
       
    objects = mttGetFieldNames(model,'obj') ;
    
    line = 0 ;
    
    for n = 1:length(objects)
        object_name = objects{n} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'},
            
            for j = 1:mttGetFieldLength(object,'interface')
                flow_equation = [] ;
                effort_equation = [] ;
                
                terminal = [branch,'__',object_name] ;
                
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    [specified_domain,specified_domain_item] = mttGetBondDomain(model,inbond) ;
                    
                    new_name = 0 ;
                    
                    line = line + 1 ;
                    if bond.flow
                        if strcmp(object.class,'De')
                            ese(line) = specify_ese(branch,[2*inbond],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond],branch,{name_counter+1},[]) ;
                            new_name = 1 ;
                        end
                    else
                        ese(line) = specify_ese(branch,{name_counter+1},branch,[2*inbond],[]) ;
                        new_name = 1 ;
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.flow'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                    
                	new_name = 0 ;
                
                    line = line + 1 ;
                    if bond.effort
                        ese(line) = specify_ese(branch,{name_counter+1},branch,[2*inbond-1],[]) ;
                        new_name = 1 ;
                    else
                        if strcmp(object.class,'Df')
                            ese(line) = specify_ese(branch,[2*inbond-1],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond-1],branch,{name_counter+1},[]) ;
	                        new_name = 1 ;
                        end
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.effort'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                end
                               
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    [specified_domain,specified_domain_item] = mttGetBondDomain(model,outbond) ;
                    
                    new_name = 0 ;
                    
                    if bond.flow
                        if ~strcmp(object.class,'Se')
                            line = line + 1 ;
                            ese(line) = specify_ese(branch,{name_counter+1},branch,[2*outbond],[]) ;
                            new_name = 1 ;
                        end
                    else
                        line = line + 1 ;
                        ese(line) = specify_ese(branch,[2*outbond],branch,{name_counter+1},[]) ;
                        new_name = 1 ;
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.flow'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                    
                    new_name = 0 ;
                    
                    if bond.effort
                        line = line + 1 ;
                        ese(line) = specify_ese(branch,[2*outbond-1],branch,{name_counter+1},[]) ;
                        new_name = 1 ;
                    else
                        if ~strcmp(object.class,'Sf')
                            line = line + 1 ;
                            ese(line) = specify_ese(branch,{name_counter+1},branch,[2*outbond-1],[]) ;
                            new_name = 1 ;
                        end
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.effort'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                end
            end
            
        case '0',
            
            imposed_effort = [] ;
            resultant_flow = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort,flow] = mttGetBondCausality(model,bond_number(i)) ;
                
                if effort==orientation(i)
                    imposed_effort = 2*bond_number(i)-1 ;
                end
                if flow==orientation(i)
                    resultant_flow = 2*bond_number(i) ;
                    resultant_orientation = orientation(i) ;
                end
            end
            
            for i = 1:mttGetFieldLength(object,'interface')
                effort = 2*bond_number(i)-1 ;
                if effort~=imposed_effort
                    derived_effort = effort ;
                    
                    line = line + 1 ;
                    ese(line) = specify_ese(branch,derived_effort,branch,imposed_effort,[]) ;
                end
            end
            
            flow_summation = [] ;
            for i = 1:mttGetFieldLength(object,'interface')
                flow = 2*bond_number(i) ;
                
                if flow~=resultant_flow
                    impinging_flow = flow ;
                    
                    if orientation(i)
                        if resultant_orientation
                            flow_summation = [ flow_summation, -impinging_flow ] ;
                        else
                            flow_summation = [ flow_summation, impinging_flow ] ;
                        end
                    else
                        if resultant_orientation
                            flow_summation = [ flow_summation, impinging_flow ] ;
                        else
                            flow_summation = [ flow_summation, -impinging_flow ] ;
                        end
                    end
                end
            end
            
            line = line + 1 ;
            ese(line) = specify_ese(branch,resultant_flow,branch,flow_summation,[]) ;
            
        case '1',
            
            imposed_flow = [] ;
            resultant_effort = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort,flow] = mttGetBondCausality(model,bond_number(i)) ;
                
                if flow~=orientation(i)
                    imposed_flow = 2*bond_number(i) ;
                end
                if effort~=orientation(i)
                    resultant_effort = 2*bond_number(i)-1 ;
                    resultant_orientation = orientation(i) ;
                end
            end
            
            for i = 1:mttGetFieldLength(object,'interface')
                flow = 2*bond_number(i) ;
                if flow~=imposed_flow
                    derived_flow = flow ;
                    
                    line = line + 1 ;
                    ese(line) = specify_ese(branch,derived_flow,branch,imposed_flow,[]) ;
                end
            end
            
            effort_summation = [] ;            
            for i = 1:mttGetFieldLength(object,'interface')
                effort = 2*bond_number(i)-1 ;
                
                if effort~=resultant_effort
                    impinging_effort = effort ;
                    
                    if orientation(i)
                        if resultant_orientation
                            effort_summation = [ effort_summation, -impinging_effort ] ;
                        else
                            effort_summation = [ effort_summation, impinging_effort ] ;
                        end
                    else
                        if resultant_orientation
                            effort_summation = [ effort_summation, impinging_effort ] ;
                        else
                            effort_summation = [ effort_summation, -impinging_effort ] ;
                        end
                    end
                end
            end
            
            line = line + 1 ;
            ese(line) = specify_ese(branch,resultant_effort,branch,effort_summation,[]) ;
            
        otherwise,
            
            if ~isempty(object.cr)
                interface = object.cr.interface ;
                port_names = mttGetFieldNames(interface,'port') ;
                number_of_ports = length(port_names) ;
                
                link_counter = 0 ;
                
                for i = 1:number_of_ports
                    port_name = port_names{i} ;
                    port = getfield(interface,'port',port_name) ;
                    terminal = [branch,'__',object_name,'___',port_name] ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    if ~isempty(inbond)
                        bond = model.bond(inbond) ;
                        [specified_domain,specified_domain_item] = mttGetBondDomain(model,inbond) ;
                        
                        name_counter = name_counter + 1 ;
                        if port.is_flow_state
                            namelist(name_counter).var = [terminal,'.flow_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.flow'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.flow
                            ese(line) = specify_ese(branch,[2*inbond],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                        else
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*inbond],[]) ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                        end
                        
                        name_counter = name_counter + 1 ;
                        if port.is_effort_state
                            namelist(name_counter).var = [terminal,'.effort_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.effort'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.effort
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*inbond-1],[]) ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond-1],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                        end
                    end
                    
                    if ~isempty(outbond)
                        bond = model.bond(outbond) ;
                        [specified_domain,specified_domain_item] = mttGetBondDomain(model,outbond) ;
                        
                        name_counter = name_counter + 1 ;
                        if port.is_flow_state
                            namelist(name_counter).var = [terminal,'.flow_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.flow'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.flow
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*outbond],[]) ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                        else
                            ese(line) = specify_ese(branch,[2*outbond],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                        end
                        
                        name_counter = name_counter + 1 ;
                        if port.is_effort_state
                            namelist(name_counter).var = [terminal,'.effort_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.effort'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.effort
                            ese(line) = specify_ese(branch,[2*outbond-1],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                        else
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*outbond-1],[]) ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                        end
                    end
                end
                
                
                input_mask = zeros(number_of_ports,1) ;
                output_mask = zeros(number_of_ports,1) ;
                
                number_of_links = link_counter ;
                linked = zeros(number_of_links,1) ;
                
                operators = object.cr.operator ;
                number_of_operators = length(operators) ;
                
                object.cr.used_operator = zeros(1,number_of_operators) ;
                
                op_counter = 0 ;
                
                matching = 1 ;
                while matching
                    op_counter = op_counter + 1 ;
                    operator = operators(op_counter) ;
                    
                    full_operator_name = [branch,'__',object_name,'___',operator.name] ;
                    
                    number_of_op_links = length(operator.link) ;
                    op_linked = zeros(number_of_op_links,1) ;
                    
                    for j = 1:number_of_op_links
                        k = 0 ;
                        comparing = 1 ;
                        while comparing
                            k = k + 1 ;
                            if compare_links(link(k),operator.link(j))
                                op_linked(j) = k ;
                                comparing = 0 ;
                            end
                            comparing = comparing & (k<number_of_links) ;
                        end
                    end
                    
                    
                    input_counter = 0 ;
                    output_counter = 0 ;
                    input = [] ;
                    output = [] ;
                    
                    if all(op_linked)
                        object.cr.used_operator(op_counter) = 1 ;
                        
                        interface = object.cr.interface ;
                        assigned_ports = mttGetFieldNames(operator,'assign') ;
                        for j = 1:length(assigned_ports)
                            port_name = assigned_ports{j} ;
                            next = getfield(operator.assign,port_name) ;
                            
                            actual_port = getfield(interface,'port',port_name) ;
                            if ~isempty(actual_port.assign)
                                previous = actual_port.assign ;
                                
                                for k = 1:length(next.covar)
                                    covar = next.covar{k} ;
                                    index = strmatch(covar,previous.covar,'exact') ;
                                    
                                    if ~isempty(index)
                                        mttAssert(strcmp(next.state{k},previous.state{k}),...
                                            ['Conflicting state assignments for port "',port_name,'.',covar,'" in ',here]) ;
                                    else
                                        actual_port.assign.state{index} = next.state{k} ;
                                    end
                                end
                            else
                                actual_port.assign = next ;
                            end
                            interface = setfield(interface,'port',port_name,actual_port) ;
                        end
%                        operator = mttDeleteField(operator,'assign') ;
                            
%                        object.cr.operator(op_counter) = operator ;
                        object.cr.interface = interface ;
                        model = setfield(model,'obj',object_name,object) ;
                        
                        
                        for j = 1:number_of_op_links
                            k = op_linked(j) ;
                            
                            linked(k) = 1 ;
                            link(k).is_unconstrained = operator.link(j).is_unconstrained ;
                            
                            current_link = link(k) ;
                            port_name = current_link.name ;
                            
                            port_index = strmatch(port_name,port_names,'exact') ;
                            
                            terminal = [branch,'__',object_name,'___',port_name] ;
                            
                            if current_link.is_effort
                                if current_link.is_state
                                    link_name{j} = [terminal,'.effort_state'] ;
                                else
                                    link_name{j} = [terminal,'.effort'] ;
                                end
                            end
                            if current_link.is_flow
                                if current_link.is_state
                                    link_name{j} = [terminal,'.flow_state'] ;
                                else
                                    link_name{j} = [terminal,'.flow'] ;
                                end
                            end
                            
                            matched_name_counter = strmatch(link_name{j},{namelist.var},'exact') ;
                            if current_link.is_input
                                input_mask(port_index) = 1 ;
                                
                                if current_link.is_unconstrained
                                    input_counter = input_counter + 1 ;
                                    input{input_counter} = matched_name_counter ;
                                end
                            else
                                mttAssert(~output_mask(port_index),...
                                    ['Over-determined output "',port_name,'" in operator ',full_operator_name]) ;
                                
                                output_mask(port_index) = 1 ;
                                
                                if current_link.is_unconstrained & ~current_link.is_state
                                    output_counter = output_counter + 1 ;
                                    output{output_counter} = matched_name_counter ;
                                end
                            end
                        end
                        
                        line = line + 1 ;
                        ese(line) = specify_ese(branch,output,branch,input,full_operator_name) ;
                        
                        for j = 1:number_of_op_links
                            k = op_linked(j) ;
                            current_link = link(k) ;
                            
                            matched_name_counter = strmatch(link_name{j},{namelist.var},'exact') ;
                            if ~current_link.is_input
                                if ~current_link.is_unconstrained
                                    line = line + 1 ;
                                    ese(line) = specify_ese(branch,{matched_name_counter},branch,{1},[]) ;
                                end
                            end
                        end
                    end
                    
                    
                    unused_inputs = ~all(input_mask) ;
                    unused_outputs = ~all(output_mask) ;
                    still_counting = op_counter<number_of_operators ;
                    
                    matching = (unused_inputs | unused_outputs) & (op_counter<number_of_operators) ;
                end
                
                mttAssert(all(input_mask),...
                    ['Unattached input(s) in "cr" implementation in ',here]) ;
                mttAssert(all(output_mask),...
                    ['Unattached output(s) in "cr" implementation in ',here]) ;
                mttAssert(all(linked),...
                    ['Unattached ports in "cr" implementation in ',here]) ;
            end
        end
    end
    
    for n = 1:length(objects)
        object_name = objects{n} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        
        if ~isempty(object.cr)
            operators = object.cr.operator ;
            number_of_operators = length(operators) ;
            
            object.cr = mttDeleteField(object.cr,'operator') ;
            used_counter = 0 ;
            
            for op_counter = 1:number_of_operators
                operator = operators(op_counter) ;
                if object.cr.used_operator(op_counter)
                    used_counter = used_counter + 1 ;
                    used_operator = operator ;
                    
%                    used_operator = mttDeleteField(used_operator,'is_used') ;
                    used_operator = mttDeleteField(used_operator,'assign') ;
                    object.cr.operator(used_counter) = used_operator ;
                end
            end
        end
        
        
        if ~isempty(object.abg)
            next_branch = [branch,'__',object_name] ;
            for j = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                inmap = object.interface(j).map.in ;
                outmap = object.interface(j).map.out ;
                interface_class = object.interface(j).class ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    
                    line = line + 1 ;
                    if bond.flow
                        if strcmp(interface_class,'Se')
	                        ese(line) = specify_ese(branch,[2*inbond],next_branch,{1},[]) ;
                        else
	                        ese(line) = specify_ese(branch,[2*inbond],next_branch,[2*inmap],[]) ;
                        end
                    else
                        ese(line) = specify_ese(next_branch,[2*inmap],branch,[2*inbond],[]) ;
                    end
                    
                    line = line + 1 ;
                    if bond.effort
                        ese(line) = specify_ese(next_branch,[2*inmap-1],branch,[2*inbond-1],[]) ;
                    else
                        if strcmp(interface_class,'Sf')
                            ese(line) = specify_ese(branch,[2*inbond-1],next_branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond-1],next_branch,[2*inmap-1],[]) ;
                        end
                    end
                end
                
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    
                    line = line + 1 ;
                    if bond.flow
                        if strcmp(interface_class,'De')
                            ese(line) = specify_ese(next_branch,[2*outmap],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(next_branch,[2*outmap],branch,[2*outbond],[]) ;
                        end
                    else
                        ese(line) = specify_ese(branch,[2*outbond],next_branch,[2*outmap],[]) ;
                    end
                    
                    line = line + 1 ;
                    if bond.effort
                        ese(line) = specify_ese(branch,[2*outbond-1],next_branch,[2*outmap-1],[]) ;
                    else
                        if strcmp(interface_class,'Df')
                            ese(line) = specify_ese(next_branch,[2*outmap-1],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(next_branch,[2*outmap-1],branch,[2*outbond-1],[]) ;
                        end
                    end
                end
            end

            [object,object_ese,object_namelist] = specify_equations(object,next_branch,namelist) ;
            model = setfield(model,'obj',object_name,object) ;
            
            ese = [ese, object_ese] ;
            line = length(ese) ;
            
			namelist = object_namelist ;
        end
        
        object.cr = mttDeleteField(object.cr,'used_operator') ;
        model = setfield(model,'obj',object_name,object) ;
    end
    
    
function equation = specify_ese(LHS_branch,LHS_var,RHS_branch,RHS_var,operator)
    equation.branch.LHS = LHS_branch ;
    equation.branch.RHS = RHS_branch ;
    equation.var.LHS = LHS_var ;
    equation.var.RHS = RHS_var ;
    equation.operator = operator ;
    
    
function [branchlist,branchbond] = identify_branches(model,branch)
    is_root_model = (nargin==1) ;
    
    if is_root_model
        branch = mttDetachText(model.source,'/') ;
        branchlist{1} = branch ;
        branchbond = length(model.bond) ;
        counter = 1 ;
    else
        branchlist = [] ;
        branchbond = 0 ;
        counter = 0 ;
    end

    objects = mttGetFieldNames(model,'obj') ;
    
    for n = 1:length(objects)
        object_name = objects{n} ;
        
        object = getfield(model,'obj',object_name) ;
        next_branch = [branch,'__',object_name] ;
        [next_branchlist,next_branchbond] = identify_branches(object,next_branch) ;
        
        counter = counter + 1 ;
        branchlist{counter} = next_branch ;

        if isfield(object,'bond')
            branchbond(counter) = length(object.bond) ;
        else
            branchbond(counter) = 0 ;
        end
        
        for i = 1:length(next_branchlist)
            counter = counter + 1 ;
            branchlist{counter} = next_branchlist{i} ;
            branchbond(counter) = next_branchbond(i) ;
        end
    end
    
    
function [sse,sorted_equations] = sort_equations(ese,model,namelist)
    mttWriteNewLine ;
    mttNotify('...sorting equations') ;
    mttWriteNewLine ;
    
    [branchlist,branchbond] = identify_branches(model) ;
    lastvar = cumsum(2*branchbond) ;
    offsetvar = lastvar - 2*branchbond ;
    
    number_of_equations = length(ese) ;
%    number_of_covariables = length(namelist) - 1 ;
%    number_of_interface_variables = max(lastvar) ;
    number_of_covariables = max(lastvar) ;
    number_of_interface_variables = length(namelist) - 1 ;
    
    mttNotifyEquationSummary(number_of_equations,number_of_covariables,number_of_interface_variables) ;
    
    for i = 1:length(ese)
        if isempty(ese(i).operator)
            var = ese(i).var.LHS ;
            switch class(var)
            case 'double',
                branch_index = strmatch(ese(i).branch.LHS,branchlist,'exact') ;
                info(i).LHS = abs(var) + offsetvar(branch_index) ;
            case 'cell',
                info(i).LHS = ese(i).var.LHS ;
            end
            
            var = ese(i).var.RHS ;
            switch class(var)
            case 'double',
                branch_index = strmatch(ese(i).branch.RHS,branchlist,'exact') ;
                for j = 1:length(var)
                    info(i).RHS(j) = abs(var(j)) + offsetvar(branch_index) ;
                end
            case 'cell',
                info(i).RHS = ese(i).var.RHS ;
            end
        else
            info(i).LHS = ese(i).var.LHS ;
            info(i).RHS = ese(i).var.RHS ;
        end
    end
    
    
    var_known = zeros(max(lastvar),1) ;
    name_known = zeros(length(namelist),1) ;
    name_known(1) = 1 ;
    
    log = ones(length(ese),1) ;
    map = zeros(length(ese),1) ;
    
    counter = 0 ;
    
    for i = 1:length(ese)
        if log(i) & isempty(ese(i).operator)
            left = info(i).LHS ;
            right = info(i).RHS ;
                
            if isnumeric(left) & iscell(right)
                name = namelist(right{1}).var ;
                is_object_interface = ~isempty(findstr(name,'___')) ;
                
                ok = 1 ;
                if is_object_interface
                    is_effort_state = ~isempty(findstr(name,'.effort_state')) ;
                    is_flow_state = ~isempty(findstr(name,'.flow_state')) ;
                    ok = is_effort_state | is_flow_state ;
                end
                
                if ok
                    log(i) = 0 ;
                    counter = counter + 1 ;
                    map(counter) = i ;
                    
                    var_known(left) = 1 ;
                    name_index = strmatch(name,{namelist.var},'exact') ;
                    name_known(name_index) = 1 ;
                end
            end
            
            if iscell(left) & iscell(right)
                if right{1}==1
                    log(i) = 0 ;
                    counter = counter + 1 ;
                    map(counter) = i ;
                    
                    name = namelist(left{1}).var ;
                    name_index = strmatch(name,{namelist.var},'exact') ;
                    name_known(name_index) = 1 ;
                end
            end
        end
    end
    
    previous_var_known = var_known ;
    previous_name_known = name_known ;
    
    sort_iteration = 0 ;
    
    sorting = 1 ;
    while sorting
        sort_iteration = sort_iteration + 1 ;
        
        for i = 1:length(ese)
            if log(i) & isempty(ese(i).operator)
                left = info(i).LHS ;
                right = info(i).RHS ;
                
                if isnumeric(right)
                    if all(var_known(right))
                        log(i) = 0 ;
                        counter = counter + 1 ;
                        map(counter) = i ;
                        
                        if isnumeric(left)
                            var_known(left) = 1 ;
                        else
                            name = namelist(left{1}).var ;
                            name_index = strmatch(name,{namelist.var},'exact') ;
                            name_known(name_index) = 1 ;
                        end
                    end
                else
                    name = namelist(right{1}).var ;
                    name_index = strmatch(name,{namelist.var},'exact') ;
                    if name_known(name_index)
                        is_object_interface = ~isempty(findstr(name,'___')) ;
                        
                        if is_object_interface
                            log(i) = 0 ;
                            counter = counter + 1 ;
                            map(counter) = i ;
                            
                            var_known(left) = 1 ;
                        end
                    end
                end
            end
        end
        
        for i = 1:length(ese)
            if log(i) & ~isempty(ese(i).operator)
                left = info(i).LHS ;
                right = info(i).RHS ;
                
                indices = [] ;
                for j = 1:length(right)
                    name = namelist(right{j}).var ;
                    indices(j) = strmatch(name,{namelist.var},'exact') ;
                end
                
                if all(name_known(indices))
                    log(i) = 0 ;
                    counter = counter + 1 ;
                    map(counter) = i ;
                    for j = 1:length(left)
                        name = namelist(left{j}).var ;
                        name_index = strmatch(name,{namelist.var},'exact') ;
                        name_known(name_index) = 1 ;
                    end
                end
            end
        end
        
        same_vars_known = sum(var_known)==sum(previous_var_known) ;
        same_names_known = sum(name_known)==sum(previous_name_known) ;
        
        previous_var_known = var_known ;
        previous_name_known = name_known ;
        
        sorting = ~(same_vars_known & same_names_known) ;
        
        if sorting
            mttNotify(['...iteration ',num2str(sort_iteration)]) ;
            mttWriteNewLine ;
%            is_complete = ...
%                mttNotifyEquationSort(sort_iteration,...
%	             sum(log),number_of_equations,...
%                sum(name_known),number_of_covariables,...
%                sum(var_known),number_of_interface_variables) ;
            is_complete = ...
                mttNotifyEquationSort(sort_iteration,...
	            sum(log),number_of_equations,...
                sum(var_known),number_of_covariables,...
                sum(name_known),number_of_interface_variables) ;
            
            sorting = sorting & ~is_complete ;
        end
    end

    for i = 1:length(ese)
        if log(i) & isempty(ese(i).operator)
            left = info(i).LHS ;
            right = info(i).RHS ;
                
            if iscell(left) & isnumeric(right)
                name = namelist(left{1}).var ;
                is_object_interface = ~isempty(findstr(name,'___')) ;
                    
                if ~is_object_interface
                    if var_known(right)
                        log(i) = 0 ;
                        counter = counter + 1 ;
                        map(counter) = i ;
                        
                        name_index = strmatch(name,{namelist.var},'exact') ;
                        name_known(name_index) = 1 ;
                    end
                end
            end
        end
    end
    
    sorted_equations = counter ;
    
    if sorted_equations<number_of_equations
	    mttWriteNewLine ;
        mttNotify(['...unable to sort equations completely']) ;
	    mttWriteNewLine ;
        mttNotifyEquationSortProblems(name_known,namelist) ;
    end
    
    for i = 1:length(ese)
        if log(i)
            counter = counter + 1 ;
            map(counter) = i ;
        end
    end
    
    mttAssert(counter==length(ese),'Sort algorithm has failed! Seek expert assistance!') ;
    
	for i = 1:length(ese)
    	sse(i) = ese(map(i)) ;
    end
    
    
function link = create_link(is_input,is_effort,is_flow,name,is_state)
    link.is_input    = is_input ;
    link.is_effort   = is_effort ;
    link.is_flow     = is_flow ;
    link.name        = name ;
    link.is_state    = is_state ;
    
    link.is_unconstrained = [] ;
    
    
function boolean = compare_links(actual_link,op_link)
    input_is_same  = actual_link.is_input==op_link.is_input ;
    effort_is_same = actual_link.is_effort==op_link.is_effort ;
    flow_is_same   = actual_link.is_flow==op_link.is_flow ;
    name_is_same   = strcmp(actual_link.name,op_link.name) ;
    
    boolean = input_is_same & effort_is_same & flow_is_same & name_is_same ;
    

Deleted mttroot/ntt/bin/trans/m/mttCreateEnvironment.m version [9307cb976f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313

























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttCreateEnvironment(context)
global mtt_env

mttNotify('...setting "env" definition') ;
mttWriteNewLine ;

directory_name = identify_directory_name(context) ;
source_name = identify_source_name(context,directory_name) ;
environment_filename = [source_name,'_env.txt'] ;

model = mttFetchEnvironment(environment_filename) ;
model = establish_path_names(model) ;

mttWriteNewLine ;
mttNotify('...acquiring "domain" source definitions') ;
mttWriteNewLine ;

model = establish_user_domains(model) ;

number_of_domains = mttGetFieldLength(model,'dom') ;
if number_of_domains>0
    for i = 1:number_of_domains
        model.public_domain(i).representation = model.dom(i).representation ;
        model.public_domain(i).source = model.dom(i).source ;
        
        domain = model.dom(i) ;
        item_names = mttGetFieldNames(domain,'item') ;
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            item = getfield(domain,'item',item_name) ;
            
            compound_item = mttIdentifyDomainCovariables(item,domain,model) ;
            model = setfield(model,'public_domain',{i},'item',item_name,compound_item) ;
        end
    end
    model = hide_private_domains(model) ;
end

model = mttDeleteField(model,'dom') ;


mttWriteNewLine ;
mttNotify('...acquiring "struct" source definitions') ;
mttWriteNewLine ;

model = establish_user_structs(model) ;

number_of_structs = mttGetFieldLength(model,'str') ;
if number_of_structs>0
    for i = 1:number_of_structs
        model.public_struct(i).representation = model.str(i).representation ;
        model.public_struct(i).source = model.str(i).source ;
        
        struct = model.str(i) ;
        item_names = mttGetFieldNames(struct,'item') ;
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            item = getfield(struct,'item',item_name) ;
            
            compound_item = mttIdentifyStructVariables(item,struct,model) ;
            model = setfield(model,'public_struct',{i},'item',item_name,compound_item) ;
        end
    end
    model = hide_private_structs(model) ;
end

model = mttDeleteField(model,'str') ;



function directory = identify_directory_name(context)
    mttAssert(ischar(context),'Context must be specified by name') ;
    working_directory  = pwd ;
    working_directory = strrep(working_directory,'\','/') ;
    
    [system_name,local_directory] = mttDetachText(context,'/') ;
    if isempty(system_name)
        local_directory = [] ;
    end
    
    if isempty(local_directory)
        directory = working_directory ;
    else
        directory = mttLocateDirectory(working_directory,local_directory) ;
    end
    
    
function source = identify_source_name(context,directory)
    [context_name,local_directory] = mttDetachText(context,'/') ;
    if isempty(context_name)
        context_name = context ;
        local_directory = [] ;
    end
    source = [directory,'/',context_name] ;
    
    
function model = establish_path_names(model)
	path_names = mttGetFieldNames(model,'path') ;
    
    for n = 1:length(path_names)
        path_name = path_names{n} ;
        path_spec = getfield(model,'path',path_name) ;
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        
        directory = identify_directory(working_directory,path_spec,model) ;
        
        mttAssert(~isempty(directory),...
            ['Undefined path "',path_name,'"']) ;
        
		model = setfield(model,'path',path_name,directory) ;
    end
    
    
function directory = identify_directory(working_directory,path_spec,model)
	path_names = mttGetFieldNames(model,'path') ;

    if isempty(path_spec)
		directory = [] ;
    else
        if path_spec(1)=='$'
            [path_alias,path_branch] = mttCutText(path_spec,'/') ;
            path_alias(1) = [] ;
            
            mttAssert(ismember(path_alias,path_names),...
                ['Path "',path_alias,'" not recognised']) ;
            
            path_root = getfield(model,'path',path_alias) ;
            
            if isempty(path_branch)
                directory = path_root ;
            else
                directory = [path_root,'/',path_branch] ;
            end
        else
            [local_directory,name] = mttCutText(path_spec,'/') ;
            
            directory_located = 0 ;
            if strcmp(local_directory,'.')
                if isempty(name)
                    directory = working_directory ;
                    directory_located = 1 ;
                else
                    local_directory = name ;
                end
            else
                local_directory = path_spec ;
            end
            
            if ~directory_located
                directory = mttLocateDirectory(working_directory,local_directory) ;
            end
        end
    end
    
    
function model = establish_user_domains(model)
	path_names = mttGetFieldNames(model,'path') ;
    domain_names = mttGetFieldNames(model,'domain') ;
    
    counter = 0 ; 
    
    for n = 1:length(domain_names)
        domain_name = domain_names{n} ;
        domain_spec = getfield(model,'domain',domain_name) ;
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        [domain_source,domain_item] = mttCutText(domain_spec,'::') ;
        [name,path_spec] = mttDetachText(domain_source,'/') ;
        
        if isempty(name)
            source_name = [working_directory,'/',domain_source] ;
        else
            directory = identify_directory(working_directory,path_spec,model) ;
            source_name = [directory,'/',name] ;
        end
        
        domain_filename = [source_name,'_domain.txt'] ;
        
        domain_index = [] ;
        if isfield(model,'dom')
            existing_doms = {model.dom.source} ;
            domain_index = strmatch(source_name,existing_doms,'exact') ;
        end
        
        if isempty(domain_index)
            counter = counter + 1 ;
            model.dom(counter) = mttFetchDomain(domain_filename) ;
            domain_index = counter ;
        end
        
        domain_spec.dom = domain_index ;
        domain_spec.item = domain_item ;
        model = setfield(model,'domain',domain_name,domain_spec) ;
    end
    
function model = hide_private_domains(model)
	for n = 1:mttGetFieldLength(model,'public_domain')
        dom = model.dom(n) ;
        dom_items = dom.item ;
        
        domain = model.public_domain(n) ;
        domain_items = domain.item ;
        
        item_names = mttGetFieldNames(domain,'item') ;
        
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            is_private(j) = getfield(dom_items,item_name,'is_private') ;
            
            if is_private(j)
                domain_items = mttDeleteField(domain_items,item_name) ;
                
                mttAssert(~isempty(domain_items),...
                    ['No public domains in ',dom.source]) ;
            end
        end
        
        model = setfield(model,'public_domain',{n},'item',domain_items) ;
    end
    
	user_domain_names = mttGetFieldNames(model,'domain') ;
    for i = 1:length(user_domain_names)
        user_domain_name = user_domain_names{i} ;
        user_domain = getfield(model,'domain',user_domain_name) ;
        
        dom = model.dom(user_domain.dom) ;
        if ~isempty(user_domain.item)
            is_private = getfield(dom,'item',user_domain.item,'is_private') ;
            mttAssert(~is_private,...
                ['User-defined domain "',user_domain_name,'" is declared as private']) ;
        end
    end
    
    
function model = establish_user_structs(model)
	path_names = mttGetFieldNames(model,'path') ;
    struct_names = mttGetFieldNames(model,'struct') ;
    
    counter = 0 ; 
    
    for n = 1:length(struct_names)
        struct_name = struct_names{n} ;
        struct_spec = getfield(model,'struct',struct_name) ;
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        [struct_source,struct_item] = mttCutText(struct_spec,'::') ;
        [name,path_spec] = mttDetachText(struct_source,'/') ;
        
        if isempty(name)
            source_name = [working_directory,'/',struct_source] ;
        else
            directory = identify_directory(working_directory,path_spec,model) ;
            source_name = [directory,'/',name] ;
        end
        
        struct_filename = [source_name,'_struct.txt'] ;
        
        struct_index = [] ;
        if isfield(model,'str')
            existing_strs = {model.str.source} ;
            struct_index = strmatch(source_name,existing_strs,'exact') ;
        end
        
        if isempty(struct_index)
            counter = counter + 1 ;
            model.str(counter) = mttFetchStruct(struct_filename) ;
            struct_index = counter ;
        end
        
        struct_spec.str = struct_index ;
        struct_spec.item = struct_item ;
        model = setfield(model,'struct',struct_name,struct_spec) ;
    end
    
function model = hide_private_structs(model)
	for n = 1:mttGetFieldLength(model,'public_struct')
        str = model.str(n) ;
        str_items = str.item ;
        
        struct = model.public_struct(n) ;
        struct_items = struct.item ;
        
        item_names = mttGetFieldNames(struct,'item') ;
        
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            is_private(j) = getfield(str_items,item_name,'is_private') ;
            
            if is_private(j)
                struct_items = mttDeleteField(struct_items,item_name) ;
                
                mttAssert(~isempty(struct_items),...
                    ['No public structs in ',str.source]) ;
            end
        end
        
        model = setfield(model,'public_struct',{n},'item',struct_items) ;
    end
    
	user_struct_names = mttGetFieldNames(model,'struct') ;
    for i = 1:length(user_struct_names)
        user_struct_name = user_struct_names{i} ;
        user_struct = getfield(model,'struct',user_struct_name) ;
        
        str = model.str(user_struct.str) ;
        if ~isempty(user_struct.item)
            is_private = getfield(str,'item',user_struct.item,'is_private') ;
            mttAssert(~is_private,...
                ['User-defined struct "',user_struct_name,'" is declared as private']) ;
        end
    end
        

Deleted mttroot/ntt/bin/trans/m/mttCreateSystemMdl.m version [1ef68305e6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170










































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttCreateSystemMdl(model)

model_name = mttDetachText(model.source,'/') ;
icd = mttCreateSystemMdl_ICD(model) ;

NumInputs = length(icd.input_namelist) ;
NumOutputs = length(icd.output_namelist) ;
MaxInterfaces = max(NumInputs,NumOutputs) ;

new_system(model_name) ;
open_system(model_name) ;
set_param(model_name,'Location',[50 100 850 250+20*MaxInterfaces]) ;

left = 100 ;
top = 25 ;
width = 600 ;
height = 25*(5+MaxInterfaces)  ;

position_vector = [left,top,left+width,top+height] ;

ModelHndl = add_block(...
    'simulink3/Subsystems/Subsystem',...
    [model_name,'/Model'],...
    'Position',position_vector,...
    'BackgroundColor','yellow',...
    'FontName','Helvetica',...
    'FontSize',num2str(16)) ;


system = [model_name,'/Model'] ;

set_param(system,'Location',[200 250 1050 285+30*MaxInterfaces]) ;

Line = get_param(system,'Lines') ;
for i = 1:length(Line)
    SrcBlock = get_param(Line(i).SrcBlock,'Name') ;
    DstBlock = get_param(Line(i).DstBlock,'Name') ;
    SrcPort = num2str(Line(i).SrcPort) ;
    DstPort = num2str(Line(i).DstPort) ;
    
    delete_line(system,[SrcBlock,'/',SrcPort],[DstBlock,'/',DstPort]) ;
end

Block = get_param(system,'Blocks') ;
for i = 1:length(Block)
    delete_block([system,'/',Block{i}]) ;
end


left = 125 ;
centre_left = 250 ;
centre = 350 ;
centre_right = 580 ;
right = 670 ;

top = 20 ;
down = 30 ;

port_width = 40 ;
port_height = 15 ;
port_spacing = down ;

mux_width = 5 ;
mux_height = NumInputs*port_spacing ;

demux_width = 5 ;
demux_height = NumOutputs*port_spacing ;

sfun_width = 150 ;
sfun_height = 30 ;

left_vertical_offset = (NumInputs*port_spacing - sfun_height)/2 ;
right_vertical_offset = (NumOutputs*port_spacing - sfun_height)/2 ;

vertical_offset = max(left_vertical_offset,right_vertical_offset) ;
datum = top + vertical_offset ;



top = datum - left_vertical_offset ;

for i = 1:NumInputs
    position_vector = [...
            left,...
            top + (i-1)*port_spacing,...
            left + port_width,...
            top + (i-1)*port_spacing + port_height] ;
        
    InHndl(i) = add_block(...
        'simulink3/Sources/In1',...
        [system,'/',icd.input_namelist{i}],...
        'Position',position_vector) ;
end

position_vector = [...
        centre_left,...
        top-port_height/3,...
        centre_left+mux_width,...
        top+mux_height-port_height/3] ;

MuxHndl = add_block(...
    'simulink3/Signals & Systems/Mux',...
    [system,'/InputMapping'],...
    'Position',position_vector,...
    'Inputs',num2str(NumInputs)) ;

position_vector = [...
        centre,...
        top+left_vertical_offset-sfun_height/2,...
        centre+sfun_width,...
        top+left_vertical_offset+sfun_height] ;

SfunHndl = add_block(...
    'simulink3/Functions & Tables/S-Function',...
    [system,'/sfun'],...
    'Position',position_vector,...
    'FunctionName',[model_name,'_sfun'],...
    'BackgroundColor','yellow',...
    'FontName','Helvetica',...
    'FontSize',num2str(16)) ;



top = datum - right_vertical_offset ;

position_vector = [...
        centre_right,...
        top-port_height/3,...
        centre_right+demux_width,...
        top+demux_height-port_height/3] ;

DemuxHndl = add_block(...
    'simulink3/Signals & Systems/Demux',...
    [system,'/OutputMapping'],...
    'Position',position_vector,...
    'Outputs',num2str(NumOutputs)) ;

for i = 1:NumOutputs
    position_vector = [...
            right,...
            top + (i-1)*port_spacing,...
            right + port_width,...
            top + (i-1)*port_spacing + port_height] ;
        
    OutHndl(i) = add_block(...
        'simulink3/Sinks/Out1',...
        [system,'/',icd.output_namelist{i}],...
        'Position',position_vector) ;
end



for i = 1:NumInputs
    port = num2str(i) ;
    InLineHndl(i) = add_line(system,...
        [icd.input_namelist{i},'/1'],['InputMapping/',port]) ;
end

SfunInLineHndl = add_line(system,'InputMapping/1','sfun/1') ;
set_param(SfunInLineHndl,'Name','_Input') ;

SfunOutLineHndl = add_line(system,'sfun/1','OutputMapping/1') ;
set_param(SfunOutLineHndl,'Name','_Output') ;

for i = 1:NumOutputs
    port = num2str(i) ;
    OutLineHndl(i) = add_line(system,...
        ['OutputMapping/',port],[icd.output_namelist{i},'/1']) ;
end

Deleted mttroot/ntt/bin/trans/m/mttCreateSystemMdl_ICD.m version [ca430de00e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274


















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function icd = mttCreateSystemMdl_ICD(model)

sympar = map_system_sympars(model) ;
input  = map_system_inputs(model) ;
invar  = map_system_invars(model) ;
outvar = map_system_outvars(model) ;

icd.output_namelist = outvar ;
icd.input_namelist = invar ;
if ~isempty(input)
    icd.input_namelist = [icd.input_namelist,input] ;
end
if ~isempty(sympar)
    icd.input_namelist = [icd.input_namelist,sympar] ;
end

icd.output_namelist = sort(icd.output_namelist) ;
icd.input_namelist = sort(icd.input_namelist) ;



function map = map_system_sympars(model)
	mttNotify('...mapping system inputs (symbolic parameters)') ;
    mttWriteNewLine ;
    
    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default_value = model.sympar_default{i} ;
        
        if isempty(default_value)
            line = line + 1 ;
            map{line} = [model_name,'___',variable_name] ;
        end
    end
    
    
function map = map_system_inputs(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input variables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        
        line = line + 1 ;
        map{line} = [current_branch,'___',variable_name] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_inputs(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_map = map_system_inputs(object.cr,root,next_branch) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_invars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_invars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_outvars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system outputs (output covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if inbond.effort
                    covar = covariables.effort ;
                elseif ~inbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if ~outbond.effort
                    if ~strcmp(object.class,'Sf')
                        covar = covariables.effort ;
                    end
                elseif outbond.flow
                    if ~strcmp(object.class,'Se')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_outvars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    

Deleted mttroot/ntt/bin/trans/m/mttCreateUnifiedModel.m version [27142f9b00].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182






















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttCreateUnifiedModel(model,bondgraph,specification)

	model.source = mttCutText(specification.specification,'_abg.txt') ;
    model.bondgraph = mttCutText(bondgraph.bondgraph,'_abg.fig') ;
    
    model.obj = bondgraph.obj ;
    model.bond = bondgraph.bond ;
	
    object_names = mttGetFieldNames(model,'obj') ;
    specified_object_names = mttGetFieldNames(specification,'obj') ;
    
    for n = 1:length(object_names)
        object_name = object_names{n} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~mttIsPassiveClass(object.class)
            mttAssert(ismember(object_name,specified_object_names),...
                ['Object name "',object_name,'" does not appear in specification']) ;
        end
    end
    
    for n = 1:length(specified_object_names)
        specified_object_name = specified_object_names{n} ;
        mttAssert(ismember(specified_object_name,object_names),...
            ['Specified object name "',specified_object_name,...
                '" does not appear in bond graph']) ;
        
        specified_object = getfield(specification,'obj',specified_object_name) ;
        object = getfield(model,'obj',specified_object_name) ;

        if strcmp(specified_object.name.class,object.class)
            mttAssert(~mttIsFoundationClass(object.class),...
                'Cannot redefine MTT foundation class') ;
            is_abg = 1 ;
        else
            mttAssert(~mttIsPassiveClass(object.class),...
                'Cannot modify MTT junctions or ports') ;
            is_abg = 0 ;
        end

        object.is_abg = is_abg ;        
        object.name = specified_object.name ;
        object.parameter = specified_object.parameter ;
        
        model = setfield(model,'obj',specified_object_name,object) ;
    end
    
    model.sympar = specification.sympar ;
    model.numpar = specification.numpar ;
    model.input = specification.input ;

    model.sympar_default = specification.sympar_default ;
    model.numpar_default = specification.numpar_default ;
    model.input_default = specification.input_default ;

    for n = 1:length(object_names)
        object_name = object_names{n} ;
        object = getfield(model,'obj',object_name) ;
        
        if mttIsPortClass(object.class)
            mttAssert(mttGetFieldLength(object,'interface')==1,...
                ['Port components must have one and only one interface']) ;
            
            switch object.class
            case {'Se','Sf'},
                mttAssert(~isempty(object.interface.out),...
                    'Each source port must have an outward bond') ;
            case {'De','Df'},
                mttAssert(~isempty(object.interface.in),...
                    'Each detector port must have an inward bond') ;
            end
        end
        
        if ~ismember(object_name,specified_object_names)
            object.name.item = [] ;
            object.name.class = object.class ;
            object.name.path = [] ;
            object.parameter = [] ;
            object.is_abg = 1 ;
        end
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        local_directory = object.name.path ;
        directory = mttLocateDirectory(working_directory,local_directory) ;
        
        source = [directory,'/',object.name.class] ;
		
        current_leaf = model.leaf ;
        
		if object.is_abg
            if mttIsPassiveClass(object.name.class)
                object.abg = [] ;
            else
                current_branch = model.branch ;
                mttAssert(~ismember(source,current_branch),...
                    ['Recursive definition of "',source,'"']) ;

                if isempty(model.abgs)
                    existing_abg = [] ;
                else
                    existing_abg = strmatch(source,model.abgs,'exact') ;
                end
                
                if isempty(existing_abg) 
                    if isempty(current_branch)
                        next_branch = {source} ;
                        next_leaf = object_name ;
                    else
                        next_branch = [current_branch,{source}] ;
                        next_leaf = [current_leaf,'/',object_name] ;
                    end
                    model.branch = next_branch ;
                    model.leaf = next_leaf ;
                    
                    class_model = mttCreateAcausalBondgraph(source,model) ;
                    
                    model.leaf = current_leaf ;
                    model.branch = current_branch ;
                    
                    next_abg = 1 + mttGetFieldLength(model,'abg') ;
                    for i = 1:mttGetFieldLength(class_model,'abg')
                        model.abg(next_abg) = class_model.abg(i) ;
                        model.abgs = class_model.abgs ;
                        next_abg = next_abg + 1 ;
                    end
                    class_model = mttDeleteField(class_model,'abg') ;
                    
                    model.crs = class_model.crs ;
                    class_model = mttDeleteField(class_model,'crs') ;
                    
                    model.cr_usage = class_model.cr_usage ;
                    class_model = mttDeleteField(class_model,'cr_usage') ;
                    
                    model.abg(next_abg) = class_model ;
                    model = mttAppend(model,'abgs',{source}) ;
                    
                    index = length(model.abgs) ;
                    mttNotify(['   ...made "#',num2str(index),':',object.name.class,'" definition']) ;
                    mttWriteNewLine ;
                end
				object.abg = strmatch(source,model.abgs,'exact') ;
            end
            object.cr = [] ;
            object.cr_item = [] ;
        else
            if isempty(model.crs)
                existing_cr = [] ;
            else
                existing_cr = strmatch(source,model.crs,'exact') ;
            end
            
            if isempty(current_leaf)
                cr_user = object_name ;
            else
                cr_user = [current_leaf,'/',object_name] ;
            end
            
            if isempty(existing_cr)
                model = mttAppend(model,'crs',{source}) ;
                
                N = length(model.crs) ;
                model.cr_usage(N).obj{1} = cr_user ;
            else
                N = 1+length(model.cr_usage(existing_cr).obj) ;
                model.cr_usage(existing_cr).obj{N} = cr_user ;
            end
            
            object.abg = [] ;
            object.cr = strmatch(source,model.crs,'exact') ;

            if isempty(object.name.item)
                object.cr_item = mttDetachText(model.crs{object.cr},'/') ;
            else
                object.cr_item = object.name.item ;
            end
        end
        
        object = mttDeleteField(object,'name') ;
        object = mttDeleteField(object,'is_abg') ;
        
        model = setfield(model,'obj',object_name,object) ;
    end

Deleted mttroot/ntt/bin/trans/m/mttEmbedAcausalBondgraph.m version [a4a8eda9a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttEmbedAcausalBondgraph(model,component,system)
    source = model.abg(component) ;
    
    if nargin==2
        is_root_model = 1 ;
        target = model ;
    else
        is_root_model = 0 ;
        target = model.abg(system) ;
    end
    
    source_objects = mttGetFieldNames(source,'obj') ;
    target_objects = mttGetFieldNames(target,'obj') ;
    
    for n = 1:length(target_objects)
        target_object_name = target_objects{n} ;
        target_object = getfield(target,'obj',target_object_name) ;
        
        here = [mttDetachText(target.source,'/'),'/',target_object_name] ;
    
        is_abg_instance = 0 ;
        if ~isempty(target_object.abg)
            is_abg_instance = target_object.abg==component ;
        end
        
        if is_abg_instance
            target_object.sympar = source.sympar ;
            target_object.numpar = source.numpar ;
            target_object.input = source.input ;
            
            target_object.sympar_default = source.sympar_default ;
            target_object.numpar_default = source.numpar_default ;
            target_object.input_default = source.input_default ;
            
            declarations = length(target_object.sympar) ;
            values = length(target_object.parameter) ;
            
            mttAssert(declarations==values,['Mismatched parameters in object ',here]) ;
            
            
            number_of_target_ports = mttGetFieldLength(target_object,'interface') ;

            found_target_port = [] ;            
            target_ports_found = [] ;
            
            for i = 1:number_of_target_ports
                
                target_port_name = target_object.interface(i).name ;
                target_inbond = target_object.interface(i).in ;
                target_outbond = target_object.interface(i).out ;
                
                is_inline = (~isempty(target_inbond) & ~isempty(target_outbond)) ;
                
                next = 0 ;
                found_target_port(i) = 0 ;
                
                matching = 1 ;
                while matching
                    next = next + 1 ;
                    source_object_name = source_objects{next} ;
                    source_object = getfield(source,'obj',source_object_name) ;
                    
                    if ismember(source_object.class,{'SS','Se','Sf','De','Df'})
                        source_port_name = source_object_name ;
                        
                        if is_inline
                            source_interface = getfield(source,'obj',source_port_name,'interface') ;
                            
                            inport_found = 0 ;
                            if ~isempty(source_interface.in)
                                inport_found = strcmp(source_port_name,[target_port_name,'_in']) ;
                            end
                            
                            outport_found = 0 ;
                            if ~isempty(source_interface.out)
                                outport_found = strcmp(source_port_name,[target_port_name,'_out']) ;
                            end
                            
                            found_target_port(i) = inport_found | outport_found ;
                        else
                            found_target_port(i) = strcmp(source_port_name,target_port_name) ;
                        end
                    end
                    
                    if found_target_port(i)
                        if isempty(target_ports_found)
                            target_ports_found = {target_port_name} ;
                        else
                            target_ports_found = [target_ports_found, {target_port_name}] ;
                        end
                        matching = 0 ;
                    else
                        matching = (next<length(source_objects)) ;
                    end
                end
                
                mttAssert(found_target_port(i),...
                    ['Unmatched port "',target_object_name,'[',target_port_name,']"']) ;
                
                source_object = getfield(source,'obj',source_port_name) ;
                source_inbond = source_object.interface.in ;
                source_outbond = source_object.interface.out ;
                source_class = source_object.class ;
                source_domain = source_object.domain ;
                source_domain_item = source_object.domain_item ;
                
                is_inward_compatible = ~xor(isempty(target_inbond),isempty(source_outbond)) ;
                is_outward_compatible = ~xor(isempty(target_outbond),isempty(source_inbond)) ;
                is_compatible = is_inward_compatible & is_outward_compatible ;
                
                mttAssert(is_compatible,...
                    ['Incompatible bond connections at port "',...
                        target_object_name,'[',target_port_name,']"']) ;
                
                target_object = setfield(target_object,'interface',{i},'map','in',source_outbond) ;
                target_object = setfield(target_object,'interface',{i},'map','out',source_inbond) ;
                target_object = setfield(target_object,'interface',{i},'class',source_class) ;
                target_object = setfield(target_object,'interface',{i},'domain',source_domain) ;
                target_object = setfield(target_object,'interface',{i},'domain_item',source_domain_item) ;
            end
            
            number_of_target_ports_found = sum(found_target_port) ;
            mttAssert(number_of_target_ports_found==number_of_target_ports,...
                ['Mismatched ports in "',target_object_name,'"']) ;
            
            for i = 1:length(source_objects)
                source_object_name = source_objects{i} ;
                if ~ismember(source_object_name,target_ports_found)
                    source_object = getfield(source,'obj',source_object_name) ;
                    source_object = mttDeleteField(source_object,'cr_item') ;
                    
                    target_object = setfield(target_object,'obj',source_object_name,source_object) ;
                end
            end
            
            source_bond_list = getfield(source,'bond') ;
            target_object = setfield(target_object,'bond',source_bond_list) ;
            
            target = setfield(target,'obj',target_object_name,target_object) ;
        end
    end
    
    if is_root_model
        model = target ;
    else
        if ~isempty(target.invokes)
	        invoked_abgs = target.invokes ;
            other_abgs = target.invokes(invoked_abgs~=component) ;
            
            if isempty(other_abgs)
                target.invokes = [] ;
            else
                target.invokes = other_abgs ;
            end
        end
        model.abg(system) = target ;
    end
    
    

Deleted mttroot/ntt/bin/trans/m/mttEmbedInterfaceDefinition.m version [b375cb1133].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttEmbedInterfaceDefinition(model,object_name,root)
	if nargin==2
    	root = model ;
    end
	
    here = [mttDetachText(model.source,'/'),'/',object_name] ;
    
	object = getfield(model,'obj',object_name) ;
    cr = root.cr(object.cr) ;
    cr_item_name = object.cr_item ;
    
    cr_item_names = mttGetFieldNames(cr,'item') ;
    mttAssert(ismember(cr_item_name,cr_item_names),...
        ['CR "',cr_item_name,'" not found']) ;
    
    cr_item = getfield(cr,'item',cr_item_name) ;
    
    cr_portnames = mttGetFieldNames(cr_item.interface,'port') ;
    
    for i = 1:mttGetFieldLength(object,'interface')
        interface_name = object.interface(i).name ;
        
        mttAssert(ismember(interface_name,cr_portnames),...
            ['Unrecognised interface "',interface_name,'" in object ',here]) ;
        
            interface = getfield(cr_item,'interface','port',interface_name) ;
            interface.in = object.interface(i).in ;
            interface.out = object.interface(i).out ;
            
            has_inbond = ~isempty(object.interface(i).in) ;
            has_outbond = ~isempty(object.interface(i).out) ;

            mttAssert(xor(has_inbond,has_outbond),...
                ['Mismatched interface "',interface_name,'" in object ',here]) ;
            
            cr_item = setfield(cr_item,'interface','port',interface_name,interface) ;
    end
    
    for i = 1:length(cr_portnames)
        port_name = cr_portnames{i} ;
        cr_item_port = getfield(cr_item,'interface','port',port_name) ;
        mttAssert(isfield(cr_item_port,'in')|isfield(cr_item_port,'out'),...
            ['Unmatched port ',here,':',port_name]) ;
    end
    
    object.sympar = cr_item.sympar ;
    object.sympar_default = cr_item.sympar_default ;
    
    cr_item = mttDeleteField(cr_item,'parameter') ;
    object.cr = cr_item ;
    
    declarations = length(object.sympar) ;
    values = length(object.parameter) ;
    
    mttAssert(declarations==values,...
        ['Mismatched parameters in object ',here]) ;
    
    object = mttDeleteField(object,'cr_item') ;
    model = setfield(model,'obj',object_name,object) ;

    

Deleted mttroot/ntt/bin/trans/m/mttFetchApps.m version [637cce0534].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttFetchApps(filename)

if ~mttFileExists(filename)
    model = [] ;
    return ;
end

model.representation = 'apps' ;

mttNotify(['...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_apps.txt') ;
model_name = mttDetachText(model.source,'/') ;

content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

apps_declared = 0 ;
next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'apps',
        mttAssert(~apps_declared,...
            '"apps" declaration must be unique') ;
        apps_declared = 1 ;
        
        apps_name = line ;
        mttAssert(strcmp(apps_name,model_name),...
            ['Wrong name:[',apps_name,'] Expecting:[',model_name,']']) ;
        
        [apps,next] = fetch_apps(statements,next) ;
        model = mttAppendFields(model,apps) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end




function [apps,next] = fetch_apps(statements,next)
    apps = [] ;
    unit_name = 'apps' ;
    
    number_of_statements = length(statements) ;
    
    open = 0 ;
    counter = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'app',
            mttAssert(open,...
                ['"app" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            app_name = line ;
            
            counter = counter + 1 ;
            apps.app{counter} = app_name ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    apps = mttSetFieldDefault(apps,'app',[]) ;
    

Deleted mttroot/ntt/bin/trans/m/mttFetchBondgraph.m version [521f373616].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttFetchBondgraph(filename)

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.bondgraph = filename ;
content = mttReadFile(filename) ;

L = length(content) ;    
N = 1 ;

processing = (N<=L) ;
while processing
    jump = 1 ;
    line = mttClipText(content{N}) ;
    
    if ~isempty(line)
        no_string_terminator = isempty(findstr('\001',line)) ;
        
        if no_string_terminator
            if mttIsNumericText(line)
                numbers = round(str2num(line)) ;    	% only interested in integer values
                
                if numbers(1)==2						% ... line definition
                    forward_arrow = numbers(14)~=0 ;
                    reverse_arrow = numbers(15)~=0 ;
                    arrow = (forward_arrow | reverse_arrow) ;
                    
                    depth = numbers(7) ;
                    is_visible = rem(depth,10)==0 ;
                    
                    if is_visible
                        mttAssert(~arrow,...
                            ['Line ',num2str(N),': Arrows are not recognised in bond graphs']) ;
                        
                        number_of_points = numbers(16) ;

                        coordinate_string = [] ;
                        M = 0 ;
                        
                        matching = 1 ;
                        while matching
                            M = M + 1 ;
                            if isempty(coordinate_string)
                                coordinate_string = content{N+M} ;
                            else
                                coordinate_string = [coordinate_string,' ',content{N+M}] ;
                            end
                            
                            mttAssert(mttIsNumericText(coordinate_string),...
                                ['Line ',num2str(N+M),': Coordinates not recognised']) ;
                            
                            coordinates = str2num(coordinate_string) ;
                            
                            matching = length(coordinates)<2*number_of_points ;
                        end
                        
                        mttAssert(length(coordinates)==2*number_of_points,...
                            ['Line ',num2str(N+1),': Wrong number of coordinates']) ;
                        
                        jump = jump + M ; 
                        
                        if number_of_points==2
                            model = create_line(model,coordinates) ;
                        elseif number_of_points>2
                            model = create_bond(model,coordinates) ;
                        end
                    else
                        jump = jump + forward_arrow + reverse_arrow ;
                    end
                end
            end
        else
            [last_word,first_part] = mttDetachText(line,' ') ;
            
            if mttIsNumericText(first_part)
                numbers = round(str2num(first_part)) ;    	% only interested in integer values
                if numbers(1)==4							% ... text definition
                    depth = numbers(4) ;
                    is_visible = rem(depth,10)==0 ;
                    
                    if is_visible
                        coordinates = numbers(12:13) ;
                        text = mttCompressText(mttCutText(last_word,'\001')) ;
                        
                        identifier = mttCutText(text,'[') ;
                        qualifier = mttExtractText(text,'[',']') ;
                        
                        name.label = [] ;
                        name.domain = [] ;
                        name.domain_item = [] ;
                        name.class = [] ;
                        name.object = [] ;
                        
                        if isempty(identifier)
                            name.label = qualifier ;
                            model = create_label(model,name,coordinates) ;
                        else
                            [name.domain,name.domain_item] = mttCutText(qualifier,'::') ;
                            [name.class,name.object] = mttCutText(identifier,':') ;
                            model = create_object(model,name,coordinates) ;
                        end
                    end
                end
            end
        end
    end
    
    N = N + jump ;
	processing = (N<=L) ;
end

model = incorporate_anonymous_objects(model) ;
model = identify_causal_assignments(model) ;
model = identify_object_binding(model) ;
model = identify_object_interfaces(model) ;
model = associate_external_domains(model) ;
model = tidy_up(model) ;



function model = create_line(model,coordinates)
    next = 1 + mttGetFieldLength(model,'line') ;
    model.line(next).xy1 = coordinates(1:2) ;
    model.line(next).xy2 = coordinates(3:4) ;
    model.line(next).mid = (coordinates(1:2)+coordinates(3:4))/2 ;
            
function model = create_bond(model,coordinates)
	next = 1 + mttGetFieldLength(model,'bond') ;
	
    N = length(coordinates) ;
    
    q1 = coordinates(N-1:N) ;	p1 = coordinates(1:2) ;		
    p2 = coordinates(3:4) ;		q2 = coordinates(N-3:N-2) ;
    p3 = coordinates(5:6) ;		q3 = coordinates(N-5:N-4) ;
    ps = norm(p2-p1) ;		    qs = norm(q2-q1) ;
    
    orientation = sign(ps-qs) ;
    
    switch orientation
    case 1,		% harpoon points forward
        xy1 = p1 ; xy2 = q2 ; v1 = p2-p1 ; v2 = q2-q3 ; harpoon = q1-q2 ;
    case -1,	% harpoon points backward
        xy1 = p2 ; xy2 = q1 ; v1 = q2-q1 ; v2 = p2-p3 ; harpoon = p1-p2 ;
    end
    
    harpoon_side = sign_cross_product(v2,harpoon) ;
    
    mttAssert(~(orientation==0 | harpoon_side==0),...
        ['Ambiguous bond orientation between[',num2str(xy1),'] and [',num2str(xy2),']']) ;
    
    model.bond(next).xy1 = xy1 ;
    model.bond(next).xy2 = xy2 ;
    model.bond(next).v1  = v1 ;
    model.bond(next).v2  = v2 ;
    model.bond(next).harpoon = harpoon ;
    model.bond(next).harpoon_side = harpoon_side ;
    
    model.bond(next).from.obj = [] ;
    model.bond(next).from.interface = [] ;
    model.bond(next).to.obj = [] ;
    model.bond(next).to.interface = [] ;
    model.bond(next).flow = [] ;
    model.bond(next).effort = [] ;
    model.bond(next).unicausal = [] ;
    model.bond(next).domain = [] ;
    model.bond(next).domain_item = [] ;
    
function model = create_label(model,name,coordinates)
	inner_name = mttExtractText(name.label,'<','>') ;
    if isempty(inner_name)
        label_name = name.label ;
        is_inline = 0 ;
    else
        label_name = inner_name ;
        is_inline = 1 ;
    end
    mttValidateName(label_name) ;

    next = 1 + mttGetFieldLength(model,'label') ;
    model.label(next).name = label_name ;
    model.label(next).is_inline = is_inline ;
    model.label(next).xy = coordinates ;

function model = create_object(model,name,coordinates)
global mtt_environment
    
    domain_names = mttGetFieldNames(mtt_environment,'domain') ;
    
    is_anonymous = 0 ;
    if isempty(name.object)
        switch name.class
        case {'0','1'},
            is_anonymous = 1 ;
        case 'SS',
            mttAssert(~isempty(name.object),...
                'Anonymous "SS" object') ;
        otherwise,
            name.object = name.class ;
        end
    end
    
    if is_anonymous
        next = 1 + mttGetFieldLength(model,'anonymous') ;
        model.anonymous(next).class = name.class ;
        model.anonymous(next).xy = coordinates ;
    else
        object_names = mttGetFieldNames(model,'obj') ;
        if ~isempty(object_names)
            mttAssert(~ismember(name.object,object_names),...
                ['Repeated object: "',name.object,'"']) ;
        end
        
        switch name.class
        case {'0','1'},
            mttValidateName(name.object) ;
            mttAssert(~ismember(name.object,{'in','out'}),...
                'Junctions cannot use reserved port names') ;
            
        case {'SS','Se','Sf','De','Df'},
            mttValidateName(name.object) ;
            
            if isempty(name.domain) | isempty(mtt_environment)
                model = setfield(model,'obj',name.object,'domain',[]) ;
                model = setfield(model,'obj',name.object,'domain_item',[]) ;
            else
                mttAssert(ismember(name.domain,domain_names),...
                    ['Unrecognised domain "',name.domain,'"']) ;
                dom = getfield(mtt_environment,'domain',name.domain,'dom') ;
                item = getfield(mtt_environment,'domain',name.domain,'item') ;
                
                if isempty(item)
                    public_domain = getfield(mtt_environment,'public_domain',{dom}) ;
                    item_names = mttGetFieldNames(public_domain,'item') ;
                    
                    mttAssert(ismember(name.domain_item,item_names),...
                        ['Item "',name.domain_item,'" not found in public domain "',name.domain,'"']) ;
                    item_name = name.domain_item ;
                else
                    mttAssert(isempty(name.domain_item),...
                        ['Item unspecified in public domain "',name.domain,'"']) ;
                    item_name = item ;
                end
                
                model = setfield(model,'obj',name.object,'domain',dom) ;
                model = setfield(model,'obj',name.object,'domain_item',item_name) ;
            end
                
        otherwise,
            mttValidateName(name.class) ;
            mttValidateName(name.object) ;
            
            mttAssert(~ismember(name.object,{'in','out'}),...
                'Objects cannot use reserved port names') ;
        end
        model = setfield(model,'obj',name.object,'class',name.class) ;
        model = setfield(model,'obj',name.object,'xy',coordinates) ;
    end

function model = incorporate_anonymous_objects(model)
    number_of_objects = mttGetFieldLength(model,'anonymous') ;

    last = length(num2str(number_of_objects)) ;
    for i = 1:last
        object_number(i) = '0' ;
    end
    
    for i = 1:number_of_objects
        anonymous_object = getfield(model,'anonymous',{i}) ;
        
        current_number = num2str(i) ;
        width = length(current_number) ;
        first = last-width+1 ;
        object_number(first:last) = current_number ;
        
        object_name = ['mtt_obj',object_number] ;
        model = setfield(model,'obj',object_name,model.anonymous(i)) ;
    end

function r = sign_cross_product(v1,v2)
    r = sign(v1(1)*v2(2) - v1(2)*v2(1)) ;
    
function model = identify_causal_assignments(model)
	L = mttGetFieldLength(model,'line') ;
    
    if L>0
        N = mttGetFieldLength(model,'bond') ;
        
        for j = 1:L 
            for i = 1:N
                s(i,j) = norm(model.line(j).mid - model.bond(i).xy1) ;
                f(i,j) = norm(model.line(j).mid - model.bond(i).xy2) ;
            end
        end
        
        [min_range_start,nearest_bond_start] = min(s) ;
        [min_range_finish,nearest_bond_finish] = min(f) ;
        
        equidistant = min_range_start==min_range_finish ;
        at_harpoon = min_range_start>min_range_finish ;
        
        for j = 1:L
            fulcrum = num2str(model.line(j).mid) ;
            
            mttAssert(~equidistant(j),...
                ['Ambiguous causal line at [',num2str(model.line(j).mid),']']) ;
            
            if at_harpoon(j)
                index = nearest_bond_finish(j) ;
                bond = model.bond(index) ;
                terminal = bond.xy2 ;
                terminal_vector = bond.v2 ;
            else
                index = nearest_bond_start(j) ;
                bond = model.bond(index) ;
                terminal = bond.xy1 ;
                terminal_vector = bond.v1 ;
            end
            
            to_lhs = norm(model.line(j).xy1 - terminal) ;
            to_mid = norm(model.line(j).mid - terminal) ;
            to_rhs = norm(model.line(j).xy2 - terminal) ;
            
            mttAssert(to_mid<norm(bond.harpoon),...
                ['Cannot assign causality at [',num2str(fulcrum),']']) ;
            
            causality_ok = 0 ;
            
            is_unicausal = to_mid<min(to_lhs,to_rhs) ;
            if is_unicausal
                [bond.flow,causality_ok] = mttAssign(bond.flow,at_harpoon(j)) ;
                [bond.effort,causality_ok] = mttAssign(bond.effort,at_harpoon(j)) ;
            else
                causal_vector = (right-left) * sign(to_mid>to_left) ;
                causal_assignment = sign_cross_product(terminal_vector,causal_vector) ;
                mttAssert(causal_assignment~=0,...
                    ['Cannot determine causality near [',num2str(fulcrum),']']) ;
                
                if causal_assignment==bond.harpoon_side
                    [bond.flow,causality_ok] = mttAssign(bond.flow,at_harpoon(j)) ;
                else
                    [bond.effort,causality_ok] = mttAssign(bond.effort,at_harpoon(j)) ;
                end
            end
            mttAssert(causality_ok,...            
                ['Ambiguous causal assignment near [',num2str(fulcrum),']']) ;
            
            bond.unicausal = mttCompare(bond.flow,bond.effort) ;
            
            model.bond(index) = bond ;
        end
    end
    
    
function model = identify_object_binding(model)
	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
	number_of_bonds = mttGetFieldLength(model,'bond') ;
    
    for j = 1:number_of_bonds
        bond = model.bond(j) ;
        for i = 1:number_of_objects
            object = getfield(model,'obj',object_names{i}) ;
        	origin_proximity(i) = norm(object.xy - bond.xy1) ;
            target_proximity(i) = norm(object.xy - bond.xy2) ;
        end
       	
        [range,index] = min(origin_proximity) ;
        origin_name = object_names{index} ;
        bond.from.obj = origin_name ;
        bond.from.interface = [] ;
        
        [range,index] = min(target_proximity) ;
        target_name = object_names{index} ;
        bond.to.obj = target_name ;
        bond.to.interface = [] ;
        
        model = setfield(model,'bond',{j},bond) ;
        
        origin = getfield(model,'obj',origin_name) ;
        next = 1 + mttGetFieldLength(origin,'bond') ;
        origin.bond(next).number = j ;
        origin.bond(next).is_inbond = 0 ;
        model = setfield(model,'obj',origin_name,origin) ;
        
        target = getfield(model,'obj',target_name) ;
        next = 1 + mttGetFieldLength(target,'bond') ;
        target.bond(next).number = j ;
        target.bond(next).is_inbond = 1 ;
        model = setfield(model,'obj',target_name,target) ;
    end
    
    
function model = identify_object_interfaces(model)
	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
	number_of_labels = mttGetFieldLength(model,'label') ;
	number_of_bonds = mttGetFieldLength(model,'bond') ;
    
    for j = 1:number_of_labels
        label = model.label(j) ;
        for i = 1:number_of_objects
            object_name = object_names{i} ;
            object = getfield(model,'obj',object_names{i}) ;
            proximity(i) = norm(object.xy - label.xy) ;
        end
        [range,index] = min(proximity) ;
        associated_object = object_names{index} ;
        object = getfield(model,'obj',associated_object) ;
        
        switch object.class
        case {'0','1'},
            mttAssert(~label.is_inline,...
                ['Inline ports not valid for "0" and "1" junctions']) ;
        end
        
        next = 1 + mttGetFieldLength(object,'interface') ;
        object = setfield(object,'interface',{next},'name',label.name) ;
        object = setfield(object,'interface',{next},'class',[]) ;
        object = setfield(object,'interface',{next},'is_inline',label.is_inline) ;
        object = setfield(object,'interface',{next},'xy',label.xy) ;
        object = setfield(object,'interface',{next},'in',[]) ;
        object = setfield(object,'interface',{next},'out',[]) ;
        object = setfield(object,'interface',{next},'map',[]) ;
        model = setfield(model,'obj',associated_object,object) ;
    end
    
    for j = 1:number_of_objects
        object_name = object_names{j} ;
        object = getfield(model,'obj',object_name) ;
        
        number_of_attached_bonds = mttGetFieldLength(object,'bond') ;
        number_of_interfaces = mttGetFieldLength(object,'interface') ;
        
        for k = 1:number_of_interfaces
            interface = object.interface(k) ;
            
            inbond_proximity = [] ;  inbond_counter = [] ;
            outbond_proximity = [] ; outbond_counter = [] ;
            
            in_counter = 0 ;
            out_counter = 0 ;
            
            for i = 1:number_of_attached_bonds
                bond_number = object.bond(i).number ; 
                bond = model.bond(bond_number) ;
                
                if object.bond(i).is_inbond
                    if isempty(bond.to.interface)
                        in_counter = in_counter + 1 ;
                        inbond_proximity(in_counter) = norm(interface.xy - bond.xy2) ;
                        inbond_counter(in_counter) = bond_number ;
                    end
                else
                    if isempty(bond.from.interface)
                        out_counter = out_counter + 1 ;
                        outbond_proximity(out_counter) = norm(interface.xy - bond.xy1) ;
                        outbond_counter(out_counter) = bond_number ;
                    end
                end
            end
            
            [in_range,inbond_index] = min(inbond_proximity) ;
            [out_range,outbond_index] = min(outbond_proximity) ;

            inbond = inbond_counter(inbond_index) ;
            outbond = outbond_counter(outbond_index) ;
            
            if interface.is_inline
                mttAssert(~isempty(inbond_proximity),...
                    ['No in-bond for interface "',object_name,'[',interface.name,']"']) ;
                mttAssert(~isempty(outbond_proximity),...
                    ['No out-bond for interface "',object_name,'[',interface.name,']"']) ;
                
            	interface.in = inbond ;
                interface.out = outbond ;
                
                model = setfield(model,'bond',{outbond},'from','interface',k) ;
                model = setfield(model,'bond',{inbond},'to','interface',k) ;
            else
                mttAssert(~(isempty(inbond_proximity) & isempty(outbond_proximity)),...
                    ['No bond for interface "',object_name,'[',interface.name,']"']) ;
                
                if isempty(inbond_proximity)
                    interface.out = outbond ;
                    model = setfield(model,'bond',{outbond},'from','interface',k) ;
                elseif isempty(outbond_proximity)
                    interface.in = inbond ;
                    model = setfield(model,'bond',{inbond},'to','interface',k) ;
                else
                    mttAssert(in_range~=out_range,...
                        ['Ambiguous interface "',object_name,'[',interface.name,']"']) ;
                    
                    if out_range<in_range
                        interface.out = outbond ;
	                    model = setfield(model,'bond',{outbond},'from','interface',k) ;
                    else
                        interface.in = inbond ;
	                    model = setfield(model,'bond',{inbond},'to','interface',k) ;
                    end
                end
            end
            object.interface(k) = interface ;
        end
        model = setfield(model,'obj',object_name,object) ;
    end
    
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
            
        number_of_interfaces = mttGetFieldLength(object,'interface') ;
        for k = 1:number_of_interfaces;
            interface = object.interface(k) ;
            
            if interface.is_inline
                mttAssert(~(isempty(interface.in) | isempty(interface.out)),...
                    ['Unbound interface: ',object_name,'[',interface.name,']']) ;
            else
                mttAssert(~(isempty(interface.in) & isempty(interface.out)),...
                    ['Unbound interface: ',object_name,'[',interface.name,']']) ;
            end
        end
    end
    
    objects_with_in = [] ;
    objects_with_out = [] ;
    
    for j = 1:number_of_bonds
        bond = model.bond(j) ;
        
        if isempty(bond.from.interface)
            object_name = bond.from.obj ;
            object = getfield(model,'obj',object_name) ;
            
            if ~ismember(object.class,{'0','1'})
                mttAssert(~ismember(object_name,objects_with_out),...
                    ['Object "',object_name,'" has more than one implicit out-bond']) ;
                if isempty(objects_with_out)
                    objects_with_out = {object_name} ;
                else
                    objects_with_out = [objects_with_out,{object_name}] ;
                end
            end
            
            next = 1 + mttGetFieldLength(object,'interface') ;
            model = setfield(model,'obj',object_name,'interface',{next},'name','out') ;
      		model = setfield(model,'obj',object_name,'interface',{next},'in',[]) ;
            model = setfield(model,'obj',object_name,'interface',{next},'out',j) ;
            model = setfield(model,'bond',{j},'from','interface',next) ;
        end
        
        if isempty(bond.to.interface)
            object_name = bond.to.obj ;
            object = getfield(model,'obj',object_name) ;
            
            if ~ismember(object.class,{'0','1'})
                mttAssert(~ismember(object_name,objects_with_in),...
                    ['Object "',object_name,'" has more than one implicit in-bond']) ;
                if isempty(objects_with_in)
                    objects_with_in = {object_name} ;
                else
                    objects_with_in = [objects_with_in,{object_name}] ;
                end
            end
            
            next = 1 + mttGetFieldLength(object,'interface') ;
            model = setfield(model,'obj',object_name,'interface',{next},'name','in') ;
            model = setfield(model,'obj',object_name,'interface',{next},'in',j) ;
         	model = setfield(model,'obj',object_name,'interface',{next},'out',[]) ;
            model = setfield(model,'bond',{j},'to','interface',next) ;
        end
    end
    
    
function model = associate_external_domains(model)

	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
    
	for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'},
            mttAssert(mttGetFieldLength(object,'interface')==1,...
                ['Object "',object_name,'" must have a unique bond interface']) ;
            
            bond_number = [] ;
            
            if ~isempty(object.interface.in)
                bond_number = object.interface.in ;
            end
            if ~isempty(object.interface.out)
                bond_number = object.interface.out ;
            end
            
            [model,ok] = mttUpdateBondDomain(model,bond_number,object.domain,object.domain_item) ;
            mttAssert(ok,['Domain conflict on bond connected to object "',object_name,'"']) ;
        end
    end
    
    
function model = tidy_up(model)
% remove temperory data and xfig geometry from model structure 

	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
    
	for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        object = mttDeleteField(object,'bond') ;
        
        object_interfaces = getfield(object,'interface') ;
        object_interfaces = mttDeleteField(object_interfaces,'is_inline') ;
        object_interfaces = mttDeleteField(object_interfaces,'xy') ;
        object = setfield(object,'interface',object_interfaces) ;
        object = mttDeleteField(object,'xy') ;
        model = setfield(model,'obj',object_name,object) ;
    end
    
	all_bonds = getfield(model,'bond') ;
    all_bonds = mttDeleteField(all_bonds,'xy1') ;
    all_bonds = mttDeleteField(all_bonds,'xy2') ;
    all_bonds = mttDeleteField(all_bonds,'v1') ;
    all_bonds = mttDeleteField(all_bonds,'v2') ;
    all_bonds = mttDeleteField(all_bonds,'harpoon') ;
    all_bonds = mttDeleteField(all_bonds,'harpoon_side') ;
    model = setfield(model,'bond',all_bonds) ;
    
    model = mttDeleteField(model,'anonymous') ;
    model = mttDeleteField(model,'line') ;
    model = mttDeleteField(model,'label') ;

Deleted mttroot/ntt/bin/trans/m/mttFetchDomain.m version [3356e6dd33].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179



















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttFetchDomain(filename)

model.representation = 'domain' ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_domain.txt') ;
content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case {'domain','public_domain','private_domain'},
        domain_name = line ;
        mttValidateName(domain_name) ;
        
        [domain,next] = fetch_domain(statements,next,domain_name) ;
        model = setfield(model,'item',domain_name,domain) ;
        
        is_private = strcmp(keyword,'private_domain') ;
        model = setfield(model,'item',domain_name,'is_private',is_private) ;
        
    case {'multi_domain','public_multi_domain','private_multi_domain'},
        domain_name = line ;
        mttValidateName(domain_name) ;
        
        [domain,next] = fetch_multi_domain(statements,next,domain_name) ;
        model = setfield(model,'item',domain_name,domain) ;

        is_private = strcmp(keyword,'private_multi_domain') ;
        model = setfield(model,'item',domain_name,'is_private',is_private) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end


function [domain,next] = fetch_domain(statements,next,domain_name)
    domain = [] ;
    unit_name = 'domain' ;
    
    number_of_statements = length(statements) ;
    
    effort_declared = 0 ;
    flow_declared = 0 ;
    
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'effort',
            mttAssert(open,...
                ['"effort" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~effort_declared,...
                ['"effort" declarations must be unique in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "effort" in "',unit_name,'"']) ;
            
            [covar,default] = mttCutText(line,'=') ;
            
            mttValidateName(covar) ;
            domain.covar.effort = covar ;
            domain.covar.effort_default = default ;
            effort_declared = 1 ;
            
        case 'flow',
            mttAssert(open,...
                ['"flow" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~flow_declared,...
                ['"flow" declarations must be unique in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "flow" in "',unit_name,'"']) ;
            
            [covar,default] = mttCutText(line,'=') ;
            
            mttValidateName(covar) ;
            domain.covar.flow = covar ;
            domain.covar.flow_default = default ;
            flow_declared = 1 ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    
function [domain,next] = fetch_multi_domain(statements,next,domain_name)
    domain = [] ;
    unit_name = 'domain' ;
    
    number_of_statements = length(statements) ;
    
    counter = 0 ;
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'bond',
            mttAssert(open,...
                ['"bond" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "bond" in "',unit_name,'"']) ;
            
            [bond_name,bond_domain] = mttCutText(line,'[') ;
            [bond_domain,rubbish] = mttCutText(bond_domain,']') ;
            
            mttAssert(isempty(rubbish),...
                ['Unexpected text after "]" in "',unit_name,'"']) ;
            
            if ~isempty(bond_name)
                mttValidateName(bond_name) ;
            end
            
            counter = counter + 1 ;
            domain.bond(counter).name = bond_name ;
            domain.bond(counter).domain = bond_domain ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end

Deleted mttroot/ntt/bin/trans/m/mttFetchEnvironment.m version [43e7bb5007].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134






































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttFetchEnvironment(filename)

model.representation = 'env' ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_env.txt') ;
model_name = mttDetachText(model.source,'/') ;

content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

env_declared = 0 ;
next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'env',
        mttAssert(~env_declared,...
            '"env" declaration must be unique') ;
        env_declared = 1 ;
        
        env_name = line ;
        mttAssert(strcmp(env_name,model_name),...
            ['Wrong name:[',env_name,'] Expecting:[',model_name,']']) ;
        
        [env,next] = fetch_env(statements,next) ;
        model = mttAppendFields(model,env) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end




function [env,next] = fetch_env(statements,next)
    env = [] ;
    unit_name = 'env' ;
    
    number_of_statements = length(statements) ;
    
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'path',
            mttAssert(open,...
                ['"path" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            path_names = mttGetFieldNames(env,'path') ;
            
            [path_name,path_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(path_name,path_names),...
                ['Path "',path_name,'" already declared']) ;
            mttAssert(path_name(1)=='$',...
                ['Path "',path_name,'" must be prefixed with "$"']) ;
            
            path_name(1) = [] ;
            env = setfield(env,'path',path_name,path_spec) ;
            
        case 'domain',
            mttAssert(open,...
                ['"domain" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            domain_names = mttGetFieldNames(env,'domain') ;
            
            [domain_name,domain_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(domain_name,domain_names),...
                ['Domain "',domain_name,'" already declared']) ;
            
            env = setfield(env,'domain',domain_name,domain_spec) ;
                    
        case 'struct',
            mttAssert(open,...
                ['"struct" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            struct_names = mttGetFieldNames(env,'struct') ;
            
            [struct_name,struct_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(struct_name,struct_names),...
                ['Struct "',struct_name,'" already declared']) ;
            mttAssert(~isempty(struct_spec),...
                ['Undefined datatype within struct "',struct_name,'"']) ;
            
            env = setfield(env,'struct',struct_name,struct_spec) ;
                    
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    env = mttSetFieldDefault(env,'path',[]) ;
    env = mttSetFieldDefault(env,'domain',[]) ;
    env = mttSetFieldDefault(env,'struct',[]) ;
    

Deleted mttroot/ntt/bin/trans/m/mttFetchInterfaceDefinition.m version [317a4da97c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583







































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttFetchInterfaceDefinition(filename)

mttAssert(exist(filename)==2,...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.representation = 'cr' ;
model.source = mttCutText(filename,'_cr.txt') ;
content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;
crs = [] ;

next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'cr',
        cr_name = mttCutText(line,'[') ;
        mttValidateName(cr_name) ;
        
        if ~isempty(crs)
            mttAssert(~ismember(cr_name,crs),...
                ['"cr ',cr_name,'" has already been declared']) ;
        end
        
        cr_parameter_list = mttExtractText(line,'[',']') ;
        [cr_parameters,cr_defaults] = mttGetParameters(cr_parameter_list) ;
        
        [cr,next] = fetch_cr(statements,next,cr_name,cr_parameters,cr_defaults) ;
        
        mttCheckInterfaceDeclarations(cr) ;
        mttCheckStateDeclarations(cr) ;
        
        model = setfield(model,'item',cr_name,cr) ;
        
        if isempty(crs)
            crs = {cr_name} ;
        else
            crs = [crs,{cr_name}] ;
        end
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end


       
function [cr,next] = fetch_cr(statements,next,cr_name,cr_parameters,cr_defaults)
	unit_name = 'cr' ;
	here = [cr_name,'/',unit_name] ;
    
    cr = [] ;
    number_of_statements = length(statements) ;
    
    cr.sympar = cr_parameters ;
    cr.numpar = [] ;
    cr.input = [] ;
    cr.state = [] ;
    
    cr.sympar_default = cr_defaults ;
    cr.numpar_default = [] ;
    cr.input_default = [] ;
    cr.state_default = [] ;

    op_counter = 0 ;
    interface_declared = 0 ;
	open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'interface',
            mttAssert(open,...
                ['"interface" declaration must be contained inside {...} in ',here]) ;
            mttAssert(~interface_declared,...
                '"interface" declaration must be unique') ;
            mttAssert(isempty(line),...
                ['Unexpected text after "interface" declaration in ',here]) ;
            
            [interface,next] = fetch_interface(statements,next,cr_name) ;
            cr.interface = interface ;
            interface_declared = 1 ;
            
        case 'operator',
            mttAssert(interface_declared,...
                ['"operator" declaration must follow "interface" in ',here]) ;
            mttAssert(open,...
                ['"operator" declaration must be contained inside {...} in ',here]) ;
            
            op_counter = op_counter + 1 ;
            [operator,next] = fetch_operator(statements,next,cr,cr_name) ;
            
            if ~isfield(operator,'content')
                operator.content = [] ;
            end
            cr.operator(op_counter) = operator ;
            
        case 'input',
            mttAssert(open,...
                ['"input" declarations must be contained inside {...} in ',here]) ;
            
            input_parameter_list = line ;
            [input_parameters,input_defaults] = mttGetParameters(input_parameter_list) ;
            
            cr = mttAppend(cr,'input',input_parameters) ;
            cr = mttAppend(cr,'input_default',input_defaults) ;
            
        case 'numpar',
            mttAssert(open,...
                ['"numpar" declarations must be contained inside {...} in ',here]) ;
            
            numerical_parameter_list = line ;
            [numerical_parameters,numerical_defaults] = mttGetParameters(numerical_parameter_list) ;
            
            cr = mttAppend(cr,'numpar',numerical_parameters) ;
            cr = mttAppend(cr,'numpar_default',numerical_defaults) ;
            
        case 'state',
            mttAssert(open,...
                ['"state" declarations must be contained inside {...} in ',here]) ;
            
            state_parameter_list = line ;
            [state_parameters,state_defaults] = mttGetParameters(state_parameter_list) ;
            
            cr = mttAppend(cr,'state',state_parameters) ;
            cr = mttAppend(cr,'state_default',state_defaults) ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in ',here]) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in ',here]) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised keyword "',keyword,'" in ',here]) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in ',here]) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    interface_ports = mttGetFieldNames(cr.interface,'port') ;
    interface_ports_with_state = [] ;
    
    counter = 0 ;
    for i = 1:length(interface_ports)
        port_name = interface_ports{i} ;
        interface_port = getfield(cr.interface,'port',port_name) ;
        if interface_port.is_effort_state | interface_port.is_flow_state
            counter = counter + 1 ;
            interface_ports_with_state{counter} = port_name ;
        end
    end
    
    mttAssert(op_counter>0,...
        ['No operator defined in ',here]) ;
    
    assigned_ports = [] ;
    
    for i = 1:length(cr.operator)
        if i==1
            operator_names{1} = cr.operator(i).name ;
        else
            operator_name = cr.operator(i).name ;
            mttAssert(~ismember(operator_name,operator_names),...
                ['Repeated operator name "',operator_name,'" in ',here]) ;
            operator_names{i} = operator_name ;
        end
        
        newly_assigned_ports = mttGetFieldNames(cr.operator(i),'assign') ;
        if isempty(assigned_ports)
            assigned_ports = newly_assigned_ports ;
        else
            if ~isempty(newly_assigned_ports)
                assigned_ports = [assigned_ports, newly_assigned_ports] ;
            end
        end
    end
    
    for i = 1:length(interface_ports_with_state)
        interface_port = interface_ports_with_state{i} ;
        
        mttAssert(ismember(interface_port,assigned_ports),...
            ['Missing "set" declaration for port "',interface_port,'" in ',here]) ;
    end
    
    
    
    
function [interface,next] = fetch_interface(statements,next,cr_name)
global mtt_environment
	unit_name = 'interface' ;
    here = [cr_name,'/',unit_name] ;
    
    domain_names = mttGetFieldNames(mtt_environment,'domain') ;
    
    interface = [] ;
    number_of_statements = length(statements) ;
    
    counter = 0 ;
    constraint = [] ;
    
    open = 0 ;
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'port',
            ports = mttGetItemList(line) ;
            for n = 1:length(ports)
                identifier = mttCutText(ports{n},'[') ;
                qualifier = mttExtractText(ports{n},'[',']') ;
                [name.domain,name.domain_item] = mttCutText(qualifier,'::') ;
                
                name.port = identifier ;
                mttValidateName(name.port) ;
                
                if isempty(name.domain) | isempty(mtt_environment)
                    interface = setfield(interface,'port',name.port,'domain',[]) ;
                    interface = setfield(interface,'port',name.port,'domain_item',[]) ;
                    interface = setfield(interface,'port',name.port,'was_generic',1) ;
                else
                    mttAssert(ismember(name.domain,domain_names),...
                        ['Unrecognised domain "',name.domain,'"']) ;
                    dom = getfield(mtt_environment,'domain',name.domain,'dom') ;
                    item = getfield(mtt_environment,'domain',name.domain,'item') ;
                    
                    if isempty(item)
                        public_domain = getfield(mtt_environment,'public_domain',{dom}) ;
                        item_names = mttGetFieldNames(public_domain,'item') ;
                        
                        mttAssert(ismember(name.domain_item,item_names),...
                            ['Item "',name.domain_item,'" not found in public domain "',name.domain,'"']) ;
                        item_name = name.domain_item ;
                    else
                        mttAssert(isempty(name.domain_item),...
                            ['Item unspecified in public domain "',name.domain,'"']) ;
                        item_name = item ;
                    end
                    
                    interface = setfield(interface,'port',name.port,'domain',dom) ;
                    interface = setfield(interface,'port',name.port,'domain_item',item_name) ;
                    interface = setfield(interface,'port',name.port,'was_generic',0) ;
                end
                interface = setfield(interface,'port',name.port,'is_effort_state',0) ;
                interface = setfield(interface,'port',name.port,'is_flow_state',0) ;
                interface = setfield(interface,'port',name.port,'assign',[]) ;
            end
            
        case {'assert','prefer'},
            counter = counter + 1 ;
            constraint{counter} = statement ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in ',here]) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in ',here]) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in ',here]) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in ',here]) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    
    interface_ports = mttGetFieldNames(interface,'port') ;
    number_of_constraints = length(constraint) ;
    
    for i = 1:number_of_constraints
        [keyword,assignment] = mttSeparateText(constraint{i}) ;
        [namelist,definition] = mttCutText(assignment,'=>') ;
        
        mttAssert(~isempty(keyword),...
            ['Rule "',constraint{i},'" has no context in cr ',cr_name]) ;
                
        if ~isempty(namelist)
            first = 1 ;
            last = length(namelist) ;
            if namelist([first,last])=='[]'
                ports = mttGetItemList(mttExtractText(namelist,'[',']')) ;
            else
                ports = {namelist} ;
            end
        end
        
        mttAssert(~isempty(ports),...
            ['Rule "',constraint{i},'" has no association in cr ',cr_name]) ;
        mttAssert(~isempty(definition),...
            ['Rule "',constraint{i},'" not defined in cr ',cr_name]) ;
        
		for j = 1:length(ports)
            port_name = ports{j} ;
            mttValidateName(port_name) ;
            
            other_ports = [] ;
            counter = 0 ;
            for k = 1:length(ports)
                if j~=k
                    counter = counter + 1 ;
                    other_ports{counter} = ports{k} ;
                end
            end
            
            mttAssert(ismember(port_name,interface_ports),...
                ['Unreferenced port "',port_name,'" in cr ',cr_name]) ;
            
            port = getfield(interface,'port',port_name) ;
            
            switch definition
            case 'effort_state',
                mttAssert(mttIsEqual(port.is_flow_state,0),...
                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
                port.is_effort_state = 1 ;
                
            case 'flow_state',
                mttAssert(mttIsEqual(port.is_effort_state,0),...
                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
                port.is_flow_state = 1 ;
                
            otherwise,
                rule_number = 1 + mttGetFieldLength(port,'causality') ;
                
                port.causality(rule_number).rule = keyword ;
                port.causality(rule_number).def = definition ;
                port.causality(rule_number).with = other_ports ;
                port.causality(rule_number).applied = 0 ;
            end
            
            interface = setfield(interface,'port',port_name,port) ;
        end
    end
        
    
function [operator,next] = fetch_operator(statements,next,cr,cr_name)
	unit_name = 'operator' ;
    here = [cr_name,'/',unit_name] ;
    
    interface = [] ;
    number_of_statements = length(statements) ;
    
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    operator = mttGetOperatorContext(line,cr,cr_name) ;
    
    operator.content = [] ;
    operator.var = [] ;
    operator.var_default = [] ;
    operator.struct = [] ;
    operator.set = [] ;
    
    counter = 0 ;
    
    open = 0 ;
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case '{',
            mttAssert(~open,['Unmatched "{" in ',here]) ;
            open = 1 ;
            
        case '}',
            mttAssert(open,['Unmatched "}" in ',here]) ;
			open = 0 ;
            
        case 'set',
            mttAssert(open,...
                ['"set" declarations must be contained inside {...} in ',here]) ;
            
            operator = mttAppend(operator,'set',{line}) ;
            
        case 'var',
            mttAssert(open,...
                ['"var" declarations must be contained inside {...} in ',here]) ;
            
            variable_list = line ;
            [variables,defaults] = mttGetParameters(variable_list) ;
            
            operator = mttAppend(operator,'var',variables) ;
            operator = mttAppend(operator,'var_default',defaults) ;
            
        case 'struct',
            mttAssert(open,...
                ['"struct" declarations must be contained inside {...} in ',here]) ;
            
            [struct_name,variable_list] = mttSeparateText(line) ;
            [variables,defaults] = mttGetParameters(variable_list) ;
            
            mttAssert(mttIsEmptyCellArray(defaults),...
                ['"struct" declarations cannot have default values in ',here]) ;
            
            operator.struct = mttAppend(operator.struct,struct_name,variables) ;
            
        otherwise,
            counter = counter + 1 ;
            operator.content{counter} = statement ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in ',here]) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    cr_ports = mttGetFieldNames(cr.interface,'port') ;
    for i = 1:length(operator.var)
        current_var = operator.var{i} ;
        mttAssert(~ismember(current_var,cr.numpar),...
            ['Variable "',current_var,'" redeclares CR numerical parameter in ',cr_name]) ;
        mttAssert(~ismember(current_var,cr.sympar),...
            ['Variable "',current_var,'" redeclares CR parameter in ',cr_name]) ;
        mttAssert(~ismember(current_var,cr_ports),...
            ['Variable "',current_var,'" redeclares CR port in ',cr_name]) ;
    end
    
    operator = mttParseOperatorEquations(operator,cr,cr_name) ;

    
function context = mttGetOperatorContext(line,cr,cr_name)
    index = sort([findstr(line,'|'),findstr(line,'<'),findstr(line,'>')]) ;
    assignment = findstr(line,':=') ;

    mttAssert(length(assignment)==1,...
        ['Operator declaration must contain a unique ":=" assignment in cr ',cr_name]) ;
    mttAssert(length(index)>0,...
        ['Operator declaration without ports in cr ',cr_name]) ;
    
    left_side = index(index<assignment) ;
    right_side = index(index>assignment) ;
    
    mttAssert(length(left_side)>0,...
        ['Operator declaration without input ports in cr ',cr_name]) ;
    mttAssert(length(right_side)>0,...
        ['Operator declaration without output ports in cr ',cr_name]) ;
    mttAssert(mod(length(left_side),2)==0 & mod(length(right_side),2)==0,...
        ['Operator declaration has mismatched tags in cr ',cr_name]) ;
    
    context.name = mttClipText(line(assignment+2:right_side(1)-1)) ;
    mttAssert(~isempty(context.name),...
        ['Operator declaration is anonymous in cr ',cr_name]) ;
    
    mttValidateName(context.name) ;
    
    
    counter = 0 ;
    
    for i = 1:length(index)/2
        counter = counter + 1 ;
        link = [] ;
        
        right = 2*i ;
        left = right - 1 ;
        
        if index(right)<assignment
            link.is_input = 0 ;
        elseif index(left)>assignment
            link.is_input = 1 ;
        end
        
        
        recognised = 1 ;
        switch line(index([left,right]))
        case '|>',
            link.is_flow = 1 ;
            link.is_effort = 0 ;
        case '<|',
            link.is_flow = 0 ;
            link.is_effort = 1 ;
        case '<>',
            link.is_flow = 1 ;
            link.is_effort = 1 ;
        otherwise,
            recognised = 0 ;
        end
        
        mttAssert(recognised,...
            ['Unrecognised tags in operator ',context.name,' (cr ',cr_name,')']) ;
        
        port_declaration = line(index(left):index(right)) ;
        port = line(index(left)+1:index(right)-1) ;
        mttAssert(~isempty(port),...
            ['Empty port in operator ',context.name,' (cr ',cr_name,')']) ;
            
        [port_name,qualifier] = mttCutText(port,'=') ;
        
        link.name = port_name ;

        if isempty(qualifier)
            link.is_unconstrained = 1 ;
        else
            link.is_unconstrained = 0 ;
            mttAssert(strcmp(qualifier,'0'),...
                ['Non-zero port constraint in operator ',context.name,' (cr ',cr_name,')']) ;
        end
        
        context.link(counter) = link ;
    end
    
    
    cr_port_names = mttGetFieldNames(cr.interface,'port') ;
    
    check.is_input = [] ;
    check.is_output = [] ;
    check.is_effort = [] ;
    check.is_flow = [] ;
    
    for j = 1:length(cr_port_names)
        port_check(j) = check ;
    end    
    
    for i = 1:counter
        port_name = context.link(i).name ;
        mttAssert(ismember(port_name,cr_port_names),...
            ['Operator declaration uses undefined port "',port_name,'" in cr ',cr_name]) ;
        
        index = strmatch(port_name,cr_port_names,'exact') ;
        
        mttAssert(~mttIsEqual(port_check(index).is_input,context.link(i).is_input),...
            ['Operator declaration has repeated input ports in cr ',cr_name]) ;
        mttAssert( mttIsEqual(port_check(index).is_output,context.link(i).is_input),...
            ['Operator declaration has repeated output ports in cr ',cr_name]) ;
        mttAssert(~mttIsEqual(port_check(index).is_flow,context.link(i).is_flow),...
            ['Operator declaration has repeated flow in cr ',cr_name]) ;
        mttAssert(~mttIsEqual(port_check(index).is_effort,context.link(i).is_effort),...
            ['Operator declaration has repeated effort in cr ',cr_name]) ;
        
        port_check(index).is_input = context.link(i).is_input ;
        port_check(index).is_output = ~context.link(i).is_input ;
        port_check(index).is_flow = context.link(i).is_flow ;
        port_check(index).is_effort = context.link(i).is_effort ;
    end
    
    for j = 1:length(cr_port_names)
        mttAssert(~isempty(port_check(j).is_input),...
            ['Operator declaration has missing input ports in cr ',cr_name]) ;
        mttAssert(~isempty(port_check(j).is_output),...
            ['Operator declaration has missing output ports in cr ',cr_name]) ;
        mttAssert(~isempty(port_check(j).is_flow),...
            ['Operator declaration has missing flow in cr ',cr_name]) ;
        mttAssert(~isempty(port_check(j).is_effort),...
            ['Operator declaration has missing effort in cr ',cr_name]) ;
    end    

Deleted mttroot/ntt/bin/trans/m/mttFetchSpecification.m version [94b1cb9964].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189





























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttFetchSpecification(filename)

model = [] ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.specification = filename ;

model.source = mttCutText(filename,'_abg.txt') ;
model_name = mttDetachText(model.source,'/') ;

content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

abg_declared = 0 ;
next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'abg',
        mttAssert(~abg_declared,...
            '"abg" declaration must be unique') ;
        abg_declared = 1 ;
        
        abg_name = mttCutText(line,'[') ;
        mttAssert(strcmp(abg_name,model_name),...
            ['Wrong name:[',abg_name,'] Expecting:[',model_name,']']) ;
        
        abg_parameter_list = mttExtractText(line,'[',']') ;
        [abg_parameters,abg_defaults] = mttGetParameters(abg_parameter_list) ;
        
        model.name = abg_name ;
        
        model.sympar = abg_parameters ;
        model.sympar_default = abg_defaults ;

        [abg,next] = fetch_abg(statements,next) ;
        
        model = mttAppendFields(model,abg) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end

mttCheckBondgraphDeclarations(model) ;



function [abg,next] = fetch_abg(statements,next)
global mtt_environment

    abg = [] ;
    unit_name = 'abg' ;
    
    user_defined_paths = mttGetFieldNames(mtt_environment,'path') ;
    
    number_of_statements = length(statements) ;
    
    bondgraph = [] ;
    use_declared = 0 ;
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'use',
            mttAssert(open,...
                ['"use" declaration must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~use_declared,...
                '"use" declaration must be unique') ;
            
            use_declared = 1 ;
            bondgraph = line ;
            
            abg.bondgraph = bondgraph ;
            
        case 'input',
            mttAssert(open,...
                ['"input" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            input_parameter_list = line ;
            [input_parameters,input_defaults] = mttGetParameters(input_parameter_list) ;
            
            abg = mttAppend(abg,'input',input_parameters) ;
            abg = mttAppend(abg,'input_default',input_defaults) ;
            
        case 'numpar',
            mttAssert(open,...
                ['"numpar" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            numerical_parameter_list = line ;
            [numerical_parameters,numerical_defaults] = mttGetParameters(numerical_parameter_list) ;
            
            abg = mttAppend(abg,'numpar',numerical_parameters) ;
            abg = mttAppend(abg,'numpar_default',numerical_defaults) ;
            
        case 'object',
            mttAssert(open,...
                ['"object" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            object_names = mttGetFieldNames(abg,'obj') ;
            
            [object_name,object_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(object_name,object_names),...
                ['Object "',object_name,'" already declared']) ;
            
            implementation = mttCutText(object_spec,'[') ;
            mttAssert(~isempty(implementation),...
                ['Incomplete specification:[',line,']']) ;
            
            object_parameter_list = mttExtractText(line,'[',']') ;
            object_parameters = mttGetInstanceParameters(object_parameter_list) ;
            
            [source,name.item] = mttCutText(implementation,'::') ;
            [name.class,name.path] = mttDetachText(source,'/') ;
            
            if isempty(name.class)
                name.class = source ;
                name.path = [] ;
            else
                mttAssert(~isempty(name.path),...
                    ['Empty path name in "',unit_name,'"']) ;
                if name.path(1)=='$'
                    [path_alias,path_branch] = mttCutText(name.path,'/') ;
                    path_alias(1) = [] ;
                    
                    mttAssert(ismember(path_alias,user_defined_paths),...
                        ['Path "',path_alias,'" not recognised']) ;
                    
                    path_root = getfield(mtt_environment,'path',path_alias) ;
                    if isempty(path_branch)
                        name.path = path_root ;
                    else
                        name.path = [path_root,'/',path_branch] ;
                    end
                end
            end
            
            abg = setfield(abg,'obj',object_name,'name',name) ;
            abg = setfield(abg,'obj',object_name,'parameter',object_parameters) ;
                    
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    abg = mttSetFieldDefault(abg,'input',[]) ;
    abg = mttSetFieldDefault(abg,'input_default',[]) ;
    abg = mttSetFieldDefault(abg,'numpar',[]) ;
    abg = mttSetFieldDefault(abg,'numpar_default',[]) ;
    abg = mttSetFieldDefault(abg,'bondgraph',[]) ;
    

Deleted mttroot/ntt/bin/trans/m/mttFetchStruct.m version [3e806bb24f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttFetchStruct(filename)

model.representation = 'struct' ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_struct.txt') ;
content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case {'struct','public_struct','private_struct'},
        struct_name = line ;
        mttValidateName(struct_name) ;
        
        [struct,next] = fetch_struct(statements,next,struct_name) ;
        model = setfield(model,'item',struct_name,struct) ;
        
        is_private = strcmp(keyword,'private_struct') ;
        model = setfield(model,'item',struct_name,'is_private',is_private) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end


function [struct,next] = fetch_struct(statements,next,struct_name)
    struct = [] ;
    unit_name = 'struct' ;
    
    number_of_statements = length(statements) ;
    
    counter = 0 ;
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'var',
            mttAssert(open,...
                ['"var" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "var" in "',unit_name,'"']) ;
            
            data_name = line ;
            mttValidateName(data_name) ;
            
            counter = counter + 1 ;
            struct.var(counter).name = data_name ;
            struct.var(counter).type = [] ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            mttAssert(open,...
                ['Declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Empty declaration in "',unit_name,'"']) ;
            
            data_name = line ;
            mttValidateName(data_name) ;
            
            data_type = keyword ;
            mttValidateName(data_type) ;
            
            counter = counter + 1 ;
            struct.var(counter).name = data_name ;
            struct.var(counter).type = data_type ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end

Deleted mttroot/ntt/bin/trans/m/mttIdentifyDomainCovariables.m version [9da7d7b8fd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function compound_item = mttIdentifyDomainCovariables(item,domain,model)
	domains = mttGetFieldNames(model,'domain') ;
	
	domain_name = domain.source ;
    domain_shortname = mttDetachText(domain_name,'/') ;
    
    item_names = mttGetFieldNames(domain,'item') ;
	
    number_of_bonds = mttGetFieldLength(item,'bond') ;
    
    if number_of_bonds==0
        compound_item.effort = {item.covar.effort} ;
        compound_item.flow = {item.covar.flow} ;
        
   		compound_item.effort_default = {item.covar.effort_default} ;
		compound_item.flow_default = {item.covar.flow_default} ;

    else
        counter = 0 ;
        for k = 1:number_of_bonds
            bond = item.bond(k) ;
            
            [next_domain,next_item] = mttCutText(bond.domain,'::') ;
            if isempty(next_item)
	            mttAssert(ismember(next_item,item_names),...
    	            ['Unrecognised reference "',next_item,'" in domain ',domain_shortname]) ;
            
                next_item = bond.domain ;
                dependent_item = getfield(domain,'item',next_item) ;
                compound_domain = mttIdentifyDomainCovariables(dependent_item,domain,model) ;
            else
                mttAssert(ismember(next_domain,domains),...
                    ['Unrecognised domain reference "',next_domain,'" in domain ',domain_shortname]) ;
                
                next_domain_index = getfield(model,'domain',next_domain,'dom') ;
                next_domain_item_reference = getfield(model,'domain',next_domain,'item') ;
                
                mttAssert(isempty(next_domain_item_reference),...
                    ['Constrained domain reference "',next_domain,'" in domain ',domain_shortname]) ;
                
                actual_domain = model.dom(next_domain_index) ;
                
                actual_domain_name = actual_domain.source ;
                actual_domain_shortname = mttDetachText(actual_domain_name,'/') ;
            
                actual_item_names = mttGetFieldNames(actual_domain,'item') ;
                mttAssert(ismember(next_item,actual_item_names),...
                    ['Unrecognised reference "',next_item,'" in domain ',actual_domain_shortname]) ;
                
                dependent_item = getfield(actual_domain,'item',next_item) ;
                mttAssert(~dependent_item.is_private,...
                    ['No public cross-reference available for "',next_item,'" in domain ',actual_domain_shortname]) ;
                
                compound_domain = mttIdentifyDomainCovariables(dependent_item,actual_domain,model) ;
            end
            
            for i = 1:length(compound_domain.effort)
                counter = counter + 1 ;
                if isempty(bond.name)
                    compound_effort{counter} = compound_domain.effort{i} ;
                    compound_flow{counter} = compound_domain.flow{i} ;
                else
                    compound_effort{counter} = [bond.name,'.',compound_domain.effort{i}] ;
                    compound_flow{counter} = [bond.name,'.',compound_domain.flow{i}] ;
                end
                compound_effort_default{counter} = compound_domain.effort_default{i} ;
                compound_flow_default{counter} = compound_domain.flow_default{i} ;
            end
        end
        
        depth = length(compound_effort) ;
        for n = 1:depth-1
            mttAssert(~ismember(compound_effort{n},{compound_effort{n+1:depth}}),...
                ['Repeated effort variable "',compound_effort{n},'" in domain ',domain_shortname]) ;
            mttAssert(~ismember(compound_flow{n},{compound_flow{n+1:depth}}),...
                ['Repeated flow variable "',compound_flow{n},'" in domain ',domain_shortname]) ;
        end
        
        for n = 1:depth
            mttAssert(~ismember(compound_effort{n},{compound_flow{1:depth}}),...
                ['Ambiguous effort/flow variable "',compound_effort{n},'" in domain ',domain_shortname]) ;
            mttAssert(~ismember(compound_flow{n},{compound_effort{1:depth}}),...
                ['Ambiguous flow/effort variable "',compound_flow{n},'" in domain ',domain_shortname]) ;
        end
        
        mttAssert(~ismember('flow',{compound_effort{1:depth}}),...
            ['Effort variable called "flow" in domain ',domain_shortname]) ;
        mttAssert(~ismember('effort',{compound_flow{1:depth}}),...
            ['flow variable called "effort" in domain ',domain_shortname]) ;
        
		compound_item.effort = compound_effort ;
        compound_item.flow = compound_flow ;
        
		compound_item.effort_default = compound_effort_default ;
		compound_item.flow_default = compound_flow_default ;
    end
	

Deleted mttroot/ntt/bin/trans/m/mttIdentifyStructVariables.m version [69b4827ac5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function compound_item = mttIdentifyStructVariables(item,struct,model)
	structs = mttGetFieldNames(model,'struct') ;
	
	struct_name = struct.source ;
    struct_shortname = mttDetachText(struct_name,'/') ;
    
    item_names = mttGetFieldNames(struct,'item') ;
	
    number_of_vars = mttGetFieldLength(item,'var') ;
    
    counter = 0 ;
    for k = 1:number_of_vars
        var = item.var(k) ;
        
        next_item = var.type ;
        if isempty(next_item)
            counter = counter + 1 ;
            compound_var{counter} = var.name ;
        else
            mttAssert(ismember(next_item,item_names),...
                ['Unrecognised reference "',next_item,'" in struct ',struct_shortname]) ;
            
            dependent_item = getfield(struct,'item',next_item) ;
            compound_struct = mttIdentifyStructVariables(dependent_item,struct,model) ;
            
            for i = 1:length(compound_struct.var)
                counter = counter + 1 ;
                compound_var{counter} = [var.name,'.',compound_struct.var{i}] ;
            end
        end
        
        variables = length(compound_var) ;
        for n = 1:variables-1 ;
            mttAssert(~ismember(compound_var{n},{compound_var{n+1:variables}}),...
                ['Repeated variable "',compound_var{n},'" in struct ',struct_shortname]) ;
        end
        
		compound_item.var = compound_var ;
    end
	

Deleted mttroot/ntt/bin/trans/m/mttParseOperatorEquations.m version [aba93f30d1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318






























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function operator = mttParseOperatorEquations(operator,cr,cr_name)
global mtt_environment

    operator.equation = [] ;
%    operator.is_used = 0 ;

	numparlist = cr.numpar ;
	symparlist = cr.sympar ;
	varlist    = operator.var ;
	inputlist  = cr.input ;
	statelist  = cr.state ;
    
    structlist = [] ;
    if ~isempty(operator.struct)
        struct_names = mttGetFieldNames(operator,'struct') ;
        number_of_structs = length(struct_names) ;
        for i = 1:number_of_structs
            struct_name = struct_names{i} ;
            variables = getfield(operator,'struct',struct_name) ;
            if i==1
                structlist = variables ;
            else
                structlist = [structlist,variables] ;
            end
        end
    end
    
    
    inlist = [] ;
    outlist = [] ;
    inlink = [] ;
    outlink = [] ;
    
    input_counter = 0 ;
    output_counter = 0 ;
    
    for i = 1:length(operator.link)
        if operator.link(i).is_input
            input_counter = input_counter + 1 ;
            inlist{input_counter} = operator.link(i).name ;
            inlink(input_counter) = i ;
            infree(input_counter) = operator.link(i).is_unconstrained ;
        else
            output_counter = output_counter + 1 ;
            outlist{output_counter} = operator.link(i).name ;
            outlink(output_counter) = i ;
            outfree(output_counter) = operator.link(i).is_unconstrained ;
        end
    end
    
    
    operator.assign = [] ;
    ports_with_state_assignment = [] ;
        
    for i = 1:length(operator.set)
        [port_covariable,state] = mttCutText(operator.set{i},'=>') ;
        mttAssert(~isempty(state),...
            ['"set" declarations must use "=>" in cr ',cr_name]) ;
        
        [port_name,covariable] = mttCutText(port_covariable,'.') ;
        mttAssert(~isempty(covariable),...
            ['"set" declarations must reference effort/flow covariables in cr ',cr_name]) ;
        
        port = strmatch(port_name,outlist,'exact') ;
        ports_with_state_assignment = [ports_with_state_assignment,port] ;
        
        mttAssert(~isempty(port),...
            ['Output port "',port_name,'" not recognised for "set" declaration in cr ',cr_name]) ;
        mttAssert(outfree(port),...
            ['Constrained port variable used for "set" declaration in cr ',cr_name]) ;
        
        actual_port = getfield(cr.interface.port,port_name) ;
        mttAssert(actual_port.is_effort_state | actual_port.is_flow_state,...
            ['"set" declarations must only be used for effort_states or flow_states in cr ',cr_name]) ;
        
        if isempty(actual_port.domain)
            if actual_port.is_effort_state
                covariables = {'effort'} ;
            elseif actual_port.is_flow_state
                covariables = {'flow'} ;
            end
        else
            public_domain = mtt_environment.public_domain(actual_port.domain) ;
            domain_item = getfield(public_domain.item,actual_port.domain_item) ;
            
            if actual_port.is_effort_state
                covariables = domain_item.effort ;
            elseif actual_port.is_flow_state
                covariables = domain_item.flow ;
            end
        end
        
        index = strmatch(covariable,covariables,'exact') ;
        mttAssert(~isempty(index),...
            ['Unrecognised covariable "',covariable,'" used for "set" declaration in cr ',cr_name]) ;
        
        if isfield(operator.assign,port_name)
            assignment = getfield(operator,'assign',port_name) ;
            mttAssert(isempty(assignment.states{index}),...
                ['Repeated covariable "',covariable,'" used for "set" declaration in cr ',cr_name]) ;
        else
            assignment.covar = covariables ;
            assignment.state{length(covariables)} = [] ;
%            assignment.domain = actual_port.domain ;
%            assignment.domain_item = actual_port.domain_item ;
        end
        
        mttAssert(ismember(state,cr.state),...
            ['Unrecognised state "',state,'" used for "set" declaration in cr ',cr_name]) ;
        
        assignment.state{index} = state ;
        operator = setfield(operator,'assign',port_name,assignment) ;
    end
    operator = mttDeleteField(operator,'set') ;
    
    
    port_assignments = mttGetFieldNames(operator,'assign') ;
    number_of_assignments = length(port_assignments) ;
    for i = 1:number_of_assignments
        assignment = getfield(operator,'assign',port_name) ;
        for j = 1:length(assignment.state)
            mttAssert(~isempty(assignment.state{j}),...
                ['Missing covariable "',covariable,'" from "set" declaration in cr ',cr_name]) ;
        end
    end
        
        
    for i = 1:length(operator.content)
        operator.equation(i).chunk = {[]} ;
%        operator.equation(i).was_generic = 1 ;
%        operator.equation(i).domain = [] ;
%        operator.equation(i).domain_item = [] ;
%        operator.equation(i).is_effort = [] ;
%        operator.equation(i).covariable = [] ;
        
        counter = 0 ;
        
        line = operator.content{i} ;
        
        if ~isempty(mttClipText(line))
            [var,loc] = mttFindEquationVariables(line) ;
            
            if loc(1)>1
                front = line(1:loc(1)-1) ;
                counter = counter + 1 ;
                operator.equation(i).chunk{counter} = front ;
            end
            
            last = length(line) ;
            
            for j = 1:length(var)
                [name,component] = mttCutText(var{j},'.') ;
                
                if isempty(component)
                    [name,attribute] = mttCutText(name,'''') ;
                    
                    numpar = strmatch(name,numparlist,'exact') ;
                    sympar = strmatch(name,symparlist,'exact') ;
                    variable = strmatch(name,varlist,'exact') ;
                    struct = strmatch(name,structlist,'exact') ;
                    input = strmatch(name,inputlist,'exact') ;
                    state = strmatch(name,statelist,'exact') ;
                    
                    ok = ~(isempty(numpar)&isempty(sympar)&isempty(variable)&isempty(struct)&isempty(input)&isempty(state)) ;
                    mttAssert(ok,['Variable ',var{j},' not recognised in cr ',cr_name]) ;
                    
                    is_numpar = ~isempty(numpar) ;
                    is_sympar = ~isempty(sympar) ;
                    is_var    = ~isempty(variable) ;
                    is_struct = ~isempty(struct) ;
                    is_input  = ~isempty(input) ;
                    is_state  = ~isempty(state) ;
                    is_derivative = 0 ;
                    
                    if ~isempty(attribute)
                        mttAssert(strcmp(attribute,'dt'),...
                            ['Unrecognised attribute ',attribute,' in cr ',cr_name]) ;
                        mttAssert(is_state,...
                            ['Derivative of non-state variable in cr ',cr_name]) ;
                        is_state = 0 ;
                        is_derivative = 1 ;
                    end
                    
                    counter = counter + 1 ;
                    
                    if is_numpar
                        operator.equation(i).chunk{counter} = {'numpar',numpar} ;
                    end
                    
                    if is_sympar
                        operator.equation(i).chunk{counter} = {'sympar',sympar} ;
                    end
                    
                    if is_var
                        operator.equation(i).chunk{counter} = {'var',variable} ;
                    end
                    
                    if is_struct
                        operator.equation(i).chunk{counter} = {'struct',struct} ;
                    end
                    
                    if is_input
                        operator.equation(i).chunk{counter} = {'input',input} ;
                    end
                    
                    if is_state
                        operator.equation(i).chunk{counter} = {'state',state} ;
                    end
                    
                    if is_derivative
                        operator.equation(i).chunk{counter} = {'derivative',state} ;
                    end
                    
                else
                    
                    if j==1
                        port = strmatch(name,outlist,'exact') ;
                        
                        if ~isempty(ports_with_state_assignment)
                            mttAssert(~any(port==ports_with_state_assignment),...
                                ['Use "set" declaration to assign output port ',name,' to state in cr ',cr_name]) ;
                        end
                        
                        mttAssert(~isempty(port),...
                            ['Output port ',name,' not recognised in cr ',cr_name]) ;
                        mttAssert(outfree(port),...
                            ['Constrained port variable used in cr ',cr_name]) ;
                        
                        counter = counter + 1 ;
                        operator.equation(i).chunk{counter} = {'link',outlink(port),component} ;
                    else
                        port = strmatch(name,inlist,'exact') ;
                        mttAssert(~isempty(port),...
                            ['Input port ',name,' not recognised in cr ',cr_name]) ;
                        mttAssert(infree(port),...
                            ['Constrained port variable used in cr ',cr_name]) ;
                        
                        counter = counter + 1 ;
                        operator.equation(i).chunk{counter} = {'link',inlink(port),component} ;
                    end
                    
                    
%                    equation_domain = mttIdentifyUserDomain(mtt_environment,...
%                        operator.equation(i).domain,....
%                        operator.equation(i).domain_item) ;
                    
                    covariable = component ;
                    port_name = name ;
                    port = getfield(cr.interface.port,port_name) ;
                    
                    if isempty(port.domain)
                        is_effort = strcmp(covariable,'effort') ;
                        is_flow = strcmp(covariable,'flow') ;
                        
                        mttAssert(is_effort|is_flow, ...
                            ['"',covariable,'" is not a generic covariable']) ;
                        
%                        mttAssert(isempty(operator.equation(i).domain),...
%                            ['Generic interface "',port_name,'" referenced in ',equation_domain,' equation']) ;
                    else
                        public_domain = mtt_environment.public_domain(port.domain) ;
                        actual_domain = getfield(public_domain,'item',port.domain_item) ;
                        
                        port_domain = mttIdentifyUserDomain(mtt_environment,port.domain,port.domain_item) ;
                        
                        is_effort = ismember(covariable,actual_domain.effort) ;
                        is_flow = ismember(covariable,actual_domain.flow) ;
                        
                        mttAssert(is_effort|is_flow, ...
                            ['"',covariable,'" is not a covariable defined in domain "',port_domain,'"']) ;
                        
%                        if isempty(equation_domain)
%                            operator.equation(i).was_generic = 0 ;
%                            operator.equation(i).domain = port.domain ;
%                            operator.equation(i).domain_item = port.domain_item ;
                            %                        operator.equation(i).covariable = covariable ;
                            %                    else
                            %                        mttAssert(covariable==operator.equation(i).covariable, ...
                            %                            ['Equation cannot combine different covariables: [',covariable,',',operator.equation(i).covariable,']') ;
%                        end
                    end
                    
%                    if isempty(operator.equation(i).is_effort)
%                        if is_effort
%                            operator.equation(i).is_effort = 1 ;
%                        else
%                            operator.equation(i).is_effort = 0 ;
%                        end
%                    else
%                        mttAssert(operator.equation(i).is_effort==is_effort,...
%                            ['Effort and flow covariables appear in equation: "',operator.content{i},'"']) ;
%                    end
                end
                
                next = loc(j) + length(var{j}) ;
                
                if j<length(var)
                    glue = line(next:loc(j+1)-1) ;
                    
                    counter = counter + 1 ;
                    operator.equation(i).chunk{counter} = glue ;
                    
                    if j==1
                        mttAssert(~isempty(findstr(glue,':=')),...
                            ['Expect ":=" after first variable in cr ',cr_name]) ;
                    end
                else
                    if next<=last
                        back = line(next:last) ;
                        
                        counter = counter + 1 ;
                        operator.equation(i).chunk{counter} = back ;
                    end
                end
            end
        end
    end
    

Deleted mttroot/ntt/bin/trans/m/mttPropagateCausality.m version [3db1dcaa36].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180




















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttPropagateCausality(model,branch)
    is_root_model = (nargin==1) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if is_root_model
            branch = mttDetachText(model.source,'/') ;
        end
        here = [branch,':',object_name] ;
        
        if isfield(object,'obj')
            
            for i = 1:mttGetFieldLength(object,'interface')
                port_name = object.interface(i).name ;
                
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                inmap = object.interface(i).map.in ;
                outmap = object.interface(i).map.out ;
                
                [inbond_effort,inbond_flow,inbond_unicausal] = mttGetBondCausality(model,inbond) ;
                [outbond_effort,outbond_flow,outbond_unicausal] = mttGetBondCausality(model,outbond) ;
                [inmap_effort,inmap_flow,inmap_unicausal] = mttGetBondCausality(object,inmap) ;
                [outmap_effort,outmap_flow,outmap_unicausal] = mttGetBondCausality(object,outmap) ;
                
                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,inmap_effort,inmap_flow,inmap_unicausal) ; 
                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,outmap_effort,outmap_flow,outmap_unicausal) ; 
                [object,inmap_ok] = mttUpdateBondCausality(object,inmap,inbond_effort,inbond_flow,inbond_unicausal) ; 
                [object,outmap_ok] = mttUpdateBondCausality(object,outmap,outbond_effort,outbond_flow,outbond_unicausal) ; 
                
                ok = inbond_ok & outbond_ok & inmap_ok & outmap_ok ;
                mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
            end
            
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttPropagateCausality(object,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        else
            number_of_interfaces = mttGetFieldLength(object,'interface') ;
            
            switch object.class
            case {'Se','Sf','De','Df'}
                for i = 1:number_of_interfaces
                    port_name = object.interface(i).name ;
                    
                    inbond = object.interface(i).in ;
                    outbond = object.interface(i).out ;
                    
                    mttAssert(xor(isempty(inbond),isempty(outbond)),...
                        ['"',object.class,'" objects must have exactly one attached bond in ',here]) ;
                    
                    switch object.class
                    case {'Se','De'},
                        [model,ok] = mttUpdateBondCausality(model,outbond,[],1,1) ; % Constraint
                        [model] = mttUpdateBondCausality(model,outbond,1,[],1) ; 	% Preference
                    case {'Sf','Df'},
                        [model,ok] = mttUpdateBondCausality(model,outbond,0,[],1) ; % Constraint
                        [model] = mttUpdateBondCausality(model,outbond,[],0,1) ; 	% Preference
                    end
                    
                    mttAssert(ok,['Causal constraint violation at port "',port_name,'" in ',here]) 
                end
                
            case '0',
                mttAssert(number_of_interfaces>1,...
                    ['Less than two interfaces at 0-junction ',here]) ;
                
                imposed_effort = [] ;
                resultant_flow = [] ;
                
                for j = 1:number_of_interfaces
                    inbond = object.interface(j).in ;
                    outbond = object.interface(j).out ;
                    
                    if isempty(inbond)
                        bond(j) = outbond ;
                        orientation(j) = 0 ;
                    else
                        bond(j) = inbond ;
                        orientation(j) = 1 ;
                    end
                    
                    [effort,flow,unicausal] = mttGetBondCausality(model,bond(j)) ;
                    
                    if ~isempty(effort)
	                    if effort==orientation(j)
		                    mttAssert(isempty(imposed_effort),...
    	                        ['Over-determined effort at 0-junction ',here]) ;
                            imposed_effort = bond(j) ;
                        end
                    end
                    
                    if ~isempty(flow)
	                    if flow==orientation(j)
		                    mttAssert(isempty(resultant_flow),...
    	                        ['Over-determined flow at 0-junction ',here]) ;
                            resultant_flow = bond(j) ;
                        end
                    end
                end
                
                for j = 1:number_of_interfaces
                    if ~isempty(imposed_effort)
                        if bond(j)~=imposed_effort
                            model = mttUpdateBondCausality(model,bond(j),~orientation(j),[],[]) ;
                        end
                    end
                    
                    if ~isempty(resultant_flow)
                        if bond(j)~=resultant_flow
                            model = mttUpdateBondCausality(model,bond(j),[],~orientation(j),[]) ;
                        end
                    end
                end
                
            case '1',
                mttAssert(number_of_interfaces>1,...
                    ['Less than two interfaces at 1-junction ',here]) ;
                
                imposed_flow = [] ;
                resultant_effort = [] ;
                
                for j = 1:number_of_interfaces
                    inbond = object.interface(j).in ;
                    outbond = object.interface(j).out ;
                    
                    if isempty(inbond)
                        bond(j) = outbond ;
                        orientation(j) = 0 ;
                    else
                        bond(j) = inbond ;
                        orientation(j) = 1 ;
                    end

                    [effort,flow,unicausal] = mttGetBondCausality(model,bond(j)) ;
                    
                    if ~isempty(effort)
	                    if effort~=orientation(j)
		                    mttAssert(isempty(resultant_effort),...
    	                        ['Over-determined effort at 1-junction ',here]) ;
                            resultant_effort = bond(j) ;
                        end
                    end
                    
                    if ~isempty(flow)
	                    if flow~=orientation(j)
		                    mttAssert(isempty(imposed_flow),...
    	                        ['Over-determined flow at 1-junction ',here]) ;
                            imposed_flow = bond(j) ;
                        end
                    end
                end
                
                for j = 1:number_of_interfaces
                    if ~isempty(resultant_effort)
                        if bond(j)~=resultant_effort
                            model = mttUpdateBondCausality(model,bond(j),orientation(j),[],[]) ;
                        end
                    end
                    
                    if ~isempty(imposed_flow)
                        if bond(j)~=imposed_flow
                            model = mttUpdateBondCausality(model,bond(j),[],orientation(j),[]) ;
                        end
                    end
                end
            end
        end
    end
    

Deleted mttroot/ntt/bin/trans/m/mttPropagateDomains.m version [01ad4b747a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttPropagateDomains(model,branch)
    is_root_model = (nargin==1) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if is_root_model
            branch = mttDetachText(model.source,'/') ;
        end
        here = [branch,':',object_name] ;
        
        if ~isempty(object.abg)
            
            for j = 1:mttGetFieldLength(object,'interface')
			    port_name = object.interface(j).name ;
                
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                inmap = object.interface(j).map.in ;
                outmap = object.interface(j).map.out ;
                
                [inbond_domain,inbond_domain_item]   = mttGetBondDomain(model,inbond) ;
                [outbond_domain,outbond_domain_item] = mttGetBondDomain(model,outbond) ;
                [inmap_domain,inmap_domain_item]     = mttGetBondDomain(object,inmap) ;
                [outmap_domain,outmap_domain_item]   = mttGetBondDomain(object,outmap) ;
                
                [model,inbond_ok]  = mttUpdateBondDomain(model,inbond,inmap_domain,inmap_domain_item) ; 
                [model,outbond_ok] = mttUpdateBondDomain(model,outbond,outmap_domain,outmap_domain_item) ; 
                [object,inmap_ok]  = mttUpdateBondDomain(object,inmap,inbond_domain,inbond_domain_item) ; 
                [object,outmap_ok] = mttUpdateBondDomain(object,outmap,outbond_domain,outbond_domain_item) ;
                
                ok = inbond_ok & outbond_ok & inmap_ok & outmap_ok ;
                mttAssert(ok,['Domain conflict at port "',port_name,'" in ',here]) ;
            end
            
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttPropagateDomains(object,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        elseif ~isempty(object.cr)
            
            interface = object.cr.interface ;
            port_names = mttGetFieldNames(interface,'port') ;            
            
            for j = 1:length(port_names)
                port_name = port_names{j} ;
                port = getfield(interface,'port',port_name) ;
                
                inbond = port.in ;
                outbond = port.out ;
                
                [model,inbond_ok]  = mttUpdateBondDomain(model,inbond,port.domain,port.domain_item) ;
                [model,outbond_ok] = mttUpdateBondDomain(model,outbond,port.domain,port.domain_item) ; 
                
                ok = inbond_ok & outbond_ok ;
                mttAssert(ok,['Domain conflict at port "',port_name,'" in ',here]) ;
            end
            
        else
            
            number_of_interfaces = mttGetFieldLength(object,'interface') ;
            
            switch object.class
            case {'0','1'},
                index = 0 ;
                finding_domain = 1 ;
                
                while finding_domain
                    index = index + 1 ;
                
                    inbond = object.interface(index).in ;
                    outbond = object.interface(index).out ;
                    
                    if isempty(inbond)
                        bond_number = outbond ;
                    else
                        bond_number = inbond ;
                    end
                    
                    [existing_domain,existing_domain_item] = mttGetBondDomain(model,bond_number) ;
                
                    found_domain = ~isempty(existing_domain) ;
                    finding_domain = ~found_domain & index<number_of_interfaces ;
                end
                
                if found_domain
                    for j = 1:number_of_interfaces
                        inbond = object.interface(j).in ;
                        outbond = object.interface(j).out ;
                        
                        if isempty(inbond)
                            bond_number = outbond ;
                        else
                            bond_number = inbond ;
                        end
                    
                        model = mttUpdateBondDomain(model,bond_number,existing_domain,existing_domain_item) ;
                    end
                end
            end
        end
    end
    

Deleted mttroot/ntt/bin/trans/m/mttWriteSystemApps.m version [d508925095].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttWriteSystemApps(model)
	if ~isfield(model,'app')
    	return ;
	end

    filename = [model.source,'_include_apps.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Applications for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    fprintf(fid,'\n\n') ;
    
    for i = 1:length(model.app)
        app_inclusion = ['#include "',model.app{i},'"\n'] ;
        fprintf(fid,app_inclusion) ;
    end
    
    fclose(fid) ;

Deleted mttroot/ntt/bin/trans/m/mttWriteSystemDefinitions.m version [b4ee230811].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582






































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttWriteSystemDefinitions(model)

def.structure = define_data_structures(model) ;
def.covar     = define_bond_covariables(model) ;
def.var       = define_interface_covariables(model) ;
def.sympar    = define_symbolic_parameters(model) ;
def.numpar    = define_numerical_parameters(model) ;
def.input     = define_input_variables(model) ;
def.state     = define_state_variables(model) ;
def.opvar     = define_operator_variables(model) ;

write_definitions(def,model) ;


function code = define_data_structures(model)
    mttNotify('...defining data structures') ;
    mttWriteNewLine ;
    
    code = [] ;
    line = 0 ;
    
    tab = char(32*ones(1,3)) ;
    
    line = line + 1 ;
    code{line} = ['typedef struct {'] ;
    
    line = line + 1 ;
    code{line} = [tab,'double state,derivative ;'] ;
    
    line = line + 1 ;
    code{line} = ['} mttState ;'] ;
    
    line = line + 1 ;
    code{line} = '' ;
    
    line = line + 1 ;
    code{line} = ['typedef struct {'] ;
    
    line = line + 1 ;
    code{line} = [tab,'double effort,flow ;'] ;
    
    line = line + 1 ;
    code{line} = ['} mttGenericDomain ;'] ;
    
    line = line + 1 ;
    code{line} = '' ;
    
    domain_names = mttGetFieldNames(model.env,'domain') ;
    for i = 1:length(domain_names)
        domain_name = domain_names{i} ;
        domain = getfield(model.env,'domain',domain_name) ;
        
        public_domain = model.env.public_domain(domain.dom) ;
        item_names = mttGetFieldNames(public_domain,'item') ;
        
        if isempty(domain.item)
            first = 1 ;
            last = length(item_names) ;
        else
            first = strmatch(domain.item,item_names,'exact') ;
            last = first ;
        end
        
        for j = first:last
            item_name = item_names{j} ;
            covariables = getfield(public_domain,'item',item_name) ;
            
            line = line + 1 ;
            code{line} = ['typedef struct {'] ;
            
            for k = 1:length(covariables.effort)
                line = line + 1 ;
                effort_covariable = strrep(covariables.effort{k},'.','__') ;
                flow_covariable = strrep(covariables.flow{k},'.','__') ;
                code{line} = [tab,'double ',effort_covariable,',',flow_covariable,' ;'] ;
            end
            
            definition = ['} mttDomain__',domain_name] ;
            if isempty(domain.item)
                definition = [definition,'__',item_name] ;
            end
            definition = [definition,' ;'] ;
            
            line = line + 1 ;
            code{line} = definition ;
            
            if j<last
                line = line + 1 ;
                code{line} = '' ;
            end
        end
        
        line = line + 1 ;
        code{line} = '' ;
    end

    struct_names = mttGetFieldNames(model.env,'struct') ;
    for i = 1:length(struct_names)
        struct_name = struct_names{i} ;
        struct = getfield(model.env,'struct',struct_name) ;
        
        public_struct = model.env.public_struct(struct.str) ;
        item_names = mttGetFieldNames(public_struct,'item') ;
        
        index = strmatch(struct.item,item_names,'exact') ;
        
        item_name = item_names{index} ;
        variables = getfield(public_struct,'item',item_name,'var') ;
        
        line = line + 1 ;
        code{line} = ['typedef struct {'] ;
        
        for k = 1:length(variables)
            line = line + 1 ;
            variable = strrep(variables{k},'.','__') ;
            code{line} = [tab,'double ',variable,' ;'] ;
        end
        
        definition = ['} ',struct_name,' ;'] ;
        
        line = line + 1 ;
        code{line} = definition ;
        
        if i<length(struct_names)
            line = line + 1 ;
            code{line} = '' ;
        end
    end


function code = define_bond_covariables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining bond covariables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    width = 0 ;
    domain_names = mttGetFieldNames(root.env,'domain') ;
    for j = 1:length(domain_names)
        domain_name = domain_names{j} ;
        width = max(width,length(domain_name)) ;
    end
    
    code = [] ;
    line = 0 ;
    
    number_of_bonds = mttGetFieldLength(model,'bond') ;
    for i = 1:number_of_bonds
        current_bond = model.bond(i) ;
        
        specified_domain = current_bond.domain ;
        specified_domain_item = current_bond.domain_item ;
        
        user_domain_identification = mttIdentifyUserDomain(root.env,specified_domain,specified_domain_item) ;
        
        if isempty(user_domain_identification)
            data_structure = ['mttGenericDomain'] ;
        else
            data_structure = ['mttDomain__',user_domain_identification] ;
        end
        
        nominal_width = 14 + width ;
        actual_width = length(data_structure) ;
        gap = nominal_width - actual_width ;
        
        whitespace = char(32*ones(1,gap+3)) ;
        
        line = line + 1 ;
        code{line} = [data_structure,whitespace,current_branch,'__',num2str(i),' ;'] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~isempty(object.abg)
            next_branch = [current_branch,'__',object_name] ;
            additional_code = define_bond_covariables(object,root,next_branch) ;
            
            if isempty(code)
                code = additional_code ;
            else
                code = [code,additional_code] ;
            end
        end
    end
    
    if line==0
        code = [] ;
    end
    
    
function code = define_interface_covariables(model)
	mttNotify('...defining interface covariables') ;
    mttWriteNewLine ;
    
    width = 0 ;
    domain_names = mttGetFieldNames(model.env,'domain') ;
    for j = 1:length(domain_names)
        domain_name = domain_names{j} ;
        width = max(width,length(domain_name)) ;
    end
    
    code = [] ;
    line = 0 ;
    
    previous_name = model.namelist(1).var ;
    
    number_of_variables = mttGetFieldLength(model,'namelist') ;
    for i = 2:number_of_variables   % .... first variable is reserved !
        variable_name = model.namelist(i).var ;
        [variable_name,extension] = mttCutText(variable_name,'.') ;

        if ~strcmp(variable_name,previous_name)
            previous_name = variable_name ;
            
            specified_domain = model.namelist(i).domain ;
            specified_domain_item = model.namelist(i).domain_item ;
            
            user_domain_identification = mttIdentifyUserDomain(model.env,specified_domain,specified_domain_item) ;

            if isempty(user_domain_identification)
                data_structure = ['mttGenericDomain'] ;
            else
                data_structure = ['mttDomain__',user_domain_identification] ;
            end
            
            nominal_width = 14 + width ;
            actual_width = length(data_structure) ;
            gap = nominal_width - actual_width ;
            
            whitespace = char(32*ones(1,gap+3)) ;
            
            line = line + 1 ;
            code{line} = [data_structure,whitespace,variable_name,' ;'] ;
        end
    end
    

function code = define_symbolic_parameters(model)
	mttNotify('...defining symbolic parameters') ;
    mttWriteNewLine ;

    model_name = mttDetachText(model.source,'/') ;
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default_value = model.sympar_default{i} ;
        
        whitespace = char(32*ones(1,3)) ;
        
        if isempty(default_value)
            line = line + 1 ;
            code{line} = ['double',whitespace,model_name,'___',variable_name,' ;'] ;
        end
    end
    
    
function code = define_numerical_parameters(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining numerical parameters') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'numpar') ;
    for i = 1:number_of_variables
        variable_name = model.numpar{i} ;
        
        whitespace = char(32*ones(1,3)) ;
        
        line = line + 1 ;
        code{line} = ['double',whitespace,current_branch,'___',variable_name,' ;'] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = define_numerical_parameters(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = define_numerical_parameters(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = define_input_variables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining input variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        
        whitespace = char(32*ones(1,3)) ;
        
        line = line + 1 ;
        code{line} = ['double',whitespace,current_branch,'___',variable_name,' ;'] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = define_input_variables(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = define_input_variables(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = define_state_variables(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining state variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end
    
    whitespace = char(32*ones(1,3)) ;
        
    code = [] ;
    line = 0 ;
    
    if isfield(model,'state')
        assigned_states = [] ;
        counter = 0 ;
        
        port_names = mttGetFieldNames(model.interface,'port') ;
        for j = 1:length(port_names)
            port_name = port_names{j} ;
            port = getfield(model,'interface','port',port_name) ;
            
            if ~isempty(port.assign)
                assignment = port.assign ;
                
                if port.was_generic & ~isempty(port.domain)
                    covariables = mttGetCovariables(env,port.domain,port.domain_item) ;
                    if port.is_effort_state
                        covar = covariables.effort ;
                    else
                        covar = covariables.flow ;
                    end
                    
                    block_size = length(covar) ;
                    for k = 1:length(assignment.state)
                        counter = counter + 1 ;
                        assigned_states{counter} = assignment.state{k} ;
                        
                        for var = 1:block_size
                            line = line + 1 ;
                            code{line} = ['mttState',whitespace,current_branch,'___',assignment.state{k},'___',covar{var},' ;'] ;
                        end                        
                    end
                end
            end
        end
        
        number_of_variables = mttGetFieldLength(model,'state') ;
        for i = 1:number_of_variables
            variable_name = model.state{i} ;
            
            if ~ismember(variable_name,assigned_states)
                line = line + 1 ;
                code{line} = ['mttState',whitespace,current_branch,'___',variable_name,' ;'] ;
            end
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = define_state_variables(object,root,next_branch,env) ;
        elseif ~isempty(object.cr)
            additional_code = define_state_variables(object.cr,root,next_branch,env) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
 
    
function code = define_operator_variables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining operator variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        if ~isempty(object.abg)
            additional_code = define_operator_variables(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            line = 0 ;
            additional_code = [] ;
            
            number_of_operators = mttGetFieldLength(object.cr,'operator') ;
            for j = 1:number_of_operators
                operator = object.cr.operator(j) ;
                
                number_of_vars = mttGetFieldLength(operator,'var') ;
                for k = 1:number_of_vars
                    variable_name = operator.var{k} ;
                    
                    whitespace = char(32*ones(1,3)) ;
                    
                    line = line + 1 ;
                    prefix = [next_branch,'___',operator.name] ;
                    additional_code{line} = ['double',whitespace,prefix,'___',variable_name,'      = 0.0 ;'] ;
                end
                
                struct_names = mttGetFieldNames(operator,'struct') ;
                number_of_structs = length(struct_names) ;
                for k = 1:number_of_structs
                    struct_name = struct_names{k} ;
                    variables = getfield(operator,'struct',struct_name) ;
                    
                    for kv = 1:length(variables)
                        variable_name = variables{kv} ;
                        
                        whitespace = char(32*ones(1,3)) ;
                        
                        line = line + 1 ;
                        prefix = [next_branch,'___',operator.name] ;
                        additional_code{line} = [struct_name,whitespace,prefix,'___',variable_name,' ;'] ;
                    end
                end
            end
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function write_definitions(def,model)
    filename = [model.source,'_include_def.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Definitions for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    write_definitive_list(fid,'data_structures',def.structure) ;
    write_definitive_list(fid,'bond_covariables',def.covar) ;
    write_definitive_list(fid,'interface_covariables',def.var) ;
    write_definitive_list(fid,'symbolic_parameters',def.sympar) ;
    write_definitive_list(fid,'numerical_parameters',def.numpar) ;
    write_definitive_list(fid,'input_variables',def.input) ;
    write_definitive_list(fid,'state_variables',def.state) ;
    write_definitive_list(fid,'operator_variables',def.opvar) ;
   
    fclose(fid) ;
    
    
function write_definitive_list(fid,var_type,var_list)
    if ~isempty(var_list)
        fprintf(fid,'\n\n') ;
        fprintf(fid,['// ',var_type]) ;
        fprintf(fid,'\n') ;
        
        tab = char(32*ones(1,3)) ;
        for i = 1:length(var_list)
            formatted_declaration = [tab,var_list{i},'\n'] ;
            fprintf(fid,formatted_declaration) ;
        end
    end

Deleted mttroot/ntt/bin/trans/m/mttWriteSystemEquations.m version [6eecd251a9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509





























































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttWriteSystemEquations(model)

[eqn,ini] = format_equations(model) ;
write_equations(eqn,ini,model) ;


function [eqn,ini] = format_equations(model)
    mttNotify('...formating ordinary differential equations') ;
    mttWriteNewLine ;
    
    sse = model.equation ;
    namelist = model.namelist ;
    
    tab = char(32*ones(1,3)) ;
                
    eqn_counter = 0 ;
    ini_counter = 0 ;
    
    eqn = [] ;
    ini = [] ;
    
    for i = 1:length(sse)
        content = [] ;
        indent = 0 ;
        
        if isempty(sse(i).operator)
            Lvar = sse(i).var.LHS ;
            Rvar = sse(i).var.RHS ;
            
            if isnumeric(Lvar) | isnumeric(Rvar)
                if isnumeric(Lvar)
                    name = sse(i).branch.LHS ;
                    if mod(Lvar,2)
                        bond_number = (Lvar+1)/2 ;
                    else
                        bond_number = Lvar/2 ;
                    end
                else
                    name = sse(i).branch.RHS ;
                    if mod(Rvar,2)
                        bond_number = (Rvar+1)/2 ;
                    else
                        bond_number = Rvar/2 ;
                    end
                end
                
                [hierarchy,interface] = mttCutText(name,'___') ;
                level = length(findstr(hierarchy,'__')) ;
                
                [root,hierarchy] = mttCutText(hierarchy,'__') ;
                for j = 1:level
                    [obj{j},hierarchy] = mttCutText(hierarchy,'__') ;
                end
                
                if level==0
                    local_object = model ;
                else
                    local_object = getfield(model,'obj',obj{1}) ;
                    for j = 2:level
                        local_object = getfield(local_object,'obj',obj{j}) ;
                    end
                end
                
                [specified_domain,specified_domain_item] = mttGetBondDomain(local_object,bond_number) ;
                
            else
                [name,covar] = mttCutText(namelist(Lvar{1}).var,'.') ;
                [hierarchy,interface] = mttCutText(name,'___') ;
                level = length(findstr(hierarchy,'__')) ;
                
                [root,hierarchy] = mttCutText(hierarchy,'__') ;
                for j = 1:level
                    [obj{j},hierarchy] = mttCutText(hierarchy,'__') ;
                end
                
                parent_object = model ;
                object = getfield(model,'obj',obj{1}) ;
                
                for j = 2:level
                    parent_object = object ;
                    object = getfield(object,'obj',obj{j}) ;
                end
                
                index = strmatch(interface,{object.interface.name},'exact') ;
                interface_definition = object.interface(index) ;
                
                if isempty(interface_definition.in)
                    bond_number = interface_definition.out ;
                else
                    bond_number = interface_definition.in ;
                end
                
                [specified_domain,specified_domain_item] = mttGetBondDomain(parent_object,bond_number) ;
            end
            
            covariables = mttGetCovariables(model.env,specified_domain,specified_domain_item) ;
            
            dimension = length(covariables.effort) ;
            
            
            
            var = sse(i).var.LHS ;
            branch = sse(i).branch.LHS ;
            
            LHS.name = [] ;
            LHS.is_effort = [] ;
            
            switch class(var)
            case 'double',
                if mod(var,2)
%                    LHS.name = [branch,'[',num2str((var+1)/2),']'] ;
                    LHS.name = [branch,'__',num2str((var+1)/2)] ;
                    LHS.is_effort = 1 ;
                else
%                    LHS.name = [branch,'[',num2str(var/2),']'] ;
                    LHS.name = [branch,'__',num2str(var/2)] ;
                    LHS.is_effort = 0 ;
                end
            case 'cell',
                [name,covar] = mttCutText(namelist(var{1}).var,'.') ;
                LHS.name = name ;
                
                if strcmp(covar,'effort')
                    LHS.is_effort = 1 ;
                else
                    LHS.is_effort = 0 ;
                end
            end
            
            
            var = sse(i).var.RHS ;
            branch = sse(i).branch.RHS ;
            
            RHS.name = [] ;
            RHS.is_effort = [] ;
            
            
            switch class(var)
            case 'double',
                if mod(abs(var(1)),2)
%                    RHS.name{1} = [branch,'[',num2str((abs(var(1))+1)/2),']'] ;
                    RHS.name{1} = [branch,'__',num2str((abs(var(1))+1)/2)] ;
                    RHS.is_effort(1) = 1 ;
                else
%                    RHS.name{1} = [branch,'[',num2str(abs(var(1))/2),']'] ;
                    RHS.name{1} = [branch,'__',num2str(abs(var(1))/2)] ;
                    RHS.is_effort(1) = 0 ;
                end
                
                if var(1)<0
                    RHS.name{1} = ['-',RHS.name{1}] ;
                end
                
                for j = 2:length(var)
                    if mod(abs(var(j)),2)
%                        RHS.name{j} = [branch,'[',num2str((abs(var(j))+1)/2),']'] ;
                        RHS.name{j} = [branch,'__',num2str((abs(var(j))+1)/2)] ;
                    	RHS.is_effort(j) = 1 ;
                    else
%                        RHS.name{j} = [branch,'[',num2str(abs(var(j))/2),']'] ;
                        RHS.name{j} = [branch,'__',num2str(abs(var(j))/2)] ;
                    	RHS.is_effort(j) = 0 ;
                    end
                    
                    if var(j)>0
                        RHS.name{j} = [' + ',RHS.name{j}] ;
                    else
                        RHS.name{j} = [' - ',RHS.name{j}] ;
                    end
                end
                
            case 'cell',
                [name,covar] = mttCutText(namelist(var{1}).var,'.') ;
                RHS.name{1} = name ;
                
                if strcmp(covar,'effort') | strcmp(covar,'effort_state')
                    RHS.is_effort = 1 ;
                else
                    RHS.is_effort = 0 ;
                end
            end
            
            for k = 1:dimension
                if LHS.is_effort
                    covar = covariables.effort{k} ;
                else
                    covar = covariables.flow{k} ;
                end
                
                content = [LHS.name,'.',strrep(covar,'.','__')] ;
                indent = char(32*ones(1,length(content)+3)) ;
                
                for j = 1:length(RHS.name)
                    if RHS.is_effort(j)
                        covar = covariables.effort{k} ;
                    else
                        covar = covariables.flow{k} ;
                    end
                    
                    if j==1
                        if strcmp(RHS.name{1},'0')
                            content = [content,' = ',RHS.name{1}] ;
                        else
                            content = [content,' = ',RHS.name{1},'.',strrep(covar,'.','__')] ;
                        end
                    else
                        content = [content,'\n',indent,RHS.name{j},'.',strrep(covar,'.','__')] ;
                    end
                end
                
                content = [content,' ;'] ;
                
                if ~isempty(content)
                    eqn_counter = eqn_counter + 1 ;
                    eqn{eqn_counter} = content ;
                end
            end
            
        else
            op = [sse(i).operator] ;
            [cr,operator] = mttCutText(op,'___') ;
			
            if ~strcmp(eqn{eqn_counter},'')
                eqn_counter = eqn_counter + 1 ;
                eqn{eqn_counter} = [''] ;
            end
            eqn_counter = eqn_counter + 1 ;
            eqn{eqn_counter} = ['// ',op] ; 
            
            
            [root,hierarchy] = mttCutText(cr,'__') ;
            
            level = length(findstr(cr,'__')) ;
            for j = 1:level
                [obj{j},hierarchy] = mttCutText(hierarchy,'__') ;
            end
            
            object = getfield(model,'obj',obj{1}) ;
            for j = 2:level
                object = getfield(object,'obj',obj{j}) ;
            end
            
            index = strmatch(operator,{object.cr.operator.name},'exact') ;
            cr_definition = object.cr ;
            operator_definition = cr_definition.operator(index) ;
            
            
            
            structlist = [] ;
            if ~isempty(operator_definition.struct)
                struct_names = mttGetFieldNames(operator_definition,'struct') ;
                number_of_structs = length(struct_names) ;
                for i = 1:number_of_structs
                    struct_name = struct_names{i} ;
                    variables = getfield(operator_definition,'struct',struct_name) ;
                    if i==1
                        structlist = variables ;
                    else
                        structlist = [structlist,variables] ;
                    end
                end
            end
            
            
            
            
            reassigned_state_list = [] ;
            counter = 0 ;
            
            
            port_names = mttGetFieldNames(cr_definition.interface,'port') ;
            for j = 1:length(port_names)
                port_name = port_names{j} ;
                port = getfield(cr_definition,'interface','port',port_name) ;
                
                if ~isempty(port.assign)
                    assignment = port.assign ;
                    
                                
                    if port.was_generic & ~isempty(port.domain)
                        covar = mttGetCovariables(model.env,port.domain,port.domain_item) ;
                        if port.is_effort_state
                            covar = covariables.effort ;
                        else
                            covar = covariables.flow ;
                        end
                        
                        for k = 1:length(assignment.state)
                            counter = counter + 1 ;
                            reassigned_state_list.name{counter} = assignment.state{k} ;
                            reassigned_state_list.covar{counter} = covar ;
                        end
                        
                        
                        block_size = length(covar) ;
                        for var = 1:block_size
                            segment = [] ;
                            
                            for k = 1:length(assignment.state)
                                segment{1} = [cr,'___',port_name,'.',strrep(covar{var},'.','__')] ;
                                segment{2} = [' = '] ;
                                segment{3} = [cr,'___',assignment.state{k},'___',strrep(covar{var},'.','__'),'.state ;'] ;
                                
                                ini_counter = ini_counter + 1 ;
                                ini{ini_counter} = [segment{1},segment{2},segment{3}] ;
                            end                        
                        end
                    else
                        
                        for k = 1:length(assignment.state)
                            segment{1} = [cr,'___',port_name,'.',strrep(assignment.covar{k},'.','__')] ;
                            segment{2} = [' = '] ;
                            segment{3} = [cr,'___',assignment.state{k},'.state ;'] ;
                            
                            ini_counter = ini_counter + 1 ;
                            ini{ini_counter} = [segment{1},segment{2},segment{3}] ;
                        end
                    end                        
                end
            end
            
            
            equations = operator_definition.equation ;
            for j = 1:length(equations)
                equation = equations(j) ;
                number_of_chunks = mttGetFieldLength(equation,'chunk') ;
                
                equation.domain = [] ;
                equation.domain_item = [] ;
                
                for k = 1:number_of_chunks
                    chunk = equation.chunk{k} ;
                    
                    switch class(chunk)
                    case 'cell'
                        type = chunk{1} ;
                        index = chunk{2} ;
                        
                        switch type
                        case 'link'
                            port_name = operator_definition.link(index).name ;
			                port = getfield(cr_definition,'interface','port',port_name) ;
                            
                            if port.was_generic & ~isempty(port.domain)
                                if isempty(equation.domain)
                                    equation.domain = port.domain ;
                                    equation.domain_item = port.domain_item ;
                                else
                                    same_domain = equation.domain==port.domain ;
                                    same_domain_item = strcmp(equation.domain_item,port.domain_item) ;
                                    mttAssert(same_domain&same_domain_item,...
                                        ['Attempt to overwrite implicit variables with conflicting domains in "',...
                                            operator_definition.content{j},'"']) ;
                                end
                            end
                        end
                    end
                end
                
                
                covariables = mttGetCovariables(model.env,equation.domain,equation.domain_item) ;
%                if equation.is_effort
%                    covar = covariables.effort ; 
%                else
%                    covar = covariables.flow ; 
%                end
                
                block_size = length(covariables.effort) ;
                
                
                for line = 1:block_size
	                segment = [] ;
                    content = [] ;
                    
                    for k = 1:number_of_chunks
                        chunk = equation.chunk{k} ;
                        
                        switch class(chunk)
                        case 'cell'
                            type = chunk{1} ;
                            index = chunk{2} ;
                            
                            switch type
                            case 'link'
                                port_variable = [cr,'___',operator_definition.link(index).name] ;
                                
                                if strcmp(chunk{3},'generic___effort')
                                    segment{k} = [port_variable,'.',strrep(covariables.effort{line},'.','__')] ;
                                elseif strcmp(chunk{3},'generic___flow')
                                    segment{k} = [port_variable,'.',strrep(covariables.flow{line},'.','__')] ;
                                else
                                    segment{k} = [port_variable,'.',strrep(chunk{3},'.','__')] ;
                                end
                                
%                                if length(chunk)>2
%                                    segment{k} = [port_variable,'.',strrep(chunk{3},'.','__')] ;
%                                else
%                                    segment{k} = [port_variable,'.',strrep(covar{line},'.','__')] ;
%                                end
                                
                            case 'numpar'
                                segment{k} = [cr,'___',cr_definition.numpar{index}] ;
                                
                            case 'sympar'
                                parameter = [cr_definition.parameter{index}] ;
                                if isnumeric(parameter)
                                    segment{k} = num2str(parameter) ;
                                else
                                    segment{k} = [cr_definition.parameter{index}] ;
                                end
                                
                            case 'var'
                                segment{k} = [op,'___',operator_definition.var{index}] ;
                                
                            case 'struct'
                                segment{k} = [op,'___',structlist{index}] ;
                                
                            case 'input'
                                segment{k} = [cr,'___',cr_definition.input{index}] ;
                                
                            case 'state'
                                state = cr_definition.state{index} ;
                                if isempty(reassigned_state_list)
                                    state_reassignment = [] ;
                                else
                                    state_reassignment = strmatch(state,reassigned_state_list.name,'exact') ;
                                end
                                
                                if isempty(state_reassignment)
                                    segment{k} = [cr,'___',state,'.state'] ;
                                else
                                    state_covar = reassigned_state_list.covar{line} ;
                                    segment{k} = [cr,'___',state,'___',state_covar{1},'.state'] ;
                                end
                                
%                                segment{k} = [cr,'___',cr_definition.state{index},'.state'] ;
                                    
                            case 'derivative'
                                state = cr_definition.state{index} ;
                                if isempty(reassigned_state_list)
                                    state_reassignment = [] ;
                                else
                                    state_reassignment = strmatch(state,reassigned_state_list.name,'exact') ;
                                end
                                
                                if isempty(state_reassignment)
                                    segment{k} = [cr,'___',state,'.derivative'] ;
                                else
                                    state_covar = reassigned_state_list.covar{line} ;
                                    segment{k} = [cr,'___',state,'___',state_covar{1},'.derivative'] ;
                                end
                                
%                                segment{k} = [cr,'___',cr_definition.state{index},'.derivative'] ;
                                
                            end
                        otherwise
                            chunk = strrep(chunk,':=','=') ;
                            segment{k} = chunk ;
                        end
                    end
                    
                    content = [tab,segment{1}] ;
                    for k = 2:length(segment)
                        content = [content,segment{k}] ;
                    end
                    content = [content,' ;'] ;
                    
                    eqn_counter = eqn_counter + 1 ;
                    eqn{eqn_counter} = content ;
                end
            end
            
            eqn_counter = eqn_counter + 1 ;
            eqn{eqn_counter} = ['// End of ',op] ; 
            eqn_counter = eqn_counter + 1 ;
            eqn{eqn_counter} = [''] ; 
        end
    end    
    
    eqn = eqn' ;
    ini = ini' ;
    

function write_equations(eqn,ini,model)
    filename = [model.source,'_include_ode.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    fprintf(fid,'\n\n') ;
    
    tab = char(32*ones(1,3)) ;
    for i = 1:length(ini)
        formatted_equation = [tab,ini{i},'\n'] ;
        fprintf(fid,formatted_equation) ;
    end
    fprintf(fid,'\n') ;
    for i = 1:length(eqn)
        formatted_equation = [tab,eqn{i},'\n'] ;
        fprintf(fid,formatted_equation) ;
    end
    
    fclose(fid) ;
    

Deleted mttroot/ntt/bin/trans/m/mttWriteSystemInitialisation.m version [e48f28b850].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435



















































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttWriteSystemInitialisation(model)

assignment.numpar = assign_numerical_parameters(model) ;
assignment.sympar = assign_symbolic_parameters(model) ;
assignment.input  = assign_input_variables(model) ;
assignment.invar  = assign_input_covariables(model) ;
assignment.state  = assign_state_variables(model) ;

write_set_numpar(assignment,model) ;
write_set_input(assignment,model) ;
write_set_state(assignment,model) ;



function code = assign_symbolic_parameters(model)
	mttNotify('...assigning symbolic parameters') ;
    mttWriteNewLine ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default = model.sympar_default{i} ;
        
        if isempty(default)
            line = line + 1 ;
            code{line} = [model_name,'___',variable_name,' = 1.0 ;'] ;
        else
            line = line + 1 ;
            code{line} = [model_name,'___',variable_name,' = ',default,' ;'] ;
        end
    end
    
    
function code = assign_numerical_parameters(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning numerical parameters') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'numpar') ;
	    
    for i = 1:number_of_variables
        variable_name = model.numpar{i} ;
        default = model.numpar_default{i} ;
        
        line = line + 1 ;
        if isempty(default)
            code{line} = [current_branch,'___',variable_name,' = 1.0 ;'] ;
        else
            code{line} = [current_branch,'___',variable_name,' = ',default,' ;'] ;
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_numerical_parameters(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = assign_numerical_parameters(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = assign_input_variables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning input variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        default = model.input_default{i} ;
        
        line = line + 1 ;
        if isempty(default)
            code{line} = [current_branch,'___',variable_name,' = 0.0 ;'] ;
        else
            code{line} = [current_branch,'___',variable_name,' = ',default,' ;'] ;
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_input_variables(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = assign_input_variables(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = assign_input_covariables(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning input covariables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    code = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    code{line} = [current_branch,'__',object_name,'.',covariable,' = 0.0 ;'] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    code{line} = [current_branch,'__',object_name,'.',covariable,' = 0.0 ;'] ;
                end
            end
        end
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_input_covariables(object,root,next_branch,env) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = assign_state_variables(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning state variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    line = 0 ;
    
    if isfield(model,'state')
        assigned_states = [] ;
        counter = 0 ;
        
        port_names = mttGetFieldNames(model.interface,'port') ;
        for j = 1:length(port_names)
            port_name = port_names{j} ;
            port = getfield(model,'interface','port',port_name) ;
            
            if ~isempty(port.assign)
                assignment = port.assign ;
                
                if port.was_generic & ~isempty(port.domain)
                    covariables = mttGetCovariables(env,port.domain,port.domain_item) ;
                    if port.is_effort_state
                        covar = covariables.effort ;
                        default = covariables.effort_default ;
                    else
                        covar = covariables.flow ;
                        default = covariables.flow_default ;
                    end
                    
                    block_size = length(covar) ;
                    for k = 1:length(assignment.state)
                        counter = counter + 1 ;
                        assigned_states{counter} = assignment.state{k} ;
                        
                        for var = 1:block_size
                            line = line + 1 ;
                            if isempty(default{var})
                                code{line} = [current_branch,'___',assignment.state{k},'___',covar{var},'.state = 0.0 ;'] ;
                            else
                                code{line} = [current_branch,'___',assignment.state{k},'___',covar{var},'.state = ',default{var},' ;'] ;
                            end
                        end                        
                    end
                end
            end
        end
        
        number_of_variables = mttGetFieldLength(model,'state') ;
        
        for i = 1:number_of_variables
            variable_name = model.state{i} ;
            default = model.state_default{i} ;
            
            if ~ismember(variable_name,assigned_states)
                line = line + 1 ;
                if isempty(default)
                    code{line} = [current_branch,'___',variable_name,'.state = 0.0 ;'] ;
                else
                    code{line} = [current_branch,'___',variable_name,'.state = ',default,' ;'] ;
                end
            end
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_state_variables(object,root,next_branch,env) ;
        elseif ~isempty(object.cr)
            additional_code = assign_state_variables(object.cr,root,next_branch,env) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
 
    
function write_set_numpar(assignment,model)
    filename = [model.source,'_include_set_numpar.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Numerical Parameters for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_assigned_list(fid,[],assignment.numpar,model_name) ;
   
    fclose(fid) ;
    
    
function write_set_input(assignment,model)
    filename = [model.source,'_include_set_input.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Default Inputs for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_assigned_list(fid,'symbolic_parameters',assignment.sympar,model_name) ;
    write_assigned_list(fid,'input_variables',assignment.input,model_name) ;
    write_assigned_list(fid,'input_covariables',assignment.invar,model_name) ;
   
    fclose(fid) ;
    
    
function write_set_state(assignment,model)
    filename = [model.source,'_include_set_state.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Initial states for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_assigned_list(fid,[],assignment.state,model_name) ;
   
    fclose(fid) ;
    
    
function write_assigned_list(fid,var_type,var_list,model_name)
    if ~isempty(var_list)
        if ~isempty(var_type)
            fprintf(fid,'\n\n') ;
            fprintf(fid,['// ',var_type]) ;
        end
        fprintf(fid,'\n') ;
    
        var_list = sort(var_list) ;
        
        width = 0 ;
        for i = 1:length(var_list)
            [left,right] = mttCutText(var_list{i},'=') ;
            width = max(width,length(left)) ;
        end
    
        tab = char(32*ones(1,3)) ;
        for i = 1:length(var_list)
            [left,right] = mttCutText(var_list{i},'=') ;
            
            nominal_width = width ;
            actual_width = length(left) ;
            
            gap = nominal_width - actual_width ;
            whitespace = char(32*ones(1,gap)) ;
            
            formatted_assignment = [tab,left,whitespace,' = ',right,'\n'] ;
            fprintf(fid,formatted_assignment) ;
        end
    end

Deleted mttroot/ntt/bin/trans/m/mttWriteSystemMapping.m version [10f14b69b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
















































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttWriteSystemMapping(model)

sympar = map_system_sympars(model) ;
input  = map_system_inputs(model) ;
invar  = map_system_invars(model) ;
outvar = map_system_outvars(model) ;
state  = map_system_states(model) ;

derivative = differentiate(state) ;

mapping.input = invar ;
if ~isempty(input)
    mapping.input = [mapping.input,input] ;
end
if ~isempty(sympar)
    mapping.input = [mapping.input,sympar] ;
end

mapping.output = outvar ;
mapping.state  = state ;
mapping.derivative = derivative ;

write_get_input(mapping,model) ;
write_get_state(mapping,model) ;

write_put_input(mapping,model) ;
write_put_state(mapping,model) ;
write_put_output(mapping,model) ;
write_put_derivative(mapping,model) ;



function map = map_system_sympars(model)
	mttNotify('...mapping system inputs (symbolic parameters)') ;
    mttWriteNewLine ;

    model_name = mttDetachText(model.source,'/') ;
    
    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default_value = model.sympar_default{i} ;
        
        if isempty(default_value)
            line = line + 1 ;
            map{line} = [model_name,'___',variable_name] ;
        end
    end
    
    
function map = map_system_inputs(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input variables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        
        line = line + 1 ;
        map{line} = [current_branch,'___',variable_name] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_inputs(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_map = map_system_inputs(object.cr,root,next_branch) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_invars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_invars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_outvars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system outputs (output covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if inbond.effort
                    covar = covariables.effort ;
                elseif ~inbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if ~outbond.effort
                    if ~strcmp(object.class,'Sf')
                        covar = covariables.effort ;
                    end
                elseif outbond.flow
                    if ~strcmp(object.class,'Se')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_outvars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_states(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system states') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end
    
    map = [] ;
    line = 0 ;
    
    if isfield(model,'state')
        assigned_states = [] ;
        counter = 0 ;
        
        port_names = mttGetFieldNames(model.interface,'port') ;
        for j = 1:length(port_names)
            port_name = port_names{j} ;
            port = getfield(model,'interface','port',port_name) ;
            
            if ~isempty(port.assign)
                assignment = port.assign ;
                
                if port.was_generic & ~isempty(port.domain)
                    covariables = mttGetCovariables(env,port.domain,port.domain_item) ;
                    if port.is_effort_state
                        covar = covariables.effort ;
                    else
                        covar = covariables.flow ;
                    end
                    
                    block_size = length(covar) ;
                    for k = 1:length(assignment.state)
                        counter = counter + 1 ;
                        assigned_states{counter} = assignment.state{k} ;
                        
                        for var = 1:block_size
                            line = line + 1 ;
                            map{line} = [current_branch,'___',assignment.state{k},'___',covar{var},'.state'] ;
                        end                        
                    end
                end
            end
        end
        
        number_of_variables = mttGetFieldLength(model,'state') ;
        
        for i = 1:number_of_variables
            variable_name = model.state{i} ;
            
            if ~ismember(variable_name,assigned_states)
                line = line + 1 ;
                map{line} = [current_branch,'___',variable_name,'.state'] ;
            end
        end
    end
    
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_states(object,root,next_branch,env) ;
        elseif ~isempty(object.cr)
            additional_map = map_system_states(object.cr,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function derivative = differentiate(state)
    mttNotify('...mapping system derivatives') ;
    mttWriteNewLine ;
    
    for i = 1:length(state)
        derivative{i} = strrep(state{i},'.state','.derivative') ;
    end
    
    
function write_get_input(mapping,model)
    filename = [model.source,'_include_get_input.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Input get-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttInput',mapping.input,model_name,1) ;
   
    fclose(fid) ;
    
    
function write_put_input(mapping,model)
    filename = [model.source,'_include_put_input.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Input put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttInput',mapping.input,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_get_state(mapping,model)
    filename = [model.source,'_include_get_state.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// State get-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttState',mapping.state,model_name,1) ;
   
    fclose(fid) ;
    
    
function write_put_state(mapping,model)
    filename = [model.source,'_include_put_state.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// State put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttState',mapping.state,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_put_output(mapping,model)
    filename = [model.source,'_include_put_output.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Output put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttOutput',mapping.output,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_put_derivative(mapping,model)
    filename = [model.source,'_include_put_derivative.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Derivative put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttDerivative',mapping.derivative,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_mapping(fid,array_name,var_list,model_name,is_inward_mapping)
    if ~isempty(var_list)
        var_list = sort(var_list) ;
        
        width = 0 ;
        for i = 1:length(var_list)
            width = max(width,length(var_list{i})) ;
        end
    
        tab = char(32*ones(1,3)) ;
        
        fprintf(fid,'\n') ;
        for i = 1:length(var_list)
            variable = var_list{i} ;
            
            if is_inward_mapping
                nominal_width = width ;
                actual_width = length(variable) ;
                
                gap = nominal_width - actual_width ;
                whitespace = char(32*ones(1,gap)) ;
                
                formatted_mapping = [tab,variable,whitespace,' = ',array_name,'[',num2str(i-1),'] ;\n'] ;
            else
                formatted_mapping = [tab,array_name,'[',num2str(i-1),'] = ',variable,' ;\n'] ;
            end
                
            fprintf(fid,formatted_mapping) ;
        end        
    end

Deleted mttroot/ntt/bin/trans/m/mttWriteSystemSfun.m version [ac6231b47a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250


























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttWriteSystemSfun(model)

model_name = mttDetachText(model.source,'/') ;

working_directory  = pwd ;
working_directory = strrep(working_directory,'\','/') ;

filename = [working_directory,'/',model_name,'_sfun.cpp'] ;
fid = fopen(filename,'w') ;

mttNotify(['...creating ',filename]) ;
mttWriteNewLine ;

model_name = mttDetachText(model.source,'/') ;

fprintf(fid,['// Simulation Code for "',model_name,'"\n']) ;
fprintf(fid,'\n') ;
fprintf(fid,['// file: ',filename             ,'\n']) ;
fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
fprintf(fid,'\n') ;

write_sfun(fid,model) ;

fclose(fid) ;


function write_sfun(fid,model)
    model_name = mttDetachText(model.source,'/') ;
    counter = mttCountSystemMapping(model) ;

    fprintf(fid,['#define S_FUNCTION_NAME ',model_name,'_sfun'                     ,'\n']) ;
    fprintf(fid,['#define S_FUNCTION_LEVEL 2'                                      ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['#include "',model_name,'_include_def.h"'                         ,'\n']) ;
    
    if isfield(model,'app')
        if ~isempty(model.app)
            fprintf(fid,['#include "',model_name,'_include_apps.h"'                ,'\n']) ;
        end
    end
    
    fprintf(fid,['#include "simstruc.h"'                                           ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static double *_mttInput ;'                                      ,'\n']) ;
    fprintf(fid,['static double *_mttState ;'                                      ,'\n']) ;
    fprintf(fid,['static double *_mttDerivative ;'                                 ,'\n']) ;
    fprintf(fid,['static double *_mttOutput ;'                                     ,'\n']) ;
    fprintf(fid,['static double  _mttTime ;'                                       ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static unsigned int _mttIndex ;'                                 ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['const int _mttNumInputs  = ',num2str(counter.input),' ;'         ,'\n']) ;
    fprintf(fid,['const int _mttNumOutputs = ',num2str(counter.output),' ;'        ,'\n']) ;
    fprintf(fid,['const int _mttNumStates  = ',num2str(counter.state),' ;'         ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    
    fprintf(fid,['// system equations'                                             ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_set_numpar (void) {'                  ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_set_numpar.h"'                  ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_set_input (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_set_input.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_set_state (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_set_state.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_get_input (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_get_input.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_get_state (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_get_state.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_put_state (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_put_state.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_put_derivative (void) {'              ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_put_derivative.h"'              ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_put_output (void) {'                  ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_put_output.h"'                  ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_ode (void) {'                         ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_ode.h"'                         ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 

    fprintf(fid,['// utility procedures'                                           ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static double *array_of_double (size_t n)'                       ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  void *p = calloc (n, sizeof (double)) ;'                       ,'\n']) ;
    fprintf(fid,['  if (! p) fprintf (stderr, "*** ERROR: failed to allocate memory") ;','\n']) ;
    fprintf(fid,['  return (double *) p ;'                                         ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void initialise_arrays (void)'                            ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  _mttInput	 = array_of_double(_mttNumInputs) ;'               ,'\n']) ;
    fprintf(fid,['  _mttOutput	 = array_of_double(_mttNumOutputs) ;'              ,'\n']) ;
    fprintf(fid,['  _mttState	 = array_of_double(_mttNumStates) ;'               ,'\n']) ;
    fprintf(fid,['  _mttDerivative = array_of_double(_mttNumStates) ;'             ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void check_finite(SimStruct *S, double *array, unsigned int index)','\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  const char *array_name ;'                                      ,'\n']) ;
    fprintf(fid,['  char warning[128] ;'                                           ,'\n']) ;
    fprintf(fid,['  if ((array[index] <= 0.0) || (array[index] >= 0.0)) {'         ,'\n']) ;
    fprintf(fid,['    ; // ...no problem'                                          ,'\n']) ;
    fprintf(fid,['  } else {'                                                      ,'\n']) ;
    fprintf(fid,['    if (array == _mttInput) {'                                   ,'\n']) ;
    fprintf(fid,['      array_name = "_mttInput" ;'                                ,'\n']) ;
    fprintf(fid,['    } else if (array == _mttState) {'                            ,'\n']) ;
    fprintf(fid,['      array_name = "_mttState" ;'                                ,'\n']) ;
    fprintf(fid,['    } else if (array == _mttOutput) {'                           ,'\n']) ;
    fprintf(fid,['      array_name = "_mttOutput" ;'                               ,'\n']) ;
    fprintf(fid,['    } else if (array == _mttDerivative) {'                       ,'\n']) ;
    fprintf(fid,['      array_name = "_mttDerivative" ;'                           ,'\n']) ;
    fprintf(fid,['    } else {'                                                    ,'\n']) ;
    fprintf(fid,['      array_name = "unknown_array" ;'                            ,'\n']) ;
    fprintf(fid,['    }'                                                           ,'\n']) ;
    fprintf(fid,['    sprintf(warning,"(time %%f) Non-finite array element: %%s[%%d]",_mttTime,array_name,index) ;','\n']) ;
    fprintf(fid,['    ssWarning(S,warning) ;'                                      ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;

    fprintf(fid,['// S-function methods'                                           ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlInitializeSizes(SimStruct *S)'                    ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  ssSetNumSFcnParams(S,0) ;'                                     ,'\n']) ; 
    fprintf(fid,['  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return ;','\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ssSetNumContStates(S,_mttNumStates) ;'                         ,'\n']) ;
    fprintf(fid,['  ssSetNumDiscStates(S,0) ;'                                     ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  if (!ssSetNumInputPorts(S,1)) return ;'                        ,'\n']) ;
    fprintf(fid,['  ssSetInputPortWidth(S,0,_mttNumInputs) ;'                      ,'\n']) ;
    fprintf(fid,['  ssSetInputPortDirectFeedThrough(S,0,1) ;'                      ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  if (!ssSetNumOutputPorts(S,1)) return ;'                       ,'\n']) ;
    fprintf(fid,['  ssSetOutputPortWidth(S,0,_mttNumOutputs) ;'                    ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ssSetNumSampleTimes(S,1) ;'                                    ,'\n']) ;
    fprintf(fid,['  ssSetNumRWork(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumIWork(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumPWork(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumModes(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumNonsampledZCs(S,0) ;'                                  ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ssSetOptions(S,SS_OPTION_EXCEPTION_FREE_CODE) ;'               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  initialise_arrays() ;'                                         ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlInitializeSampleTimes(SimStruct *S)'              ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  ssSetSampleTime(S,0,CONTINUOUS_SAMPLE_TIME) ;'                 ,'\n']) ;
    fprintf(fid,['  ssSetOffsetTime(S,0,0.0) ;'                                    ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['#define MDL_INITIALIZE_CONDITIONS'                               ,'\n']) ;
    fprintf(fid,['static void mdlInitializeConditions(SimStruct *S)'               ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  ',model_name,'_set_numpar() ;'                                 ,'\n']) ;
    fprintf(fid,['  ',model_name,'_set_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_put_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) ssGetContStates(S)[_mttIndex] = _mttState[_mttIndex] ;','\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlOutputs(SimStruct *S,int_T tid)'                  ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  UNUSED_ARG(tid) ;'                                             ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttState[_mttIndex] = ssGetContStates(S)[_mttIndex] ;'      ,'\n']) ;
    fprintf(fid,['    check_finite(S,_mttState,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumInputs; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttInput[_mttIndex] = *ssGetInputPortRealSignalPtrs(S,0)[_mttIndex] ;','\n']) ;
    fprintf(fid,['    check_finite(S,_mttInput,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  _mttTime = ssGetT(S) ;'                                        ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_input() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_ode() ;'                                        ,'\n']) ;
    fprintf(fid,['  ',model_name,'_put_output() ;'                                 ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  for(_mttIndex=0; _mttIndex<_mttNumOutputs; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    check_finite(S,_mttOutput,_mttIndex) ;'                      ,'\n']) ;
    fprintf(fid,['    ssGetOutputPortRealSignal(S,0)[_mttIndex] = _mttOutput[_mttIndex] ;','\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['#define MDL_DERIVATIVES'                                         ,'\n']) ;
    fprintf(fid,['static void mdlDerivatives(SimStruct *S)'                        ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttState[_mttIndex] = ssGetContStates(S)[_mttIndex] ;'      ,'\n']) ;
    fprintf(fid,['    check_finite(S,_mttState,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumInputs; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttInput[_mttIndex] = *ssGetInputPortRealSignalPtrs(S,0)[_mttIndex] ;','\n']) ;
    fprintf(fid,['    check_finite(S,_mttInput,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  _mttTime = ssGetT(S) ;'                                        ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_input() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_ode() ;'                                        ,'\n']) ;
    fprintf(fid,['  ',model_name,'_put_derivative() ;'                             ,'\n']) ;
    fprintf(fid,['  '                                                              ,'\n']) ;
    fprintf(fid,['  if (_mttTime==0)'                                              ,'\n']) ;
    fprintf(fid,['    for(_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) ssGetdX(S)[_mttIndex] = 0.0 ;','\n']) ;
    fprintf(fid,['  else'                                                          ,'\n']) ;
    fprintf(fid,['    for(_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) {'    ,'\n']) ;
    fprintf(fid,['      check_finite(S,_mttDerivative,_mttIndex) ;'                ,'\n']) ;
    fprintf(fid,['      ssGetdX(S)[_mttIndex] = _mttDerivative[_mttIndex] ;'       ,'\n']) ;
    fprintf(fid,['    }'                                                           ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlTerminate(SimStruct *S)'                          ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  UNUSED_ARG(S);'                                                ,'\n']) ;
    fprintf(fid,['  free (_mttInput) ;'                                            ,'\n']) ;
    fprintf(fid,['  free (_mttOutput) ;'                                           ,'\n']) ;
    fprintf(fid,['  free (_mttState) ;'                                            ,'\n']) ;
    fprintf(fid,['  free (_mttDerivative) ;'                                       ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    
    fprintf(fid,['#ifdef  MATLAB_MEX_FILE'                                         ,'\n']) ;
    fprintf(fid,['#include "simulink.c"'                                           ,'\n']) ;
    fprintf(fid,['#else'                                                           ,'\n']) ;
    fprintf(fid,['#include "cg_sfun.h"'                                            ,'\n']) ;
    fprintf(fid,['#endif'                                                          ,'\n']) ;

Deleted mttroot/ntt/bin/trans/mttAppend.m version [18a7272424].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
function information = mttAppend(information,field,items)
	if isfield(information,field)
        previous = getfield(information,field) ;
        if isempty(previous)
            information = setfield(information,field,items) ;
        else
            information = setfield(information,field,[previous,items]) ;
        end
    else
        information = setfield(information,field,items) ;
    end            

Deleted mttroot/ntt/bin/trans/mttAppendFields.m version [b7b88d7113].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
function information = mttAppendFields(information,extra)
    if isstruct(information) & isstruct(extra)
        information_fields = fieldnames(information) ;
        extra_fields = fieldnames(extra) ;
        
        for i = 1:length(extra_fields)
            field_name = extra_fields{i} ;
            extra_field = getfield(extra,field_name) ;
            information = setfield(information,field_name,extra_field) ;
        end
    end            

Deleted mttroot/ntt/bin/trans/mttAssert.m version [0c09e28616].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function mttAssert(rule,msg)
    if ~isempty(rule)
        if ~rule
            error(['MTT: ',msg]) ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttAssign.m version [2407c65690].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function [register,ok] = mttAssign(register,new_value)
	if isempty(register)
        register = new_value ;
        ok = 1 ;
	else
    	ok = register==new_value ;
	end

Deleted mttroot/ntt/bin/trans/mttCheckBondgraphDeclarations.m version [6ec9682a08].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttCheckBondgraphDeclarations(model)

    for i = 1:length(model.sympar)
        mttAssert(~ismember(model.sympar{i},model.numpar),...
            ['Same name (',model.sympar{i},') used for "numpar" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.sympar{i},model.input),...
            ['Same name (',model.sympar{i},') used for "input" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.numpar)
        mttAssert(~ismember(model.numpar{i},model.input),...
            ['Same name (',model.numpar{i},') used for "numpar" and "input" parameters']) ;   
        mttAssert(~ismember(model.numpar{i},model.sympar),...
            ['Same name (',model.numpar{i},') used for "numpar" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.input)
        mttAssert(~ismember(model.input{i},model.sympar),...
            ['Same name (',model.input{i},') used for "input" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.input{i},model.numpar),...
            ['Same name (',model.input{i},') used for "numpar" and "input" parameters']) ;   
    end
    
    all_parameters = [] ;
    
    if ~isempty(model.sympar)
        all_parameters = model.sympar ;
    end
    if ~isempty(model.numpar)
        if isempty(all_parameters)
            all_parameters = model.numpar ;
        else
            all_parameters = [all_parameters, model.numpar] ;
        end
    end
    if ~isempty(model.input)
        if isempty(all_parameters)
            all_parameters = model.input ;
        else
            all_parameters = [all_parameters, model.input] ;
        end
    end
    
    object_names = mttGetFieldNames(model,'obj') ;
    
    if ~isempty(all_parameters)
        for i = 1:length(object_names)
            object_name = object_names{i} ;
            object = getfield(model,'obj',object_name) ;
            
            for j = 1:length(object.parameter)
                object_parameter = object.parameter{j} ;
                if ~isnumeric(object_parameter)
                    mttAssert(ismember(object_parameter,all_parameters),...
                        ['Object parameter "',object.parameter{j},'" not previously declared']) ;
                end
            end
        end
        
        for j = 1:length(all_parameters)
            current_parameter = all_parameters{j} ;
            other_parameters = all_parameters ;
            other_parameters(j) = [] ;
            
            mttAssert(~ismember(current_parameter,other_parameters),...
                ['Repeated parameter/input name "',current_parameter,'"']) ;
        end
    end
    
    
    counter = 0 ;
    all_instance_parameters = [] ;
    
    for i = 1:length(object_names)
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        for j = 1:length(object.parameter)
            object_parameter = object.parameter{j} ;
            if ~isnumeric(object_parameter)
                counter = counter + 1 ;
                all_instance_parameters{counter} = object_parameter ;
            end
        end
    end
    
    for k = 1:length(all_parameters)
        parameter = all_parameters{k} ;
        if isempty(all_instance_parameters)
            mttAssert(0,['Declared parameter/input "',parameter,'" not used']) ;
        else
            mttAssert(ismember(parameter,all_instance_parameters),...
                ['Declared parameter/input "',parameter,'" not used']) ;
        end
    end
    
    

Deleted mttroot/ntt/bin/trans/mttCheckInterfaceDeclarations.m version [2c5010e210].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttCheckInterfaceDeclarations(model)

    for i = 1:length(model.sympar)
        mttAssert(~ismember(model.sympar{i},model.numpar),...
            ['Same name (',model.sympar{i},') used for "numpar" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.sympar{i},model.input),...
            ['Same name (',model.sympar{i},') used for "input" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.numpar)
        mttAssert(~ismember(model.numpar{i},model.input),...
            ['Same name (',model.numpar{i},') used for "numpar" and "input" parameters']) ;   
        mttAssert(~ismember(model.numpar{i},model.sympar),...
            ['Same name (',model.numpar{i},') used for "numpar" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.input)
        mttAssert(~ismember(model.input{i},model.sympar),...
            ['Same name (',model.input{i},') used for "input" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.input{i},model.numpar),...
            ['Same name (',model.input{i},') used for "numpar" and "input" parameters']) ;   
    end
    
    all_parameters = [] ;
    
    if ~isempty(model.sympar)
        all_parameters = model.sympar ;
    end
    if ~isempty(model.numpar)
        if isempty(all_parameters)
            all_parameters = model.numpar ;
        else
            all_parameters = [all_parameters, model.numpar] ;
        end
    end
    if ~isempty(model.input)
        if isempty(all_parameters)
            all_parameters = model.input ;
        else
            all_parameters = [all_parameters, model.input] ;
        end
    end
    
    object_names = mttGetFieldNames(model,'obj') ;
    
    if ~isempty(all_parameters)
        for i = 1:length(object_names)
            object_name = object_names{i} ;
            object = getfield(model,'obj',object_name) ;
            
            for j = 1:length(object.parameter)
                object_parameter = object.parameter{j} ;
                if ~isnumeric(object_parameter)
                    mttAssert(ismember(object_parameter,all_parameters),...
                        ['Object parameter "',object.parameter{j},'" not previously declared']) ;
                end
            end
        end
        
        for j = 1:length(all_parameters)
            current_parameter = all_parameters{j} ;
            other_parameters = all_parameters ;
            other_parameters(j) = [] ;
            
            mttAssert(~ismember(current_parameter,other_parameters),...
                ['Repeated parameter/input name "',current_parameter,'"']) ;
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttCheckStateDeclarations.m version [3c4952b269].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttCheckStateDeclarations(model)
    for i = 1:length(model.sympar)
        mttAssert(~ismember(model.sympar{i},model.state),...
            ['Same name (',model.sympar{i},') used for "state" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.numpar)
        mttAssert(~ismember(model.numpar{i},model.state),...
            ['Same name (',model.numpar{i},') used for "numpar" and "state" parameters']) ;   
    end
    
    for i = 1:length(model.input)
        mttAssert(~ismember(model.input{i},model.state),...
            ['Same name (',model.input{i},') used for "input" and "state" parameters']) ;   
    end
    
    for i = 1:length(model.state)
        mttAssert(~ismember(model.state{i},model.sympar),...
            ['Same name (',model.state{i},') used for "state" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.state{i},model.numpar),...
            ['Same name (',model.state{i},') used for "state" and "numpar" parameters']) ;   
        mttAssert(~ismember(model.state{i},model.input),...
            ['Same name (',model.state{i},') used for "state" and "input" parameters']) ;   
    end
    
    all_parameters = [] ;
    
    if ~isempty(model.sympar)
        all_parameters = model.sympar ;
    end
    if ~isempty(model.numpar)
        if isempty(all_parameters)
            all_parameters = model.numpar ;
        else
            all_parameters = [all_parameters, model.numpar] ;
        end
    end
    if ~isempty(model.input)
        if isempty(all_parameters)
            all_parameters = model.input ;
        else
            all_parameters = [all_parameters, model.input] ;
        end
    end
    
    for j = 1:length(all_parameters)
        current_parameter = all_parameters{j} ;
        mttAssert(~ismember(current_parameter,model.state),...
            ['Repeated parameter/state name "',current_parameter,'"']) ;
    end
    
    for j = 1:length(model.state)
        current_state = model.state{j} ;
        mttAssert(~ismember(current_state,all_parameters),...
            ['Repeated parameter/state name "',current_state,'"']) ;
    end
    

Deleted mttroot/ntt/bin/trans/mttClipText.m version [69d529c0b6].

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
function clipped_text = mttClipText(text)
	if isempty(text)
        clipped_text = [] ;
    else
        index = 1:length(text) ;
        useful = index(~isspace(text)) ;
        clipped_text = text(min(useful):max(useful)) ;
    end

Deleted mttroot/ntt/bin/trans/mttCompare.m version [202012e558].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function comparison = mttCompare(left,right)
	if isempty(left) | isempty(right)
        comparison = [] ;
    else
        comparison = (left==right) ;
    end
    

Deleted mttroot/ntt/bin/trans/mttCompareCausalCompletion.m version [52e40be8ac].

1
2
3
4
5
6






-
-
-
-
-
-
function is_stable = mttCompareCausalCompletion(current,previous)
	is_stable_flow = current.flows==previous.flows ;
    is_stable_effort = current.efforts==previous.efforts ;
    is_stable = is_stable_flow & is_stable_effort ;


Deleted mttroot/ntt/bin/trans/mttCompareDomainCompletion.m version [d97ae73c6a].

1
2
3



-
-
-
function is_stable = mttCompareDomainCompletion(current,previous)
	is_stable = current.assignments==previous.assignments ;

Deleted mttroot/ntt/bin/trans/mttCompressText.m version [e7042c4298].

1
2
3
4
5
6






-
-
-
-
-
-
function compressed_text = mttCompressText(text)
	if isempty(text)
    	compressed_text = [] ;
    else
        compressed_text = text(~isspace(text)) ;
    end

Deleted mttroot/ntt/bin/trans/mttCountObjects.m version [bbb060ad26].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttCountObjects(model)

    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    model.count.obj = number_of_objects ;
    model.count.cr = 0 ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~isempty(object.cr)
            model.count.cr = model.count.cr + 1 ;
        end
        
        if isfield(object,'obj')
            next = mttCountObjects(object) ;
            model.count.obj = model.count.obj + next.count.obj ;
            model.count.cr = model.count.cr + next.count.cr ;
        end
    end
            

Deleted mttroot/ntt/bin/trans/mttCountSystemMapping.m version [70ad7bc3f3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195



































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function counter = mttCountSystemMapping(model)

sympars = count_system_sympars(model) ;
inputs  = count_system_inputs(model) ;
invars  = count_system_invars(model) ;
outvars = count_system_outvars(model) ;
states  = count_system_states(model) ;

counter.input = sympars + inputs + invars ;
counter.output = outvars ;
counter.state  = states ;


function counter = count_system_sympars(model)
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    counter = 0 ;
    
    for i = 1:number_of_variables
        default_value = model.sympar_default{i} ;
        if isempty(default_value)
            counter = counter + 1 ;
        end
    end
    
    
function counter = count_system_inputs(model)
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_inputs(object) ;
        elseif ~isempty(object.cr)
            additional_variables = count_system_inputs(object.cr) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;
    
    
function counter = count_system_invars(model,root,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        root = model ;
        env = model.env ;
    end
    
    number_of_variables = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
        end
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_invars(object,root,env) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;
    
    
function counter = count_system_outvars(model,root,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        root = model ;
        env = model.env ;
    end

    number_of_variables = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if inbond.effort
                    covar = covariables.effort ;
                elseif ~inbond.flow
                    covar = covariables.flow ;
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if ~outbond.effort
                    if ~strcmp(object.class,'Sf')
                        covar = covariables.effort ;
                    end
                elseif outbond.flow
                    if ~strcmp(object.class,'Se')
                        covar = covariables.flow ;
                    end
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
        end
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_outvars(object,root,env) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;
    
    
function counter = count_system_states(model)
    number_of_variables = mttGetFieldLength(model,'state') ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_states(object) ;
        elseif ~isempty(object.cr)
            additional_variables = count_system_states(object.cr) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;

Deleted mttroot/ntt/bin/trans/mttCreateAlternativeEquations.m version [8fa9da4786].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563



















































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function ese = mttCreateAlternativeEquations(model)

ese = write_equations(model) ;
ese = ese' ;

filename = [model.source,'_ese.txt'] ;
fid = fopen(filename,'w') ;

fprintf(fid,['// Elementary System Equations\n']) ;
fprintf(fid,'\n') ;
fprintf(fid,['// file: ',filename,'\n']) ;
fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
fprintf(fid,'\n\n') ;

fprintf(fid,['ese ',mttDetachText(model.source,'/'),' {']) ;
fprintf(fid,'\n') ;

tab = char(32*ones(1,3)) ;

for i = 1:length(ese)
    fprintf(fid,[tab,ese{i},'\n']) ;
end

fprintf(fid,'}') ;

fclose(fid) ;



function ese = write_equations(model,branch)
    is_root_model = (nargin==1) ;

    if is_root_model
        branch = mttDetachText(model.source,'/') ;
    end
    
%    ese{1} = ' ' ;
%    ese{2} = ['// ESE representation for module: ',branch] ;
%    ese{3} = ' ' ;
%    
%    line = 3 ;

    line = 0 ;
    
    indent = char(32*ones(1,6)) ;

    
    objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        switch object.class
        case 'SS',
            
            for j = 1:mttGetFieldLength(object,'interface')
                flow_equation = [] ;
                effort_equation = [] ;
                
                port_name = object.interface(j).name ;
                
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    
                    extern = [branch,'__',object_name,'___flow'] ;
                    intern = [branch,'___f[',num2str(inbond),']'] ;
                    if bond.flow
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    else
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___effort'] ;
                    intern = [branch,'___e[',num2str(inbond),']'] ;
                    if bond.effort
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    else
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
                
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    
                    extern = [branch,'__',object_name,'___flow'] ;
                    intern = [branch,'___f[',num2str(outbond),']'] ;
                    if bond.flow
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    else
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___effort'] ;
                    intern = [branch,'___e[',num2str(outbond),']'] ;
                    if bond.effort
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    else
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
            end
            
        case '0',
            
            imposed_effort = [] ;
            resultant_flow = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort(i),flow(i)] = mttGetBondCausality(model,bond_number(i)) ;
                
                if effort(i)==orientation(i)
                    imposed_effort_bond = bond_number(i) ;
                    imposed_effort = [branch,'___e[',num2str(imposed_effort_bond),']'] ;
                end
                if flow(i)==orientation(i)
                    resultant_flow_bond = bond_number(i) ;
                    resultant_flow = [branch,'___f[',num2str(resultant_flow_bond),']'] ;
                end
            end
            
            
            for i = 1:mttGetFieldLength(object,'interface')
                if bond_number(i)~=imposed_effort_bond
                    line = line + 1 ;
                    derived_effort = [branch,'___e[',num2str(bond_number(i)),']'] ;
                    ese{line} = [derived_effort,' = ',imposed_effort,' ;'] ;
                end
            end
            
            waiting = 1 ;
            offset = char(32*ones(1,length(resultant_flow)+1)) ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                next_flow = [] ;
                
                if bond_number(i)~=resultant_flow_bond
                    next_flow = [branch,'___f[',num2str(bond_number(i)),']'] ;
                    line = line + 1 ;
                    
                    if waiting
                        if orientation(i)
                            ese{line} = [resultant_flow,' = ',next_flow] ;
                        else
                            ese{line} = [resultant_flow,' = -',next_flow] ;
                        end
                        waiting = 0 ;
                    else
                        if orientation(i)
	                        ese{line} = [offset,'+ ',next_flow] ;
                        else
    	                    ese{line} = [offset,'- ',next_flow] ;
                        end
                    end
                end
            end
            ese{line} = [ese{line},' ;'] ;
            
        case '1',
            
            imposed_flow = [] ;
            resultant_effort = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort(i),flow(i)] = mttGetBondCausality(model,bond_number(i)) ;
                
                if flow(i)~=orientation(i)
                    imposed_flow_bond = bond_number(i) ;
                    imposed_flow = [branch,'___f[',num2str(imposed_flow_bond),']'] ;
                end
                if effort(i)~=orientation(i)
                    resultant_effort_bond = bond_number(i) ;
                    resultant_effort = [branch,'___e[',num2str(resultant_effort_bond),']'] ;
                end
            end
            
            
            for i = 1:mttGetFieldLength(object,'interface')
                if bond_number(i)~=imposed_flow_bond
                    line = line + 1 ;
                    derived_flow = [branch,'___f[',num2str(bond_number(i)),']'] ;
                    ese{line} = [derived_flow,' = ',imposed_flow,' ;'] ;
                end
            end
            
            waiting = 1 ;
            offset = char(32*ones(1,length(resultant_effort)+1)) ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                next_effort = [] ;
                
                if bond_number(i)~=resultant_effort_bond
                    next_effort = [branch,'___e[',num2str(bond_number(i)),']'] ;
                    line = line + 1 ;
                    
                    if waiting
                        if orientation(i)
                            ese{line} = [resultant_effort,' = ',next_effort] ;
                        else
                            ese{line} = [resultant_effort,' = -',next_effort] ;
                        end
                        waiting = 0 ;
                    else
                        if orientation(i)
	                        ese{line} = [offset,'+ ',next_effort] ;
                        else
    	                    ese{line} = [offset,'- ',next_effort] ;
                        end
                    end
                end
            end
            ese{line} = [ese{line},' ;'] ;
            
        otherwise,
            
            if ~isempty(object.cr)
                operators = object.cr.operator ;
                interface = object.cr.interface ;
                port_names = mttGetFieldNames(interface,'port') ;
                
                link_counter = 0 ;
                
                for i = 1:length(port_names)
                    port_name = port_names{i} ;
                    port = getfield(interface,'port',port_name) ;
                    terminal = [branch,'__',object_name,'___',port_name] ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    if ~isempty(inbond)
                        bond = model.bond(inbond) ;
                        
                        intern = [branch,'___f[',num2str(inbond),']'] ;
                        if bond.flow
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [intern,' = ',terminal,'___flow_state ;'] ;
                            else
                                flow_equation = [intern,' = ',terminal,'___flow ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [terminal,'___flow_state = ',intern,' ;'] ;
                            else
                                flow_equation = [terminal,'___flow = ',intern,' ;'] ;
                            end
                        end
                        
                        intern = [branch,'___e[',num2str(inbond),']'] ;
                        if bond.effort
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [terminal,'___effort_state = ',intern,' ;'] ;
                            else
                                effort_equation = [terminal,'___effort = ',intern,' ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [intern,' = ',terminal,'___effort_state ;'] ;
                            else
                                effort_equation = [intern,' = ',terminal,'___effort ;'] ;
                            end
                        end
                        
                        line = line + 1 ;
                        ese{line} = flow_equation ;
                        
                        line = line + 1 ;
                        ese{line} = effort_equation ;
                    end                                
                    
                    if ~isempty(outbond)
                        bond = model.bond(outbond) ;
                        
                        intern = [branch,'___f[',num2str(outbond),']'] ;
                        if bond.flow
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [terminal,'___flow_state = ',intern,' ;'] ;
                            else
                                flow_equation = [terminal,'___flow = ',intern,' ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [intern,' = ',terminal,'___flow_state ;'] ;
                            else
                                flow_equation = [intern,' = ',terminal,'___flow ;'] ;
                            end
                        end
                        
                        intern = [branch,'___e[',num2str(outbond),']'] ;
                        if bond.effort
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [intern,' = ',terminal,'___effort_state ;'] ;
                            else
                                effort_equation = [intern,' = ',terminal,'___effort ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [terminal,'___effort_state = ',intern,' ;'] ;
                            else
                                effort_equation = [terminal,'___effort = ',intern,' ;'] ;
                            end
                        end
                        
                        line = line + 1 ;
                        ese{line} = flow_equation ;
                        
                        line = line + 1 ;
                        ese{line} = effort_equation ;
                    end
                end
                
                number_of_operators = length(operators) ;
                op_counter = 1 ;
                
                matching = 1 ;
                while matching
                    operator = operators(op_counter) ;
                    
                    links = length(link) ;
                    op_links = length(operator.link) ;
                    op_linked = zeros(op_links,1) ;
                    
                    for j = 1:op_links
                        for k = 1:links
                            if compare_links(link(k),operator.link(j))
                                op_linked(j) = k ;
                                break ;
                            end
                        end
                    end
                    
                    input_counter = 0 ;
                    output_counter = 0 ;
                    input = [] ;
                    output = [] ;
                    
                    if all(op_linked)
                        for j = 1:op_links
                            current_link = link(op_linked(j)) ;
                            port_name = current_link.name ;
                            
                            if current_link.is_effort
                                if current_link.is_state
                                    link_name = [branch,'__',object_name,'___',port_name,'___effort_state'] ;
                                else
                                    link_name = [branch,'__',object_name,'___',port_name,'___effort'] ;
                                end
                            end
                            if current_link.is_flow
                                if current_link.is_state
                                    link_name = [branch,'__',object_name,'___',port_name,'___flow_state'] ;
                                else
                                    link_name = [branch,'__',object_name,'___',port_name,'___flow'] ;
                                end
                            end
                            if current_link.is_input
                                input_counter = input_counter + 1 ;
                                input{input_counter} = link_name ;
                            else
                                output_counter = output_counter + 1 ;
                                output{output_counter} = link_name ;
                            end
                        end
                        
                        if input_counter>0
                            input_list = ['[',input{1}] ;
                            for j = 2:input_counter
                                input_list = [input_list,',',input{j}] ;
                            end
                            input_list = [input_list,']'] ;
                        end
                        
                        if output_counter>0
                            output_list = ['[',output{1}] ;
                            for j = 2:output_counter
                                output_list = [output_list,',',output{j}] ;
                            end
                            output_list = [output_list,']'] ;
                        end
                        
                        if input_counter>0
                            line = line + 1 ;
                            ese{line} = [output_list,' = '] ;
                        end
                        
                        line = line + 1 ;
                        ese{line} = [indent,branch,'__',object_name,'___',operator.name] ;
                        
                        if output_counter>0                                
                            line = line + 1 ;
                            ese{line} = [indent,indent,input_list,' ;'] ;
                        end
                        
                        link(op_linked) = [] ;
                    end
                    
                    op_counter = op_counter + 1 ;
                    matching = ~isempty(link) & (op_counter<=number_of_operators) ;
                end
                
                mttAssert(isempty(link),...
                    ['Unattached ports in "cr" implementation in ',here]) ;
            end
        end
    end
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        if ~isempty(object.abg)
            for j = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                inmap = object.interface(j).map.in ;
                outmap = object.interface(j).map.out ;
                
                line = line + 1 ;
                ese{line} = ' ' ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    
                    extern = [branch,'__',object_name,'___f[',num2str(inmap),']'] ;
                    intern = [branch,'___f[',num2str(inbond),']'] ;
                    if bond.flow
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    else
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___e[',num2str(inmap),']'] ;
                    intern = [branch,'___e[',num2str(inbond),']'] ;
                    if bond.effort
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    else
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
                
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    
                    extern = [branch,'__',object_name,'___f[',num2str(outmap),']'] ;
                    intern = [branch,'___f[',num2str(outbond),']'] ;
                    if bond.flow
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    else
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___e[',num2str(outmap),']'] ;
                    intern = [branch,'___e[',num2str(outbond),']'] ;
                    if bond.effort
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    else
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
            end
            next_branch = [branch,'__',object_name] ;
            
            object_ese = write_equations(object,next_branch) ;
            
            ese = [ese, object_ese] ;
            line = length(ese) ;
        end
    end
    
    
function link = create_link(is_input,is_effort,is_flow,name,is_state)
    link.is_input    = is_input ;
    link.is_effort   = is_effort ;
    link.is_flow     = is_flow ;
    link.name        = name ;
    link.is_state    = is_state ;
    
function boolean = compare_links(actual_link,op_link)
    input_is_same  = actual_link.is_input==op_link.is_input ;
    effort_is_same = actual_link.is_effort==op_link.is_effort ;
    flow_is_same   = actual_link.is_flow==op_link.is_flow ;
    name_is_same   = strcmp(actual_link.name,op_link.name) ;
    
    boolean = input_is_same & effort_is_same & flow_is_same & name_is_same ;
    
    

Deleted mttroot/ntt/bin/trans/mttCutText.m version [df536d2c98].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [left,right] = mttCutText(text,delimiter)
    if isempty(text)
	    left = [] ;
    	right = [] ;
    else
	    where = min(findstr(text,delimiter)) ;
        if isempty(where)
            left = mttClipText(text) ;
            right = [] ;
        else
            left = mttClipText(text(1:where-1)) ;
            right = mttClipText(text(where+length(delimiter):length(text))) ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttDeleteField.m version [482e247ec2].

1
2
3
4
5
6






-
-
-
-
-
-
function model = mttDeleteField(structure,field_name)
    if isfield(structure,field_name)
        model = rmfield(structure,field_name) ;
    else
        model = structure ;
    end

Deleted mttroot/ntt/bin/trans/mttDetachText.m version [3bacd6b720].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [detached_text,preceding_text] = mttDetachText(text,delimiter)
    if isempty(text)
        detached_text = [] ;
        preceding_text = [] ;
    else
	    where = max(findstr(text,delimiter)) ;
        if isempty(where)
            detached_text = [] ;
            preceding_text = mttClipText(text) ;
        else
            detached_text = mttClipText(text(where+length(delimiter):length(text))) ;
            preceding_text = mttClipText(text(1:where-1)) ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttElapseTime.m version [5d0d579808].

1
2
3
4




-
-
-
-
function elapsed_time = mttElapseTime(t0)
	current_time = mttGetTime ;
    elapsed_time.cpu = current_time.cpu - t0.cpu ;
    elapsed_time.clock = etime(current_time.clock,t0.clock) ;

Deleted mttroot/ntt/bin/trans/mttExtractStatements.m version [62c7b13d82].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function statements = mttExtractStatements(content)
	input = 1 ;
    output = 0 ;
    line = [] ;
    
    searching = 0 ;
    processing = 1 ;
    while processing
        line = [line,content{input}] ;
        line = mttCutText(line,'//') ;
        
        if ~isempty(line)
            semicolon = findstr(line,';') ;
            leftbrace = findstr(line,'{') ;
            rightbrace = findstr(line,'}') ;
            terminator = sort([semicolon,leftbrace,rightbrace]) ;
            
            if isempty(terminator)
                searching = 1 ;
            else
                first = 1 ;
                N = length(terminator) ;
                L = length(line) ;
                
                for i = 1:N
                    last = terminator(i) - 1 ;
                    if first<=last
                        output = output + 1 ;
                        statements{output} = mttClipText(line(first:last)) ;
                    end
                    
                    if ismember(line(terminator(i)),{'{','}'})
                        output = output + 1 ;
                        statements{output} = line(terminator(i)) ;
                    end
                    first = last + 2 ;
                end
                
                if terminator(N)==L
                    line = [] ;
                    searching = 0 ;
                else
                    line = mttClipText(line(terminator(N):L)) ;
                end
            end
        end
        input = input + 1 ;
        processing = input<=length(content) ;
        
        if searching
            mttAssert(input<=length(content),...
                'End of file found with an incomplete statement') ;
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttExtractText.m version [18e3a1f15b].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
function extracted_text = mttExtractText(text,left,right)
    if isempty(text)
	    extracted_text = [] ;
    else
	    where_left = min(findstr(text,left)) ;
    	where_right = min(findstr(text,right)) ;
    
        if ~isempty(where_left) & ~isempty(where_right)
            extracted_text = mttClipText(text(where_left+length(left):where_right-1)) ;
        else
            extracted_text = [] ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttFileExists.m version [88a67661d5].

1
2
3
4




-
-
-
-
function boolean = mttFileExists(filename)

    boolean = exist(filename)==2 ;

Deleted mttroot/ntt/bin/trans/mttFindEquationVariables.m version [448d87faf7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [varlist,location] = mttFindEquationVariables(line)
	line = mttClipText(line) ;

	if isempty(line)
        namelist = [] ;
        location = [] ;
    else
        numbers = (line>=48 & line<=57) ;
        letters = (line>=65 & line<=90)|(line>=97 & line<=122) ;
        underscores = (line==95) ;
        dots = (line==46) ;
        apostrophes = (line==39) ;
        
        mask = (numbers|letters|underscores|dots|apostrophes) ;
        
        buffer = line ;
        buffer(~mask) = char(32*ones(1,sum(~mask))) ;
        
        next = 1 ;
        last = length(buffer) ;
        
        counter = 0 ;
        
        finding = any(mask) ;
        while finding
            i = min(find(~isspace(buffer(next:last))))+next-1 ;
            
            if isempty(i)
                finding = 0 ;
            else
                if i>last
                    finding = 0 ;
                else
                    if i==last
                        j = last ;
                    else
                        j = min(find(isspace(buffer(i+1:last))))+i ;
                        
                        if isempty(j)
                            j = last ;
                        else
                            j = j - 1 ;
                        end
                    end
                    
                    if ~mttIsNumericText(buffer(i:j))
                        var_found = 1 ;
                        
                        if j<last
                            jj = min(find(~isspace(line(j+1:last))))+j ;
                            if line(jj)=='('
                                var_found = 0 ;
                            end
                        end
                        if var_found
                            counter = counter + 1 ;
                            varlist{counter} = buffer(i:j) ;
                            location(counter) = i ;
                        end
                    end
                    next = j + 1 ;
                    finding = (next<last) & ~isempty(i) ;
                end
            end
        end
    end
     

Deleted mttroot/ntt/bin/trans/mttGetBondCausality.m version [e62609931f].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
function [effort_causality,flow_causality,uni_causality] = mttGetBondCausality(model,bond_number)
    if isempty(bond_number)
        effort_causality = [] ;
        flow_causality = [] ;
        uni_causality = [] ;
    else
        effort_causality = model.bond(bond_number).effort ;
        flow_causality = model.bond(bond_number).flow ;
        uni_causality = model.bond(bond_number).unicausal ;
    end

Deleted mttroot/ntt/bin/trans/mttGetBondDomain.m version [b0febc628a].

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
function [domain,domain_item] = mttGetBondDomain(model,bond_number)
    if isempty(bond_number)
        domain = [] ;
        domain_item = [] ;
    else
        domain = model.bond(bond_number).domain ;
        domain_item = model.bond(bond_number).domain_item ;
    end

Deleted mttroot/ntt/bin/trans/mttGetCovariables.m version [5ae2548ed6].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
function covariables = mttGetCovariables(env,domain,domain_item)
	if isempty(domain)
        covariables.effort = {'effort'} ;
        covariables.flow = {'flow'} ;
        covariables.effort_default = {[]} ;
        covariables.flow_default = {[]} ;
    else
        covariables = getfield(env,'public_domain',{domain},'item',domain_item) ;
    end
    

Deleted mttroot/ntt/bin/trans/mttGetField.m version [93d11ba8da].

1
2
3
4
5





-
-
-
-
-
function field = mttGetField(structure,component)
	field = [] ;
	if isfield(structure,component)
        field = getfield(structure,component) ;
    end

Deleted mttroot/ntt/bin/trans/mttGetFieldLength.m version [ffab5c2924].

1
2
3
4
5





-
-
-
-
-
function N = mttGetFieldLength(structure,vector)
    N = 0 ;
    if isfield(structure,vector)
        N = length(getfield(structure,vector)) ;
    end

Deleted mttroot/ntt/bin/trans/mttGetFieldNames.m version [371982056a].

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
function namelist = mttGetFieldNames(structure,component)
    namelist = [] ;
    if isfield(structure,component)
        field = getfield(structure,component) ;
        if ~isempty(field)
            namelist = fieldnames(field) ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttGetInstanceParameters.m version [12b70a7300].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
function parameters = mttGetInstanceParameters(parameter_list)
    parameters = mttGetItemList(parameter_list) ;

    for n = 1:length(parameters)
        if mttIsNumericText(parameters{n})
            parameters{n} = str2num(parameters{n}) ;
        else
            mttValidateName(parameters{n}) ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttGetItemList.m version [52367110b3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [items,item_values] = mttGetItemList(text)
    if isempty(text)
	    items = [] ;
        item_values = [] ;
    else
        counter = 0 ;
        fetching_items = 1 ;
        while fetching_items
            counter = counter + 1 ;
            [next_item,text] = mttCutText(text,',') ;
            
            [item_name,item_value] = mttCutText(next_item,'=') ;
            
            items{counter} = item_name ;
            item_values{counter} = item_value ;
            
            if isempty(text)
                fetching_items = 0 ;
            end
        end
    end

Deleted mttroot/ntt/bin/trans/mttGetParameters.m version [d7054c9547].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [parameters,default_values] = mttGetParameters(parameter_list)
    [parameters,default_values] = mttGetItemList(parameter_list) ;
    
    for n = 1:length(parameters)
        parameter_name = parameters{n} ;
        mttValidateName(parameter_name) ;
    end
    
    for n = 1:length(default_values)
        default_value = default_values{n} ;
        if ~isempty(default_value)
            mttAssert(mttIsNumericText(default_value),...
                'Parameter list contains non-numeric default value') ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttGetTime.m version [db639d211d].

1
2
3



-
-
-
function time = mttGetTime
	time.clock = clock ;
    time.cpu = cputime ;

Deleted mttroot/ntt/bin/trans/mttIdentifyImplicitBonds.m version [06bec7e6fc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function next_next = mttIdentifyImplicitBonds(model,branch,next)
    is_root_model = (nargin==1) ;
    
    if is_root_model
        mttNotify('...following bonds have no explicit domain allocation:') ;
        mttWriteNewLine ;
        
        branch = mttDetachText(model.source,'/') ;
        next = 0 ;
    end

    number_of_bonds = mttGetFieldLength(model,'bond') ;
    for i = 1:number_of_bonds
        if isempty(model.bond(i).domain)
            origin = model.bond(i).from.obj ;
            port = model.bond(i).from.interface ;
            
            if isfield(model.obj,origin)
                origin_class = getfield(model,'obj',origin,'class') ;
                
                switch origin_class
                case {'0','1'},
                    bond_origin = [origin_class,':',origin] ;
                otherwise,
                    origin_port = getfield(model,'obj',origin,'interface',{port},'name') ;
                    bond_origin = [origin_class,':',origin,'[',origin_port,']'] ;
                end
            else
                bond_origin = ['SS:',origin] ;
            end
            
            target = model.bond(i).to.obj ;
            port = model.bond(i).to.interface ;
            
            if isfield(model.obj,target)
                target_class = getfield(model,'obj',target,'class') ;
                
                switch target_class
                case {'0','1'},
                    bond_target = [target_class,':',target] ;
                otherwise,
                    target_port = getfield(model,'obj',target,'interface',{port},'name') ;
                    bond_target = [target_class,':',target,'[',target_port,']'] ;
                end
            else
                bond_target = ['SS:',target] ;
            end
            
            next = next + 1 ;
            descriptor = ['      ',num2str(next),': ',branch,'(',num2str(i),') from: ',...
                bond_origin,' to: ',bond_target] ;
            
            mttNotify(descriptor) ;
            mttWriteNewLine ;
        end
    end
    
    
    next_next = next ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            next_branch = [branch,'/',object_name] ;
            next_next = mttIdentifyImplicitBonds(object,next_branch,next) ;
            next = next_next ;
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttIdentifySource.m version [333fd4e482].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function [directory,file] = mttIdentifySource(local_filename)
local_filename
    filename = which(local_filename) 
    backslash = findstr(filename,'\') ;
    filename(backslash) = '/' ;
    
    [file,directory] = mttDetachText(filename,'/') ;

Deleted mttroot/ntt/bin/trans/mttIdentifyUndercausalBonds.m version [b4813b7312].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function next_next = mttIdentifyUndercausalBonds(model,branch,next)
    is_root_model = (nargin==1) ;
    
    if is_root_model
        mttNotify('...following bonds are under-causal:') ;
        mttWriteNewLine ;
        
        branch = mttDetachText(model.source,'/') ;
        next = 0 ;
    end

    number_of_bonds = mttGetFieldLength(model,'bond') ;
    for i = 1:number_of_bonds
        if isempty(model.bond(i).effort) | isempty(model.bond(i).flow)
            origin = model.bond(i).from.obj ;
            port = model.bond(i).from.interface ;
            
            if isfield(model.obj,origin)
                origin_class = getfield(model,'obj',origin,'class') ;
                
                switch origin_class
                case {'0','1'},
                    bond_origin = [origin_class,':',origin] ;
                otherwise,
                    origin_port = getfield(model,'obj',origin,'interface',{port},'name') ;
                    bond_origin = [origin_class,':',origin,'[',origin_port,']'] ;
                end
            else
                bond_origin = ['SS:',origin] ;
            end
            
            target = model.bond(i).to.obj ;
            port = model.bond(i).to.interface ;
            
            if isfield(model.obj,target)
                target_class = getfield(model,'obj',target,'class') ;
                
                switch target_class
                case {'0','1'},
                    bond_target = [target_class,':',target] ;
                otherwise,
                    target_port = getfield(model,'obj',target,'interface',{port},'name') ;
                    bond_target = [target_class,':',target,'[',target_port,']'] ;
                end
            else
                bond_target = ['SS:',target] ;
            end
            
            next = next + 1 ;
            descriptor = ['      ',num2str(next),': ',branch,'(',num2str(i),') from: ',...
                bond_origin,' to: ',bond_target] ;
            
            mttNotify(descriptor) ;
            mttWriteNewLine ;
        end
    end
    
    
    next_next = next ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            next_branch = [branch,'/',object_name] ;
            next_next = mttIdentifyUndercausalBonds(object,next_branch,next) ;
            next = next_next ;
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttIdentifyUserDomain.m version [c4859d1958].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function user_domain_identification = mttIdentifyUserDomain(environment,domain,domain_item)
    user_domain_identification = [] ;
    
    if ~(isempty(domain) | isempty(domain_item))
        user_domain_names = mttGetFieldNames(environment,'domain') ;
        number_of_user_domains = length(user_domain_names) ;
        
        counter = 0 ;
        
        identifying = 1 ;
        while identifying
            counter = counter + 1 ;
            user_domain_name = user_domain_names{counter} ;
            user_domain = getfield(environment,'domain',user_domain_name) ;
            
            specified_domain = user_domain.dom ;
            specified_domain_item = user_domain.item ;
            
            if domain==specified_domain
                if ~isempty(domain_item)
                    if isempty(specified_domain_item)
                        domain_item_names = mttGetFieldNames(environment.public_domain(domain),'item') ;
                        is_valid_item = ismember(domain_item,domain_item_names) ;
                        if is_valid_item
                            user_domain_identification = [user_domain_name,'__',domain_item] ;
                        end
                    else
                        is_matched_item = strcmp(domain_item,specified_domain_item) ;
                        if is_matched_item
                            user_domain_identification = user_domain_name ;
                        end
                    end
                end
            end
            
            identifying = (counter<number_of_user_domains) & isempty(user_domain_identification) ;
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttIsEmptyCellArray.m version [39b20a02b5].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
function boolean = mttIsEmptyCellArray(cell_array)
    boolean = [] ;
    if iscell(cell_array)
        boolean = 1 ;
        for i = 1:length(cell_array)
            if ~isempty(cell_array{i})
                boolean = 0 ;
            end
        end
    end

Deleted mttroot/ntt/bin/trans/mttIsEqual.m version [6c0e6f54d5].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function result = mttIsEqual(left,right)
	if ~isempty(left) & ~isempty(right)
        result = left==right ;
    else
        result = [] ;
    end
    

Deleted mttroot/ntt/bin/trans/mttIsFoundationClass.m version [33607d1580].

1
2
3
4




-
-
-
-
function boolean = mttIsFoundationClass(class_name)
    boolean = ismember(class_name,...
        {'R','C','I','TF','GY','AE','AF','SS','Se','Sf','De','Df','0','1'}) ;

Deleted mttroot/ntt/bin/trans/mttIsNumericText.m version [8cd049d628].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function boolean = mttIsNumericText(text)

    if any(abs(text)==39)
    % MATLAB doesn't like apostrophes in text
        boolean = 0 ;
    elseif strcmp(text,'flow')
    % MATLAB invokes built-in function "flow" rather than treating it as text in str2num(text) !!!
        boolean = 0 ;
    elseif strcmp(text,'error')
    % MATLAB invokes built-in function "error" rather than treating it as text in str2num(text) !!!
        boolean = 0 ;
    else
        num = str2num(text) ;
        if isempty(num)
            boolean = 0 ;
            % ... contains non-numeric characters other than stand-alone "i" or "j"
        else
            boolean = isreal(num) ;
            % ... doesn't contain stand-alone "i" or "j"
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttIsPassiveClass.m version [e8bd676573].

1
2


-
-
function boolean = mttIsPassiveClass(class_name)
	boolean = ismember(class_name,{'SS','Se','Sf','De','Df','0','1'}) ;

Deleted mttroot/ntt/bin/trans/mttIsPortClass.m version [5ddeb3fb33].

1
2


-
-
function boolean = mttIsPortClass(class_name)
	boolean = ismember(class_name,{'SS','Se','Sf','De','Df'}) ;

Deleted mttroot/ntt/bin/trans/mttLocateDirectory.m version [4faff0628d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function directory = mttLocateDirectory(working_directory,local_directory)
	if isempty(local_directory)
        directory = working_directory ;
    else
        backslash = findstr(working_directory,'\') ;
        working_directory(backslash) = '/' ;
        
        [working_drive,working_path] = mttCutText(working_directory,':') ;
        if isempty(working_path)
            working_path = working_directory ;
            working_drive = [] ;
        end
        
        [local_drive,local_path] = mttCutText(local_directory,':') ;
        if isempty(local_path)
            local_path = local_directory ;
            local_drive = [] ;
        end
        
        
        if isempty(local_drive)
            if local_path(1)=='/'
                if isempty(working_drive)
                    directory = local_path ;
                else
                    directory = [working_drive,':',local_path] ;
                end
            else
                directory = [working_directory,'/',local_directory] ;
            end
        else
            mttAssert(all(isletter(local_drive)),...
                ['"',local_drive,'" is an invalid drive specifier']) ;
            directory = local_directory ;
        end
        mttAssert(exist(directory,'dir')==7,...
            ['Directory "',directory,'" not found']) ;
        
        locating = 1 ;
        while locating
            [left,right] = mttCutText(directory,'//') ;
            if isempty(right)
                locating = 0 ;
            else
                directory = [left,'/',right] ;
            end
        end
        
        locating = 1 ;
        while locating
            backtrack = findstr(directory,'/..') ;
            if isempty(backtrack)
                locating = 0 ;
            else
                [left,right] = mttCutText(directory,'/..') ;
                if isempty(right)
                    [cancelled,left] = mttDetachText(left,'/') ;
                    directory = left ;
                else
                    [cancelled,left] = mttDetachText(left,'/') ;
                    directory = [left,right] ;
                end
            end
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttMeasureCausalCompletion.m version [0f88a2574d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttMeasureCausalCompletion(model)
    
    number_of_bonds = mttGetFieldLength(model,'bond') ;

    for i = 1:number_of_bonds
        effort_defined(i) = ~isempty(model.bond(i).effort) ;
        flow_defined(i) = ~isempty(model.bond(i).flow) ;
    end
    partly_defined = effort_defined|flow_defined ;
    fully_defined = effort_defined&flow_defined ;
    
    causal_completion.bonds = number_of_bonds ;
    causal_completion.flows = sum(flow_defined) ;
    causal_completion.efforts = sum(effort_defined) ;
    causal_completion.assignments = sum(partly_defined) ;
    
    unicausal_bonds = 0 ;
    causal_bond = model.bond(fully_defined) ;
    for i = 1:length(causal_bond)
        if causal_bond(i).effort==causal_bond(i).flow
            unicausal_bonds = unicausal_bonds + 1 ;
        end
    end
    causal_completion.unicausal = unicausal_bonds ;
    causal_completion.is_unicausal = causal_completion.assignments==causal_completion.unicausal ;
    
    causal_completion.is_causal = (causal_completion.efforts==causal_completion.bonds) ...
                                & (causal_completion.flows==causal_completion.bonds) ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        if ~isempty(object.abg)
            object = mttMeasureCausalCompletion(object) ;
            
            causal_completion.bonds         = causal_completion.bonds        + object.causal_completion.bonds ;
            causal_completion.flows         = causal_completion.flows        + object.causal_completion.flows ;
            causal_completion.efforts       = causal_completion.efforts      + object.causal_completion.efforts ;
            causal_completion.assignments   = causal_completion.assignments  + object.causal_completion.assignments ;
            causal_completion.unicausal     = causal_completion.unicausal    + object.causal_completion.unicausal ;
            
            causal_completion.is_unicausal  = causal_completion.is_unicausal & object.causal_completion.is_unicausal ;
            causal_completion.is_causal     = causal_completion.is_causal    & object.causal_completion.is_causal ;
        end
    end
    
    model.causal_completion = causal_completion ;
    
    

Deleted mttroot/ntt/bin/trans/mttMeasureDomainCompletion.m version [ba3a2087d1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function model = mttMeasureDomainCompletion(model)
    
    number_of_bonds = mttGetFieldLength(model,'bond') ;

    for i = 1:number_of_bonds
        domain_defined(i) = ~isempty(model.bond(i).domain) ;
    end
    
    domain_completion.bonds = number_of_bonds ;
    domain_completion.assignments = sum(domain_defined) ;
    
    domain_completion.is_done = (domain_completion.bonds==domain_completion.assignments) ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        if ~isempty(object.abg)
            object = mttMeasureDomainCompletion(object) ;
            
            domain_completion.bonds       = domain_completion.bonds       + object.domain_completion.bonds ;
            domain_completion.assignments = domain_completion.assignments + object.domain_completion.assignments ;
            
            domain_completion.is_done     = domain_completion.is_done     & object.domain_completion.is_done ;
        end
    end
    
    model.domain_completion = domain_completion ;
    
    

Deleted mttroot/ntt/bin/trans/mttNotify.m version [f0a2b33349].

1
2
3



-
-
-
function mttNotify(msg)
    fprintf(msg) ;
    

Deleted mttroot/ntt/bin/trans/mttNotifyCausalCompletion.m version [e3901e9d39].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttNotifyCausalCompletion(model)
    
	flow = floor(100*model.causal_completion.flows/model.causal_completion.bonds) ;
	effort = floor(100*model.causal_completion.efforts/model.causal_completion.bonds) ;
	unicausal = model.causal_completion.unicausal/model.causal_completion.bonds ;
	
    if model.causal_completion.is_unicausal
	    fprintf(['   ...causality is %i%% complete [%i/%i]: all unicausal\n'],...
            flow,model.causal_completion.assignments,model.causal_completion.bonds) ;
	else
	    fprintf(['   .....flow causality is %i%% complete [%i/%i]\n'],...
            flow,model.causal_completion.flows,model.causal_completion.bonds) ;
	    fprintf(['   ...effort causality is %i%% complete [%i/%i]\n'],...
            effort,model.causal_completion.efforts,model.causal_completion.bonds) ;
	    fprintf(['              => %i bonds are unicausal\n'],...
            model.causal_completion.unicausal) ;
	end

Deleted mttroot/ntt/bin/trans/mttNotifyDomainCompletion.m version [532186cac8].

1
2
3
4
5
6






-
-
-
-
-
-
function mttNotifyDomainCompletion(model)
    
	domain = floor(100*model.domain_completion.assignments/model.domain_completion.bonds) ;
	
    fprintf(['   ...domain allocation is %i%% complete [%i/%i]\n'],...
        domain,model.domain_completion.assignments,model.domain_completion.bonds) ;

Deleted mttroot/ntt/bin/trans/mttNotifyEquationSort.m version [5bdea2a945].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function is_complete = mttNotifyEquationSort(sort_iteration,...
    number_of_unsorted_equations,number_of_equations,...
    number_of_known_covariables,number_of_covariables,...
    number_of_known_interface_variables,number_of_interface_variables) ;
	
%	number_of_known_covariables = number_of_known_covariables - 1 ;
	number_of_known_interface_variables = number_of_known_interface_variables - 1 ;
    
    number_of_sorted_equations = number_of_equations - number_of_unsorted_equations ;
    
    sorted = floor(100*number_of_sorted_equations/number_of_equations) ;
    covar = floor(100*number_of_known_covariables/number_of_covariables) ;
    interface_var = floor(100*number_of_known_interface_variables/number_of_interface_variables) ;
    
    fprintf(['   ...%i%% complete [%i/%i]\n'],...
        sorted,number_of_sorted_equations,number_of_equations) ;
    fprintf(['          matching %i%% co_variables [%i/%i] and'],...
        covar,number_of_known_covariables,number_of_covariables) ;
    fprintf([' %i%% interface_variables [%i/%i]\n'],...
        interface_var,number_of_known_interface_variables,number_of_interface_variables) ;
    
    is_complete = (sorted==100) & (covar==100) & (interface_var==100) ;
    

Deleted mttroot/ntt/bin/trans/mttNotifyEquationSortProblems.m version [422f8ebbc4].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function mttNotifyEquationSortProblems(name_known,namelist)
    fprintf('   ...undetermined interface_variables are:\n') ;
	for i = 2:length(namelist)
        if ~name_known(i)
            fprintf(['         ',namelist{i},'\n']) ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttNotifyEquationSummary.m version [a1f8988b05].

1
2
3
4
5
6
7







-
-
-
-
-
-
-
function mttNotifyEquationSummary(number_of_equations,number_of_covariables,number_of_interface_variables)
    mttNotify(['   ...model has ',num2str(number_of_equations),' equations']) ;
    mttWriteNewLine ;
    mttNotify(['      with ',num2str(number_of_covariables),' co_variables']) ;
    mttNotify([' and ',num2str(number_of_interface_variables),' interface_variables']) ;
    mttWriteNewLine ;
    

Deleted mttroot/ntt/bin/trans/mttNotifyNumberOfBonds.m version [edfe090ab6].

1
2
3
4




-
-
-
-
function mttNotifyOfBonds(model)
    
	number_of_bonds  = model.causal_completion.bonds ;
    fprintf('   ...model has %i bonds',number_of_bonds) ;

Deleted mttroot/ntt/bin/trans/mttNotifyNumberOfObjects.m version [a3f2f2c77b].

1
2
3
4
5





-
-
-
-
-
function mttNotifyOfObjects(model)
    
	number_of_objects = model.count.obj ;
    number_of_crs = model.count.cr ; 
    fprintf('   ...model has %i active objects (%i implemented by CRs)',number_of_objects,number_of_crs) ;

Deleted mttroot/ntt/bin/trans/mttReadFile.m version [37968e6d57].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function content = mttReadFile(filename)

file_exists = exist(filename)==2 ;
if file_exists
    fid = fopen(filename,'r') ;
    reading = 1 ;
    
    counter = 0 ;
    while reading
        line = fgetl(fid) ;
        if ~isempty(line)
            if line==-1
                reading = 0 ;
            else
                counter = counter + 1 ;
                content{counter} = line ;
            end
        end
    end    
    fclose(fid) ;
else
    error(['file_not_found[',filename,']'])
end

Deleted mttroot/ntt/bin/trans/mttSeparateText.m version [4f00712084].

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [left,right] = mttSeparateText(text)
    if isempty(text)
	    left = [] ;
        right = [] ;
    else
		whitespace = min(find(isspace(text))) ;
        if isempty(whitespace)
            left = text ;
            right = [] ;
        else
            left = text(1:whitespace-1) ;
            right = mttClipText(text(whitespace+1:length(text))) ;
        end
    end

Deleted mttroot/ntt/bin/trans/mttSetFieldDefault.m version [5626026953].

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
function structure = mttSetFieldDefault(structure,component,value)
    undefined = 0 ;
    if isfield(structure,component)
        undefined = isempty(getfield(structure,component)) ;
    else
        undefined = 1 ;
    end
        
    if undefined
        structure = setfield(structure,component,value) ;
    end

Deleted mttroot/ntt/bin/trans/mttUpdateBondCausality.m version [f0b400b32e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%function [model,bond_not_failed,diagnostic] = mttUpdateBondCausality(...
%    model,bond_number,effort_causality,flow_causality,uni_causality)
function [model,bond_not_failed] = mttUpdateBondCausality(...
    model,bond_number,effort_causality,flow_causality,uni_causality)
    
    if isempty(bond_number)
        bond_not_failed = 1 ;
%        diagnostic = [] ;
    else
        [model.bond(bond_number).effort,effort_ok] = ...
            update_causality(model.bond(bond_number).effort,effort_causality) ;
        [model.bond(bond_number).flow,flow_ok] = ...
            update_causality(model.bond(bond_number).flow,flow_causality) ;
        [model.bond(bond_number).unicausal,unicausal_ok] = ...
            update_causality(model.bond(bond_number).unicausal,uni_causality) ;
        
        [model.bond(bond_number),unicausal_checked] = ...
            check_unicausal(model.bond(bond_number)) ;
        
        bond_not_failed = effort_ok & flow_ok & unicausal_ok & unicausal_checked ;
%        diagnostic = [effort_ok,flow_ok,unicausal_ok,unicausal_checked] ;
    end
    
    
function [value,ok] = update_causality(value,new_value)
    ok = 1 ;
    
    if ~isempty(new_value)
        if isempty(value)
            value = new_value ;
        else
            ok = value==new_value ;
        end
    end
    
function [bond,ok] = check_unicausal(bond)
    unicausal_defined = ~isempty(bond.unicausal) ;
    effort_defined = ~isempty(bond.effort) ;
    flow_defined = ~isempty(bond.flow) ;
    
    ok = 1 ;
    
    if unicausal_defined
        switch bond.unicausal
        case 0,
            if effort_defined & flow_defined
                ok = bond.effort==~bond.flow ;
            elseif effort_defined & ~flow_defined
                bond.flow = ~bond.effort ;
            elseif flow_defined & ~effort_defined
                bond.effort = ~bond.flow ;
            end
        case 1,
            if effort_defined & flow_defined
                ok = bond.effort==bond.flow ;
            elseif effort_defined & ~flow_defined
                bond.flow = bond.effort ;
            elseif flow_defined & ~effort_defined
                bond.effort = bond.flow ;
            end
        end
    end        
     

Deleted mttroot/ntt/bin/trans/mttUpdateBondDomain.m version [04cf4f8e59].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function [model,bond_not_failed] = mttUpdateBondDomain(...
    model,bond_number,imposed_domain,imposed_domain_item)
    
    if isempty(bond_number)
        bond_not_failed = 1 ;
    else
        [model.bond(bond_number).domain,domain_ok] = ...
            update_domain(model.bond(bond_number).domain,imposed_domain) ;
        if domain_ok
            [model.bond(bond_number).domain_item,domain_item_ok] = ...
                update_domain_item(model.bond(bond_number).domain_item,imposed_domain_item) ;
        else
            domain_item_ok = 0 ;
        end
        
        bond_not_failed = domain_ok & domain_item_ok ;
    end
    
    
function [value,ok] = update_domain(value,new_value)
    ok = 1 ;
    
    if ~isempty(new_value)
        if isempty(value)
            value = new_value ;
        else
            ok = value==new_value ;
        end
    end
    
function [value,ok] = update_domain_item(value,new_value)
    ok = 1 ;
    
    if ~isempty(new_value)
        if isempty(value)
            value = new_value ;
        else
            ok = strcmp(value,new_value) ;
        end
    end
    

Deleted mttroot/ntt/bin/trans/mttValidateName.m version [b841cdc721].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function mttValidateName(name)
    mttAssert(~isempty(name),'Empty name') ;
    
    numbers = (name>=48 & name<=57) ;
    letters = (name>=65 & name<=90)|(name>=97 & name<=122) ;
    underscores = (name==95) ;
    
    is_alphanumeric = all(numbers|letters|underscores) ;
    starts_with_letter = isletter(name(1)) ;
    
    valid_name = is_alphanumeric & starts_with_letter ;
%    mtt_prefix = strncmp(name,'mtt_',4) ;
    mtt_delimiter = ~isempty(findstr(name,'__')) ;
    
%    mttAssert(~mtt_prefix,['"',name,'" must not contain "mtt_" prefix']) ;
    mttAssert(~mtt_delimiter,['"',name,'" must not contain contiguous "_" delimiters']) ;
    mttAssert(valid_name,['"',name,'" is not a valid name']) ;
    mttAssert(length(name)<32,['"',name,'" must be shortened to less than 32 characters']) ;

Deleted mttroot/ntt/bin/trans/mttVerifyAlternativeEquations.m version [c872db1223].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function delta = mttVerifyEquations(primary,secondary)
    searching = 1 ;
    
    length_primary = length(primary) ;
    length_secondary = length(secondary) ;
    
    i = 1 ;
    j = 1 ;
    k = 1 ;
    fprintf('k=%i: i=%i j=%i L=%i\n',k,i,j,length_secondary) ;            

    while searching
        k = k + 1 ;
        if strcmp(primary(i),secondary(j))
            secondary(j) = [] ;
            length_secondary = length_secondary - 1 ;
            fprintf('k=%i: i=%i j=%i L=%i\n',k,i,j,length_secondary) ;            
            
            i = i + 1;
            j = 1 ;
        else
            j = j + 1 ;
        end
        
        if length_secondary<1
            searching = 0 ;
        elseif j>length_secondary
            i = i + 1 ;
            j = 1 ;
        end
        
        if i>length_primary
            searching = 0 ;
        end
    end
            
    delta = secondary ;

    fprintf('Verification complete after %i iterations\n',k) ;            
    fprintf('...%i new records found\n',length(delta)) ;
    

Deleted mttroot/ntt/bin/trans/mttWriteNewLine.m version [252139e429].

1
2
3



-
-
-
function mttWriteNewLine
	fprintf('\n') ;

Deleted mttroot/patches/p2c/p2c-1.21alpha2/lex.c.diff version [7c654e3c9b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
*** p2c-1.22/src/lex.c	Tue Mar 16 09:28:20 1999
--- p2c-1.22-dev/src/lex.c	Tue Jan 30 16:57:23 2001
*************** Static int skipflag;
*** 38,44 ****
  Static char modulenotation;
  Static short inputkind;
  Static Strlist *instrlist;
! Static char inbuf[300];
  Static char *oldinfname, *oldctxname;
  Static Strlist *endnotelist;
  
--- 38,44 ----
  Static char modulenotation;
  Static short inputkind;
  Static Strlist *instrlist;
! Static char *inbuf;
  Static char *oldinfname, *oldctxname;
  Static Strlist *endnotelist;
  
*************** void init_lex()
*** 411,416 ****
--- 411,417 ----
      inputkind = INP_FILE;
      inf_lnum = 0;
      inf_ltotal = 0;
+     inbuf = ALLOC(buffersize, char, strings); /* strings ? */
      *inbuf = 0;
      inbufptr = inbuf;
      keepingstrlist = NULL;
*************** void getline()
*** 1055,1061 ****
          case INP_INCFILE:
              inf_lnum++;
  	    inf_ltotal++;
!             if (fgets(inbuf, 300, inf)) {
                  cp = inbuf + strlen(inbuf);
                  if (*inbuf && cp[-1] == '\n')
                      cp[-1] = 0;
--- 1056,1062 ----
          case INP_INCFILE:
              inf_lnum++;
  	    inf_ltotal++;
!             if (fgets(inbuf, buffersize, inf)) {
                  cp = inbuf + strlen(inbuf);
                  if (*inbuf && cp[-1] == '\n')
                      cp[-1] = 0;
*************** int p2c_only, starparen;
*** 1889,1895 ****
      }
      if (!isalpha(*cp))
          return 0;
!     while ((isalnum(*cp) || *cp == '_') && cp2 < namebuf+300)
          *cp2++ = toupper(*cp++);
      if (cp[0] == '+' && cp[1] == '+' &&
  	cp == inbufptr+1 && toupper(cp[-1]) == 'C')
--- 1890,1896 ----
      }
      if (!isalpha(*cp))
          return 0;
!     while ((isalnum(*cp) || *cp == '_') && cp2 < namebuf+buffersize)
          *cp2++ = toupper(*cp++);
      if (cp[0] == '+' && cp[1] == '+' &&
  	cp == inbufptr+1 && toupper(cp[-1]) == 'C')

Deleted mttroot/patches/p2c/p2c-1.21alpha2/loc.p2crc version [73e4cd2acc].

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-

# Store public p2crc commands local to your system here, so that
# you can grab a new version of sys.p2crc without losing your changes.

BufferSize=1000000.

LineWidth=1000000.
MaxLineWidth=1000000.

OverWidePenalty=0.
OverWideExtraPenalty=0.

Deleted mttroot/patches/p2c/p2c-1.21alpha2/parse.c.diff version [305c42d48a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
*** p2c-1.22/src/parse.c	Tue Mar 16 09:28:20 1999
--- p2c-1.22-dev/src/parse.c	Tue Jan 30 16:30:40 2001
*************** int p_search(fname, ext, need)
*** 5477,5483 ****
  char *fname, *ext;
  int need;
  {
!     char infnbuf[300];
      FILE *fp;
      Meaning *mod;
      int savesysprog, savecopysource;
--- 5477,5483 ----
  char *fname, *ext;
  int need;
  {
!     char infnbuf[buffersize];
      FILE *fp;
      Meaning *mod;
      int savesysprog, savecopysource;

Deleted mttroot/patches/p2c/p2c-1.21alpha2/sys.p2crc.diff version [189e9e035c].

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
*** p2c-1.22/src/sys.p2crc	Tue Mar 16 09:28:20 1999
--- p2c-1.22-dev/src/sys.p2crc	Tue Jan 30 17:01:14 2001
*************** MinSpacingThresh                # If spe
*** 455,460 ****
--- 455,462 ----
  
  # LINE BREAKING
  
+ BufferSize			# Maximum input line length; default=300.
+ 
  LineWidth                       # Target max output line width; default=78.
  
  MaxLineWidth                    # Absolute max output line width; default=90.

Deleted mttroot/patches/p2c/p2c-1.21alpha2/trans.h.diff version [e99f32563f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
*** p2c-1.22/src/trans.h	Tue Mar 16 09:28:21 1999
--- p2c-1.22-dev/src/trans.h	Tue Jan 30 17:25:33 2001
*************** extern int sizeof_char, sizeof_short, si
*** 1133,1138 ****
--- 1133,1139 ----
  extern short size_t_long;
  extern int setbits, defaultsetsize, seek_base, integerwidth, realwidth;
  extern short quoteincludes, expandincludes, collectnest;
+ extern const int buffersize;
  extern int phystabsize, intabsize, linewidth, maxlinewidth;
  extern int majorspace, minorspace, declspace, functionspace, minfuncspace;
  extern int casespacing, caselimit;
*************** struct rcstruct {
*** 1351,1356 ****
--- 1352,1358 ----
      'I', 'R', "MINSPACINGTHRESH",(anyptr) &minspacingthresh, -1,
  
  /* LINE BREAKING */
+     'I', 'R', "BUFFERSIZE",	(anyptr) &buffersize,	300,
      'I', 'R', "LINEWIDTH",       (anyptr) &linewidth,        78,
      'I', 'R', "MAXLINEWIDTH",    (anyptr) &maxlinewidth,     90,
      'R', 'V', "OVERWIDEPENALTY",       (anyptr) &overwidepenalty,         2500,

Added ntt/COPYING version [8252cc0f12].







































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

    ntt: new transformation tools for using bond graphs with Matlab
    Copyright (C) 2003  Dr. Dominic J. Diston

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
^L
		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

		    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

			    NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS

	    How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year  name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

Added ntt/bin/make_abg.m version [44a307073f].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function abg = make_abg(system)
global mtt_environment

start_time = mttGetTime ;

input = [] ;
abg = [] ;


switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    


if strcmp(input,'spec')
    mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;

    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

mttAssert(strcmp(input,'abg'),'Input representation not recognised') ;

if isempty(abg)
    mttWriteNewLine ;
    mttNotify('Copying "abg" representation') ;
    mttWriteNewLine ;
    
    mttNotify('...INFO: Input already defined as a "abg": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    abg = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Added ntt/bin/make_cbg.m version [d10c4751f3].







































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function cbg = make_cbg(system)
global mtt_environment

start_time = mttGetTime ;

input = [] ;
abg = [] ;
cbg = [] ;


switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    


if strcmp(input,'spec')
    mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;

    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

mttAssert(strcmp(input,'cbg'),'Input representation not recognised') ;

if isempty(cbg)
    mttWriteNewLine ;
    mttNotify('Copying "cbg" representation') ;
    mttWriteNewLine ;

    mttNotify('...INFO: Input already defined as a "cbg": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    cbg = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Added ntt/bin/make_env.m version [bd8ec0bc89].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function make_env(system)
global mtt_environment

start_time = mttGetTime ;

input = [] ;
env = [] ;


switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

if strcmp(input,'spec')
    mttWriteNewLine ;
    mttNotify('Making "env" representation') ;
    mttWriteNewLine ;

    env = mttCreateEnvironment(system) ;
    input = 'env' ;
end

mttAssert(strcmp(input,'env'),'Input representation not recognised') ;

if isempty(env)
    mttWriteNewLine ;
    mttNotify('Copying "env" representation') ;
    mttWriteNewLine ;

    mttNotify('...INFO: Input already defined as a "env": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    env = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;


mtt_environment = env ;

Added ntt/bin/make_ese.m version [2b8c245d06].





















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ese = make_ese(system,sorter_on)
global mtt_environment

if nargin<2
    sorter_on = 1 ;
end

switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

start_time = mttGetTime ;

abg = [] ;
cbg = [] ;
ese = [] ;

if strcmp(input,'spec')
 	mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;
    
    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

if strcmp(input,'cbg')
    if isempty(cbg)
        cbg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "cbg" to "ese"') ;
    mttWriteNewLine ;
    ese = mttCreateElementaryEquations(cbg,sorter_on) ;
    input = 'ese' ;
end

mttAssert(strcmp(input,'ese'),'Input representation not recognised') ;

if isempty(ese)
    mttWriteNewLine ;
    mttNotify('Making "ese" representation') ;
    mttWriteNewLine ;

    mttNotify('Input already defined as a "ese": copying to Output') ;
    mttWriteNewLine ;
    mttWriteNewLine ;
    ese = system ;
end


elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Added ntt/bin/make_mdl.m version [8f904e7563].















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function make_sfun(system,sorter_on)
global mtt_environment

if nargin<2
    sorter_on = 1 ;
end

switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

start_time = mttGetTime ;

abg = [] ;
cbg = [] ;
ese = [] ;

if strcmp(input,'spec')
 	mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;
    
    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

if strcmp(input,'cbg')
    if isempty(cbg)
        cbg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "cbg" to "ese"') ;
    mttWriteNewLine ;
    ese = mttCreateElementaryEquations(cbg,sorter_on) ;
    input = 'ese' ;
end

mttAssert(strcmp(input,'ese'),'Input representation not recognised') ;

if isempty(ese)
    ese = system ;
end
mttCreateSystemMdl(ese) ;
    

elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Added ntt/bin/make_sfun.m version [9b2b6d6f69].






















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function make_sfun(system,sorter_on)
global mtt_environment

if nargin<2
    sorter_on = 1 ;
end

switch class(system)
case 'char',
    input = 'spec' ;
case 'struct',
    if isfield(system,'representation')
        input = system.representation ;
    end
end    

start_time = mttGetTime ;

abg = [] ;
cbg = [] ;
ese = [] ;

if strcmp(input,'spec')
 	mttWriteNewLine ;
    mttNotify('Making "abg" representation') ;
    mttWriteNewLine ;
    
    if isempty(mtt_environment)
        mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
        mttWriteNewLine ;
        mttNotify('                                => paths will not be recognised') ;
        mttWriteNewLine ;
    end
    
    abg = mttCreateAcausalBondgraph(system) ;
    input = 'abg' ;
end

if strcmp(input,'abg')
    if isempty(abg)
        abg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "abg" to "cbg"') ;
    mttWriteNewLine ;
    cbg = mttCreateCausalBondgraph(abg) ;
    input = 'cbg' ;
end

if strcmp(input,'cbg')
    if isempty(cbg)
        cbg = system ;
    end
    
    mttWriteNewLine ;
    mttNotify('Transforming from "cbg" to "ese"') ;
    mttWriteNewLine ;
    ese = mttCreateElementaryEquations(cbg,sorter_on) ;
    input = 'ese' ;
end

mttAssert(strcmp(input,'ese'),'Input representation not recognised') ;

if isempty(ese)
    ese = system ;
end
mttWriteSystemEquations(ese) ;
mttWriteSystemDefinitions(ese) ;
mttWriteSystemInitialisation(ese) ;
mttWriteSystemMapping(ese) ;

ese = mttCreateApps(ese) ;
mttWriteSystemApps(ese) ;
mttWriteSystemSfun(ese) ;
    

elapsed_time = mttElapseTime(start_time) ;
cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;

mttWriteNewLine ;    
mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
mttWriteNewLine ;    
mttWriteNewLine ;

Added ntt/bin/trans/m/mttApplyInterfaceCausality.m version [028f9372f5].









































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttApplyInterfaceCausality(model,specified_rule,branch) ;
    is_root_model = (nargin==2) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttApplyInterfaceCausality(object,specified_rule,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        else
            if ~isempty(object.cr)
                if is_root_model
                    branch = mttDetachText(model.source,'/') ;
                end
                here = [branch,':',object_name] ;
                
                port_names = mttGetFieldNames(object.cr.interface,'port') ;
                
                for j = 1:length(port_names)
                    port_name = port_names{j} ;
                    port = getfield(object.cr.interface,'port',port_name) ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    for k = 1:mttGetFieldLength(port,'causality')
                        rule = port.causality(k).rule ;
                        definition = port.causality(k).def ;
                        association = port.causality(k).with ;
                        not_applied = ~port.causality(k).applied ;
                        
                        switch rule
                        case 'assert',  is_assertion = 1 ;
                        case 'prefer',  is_assertion = 0 ;
                        otherwise
                            error(['Unrecognised rule "',port_causality.rule,'" in ',here]) ;
                        end
                        
                        apply_rule = strcmp(specified_rule,rule) & not_applied ;
                        if apply_rule
                            
                            switch definition
%                            case 'effort_state',
%                                mttAssert(mttIsEqual(port.is_flow_state,0),...
%                                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
%                                port.is_effort_state = 1 ;
                                
%                            case 'flow_state',
%                                mttAssert(mttIsEqual(port.is_effort_state,0),...
%                                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
%                                port.is_flow_state = 1 ;
                                
                            case {'effort_in_flow_out','flow_in_effort_out','flow_out_effort_in','effort_out_flow_in'}
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                switch definition
                                case {'effort_in_flow_out','flow_out_effort_in'},
                                    [model,inbond_ok] = mttUpdateBondCausality(model,inbond,1,1,1) ; 
                                    [model,outbond_ok] = mttUpdateBondCausality(model,outbond,0,0,1) ;
                                case {'flow_in_effort_out','effort_out_flow_in'},
                                    [model,inbond_ok] = mttUpdateBondCausality(model,inbond,0,0,1) ; 
                                    [model,outbond_ok] = mttUpdateBondCausality(model,outbond,1,1,1) ;
                                end

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'effort_in'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,1,[],1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,0,[],1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'effort_out'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,0,[],1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,1,[],1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'flow_in'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,[],0,1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,[],1,1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'flow_out'
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,[],1,1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,[],0,1) ;

                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case 'unicausal',
                                mttAssert(isempty(association),...
                                    ['Over-constraint at port "',port_name,'" in ',here]) ;
                                
                                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,[],[],1) ; 
                                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,[],[],1) ;
                                
                                ok = inbond_ok & outbond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
                                end
                                
                            case {'equicausal','anticausal'}
                                mttAssert(length(association)==1,...
                                    ['Incorrect constraint at port "',port_name,'" in ',here]) ;
                                
                                associated_port_name = association{1} ;
                                associated_port = getfield(cr.interface,'port',associated_port_name) ;
                                
                                associated_inbond = associated_port.in ;
                                associated_outbond = associated_port.out ;
                                
                                mttAsert(xor(isempty(inbond),isempty(outbond)),...
                                    ['Causal rule expects unique bond at port "',port_name,'" in ',here]) ;
                                mttAsert(xor(isempty(associated_inbond),isempty(associated_outbond)),...
                                    ['Causal rule expects unique bond at port "',associated_port_name,'" in ',here]) ;
                                
                                if isempty(associated_inbond)
                                    a = associated_outbond ;
                                else
                                    a = associated_inbond ;
                                end
                                
                                if isempty(inbond)
                                    b = outbond ;
                                else
                                    b = inbond ;
                                end
                                
                                switch definition
                                case 'equicausal',
                                    [model,bond_ok] = mttUpdateBondCausality(model,b,...
                                        model.bond(a).effort,model.bond(a).flow,model.bond(a).unicausal) ; 
                                    [model,associated_bond_ok] = mttUpdateBondCausality(model,a,...
                                        model.bond(b).effort,~model.bond(b).flow,model.bond(b).unicausal) ;
                                case 'anticausal',
                                    [model,bond_ok] = mttUpdateBondCausality(model,b,...
                                        ~model.bond(a).effort,model.bond(a).flow,model.bond(a).unicausal) ; 
                                    [model,associated_bond_ok] = mttUpdateBondCausality(model,a,...
                                        ~model.bond(b).effort,~model.bond(b).flow,model.bond(b).unicausal) ;
                                end
                                
                                ok = bond_ok & associated_bond_ok ;
                                if is_assertion
                                    mttAssert(ok,['Causal conflict between ports "',port_name,...
                                            'and',associated_port_name,'" in ',here]) ;
                                end
                                
                            otherwise,
                                error(['Unrecognised constraint "',definition,'" in ',here]) ;
                            end
                            
                            port.causality(k).applied = 1 ;
                            object = setfield(object,'cr','interface','port',port_name,port) ;
                            model = setfield(model,'obj',object_name,object) ;
                        end                    
                    end
                end
            end
        end
    end
    

Added ntt/bin/trans/m/mttApplyInterfaceDomains.m version [bfc53eba3d].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttApplyInterfaceDomains(model,branch) ;
    is_root_model = (nargin==1) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttApplyInterfaceDomains(object,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        else
            if ~isempty(object.cr)
                if is_root_model
                    branch = mttDetachText(model.source,'/') ;
                end
                here = [branch,':',object_name] ;
                
                port_names = mttGetFieldNames(object.cr.interface,'port') ;
                
                for j = 1:length(port_names)
                    port_name = port_names{j} ;
                    port = getfield(object.cr.interface,'port',port_name) ;
                    
                    predefined_domain = port.domain ;
                    predefined_domain_item = port.domain_item ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    if isempty(inbond)
                        bond_number = outbond ;
                    else
                        bond_number = inbond ;
                    end
                    
                    [model,ok] = mttUpdateBondDomain(model,bond_number,predefined_domain,predefined_domain_item) ;
                    
                    mttAssert(ok,['Domain conflict at port "',port_name,'" in ',here]) ;
                end
            end
        end
    end
    

Added ntt/bin/trans/m/mttCreateAcausalBondgraph.m version [a4799dbea4].




































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttCreateAcausalBondgraph(system,root)
global mtt_environment


switch nargin
case 0,
    model = [] ; return ;
case 1,
    root = [] ;
    is_root_model = 1 ;
otherwise,
    is_root_model = 0 ;
end

if is_root_model
    model = intialise_model(system) ;
    
    directory_name = identify_directory_name(system) ;
    source_name = identify_source_name(system,directory_name) ;
    
    mttNotify('...acquiring "abg" source definitions') ;
    mttWriteNewLine ;
else
    model = propagate_root_data(root) ;
    source_name = system ;
end

specification_filename = [source_name,'_abg.txt'] ;
specification = mttFetchSpecification(specification_filename) ;
specification = mttSetFieldDefault(specification,'bondgraph',system) ;
    
[local_system_name,rubbish] = mttDetachText(system,'/') ;
if isempty(local_system_name)
    local_system_name = system ;
end


if is_root_model
    source_name = identify_source_name(specification.bondgraph,directory_name) ;
else
    source_name = specification.bondgraph ;
end
source_name = mttCutText(source_name,'_abg.fig') ;

bondgraph_filename = [source_name,'_abg.fig'] ;
bondgraph = mttFetchBondgraph(bondgraph_filename) ;

model = mttCreateUnifiedModel(model,bondgraph,specification) ;
model = mttDeleteField(model,'branch') ;
model = mttDeleteField(model,'leaf') ;


if is_root_model
    mttWriteNewLine ;
    mttNotify('...acquiring "cr" source definitions') ;
    mttWriteNewLine ;
    
    for n = 1:length(model.crs)
        source_name = model.crs{n} ;
        cr_filename = [source_name,'_cr.txt'] ;
        
        if ~mttFileExists(cr_filename)
            cr_short_name = mttDetachText(source_name,'/') ;
            
            mttNotify(['   ...ERROR: "',cr_short_name,'_cr" source does not exist']) ;
            mttWriteNewLine ;
            mttNotify(['   ...finding dependencies for ',source_name,':']) ;
            mttWriteNewLine ;
            
            prefix = mttDetachText(system,'/') ;
            if isempty(prefix)
                prefix = system ;
            end
            
            cr_user = model.cr_usage(n).obj ;
            for i = 1:length(cr_user)
                mttNotify(['         ',prefix,'/',cr_user{i}]) ;
                mttWriteNewLine ;
            end
        end
        
        model.cr(n) = mttFetchInterfaceDefinition(cr_filename) ;
    end
    
    model = mttDeleteField(model,'cr_usage') ;
    model = mttDeleteField(model,'crs') ;
    model = mttDeleteField(model,'abgs') ;
end

model.env = mtt_environment ;



function model = intialise_model(system)
    model.representation = 'abg' ;
    model.abgs = [] ;
    model.crs = [] ;
    model.cr_usage = [] ;
    model.branch = [] ;
    model.leaf = [] ;
    
function model = propagate_root_data(root)
    model.abgs = root.abgs ;
    model.crs = root.crs ;
    model.cr_usage = root.cr_usage ;
    model.branch = root.branch ;
    model.leaf = root.leaf ;

function directory = identify_directory_name(system)
    mttAssert(ischar(system),'System must be specified by name') ;
    working_directory  = pwd ;
    working_directory = strrep(working_directory,'\','/') ;
    
    [system_name,local_directory] = mttDetachText(system,'/') ;
    if isempty(system_name)
        local_directory = [] ;
    end
    
    if isempty(local_directory)
        directory = working_directory ;
    else
        directory = mttLocateDirectory(working_directory,local_directory) ;
    end
    
function source = identify_source_name(system,directory)
    [system_name,local_directory] = mttDetachText(system,'/') ;
    if isempty(system_name)
        system_name = system ;
        local_directory = [] ;
    end
    source = [directory,'/',system_name] ;

Added ntt/bin/trans/m/mttCreateApps.m version [dd7bd6b560].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttCreateApps(model)

apps_filename = [model.source,'_apps.txt'] ;
apps = mttFetchApps(apps_filename) ;

if isempty(apps)
    return ;
end

for i = 1:length(apps.app)
    app_source = apps.app{i} ;
    
    [rubbish,working_directory] = mttDetachText(model.source,'/') ;
    [name,path_spec] = mttDetachText(app_source,'/') ;
    
    if isempty(name)
        source_name = [working_directory,'/',domain_source] ;
    else
        directory = identify_directory(working_directory,path_spec,model) ;
        source_name = [directory,'/',name] ;
    end
    
    app_filename = [source_name,'_app.h'] ;
    model.app{i} = app_filename ;
end

    
function directory = identify_directory(working_directory,path_spec,model)
	path_names = mttGetFieldNames(model.env,'path') ;

    if isempty(path_spec)
		directory = [] ;
    else
        if path_spec(1)=='$'
            [path_alias,path_branch] = mttCutText(path_spec,'/') ;
            path_alias(1) = [] ;
            
            mttAssert(ismember(path_alias,path_names),...
                ['Path "',path_alias,'" not recognised']) ;
            
            path_root = getfield(model.env,'path',path_alias) ;
            
            if isempty(path_branch)
                directory = path_root ;
            else
                directory = [path_root,'/',path_branch] ;
            end
        else
            [name,local_directory] = mttDetachText(path_spec,'/') ;
            
            directory_located = 0 ;
            if strcmp(local_directory,'.')
                if isempty(name)
                    directory = working_directory ;
                    directory_located = 1 ;
                else
                    local_directory = name ;
                end
            else
                local_directory = path_spec ;
            end
            
            if ~directory_located
                directory = mttLocateDirectory(working_directory,local_directory) ;
            end
        end
    end
    




Added ntt/bin/trans/m/mttCreateCausalBondgraph.m version [88053c538d].





































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttCreateCausalBondgraph(model)

model.representation = 'cbg' ;

model = incorporate_interface_definitions(model) ;
model = establish_abg_dependencies(model) ;
model = create_object_hierarchy(model) ;
model = assign_sympar_values(model) ;
model = complete_causal_assignment(model) ;
model = complete_domain_assignment(model) ;
model = overwrite_implicit_domains(model) ;


function model = incorporate_interface_definitions(model)
	mttNotify('...incorporating "cr" definitions') ;
    mttWriteNewLine ;
    
    mttNotify(['   ...processing ',model.source]) ;
    mttWriteNewLine ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~mttIsFoundationClass(object.class)
            mttAssert(xor(isempty(object.abg),isempty(object.cr)),...
                ['"',object_name,'" must exclusively have a "cr" or an "abg" representation']) ;
        end
        
        if isempty(object.cr)
            object = mttDeleteField(object,'cr_item') ;
            model = setfield(model,'obj',object_name,object) ;
        else
            model = mttEmbedInterfaceDefinition(model,object_name) ;
        end
    end
    
    for i = 1:mttGetFieldLength(model,'abg')
        component_type = mttDetachText(model.abg(i).source,'/') ;
        mttNotify(['   ...processing "#',num2str(i),':',component_type,'" ',model.abg(i).source]) ;
        mttWriteNewLine ;
        
        objects = mttGetFieldNames(model.abg(i),'obj') ;
        for j = 1:length(objects)
	        object_name = objects{j} ;
            object = getfield(model,'abg',{i},'obj',object_name) ;
            
    	    if ~mttIsFoundationClass(object.class)
	            mttAssert(xor(isempty(object.abg),isempty(object.cr)),...
        	        ['abg[',num2str(i),']: "',object_name,'" must exclusively have a "cr" or an "abg" representation']) ;
            end
            
            if isempty(object.cr)
                object = mttDeleteField(object,'cr_item') ;
                model = setfield(model,'abg',{i},'obj',object_name,object) ;
            else
                model.abg(i) = mttEmbedInterfaceDefinition(model.abg(i),object_name,model) ;
            end
        end
        model.abg(i).invokes = [] ;
        model.abg(i).invoked_by = [] ;
    end
    model = mttDeleteField(model,'cr') ;
    
    
function model = establish_abg_dependencies(model)
	mttNotify('...establishing "abg" dependencies') ;
    mttWriteNewLine ;
    
    for i = 1:mttGetFieldLength(model,'abg')
        objects = mttGetFieldNames(model.abg(i),'obj') ;
        for j = 1:length(objects)
            object_name = objects{j} ;
            object = getfield(model.abg(i).obj,object_name) ;
            
            if isempty(object.cr)	%... still within object hierarchy
                if ~mttIsFoundationClass(object.class)
                    existing_dependencies = model.abg(i).invokes ;
                    
                    if isempty(existing_dependencies)
                        new_dependency = 1 ;
                    else
                        new_dependency = isempty(find(existing_dependencies==object.abg)) ;
                    end
                    
                    if new_dependency
                        model.abg(i).invokes = [existing_dependencies,object.abg] ;
                    end
                    
                    existing_dependencies = model.abg(object.abg).invoked_by ;
                    if isempty(existing_dependencies)
                        new_dependency = 1 ;
                    else
                        new_dependency = isempty(find(existing_dependencies==i)) ;
                    end
                    
                    if new_dependency
                        model.abg(object.abg).invoked_by = [existing_dependencies,i] ;
                    end
                end
            end
        end
    end
    
    model.invokes = [] ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for j = 1:length(objects)
        object_name = objects{j} ;
        object = getfield(model.obj,object_name) ;
        
        if ~isempty(object.abg)
            if ~mttIsFoundationClass(object.class)
                existing_dependencies = model.invokes ;
                
                if isempty(existing_dependencies)
                    new_dependency = 1 ;
                else
                    new_dependency = isempty(find(existing_dependencies==object.abg)) ;
                end
                
                if new_dependency
                    model.invokes = [existing_dependencies,object.abg] ;
                end
            end
        end
    end
    
    
function model = create_object_hierarchy(model) ;
	mttNotify('...creating object hierarchy') ;
    mttWriteNewLine ;
    
    top_level_model = mttDetachText(model.source,'/') ;
    
    if isfield(model,'abg')
        is_embedded = zeros(1,length(model.abg)) ;
        embedding = 1 ;
    else
        embedding = 0 ;
    end
    
    component = 0 ;

    embedding = isfield(model,'abg') ;
    while embedding
        component = 1 + mod(component,length(model.abg)) ;
        if ~is_embedded(component)            
            if isempty(model.abg(component).invokes)
                number_of_systems = length(model.abg(component).invoked_by) ;
                
                for n = 1:number_of_systems
                    system = model.abg(component).invoked_by(n) ;
                    component_type = mttDetachText(model.abg(component).source,'/') ;
                    system_type = mttDetachText(model.abg(system).source,'/') ;
                    mttNotify(['   ...embedding "#',num2str(component),':',component_type,...
                            '" definition within "#',num2str(system),':',system_type,'" objects']) ;
                    mttWriteNewLine ;
                    
                    model = mttEmbedAcausalBondgraph(model,component,system) ;
                end
                model.abg(component).invoked_by = [] ;
                
                if ~isempty(find(model.invokes==component))
                    component_type = mttDetachText(model.abg(component).source,'/') ;
                    mttNotify(['   ...embedding "#',num2str(component),':',component_type,...
                            '" definition within "',top_level_model,'"']) ;
                    mttWriteNewLine ;
                    
                    model = mttEmbedAcausalBondgraph(model,component) ;
                end
                is_embedded(component) = 1 ;
            end
        end
        embedding = any(~is_embedded) ;
    end
    
    model = mttDeleteField(model,'abg') ;
    model = mttDeleteField(model,'invokes') ;
    
    
function model = assign_sympar_values(model) 
	mttNotify('...assigning "sympar" values') ;
    mttWriteNewLine ;
    
    model_name = mttDetachText(model.source,'/') ;
    current_branch = model_name ;
    
    sympars = model.sympar ;
    defaults = model.sympar_default ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~mttIsPassiveClass(object.class)
            for j = 1:length(object.parameter)
                object_parameter = object.parameter{j} ;
                if ischar(object_parameter)
                    index = strmatch(object_parameter,sympars,'exact') ;
                    
                    new_parameter = 0 ;
                    
                    if isempty(index)
                        new_parameter = 1 ;
                    else
                        default_value = defaults{index} ;
                        if isempty(default_value)
                            new_parameter = 1 ;
                        else
                            object.parameter{j} = default_value ;
                        end
                    end
                    
                    if new_parameter
                        object.parameter{j} = [current_branch,'___',object_parameter] ;
                    end
                end
            end
            
            branch = [model_name,'__',object_name] ;
            object = assign_object_sympar_values(object,branch) ;
            
            model = setfield(model,'obj',object_name,object) ;
        end
    end
    
    
function model = assign_object_sympar_values(model,branch)
    current_branch = branch ;
    
	sympars = model.sympar ;
    parameters = model.parameter ;
    
    if ~isempty(model.abg)
        objects = mttGetFieldNames(model,'obj') ;
        for i = 1:length(objects)
            object_name = objects{i} ;
            object = getfield(model,'obj',object_name) ;
            
            if ~mttIsPassiveClass(object.class)
                for j = 1:length(object.parameter)
                    object_parameter = object.parameter{j} ;
                    if ischar(object_parameter)
                        index = strmatch(object_parameter,sympars,'exact') ;
                        if isempty(index)
                            object.parameter{j} = [current_branch,'___',object_parameter] ;
                        else
                            object.parameter{j} = parameters{index} ;
                        end
                    end
                end
                
                branch = [current_branch,'__',object_name] ;
                object = assign_object_sympar_values(object,branch) ;
                
                model = setfield(model,'obj',object_name,object) ;
            end
        end
    elseif ~isempty(model.cr)
        model.cr.parameter = model.parameter ;
    end
    
    
function model = complete_causal_assignment(model)
    mttWriteNewLine ;
	mttNotify('...summarising model content') ;
    mttWriteNewLine ;
    
    model = mttCountObjects(model) ;
    mttNotifyNumberOfObjects(model) ;
    mttWriteNewLine ;
    model = mttDeleteField(model,'count') ;
    
    model = mttMeasureCausalCompletion(model) ;
	mttNotifyNumberOfBonds(model) ;
    mttWriteNewLine ;
    
    mttWriteNewLine ;
	mttNotify('...analysing predefined causality') ;
    mttWriteNewLine ;
    
	mttNotifyCausalCompletion(model) ;
    mttWriteNewLine ;
    
	if model.causal_completion.is_causal
        mttNotify('...applying CR constraints') ;
        mttWriteNewLine ;
        model = incorporate_cr_rules(model,'assert') ;
    else    
        mttNotify('...completing causality') ;
        mttWriteNewLine ;
        
        iterations = 0 ;
        
        propagating = 1 ;
        while propagating
            iterations = iterations + 1 ;
            previous_causal_completion = model.causal_completion ;
            
            model = mttApplyInterfaceCausality(model,'assert') ;
            model = mttPropagateCausality(model) ;
            model = mttApplyInterfaceCausality(model,'prefer') ;
            model = mttPropagateCausality(model) ;
            model = mttMeasureCausalCompletion(model) ;
            
            is_stable = mttCompareCausalCompletion(model.causal_completion,previous_causal_completion) ;
            propagating = (~is_stable) ;
            
            if propagating
                mttNotify(['...iteration ',num2str(iterations)]) ;
                mttWriteNewLine ;
                mttNotifyCausalCompletion(model) ;
            end
            
            propagating = propagating & (~model.causal_completion.is_causal) ;
        end
    end
    
    
    if ~model.causal_completion.is_causal
        mttWriteNewLine ;
        mttNotify('...causality not complete') ;
        mttWriteNewLine ;
        mttWriteNewLine ;
        
        mttIdentifyUndercausalBonds(model) ;
    end
    
    model = mttDeleteField(model,'causal_completion') ;
    
    
function model = complete_domain_assignment(model)
    mttWriteNewLine ;
	mttNotify('...allocating domain definitions') ;
    mttWriteNewLine ;
    
    model = mttMeasureDomainCompletion(model) ;
    
    iterations = 0 ;
    
    propagating = 1 ;
    while propagating
        iterations = iterations + 1 ;
        previous_domain_completion = model.domain_completion ;
        
        model = mttApplyInterfaceDomains(model) ;
        model = mttPropagateDomains(model) ;
        model = mttMeasureDomainCompletion(model) ;
        
        is_stable = mttCompareDomainCompletion(model.domain_completion,previous_domain_completion) ;
        propagating = (~is_stable) ;
        
        if propagating
            mttNotify(['...iteration ',num2str(iterations)]) ;
            mttWriteNewLine ;
            mttNotifyDomainCompletion(model) ;
        end
        
        propagating = propagating & (~model.domain_completion.is_done) ;
    end
    
    model = mttDeleteField(model,'domain_completion') ;
    
    
function model = overwrite_implicit_domains(model)
    mttWriteNewLine ;
	mttNotify('...overwriting implicit domain definitions') ;
    mttWriteNewLine ;
    
    model = mttOverwriteImplicitDomains(model) ;
    
    
function model = mttOverwriteImplicitDomains(root,model,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        model = root ;
        env = root.env ;
    end
        
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~isempty(object.abg)
            object = mttOverwriteImplicitDomains(model,object,env) ;
        end
        
        if ~isempty(object.cr)
            interface_ports = mttGetFieldNames(object.cr.interface,'port') ;
            for j = 1:length(interface_ports)
                port_name = interface_ports{j} ;
                port = getfield(object.cr.interface,'port',port_name) ;
                
                if isempty(port.domain)
                    if isempty(port.in)
                        bond_number = port.out ;
                    else
                        bond_number = port.in ;
                    end
                    
                    actual_domain = model.bond(bond_number).domain ;
                    actual_domain_item = model.bond(bond_number).domain_item ;
                    
                    port.domain = actual_domain ;
                    port.domain_item = actual_domain_item ;
	                object.cr.interface = setfield(object.cr.interface,'port',port_name,port) ;
                    
                    number_of_operators = mttGetFieldLength(object.cr,'operator') ;
                    for op_counter = 1:number_of_operators
                        operator = object.cr.operator(op_counter) ;
                        
                        matching_links = strmatch(port_name,{operator.link.name},'exact') ;
                        
                        number_of_equations = mttGetFieldLength(operator,'equation') ;
                        
                        for eq_counter = 1:number_of_equations
                            equation = operator.equation(eq_counter) ;
%                            if isempty(equation.domain)
                                
                                number_of_chunks = mttGetFieldLength(equation,'chunk') ;
                                for chunk_counter = 1:number_of_chunks
                                    chunk = equation.chunk{chunk_counter} ;
                                    
                                    if iscell(chunk)
                                        if strcmp(chunk{1},'link')
                                            link = chunk{2} ;
                                            
                                            if any(link==matching_links)
                                                covar = chunk{3} ;
                                                chunk{3} = ['generic___',covar] ;
                                            end
                                        end
	                                    equation.chunk{chunk_counter} = chunk ;
                                    end
                                end
                                operator.equation(eq_counter) = equation ;
%                            end
                        end
                        object.cr.operator(op_counter) = operator ;
                    end
                end
            end
        end
        
        model = setfield(model,'obj',object_name,object) ;
    end
    

Added ntt/bin/trans/m/mttCreateElementaryEquations.m version [170ccc2756].

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttCreateElementaryEquations(model,sorter_on)

model.representation = 'ese' ;

[model,ese,namelist] = specify_equations(model) ;
if sorter_on
    [sse,counter] = sort_equations(ese,model,namelist) ;
else
    sse = ese ;
    counter = 0 ;
end

model.equation = sse ;
model.sorted_equations = counter ;
model.namelist = namelist ;



function [model,ese,namelist] = specify_equations(model,branch,root_namelist)
    is_root_model = (nargin==1) ;

    if is_root_model
        mttNotify('...specifying equations') ;
    	mttWriteNewLine ;
        
        branch = mttDetachText(model.source,'/') ;
        
        name_counter = 1 ;
        namelist(name_counter).var = '0' ;
        namelist(name_counter).domain = [] ;
        namelist(name_counter).domain_item = [] ;
    else
        namelist = root_namelist ;
        name_counter = length(namelist) ;
    end
        
    mttNotify(['   ...processing ',branch]) ;
   	mttWriteNewLine ;
       
    objects = mttGetFieldNames(model,'obj') ;
    
    line = 0 ;
    
    for n = 1:length(objects)
        object_name = objects{n} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'},
            
            for j = 1:mttGetFieldLength(object,'interface')
                flow_equation = [] ;
                effort_equation = [] ;
                
                terminal = [branch,'__',object_name] ;
                
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    [specified_domain,specified_domain_item] = mttGetBondDomain(model,inbond) ;
                    
                    new_name = 0 ;
                    
                    line = line + 1 ;
                    if bond.flow
                        if strcmp(object.class,'De')
                            ese(line) = specify_ese(branch,[2*inbond],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond],branch,{name_counter+1},[]) ;
                            new_name = 1 ;
                        end
                    else
                        ese(line) = specify_ese(branch,{name_counter+1},branch,[2*inbond],[]) ;
                        new_name = 1 ;
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.flow'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                    
                	new_name = 0 ;
                
                    line = line + 1 ;
                    if bond.effort
                        ese(line) = specify_ese(branch,{name_counter+1},branch,[2*inbond-1],[]) ;
                        new_name = 1 ;
                    else
                        if strcmp(object.class,'Df')
                            ese(line) = specify_ese(branch,[2*inbond-1],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond-1],branch,{name_counter+1},[]) ;
	                        new_name = 1 ;
                        end
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.effort'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                end
                               
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    [specified_domain,specified_domain_item] = mttGetBondDomain(model,outbond) ;
                    
                    new_name = 0 ;
                    
                    if bond.flow
                        if ~strcmp(object.class,'Se')
                            line = line + 1 ;
                            ese(line) = specify_ese(branch,{name_counter+1},branch,[2*outbond],[]) ;
                            new_name = 1 ;
                        end
                    else
                        line = line + 1 ;
                        ese(line) = specify_ese(branch,[2*outbond],branch,{name_counter+1},[]) ;
                        new_name = 1 ;
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.flow'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                    
                    new_name = 0 ;
                    
                    if bond.effort
                        line = line + 1 ;
                        ese(line) = specify_ese(branch,[2*outbond-1],branch,{name_counter+1},[]) ;
                        new_name = 1 ;
                    else
                        if ~strcmp(object.class,'Sf')
                            line = line + 1 ;
                            ese(line) = specify_ese(branch,{name_counter+1},branch,[2*outbond-1],[]) ;
                            new_name = 1 ;
                        end
                    end
                    
                    if new_name
                        name_counter = name_counter + 1 ;
                        namelist(name_counter).var = [terminal,'.effort'] ;
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                    end
                end
            end
            
        case '0',
            
            imposed_effort = [] ;
            resultant_flow = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort,flow] = mttGetBondCausality(model,bond_number(i)) ;
                
                if effort==orientation(i)
                    imposed_effort = 2*bond_number(i)-1 ;
                end
                if flow==orientation(i)
                    resultant_flow = 2*bond_number(i) ;
                    resultant_orientation = orientation(i) ;
                end
            end
            
            for i = 1:mttGetFieldLength(object,'interface')
                effort = 2*bond_number(i)-1 ;
                if effort~=imposed_effort
                    derived_effort = effort ;
                    
                    line = line + 1 ;
                    ese(line) = specify_ese(branch,derived_effort,branch,imposed_effort,[]) ;
                end
            end
            
            flow_summation = [] ;
            for i = 1:mttGetFieldLength(object,'interface')
                flow = 2*bond_number(i) ;
                
                if flow~=resultant_flow
                    impinging_flow = flow ;
                    
                    if orientation(i)
                        if resultant_orientation
                            flow_summation = [ flow_summation, -impinging_flow ] ;
                        else
                            flow_summation = [ flow_summation, impinging_flow ] ;
                        end
                    else
                        if resultant_orientation
                            flow_summation = [ flow_summation, impinging_flow ] ;
                        else
                            flow_summation = [ flow_summation, -impinging_flow ] ;
                        end
                    end
                end
            end
            
            line = line + 1 ;
            ese(line) = specify_ese(branch,resultant_flow,branch,flow_summation,[]) ;
            
        case '1',
            
            imposed_flow = [] ;
            resultant_effort = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort,flow] = mttGetBondCausality(model,bond_number(i)) ;
                
                if flow~=orientation(i)
                    imposed_flow = 2*bond_number(i) ;
                end
                if effort~=orientation(i)
                    resultant_effort = 2*bond_number(i)-1 ;
                    resultant_orientation = orientation(i) ;
                end
            end
            
            for i = 1:mttGetFieldLength(object,'interface')
                flow = 2*bond_number(i) ;
                if flow~=imposed_flow
                    derived_flow = flow ;
                    
                    line = line + 1 ;
                    ese(line) = specify_ese(branch,derived_flow,branch,imposed_flow,[]) ;
                end
            end
            
            effort_summation = [] ;            
            for i = 1:mttGetFieldLength(object,'interface')
                effort = 2*bond_number(i)-1 ;
                
                if effort~=resultant_effort
                    impinging_effort = effort ;
                    
                    if orientation(i)
                        if resultant_orientation
                            effort_summation = [ effort_summation, -impinging_effort ] ;
                        else
                            effort_summation = [ effort_summation, impinging_effort ] ;
                        end
                    else
                        if resultant_orientation
                            effort_summation = [ effort_summation, impinging_effort ] ;
                        else
                            effort_summation = [ effort_summation, -impinging_effort ] ;
                        end
                    end
                end
            end
            
            line = line + 1 ;
            ese(line) = specify_ese(branch,resultant_effort,branch,effort_summation,[]) ;
            
        otherwise,
            
            if ~isempty(object.cr)
                interface = object.cr.interface ;
                port_names = mttGetFieldNames(interface,'port') ;
                number_of_ports = length(port_names) ;
                
                link_counter = 0 ;
                
                for i = 1:number_of_ports
                    port_name = port_names{i} ;
                    port = getfield(interface,'port',port_name) ;
                    terminal = [branch,'__',object_name,'___',port_name] ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    if ~isempty(inbond)
                        bond = model.bond(inbond) ;
                        [specified_domain,specified_domain_item] = mttGetBondDomain(model,inbond) ;
                        
                        name_counter = name_counter + 1 ;
                        if port.is_flow_state
                            namelist(name_counter).var = [terminal,'.flow_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.flow'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.flow
                            ese(line) = specify_ese(branch,[2*inbond],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                        else
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*inbond],[]) ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                        end
                        
                        name_counter = name_counter + 1 ;
                        if port.is_effort_state
                            namelist(name_counter).var = [terminal,'.effort_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.effort'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.effort
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*inbond-1],[]) ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond-1],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                        end
                    end
                    
                    if ~isempty(outbond)
                        bond = model.bond(outbond) ;
                        [specified_domain,specified_domain_item] = mttGetBondDomain(model,outbond) ;
                        
                        name_counter = name_counter + 1 ;
                        if port.is_flow_state
                            namelist(name_counter).var = [terminal,'.flow_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.flow'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.flow
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*outbond],[]) ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                        else
                            ese(line) = specify_ese(branch,[2*outbond],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                        end
                        
                        name_counter = name_counter + 1 ;
                        if port.is_effort_state
                            namelist(name_counter).var = [terminal,'.effort_state'] ;
                        else
                            namelist(name_counter).var = [terminal,'.effort'] ;
                        end
                        namelist(name_counter).domain = specified_domain ;
                        namelist(name_counter).domain_item = specified_domain_item ;
                        
                        line = line + 1 ;
                        link_counter = link_counter + 1 ;
                        if bond.effort
                            ese(line) = specify_ese(branch,[2*outbond-1],branch,{name_counter},[]) ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                        else
                            ese(line) = specify_ese(branch,{name_counter},branch,[2*outbond-1],[]) ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                        end
                    end
                end
                
                
                input_mask = zeros(number_of_ports,1) ;
                output_mask = zeros(number_of_ports,1) ;
                
                number_of_links = link_counter ;
                linked = zeros(number_of_links,1) ;
                
                operators = object.cr.operator ;
                number_of_operators = length(operators) ;
                
                object.cr.used_operator = zeros(1,number_of_operators) ;
                
                op_counter = 0 ;
                
                matching = 1 ;
                while matching
                    op_counter = op_counter + 1 ;
                    operator = operators(op_counter) ;
                    
                    full_operator_name = [branch,'__',object_name,'___',operator.name] ;
                    
                    number_of_op_links = length(operator.link) ;
                    op_linked = zeros(number_of_op_links,1) ;
                    
                    for j = 1:number_of_op_links
                        k = 0 ;
                        comparing = 1 ;
                        while comparing
                            k = k + 1 ;
                            if compare_links(link(k),operator.link(j))
                                op_linked(j) = k ;
                                comparing = 0 ;
                            end
                            comparing = comparing & (k<number_of_links) ;
                        end
                    end
                    
                    
                    input_counter = 0 ;
                    output_counter = 0 ;
                    input = [] ;
                    output = [] ;
                    
                    if all(op_linked)
                        object.cr.used_operator(op_counter) = 1 ;
                        
                        interface = object.cr.interface ;
                        assigned_ports = mttGetFieldNames(operator,'assign') ;
                        for j = 1:length(assigned_ports)
                            port_name = assigned_ports{j} ;
                            next = getfield(operator.assign,port_name) ;
                            
                            actual_port = getfield(interface,'port',port_name) ;
                            if ~isempty(actual_port.assign)
                                previous = actual_port.assign ;
                                
                                for k = 1:length(next.covar)
                                    covar = next.covar{k} ;
                                    index = strmatch(covar,previous.covar,'exact') ;
                                    
                                    if ~isempty(index)
                                        mttAssert(strcmp(next.state{k},previous.state{k}),...
                                            ['Conflicting state assignments for port "',port_name,'.',covar,'" in ',here]) ;
                                    else
                                        actual_port.assign.state{index} = next.state{k} ;
                                    end
                                end
                            else
                                actual_port.assign = next ;
                            end
                            interface = setfield(interface,'port',port_name,actual_port) ;
                        end
%                        operator = mttDeleteField(operator,'assign') ;
                            
%                        object.cr.operator(op_counter) = operator ;
                        object.cr.interface = interface ;
                        model = setfield(model,'obj',object_name,object) ;
                        
                        
                        for j = 1:number_of_op_links
                            k = op_linked(j) ;
                            
                            linked(k) = 1 ;
                            link(k).is_unconstrained = operator.link(j).is_unconstrained ;
                            
                            current_link = link(k) ;
                            port_name = current_link.name ;
                            
                            port_index = strmatch(port_name,port_names,'exact') ;
                            
                            terminal = [branch,'__',object_name,'___',port_name] ;
                            
                            if current_link.is_effort
                                if current_link.is_state
                                    link_name{j} = [terminal,'.effort_state'] ;
                                else
                                    link_name{j} = [terminal,'.effort'] ;
                                end
                            end
                            if current_link.is_flow
                                if current_link.is_state
                                    link_name{j} = [terminal,'.flow_state'] ;
                                else
                                    link_name{j} = [terminal,'.flow'] ;
                                end
                            end
                            
                            matched_name_counter = strmatch(link_name{j},{namelist.var},'exact') ;
                            if current_link.is_input
                                input_mask(port_index) = 1 ;
                                
                                if current_link.is_unconstrained
                                    input_counter = input_counter + 1 ;
                                    input{input_counter} = matched_name_counter ;
                                end
                            else
                                mttAssert(~output_mask(port_index),...
                                    ['Over-determined output "',port_name,'" in operator ',full_operator_name]) ;
                                
                                output_mask(port_index) = 1 ;
                                
                                if current_link.is_unconstrained & ~current_link.is_state
                                    output_counter = output_counter + 1 ;
                                    output{output_counter} = matched_name_counter ;
                                end
                            end
                        end
                        
                        line = line + 1 ;
                        ese(line) = specify_ese(branch,output,branch,input,full_operator_name) ;
                        
                        for j = 1:number_of_op_links
                            k = op_linked(j) ;
                            current_link = link(k) ;
                            
                            matched_name_counter = strmatch(link_name{j},{namelist.var},'exact') ;
                            if ~current_link.is_input
                                if ~current_link.is_unconstrained
                                    line = line + 1 ;
                                    ese(line) = specify_ese(branch,{matched_name_counter},branch,{1},[]) ;
                                end
                            end
                        end
                    end
                    
                    
                    unused_inputs = ~all(input_mask) ;
                    unused_outputs = ~all(output_mask) ;
                    still_counting = op_counter<number_of_operators ;
                    
                    matching = (unused_inputs | unused_outputs) & (op_counter<number_of_operators) ;
                end
                
                mttAssert(all(input_mask),...
                    ['Unattached input(s) in "cr" implementation in ',here]) ;
                mttAssert(all(output_mask),...
                    ['Unattached output(s) in "cr" implementation in ',here]) ;
                mttAssert(all(linked),...
                    ['Unattached ports in "cr" implementation in ',here]) ;
            end
        end
    end
    
    for n = 1:length(objects)
        object_name = objects{n} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        
        if ~isempty(object.cr)
            operators = object.cr.operator ;
            number_of_operators = length(operators) ;
            
            object.cr = mttDeleteField(object.cr,'operator') ;
            used_counter = 0 ;
            
            for op_counter = 1:number_of_operators
                operator = operators(op_counter) ;
                if object.cr.used_operator(op_counter)
                    used_counter = used_counter + 1 ;
                    used_operator = operator ;
                    
%                    used_operator = mttDeleteField(used_operator,'is_used') ;
                    used_operator = mttDeleteField(used_operator,'assign') ;
                    object.cr.operator(used_counter) = used_operator ;
                end
            end
        end
        
        
        if ~isempty(object.abg)
            next_branch = [branch,'__',object_name] ;
            for j = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                inmap = object.interface(j).map.in ;
                outmap = object.interface(j).map.out ;
                interface_class = object.interface(j).class ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    
                    line = line + 1 ;
                    if bond.flow
                        if strcmp(interface_class,'Se')
	                        ese(line) = specify_ese(branch,[2*inbond],next_branch,{1},[]) ;
                        else
	                        ese(line) = specify_ese(branch,[2*inbond],next_branch,[2*inmap],[]) ;
                        end
                    else
                        ese(line) = specify_ese(next_branch,[2*inmap],branch,[2*inbond],[]) ;
                    end
                    
                    line = line + 1 ;
                    if bond.effort
                        ese(line) = specify_ese(next_branch,[2*inmap-1],branch,[2*inbond-1],[]) ;
                    else
                        if strcmp(interface_class,'Sf')
                            ese(line) = specify_ese(branch,[2*inbond-1],next_branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(branch,[2*inbond-1],next_branch,[2*inmap-1],[]) ;
                        end
                    end
                end
                
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    
                    line = line + 1 ;
                    if bond.flow
                        if strcmp(interface_class,'De')
                            ese(line) = specify_ese(next_branch,[2*outmap],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(next_branch,[2*outmap],branch,[2*outbond],[]) ;
                        end
                    else
                        ese(line) = specify_ese(branch,[2*outbond],next_branch,[2*outmap],[]) ;
                    end
                    
                    line = line + 1 ;
                    if bond.effort
                        ese(line) = specify_ese(branch,[2*outbond-1],next_branch,[2*outmap-1],[]) ;
                    else
                        if strcmp(interface_class,'Df')
                            ese(line) = specify_ese(next_branch,[2*outmap-1],branch,{1},[]) ;
                        else
                            ese(line) = specify_ese(next_branch,[2*outmap-1],branch,[2*outbond-1],[]) ;
                        end
                    end
                end
            end

            [object,object_ese,object_namelist] = specify_equations(object,next_branch,namelist) ;
            model = setfield(model,'obj',object_name,object) ;
            
            ese = [ese, object_ese] ;
            line = length(ese) ;
            
			namelist = object_namelist ;
        end
        
        object.cr = mttDeleteField(object.cr,'used_operator') ;
        model = setfield(model,'obj',object_name,object) ;
    end
    
    
function equation = specify_ese(LHS_branch,LHS_var,RHS_branch,RHS_var,operator)
    equation.branch.LHS = LHS_branch ;
    equation.branch.RHS = RHS_branch ;
    equation.var.LHS = LHS_var ;
    equation.var.RHS = RHS_var ;
    equation.operator = operator ;
    
    
function [branchlist,branchbond] = identify_branches(model,branch)
    is_root_model = (nargin==1) ;
    
    if is_root_model
        branch = mttDetachText(model.source,'/') ;
        branchlist{1} = branch ;
        branchbond = length(model.bond) ;
        counter = 1 ;
    else
        branchlist = [] ;
        branchbond = 0 ;
        counter = 0 ;
    end

    objects = mttGetFieldNames(model,'obj') ;
    
    for n = 1:length(objects)
        object_name = objects{n} ;
        
        object = getfield(model,'obj',object_name) ;
        next_branch = [branch,'__',object_name] ;
        [next_branchlist,next_branchbond] = identify_branches(object,next_branch) ;
        
        counter = counter + 1 ;
        branchlist{counter} = next_branch ;

        if isfield(object,'bond')
            branchbond(counter) = length(object.bond) ;
        else
            branchbond(counter) = 0 ;
        end
        
        for i = 1:length(next_branchlist)
            counter = counter + 1 ;
            branchlist{counter} = next_branchlist{i} ;
            branchbond(counter) = next_branchbond(i) ;
        end
    end
    
    
function [sse,sorted_equations] = sort_equations(ese,model,namelist)
    mttWriteNewLine ;
    mttNotify('...sorting equations') ;
    mttWriteNewLine ;
    
    [branchlist,branchbond] = identify_branches(model) ;
    lastvar = cumsum(2*branchbond) ;
    offsetvar = lastvar - 2*branchbond ;
    
    number_of_equations = length(ese) ;
%    number_of_covariables = length(namelist) - 1 ;
%    number_of_interface_variables = max(lastvar) ;
    number_of_covariables = max(lastvar) ;
    number_of_interface_variables = length(namelist) - 1 ;
    
    mttNotifyEquationSummary(number_of_equations,number_of_covariables,number_of_interface_variables) ;
    
    for i = 1:length(ese)
        if isempty(ese(i).operator)
            var = ese(i).var.LHS ;
            switch class(var)
            case 'double',
                branch_index = strmatch(ese(i).branch.LHS,branchlist,'exact') ;
                info(i).LHS = abs(var) + offsetvar(branch_index) ;
            case 'cell',
                info(i).LHS = ese(i).var.LHS ;
            end
            
            var = ese(i).var.RHS ;
            switch class(var)
            case 'double',
                branch_index = strmatch(ese(i).branch.RHS,branchlist,'exact') ;
                for j = 1:length(var)
                    info(i).RHS(j) = abs(var(j)) + offsetvar(branch_index) ;
                end
            case 'cell',
                info(i).RHS = ese(i).var.RHS ;
            end
        else
            info(i).LHS = ese(i).var.LHS ;
            info(i).RHS = ese(i).var.RHS ;
        end
    end
    
    
    var_known = zeros(max(lastvar),1) ;
    name_known = zeros(length(namelist),1) ;
    name_known(1) = 1 ;
    
    log = ones(length(ese),1) ;
    map = zeros(length(ese),1) ;
    
    counter = 0 ;
    
    for i = 1:length(ese)
        if log(i) & isempty(ese(i).operator)
            left = info(i).LHS ;
            right = info(i).RHS ;
                
            if isnumeric(left) & iscell(right)
                name = namelist(right{1}).var ;
                is_object_interface = ~isempty(findstr(name,'___')) ;
                
                ok = 1 ;
                if is_object_interface
                    is_effort_state = ~isempty(findstr(name,'.effort_state')) ;
                    is_flow_state = ~isempty(findstr(name,'.flow_state')) ;
                    ok = is_effort_state | is_flow_state ;
                end
                
                if ok
                    log(i) = 0 ;
                    counter = counter + 1 ;
                    map(counter) = i ;
                    
                    var_known(left) = 1 ;
                    name_index = strmatch(name,{namelist.var},'exact') ;
                    name_known(name_index) = 1 ;
                end
            end
            
            if iscell(left) & iscell(right)
                if right{1}==1
                    log(i) = 0 ;
                    counter = counter + 1 ;
                    map(counter) = i ;
                    
                    name = namelist(left{1}).var ;
                    name_index = strmatch(name,{namelist.var},'exact') ;
                    name_known(name_index) = 1 ;
                end
            end
        end
    end
    
    previous_var_known = var_known ;
    previous_name_known = name_known ;
    
    sort_iteration = 0 ;
    
    sorting = 1 ;
    while sorting
        sort_iteration = sort_iteration + 1 ;
        
        for i = 1:length(ese)
            if log(i) & isempty(ese(i).operator)
                left = info(i).LHS ;
                right = info(i).RHS ;
                
                if isnumeric(right)
                    if all(var_known(right))
                        log(i) = 0 ;
                        counter = counter + 1 ;
                        map(counter) = i ;
                        
                        if isnumeric(left)
                            var_known(left) = 1 ;
                        else
                            name = namelist(left{1}).var ;
                            name_index = strmatch(name,{namelist.var},'exact') ;
                            name_known(name_index) = 1 ;
                        end
                    end
                else
                    name = namelist(right{1}).var ;
                    name_index = strmatch(name,{namelist.var},'exact') ;
                    if name_known(name_index)
                        is_object_interface = ~isempty(findstr(name,'___')) ;
                        
                        if is_object_interface
                            log(i) = 0 ;
                            counter = counter + 1 ;
                            map(counter) = i ;
                            
                            var_known(left) = 1 ;
                        end
                    end
                end
            end
        end
        
        for i = 1:length(ese)
            if log(i) & ~isempty(ese(i).operator)
                left = info(i).LHS ;
                right = info(i).RHS ;
                
                indices = [] ;
                for j = 1:length(right)
                    name = namelist(right{j}).var ;
                    indices(j) = strmatch(name,{namelist.var},'exact') ;
                end
                
                if all(name_known(indices))
                    log(i) = 0 ;
                    counter = counter + 1 ;
                    map(counter) = i ;
                    for j = 1:length(left)
                        name = namelist(left{j}).var ;
                        name_index = strmatch(name,{namelist.var},'exact') ;
                        name_known(name_index) = 1 ;
                    end
                end
            end
        end
        
        same_vars_known = sum(var_known)==sum(previous_var_known) ;
        same_names_known = sum(name_known)==sum(previous_name_known) ;
        
        previous_var_known = var_known ;
        previous_name_known = name_known ;
        
        sorting = ~(same_vars_known & same_names_known) ;
        
        if sorting
            mttNotify(['...iteration ',num2str(sort_iteration)]) ;
            mttWriteNewLine ;
%            is_complete = ...
%                mttNotifyEquationSort(sort_iteration,...
%	             sum(log),number_of_equations,...
%                sum(name_known),number_of_covariables,...
%                sum(var_known),number_of_interface_variables) ;
            is_complete = ...
                mttNotifyEquationSort(sort_iteration,...
	            sum(log),number_of_equations,...
                sum(var_known),number_of_covariables,...
                sum(name_known),number_of_interface_variables) ;
            
            sorting = sorting & ~is_complete ;
        end
    end

    for i = 1:length(ese)
        if log(i) & isempty(ese(i).operator)
            left = info(i).LHS ;
            right = info(i).RHS ;
                
            if iscell(left) & isnumeric(right)
                name = namelist(left{1}).var ;
                is_object_interface = ~isempty(findstr(name,'___')) ;
                    
                if ~is_object_interface
                    if var_known(right)
                        log(i) = 0 ;
                        counter = counter + 1 ;
                        map(counter) = i ;
                        
                        name_index = strmatch(name,{namelist.var},'exact') ;
                        name_known(name_index) = 1 ;
                    end
                end
            end
        end
    end
    
    sorted_equations = counter ;
    
    if sorted_equations<number_of_equations
	    mttWriteNewLine ;
        mttNotify(['...unable to sort equations completely']) ;
	    mttWriteNewLine ;
        mttNotifyEquationSortProblems(name_known,namelist) ;
    end
    
    for i = 1:length(ese)
        if log(i)
            counter = counter + 1 ;
            map(counter) = i ;
        end
    end
    
    mttAssert(counter==length(ese),'Sort algorithm has failed! Seek expert assistance!') ;
    
	for i = 1:length(ese)
    	sse(i) = ese(map(i)) ;
    end
    
    
function link = create_link(is_input,is_effort,is_flow,name,is_state)
    link.is_input    = is_input ;
    link.is_effort   = is_effort ;
    link.is_flow     = is_flow ;
    link.name        = name ;
    link.is_state    = is_state ;
    
    link.is_unconstrained = [] ;
    
    
function boolean = compare_links(actual_link,op_link)
    input_is_same  = actual_link.is_input==op_link.is_input ;
    effort_is_same = actual_link.is_effort==op_link.is_effort ;
    flow_is_same   = actual_link.is_flow==op_link.is_flow ;
    name_is_same   = strcmp(actual_link.name,op_link.name) ;
    
    boolean = input_is_same & effort_is_same & flow_is_same & name_is_same ;
    

Added ntt/bin/trans/m/mttCreateEnvironment.m version [9307cb976f].


























































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttCreateEnvironment(context)
global mtt_env

mttNotify('...setting "env" definition') ;
mttWriteNewLine ;

directory_name = identify_directory_name(context) ;
source_name = identify_source_name(context,directory_name) ;
environment_filename = [source_name,'_env.txt'] ;

model = mttFetchEnvironment(environment_filename) ;
model = establish_path_names(model) ;

mttWriteNewLine ;
mttNotify('...acquiring "domain" source definitions') ;
mttWriteNewLine ;

model = establish_user_domains(model) ;

number_of_domains = mttGetFieldLength(model,'dom') ;
if number_of_domains>0
    for i = 1:number_of_domains
        model.public_domain(i).representation = model.dom(i).representation ;
        model.public_domain(i).source = model.dom(i).source ;
        
        domain = model.dom(i) ;
        item_names = mttGetFieldNames(domain,'item') ;
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            item = getfield(domain,'item',item_name) ;
            
            compound_item = mttIdentifyDomainCovariables(item,domain,model) ;
            model = setfield(model,'public_domain',{i},'item',item_name,compound_item) ;
        end
    end
    model = hide_private_domains(model) ;
end

model = mttDeleteField(model,'dom') ;


mttWriteNewLine ;
mttNotify('...acquiring "struct" source definitions') ;
mttWriteNewLine ;

model = establish_user_structs(model) ;

number_of_structs = mttGetFieldLength(model,'str') ;
if number_of_structs>0
    for i = 1:number_of_structs
        model.public_struct(i).representation = model.str(i).representation ;
        model.public_struct(i).source = model.str(i).source ;
        
        struct = model.str(i) ;
        item_names = mttGetFieldNames(struct,'item') ;
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            item = getfield(struct,'item',item_name) ;
            
            compound_item = mttIdentifyStructVariables(item,struct,model) ;
            model = setfield(model,'public_struct',{i},'item',item_name,compound_item) ;
        end
    end
    model = hide_private_structs(model) ;
end

model = mttDeleteField(model,'str') ;



function directory = identify_directory_name(context)
    mttAssert(ischar(context),'Context must be specified by name') ;
    working_directory  = pwd ;
    working_directory = strrep(working_directory,'\','/') ;
    
    [system_name,local_directory] = mttDetachText(context,'/') ;
    if isempty(system_name)
        local_directory = [] ;
    end
    
    if isempty(local_directory)
        directory = working_directory ;
    else
        directory = mttLocateDirectory(working_directory,local_directory) ;
    end
    
    
function source = identify_source_name(context,directory)
    [context_name,local_directory] = mttDetachText(context,'/') ;
    if isempty(context_name)
        context_name = context ;
        local_directory = [] ;
    end
    source = [directory,'/',context_name] ;
    
    
function model = establish_path_names(model)
	path_names = mttGetFieldNames(model,'path') ;
    
    for n = 1:length(path_names)
        path_name = path_names{n} ;
        path_spec = getfield(model,'path',path_name) ;
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        
        directory = identify_directory(working_directory,path_spec,model) ;
        
        mttAssert(~isempty(directory),...
            ['Undefined path "',path_name,'"']) ;
        
		model = setfield(model,'path',path_name,directory) ;
    end
    
    
function directory = identify_directory(working_directory,path_spec,model)
	path_names = mttGetFieldNames(model,'path') ;

    if isempty(path_spec)
		directory = [] ;
    else
        if path_spec(1)=='$'
            [path_alias,path_branch] = mttCutText(path_spec,'/') ;
            path_alias(1) = [] ;
            
            mttAssert(ismember(path_alias,path_names),...
                ['Path "',path_alias,'" not recognised']) ;
            
            path_root = getfield(model,'path',path_alias) ;
            
            if isempty(path_branch)
                directory = path_root ;
            else
                directory = [path_root,'/',path_branch] ;
            end
        else
            [local_directory,name] = mttCutText(path_spec,'/') ;
            
            directory_located = 0 ;
            if strcmp(local_directory,'.')
                if isempty(name)
                    directory = working_directory ;
                    directory_located = 1 ;
                else
                    local_directory = name ;
                end
            else
                local_directory = path_spec ;
            end
            
            if ~directory_located
                directory = mttLocateDirectory(working_directory,local_directory) ;
            end
        end
    end
    
    
function model = establish_user_domains(model)
	path_names = mttGetFieldNames(model,'path') ;
    domain_names = mttGetFieldNames(model,'domain') ;
    
    counter = 0 ; 
    
    for n = 1:length(domain_names)
        domain_name = domain_names{n} ;
        domain_spec = getfield(model,'domain',domain_name) ;
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        [domain_source,domain_item] = mttCutText(domain_spec,'::') ;
        [name,path_spec] = mttDetachText(domain_source,'/') ;
        
        if isempty(name)
            source_name = [working_directory,'/',domain_source] ;
        else
            directory = identify_directory(working_directory,path_spec,model) ;
            source_name = [directory,'/',name] ;
        end
        
        domain_filename = [source_name,'_domain.txt'] ;
        
        domain_index = [] ;
        if isfield(model,'dom')
            existing_doms = {model.dom.source} ;
            domain_index = strmatch(source_name,existing_doms,'exact') ;
        end
        
        if isempty(domain_index)
            counter = counter + 1 ;
            model.dom(counter) = mttFetchDomain(domain_filename) ;
            domain_index = counter ;
        end
        
        domain_spec.dom = domain_index ;
        domain_spec.item = domain_item ;
        model = setfield(model,'domain',domain_name,domain_spec) ;
    end
    
function model = hide_private_domains(model)
	for n = 1:mttGetFieldLength(model,'public_domain')
        dom = model.dom(n) ;
        dom_items = dom.item ;
        
        domain = model.public_domain(n) ;
        domain_items = domain.item ;
        
        item_names = mttGetFieldNames(domain,'item') ;
        
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            is_private(j) = getfield(dom_items,item_name,'is_private') ;
            
            if is_private(j)
                domain_items = mttDeleteField(domain_items,item_name) ;
                
                mttAssert(~isempty(domain_items),...
                    ['No public domains in ',dom.source]) ;
            end
        end
        
        model = setfield(model,'public_domain',{n},'item',domain_items) ;
    end
    
	user_domain_names = mttGetFieldNames(model,'domain') ;
    for i = 1:length(user_domain_names)
        user_domain_name = user_domain_names{i} ;
        user_domain = getfield(model,'domain',user_domain_name) ;
        
        dom = model.dom(user_domain.dom) ;
        if ~isempty(user_domain.item)
            is_private = getfield(dom,'item',user_domain.item,'is_private') ;
            mttAssert(~is_private,...
                ['User-defined domain "',user_domain_name,'" is declared as private']) ;
        end
    end
    
    
function model = establish_user_structs(model)
	path_names = mttGetFieldNames(model,'path') ;
    struct_names = mttGetFieldNames(model,'struct') ;
    
    counter = 0 ; 
    
    for n = 1:length(struct_names)
        struct_name = struct_names{n} ;
        struct_spec = getfield(model,'struct',struct_name) ;
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        [struct_source,struct_item] = mttCutText(struct_spec,'::') ;
        [name,path_spec] = mttDetachText(struct_source,'/') ;
        
        if isempty(name)
            source_name = [working_directory,'/',struct_source] ;
        else
            directory = identify_directory(working_directory,path_spec,model) ;
            source_name = [directory,'/',name] ;
        end
        
        struct_filename = [source_name,'_struct.txt'] ;
        
        struct_index = [] ;
        if isfield(model,'str')
            existing_strs = {model.str.source} ;
            struct_index = strmatch(source_name,existing_strs,'exact') ;
        end
        
        if isempty(struct_index)
            counter = counter + 1 ;
            model.str(counter) = mttFetchStruct(struct_filename) ;
            struct_index = counter ;
        end
        
        struct_spec.str = struct_index ;
        struct_spec.item = struct_item ;
        model = setfield(model,'struct',struct_name,struct_spec) ;
    end
    
function model = hide_private_structs(model)
	for n = 1:mttGetFieldLength(model,'public_struct')
        str = model.str(n) ;
        str_items = str.item ;
        
        struct = model.public_struct(n) ;
        struct_items = struct.item ;
        
        item_names = mttGetFieldNames(struct,'item') ;
        
        for j = 1:length(item_names)
            item_name = item_names{j} ;
            is_private(j) = getfield(str_items,item_name,'is_private') ;
            
            if is_private(j)
                struct_items = mttDeleteField(struct_items,item_name) ;
                
                mttAssert(~isempty(struct_items),...
                    ['No public structs in ',str.source]) ;
            end
        end
        
        model = setfield(model,'public_struct',{n},'item',struct_items) ;
    end
    
	user_struct_names = mttGetFieldNames(model,'struct') ;
    for i = 1:length(user_struct_names)
        user_struct_name = user_struct_names{i} ;
        user_struct = getfield(model,'struct',user_struct_name) ;
        
        str = model.str(user_struct.str) ;
        if ~isempty(user_struct.item)
            is_private = getfield(str,'item',user_struct.item,'is_private') ;
            mttAssert(~is_private,...
                ['User-defined struct "',user_struct_name,'" is declared as private']) ;
        end
    end
        

Added ntt/bin/trans/m/mttCreateSystemMdl.m version [1ef68305e6].











































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttCreateSystemMdl(model)

model_name = mttDetachText(model.source,'/') ;
icd = mttCreateSystemMdl_ICD(model) ;

NumInputs = length(icd.input_namelist) ;
NumOutputs = length(icd.output_namelist) ;
MaxInterfaces = max(NumInputs,NumOutputs) ;

new_system(model_name) ;
open_system(model_name) ;
set_param(model_name,'Location',[50 100 850 250+20*MaxInterfaces]) ;

left = 100 ;
top = 25 ;
width = 600 ;
height = 25*(5+MaxInterfaces)  ;

position_vector = [left,top,left+width,top+height] ;

ModelHndl = add_block(...
    'simulink3/Subsystems/Subsystem',...
    [model_name,'/Model'],...
    'Position',position_vector,...
    'BackgroundColor','yellow',...
    'FontName','Helvetica',...
    'FontSize',num2str(16)) ;


system = [model_name,'/Model'] ;

set_param(system,'Location',[200 250 1050 285+30*MaxInterfaces]) ;

Line = get_param(system,'Lines') ;
for i = 1:length(Line)
    SrcBlock = get_param(Line(i).SrcBlock,'Name') ;
    DstBlock = get_param(Line(i).DstBlock,'Name') ;
    SrcPort = num2str(Line(i).SrcPort) ;
    DstPort = num2str(Line(i).DstPort) ;
    
    delete_line(system,[SrcBlock,'/',SrcPort],[DstBlock,'/',DstPort]) ;
end

Block = get_param(system,'Blocks') ;
for i = 1:length(Block)
    delete_block([system,'/',Block{i}]) ;
end


left = 125 ;
centre_left = 250 ;
centre = 350 ;
centre_right = 580 ;
right = 670 ;

top = 20 ;
down = 30 ;

port_width = 40 ;
port_height = 15 ;
port_spacing = down ;

mux_width = 5 ;
mux_height = NumInputs*port_spacing ;

demux_width = 5 ;
demux_height = NumOutputs*port_spacing ;

sfun_width = 150 ;
sfun_height = 30 ;

left_vertical_offset = (NumInputs*port_spacing - sfun_height)/2 ;
right_vertical_offset = (NumOutputs*port_spacing - sfun_height)/2 ;

vertical_offset = max(left_vertical_offset,right_vertical_offset) ;
datum = top + vertical_offset ;



top = datum - left_vertical_offset ;

for i = 1:NumInputs
    position_vector = [...
            left,...
            top + (i-1)*port_spacing,...
            left + port_width,...
            top + (i-1)*port_spacing + port_height] ;
        
    InHndl(i) = add_block(...
        'simulink3/Sources/In1',...
        [system,'/',icd.input_namelist{i}],...
        'Position',position_vector) ;
end

position_vector = [...
        centre_left,...
        top-port_height/3,...
        centre_left+mux_width,...
        top+mux_height-port_height/3] ;

MuxHndl = add_block(...
    'simulink3/Signals & Systems/Mux',...
    [system,'/InputMapping'],...
    'Position',position_vector,...
    'Inputs',num2str(NumInputs)) ;

position_vector = [...
        centre,...
        top+left_vertical_offset-sfun_height/2,...
        centre+sfun_width,...
        top+left_vertical_offset+sfun_height] ;

SfunHndl = add_block(...
    'simulink3/Functions & Tables/S-Function',...
    [system,'/sfun'],...
    'Position',position_vector,...
    'FunctionName',[model_name,'_sfun'],...
    'BackgroundColor','yellow',...
    'FontName','Helvetica',...
    'FontSize',num2str(16)) ;



top = datum - right_vertical_offset ;

position_vector = [...
        centre_right,...
        top-port_height/3,...
        centre_right+demux_width,...
        top+demux_height-port_height/3] ;

DemuxHndl = add_block(...
    'simulink3/Signals & Systems/Demux',...
    [system,'/OutputMapping'],...
    'Position',position_vector,...
    'Outputs',num2str(NumOutputs)) ;

for i = 1:NumOutputs
    position_vector = [...
            right,...
            top + (i-1)*port_spacing,...
            right + port_width,...
            top + (i-1)*port_spacing + port_height] ;
        
    OutHndl(i) = add_block(...
        'simulink3/Sinks/Out1',...
        [system,'/',icd.output_namelist{i}],...
        'Position',position_vector) ;
end



for i = 1:NumInputs
    port = num2str(i) ;
    InLineHndl(i) = add_line(system,...
        [icd.input_namelist{i},'/1'],['InputMapping/',port]) ;
end

SfunInLineHndl = add_line(system,'InputMapping/1','sfun/1') ;
set_param(SfunInLineHndl,'Name','_Input') ;

SfunOutLineHndl = add_line(system,'sfun/1','OutputMapping/1') ;
set_param(SfunOutLineHndl,'Name','_Output') ;

for i = 1:NumOutputs
    port = num2str(i) ;
    OutLineHndl(i) = add_line(system,...
        ['OutputMapping/',port],[icd.output_namelist{i},'/1']) ;
end

Added ntt/bin/trans/m/mttCreateSystemMdl_ICD.m version [ca430de00e].



















































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function icd = mttCreateSystemMdl_ICD(model)

sympar = map_system_sympars(model) ;
input  = map_system_inputs(model) ;
invar  = map_system_invars(model) ;
outvar = map_system_outvars(model) ;

icd.output_namelist = outvar ;
icd.input_namelist = invar ;
if ~isempty(input)
    icd.input_namelist = [icd.input_namelist,input] ;
end
if ~isempty(sympar)
    icd.input_namelist = [icd.input_namelist,sympar] ;
end

icd.output_namelist = sort(icd.output_namelist) ;
icd.input_namelist = sort(icd.input_namelist) ;



function map = map_system_sympars(model)
	mttNotify('...mapping system inputs (symbolic parameters)') ;
    mttWriteNewLine ;
    
    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default_value = model.sympar_default{i} ;
        
        if isempty(default_value)
            line = line + 1 ;
            map{line} = [model_name,'___',variable_name] ;
        end
    end
    
    
function map = map_system_inputs(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input variables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        
        line = line + 1 ;
        map{line} = [current_branch,'___',variable_name] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_inputs(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_map = map_system_inputs(object.cr,root,next_branch) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_invars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_invars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_outvars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system outputs (output covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if inbond.effort
                    covar = covariables.effort ;
                elseif ~inbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if ~outbond.effort
                    if ~strcmp(object.class,'Sf')
                        covar = covariables.effort ;
                    end
                elseif outbond.flow
                    if ~strcmp(object.class,'Se')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    map{line} = [current_branch,'__',object_name,'(',covariable,')'] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_outvars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    

Added ntt/bin/trans/m/mttCreateUnifiedModel.m version [27142f9b00].























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttCreateUnifiedModel(model,bondgraph,specification)

	model.source = mttCutText(specification.specification,'_abg.txt') ;
    model.bondgraph = mttCutText(bondgraph.bondgraph,'_abg.fig') ;
    
    model.obj = bondgraph.obj ;
    model.bond = bondgraph.bond ;
	
    object_names = mttGetFieldNames(model,'obj') ;
    specified_object_names = mttGetFieldNames(specification,'obj') ;
    
    for n = 1:length(object_names)
        object_name = object_names{n} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~mttIsPassiveClass(object.class)
            mttAssert(ismember(object_name,specified_object_names),...
                ['Object name "',object_name,'" does not appear in specification']) ;
        end
    end
    
    for n = 1:length(specified_object_names)
        specified_object_name = specified_object_names{n} ;
        mttAssert(ismember(specified_object_name,object_names),...
            ['Specified object name "',specified_object_name,...
                '" does not appear in bond graph']) ;
        
        specified_object = getfield(specification,'obj',specified_object_name) ;
        object = getfield(model,'obj',specified_object_name) ;

        if strcmp(specified_object.name.class,object.class)
            mttAssert(~mttIsFoundationClass(object.class),...
                'Cannot redefine MTT foundation class') ;
            is_abg = 1 ;
        else
            mttAssert(~mttIsPassiveClass(object.class),...
                'Cannot modify MTT junctions or ports') ;
            is_abg = 0 ;
        end

        object.is_abg = is_abg ;        
        object.name = specified_object.name ;
        object.parameter = specified_object.parameter ;
        
        model = setfield(model,'obj',specified_object_name,object) ;
    end
    
    model.sympar = specification.sympar ;
    model.numpar = specification.numpar ;
    model.input = specification.input ;

    model.sympar_default = specification.sympar_default ;
    model.numpar_default = specification.numpar_default ;
    model.input_default = specification.input_default ;

    for n = 1:length(object_names)
        object_name = object_names{n} ;
        object = getfield(model,'obj',object_name) ;
        
        if mttIsPortClass(object.class)
            mttAssert(mttGetFieldLength(object,'interface')==1,...
                ['Port components must have one and only one interface']) ;
            
            switch object.class
            case {'Se','Sf'},
                mttAssert(~isempty(object.interface.out),...
                    'Each source port must have an outward bond') ;
            case {'De','Df'},
                mttAssert(~isempty(object.interface.in),...
                    'Each detector port must have an inward bond') ;
            end
        end
        
        if ~ismember(object_name,specified_object_names)
            object.name.item = [] ;
            object.name.class = object.class ;
            object.name.path = [] ;
            object.parameter = [] ;
            object.is_abg = 1 ;
        end
        
        [rubbish,working_directory] = mttDetachText(model.source,'/') ;
        local_directory = object.name.path ;
        directory = mttLocateDirectory(working_directory,local_directory) ;
        
        source = [directory,'/',object.name.class] ;
		
        current_leaf = model.leaf ;
        
		if object.is_abg
            if mttIsPassiveClass(object.name.class)
                object.abg = [] ;
            else
                current_branch = model.branch ;
                mttAssert(~ismember(source,current_branch),...
                    ['Recursive definition of "',source,'"']) ;

                if isempty(model.abgs)
                    existing_abg = [] ;
                else
                    existing_abg = strmatch(source,model.abgs,'exact') ;
                end
                
                if isempty(existing_abg) 
                    if isempty(current_branch)
                        next_branch = {source} ;
                        next_leaf = object_name ;
                    else
                        next_branch = [current_branch,{source}] ;
                        next_leaf = [current_leaf,'/',object_name] ;
                    end
                    model.branch = next_branch ;
                    model.leaf = next_leaf ;
                    
                    class_model = mttCreateAcausalBondgraph(source,model) ;
                    
                    model.leaf = current_leaf ;
                    model.branch = current_branch ;
                    
                    next_abg = 1 + mttGetFieldLength(model,'abg') ;
                    for i = 1:mttGetFieldLength(class_model,'abg')
                        model.abg(next_abg) = class_model.abg(i) ;
                        model.abgs = class_model.abgs ;
                        next_abg = next_abg + 1 ;
                    end
                    class_model = mttDeleteField(class_model,'abg') ;
                    
                    model.crs = class_model.crs ;
                    class_model = mttDeleteField(class_model,'crs') ;
                    
                    model.cr_usage = class_model.cr_usage ;
                    class_model = mttDeleteField(class_model,'cr_usage') ;
                    
                    model.abg(next_abg) = class_model ;
                    model = mttAppend(model,'abgs',{source}) ;
                    
                    index = length(model.abgs) ;
                    mttNotify(['   ...made "#',num2str(index),':',object.name.class,'" definition']) ;
                    mttWriteNewLine ;
                end
				object.abg = strmatch(source,model.abgs,'exact') ;
            end
            object.cr = [] ;
            object.cr_item = [] ;
        else
            if isempty(model.crs)
                existing_cr = [] ;
            else
                existing_cr = strmatch(source,model.crs,'exact') ;
            end
            
            if isempty(current_leaf)
                cr_user = object_name ;
            else
                cr_user = [current_leaf,'/',object_name] ;
            end
            
            if isempty(existing_cr)
                model = mttAppend(model,'crs',{source}) ;
                
                N = length(model.crs) ;
                model.cr_usage(N).obj{1} = cr_user ;
            else
                N = 1+length(model.cr_usage(existing_cr).obj) ;
                model.cr_usage(existing_cr).obj{N} = cr_user ;
            end
            
            object.abg = [] ;
            object.cr = strmatch(source,model.crs,'exact') ;

            if isempty(object.name.item)
                object.cr_item = mttDetachText(model.crs{object.cr},'/') ;
            else
                object.cr_item = object.name.item ;
            end
        end
        
        object = mttDeleteField(object,'name') ;
        object = mttDeleteField(object,'is_abg') ;
        
        model = setfield(model,'obj',object_name,object) ;
    end

Added ntt/bin/trans/m/mttEmbedAcausalBondgraph.m version [a4a8eda9a1].
































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttEmbedAcausalBondgraph(model,component,system)
    source = model.abg(component) ;
    
    if nargin==2
        is_root_model = 1 ;
        target = model ;
    else
        is_root_model = 0 ;
        target = model.abg(system) ;
    end
    
    source_objects = mttGetFieldNames(source,'obj') ;
    target_objects = mttGetFieldNames(target,'obj') ;
    
    for n = 1:length(target_objects)
        target_object_name = target_objects{n} ;
        target_object = getfield(target,'obj',target_object_name) ;
        
        here = [mttDetachText(target.source,'/'),'/',target_object_name] ;
    
        is_abg_instance = 0 ;
        if ~isempty(target_object.abg)
            is_abg_instance = target_object.abg==component ;
        end
        
        if is_abg_instance
            target_object.sympar = source.sympar ;
            target_object.numpar = source.numpar ;
            target_object.input = source.input ;
            
            target_object.sympar_default = source.sympar_default ;
            target_object.numpar_default = source.numpar_default ;
            target_object.input_default = source.input_default ;
            
            declarations = length(target_object.sympar) ;
            values = length(target_object.parameter) ;
            
            mttAssert(declarations==values,['Mismatched parameters in object ',here]) ;
            
            
            number_of_target_ports = mttGetFieldLength(target_object,'interface') ;

            found_target_port = [] ;            
            target_ports_found = [] ;
            
            for i = 1:number_of_target_ports
                
                target_port_name = target_object.interface(i).name ;
                target_inbond = target_object.interface(i).in ;
                target_outbond = target_object.interface(i).out ;
                
                is_inline = (~isempty(target_inbond) & ~isempty(target_outbond)) ;
                
                next = 0 ;
                found_target_port(i) = 0 ;
                
                matching = 1 ;
                while matching
                    next = next + 1 ;
                    source_object_name = source_objects{next} ;
                    source_object = getfield(source,'obj',source_object_name) ;
                    
                    if ismember(source_object.class,{'SS','Se','Sf','De','Df'})
                        source_port_name = source_object_name ;
                        
                        if is_inline
                            source_interface = getfield(source,'obj',source_port_name,'interface') ;
                            
                            inport_found = 0 ;
                            if ~isempty(source_interface.in)
                                inport_found = strcmp(source_port_name,[target_port_name,'_in']) ;
                            end
                            
                            outport_found = 0 ;
                            if ~isempty(source_interface.out)
                                outport_found = strcmp(source_port_name,[target_port_name,'_out']) ;
                            end
                            
                            found_target_port(i) = inport_found | outport_found ;
                        else
                            found_target_port(i) = strcmp(source_port_name,target_port_name) ;
                        end
                    end
                    
                    if found_target_port(i)
                        if isempty(target_ports_found)
                            target_ports_found = {target_port_name} ;
                        else
                            target_ports_found = [target_ports_found, {target_port_name}] ;
                        end
                        matching = 0 ;
                    else
                        matching = (next<length(source_objects)) ;
                    end
                end
                
                mttAssert(found_target_port(i),...
                    ['Unmatched port "',target_object_name,'[',target_port_name,']"']) ;
                
                source_object = getfield(source,'obj',source_port_name) ;
                source_inbond = source_object.interface.in ;
                source_outbond = source_object.interface.out ;
                source_class = source_object.class ;
                source_domain = source_object.domain ;
                source_domain_item = source_object.domain_item ;
                
                is_inward_compatible = ~xor(isempty(target_inbond),isempty(source_outbond)) ;
                is_outward_compatible = ~xor(isempty(target_outbond),isempty(source_inbond)) ;
                is_compatible = is_inward_compatible & is_outward_compatible ;
                
                mttAssert(is_compatible,...
                    ['Incompatible bond connections at port "',...
                        target_object_name,'[',target_port_name,']"']) ;
                
                target_object = setfield(target_object,'interface',{i},'map','in',source_outbond) ;
                target_object = setfield(target_object,'interface',{i},'map','out',source_inbond) ;
                target_object = setfield(target_object,'interface',{i},'class',source_class) ;
                target_object = setfield(target_object,'interface',{i},'domain',source_domain) ;
                target_object = setfield(target_object,'interface',{i},'domain_item',source_domain_item) ;
            end
            
            number_of_target_ports_found = sum(found_target_port) ;
            mttAssert(number_of_target_ports_found==number_of_target_ports,...
                ['Mismatched ports in "',target_object_name,'"']) ;
            
            for i = 1:length(source_objects)
                source_object_name = source_objects{i} ;
                if ~ismember(source_object_name,target_ports_found)
                    source_object = getfield(source,'obj',source_object_name) ;
                    source_object = mttDeleteField(source_object,'cr_item') ;
                    
                    target_object = setfield(target_object,'obj',source_object_name,source_object) ;
                end
            end
            
            source_bond_list = getfield(source,'bond') ;
            target_object = setfield(target_object,'bond',source_bond_list) ;
            
            target = setfield(target,'obj',target_object_name,target_object) ;
        end
    end
    
    if is_root_model
        model = target ;
    else
        if ~isempty(target.invokes)
	        invoked_abgs = target.invokes ;
            other_abgs = target.invokes(invoked_abgs~=component) ;
            
            if isempty(other_abgs)
                target.invokes = [] ;
            else
                target.invokes = other_abgs ;
            end
        end
        model.abg(system) = target ;
    end
    
    

Added ntt/bin/trans/m/mttEmbedInterfaceDefinition.m version [b375cb1133].






























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttEmbedInterfaceDefinition(model,object_name,root)
	if nargin==2
    	root = model ;
    end
	
    here = [mttDetachText(model.source,'/'),'/',object_name] ;
    
	object = getfield(model,'obj',object_name) ;
    cr = root.cr(object.cr) ;
    cr_item_name = object.cr_item ;
    
    cr_item_names = mttGetFieldNames(cr,'item') ;
    mttAssert(ismember(cr_item_name,cr_item_names),...
        ['CR "',cr_item_name,'" not found']) ;
    
    cr_item = getfield(cr,'item',cr_item_name) ;
    
    cr_portnames = mttGetFieldNames(cr_item.interface,'port') ;
    
    for i = 1:mttGetFieldLength(object,'interface')
        interface_name = object.interface(i).name ;
        
        mttAssert(ismember(interface_name,cr_portnames),...
            ['Unrecognised interface "',interface_name,'" in object ',here]) ;
        
            interface = getfield(cr_item,'interface','port',interface_name) ;
            interface.in = object.interface(i).in ;
            interface.out = object.interface(i).out ;
            
            has_inbond = ~isempty(object.interface(i).in) ;
            has_outbond = ~isempty(object.interface(i).out) ;

            mttAssert(xor(has_inbond,has_outbond),...
                ['Mismatched interface "',interface_name,'" in object ',here]) ;
            
            cr_item = setfield(cr_item,'interface','port',interface_name,interface) ;
    end
    
    for i = 1:length(cr_portnames)
        port_name = cr_portnames{i} ;
        cr_item_port = getfield(cr_item,'interface','port',port_name) ;
        mttAssert(isfield(cr_item_port,'in')|isfield(cr_item_port,'out'),...
            ['Unmatched port ',here,':',port_name]) ;
    end
    
    object.sympar = cr_item.sympar ;
    object.sympar_default = cr_item.sympar_default ;
    
    cr_item = mttDeleteField(cr_item,'parameter') ;
    object.cr = cr_item ;
    
    declarations = length(object.sympar) ;
    values = length(object.parameter) ;
    
    mttAssert(declarations==values,...
        ['Mismatched parameters in object ',here]) ;
    
    object = mttDeleteField(object,'cr_item') ;
    model = setfield(model,'obj',object_name,object) ;

    

Added ntt/bin/trans/m/mttFetchApps.m version [637cce0534].








































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttFetchApps(filename)

if ~mttFileExists(filename)
    model = [] ;
    return ;
end

model.representation = 'apps' ;

mttNotify(['...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_apps.txt') ;
model_name = mttDetachText(model.source,'/') ;

content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

apps_declared = 0 ;
next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'apps',
        mttAssert(~apps_declared,...
            '"apps" declaration must be unique') ;
        apps_declared = 1 ;
        
        apps_name = line ;
        mttAssert(strcmp(apps_name,model_name),...
            ['Wrong name:[',apps_name,'] Expecting:[',model_name,']']) ;
        
        [apps,next] = fetch_apps(statements,next) ;
        model = mttAppendFields(model,apps) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end




function [apps,next] = fetch_apps(statements,next)
    apps = [] ;
    unit_name = 'apps' ;
    
    number_of_statements = length(statements) ;
    
    open = 0 ;
    counter = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'app',
            mttAssert(open,...
                ['"app" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            app_name = line ;
            
            counter = counter + 1 ;
            apps.app{counter} = app_name ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    apps = mttSetFieldDefault(apps,'app',[]) ;
    

Added ntt/bin/trans/m/mttFetchBondgraph.m version [521f373616].

































































































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttFetchBondgraph(filename)

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.bondgraph = filename ;
content = mttReadFile(filename) ;

L = length(content) ;    
N = 1 ;

processing = (N<=L) ;
while processing
    jump = 1 ;
    line = mttClipText(content{N}) ;
    
    if ~isempty(line)
        no_string_terminator = isempty(findstr('\001',line)) ;
        
        if no_string_terminator
            if mttIsNumericText(line)
                numbers = round(str2num(line)) ;    	% only interested in integer values
                
                if numbers(1)==2						% ... line definition
                    forward_arrow = numbers(14)~=0 ;
                    reverse_arrow = numbers(15)~=0 ;
                    arrow = (forward_arrow | reverse_arrow) ;
                    
                    depth = numbers(7) ;
                    is_visible = rem(depth,10)==0 ;
                    
                    if is_visible
                        mttAssert(~arrow,...
                            ['Line ',num2str(N),': Arrows are not recognised in bond graphs']) ;
                        
                        number_of_points = numbers(16) ;

                        coordinate_string = [] ;
                        M = 0 ;
                        
                        matching = 1 ;
                        while matching
                            M = M + 1 ;
                            if isempty(coordinate_string)
                                coordinate_string = content{N+M} ;
                            else
                                coordinate_string = [coordinate_string,' ',content{N+M}] ;
                            end
                            
                            mttAssert(mttIsNumericText(coordinate_string),...
                                ['Line ',num2str(N+M),': Coordinates not recognised']) ;
                            
                            coordinates = str2num(coordinate_string) ;
                            
                            matching = length(coordinates)<2*number_of_points ;
                        end
                        
                        mttAssert(length(coordinates)==2*number_of_points,...
                            ['Line ',num2str(N+1),': Wrong number of coordinates']) ;
                        
                        jump = jump + M ; 
                        
                        if number_of_points==2
                            model = create_line(model,coordinates) ;
                        elseif number_of_points>2
                            model = create_bond(model,coordinates) ;
                        end
                    else
                        jump = jump + forward_arrow + reverse_arrow ;
                    end
                end
            end
        else
            [last_word,first_part] = mttDetachText(line,' ') ;
            
            if mttIsNumericText(first_part)
                numbers = round(str2num(first_part)) ;    	% only interested in integer values
                if numbers(1)==4							% ... text definition
                    depth = numbers(4) ;
                    is_visible = rem(depth,10)==0 ;
                    
                    if is_visible
                        coordinates = numbers(12:13) ;
                        text = mttCompressText(mttCutText(last_word,'\001')) ;
                        
                        identifier = mttCutText(text,'[') ;
                        qualifier = mttExtractText(text,'[',']') ;
                        
                        name.label = [] ;
                        name.domain = [] ;
                        name.domain_item = [] ;
                        name.class = [] ;
                        name.object = [] ;
                        
                        if isempty(identifier)
                            name.label = qualifier ;
                            model = create_label(model,name,coordinates) ;
                        else
                            [name.domain,name.domain_item] = mttCutText(qualifier,'::') ;
                            [name.class,name.object] = mttCutText(identifier,':') ;
                            model = create_object(model,name,coordinates) ;
                        end
                    end
                end
            end
        end
    end
    
    N = N + jump ;
	processing = (N<=L) ;
end

model = incorporate_anonymous_objects(model) ;
model = identify_causal_assignments(model) ;
model = identify_object_binding(model) ;
model = identify_object_interfaces(model) ;
model = associate_external_domains(model) ;
model = tidy_up(model) ;



function model = create_line(model,coordinates)
    next = 1 + mttGetFieldLength(model,'line') ;
    model.line(next).xy1 = coordinates(1:2) ;
    model.line(next).xy2 = coordinates(3:4) ;
    model.line(next).mid = (coordinates(1:2)+coordinates(3:4))/2 ;
            
function model = create_bond(model,coordinates)
	next = 1 + mttGetFieldLength(model,'bond') ;
	
    N = length(coordinates) ;
    
    q1 = coordinates(N-1:N) ;	p1 = coordinates(1:2) ;		
    p2 = coordinates(3:4) ;		q2 = coordinates(N-3:N-2) ;
    p3 = coordinates(5:6) ;		q3 = coordinates(N-5:N-4) ;
    ps = norm(p2-p1) ;		    qs = norm(q2-q1) ;
    
    orientation = sign(ps-qs) ;
    
    switch orientation
    case 1,		% harpoon points forward
        xy1 = p1 ; xy2 = q2 ; v1 = p2-p1 ; v2 = q2-q3 ; harpoon = q1-q2 ;
    case -1,	% harpoon points backward
        xy1 = p2 ; xy2 = q1 ; v1 = q2-q1 ; v2 = p2-p3 ; harpoon = p1-p2 ;
    end
    
    harpoon_side = sign_cross_product(v2,harpoon) ;
    
    mttAssert(~(orientation==0 | harpoon_side==0),...
        ['Ambiguous bond orientation between[',num2str(xy1),'] and [',num2str(xy2),']']) ;
    
    model.bond(next).xy1 = xy1 ;
    model.bond(next).xy2 = xy2 ;
    model.bond(next).v1  = v1 ;
    model.bond(next).v2  = v2 ;
    model.bond(next).harpoon = harpoon ;
    model.bond(next).harpoon_side = harpoon_side ;
    
    model.bond(next).from.obj = [] ;
    model.bond(next).from.interface = [] ;
    model.bond(next).to.obj = [] ;
    model.bond(next).to.interface = [] ;
    model.bond(next).flow = [] ;
    model.bond(next).effort = [] ;
    model.bond(next).unicausal = [] ;
    model.bond(next).domain = [] ;
    model.bond(next).domain_item = [] ;
    
function model = create_label(model,name,coordinates)
	inner_name = mttExtractText(name.label,'<','>') ;
    if isempty(inner_name)
        label_name = name.label ;
        is_inline = 0 ;
    else
        label_name = inner_name ;
        is_inline = 1 ;
    end
    mttValidateName(label_name) ;

    next = 1 + mttGetFieldLength(model,'label') ;
    model.label(next).name = label_name ;
    model.label(next).is_inline = is_inline ;
    model.label(next).xy = coordinates ;

function model = create_object(model,name,coordinates)
global mtt_environment
    
    domain_names = mttGetFieldNames(mtt_environment,'domain') ;
    
    is_anonymous = 0 ;
    if isempty(name.object)
        switch name.class
        case {'0','1'},
            is_anonymous = 1 ;
        case 'SS',
            mttAssert(~isempty(name.object),...
                'Anonymous "SS" object') ;
        otherwise,
            name.object = name.class ;
        end
    end
    
    if is_anonymous
        next = 1 + mttGetFieldLength(model,'anonymous') ;
        model.anonymous(next).class = name.class ;
        model.anonymous(next).xy = coordinates ;
    else
        object_names = mttGetFieldNames(model,'obj') ;
        if ~isempty(object_names)
            mttAssert(~ismember(name.object,object_names),...
                ['Repeated object: "',name.object,'"']) ;
        end
        
        switch name.class
        case {'0','1'},
            mttValidateName(name.object) ;
            mttAssert(~ismember(name.object,{'in','out'}),...
                'Junctions cannot use reserved port names') ;
            
        case {'SS','Se','Sf','De','Df'},
            mttValidateName(name.object) ;
            
            if isempty(name.domain) | isempty(mtt_environment)
                model = setfield(model,'obj',name.object,'domain',[]) ;
                model = setfield(model,'obj',name.object,'domain_item',[]) ;
            else
                mttAssert(ismember(name.domain,domain_names),...
                    ['Unrecognised domain "',name.domain,'"']) ;
                dom = getfield(mtt_environment,'domain',name.domain,'dom') ;
                item = getfield(mtt_environment,'domain',name.domain,'item') ;
                
                if isempty(item)
                    public_domain = getfield(mtt_environment,'public_domain',{dom}) ;
                    item_names = mttGetFieldNames(public_domain,'item') ;
                    
                    mttAssert(ismember(name.domain_item,item_names),...
                        ['Item "',name.domain_item,'" not found in public domain "',name.domain,'"']) ;
                    item_name = name.domain_item ;
                else
                    mttAssert(isempty(name.domain_item),...
                        ['Item unspecified in public domain "',name.domain,'"']) ;
                    item_name = item ;
                end
                
                model = setfield(model,'obj',name.object,'domain',dom) ;
                model = setfield(model,'obj',name.object,'domain_item',item_name) ;
            end
                
        otherwise,
            mttValidateName(name.class) ;
            mttValidateName(name.object) ;
            
            mttAssert(~ismember(name.object,{'in','out'}),...
                'Objects cannot use reserved port names') ;
        end
        model = setfield(model,'obj',name.object,'class',name.class) ;
        model = setfield(model,'obj',name.object,'xy',coordinates) ;
    end

function model = incorporate_anonymous_objects(model)
    number_of_objects = mttGetFieldLength(model,'anonymous') ;

    last = length(num2str(number_of_objects)) ;
    for i = 1:last
        object_number(i) = '0' ;
    end
    
    for i = 1:number_of_objects
        anonymous_object = getfield(model,'anonymous',{i}) ;
        
        current_number = num2str(i) ;
        width = length(current_number) ;
        first = last-width+1 ;
        object_number(first:last) = current_number ;
        
        object_name = ['mtt_obj',object_number] ;
        model = setfield(model,'obj',object_name,model.anonymous(i)) ;
    end

function r = sign_cross_product(v1,v2)
    r = sign(v1(1)*v2(2) - v1(2)*v2(1)) ;
    
function model = identify_causal_assignments(model)
	L = mttGetFieldLength(model,'line') ;
    
    if L>0
        N = mttGetFieldLength(model,'bond') ;
        
        for j = 1:L 
            for i = 1:N
                s(i,j) = norm(model.line(j).mid - model.bond(i).xy1) ;
                f(i,j) = norm(model.line(j).mid - model.bond(i).xy2) ;
            end
        end
        
        [min_range_start,nearest_bond_start] = min(s) ;
        [min_range_finish,nearest_bond_finish] = min(f) ;
        
        equidistant = min_range_start==min_range_finish ;
        at_harpoon = min_range_start>min_range_finish ;
        
        for j = 1:L
            fulcrum = num2str(model.line(j).mid) ;
            
            mttAssert(~equidistant(j),...
                ['Ambiguous causal line at [',num2str(model.line(j).mid),']']) ;
            
            if at_harpoon(j)
                index = nearest_bond_finish(j) ;
                bond = model.bond(index) ;
                terminal = bond.xy2 ;
                terminal_vector = bond.v2 ;
            else
                index = nearest_bond_start(j) ;
                bond = model.bond(index) ;
                terminal = bond.xy1 ;
                terminal_vector = bond.v1 ;
            end
            
            to_lhs = norm(model.line(j).xy1 - terminal) ;
            to_mid = norm(model.line(j).mid - terminal) ;
            to_rhs = norm(model.line(j).xy2 - terminal) ;
            
            mttAssert(to_mid<norm(bond.harpoon),...
                ['Cannot assign causality at [',num2str(fulcrum),']']) ;
            
            causality_ok = 0 ;
            
            is_unicausal = to_mid<min(to_lhs,to_rhs) ;
            if is_unicausal
                [bond.flow,causality_ok] = mttAssign(bond.flow,at_harpoon(j)) ;
                [bond.effort,causality_ok] = mttAssign(bond.effort,at_harpoon(j)) ;
            else
                causal_vector = (right-left) * sign(to_mid>to_left) ;
                causal_assignment = sign_cross_product(terminal_vector,causal_vector) ;
                mttAssert(causal_assignment~=0,...
                    ['Cannot determine causality near [',num2str(fulcrum),']']) ;
                
                if causal_assignment==bond.harpoon_side
                    [bond.flow,causality_ok] = mttAssign(bond.flow,at_harpoon(j)) ;
                else
                    [bond.effort,causality_ok] = mttAssign(bond.effort,at_harpoon(j)) ;
                end
            end
            mttAssert(causality_ok,...            
                ['Ambiguous causal assignment near [',num2str(fulcrum),']']) ;
            
            bond.unicausal = mttCompare(bond.flow,bond.effort) ;
            
            model.bond(index) = bond ;
        end
    end
    
    
function model = identify_object_binding(model)
	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
	number_of_bonds = mttGetFieldLength(model,'bond') ;
    
    for j = 1:number_of_bonds
        bond = model.bond(j) ;
        for i = 1:number_of_objects
            object = getfield(model,'obj',object_names{i}) ;
        	origin_proximity(i) = norm(object.xy - bond.xy1) ;
            target_proximity(i) = norm(object.xy - bond.xy2) ;
        end
       	
        [range,index] = min(origin_proximity) ;
        origin_name = object_names{index} ;
        bond.from.obj = origin_name ;
        bond.from.interface = [] ;
        
        [range,index] = min(target_proximity) ;
        target_name = object_names{index} ;
        bond.to.obj = target_name ;
        bond.to.interface = [] ;
        
        model = setfield(model,'bond',{j},bond) ;
        
        origin = getfield(model,'obj',origin_name) ;
        next = 1 + mttGetFieldLength(origin,'bond') ;
        origin.bond(next).number = j ;
        origin.bond(next).is_inbond = 0 ;
        model = setfield(model,'obj',origin_name,origin) ;
        
        target = getfield(model,'obj',target_name) ;
        next = 1 + mttGetFieldLength(target,'bond') ;
        target.bond(next).number = j ;
        target.bond(next).is_inbond = 1 ;
        model = setfield(model,'obj',target_name,target) ;
    end
    
    
function model = identify_object_interfaces(model)
	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
	number_of_labels = mttGetFieldLength(model,'label') ;
	number_of_bonds = mttGetFieldLength(model,'bond') ;
    
    for j = 1:number_of_labels
        label = model.label(j) ;
        for i = 1:number_of_objects
            object_name = object_names{i} ;
            object = getfield(model,'obj',object_names{i}) ;
            proximity(i) = norm(object.xy - label.xy) ;
        end
        [range,index] = min(proximity) ;
        associated_object = object_names{index} ;
        object = getfield(model,'obj',associated_object) ;
        
        switch object.class
        case {'0','1'},
            mttAssert(~label.is_inline,...
                ['Inline ports not valid for "0" and "1" junctions']) ;
        end
        
        next = 1 + mttGetFieldLength(object,'interface') ;
        object = setfield(object,'interface',{next},'name',label.name) ;
        object = setfield(object,'interface',{next},'class',[]) ;
        object = setfield(object,'interface',{next},'is_inline',label.is_inline) ;
        object = setfield(object,'interface',{next},'xy',label.xy) ;
        object = setfield(object,'interface',{next},'in',[]) ;
        object = setfield(object,'interface',{next},'out',[]) ;
        object = setfield(object,'interface',{next},'map',[]) ;
        model = setfield(model,'obj',associated_object,object) ;
    end
    
    for j = 1:number_of_objects
        object_name = object_names{j} ;
        object = getfield(model,'obj',object_name) ;
        
        number_of_attached_bonds = mttGetFieldLength(object,'bond') ;
        number_of_interfaces = mttGetFieldLength(object,'interface') ;
        
        for k = 1:number_of_interfaces
            interface = object.interface(k) ;
            
            inbond_proximity = [] ;  inbond_counter = [] ;
            outbond_proximity = [] ; outbond_counter = [] ;
            
            in_counter = 0 ;
            out_counter = 0 ;
            
            for i = 1:number_of_attached_bonds
                bond_number = object.bond(i).number ; 
                bond = model.bond(bond_number) ;
                
                if object.bond(i).is_inbond
                    if isempty(bond.to.interface)
                        in_counter = in_counter + 1 ;
                        inbond_proximity(in_counter) = norm(interface.xy - bond.xy2) ;
                        inbond_counter(in_counter) = bond_number ;
                    end
                else
                    if isempty(bond.from.interface)
                        out_counter = out_counter + 1 ;
                        outbond_proximity(out_counter) = norm(interface.xy - bond.xy1) ;
                        outbond_counter(out_counter) = bond_number ;
                    end
                end
            end
            
            [in_range,inbond_index] = min(inbond_proximity) ;
            [out_range,outbond_index] = min(outbond_proximity) ;

            inbond = inbond_counter(inbond_index) ;
            outbond = outbond_counter(outbond_index) ;
            
            if interface.is_inline
                mttAssert(~isempty(inbond_proximity),...
                    ['No in-bond for interface "',object_name,'[',interface.name,']"']) ;
                mttAssert(~isempty(outbond_proximity),...
                    ['No out-bond for interface "',object_name,'[',interface.name,']"']) ;
                
            	interface.in = inbond ;
                interface.out = outbond ;
                
                model = setfield(model,'bond',{outbond},'from','interface',k) ;
                model = setfield(model,'bond',{inbond},'to','interface',k) ;
            else
                mttAssert(~(isempty(inbond_proximity) & isempty(outbond_proximity)),...
                    ['No bond for interface "',object_name,'[',interface.name,']"']) ;
                
                if isempty(inbond_proximity)
                    interface.out = outbond ;
                    model = setfield(model,'bond',{outbond},'from','interface',k) ;
                elseif isempty(outbond_proximity)
                    interface.in = inbond ;
                    model = setfield(model,'bond',{inbond},'to','interface',k) ;
                else
                    mttAssert(in_range~=out_range,...
                        ['Ambiguous interface "',object_name,'[',interface.name,']"']) ;
                    
                    if out_range<in_range
                        interface.out = outbond ;
	                    model = setfield(model,'bond',{outbond},'from','interface',k) ;
                    else
                        interface.in = inbond ;
	                    model = setfield(model,'bond',{inbond},'to','interface',k) ;
                    end
                end
            end
            object.interface(k) = interface ;
        end
        model = setfield(model,'obj',object_name,object) ;
    end
    
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
            
        number_of_interfaces = mttGetFieldLength(object,'interface') ;
        for k = 1:number_of_interfaces;
            interface = object.interface(k) ;
            
            if interface.is_inline
                mttAssert(~(isempty(interface.in) | isempty(interface.out)),...
                    ['Unbound interface: ',object_name,'[',interface.name,']']) ;
            else
                mttAssert(~(isempty(interface.in) & isempty(interface.out)),...
                    ['Unbound interface: ',object_name,'[',interface.name,']']) ;
            end
        end
    end
    
    objects_with_in = [] ;
    objects_with_out = [] ;
    
    for j = 1:number_of_bonds
        bond = model.bond(j) ;
        
        if isempty(bond.from.interface)
            object_name = bond.from.obj ;
            object = getfield(model,'obj',object_name) ;
            
            if ~ismember(object.class,{'0','1'})
                mttAssert(~ismember(object_name,objects_with_out),...
                    ['Object "',object_name,'" has more than one implicit out-bond']) ;
                if isempty(objects_with_out)
                    objects_with_out = {object_name} ;
                else
                    objects_with_out = [objects_with_out,{object_name}] ;
                end
            end
            
            next = 1 + mttGetFieldLength(object,'interface') ;
            model = setfield(model,'obj',object_name,'interface',{next},'name','out') ;
      		model = setfield(model,'obj',object_name,'interface',{next},'in',[]) ;
            model = setfield(model,'obj',object_name,'interface',{next},'out',j) ;
            model = setfield(model,'bond',{j},'from','interface',next) ;
        end
        
        if isempty(bond.to.interface)
            object_name = bond.to.obj ;
            object = getfield(model,'obj',object_name) ;
            
            if ~ismember(object.class,{'0','1'})
                mttAssert(~ismember(object_name,objects_with_in),...
                    ['Object "',object_name,'" has more than one implicit in-bond']) ;
                if isempty(objects_with_in)
                    objects_with_in = {object_name} ;
                else
                    objects_with_in = [objects_with_in,{object_name}] ;
                end
            end
            
            next = 1 + mttGetFieldLength(object,'interface') ;
            model = setfield(model,'obj',object_name,'interface',{next},'name','in') ;
            model = setfield(model,'obj',object_name,'interface',{next},'in',j) ;
         	model = setfield(model,'obj',object_name,'interface',{next},'out',[]) ;
            model = setfield(model,'bond',{j},'to','interface',next) ;
        end
    end
    
    
function model = associate_external_domains(model)

	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
    
	for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'},
            mttAssert(mttGetFieldLength(object,'interface')==1,...
                ['Object "',object_name,'" must have a unique bond interface']) ;
            
            bond_number = [] ;
            
            if ~isempty(object.interface.in)
                bond_number = object.interface.in ;
            end
            if ~isempty(object.interface.out)
                bond_number = object.interface.out ;
            end
            
            [model,ok] = mttUpdateBondDomain(model,bond_number,object.domain,object.domain_item) ;
            mttAssert(ok,['Domain conflict on bond connected to object "',object_name,'"']) ;
        end
    end
    
    
function model = tidy_up(model)
% remove temperory data and xfig geometry from model structure 

	object_names = mttGetFieldNames(model,'obj') ;
	number_of_objects = length(object_names) ;
    
	for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        object = mttDeleteField(object,'bond') ;
        
        object_interfaces = getfield(object,'interface') ;
        object_interfaces = mttDeleteField(object_interfaces,'is_inline') ;
        object_interfaces = mttDeleteField(object_interfaces,'xy') ;
        object = setfield(object,'interface',object_interfaces) ;
        object = mttDeleteField(object,'xy') ;
        model = setfield(model,'obj',object_name,object) ;
    end
    
	all_bonds = getfield(model,'bond') ;
    all_bonds = mttDeleteField(all_bonds,'xy1') ;
    all_bonds = mttDeleteField(all_bonds,'xy2') ;
    all_bonds = mttDeleteField(all_bonds,'v1') ;
    all_bonds = mttDeleteField(all_bonds,'v2') ;
    all_bonds = mttDeleteField(all_bonds,'harpoon') ;
    all_bonds = mttDeleteField(all_bonds,'harpoon_side') ;
    model = setfield(model,'bond',all_bonds) ;
    
    model = mttDeleteField(model,'anonymous') ;
    model = mttDeleteField(model,'line') ;
    model = mttDeleteField(model,'label') ;

Added ntt/bin/trans/m/mttFetchDomain.m version [3356e6dd33].




















































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttFetchDomain(filename)

model.representation = 'domain' ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_domain.txt') ;
content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case {'domain','public_domain','private_domain'},
        domain_name = line ;
        mttValidateName(domain_name) ;
        
        [domain,next] = fetch_domain(statements,next,domain_name) ;
        model = setfield(model,'item',domain_name,domain) ;
        
        is_private = strcmp(keyword,'private_domain') ;
        model = setfield(model,'item',domain_name,'is_private',is_private) ;
        
    case {'multi_domain','public_multi_domain','private_multi_domain'},
        domain_name = line ;
        mttValidateName(domain_name) ;
        
        [domain,next] = fetch_multi_domain(statements,next,domain_name) ;
        model = setfield(model,'item',domain_name,domain) ;

        is_private = strcmp(keyword,'private_multi_domain') ;
        model = setfield(model,'item',domain_name,'is_private',is_private) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end


function [domain,next] = fetch_domain(statements,next,domain_name)
    domain = [] ;
    unit_name = 'domain' ;
    
    number_of_statements = length(statements) ;
    
    effort_declared = 0 ;
    flow_declared = 0 ;
    
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'effort',
            mttAssert(open,...
                ['"effort" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~effort_declared,...
                ['"effort" declarations must be unique in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "effort" in "',unit_name,'"']) ;
            
            [covar,default] = mttCutText(line,'=') ;
            
            mttValidateName(covar) ;
            domain.covar.effort = covar ;
            domain.covar.effort_default = default ;
            effort_declared = 1 ;
            
        case 'flow',
            mttAssert(open,...
                ['"flow" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~flow_declared,...
                ['"flow" declarations must be unique in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "flow" in "',unit_name,'"']) ;
            
            [covar,default] = mttCutText(line,'=') ;
            
            mttValidateName(covar) ;
            domain.covar.flow = covar ;
            domain.covar.flow_default = default ;
            flow_declared = 1 ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    
function [domain,next] = fetch_multi_domain(statements,next,domain_name)
    domain = [] ;
    unit_name = 'domain' ;
    
    number_of_statements = length(statements) ;
    
    counter = 0 ;
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'bond',
            mttAssert(open,...
                ['"bond" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "bond" in "',unit_name,'"']) ;
            
            [bond_name,bond_domain] = mttCutText(line,'[') ;
            [bond_domain,rubbish] = mttCutText(bond_domain,']') ;
            
            mttAssert(isempty(rubbish),...
                ['Unexpected text after "]" in "',unit_name,'"']) ;
            
            if ~isempty(bond_name)
                mttValidateName(bond_name) ;
            end
            
            counter = counter + 1 ;
            domain.bond(counter).name = bond_name ;
            domain.bond(counter).domain = bond_domain ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end

Added ntt/bin/trans/m/mttFetchEnvironment.m version [43e7bb5007].







































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttFetchEnvironment(filename)

model.representation = 'env' ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_env.txt') ;
model_name = mttDetachText(model.source,'/') ;

content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

env_declared = 0 ;
next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'env',
        mttAssert(~env_declared,...
            '"env" declaration must be unique') ;
        env_declared = 1 ;
        
        env_name = line ;
        mttAssert(strcmp(env_name,model_name),...
            ['Wrong name:[',env_name,'] Expecting:[',model_name,']']) ;
        
        [env,next] = fetch_env(statements,next) ;
        model = mttAppendFields(model,env) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end




function [env,next] = fetch_env(statements,next)
    env = [] ;
    unit_name = 'env' ;
    
    number_of_statements = length(statements) ;
    
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'path',
            mttAssert(open,...
                ['"path" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            path_names = mttGetFieldNames(env,'path') ;
            
            [path_name,path_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(path_name,path_names),...
                ['Path "',path_name,'" already declared']) ;
            mttAssert(path_name(1)=='$',...
                ['Path "',path_name,'" must be prefixed with "$"']) ;
            
            path_name(1) = [] ;
            env = setfield(env,'path',path_name,path_spec) ;
            
        case 'domain',
            mttAssert(open,...
                ['"domain" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            domain_names = mttGetFieldNames(env,'domain') ;
            
            [domain_name,domain_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(domain_name,domain_names),...
                ['Domain "',domain_name,'" already declared']) ;
            
            env = setfield(env,'domain',domain_name,domain_spec) ;
                    
        case 'struct',
            mttAssert(open,...
                ['"struct" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            struct_names = mttGetFieldNames(env,'struct') ;
            
            [struct_name,struct_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(struct_name,struct_names),...
                ['Struct "',struct_name,'" already declared']) ;
            mttAssert(~isempty(struct_spec),...
                ['Undefined datatype within struct "',struct_name,'"']) ;
            
            env = setfield(env,'struct',struct_name,struct_spec) ;
                    
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    env = mttSetFieldDefault(env,'path',[]) ;
    env = mttSetFieldDefault(env,'domain',[]) ;
    env = mttSetFieldDefault(env,'struct',[]) ;
    

Added ntt/bin/trans/m/mttFetchInterfaceDefinition.m version [317a4da97c].








































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttFetchInterfaceDefinition(filename)

mttAssert(exist(filename)==2,...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.representation = 'cr' ;
model.source = mttCutText(filename,'_cr.txt') ;
content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;
crs = [] ;

next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'cr',
        cr_name = mttCutText(line,'[') ;
        mttValidateName(cr_name) ;
        
        if ~isempty(crs)
            mttAssert(~ismember(cr_name,crs),...
                ['"cr ',cr_name,'" has already been declared']) ;
        end
        
        cr_parameter_list = mttExtractText(line,'[',']') ;
        [cr_parameters,cr_defaults] = mttGetParameters(cr_parameter_list) ;
        
        [cr,next] = fetch_cr(statements,next,cr_name,cr_parameters,cr_defaults) ;
        
        mttCheckInterfaceDeclarations(cr) ;
        mttCheckStateDeclarations(cr) ;
        
        model = setfield(model,'item',cr_name,cr) ;
        
        if isempty(crs)
            crs = {cr_name} ;
        else
            crs = [crs,{cr_name}] ;
        end
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end


       
function [cr,next] = fetch_cr(statements,next,cr_name,cr_parameters,cr_defaults)
	unit_name = 'cr' ;
	here = [cr_name,'/',unit_name] ;
    
    cr = [] ;
    number_of_statements = length(statements) ;
    
    cr.sympar = cr_parameters ;
    cr.numpar = [] ;
    cr.input = [] ;
    cr.state = [] ;
    
    cr.sympar_default = cr_defaults ;
    cr.numpar_default = [] ;
    cr.input_default = [] ;
    cr.state_default = [] ;

    op_counter = 0 ;
    interface_declared = 0 ;
	open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'interface',
            mttAssert(open,...
                ['"interface" declaration must be contained inside {...} in ',here]) ;
            mttAssert(~interface_declared,...
                '"interface" declaration must be unique') ;
            mttAssert(isempty(line),...
                ['Unexpected text after "interface" declaration in ',here]) ;
            
            [interface,next] = fetch_interface(statements,next,cr_name) ;
            cr.interface = interface ;
            interface_declared = 1 ;
            
        case 'operator',
            mttAssert(interface_declared,...
                ['"operator" declaration must follow "interface" in ',here]) ;
            mttAssert(open,...
                ['"operator" declaration must be contained inside {...} in ',here]) ;
            
            op_counter = op_counter + 1 ;
            [operator,next] = fetch_operator(statements,next,cr,cr_name) ;
            
            if ~isfield(operator,'content')
                operator.content = [] ;
            end
            cr.operator(op_counter) = operator ;
            
        case 'input',
            mttAssert(open,...
                ['"input" declarations must be contained inside {...} in ',here]) ;
            
            input_parameter_list = line ;
            [input_parameters,input_defaults] = mttGetParameters(input_parameter_list) ;
            
            cr = mttAppend(cr,'input',input_parameters) ;
            cr = mttAppend(cr,'input_default',input_defaults) ;
            
        case 'numpar',
            mttAssert(open,...
                ['"numpar" declarations must be contained inside {...} in ',here]) ;
            
            numerical_parameter_list = line ;
            [numerical_parameters,numerical_defaults] = mttGetParameters(numerical_parameter_list) ;
            
            cr = mttAppend(cr,'numpar',numerical_parameters) ;
            cr = mttAppend(cr,'numpar_default',numerical_defaults) ;
            
        case 'state',
            mttAssert(open,...
                ['"state" declarations must be contained inside {...} in ',here]) ;
            
            state_parameter_list = line ;
            [state_parameters,state_defaults] = mttGetParameters(state_parameter_list) ;
            
            cr = mttAppend(cr,'state',state_parameters) ;
            cr = mttAppend(cr,'state_default',state_defaults) ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in ',here]) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in ',here]) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised keyword "',keyword,'" in ',here]) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in ',here]) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    interface_ports = mttGetFieldNames(cr.interface,'port') ;
    interface_ports_with_state = [] ;
    
    counter = 0 ;
    for i = 1:length(interface_ports)
        port_name = interface_ports{i} ;
        interface_port = getfield(cr.interface,'port',port_name) ;
        if interface_port.is_effort_state | interface_port.is_flow_state
            counter = counter + 1 ;
            interface_ports_with_state{counter} = port_name ;
        end
    end
    
    mttAssert(op_counter>0,...
        ['No operator defined in ',here]) ;
    
    assigned_ports = [] ;
    
    for i = 1:length(cr.operator)
        if i==1
            operator_names{1} = cr.operator(i).name ;
        else
            operator_name = cr.operator(i).name ;
            mttAssert(~ismember(operator_name,operator_names),...
                ['Repeated operator name "',operator_name,'" in ',here]) ;
            operator_names{i} = operator_name ;
        end
        
        newly_assigned_ports = mttGetFieldNames(cr.operator(i),'assign') ;
        if isempty(assigned_ports)
            assigned_ports = newly_assigned_ports ;
        else
            if ~isempty(newly_assigned_ports)
                assigned_ports = [assigned_ports, newly_assigned_ports] ;
            end
        end
    end
    
    for i = 1:length(interface_ports_with_state)
        interface_port = interface_ports_with_state{i} ;
        
        mttAssert(ismember(interface_port,assigned_ports),...
            ['Missing "set" declaration for port "',interface_port,'" in ',here]) ;
    end
    
    
    
    
function [interface,next] = fetch_interface(statements,next,cr_name)
global mtt_environment
	unit_name = 'interface' ;
    here = [cr_name,'/',unit_name] ;
    
    domain_names = mttGetFieldNames(mtt_environment,'domain') ;
    
    interface = [] ;
    number_of_statements = length(statements) ;
    
    counter = 0 ;
    constraint = [] ;
    
    open = 0 ;
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'port',
            ports = mttGetItemList(line) ;
            for n = 1:length(ports)
                identifier = mttCutText(ports{n},'[') ;
                qualifier = mttExtractText(ports{n},'[',']') ;
                [name.domain,name.domain_item] = mttCutText(qualifier,'::') ;
                
                name.port = identifier ;
                mttValidateName(name.port) ;
                
                if isempty(name.domain) | isempty(mtt_environment)
                    interface = setfield(interface,'port',name.port,'domain',[]) ;
                    interface = setfield(interface,'port',name.port,'domain_item',[]) ;
                    interface = setfield(interface,'port',name.port,'was_generic',1) ;
                else
                    mttAssert(ismember(name.domain,domain_names),...
                        ['Unrecognised domain "',name.domain,'"']) ;
                    dom = getfield(mtt_environment,'domain',name.domain,'dom') ;
                    item = getfield(mtt_environment,'domain',name.domain,'item') ;
                    
                    if isempty(item)
                        public_domain = getfield(mtt_environment,'public_domain',{dom}) ;
                        item_names = mttGetFieldNames(public_domain,'item') ;
                        
                        mttAssert(ismember(name.domain_item,item_names),...
                            ['Item "',name.domain_item,'" not found in public domain "',name.domain,'"']) ;
                        item_name = name.domain_item ;
                    else
                        mttAssert(isempty(name.domain_item),...
                            ['Item unspecified in public domain "',name.domain,'"']) ;
                        item_name = item ;
                    end
                    
                    interface = setfield(interface,'port',name.port,'domain',dom) ;
                    interface = setfield(interface,'port',name.port,'domain_item',item_name) ;
                    interface = setfield(interface,'port',name.port,'was_generic',0) ;
                end
                interface = setfield(interface,'port',name.port,'is_effort_state',0) ;
                interface = setfield(interface,'port',name.port,'is_flow_state',0) ;
                interface = setfield(interface,'port',name.port,'assign',[]) ;
            end
            
        case {'assert','prefer'},
            counter = counter + 1 ;
            constraint{counter} = statement ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in ',here]) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in ',here]) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in ',here]) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in ',here]) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    
    interface_ports = mttGetFieldNames(interface,'port') ;
    number_of_constraints = length(constraint) ;
    
    for i = 1:number_of_constraints
        [keyword,assignment] = mttSeparateText(constraint{i}) ;
        [namelist,definition] = mttCutText(assignment,'=>') ;
        
        mttAssert(~isempty(keyword),...
            ['Rule "',constraint{i},'" has no context in cr ',cr_name]) ;
                
        if ~isempty(namelist)
            first = 1 ;
            last = length(namelist) ;
            if namelist([first,last])=='[]'
                ports = mttGetItemList(mttExtractText(namelist,'[',']')) ;
            else
                ports = {namelist} ;
            end
        end
        
        mttAssert(~isempty(ports),...
            ['Rule "',constraint{i},'" has no association in cr ',cr_name]) ;
        mttAssert(~isempty(definition),...
            ['Rule "',constraint{i},'" not defined in cr ',cr_name]) ;
        
		for j = 1:length(ports)
            port_name = ports{j} ;
            mttValidateName(port_name) ;
            
            other_ports = [] ;
            counter = 0 ;
            for k = 1:length(ports)
                if j~=k
                    counter = counter + 1 ;
                    other_ports{counter} = ports{k} ;
                end
            end
            
            mttAssert(ismember(port_name,interface_ports),...
                ['Unreferenced port "',port_name,'" in cr ',cr_name]) ;
            
            port = getfield(interface,'port',port_name) ;
            
            switch definition
            case 'effort_state',
                mttAssert(mttIsEqual(port.is_flow_state,0),...
                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
                port.is_effort_state = 1 ;
                
            case 'flow_state',
                mttAssert(mttIsEqual(port.is_effort_state,0),...
                    ['Attempt to overwrite state assignment at port "',port_name,'" in ',here]) ;
                port.is_flow_state = 1 ;
                
            otherwise,
                rule_number = 1 + mttGetFieldLength(port,'causality') ;
                
                port.causality(rule_number).rule = keyword ;
                port.causality(rule_number).def = definition ;
                port.causality(rule_number).with = other_ports ;
                port.causality(rule_number).applied = 0 ;
            end
            
            interface = setfield(interface,'port',port_name,port) ;
        end
    end
        
    
function [operator,next] = fetch_operator(statements,next,cr,cr_name)
	unit_name = 'operator' ;
    here = [cr_name,'/',unit_name] ;
    
    interface = [] ;
    number_of_statements = length(statements) ;
    
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    operator = mttGetOperatorContext(line,cr,cr_name) ;
    
    operator.content = [] ;
    operator.var = [] ;
    operator.var_default = [] ;
    operator.struct = [] ;
    operator.set = [] ;
    
    counter = 0 ;
    
    open = 0 ;
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case '{',
            mttAssert(~open,['Unmatched "{" in ',here]) ;
            open = 1 ;
            
        case '}',
            mttAssert(open,['Unmatched "}" in ',here]) ;
			open = 0 ;
            
        case 'set',
            mttAssert(open,...
                ['"set" declarations must be contained inside {...} in ',here]) ;
            
            operator = mttAppend(operator,'set',{line}) ;
            
        case 'var',
            mttAssert(open,...
                ['"var" declarations must be contained inside {...} in ',here]) ;
            
            variable_list = line ;
            [variables,defaults] = mttGetParameters(variable_list) ;
            
            operator = mttAppend(operator,'var',variables) ;
            operator = mttAppend(operator,'var_default',defaults) ;
            
        case 'struct',
            mttAssert(open,...
                ['"struct" declarations must be contained inside {...} in ',here]) ;
            
            [struct_name,variable_list] = mttSeparateText(line) ;
            [variables,defaults] = mttGetParameters(variable_list) ;
            
            mttAssert(mttIsEmptyCellArray(defaults),...
                ['"struct" declarations cannot have default values in ',here]) ;
            
            operator.struct = mttAppend(operator.struct,struct_name,variables) ;
            
        otherwise,
            counter = counter + 1 ;
            operator.content{counter} = statement ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in ',here]) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    cr_ports = mttGetFieldNames(cr.interface,'port') ;
    for i = 1:length(operator.var)
        current_var = operator.var{i} ;
        mttAssert(~ismember(current_var,cr.numpar),...
            ['Variable "',current_var,'" redeclares CR numerical parameter in ',cr_name]) ;
        mttAssert(~ismember(current_var,cr.sympar),...
            ['Variable "',current_var,'" redeclares CR parameter in ',cr_name]) ;
        mttAssert(~ismember(current_var,cr_ports),...
            ['Variable "',current_var,'" redeclares CR port in ',cr_name]) ;
    end
    
    operator = mttParseOperatorEquations(operator,cr,cr_name) ;

    
function context = mttGetOperatorContext(line,cr,cr_name)
    index = sort([findstr(line,'|'),findstr(line,'<'),findstr(line,'>')]) ;
    assignment = findstr(line,':=') ;

    mttAssert(length(assignment)==1,...
        ['Operator declaration must contain a unique ":=" assignment in cr ',cr_name]) ;
    mttAssert(length(index)>0,...
        ['Operator declaration without ports in cr ',cr_name]) ;
    
    left_side = index(index<assignment) ;
    right_side = index(index>assignment) ;
    
    mttAssert(length(left_side)>0,...
        ['Operator declaration without input ports in cr ',cr_name]) ;
    mttAssert(length(right_side)>0,...
        ['Operator declaration without output ports in cr ',cr_name]) ;
    mttAssert(mod(length(left_side),2)==0 & mod(length(right_side),2)==0,...
        ['Operator declaration has mismatched tags in cr ',cr_name]) ;
    
    context.name = mttClipText(line(assignment+2:right_side(1)-1)) ;
    mttAssert(~isempty(context.name),...
        ['Operator declaration is anonymous in cr ',cr_name]) ;
    
    mttValidateName(context.name) ;
    
    
    counter = 0 ;
    
    for i = 1:length(index)/2
        counter = counter + 1 ;
        link = [] ;
        
        right = 2*i ;
        left = right - 1 ;
        
        if index(right)<assignment
            link.is_input = 0 ;
        elseif index(left)>assignment
            link.is_input = 1 ;
        end
        
        
        recognised = 1 ;
        switch line(index([left,right]))
        case '|>',
            link.is_flow = 1 ;
            link.is_effort = 0 ;
        case '<|',
            link.is_flow = 0 ;
            link.is_effort = 1 ;
        case '<>',
            link.is_flow = 1 ;
            link.is_effort = 1 ;
        otherwise,
            recognised = 0 ;
        end
        
        mttAssert(recognised,...
            ['Unrecognised tags in operator ',context.name,' (cr ',cr_name,')']) ;
        
        port_declaration = line(index(left):index(right)) ;
        port = line(index(left)+1:index(right)-1) ;
        mttAssert(~isempty(port),...
            ['Empty port in operator ',context.name,' (cr ',cr_name,')']) ;
            
        [port_name,qualifier] = mttCutText(port,'=') ;
        
        link.name = port_name ;

        if isempty(qualifier)
            link.is_unconstrained = 1 ;
        else
            link.is_unconstrained = 0 ;
            mttAssert(strcmp(qualifier,'0'),...
                ['Non-zero port constraint in operator ',context.name,' (cr ',cr_name,')']) ;
        end
        
        context.link(counter) = link ;
    end
    
    
    cr_port_names = mttGetFieldNames(cr.interface,'port') ;
    
    check.is_input = [] ;
    check.is_output = [] ;
    check.is_effort = [] ;
    check.is_flow = [] ;
    
    for j = 1:length(cr_port_names)
        port_check(j) = check ;
    end    
    
    for i = 1:counter
        port_name = context.link(i).name ;
        mttAssert(ismember(port_name,cr_port_names),...
            ['Operator declaration uses undefined port "',port_name,'" in cr ',cr_name]) ;
        
        index = strmatch(port_name,cr_port_names,'exact') ;
        
        mttAssert(~mttIsEqual(port_check(index).is_input,context.link(i).is_input),...
            ['Operator declaration has repeated input ports in cr ',cr_name]) ;
        mttAssert( mttIsEqual(port_check(index).is_output,context.link(i).is_input),...
            ['Operator declaration has repeated output ports in cr ',cr_name]) ;
        mttAssert(~mttIsEqual(port_check(index).is_flow,context.link(i).is_flow),...
            ['Operator declaration has repeated flow in cr ',cr_name]) ;
        mttAssert(~mttIsEqual(port_check(index).is_effort,context.link(i).is_effort),...
            ['Operator declaration has repeated effort in cr ',cr_name]) ;
        
        port_check(index).is_input = context.link(i).is_input ;
        port_check(index).is_output = ~context.link(i).is_input ;
        port_check(index).is_flow = context.link(i).is_flow ;
        port_check(index).is_effort = context.link(i).is_effort ;
    end
    
    for j = 1:length(cr_port_names)
        mttAssert(~isempty(port_check(j).is_input),...
            ['Operator declaration has missing input ports in cr ',cr_name]) ;
        mttAssert(~isempty(port_check(j).is_output),...
            ['Operator declaration has missing output ports in cr ',cr_name]) ;
        mttAssert(~isempty(port_check(j).is_flow),...
            ['Operator declaration has missing flow in cr ',cr_name]) ;
        mttAssert(~isempty(port_check(j).is_effort),...
            ['Operator declaration has missing effort in cr ',cr_name]) ;
    end    

Added ntt/bin/trans/m/mttFetchSpecification.m version [94b1cb9964].






























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttFetchSpecification(filename)

model = [] ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.specification = filename ;

model.source = mttCutText(filename,'_abg.txt') ;
model_name = mttDetachText(model.source,'/') ;

content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

abg_declared = 0 ;
next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case 'abg',
        mttAssert(~abg_declared,...
            '"abg" declaration must be unique') ;
        abg_declared = 1 ;
        
        abg_name = mttCutText(line,'[') ;
        mttAssert(strcmp(abg_name,model_name),...
            ['Wrong name:[',abg_name,'] Expecting:[',model_name,']']) ;
        
        abg_parameter_list = mttExtractText(line,'[',']') ;
        [abg_parameters,abg_defaults] = mttGetParameters(abg_parameter_list) ;
        
        model.name = abg_name ;
        
        model.sympar = abg_parameters ;
        model.sympar_default = abg_defaults ;

        [abg,next] = fetch_abg(statements,next) ;
        
        model = mttAppendFields(model,abg) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end

mttCheckBondgraphDeclarations(model) ;



function [abg,next] = fetch_abg(statements,next)
global mtt_environment

    abg = [] ;
    unit_name = 'abg' ;
    
    user_defined_paths = mttGetFieldNames(mtt_environment,'path') ;
    
    number_of_statements = length(statements) ;
    
    bondgraph = [] ;
    use_declared = 0 ;
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'use',
            mttAssert(open,...
                ['"use" declaration must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~use_declared,...
                '"use" declaration must be unique') ;
            
            use_declared = 1 ;
            bondgraph = line ;
            
            abg.bondgraph = bondgraph ;
            
        case 'input',
            mttAssert(open,...
                ['"input" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            input_parameter_list = line ;
            [input_parameters,input_defaults] = mttGetParameters(input_parameter_list) ;
            
            abg = mttAppend(abg,'input',input_parameters) ;
            abg = mttAppend(abg,'input_default',input_defaults) ;
            
        case 'numpar',
            mttAssert(open,...
                ['"numpar" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            numerical_parameter_list = line ;
            [numerical_parameters,numerical_defaults] = mttGetParameters(numerical_parameter_list) ;
            
            abg = mttAppend(abg,'numpar',numerical_parameters) ;
            abg = mttAppend(abg,'numpar_default',numerical_defaults) ;
            
        case 'object',
            mttAssert(open,...
                ['"object" declarations must be contained inside {...} in "',unit_name,'"']) ;
            
            object_names = mttGetFieldNames(abg,'obj') ;
            
            [object_name,object_spec] = mttCutText(line,':=') ;
            mttAssert(~ismember(object_name,object_names),...
                ['Object "',object_name,'" already declared']) ;
            
            implementation = mttCutText(object_spec,'[') ;
            mttAssert(~isempty(implementation),...
                ['Incomplete specification:[',line,']']) ;
            
            object_parameter_list = mttExtractText(line,'[',']') ;
            object_parameters = mttGetInstanceParameters(object_parameter_list) ;
            
            [source,name.item] = mttCutText(implementation,'::') ;
            [name.class,name.path] = mttDetachText(source,'/') ;
            
            if isempty(name.class)
                name.class = source ;
                name.path = [] ;
            else
                mttAssert(~isempty(name.path),...
                    ['Empty path name in "',unit_name,'"']) ;
                if name.path(1)=='$'
                    [path_alias,path_branch] = mttCutText(name.path,'/') ;
                    path_alias(1) = [] ;
                    
                    mttAssert(ismember(path_alias,user_defined_paths),...
                        ['Path "',path_alias,'" not recognised']) ;
                    
                    path_root = getfield(mtt_environment,'path',path_alias) ;
                    if isempty(path_branch)
                        name.path = path_root ;
                    else
                        name.path = [path_root,'/',path_branch] ;
                    end
                end
            end
            
            abg = setfield(abg,'obj',object_name,'name',name) ;
            abg = setfield(abg,'obj',object_name,'parameter',object_parameters) ;
                    
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            error(['Unrecognised_keyword "',keyword,'" in "',unit_name,'"']) ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end
    
    abg = mttSetFieldDefault(abg,'input',[]) ;
    abg = mttSetFieldDefault(abg,'input_default',[]) ;
    abg = mttSetFieldDefault(abg,'numpar',[]) ;
    abg = mttSetFieldDefault(abg,'numpar_default',[]) ;
    abg = mttSetFieldDefault(abg,'bondgraph',[]) ;
    

Added ntt/bin/trans/m/mttFetchStruct.m version [3e806bb24f].













































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttFetchStruct(filename)

model.representation = 'struct' ;

mttAssert(mttFileExists(filename),...
    ['File "',filename,'" not found']) ;

mttNotify(['   ...processing ',filename]) ;
mttWriteNewLine ;

model.source = mttCutText(filename,'_struct.txt') ;
content = mttReadFile(filename) ;
statements = mttExtractStatements(content) ;

number_of_statements = length(statements) ;

next = 0 ;

parsing = 1 ;
while parsing
    next = next + 1 ;
    statement = statements{next} ;
    [keyword,line] = mttSeparateText(statement) ;
    
    switch keyword
    case {'struct','public_struct','private_struct'},
        struct_name = line ;
        mttValidateName(struct_name) ;
        
        [struct,next] = fetch_struct(statements,next,struct_name) ;
        model = setfield(model,'item',struct_name,struct) ;
        
        is_private = strcmp(keyword,'private_struct') ;
        model = setfield(model,'item',struct_name,'is_private',is_private) ;
        
    case '{',
        error('Unexpected "{" found') ;
    case '}',
        error('Unexpected "}" found') ;
    otherwise,
        error(['Unrecognised top-level keyword "',keyword,'"']) ;
    end
    
    if next==number_of_statements
        parsing = 0 ;
    end
end


function [struct,next] = fetch_struct(statements,next,struct_name)
    struct = [] ;
    unit_name = 'struct' ;
    
    number_of_statements = length(statements) ;
    
    counter = 0 ;
    open = 0 ;
    
	parsing = 1 ;
    while parsing
        next = next + 1 ;
        statement = statements{next} ;
        [keyword,line] = mttSeparateText(statement) ;
        
        switch keyword
        case 'var',
            mttAssert(open,...
                ['"var" declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Undefined "var" in "',unit_name,'"']) ;
            
            data_name = line ;
            mttValidateName(data_name) ;
            
            counter = counter + 1 ;
            struct.var(counter).name = data_name ;
            struct.var(counter).type = [] ;
            
        case '{',
            mttAssert(~open,['Unmatched "{" in "',unit_name,'"']) ;
            open = 1 ;
        case '}',
            mttAssert(open,['Unmatched "}" in "',unit_name,'"']) ;
			open = 0 ;
        otherwise,
            mttAssert(open,...
                ['Declarations must be contained inside {...} in "',unit_name,'"']) ;
            mttAssert(~isempty(line),...
                ['Empty declaration in "',unit_name,'"']) ;
            
            data_name = line ;
            mttValidateName(data_name) ;
            
            data_type = keyword ;
            mttValidateName(data_type) ;
            
            counter = counter + 1 ;
            struct.var(counter).name = data_name ;
            struct.var(counter).type = data_type ;
        end
        
        mttAssert(~(open & (next==number_of_statements)),...
            ['Missing "}" in "',unit_name,'"']) ;
        
        if (~open) | (next==number_of_statements)
			parsing = 0 ;
        end
    end

Added ntt/bin/trans/m/mttIdentifyDomainCovariables.m version [9da7d7b8fd].


































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function compound_item = mttIdentifyDomainCovariables(item,domain,model)
	domains = mttGetFieldNames(model,'domain') ;
	
	domain_name = domain.source ;
    domain_shortname = mttDetachText(domain_name,'/') ;
    
    item_names = mttGetFieldNames(domain,'item') ;
	
    number_of_bonds = mttGetFieldLength(item,'bond') ;
    
    if number_of_bonds==0
        compound_item.effort = {item.covar.effort} ;
        compound_item.flow = {item.covar.flow} ;
        
   		compound_item.effort_default = {item.covar.effort_default} ;
		compound_item.flow_default = {item.covar.flow_default} ;

    else
        counter = 0 ;
        for k = 1:number_of_bonds
            bond = item.bond(k) ;
            
            [next_domain,next_item] = mttCutText(bond.domain,'::') ;
            if isempty(next_item)
	            mttAssert(ismember(next_item,item_names),...
    	            ['Unrecognised reference "',next_item,'" in domain ',domain_shortname]) ;
            
                next_item = bond.domain ;
                dependent_item = getfield(domain,'item',next_item) ;
                compound_domain = mttIdentifyDomainCovariables(dependent_item,domain,model) ;
            else
                mttAssert(ismember(next_domain,domains),...
                    ['Unrecognised domain reference "',next_domain,'" in domain ',domain_shortname]) ;
                
                next_domain_index = getfield(model,'domain',next_domain,'dom') ;
                next_domain_item_reference = getfield(model,'domain',next_domain,'item') ;
                
                mttAssert(isempty(next_domain_item_reference),...
                    ['Constrained domain reference "',next_domain,'" in domain ',domain_shortname]) ;
                
                actual_domain = model.dom(next_domain_index) ;
                
                actual_domain_name = actual_domain.source ;
                actual_domain_shortname = mttDetachText(actual_domain_name,'/') ;
            
                actual_item_names = mttGetFieldNames(actual_domain,'item') ;
                mttAssert(ismember(next_item,actual_item_names),...
                    ['Unrecognised reference "',next_item,'" in domain ',actual_domain_shortname]) ;
                
                dependent_item = getfield(actual_domain,'item',next_item) ;
                mttAssert(~dependent_item.is_private,...
                    ['No public cross-reference available for "',next_item,'" in domain ',actual_domain_shortname]) ;
                
                compound_domain = mttIdentifyDomainCovariables(dependent_item,actual_domain,model) ;
            end
            
            for i = 1:length(compound_domain.effort)
                counter = counter + 1 ;
                if isempty(bond.name)
                    compound_effort{counter} = compound_domain.effort{i} ;
                    compound_flow{counter} = compound_domain.flow{i} ;
                else
                    compound_effort{counter} = [bond.name,'.',compound_domain.effort{i}] ;
                    compound_flow{counter} = [bond.name,'.',compound_domain.flow{i}] ;
                end
                compound_effort_default{counter} = compound_domain.effort_default{i} ;
                compound_flow_default{counter} = compound_domain.flow_default{i} ;
            end
        end
        
        depth = length(compound_effort) ;
        for n = 1:depth-1
            mttAssert(~ismember(compound_effort{n},{compound_effort{n+1:depth}}),...
                ['Repeated effort variable "',compound_effort{n},'" in domain ',domain_shortname]) ;
            mttAssert(~ismember(compound_flow{n},{compound_flow{n+1:depth}}),...
                ['Repeated flow variable "',compound_flow{n},'" in domain ',domain_shortname]) ;
        end
        
        for n = 1:depth
            mttAssert(~ismember(compound_effort{n},{compound_flow{1:depth}}),...
                ['Ambiguous effort/flow variable "',compound_effort{n},'" in domain ',domain_shortname]) ;
            mttAssert(~ismember(compound_flow{n},{compound_effort{1:depth}}),...
                ['Ambiguous flow/effort variable "',compound_flow{n},'" in domain ',domain_shortname]) ;
        end
        
        mttAssert(~ismember('flow',{compound_effort{1:depth}}),...
            ['Effort variable called "flow" in domain ',domain_shortname]) ;
        mttAssert(~ismember('effort',{compound_flow{1:depth}}),...
            ['flow variable called "effort" in domain ',domain_shortname]) ;
        
		compound_item.effort = compound_effort ;
        compound_item.flow = compound_flow ;
        
		compound_item.effort_default = compound_effort_default ;
		compound_item.flow_default = compound_flow_default ;
    end
	

Added ntt/bin/trans/m/mttIdentifyStructVariables.m version [69b4827ac5].









































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function compound_item = mttIdentifyStructVariables(item,struct,model)
	structs = mttGetFieldNames(model,'struct') ;
	
	struct_name = struct.source ;
    struct_shortname = mttDetachText(struct_name,'/') ;
    
    item_names = mttGetFieldNames(struct,'item') ;
	
    number_of_vars = mttGetFieldLength(item,'var') ;
    
    counter = 0 ;
    for k = 1:number_of_vars
        var = item.var(k) ;
        
        next_item = var.type ;
        if isempty(next_item)
            counter = counter + 1 ;
            compound_var{counter} = var.name ;
        else
            mttAssert(ismember(next_item,item_names),...
                ['Unrecognised reference "',next_item,'" in struct ',struct_shortname]) ;
            
            dependent_item = getfield(struct,'item',next_item) ;
            compound_struct = mttIdentifyStructVariables(dependent_item,struct,model) ;
            
            for i = 1:length(compound_struct.var)
                counter = counter + 1 ;
                compound_var{counter} = [var.name,'.',compound_struct.var{i}] ;
            end
        end
        
        variables = length(compound_var) ;
        for n = 1:variables-1 ;
            mttAssert(~ismember(compound_var{n},{compound_var{n+1:variables}}),...
                ['Repeated variable "',compound_var{n},'" in struct ',struct_shortname]) ;
        end
        
		compound_item.var = compound_var ;
    end
	

Added ntt/bin/trans/m/mttParseOperatorEquations.m version [aba93f30d1].































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function operator = mttParseOperatorEquations(operator,cr,cr_name)
global mtt_environment

    operator.equation = [] ;
%    operator.is_used = 0 ;

	numparlist = cr.numpar ;
	symparlist = cr.sympar ;
	varlist    = operator.var ;
	inputlist  = cr.input ;
	statelist  = cr.state ;
    
    structlist = [] ;
    if ~isempty(operator.struct)
        struct_names = mttGetFieldNames(operator,'struct') ;
        number_of_structs = length(struct_names) ;
        for i = 1:number_of_structs
            struct_name = struct_names{i} ;
            variables = getfield(operator,'struct',struct_name) ;
            if i==1
                structlist = variables ;
            else
                structlist = [structlist,variables] ;
            end
        end
    end
    
    
    inlist = [] ;
    outlist = [] ;
    inlink = [] ;
    outlink = [] ;
    
    input_counter = 0 ;
    output_counter = 0 ;
    
    for i = 1:length(operator.link)
        if operator.link(i).is_input
            input_counter = input_counter + 1 ;
            inlist{input_counter} = operator.link(i).name ;
            inlink(input_counter) = i ;
            infree(input_counter) = operator.link(i).is_unconstrained ;
        else
            output_counter = output_counter + 1 ;
            outlist{output_counter} = operator.link(i).name ;
            outlink(output_counter) = i ;
            outfree(output_counter) = operator.link(i).is_unconstrained ;
        end
    end
    
    
    operator.assign = [] ;
    ports_with_state_assignment = [] ;
        
    for i = 1:length(operator.set)
        [port_covariable,state] = mttCutText(operator.set{i},'=>') ;
        mttAssert(~isempty(state),...
            ['"set" declarations must use "=>" in cr ',cr_name]) ;
        
        [port_name,covariable] = mttCutText(port_covariable,'.') ;
        mttAssert(~isempty(covariable),...
            ['"set" declarations must reference effort/flow covariables in cr ',cr_name]) ;
        
        port = strmatch(port_name,outlist,'exact') ;
        ports_with_state_assignment = [ports_with_state_assignment,port] ;
        
        mttAssert(~isempty(port),...
            ['Output port "',port_name,'" not recognised for "set" declaration in cr ',cr_name]) ;
        mttAssert(outfree(port),...
            ['Constrained port variable used for "set" declaration in cr ',cr_name]) ;
        
        actual_port = getfield(cr.interface.port,port_name) ;
        mttAssert(actual_port.is_effort_state | actual_port.is_flow_state,...
            ['"set" declarations must only be used for effort_states or flow_states in cr ',cr_name]) ;
        
        if isempty(actual_port.domain)
            if actual_port.is_effort_state
                covariables = {'effort'} ;
            elseif actual_port.is_flow_state
                covariables = {'flow'} ;
            end
        else
            public_domain = mtt_environment.public_domain(actual_port.domain) ;
            domain_item = getfield(public_domain.item,actual_port.domain_item) ;
            
            if actual_port.is_effort_state
                covariables = domain_item.effort ;
            elseif actual_port.is_flow_state
                covariables = domain_item.flow ;
            end
        end
        
        index = strmatch(covariable,covariables,'exact') ;
        mttAssert(~isempty(index),...
            ['Unrecognised covariable "',covariable,'" used for "set" declaration in cr ',cr_name]) ;
        
        if isfield(operator.assign,port_name)
            assignment = getfield(operator,'assign',port_name) ;
            mttAssert(isempty(assignment.states{index}),...
                ['Repeated covariable "',covariable,'" used for "set" declaration in cr ',cr_name]) ;
        else
            assignment.covar = covariables ;
            assignment.state{length(covariables)} = [] ;
%            assignment.domain = actual_port.domain ;
%            assignment.domain_item = actual_port.domain_item ;
        end
        
        mttAssert(ismember(state,cr.state),...
            ['Unrecognised state "',state,'" used for "set" declaration in cr ',cr_name]) ;
        
        assignment.state{index} = state ;
        operator = setfield(operator,'assign',port_name,assignment) ;
    end
    operator = mttDeleteField(operator,'set') ;
    
    
    port_assignments = mttGetFieldNames(operator,'assign') ;
    number_of_assignments = length(port_assignments) ;
    for i = 1:number_of_assignments
        assignment = getfield(operator,'assign',port_name) ;
        for j = 1:length(assignment.state)
            mttAssert(~isempty(assignment.state{j}),...
                ['Missing covariable "',covariable,'" from "set" declaration in cr ',cr_name]) ;
        end
    end
        
        
    for i = 1:length(operator.content)
        operator.equation(i).chunk = {[]} ;
%        operator.equation(i).was_generic = 1 ;
%        operator.equation(i).domain = [] ;
%        operator.equation(i).domain_item = [] ;
%        operator.equation(i).is_effort = [] ;
%        operator.equation(i).covariable = [] ;
        
        counter = 0 ;
        
        line = operator.content{i} ;
        
        if ~isempty(mttClipText(line))
            [var,loc] = mttFindEquationVariables(line) ;
            
            if loc(1)>1
                front = line(1:loc(1)-1) ;
                counter = counter + 1 ;
                operator.equation(i).chunk{counter} = front ;
            end
            
            last = length(line) ;
            
            for j = 1:length(var)
                [name,component] = mttCutText(var{j},'.') ;
                
                if isempty(component)
                    [name,attribute] = mttCutText(name,'''') ;
                    
                    numpar = strmatch(name,numparlist,'exact') ;
                    sympar = strmatch(name,symparlist,'exact') ;
                    variable = strmatch(name,varlist,'exact') ;
                    struct = strmatch(name,structlist,'exact') ;
                    input = strmatch(name,inputlist,'exact') ;
                    state = strmatch(name,statelist,'exact') ;
                    
                    ok = ~(isempty(numpar)&isempty(sympar)&isempty(variable)&isempty(struct)&isempty(input)&isempty(state)) ;
                    mttAssert(ok,['Variable ',var{j},' not recognised in cr ',cr_name]) ;
                    
                    is_numpar = ~isempty(numpar) ;
                    is_sympar = ~isempty(sympar) ;
                    is_var    = ~isempty(variable) ;
                    is_struct = ~isempty(struct) ;
                    is_input  = ~isempty(input) ;
                    is_state  = ~isempty(state) ;
                    is_derivative = 0 ;
                    
                    if ~isempty(attribute)
                        mttAssert(strcmp(attribute,'dt'),...
                            ['Unrecognised attribute ',attribute,' in cr ',cr_name]) ;
                        mttAssert(is_state,...
                            ['Derivative of non-state variable in cr ',cr_name]) ;
                        is_state = 0 ;
                        is_derivative = 1 ;
                    end
                    
                    counter = counter + 1 ;
                    
                    if is_numpar
                        operator.equation(i).chunk{counter} = {'numpar',numpar} ;
                    end
                    
                    if is_sympar
                        operator.equation(i).chunk{counter} = {'sympar',sympar} ;
                    end
                    
                    if is_var
                        operator.equation(i).chunk{counter} = {'var',variable} ;
                    end
                    
                    if is_struct
                        operator.equation(i).chunk{counter} = {'struct',struct} ;
                    end
                    
                    if is_input
                        operator.equation(i).chunk{counter} = {'input',input} ;
                    end
                    
                    if is_state
                        operator.equation(i).chunk{counter} = {'state',state} ;
                    end
                    
                    if is_derivative
                        operator.equation(i).chunk{counter} = {'derivative',state} ;
                    end
                    
                else
                    
                    if j==1
                        port = strmatch(name,outlist,'exact') ;
                        
                        if ~isempty(ports_with_state_assignment)
                            mttAssert(~any(port==ports_with_state_assignment),...
                                ['Use "set" declaration to assign output port ',name,' to state in cr ',cr_name]) ;
                        end
                        
                        mttAssert(~isempty(port),...
                            ['Output port ',name,' not recognised in cr ',cr_name]) ;
                        mttAssert(outfree(port),...
                            ['Constrained port variable used in cr ',cr_name]) ;
                        
                        counter = counter + 1 ;
                        operator.equation(i).chunk{counter} = {'link',outlink(port),component} ;
                    else
                        port = strmatch(name,inlist,'exact') ;
                        mttAssert(~isempty(port),...
                            ['Input port ',name,' not recognised in cr ',cr_name]) ;
                        mttAssert(infree(port),...
                            ['Constrained port variable used in cr ',cr_name]) ;
                        
                        counter = counter + 1 ;
                        operator.equation(i).chunk{counter} = {'link',inlink(port),component} ;
                    end
                    
                    
%                    equation_domain = mttIdentifyUserDomain(mtt_environment,...
%                        operator.equation(i).domain,....
%                        operator.equation(i).domain_item) ;
                    
                    covariable = component ;
                    port_name = name ;
                    port = getfield(cr.interface.port,port_name) ;
                    
                    if isempty(port.domain)
                        is_effort = strcmp(covariable,'effort') ;
                        is_flow = strcmp(covariable,'flow') ;
                        
                        mttAssert(is_effort|is_flow, ...
                            ['"',covariable,'" is not a generic covariable']) ;
                        
%                        mttAssert(isempty(operator.equation(i).domain),...
%                            ['Generic interface "',port_name,'" referenced in ',equation_domain,' equation']) ;
                    else
                        public_domain = mtt_environment.public_domain(port.domain) ;
                        actual_domain = getfield(public_domain,'item',port.domain_item) ;
                        
                        port_domain = mttIdentifyUserDomain(mtt_environment,port.domain,port.domain_item) ;
                        
                        is_effort = ismember(covariable,actual_domain.effort) ;
                        is_flow = ismember(covariable,actual_domain.flow) ;
                        
                        mttAssert(is_effort|is_flow, ...
                            ['"',covariable,'" is not a covariable defined in domain "',port_domain,'"']) ;
                        
%                        if isempty(equation_domain)
%                            operator.equation(i).was_generic = 0 ;
%                            operator.equation(i).domain = port.domain ;
%                            operator.equation(i).domain_item = port.domain_item ;
                            %                        operator.equation(i).covariable = covariable ;
                            %                    else
                            %                        mttAssert(covariable==operator.equation(i).covariable, ...
                            %                            ['Equation cannot combine different covariables: [',covariable,',',operator.equation(i).covariable,']') ;
%                        end
                    end
                    
%                    if isempty(operator.equation(i).is_effort)
%                        if is_effort
%                            operator.equation(i).is_effort = 1 ;
%                        else
%                            operator.equation(i).is_effort = 0 ;
%                        end
%                    else
%                        mttAssert(operator.equation(i).is_effort==is_effort,...
%                            ['Effort and flow covariables appear in equation: "',operator.content{i},'"']) ;
%                    end
                end
                
                next = loc(j) + length(var{j}) ;
                
                if j<length(var)
                    glue = line(next:loc(j+1)-1) ;
                    
                    counter = counter + 1 ;
                    operator.equation(i).chunk{counter} = glue ;
                    
                    if j==1
                        mttAssert(~isempty(findstr(glue,':=')),...
                            ['Expect ":=" after first variable in cr ',cr_name]) ;
                    end
                else
                    if next<=last
                        back = line(next:last) ;
                        
                        counter = counter + 1 ;
                        operator.equation(i).chunk{counter} = back ;
                    end
                end
            end
        end
    end
    

Added ntt/bin/trans/m/mttPropagateCausality.m version [3db1dcaa36].





















































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttPropagateCausality(model,branch)
    is_root_model = (nargin==1) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if is_root_model
            branch = mttDetachText(model.source,'/') ;
        end
        here = [branch,':',object_name] ;
        
        if isfield(object,'obj')
            
            for i = 1:mttGetFieldLength(object,'interface')
                port_name = object.interface(i).name ;
                
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                inmap = object.interface(i).map.in ;
                outmap = object.interface(i).map.out ;
                
                [inbond_effort,inbond_flow,inbond_unicausal] = mttGetBondCausality(model,inbond) ;
                [outbond_effort,outbond_flow,outbond_unicausal] = mttGetBondCausality(model,outbond) ;
                [inmap_effort,inmap_flow,inmap_unicausal] = mttGetBondCausality(object,inmap) ;
                [outmap_effort,outmap_flow,outmap_unicausal] = mttGetBondCausality(object,outmap) ;
                
                [model,inbond_ok] = mttUpdateBondCausality(model,inbond,inmap_effort,inmap_flow,inmap_unicausal) ; 
                [model,outbond_ok] = mttUpdateBondCausality(model,outbond,outmap_effort,outmap_flow,outmap_unicausal) ; 
                [object,inmap_ok] = mttUpdateBondCausality(object,inmap,inbond_effort,inbond_flow,inbond_unicausal) ; 
                [object,outmap_ok] = mttUpdateBondCausality(object,outmap,outbond_effort,outbond_flow,outbond_unicausal) ; 
                
                ok = inbond_ok & outbond_ok & inmap_ok & outmap_ok ;
                mttAssert(ok,['Causal conflict at port "',port_name,'" in ',here]) ;
            end
            
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttPropagateCausality(object,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        else
            number_of_interfaces = mttGetFieldLength(object,'interface') ;
            
            switch object.class
            case {'Se','Sf','De','Df'}
                for i = 1:number_of_interfaces
                    port_name = object.interface(i).name ;
                    
                    inbond = object.interface(i).in ;
                    outbond = object.interface(i).out ;
                    
                    mttAssert(xor(isempty(inbond),isempty(outbond)),...
                        ['"',object.class,'" objects must have exactly one attached bond in ',here]) ;
                    
                    switch object.class
                    case {'Se','De'},
                        [model,ok] = mttUpdateBondCausality(model,outbond,[],1,1) ; % Constraint
                        [model] = mttUpdateBondCausality(model,outbond,1,[],1) ; 	% Preference
                    case {'Sf','Df'},
                        [model,ok] = mttUpdateBondCausality(model,outbond,0,[],1) ; % Constraint
                        [model] = mttUpdateBondCausality(model,outbond,[],0,1) ; 	% Preference
                    end
                    
                    mttAssert(ok,['Causal constraint violation at port "',port_name,'" in ',here]) 
                end
                
            case '0',
                mttAssert(number_of_interfaces>1,...
                    ['Less than two interfaces at 0-junction ',here]) ;
                
                imposed_effort = [] ;
                resultant_flow = [] ;
                
                for j = 1:number_of_interfaces
                    inbond = object.interface(j).in ;
                    outbond = object.interface(j).out ;
                    
                    if isempty(inbond)
                        bond(j) = outbond ;
                        orientation(j) = 0 ;
                    else
                        bond(j) = inbond ;
                        orientation(j) = 1 ;
                    end
                    
                    [effort,flow,unicausal] = mttGetBondCausality(model,bond(j)) ;
                    
                    if ~isempty(effort)
	                    if effort==orientation(j)
		                    mttAssert(isempty(imposed_effort),...
    	                        ['Over-determined effort at 0-junction ',here]) ;
                            imposed_effort = bond(j) ;
                        end
                    end
                    
                    if ~isempty(flow)
	                    if flow==orientation(j)
		                    mttAssert(isempty(resultant_flow),...
    	                        ['Over-determined flow at 0-junction ',here]) ;
                            resultant_flow = bond(j) ;
                        end
                    end
                end
                
                for j = 1:number_of_interfaces
                    if ~isempty(imposed_effort)
                        if bond(j)~=imposed_effort
                            model = mttUpdateBondCausality(model,bond(j),~orientation(j),[],[]) ;
                        end
                    end
                    
                    if ~isempty(resultant_flow)
                        if bond(j)~=resultant_flow
                            model = mttUpdateBondCausality(model,bond(j),[],~orientation(j),[]) ;
                        end
                    end
                end
                
            case '1',
                mttAssert(number_of_interfaces>1,...
                    ['Less than two interfaces at 1-junction ',here]) ;
                
                imposed_flow = [] ;
                resultant_effort = [] ;
                
                for j = 1:number_of_interfaces
                    inbond = object.interface(j).in ;
                    outbond = object.interface(j).out ;
                    
                    if isempty(inbond)
                        bond(j) = outbond ;
                        orientation(j) = 0 ;
                    else
                        bond(j) = inbond ;
                        orientation(j) = 1 ;
                    end

                    [effort,flow,unicausal] = mttGetBondCausality(model,bond(j)) ;
                    
                    if ~isempty(effort)
	                    if effort~=orientation(j)
		                    mttAssert(isempty(resultant_effort),...
    	                        ['Over-determined effort at 1-junction ',here]) ;
                            resultant_effort = bond(j) ;
                        end
                    end
                    
                    if ~isempty(flow)
	                    if flow~=orientation(j)
		                    mttAssert(isempty(imposed_flow),...
    	                        ['Over-determined flow at 1-junction ',here]) ;
                            imposed_flow = bond(j) ;
                        end
                    end
                end
                
                for j = 1:number_of_interfaces
                    if ~isempty(resultant_effort)
                        if bond(j)~=resultant_effort
                            model = mttUpdateBondCausality(model,bond(j),orientation(j),[],[]) ;
                        end
                    end
                    
                    if ~isempty(imposed_flow)
                        if bond(j)~=imposed_flow
                            model = mttUpdateBondCausality(model,bond(j),[],orientation(j),[]) ;
                        end
                    end
                end
            end
        end
    end
    

Added ntt/bin/trans/m/mttPropagateDomains.m version [01ad4b747a].
















































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttPropagateDomains(model,branch)
    is_root_model = (nargin==1) ;
    
	objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if is_root_model
            branch = mttDetachText(model.source,'/') ;
        end
        here = [branch,':',object_name] ;
        
        if ~isempty(object.abg)
            
            for j = 1:mttGetFieldLength(object,'interface')
			    port_name = object.interface(j).name ;
                
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                inmap = object.interface(j).map.in ;
                outmap = object.interface(j).map.out ;
                
                [inbond_domain,inbond_domain_item]   = mttGetBondDomain(model,inbond) ;
                [outbond_domain,outbond_domain_item] = mttGetBondDomain(model,outbond) ;
                [inmap_domain,inmap_domain_item]     = mttGetBondDomain(object,inmap) ;
                [outmap_domain,outmap_domain_item]   = mttGetBondDomain(object,outmap) ;
                
                [model,inbond_ok]  = mttUpdateBondDomain(model,inbond,inmap_domain,inmap_domain_item) ; 
                [model,outbond_ok] = mttUpdateBondDomain(model,outbond,outmap_domain,outmap_domain_item) ; 
                [object,inmap_ok]  = mttUpdateBondDomain(object,inmap,inbond_domain,inbond_domain_item) ; 
                [object,outmap_ok] = mttUpdateBondDomain(object,outmap,outbond_domain,outbond_domain_item) ;
                
                ok = inbond_ok & outbond_ok & inmap_ok & outmap_ok ;
                mttAssert(ok,['Domain conflict at port "',port_name,'" in ',here]) ;
            end
            
            if is_root_model
                branch = object_name ;
            else
                branch = [branch,'/',object_name] ;
            end
            
            object = mttPropagateDomains(object,branch) ;
            model = setfield(model,'obj',object_name,object) ;
            
        elseif ~isempty(object.cr)
            
            interface = object.cr.interface ;
            port_names = mttGetFieldNames(interface,'port') ;            
            
            for j = 1:length(port_names)
                port_name = port_names{j} ;
                port = getfield(interface,'port',port_name) ;
                
                inbond = port.in ;
                outbond = port.out ;
                
                [model,inbond_ok]  = mttUpdateBondDomain(model,inbond,port.domain,port.domain_item) ;
                [model,outbond_ok] = mttUpdateBondDomain(model,outbond,port.domain,port.domain_item) ; 
                
                ok = inbond_ok & outbond_ok ;
                mttAssert(ok,['Domain conflict at port "',port_name,'" in ',here]) ;
            end
            
        else
            
            number_of_interfaces = mttGetFieldLength(object,'interface') ;
            
            switch object.class
            case {'0','1'},
                index = 0 ;
                finding_domain = 1 ;
                
                while finding_domain
                    index = index + 1 ;
                
                    inbond = object.interface(index).in ;
                    outbond = object.interface(index).out ;
                    
                    if isempty(inbond)
                        bond_number = outbond ;
                    else
                        bond_number = inbond ;
                    end
                    
                    [existing_domain,existing_domain_item] = mttGetBondDomain(model,bond_number) ;
                
                    found_domain = ~isempty(existing_domain) ;
                    finding_domain = ~found_domain & index<number_of_interfaces ;
                end
                
                if found_domain
                    for j = 1:number_of_interfaces
                        inbond = object.interface(j).in ;
                        outbond = object.interface(j).out ;
                        
                        if isempty(inbond)
                            bond_number = outbond ;
                        else
                            bond_number = inbond ;
                        end
                    
                        model = mttUpdateBondDomain(model,bond_number,existing_domain,existing_domain_item) ;
                    end
                end
            end
        end
    end
    

Added ntt/bin/trans/m/mttWriteSystemApps.m version [d508925095].

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttWriteSystemApps(model)
	if ~isfield(model,'app')
    	return ;
	end

    filename = [model.source,'_include_apps.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Applications for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    fprintf(fid,'\n\n') ;
    
    for i = 1:length(model.app)
        app_inclusion = ['#include "',model.app{i},'"\n'] ;
        fprintf(fid,app_inclusion) ;
    end
    
    fclose(fid) ;

Added ntt/bin/trans/m/mttWriteSystemDefinitions.m version [b4ee230811].







































































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttWriteSystemDefinitions(model)

def.structure = define_data_structures(model) ;
def.covar     = define_bond_covariables(model) ;
def.var       = define_interface_covariables(model) ;
def.sympar    = define_symbolic_parameters(model) ;
def.numpar    = define_numerical_parameters(model) ;
def.input     = define_input_variables(model) ;
def.state     = define_state_variables(model) ;
def.opvar     = define_operator_variables(model) ;

write_definitions(def,model) ;


function code = define_data_structures(model)
    mttNotify('...defining data structures') ;
    mttWriteNewLine ;
    
    code = [] ;
    line = 0 ;
    
    tab = char(32*ones(1,3)) ;
    
    line = line + 1 ;
    code{line} = ['typedef struct {'] ;
    
    line = line + 1 ;
    code{line} = [tab,'double state,derivative ;'] ;
    
    line = line + 1 ;
    code{line} = ['} mttState ;'] ;
    
    line = line + 1 ;
    code{line} = '' ;
    
    line = line + 1 ;
    code{line} = ['typedef struct {'] ;
    
    line = line + 1 ;
    code{line} = [tab,'double effort,flow ;'] ;
    
    line = line + 1 ;
    code{line} = ['} mttGenericDomain ;'] ;
    
    line = line + 1 ;
    code{line} = '' ;
    
    domain_names = mttGetFieldNames(model.env,'domain') ;
    for i = 1:length(domain_names)
        domain_name = domain_names{i} ;
        domain = getfield(model.env,'domain',domain_name) ;
        
        public_domain = model.env.public_domain(domain.dom) ;
        item_names = mttGetFieldNames(public_domain,'item') ;
        
        if isempty(domain.item)
            first = 1 ;
            last = length(item_names) ;
        else
            first = strmatch(domain.item,item_names,'exact') ;
            last = first ;
        end
        
        for j = first:last
            item_name = item_names{j} ;
            covariables = getfield(public_domain,'item',item_name) ;
            
            line = line + 1 ;
            code{line} = ['typedef struct {'] ;
            
            for k = 1:length(covariables.effort)
                line = line + 1 ;
                effort_covariable = strrep(covariables.effort{k},'.','__') ;
                flow_covariable = strrep(covariables.flow{k},'.','__') ;
                code{line} = [tab,'double ',effort_covariable,',',flow_covariable,' ;'] ;
            end
            
            definition = ['} mttDomain__',domain_name] ;
            if isempty(domain.item)
                definition = [definition,'__',item_name] ;
            end
            definition = [definition,' ;'] ;
            
            line = line + 1 ;
            code{line} = definition ;
            
            if j<last
                line = line + 1 ;
                code{line} = '' ;
            end
        end
        
        line = line + 1 ;
        code{line} = '' ;
    end

    struct_names = mttGetFieldNames(model.env,'struct') ;
    for i = 1:length(struct_names)
        struct_name = struct_names{i} ;
        struct = getfield(model.env,'struct',struct_name) ;
        
        public_struct = model.env.public_struct(struct.str) ;
        item_names = mttGetFieldNames(public_struct,'item') ;
        
        index = strmatch(struct.item,item_names,'exact') ;
        
        item_name = item_names{index} ;
        variables = getfield(public_struct,'item',item_name,'var') ;
        
        line = line + 1 ;
        code{line} = ['typedef struct {'] ;
        
        for k = 1:length(variables)
            line = line + 1 ;
            variable = strrep(variables{k},'.','__') ;
            code{line} = [tab,'double ',variable,' ;'] ;
        end
        
        definition = ['} ',struct_name,' ;'] ;
        
        line = line + 1 ;
        code{line} = definition ;
        
        if i<length(struct_names)
            line = line + 1 ;
            code{line} = '' ;
        end
    end


function code = define_bond_covariables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining bond covariables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    width = 0 ;
    domain_names = mttGetFieldNames(root.env,'domain') ;
    for j = 1:length(domain_names)
        domain_name = domain_names{j} ;
        width = max(width,length(domain_name)) ;
    end
    
    code = [] ;
    line = 0 ;
    
    number_of_bonds = mttGetFieldLength(model,'bond') ;
    for i = 1:number_of_bonds
        current_bond = model.bond(i) ;
        
        specified_domain = current_bond.domain ;
        specified_domain_item = current_bond.domain_item ;
        
        user_domain_identification = mttIdentifyUserDomain(root.env,specified_domain,specified_domain_item) ;
        
        if isempty(user_domain_identification)
            data_structure = ['mttGenericDomain'] ;
        else
            data_structure = ['mttDomain__',user_domain_identification] ;
        end
        
        nominal_width = 14 + width ;
        actual_width = length(data_structure) ;
        gap = nominal_width - actual_width ;
        
        whitespace = char(32*ones(1,gap+3)) ;
        
        line = line + 1 ;
        code{line} = [data_structure,whitespace,current_branch,'__',num2str(i),' ;'] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~isempty(object.abg)
            next_branch = [current_branch,'__',object_name] ;
            additional_code = define_bond_covariables(object,root,next_branch) ;
            
            if isempty(code)
                code = additional_code ;
            else
                code = [code,additional_code] ;
            end
        end
    end
    
    if line==0
        code = [] ;
    end
    
    
function code = define_interface_covariables(model)
	mttNotify('...defining interface covariables') ;
    mttWriteNewLine ;
    
    width = 0 ;
    domain_names = mttGetFieldNames(model.env,'domain') ;
    for j = 1:length(domain_names)
        domain_name = domain_names{j} ;
        width = max(width,length(domain_name)) ;
    end
    
    code = [] ;
    line = 0 ;
    
    previous_name = model.namelist(1).var ;
    
    number_of_variables = mttGetFieldLength(model,'namelist') ;
    for i = 2:number_of_variables   % .... first variable is reserved !
        variable_name = model.namelist(i).var ;
        [variable_name,extension] = mttCutText(variable_name,'.') ;

        if ~strcmp(variable_name,previous_name)
            previous_name = variable_name ;
            
            specified_domain = model.namelist(i).domain ;
            specified_domain_item = model.namelist(i).domain_item ;
            
            user_domain_identification = mttIdentifyUserDomain(model.env,specified_domain,specified_domain_item) ;

            if isempty(user_domain_identification)
                data_structure = ['mttGenericDomain'] ;
            else
                data_structure = ['mttDomain__',user_domain_identification] ;
            end
            
            nominal_width = 14 + width ;
            actual_width = length(data_structure) ;
            gap = nominal_width - actual_width ;
            
            whitespace = char(32*ones(1,gap+3)) ;
            
            line = line + 1 ;
            code{line} = [data_structure,whitespace,variable_name,' ;'] ;
        end
    end
    

function code = define_symbolic_parameters(model)
	mttNotify('...defining symbolic parameters') ;
    mttWriteNewLine ;

    model_name = mttDetachText(model.source,'/') ;
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default_value = model.sympar_default{i} ;
        
        whitespace = char(32*ones(1,3)) ;
        
        if isempty(default_value)
            line = line + 1 ;
            code{line} = ['double',whitespace,model_name,'___',variable_name,' ;'] ;
        end
    end
    
    
function code = define_numerical_parameters(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining numerical parameters') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'numpar') ;
    for i = 1:number_of_variables
        variable_name = model.numpar{i} ;
        
        whitespace = char(32*ones(1,3)) ;
        
        line = line + 1 ;
        code{line} = ['double',whitespace,current_branch,'___',variable_name,' ;'] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = define_numerical_parameters(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = define_numerical_parameters(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = define_input_variables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining input variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        
        whitespace = char(32*ones(1,3)) ;
        
        line = line + 1 ;
        code{line} = ['double',whitespace,current_branch,'___',variable_name,' ;'] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = define_input_variables(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = define_input_variables(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = define_state_variables(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining state variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end
    
    whitespace = char(32*ones(1,3)) ;
        
    code = [] ;
    line = 0 ;
    
    if isfield(model,'state')
        assigned_states = [] ;
        counter = 0 ;
        
        port_names = mttGetFieldNames(model.interface,'port') ;
        for j = 1:length(port_names)
            port_name = port_names{j} ;
            port = getfield(model,'interface','port',port_name) ;
            
            if ~isempty(port.assign)
                assignment = port.assign ;
                
                if port.was_generic & ~isempty(port.domain)
                    covariables = mttGetCovariables(env,port.domain,port.domain_item) ;
                    if port.is_effort_state
                        covar = covariables.effort ;
                    else
                        covar = covariables.flow ;
                    end
                    
                    block_size = length(covar) ;
                    for k = 1:length(assignment.state)
                        counter = counter + 1 ;
                        assigned_states{counter} = assignment.state{k} ;
                        
                        for var = 1:block_size
                            line = line + 1 ;
                            code{line} = ['mttState',whitespace,current_branch,'___',assignment.state{k},'___',covar{var},' ;'] ;
                        end                        
                    end
                end
            end
        end
        
        number_of_variables = mttGetFieldLength(model,'state') ;
        for i = 1:number_of_variables
            variable_name = model.state{i} ;
            
            if ~ismember(variable_name,assigned_states)
                line = line + 1 ;
                code{line} = ['mttState',whitespace,current_branch,'___',variable_name,' ;'] ;
            end
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = define_state_variables(object,root,next_branch,env) ;
        elseif ~isempty(object.cr)
            additional_code = define_state_variables(object.cr,root,next_branch,env) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
 
    
function code = define_operator_variables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...defining operator variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        if ~isempty(object.abg)
            additional_code = define_operator_variables(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            line = 0 ;
            additional_code = [] ;
            
            number_of_operators = mttGetFieldLength(object.cr,'operator') ;
            for j = 1:number_of_operators
                operator = object.cr.operator(j) ;
                
                number_of_vars = mttGetFieldLength(operator,'var') ;
                for k = 1:number_of_vars
                    variable_name = operator.var{k} ;
                    
                    whitespace = char(32*ones(1,3)) ;
                    
                    line = line + 1 ;
                    prefix = [next_branch,'___',operator.name] ;
                    additional_code{line} = ['double',whitespace,prefix,'___',variable_name,'      = 0.0 ;'] ;
                end
                
                struct_names = mttGetFieldNames(operator,'struct') ;
                number_of_structs = length(struct_names) ;
                for k = 1:number_of_structs
                    struct_name = struct_names{k} ;
                    variables = getfield(operator,'struct',struct_name) ;
                    
                    for kv = 1:length(variables)
                        variable_name = variables{kv} ;
                        
                        whitespace = char(32*ones(1,3)) ;
                        
                        line = line + 1 ;
                        prefix = [next_branch,'___',operator.name] ;
                        additional_code{line} = [struct_name,whitespace,prefix,'___',variable_name,' ;'] ;
                    end
                end
            end
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function write_definitions(def,model)
    filename = [model.source,'_include_def.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Definitions for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    write_definitive_list(fid,'data_structures',def.structure) ;
    write_definitive_list(fid,'bond_covariables',def.covar) ;
    write_definitive_list(fid,'interface_covariables',def.var) ;
    write_definitive_list(fid,'symbolic_parameters',def.sympar) ;
    write_definitive_list(fid,'numerical_parameters',def.numpar) ;
    write_definitive_list(fid,'input_variables',def.input) ;
    write_definitive_list(fid,'state_variables',def.state) ;
    write_definitive_list(fid,'operator_variables',def.opvar) ;
   
    fclose(fid) ;
    
    
function write_definitive_list(fid,var_type,var_list)
    if ~isempty(var_list)
        fprintf(fid,'\n\n') ;
        fprintf(fid,['// ',var_type]) ;
        fprintf(fid,'\n') ;
        
        tab = char(32*ones(1,3)) ;
        for i = 1:length(var_list)
            formatted_declaration = [tab,var_list{i},'\n'] ;
            fprintf(fid,formatted_declaration) ;
        end
    end

Added ntt/bin/trans/m/mttWriteSystemEquations.m version [6eecd251a9].






























































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttWriteSystemEquations(model)

[eqn,ini] = format_equations(model) ;
write_equations(eqn,ini,model) ;


function [eqn,ini] = format_equations(model)
    mttNotify('...formating ordinary differential equations') ;
    mttWriteNewLine ;
    
    sse = model.equation ;
    namelist = model.namelist ;
    
    tab = char(32*ones(1,3)) ;
                
    eqn_counter = 0 ;
    ini_counter = 0 ;
    
    eqn = [] ;
    ini = [] ;
    
    for i = 1:length(sse)
        content = [] ;
        indent = 0 ;
        
        if isempty(sse(i).operator)
            Lvar = sse(i).var.LHS ;
            Rvar = sse(i).var.RHS ;
            
            if isnumeric(Lvar) | isnumeric(Rvar)
                if isnumeric(Lvar)
                    name = sse(i).branch.LHS ;
                    if mod(Lvar,2)
                        bond_number = (Lvar+1)/2 ;
                    else
                        bond_number = Lvar/2 ;
                    end
                else
                    name = sse(i).branch.RHS ;
                    if mod(Rvar,2)
                        bond_number = (Rvar+1)/2 ;
                    else
                        bond_number = Rvar/2 ;
                    end
                end
                
                [hierarchy,interface] = mttCutText(name,'___') ;
                level = length(findstr(hierarchy,'__')) ;
                
                [root,hierarchy] = mttCutText(hierarchy,'__') ;
                for j = 1:level
                    [obj{j},hierarchy] = mttCutText(hierarchy,'__') ;
                end
                
                if level==0
                    local_object = model ;
                else
                    local_object = getfield(model,'obj',obj{1}) ;
                    for j = 2:level
                        local_object = getfield(local_object,'obj',obj{j}) ;
                    end
                end
                
                [specified_domain,specified_domain_item] = mttGetBondDomain(local_object,bond_number) ;
                
            else
                [name,covar] = mttCutText(namelist(Lvar{1}).var,'.') ;
                [hierarchy,interface] = mttCutText(name,'___') ;
                level = length(findstr(hierarchy,'__')) ;
                
                [root,hierarchy] = mttCutText(hierarchy,'__') ;
                for j = 1:level
                    [obj{j},hierarchy] = mttCutText(hierarchy,'__') ;
                end
                
                parent_object = model ;
                object = getfield(model,'obj',obj{1}) ;
                
                for j = 2:level
                    parent_object = object ;
                    object = getfield(object,'obj',obj{j}) ;
                end
                
                index = strmatch(interface,{object.interface.name},'exact') ;
                interface_definition = object.interface(index) ;
                
                if isempty(interface_definition.in)
                    bond_number = interface_definition.out ;
                else
                    bond_number = interface_definition.in ;
                end
                
                [specified_domain,specified_domain_item] = mttGetBondDomain(parent_object,bond_number) ;
            end
            
            covariables = mttGetCovariables(model.env,specified_domain,specified_domain_item) ;
            
            dimension = length(covariables.effort) ;
            
            
            
            var = sse(i).var.LHS ;
            branch = sse(i).branch.LHS ;
            
            LHS.name = [] ;
            LHS.is_effort = [] ;
            
            switch class(var)
            case 'double',
                if mod(var,2)
%                    LHS.name = [branch,'[',num2str((var+1)/2),']'] ;
                    LHS.name = [branch,'__',num2str((var+1)/2)] ;
                    LHS.is_effort = 1 ;
                else
%                    LHS.name = [branch,'[',num2str(var/2),']'] ;
                    LHS.name = [branch,'__',num2str(var/2)] ;
                    LHS.is_effort = 0 ;
                end
            case 'cell',
                [name,covar] = mttCutText(namelist(var{1}).var,'.') ;
                LHS.name = name ;
                
                if strcmp(covar,'effort')
                    LHS.is_effort = 1 ;
                else
                    LHS.is_effort = 0 ;
                end
            end
            
            
            var = sse(i).var.RHS ;
            branch = sse(i).branch.RHS ;
            
            RHS.name = [] ;
            RHS.is_effort = [] ;
            
            
            switch class(var)
            case 'double',
                if mod(abs(var(1)),2)
%                    RHS.name{1} = [branch,'[',num2str((abs(var(1))+1)/2),']'] ;
                    RHS.name{1} = [branch,'__',num2str((abs(var(1))+1)/2)] ;
                    RHS.is_effort(1) = 1 ;
                else
%                    RHS.name{1} = [branch,'[',num2str(abs(var(1))/2),']'] ;
                    RHS.name{1} = [branch,'__',num2str(abs(var(1))/2)] ;
                    RHS.is_effort(1) = 0 ;
                end
                
                if var(1)<0
                    RHS.name{1} = ['-',RHS.name{1}] ;
                end
                
                for j = 2:length(var)
                    if mod(abs(var(j)),2)
%                        RHS.name{j} = [branch,'[',num2str((abs(var(j))+1)/2),']'] ;
                        RHS.name{j} = [branch,'__',num2str((abs(var(j))+1)/2)] ;
                    	RHS.is_effort(j) = 1 ;
                    else
%                        RHS.name{j} = [branch,'[',num2str(abs(var(j))/2),']'] ;
                        RHS.name{j} = [branch,'__',num2str(abs(var(j))/2)] ;
                    	RHS.is_effort(j) = 0 ;
                    end
                    
                    if var(j)>0
                        RHS.name{j} = [' + ',RHS.name{j}] ;
                    else
                        RHS.name{j} = [' - ',RHS.name{j}] ;
                    end
                end
                
            case 'cell',
                [name,covar] = mttCutText(namelist(var{1}).var,'.') ;
                RHS.name{1} = name ;
                
                if strcmp(covar,'effort') | strcmp(covar,'effort_state')
                    RHS.is_effort = 1 ;
                else
                    RHS.is_effort = 0 ;
                end
            end
            
            for k = 1:dimension
                if LHS.is_effort
                    covar = covariables.effort{k} ;
                else
                    covar = covariables.flow{k} ;
                end
                
                content = [LHS.name,'.',strrep(covar,'.','__')] ;
                indent = char(32*ones(1,length(content)+3)) ;
                
                for j = 1:length(RHS.name)
                    if RHS.is_effort(j)
                        covar = covariables.effort{k} ;
                    else
                        covar = covariables.flow{k} ;
                    end
                    
                    if j==1
                        if strcmp(RHS.name{1},'0')
                            content = [content,' = ',RHS.name{1}] ;
                        else
                            content = [content,' = ',RHS.name{1},'.',strrep(covar,'.','__')] ;
                        end
                    else
                        content = [content,'\n',indent,RHS.name{j},'.',strrep(covar,'.','__')] ;
                    end
                end
                
                content = [content,' ;'] ;
                
                if ~isempty(content)
                    eqn_counter = eqn_counter + 1 ;
                    eqn{eqn_counter} = content ;
                end
            end
            
        else
            op = [sse(i).operator] ;
            [cr,operator] = mttCutText(op,'___') ;
			
            if ~strcmp(eqn{eqn_counter},'')
                eqn_counter = eqn_counter + 1 ;
                eqn{eqn_counter} = [''] ;
            end
            eqn_counter = eqn_counter + 1 ;
            eqn{eqn_counter} = ['// ',op] ; 
            
            
            [root,hierarchy] = mttCutText(cr,'__') ;
            
            level = length(findstr(cr,'__')) ;
            for j = 1:level
                [obj{j},hierarchy] = mttCutText(hierarchy,'__') ;
            end
            
            object = getfield(model,'obj',obj{1}) ;
            for j = 2:level
                object = getfield(object,'obj',obj{j}) ;
            end
            
            index = strmatch(operator,{object.cr.operator.name},'exact') ;
            cr_definition = object.cr ;
            operator_definition = cr_definition.operator(index) ;
            
            
            
            structlist = [] ;
            if ~isempty(operator_definition.struct)
                struct_names = mttGetFieldNames(operator_definition,'struct') ;
                number_of_structs = length(struct_names) ;
                for i = 1:number_of_structs
                    struct_name = struct_names{i} ;
                    variables = getfield(operator_definition,'struct',struct_name) ;
                    if i==1
                        structlist = variables ;
                    else
                        structlist = [structlist,variables] ;
                    end
                end
            end
            
            
            
            
            reassigned_state_list = [] ;
            counter = 0 ;
            
            
            port_names = mttGetFieldNames(cr_definition.interface,'port') ;
            for j = 1:length(port_names)
                port_name = port_names{j} ;
                port = getfield(cr_definition,'interface','port',port_name) ;
                
                if ~isempty(port.assign)
                    assignment = port.assign ;
                    
                                
                    if port.was_generic & ~isempty(port.domain)
                        covar = mttGetCovariables(model.env,port.domain,port.domain_item) ;
                        if port.is_effort_state
                            covar = covariables.effort ;
                        else
                            covar = covariables.flow ;
                        end
                        
                        for k = 1:length(assignment.state)
                            counter = counter + 1 ;
                            reassigned_state_list.name{counter} = assignment.state{k} ;
                            reassigned_state_list.covar{counter} = covar ;
                        end
                        
                        
                        block_size = length(covar) ;
                        for var = 1:block_size
                            segment = [] ;
                            
                            for k = 1:length(assignment.state)
                                segment{1} = [cr,'___',port_name,'.',strrep(covar{var},'.','__')] ;
                                segment{2} = [' = '] ;
                                segment{3} = [cr,'___',assignment.state{k},'___',strrep(covar{var},'.','__'),'.state ;'] ;
                                
                                ini_counter = ini_counter + 1 ;
                                ini{ini_counter} = [segment{1},segment{2},segment{3}] ;
                            end                        
                        end
                    else
                        
                        for k = 1:length(assignment.state)
                            segment{1} = [cr,'___',port_name,'.',strrep(assignment.covar{k},'.','__')] ;
                            segment{2} = [' = '] ;
                            segment{3} = [cr,'___',assignment.state{k},'.state ;'] ;
                            
                            ini_counter = ini_counter + 1 ;
                            ini{ini_counter} = [segment{1},segment{2},segment{3}] ;
                        end
                    end                        
                end
            end
            
            
            equations = operator_definition.equation ;
            for j = 1:length(equations)
                equation = equations(j) ;
                number_of_chunks = mttGetFieldLength(equation,'chunk') ;
                
                equation.domain = [] ;
                equation.domain_item = [] ;
                
                for k = 1:number_of_chunks
                    chunk = equation.chunk{k} ;
                    
                    switch class(chunk)
                    case 'cell'
                        type = chunk{1} ;
                        index = chunk{2} ;
                        
                        switch type
                        case 'link'
                            port_name = operator_definition.link(index).name ;
			                port = getfield(cr_definition,'interface','port',port_name) ;
                            
                            if port.was_generic & ~isempty(port.domain)
                                if isempty(equation.domain)
                                    equation.domain = port.domain ;
                                    equation.domain_item = port.domain_item ;
                                else
                                    same_domain = equation.domain==port.domain ;
                                    same_domain_item = strcmp(equation.domain_item,port.domain_item) ;
                                    mttAssert(same_domain&same_domain_item,...
                                        ['Attempt to overwrite implicit variables with conflicting domains in "',...
                                            operator_definition.content{j},'"']) ;
                                end
                            end
                        end
                    end
                end
                
                
                covariables = mttGetCovariables(model.env,equation.domain,equation.domain_item) ;
%                if equation.is_effort
%                    covar = covariables.effort ; 
%                else
%                    covar = covariables.flow ; 
%                end
                
                block_size = length(covariables.effort) ;
                
                
                for line = 1:block_size
	                segment = [] ;
                    content = [] ;
                    
                    for k = 1:number_of_chunks
                        chunk = equation.chunk{k} ;
                        
                        switch class(chunk)
                        case 'cell'
                            type = chunk{1} ;
                            index = chunk{2} ;
                            
                            switch type
                            case 'link'
                                port_variable = [cr,'___',operator_definition.link(index).name] ;
                                
                                if strcmp(chunk{3},'generic___effort')
                                    segment{k} = [port_variable,'.',strrep(covariables.effort{line},'.','__')] ;
                                elseif strcmp(chunk{3},'generic___flow')
                                    segment{k} = [port_variable,'.',strrep(covariables.flow{line},'.','__')] ;
                                else
                                    segment{k} = [port_variable,'.',strrep(chunk{3},'.','__')] ;
                                end
                                
%                                if length(chunk)>2
%                                    segment{k} = [port_variable,'.',strrep(chunk{3},'.','__')] ;
%                                else
%                                    segment{k} = [port_variable,'.',strrep(covar{line},'.','__')] ;
%                                end
                                
                            case 'numpar'
                                segment{k} = [cr,'___',cr_definition.numpar{index}] ;
                                
                            case 'sympar'
                                parameter = [cr_definition.parameter{index}] ;
                                if isnumeric(parameter)
                                    segment{k} = num2str(parameter) ;
                                else
                                    segment{k} = [cr_definition.parameter{index}] ;
                                end
                                
                            case 'var'
                                segment{k} = [op,'___',operator_definition.var{index}] ;
                                
                            case 'struct'
                                segment{k} = [op,'___',structlist{index}] ;
                                
                            case 'input'
                                segment{k} = [cr,'___',cr_definition.input{index}] ;
                                
                            case 'state'
                                state = cr_definition.state{index} ;
                                if isempty(reassigned_state_list)
                                    state_reassignment = [] ;
                                else
                                    state_reassignment = strmatch(state,reassigned_state_list.name,'exact') ;
                                end
                                
                                if isempty(state_reassignment)
                                    segment{k} = [cr,'___',state,'.state'] ;
                                else
                                    state_covar = reassigned_state_list.covar{line} ;
                                    segment{k} = [cr,'___',state,'___',state_covar{1},'.state'] ;
                                end
                                
%                                segment{k} = [cr,'___',cr_definition.state{index},'.state'] ;
                                    
                            case 'derivative'
                                state = cr_definition.state{index} ;
                                if isempty(reassigned_state_list)
                                    state_reassignment = [] ;
                                else
                                    state_reassignment = strmatch(state,reassigned_state_list.name,'exact') ;
                                end
                                
                                if isempty(state_reassignment)
                                    segment{k} = [cr,'___',state,'.derivative'] ;
                                else
                                    state_covar = reassigned_state_list.covar{line} ;
                                    segment{k} = [cr,'___',state,'___',state_covar{1},'.derivative'] ;
                                end
                                
%                                segment{k} = [cr,'___',cr_definition.state{index},'.derivative'] ;
                                
                            end
                        otherwise
                            chunk = strrep(chunk,':=','=') ;
                            segment{k} = chunk ;
                        end
                    end
                    
                    content = [tab,segment{1}] ;
                    for k = 2:length(segment)
                        content = [content,segment{k}] ;
                    end
                    content = [content,' ;'] ;
                    
                    eqn_counter = eqn_counter + 1 ;
                    eqn{eqn_counter} = content ;
                end
            end
            
            eqn_counter = eqn_counter + 1 ;
            eqn{eqn_counter} = ['// End of ',op] ; 
            eqn_counter = eqn_counter + 1 ;
            eqn{eqn_counter} = [''] ; 
        end
    end    
    
    eqn = eqn' ;
    ini = ini' ;
    

function write_equations(eqn,ini,model)
    filename = [model.source,'_include_ode.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    fprintf(fid,'\n\n') ;
    
    tab = char(32*ones(1,3)) ;
    for i = 1:length(ini)
        formatted_equation = [tab,ini{i},'\n'] ;
        fprintf(fid,formatted_equation) ;
    end
    fprintf(fid,'\n') ;
    for i = 1:length(eqn)
        formatted_equation = [tab,eqn{i},'\n'] ;
        fprintf(fid,formatted_equation) ;
    end
    
    fclose(fid) ;
    

Added ntt/bin/trans/m/mttWriteSystemInitialisation.m version [e48f28b850].




















































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttWriteSystemInitialisation(model)

assignment.numpar = assign_numerical_parameters(model) ;
assignment.sympar = assign_symbolic_parameters(model) ;
assignment.input  = assign_input_variables(model) ;
assignment.invar  = assign_input_covariables(model) ;
assignment.state  = assign_state_variables(model) ;

write_set_numpar(assignment,model) ;
write_set_input(assignment,model) ;
write_set_state(assignment,model) ;



function code = assign_symbolic_parameters(model)
	mttNotify('...assigning symbolic parameters') ;
    mttWriteNewLine ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default = model.sympar_default{i} ;
        
        if isempty(default)
            line = line + 1 ;
            code{line} = [model_name,'___',variable_name,' = 1.0 ;'] ;
        else
            line = line + 1 ;
            code{line} = [model_name,'___',variable_name,' = ',default,' ;'] ;
        end
    end
    
    
function code = assign_numerical_parameters(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning numerical parameters') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'numpar') ;
	    
    for i = 1:number_of_variables
        variable_name = model.numpar{i} ;
        default = model.numpar_default{i} ;
        
        line = line + 1 ;
        if isempty(default)
            code{line} = [current_branch,'___',variable_name,' = 1.0 ;'] ;
        else
            code{line} = [current_branch,'___',variable_name,' = ',default,' ;'] ;
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_numerical_parameters(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = assign_numerical_parameters(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = assign_input_variables(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning input variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    code = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        default = model.input_default{i} ;
        
        line = line + 1 ;
        if isempty(default)
            code{line} = [current_branch,'___',variable_name,' = 0.0 ;'] ;
        else
            code{line} = [current_branch,'___',variable_name,' = ',default,' ;'] ;
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_input_variables(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_code = assign_input_variables(object.cr,root,next_branch) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = assign_input_covariables(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning input covariables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    code = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    code{line} = [current_branch,'__',object_name,'.',covariable,' = 0.0 ;'] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    covariable = strrep(covar{j},'.','__') ;
                    code{line} = [current_branch,'__',object_name,'.',covariable,' = 0.0 ;'] ;
                end
            end
        end
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_input_covariables(object,root,next_branch,env) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
    
    
function code = assign_state_variables(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...assigning state variables') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end
    
    code = [] ;
    line = 0 ;
    
    if isfield(model,'state')
        assigned_states = [] ;
        counter = 0 ;
        
        port_names = mttGetFieldNames(model.interface,'port') ;
        for j = 1:length(port_names)
            port_name = port_names{j} ;
            port = getfield(model,'interface','port',port_name) ;
            
            if ~isempty(port.assign)
                assignment = port.assign ;
                
                if port.was_generic & ~isempty(port.domain)
                    covariables = mttGetCovariables(env,port.domain,port.domain_item) ;
                    if port.is_effort_state
                        covar = covariables.effort ;
                        default = covariables.effort_default ;
                    else
                        covar = covariables.flow ;
                        default = covariables.flow_default ;
                    end
                    
                    block_size = length(covar) ;
                    for k = 1:length(assignment.state)
                        counter = counter + 1 ;
                        assigned_states{counter} = assignment.state{k} ;
                        
                        for var = 1:block_size
                            line = line + 1 ;
                            if isempty(default{var})
                                code{line} = [current_branch,'___',assignment.state{k},'___',covar{var},'.state = 0.0 ;'] ;
                            else
                                code{line} = [current_branch,'___',assignment.state{k},'___',covar{var},'.state = ',default{var},' ;'] ;
                            end
                        end                        
                    end
                end
            end
        end
        
        number_of_variables = mttGetFieldLength(model,'state') ;
        
        for i = 1:number_of_variables
            variable_name = model.state{i} ;
            default = model.state_default{i} ;
            
            if ~ismember(variable_name,assigned_states)
                line = line + 1 ;
                if isempty(default)
                    code{line} = [current_branch,'___',variable_name,'.state = 0.0 ;'] ;
                else
                    code{line} = [current_branch,'___',variable_name,'.state = ',default,' ;'] ;
                end
            end
        end
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_code = [] ;
        if ~isempty(object.abg)
            additional_code = assign_state_variables(object,root,next_branch,env) ;
        elseif ~isempty(object.cr)
            additional_code = assign_state_variables(object.cr,root,next_branch,env) ;
        end
        
        if isempty(code)
            code = additional_code ;
        else
            line = length(code) ;
            for j = 1:length(additional_code)
                if ~ismember(additional_code{j},code)
                    line = line + 1 ;
                    code{line} = additional_code{j} ;
                end
            end
        end
    end
 
    
function write_set_numpar(assignment,model)
    filename = [model.source,'_include_set_numpar.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Numerical Parameters for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_assigned_list(fid,[],assignment.numpar,model_name) ;
   
    fclose(fid) ;
    
    
function write_set_input(assignment,model)
    filename = [model.source,'_include_set_input.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Default Inputs for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_assigned_list(fid,'symbolic_parameters',assignment.sympar,model_name) ;
    write_assigned_list(fid,'input_variables',assignment.input,model_name) ;
    write_assigned_list(fid,'input_covariables',assignment.invar,model_name) ;
   
    fclose(fid) ;
    
    
function write_set_state(assignment,model)
    filename = [model.source,'_include_set_state.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Initial states for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_assigned_list(fid,[],assignment.state,model_name) ;
   
    fclose(fid) ;
    
    
function write_assigned_list(fid,var_type,var_list,model_name)
    if ~isempty(var_list)
        if ~isempty(var_type)
            fprintf(fid,'\n\n') ;
            fprintf(fid,['// ',var_type]) ;
        end
        fprintf(fid,'\n') ;
    
        var_list = sort(var_list) ;
        
        width = 0 ;
        for i = 1:length(var_list)
            [left,right] = mttCutText(var_list{i},'=') ;
            width = max(width,length(left)) ;
        end
    
        tab = char(32*ones(1,3)) ;
        for i = 1:length(var_list)
            [left,right] = mttCutText(var_list{i},'=') ;
            
            nominal_width = width ;
            actual_width = length(left) ;
            
            gap = nominal_width - actual_width ;
            whitespace = char(32*ones(1,gap)) ;
            
            formatted_assignment = [tab,left,whitespace,' = ',right,'\n'] ;
            fprintf(fid,formatted_assignment) ;
        end
    end

Added ntt/bin/trans/m/mttWriteSystemMapping.m version [10f14b69b1].

















































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttWriteSystemMapping(model)

sympar = map_system_sympars(model) ;
input  = map_system_inputs(model) ;
invar  = map_system_invars(model) ;
outvar = map_system_outvars(model) ;
state  = map_system_states(model) ;

derivative = differentiate(state) ;

mapping.input = invar ;
if ~isempty(input)
    mapping.input = [mapping.input,input] ;
end
if ~isempty(sympar)
    mapping.input = [mapping.input,sympar] ;
end

mapping.output = outvar ;
mapping.state  = state ;
mapping.derivative = derivative ;

write_get_input(mapping,model) ;
write_get_state(mapping,model) ;

write_put_input(mapping,model) ;
write_put_state(mapping,model) ;
write_put_output(mapping,model) ;
write_put_derivative(mapping,model) ;



function map = map_system_sympars(model)
	mttNotify('...mapping system inputs (symbolic parameters)') ;
    mttWriteNewLine ;

    model_name = mttDetachText(model.source,'/') ;
    
    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    
    for i = 1:number_of_variables
        variable_name = model.sympar{i} ;
        default_value = model.sympar_default{i} ;
        
        if isempty(default_value)
            line = line + 1 ;
            map{line} = [model_name,'___',variable_name] ;
        end
    end
    
    
function map = map_system_inputs(model,root,branch)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input variables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    for i = 1:number_of_variables
        variable_name = model.input{i} ;
        
        line = line + 1 ;
        map{line} = [current_branch,'___',variable_name] ;
    end
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_inputs(object,root,next_branch) ;
        elseif ~isempty(object.cr)
            additional_map = map_system_inputs(object.cr,root,next_branch) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_invars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system inputs (input covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_invars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_outvars(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system outputs (output covariables)') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end

    map = [] ;
    line = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if inbond.effort
                    covar = covariables.effort ;
                elseif ~inbond.flow
                    covar = covariables.flow ;
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if ~outbond.effort
                    if ~strcmp(object.class,'Sf')
                        covar = covariables.effort ;
                    end
                elseif outbond.flow
                    if ~strcmp(object.class,'Se')
                        covar = covariables.flow ;
                    end
                end
                
                for j = 1:length(covar)
                    line = line + 1 ;
                    map{line} = [current_branch,'__',object_name,'.',strrep(covar{j},'.','__')] ;
                end
            end
        end
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_outvars(object,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function map = map_system_states(model,root,branch,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        mttNotify('...mapping system states') ;
        mttWriteNewLine ;
        
        root = model ;
        current_branch = mttDetachText(model.source,'/') ;
        env = model.env ;
    else
        current_branch = branch ;
    end
    
    map = [] ;
    line = 0 ;
    
    if isfield(model,'state')
        assigned_states = [] ;
        counter = 0 ;
        
        port_names = mttGetFieldNames(model.interface,'port') ;
        for j = 1:length(port_names)
            port_name = port_names{j} ;
            port = getfield(model,'interface','port',port_name) ;
            
            if ~isempty(port.assign)
                assignment = port.assign ;
                
                if port.was_generic & ~isempty(port.domain)
                    covariables = mttGetCovariables(env,port.domain,port.domain_item) ;
                    if port.is_effort_state
                        covar = covariables.effort ;
                    else
                        covar = covariables.flow ;
                    end
                    
                    block_size = length(covar) ;
                    for k = 1:length(assignment.state)
                        counter = counter + 1 ;
                        assigned_states{counter} = assignment.state{k} ;
                        
                        for var = 1:block_size
                            line = line + 1 ;
                            map{line} = [current_branch,'___',assignment.state{k},'___',covar{var},'.state'] ;
                        end                        
                    end
                end
            end
        end
        
        number_of_variables = mttGetFieldLength(model,'state') ;
        
        for i = 1:number_of_variables
            variable_name = model.state{i} ;
            
            if ~ismember(variable_name,assigned_states)
                line = line + 1 ;
                map{line} = [current_branch,'___',variable_name,'.state'] ;
            end
        end
    end
    
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        next_branch = [current_branch,'__',object_name] ;
        
        additional_map = [] ;
        if ~isempty(object.abg)
            additional_map = map_system_states(object,root,next_branch,env) ;
        elseif ~isempty(object.cr)
            additional_map = map_system_states(object.cr,root,next_branch,env) ;
        end
        
        if isempty(map)
            map = additional_map ;
        else
            line = length(map) ;
            for j = 1:length(additional_map)
                if ~ismember(additional_map{j},map)
                    line = line + 1 ;
                    map{line} = additional_map{j} ;
                end
            end
        end
    end
    
    
function derivative = differentiate(state)
    mttNotify('...mapping system derivatives') ;
    mttWriteNewLine ;
    
    for i = 1:length(state)
        derivative{i} = strrep(state{i},'.state','.derivative') ;
    end
    
    
function write_get_input(mapping,model)
    filename = [model.source,'_include_get_input.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Input get-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttInput',mapping.input,model_name,1) ;
   
    fclose(fid) ;
    
    
function write_put_input(mapping,model)
    filename = [model.source,'_include_put_input.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Input put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttInput',mapping.input,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_get_state(mapping,model)
    filename = [model.source,'_include_get_state.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// State get-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttState',mapping.state,model_name,1) ;
   
    fclose(fid) ;
    
    
function write_put_state(mapping,model)
    filename = [model.source,'_include_put_state.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// State put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttState',mapping.state,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_put_output(mapping,model)
    filename = [model.source,'_include_put_output.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Output put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttOutput',mapping.output,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_put_derivative(mapping,model)
    filename = [model.source,'_include_put_derivative.h'] ;
    fid = fopen(filename,'w') ;
    
    mttNotify(['...creating ',filename]) ;
    mttWriteNewLine ;
    
    fprintf(fid,['// Derivative put-mapping for Ordinary Differential Equations\n']) ;
    fprintf(fid,'\n') ;
    fprintf(fid,['// file: ',filename,'\n']) ;
    fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
    
    model_name = mttDetachText(model.source,'/') ;
    
    write_mapping(fid,'_mttDerivative',mapping.derivative,model_name,0) ;
   
    fclose(fid) ;
    
    
function write_mapping(fid,array_name,var_list,model_name,is_inward_mapping)
    if ~isempty(var_list)
        var_list = sort(var_list) ;
        
        width = 0 ;
        for i = 1:length(var_list)
            width = max(width,length(var_list{i})) ;
        end
    
        tab = char(32*ones(1,3)) ;
        
        fprintf(fid,'\n') ;
        for i = 1:length(var_list)
            variable = var_list{i} ;
            
            if is_inward_mapping
                nominal_width = width ;
                actual_width = length(variable) ;
                
                gap = nominal_width - actual_width ;
                whitespace = char(32*ones(1,gap)) ;
                
                formatted_mapping = [tab,variable,whitespace,' = ',array_name,'[',num2str(i-1),'] ;\n'] ;
            else
                formatted_mapping = [tab,array_name,'[',num2str(i-1),'] = ',variable,' ;\n'] ;
            end
                
            fprintf(fid,formatted_mapping) ;
        end        
    end

Added ntt/bin/trans/m/mttWriteSystemSfun.m version [ac6231b47a].



























































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttWriteSystemSfun(model)

model_name = mttDetachText(model.source,'/') ;

working_directory  = pwd ;
working_directory = strrep(working_directory,'\','/') ;

filename = [working_directory,'/',model_name,'_sfun.cpp'] ;
fid = fopen(filename,'w') ;

mttNotify(['...creating ',filename]) ;
mttWriteNewLine ;

model_name = mttDetachText(model.source,'/') ;

fprintf(fid,['// Simulation Code for "',model_name,'"\n']) ;
fprintf(fid,'\n') ;
fprintf(fid,['// file: ',filename             ,'\n']) ;
fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
fprintf(fid,'\n') ;

write_sfun(fid,model) ;

fclose(fid) ;


function write_sfun(fid,model)
    model_name = mttDetachText(model.source,'/') ;
    counter = mttCountSystemMapping(model) ;

    fprintf(fid,['#define S_FUNCTION_NAME ',model_name,'_sfun'                     ,'\n']) ;
    fprintf(fid,['#define S_FUNCTION_LEVEL 2'                                      ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['#include "',model_name,'_include_def.h"'                         ,'\n']) ;
    
    if isfield(model,'app')
        if ~isempty(model.app)
            fprintf(fid,['#include "',model_name,'_include_apps.h"'                ,'\n']) ;
        end
    end
    
    fprintf(fid,['#include "simstruc.h"'                                           ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static double *_mttInput ;'                                      ,'\n']) ;
    fprintf(fid,['static double *_mttState ;'                                      ,'\n']) ;
    fprintf(fid,['static double *_mttDerivative ;'                                 ,'\n']) ;
    fprintf(fid,['static double *_mttOutput ;'                                     ,'\n']) ;
    fprintf(fid,['static double  _mttTime ;'                                       ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static unsigned int _mttIndex ;'                                 ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['const int _mttNumInputs  = ',num2str(counter.input),' ;'         ,'\n']) ;
    fprintf(fid,['const int _mttNumOutputs = ',num2str(counter.output),' ;'        ,'\n']) ;
    fprintf(fid,['const int _mttNumStates  = ',num2str(counter.state),' ;'         ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    
    fprintf(fid,['// system equations'                                             ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_set_numpar (void) {'                  ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_set_numpar.h"'                  ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_set_input (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_set_input.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_set_state (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_set_state.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_get_input (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_get_input.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_get_state (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_get_state.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_put_state (void) {'                   ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_put_state.h"'                   ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_put_derivative (void) {'              ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_put_derivative.h"'              ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_put_output (void) {'                  ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_put_output.h"'                  ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,['static void ',model_name,'_ode (void) {'                         ,'\n']) ; 
    fprintf(fid,['#include "',model_name,'_include_ode.h"'                         ,'\n']) ; 
    fprintf(fid,['}'                                                               ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 
    fprintf(fid,[''                                                                ,'\n']) ; 

    fprintf(fid,['// utility procedures'                                           ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static double *array_of_double (size_t n)'                       ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  void *p = calloc (n, sizeof (double)) ;'                       ,'\n']) ;
    fprintf(fid,['  if (! p) fprintf (stderr, "*** ERROR: failed to allocate memory") ;','\n']) ;
    fprintf(fid,['  return (double *) p ;'                                         ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void initialise_arrays (void)'                            ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  _mttInput	 = array_of_double(_mttNumInputs) ;'               ,'\n']) ;
    fprintf(fid,['  _mttOutput	 = array_of_double(_mttNumOutputs) ;'              ,'\n']) ;
    fprintf(fid,['  _mttState	 = array_of_double(_mttNumStates) ;'               ,'\n']) ;
    fprintf(fid,['  _mttDerivative = array_of_double(_mttNumStates) ;'             ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void check_finite(SimStruct *S, double *array, unsigned int index)','\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  const char *array_name ;'                                      ,'\n']) ;
    fprintf(fid,['  char warning[128] ;'                                           ,'\n']) ;
    fprintf(fid,['  if ((array[index] <= 0.0) || (array[index] >= 0.0)) {'         ,'\n']) ;
    fprintf(fid,['    ; // ...no problem'                                          ,'\n']) ;
    fprintf(fid,['  } else {'                                                      ,'\n']) ;
    fprintf(fid,['    if (array == _mttInput) {'                                   ,'\n']) ;
    fprintf(fid,['      array_name = "_mttInput" ;'                                ,'\n']) ;
    fprintf(fid,['    } else if (array == _mttState) {'                            ,'\n']) ;
    fprintf(fid,['      array_name = "_mttState" ;'                                ,'\n']) ;
    fprintf(fid,['    } else if (array == _mttOutput) {'                           ,'\n']) ;
    fprintf(fid,['      array_name = "_mttOutput" ;'                               ,'\n']) ;
    fprintf(fid,['    } else if (array == _mttDerivative) {'                       ,'\n']) ;
    fprintf(fid,['      array_name = "_mttDerivative" ;'                           ,'\n']) ;
    fprintf(fid,['    } else {'                                                    ,'\n']) ;
    fprintf(fid,['      array_name = "unknown_array" ;'                            ,'\n']) ;
    fprintf(fid,['    }'                                                           ,'\n']) ;
    fprintf(fid,['    sprintf(warning,"(time %%f) Non-finite array element: %%s[%%d]",_mttTime,array_name,index) ;','\n']) ;
    fprintf(fid,['    ssWarning(S,warning) ;'                                      ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;

    fprintf(fid,['// S-function methods'                                           ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlInitializeSizes(SimStruct *S)'                    ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  ssSetNumSFcnParams(S,0) ;'                                     ,'\n']) ; 
    fprintf(fid,['  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return ;','\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ssSetNumContStates(S,_mttNumStates) ;'                         ,'\n']) ;
    fprintf(fid,['  ssSetNumDiscStates(S,0) ;'                                     ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  if (!ssSetNumInputPorts(S,1)) return ;'                        ,'\n']) ;
    fprintf(fid,['  ssSetInputPortWidth(S,0,_mttNumInputs) ;'                      ,'\n']) ;
    fprintf(fid,['  ssSetInputPortDirectFeedThrough(S,0,1) ;'                      ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  if (!ssSetNumOutputPorts(S,1)) return ;'                       ,'\n']) ;
    fprintf(fid,['  ssSetOutputPortWidth(S,0,_mttNumOutputs) ;'                    ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ssSetNumSampleTimes(S,1) ;'                                    ,'\n']) ;
    fprintf(fid,['  ssSetNumRWork(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumIWork(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumPWork(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumModes(S,0) ;'                                          ,'\n']) ;
    fprintf(fid,['  ssSetNumNonsampledZCs(S,0) ;'                                  ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ssSetOptions(S,SS_OPTION_EXCEPTION_FREE_CODE) ;'               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  initialise_arrays() ;'                                         ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlInitializeSampleTimes(SimStruct *S)'              ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  ssSetSampleTime(S,0,CONTINUOUS_SAMPLE_TIME) ;'                 ,'\n']) ;
    fprintf(fid,['  ssSetOffsetTime(S,0,0.0) ;'                                    ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['#define MDL_INITIALIZE_CONDITIONS'                               ,'\n']) ;
    fprintf(fid,['static void mdlInitializeConditions(SimStruct *S)'               ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  ',model_name,'_set_numpar() ;'                                 ,'\n']) ;
    fprintf(fid,['  ',model_name,'_set_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_put_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) ssGetContStates(S)[_mttIndex] = _mttState[_mttIndex] ;','\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlOutputs(SimStruct *S,int_T tid)'                  ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  UNUSED_ARG(tid) ;'                                             ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttState[_mttIndex] = ssGetContStates(S)[_mttIndex] ;'      ,'\n']) ;
    fprintf(fid,['    check_finite(S,_mttState,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumInputs; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttInput[_mttIndex] = *ssGetInputPortRealSignalPtrs(S,0)[_mttIndex] ;','\n']) ;
    fprintf(fid,['    check_finite(S,_mttInput,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  _mttTime = ssGetT(S) ;'                                        ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_input() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_ode() ;'                                        ,'\n']) ;
    fprintf(fid,['  ',model_name,'_put_output() ;'                                 ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  for(_mttIndex=0; _mttIndex<_mttNumOutputs; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    check_finite(S,_mttOutput,_mttIndex) ;'                      ,'\n']) ;
    fprintf(fid,['    ssGetOutputPortRealSignal(S,0)[_mttIndex] = _mttOutput[_mttIndex] ;','\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['#define MDL_DERIVATIVES'                                         ,'\n']) ;
    fprintf(fid,['static void mdlDerivatives(SimStruct *S)'                        ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttState[_mttIndex] = ssGetContStates(S)[_mttIndex] ;'      ,'\n']) ;
    fprintf(fid,['    check_finite(S,_mttState,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  for (_mttIndex=0; _mttIndex<_mttNumInputs; _mttIndex++) {'     ,'\n']) ;
    fprintf(fid,['    _mttInput[_mttIndex] = *ssGetInputPortRealSignalPtrs(S,0)[_mttIndex] ;','\n']) ;
    fprintf(fid,['    check_finite(S,_mttInput,_mttIndex) ;'                       ,'\n']) ;
    fprintf(fid,['  }'                                                             ,'\n']) ;
    fprintf(fid,['  _mttTime = ssGetT(S) ;'                                        ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_input() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_get_state() ;'                                  ,'\n']) ;
    fprintf(fid,['  ',model_name,'_ode() ;'                                        ,'\n']) ;
    fprintf(fid,['  ',model_name,'_put_derivative() ;'                             ,'\n']) ;
    fprintf(fid,['  '                                                              ,'\n']) ;
    fprintf(fid,['  if (_mttTime==0)'                                              ,'\n']) ;
    fprintf(fid,['    for(_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) ssGetdX(S)[_mttIndex] = 0.0 ;','\n']) ;
    fprintf(fid,['  else'                                                          ,'\n']) ;
    fprintf(fid,['    for(_mttIndex=0; _mttIndex<_mttNumStates; _mttIndex++) {'    ,'\n']) ;
    fprintf(fid,['      check_finite(S,_mttDerivative,_mttIndex) ;'                ,'\n']) ;
    fprintf(fid,['      ssGetdX(S)[_mttIndex] = _mttDerivative[_mttIndex] ;'       ,'\n']) ;
    fprintf(fid,['    }'                                                           ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,['static void mdlTerminate(SimStruct *S)'                          ,'\n']) ;
    fprintf(fid,['{'                                                               ,'\n']) ;
    fprintf(fid,['  UNUSED_ARG(S);'                                                ,'\n']) ;
    fprintf(fid,['  free (_mttInput) ;'                                            ,'\n']) ;
    fprintf(fid,['  free (_mttOutput) ;'                                           ,'\n']) ;
    fprintf(fid,['  free (_mttState) ;'                                            ,'\n']) ;
    fprintf(fid,['  free (_mttDerivative) ;'                                       ,'\n']) ;
    fprintf(fid,['}'                                                               ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    fprintf(fid,[''                                                                ,'\n']) ;
    
    fprintf(fid,['#ifdef  MATLAB_MEX_FILE'                                         ,'\n']) ;
    fprintf(fid,['#include "simulink.c"'                                           ,'\n']) ;
    fprintf(fid,['#else'                                                           ,'\n']) ;
    fprintf(fid,['#include "cg_sfun.h"'                                            ,'\n']) ;
    fprintf(fid,['#endif'                                                          ,'\n']) ;

Added ntt/bin/trans/mttAppend.m version [18a7272424].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
function information = mttAppend(information,field,items)
	if isfield(information,field)
        previous = getfield(information,field) ;
        if isempty(previous)
            information = setfield(information,field,items) ;
        else
            information = setfield(information,field,[previous,items]) ;
        end
    else
        information = setfield(information,field,items) ;
    end            

Added ntt/bin/trans/mttAppendFields.m version [b7b88d7113].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
function information = mttAppendFields(information,extra)
    if isstruct(information) & isstruct(extra)
        information_fields = fieldnames(information) ;
        extra_fields = fieldnames(extra) ;
        
        for i = 1:length(extra_fields)
            field_name = extra_fields{i} ;
            extra_field = getfield(extra,field_name) ;
            information = setfield(information,field_name,extra_field) ;
        end
    end            

Added ntt/bin/trans/mttAssert.m version [0c09e28616].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function mttAssert(rule,msg)
    if ~isempty(rule)
        if ~rule
            error(['MTT: ',msg]) ;
        end
    end

Added ntt/bin/trans/mttAssign.m version [2407c65690].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function [register,ok] = mttAssign(register,new_value)
	if isempty(register)
        register = new_value ;
        ok = 1 ;
	else
    	ok = register==new_value ;
	end

Added ntt/bin/trans/mttCheckBondgraphDeclarations.m version [6ec9682a08].


































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttCheckBondgraphDeclarations(model)

    for i = 1:length(model.sympar)
        mttAssert(~ismember(model.sympar{i},model.numpar),...
            ['Same name (',model.sympar{i},') used for "numpar" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.sympar{i},model.input),...
            ['Same name (',model.sympar{i},') used for "input" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.numpar)
        mttAssert(~ismember(model.numpar{i},model.input),...
            ['Same name (',model.numpar{i},') used for "numpar" and "input" parameters']) ;   
        mttAssert(~ismember(model.numpar{i},model.sympar),...
            ['Same name (',model.numpar{i},') used for "numpar" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.input)
        mttAssert(~ismember(model.input{i},model.sympar),...
            ['Same name (',model.input{i},') used for "input" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.input{i},model.numpar),...
            ['Same name (',model.input{i},') used for "numpar" and "input" parameters']) ;   
    end
    
    all_parameters = [] ;
    
    if ~isempty(model.sympar)
        all_parameters = model.sympar ;
    end
    if ~isempty(model.numpar)
        if isempty(all_parameters)
            all_parameters = model.numpar ;
        else
            all_parameters = [all_parameters, model.numpar] ;
        end
    end
    if ~isempty(model.input)
        if isempty(all_parameters)
            all_parameters = model.input ;
        else
            all_parameters = [all_parameters, model.input] ;
        end
    end
    
    object_names = mttGetFieldNames(model,'obj') ;
    
    if ~isempty(all_parameters)
        for i = 1:length(object_names)
            object_name = object_names{i} ;
            object = getfield(model,'obj',object_name) ;
            
            for j = 1:length(object.parameter)
                object_parameter = object.parameter{j} ;
                if ~isnumeric(object_parameter)
                    mttAssert(ismember(object_parameter,all_parameters),...
                        ['Object parameter "',object.parameter{j},'" not previously declared']) ;
                end
            end
        end
        
        for j = 1:length(all_parameters)
            current_parameter = all_parameters{j} ;
            other_parameters = all_parameters ;
            other_parameters(j) = [] ;
            
            mttAssert(~ismember(current_parameter,other_parameters),...
                ['Repeated parameter/input name "',current_parameter,'"']) ;
        end
    end
    
    
    counter = 0 ;
    all_instance_parameters = [] ;
    
    for i = 1:length(object_names)
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        for j = 1:length(object.parameter)
            object_parameter = object.parameter{j} ;
            if ~isnumeric(object_parameter)
                counter = counter + 1 ;
                all_instance_parameters{counter} = object_parameter ;
            end
        end
    end
    
    for k = 1:length(all_parameters)
        parameter = all_parameters{k} ;
        if isempty(all_instance_parameters)
            mttAssert(0,['Declared parameter/input "',parameter,'" not used']) ;
        else
            mttAssert(ismember(parameter,all_instance_parameters),...
                ['Declared parameter/input "',parameter,'" not used']) ;
        end
    end
    
    

Added ntt/bin/trans/mttCheckInterfaceDeclarations.m version [2c5010e210].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttCheckInterfaceDeclarations(model)

    for i = 1:length(model.sympar)
        mttAssert(~ismember(model.sympar{i},model.numpar),...
            ['Same name (',model.sympar{i},') used for "numpar" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.sympar{i},model.input),...
            ['Same name (',model.sympar{i},') used for "input" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.numpar)
        mttAssert(~ismember(model.numpar{i},model.input),...
            ['Same name (',model.numpar{i},') used for "numpar" and "input" parameters']) ;   
        mttAssert(~ismember(model.numpar{i},model.sympar),...
            ['Same name (',model.numpar{i},') used for "numpar" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.input)
        mttAssert(~ismember(model.input{i},model.sympar),...
            ['Same name (',model.input{i},') used for "input" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.input{i},model.numpar),...
            ['Same name (',model.input{i},') used for "numpar" and "input" parameters']) ;   
    end
    
    all_parameters = [] ;
    
    if ~isempty(model.sympar)
        all_parameters = model.sympar ;
    end
    if ~isempty(model.numpar)
        if isempty(all_parameters)
            all_parameters = model.numpar ;
        else
            all_parameters = [all_parameters, model.numpar] ;
        end
    end
    if ~isempty(model.input)
        if isempty(all_parameters)
            all_parameters = model.input ;
        else
            all_parameters = [all_parameters, model.input] ;
        end
    end
    
    object_names = mttGetFieldNames(model,'obj') ;
    
    if ~isempty(all_parameters)
        for i = 1:length(object_names)
            object_name = object_names{i} ;
            object = getfield(model,'obj',object_name) ;
            
            for j = 1:length(object.parameter)
                object_parameter = object.parameter{j} ;
                if ~isnumeric(object_parameter)
                    mttAssert(ismember(object_parameter,all_parameters),...
                        ['Object parameter "',object.parameter{j},'" not previously declared']) ;
                end
            end
        end
        
        for j = 1:length(all_parameters)
            current_parameter = all_parameters{j} ;
            other_parameters = all_parameters ;
            other_parameters(j) = [] ;
            
            mttAssert(~ismember(current_parameter,other_parameters),...
                ['Repeated parameter/input name "',current_parameter,'"']) ;
        end
    end
    

Added ntt/bin/trans/mttCheckStateDeclarations.m version [3c4952b269].


























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttCheckStateDeclarations(model)
    for i = 1:length(model.sympar)
        mttAssert(~ismember(model.sympar{i},model.state),...
            ['Same name (',model.sympar{i},') used for "state" and "abg[...]" parameters']) ;   
    end
    
    for i = 1:length(model.numpar)
        mttAssert(~ismember(model.numpar{i},model.state),...
            ['Same name (',model.numpar{i},') used for "numpar" and "state" parameters']) ;   
    end
    
    for i = 1:length(model.input)
        mttAssert(~ismember(model.input{i},model.state),...
            ['Same name (',model.input{i},') used for "input" and "state" parameters']) ;   
    end
    
    for i = 1:length(model.state)
        mttAssert(~ismember(model.state{i},model.sympar),...
            ['Same name (',model.state{i},') used for "state" and "abg[...]" parameters']) ;   
        mttAssert(~ismember(model.state{i},model.numpar),...
            ['Same name (',model.state{i},') used for "state" and "numpar" parameters']) ;   
        mttAssert(~ismember(model.state{i},model.input),...
            ['Same name (',model.state{i},') used for "state" and "input" parameters']) ;   
    end
    
    all_parameters = [] ;
    
    if ~isempty(model.sympar)
        all_parameters = model.sympar ;
    end
    if ~isempty(model.numpar)
        if isempty(all_parameters)
            all_parameters = model.numpar ;
        else
            all_parameters = [all_parameters, model.numpar] ;
        end
    end
    if ~isempty(model.input)
        if isempty(all_parameters)
            all_parameters = model.input ;
        else
            all_parameters = [all_parameters, model.input] ;
        end
    end
    
    for j = 1:length(all_parameters)
        current_parameter = all_parameters{j} ;
        mttAssert(~ismember(current_parameter,model.state),...
            ['Repeated parameter/state name "',current_parameter,'"']) ;
    end
    
    for j = 1:length(model.state)
        current_state = model.state{j} ;
        mttAssert(~ismember(current_state,all_parameters),...
            ['Repeated parameter/state name "',current_state,'"']) ;
    end
    

Added ntt/bin/trans/mttClipText.m version [69d529c0b6].









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
function clipped_text = mttClipText(text)
	if isempty(text)
        clipped_text = [] ;
    else
        index = 1:length(text) ;
        useful = index(~isspace(text)) ;
        clipped_text = text(min(useful):max(useful)) ;
    end

Added ntt/bin/trans/mttCompare.m version [202012e558].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function comparison = mttCompare(left,right)
	if isempty(left) | isempty(right)
        comparison = [] ;
    else
        comparison = (left==right) ;
    end
    

Added ntt/bin/trans/mttCompareCausalCompletion.m version [52e40be8ac].







1
2
3
4
5
6
+
+
+
+
+
+
function is_stable = mttCompareCausalCompletion(current,previous)
	is_stable_flow = current.flows==previous.flows ;
    is_stable_effort = current.efforts==previous.efforts ;
    is_stable = is_stable_flow & is_stable_effort ;


Added ntt/bin/trans/mttCompareDomainCompletion.m version [d97ae73c6a].




1
2
3
+
+
+
function is_stable = mttCompareDomainCompletion(current,previous)
	is_stable = current.assignments==previous.assignments ;

Added ntt/bin/trans/mttCompressText.m version [e7042c4298].







1
2
3
4
5
6
+
+
+
+
+
+
function compressed_text = mttCompressText(text)
	if isempty(text)
    	compressed_text = [] ;
    else
        compressed_text = text(~isspace(text)) ;
    end

Added ntt/bin/trans/mttCountObjects.m version [bbb060ad26].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttCountObjects(model)

    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    model.count.obj = number_of_objects ;
    model.count.cr = 0 ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if ~isempty(object.cr)
            model.count.cr = model.count.cr + 1 ;
        end
        
        if isfield(object,'obj')
            next = mttCountObjects(object) ;
            model.count.obj = model.count.obj + next.count.obj ;
            model.count.cr = model.count.cr + next.count.cr ;
        end
    end
            

Added ntt/bin/trans/mttCountSystemMapping.m version [70ad7bc3f3].




































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function counter = mttCountSystemMapping(model)

sympars = count_system_sympars(model) ;
inputs  = count_system_inputs(model) ;
invars  = count_system_invars(model) ;
outvars = count_system_outvars(model) ;
states  = count_system_states(model) ;

counter.input = sympars + inputs + invars ;
counter.output = outvars ;
counter.state  = states ;


function counter = count_system_sympars(model)
    number_of_variables = mttGetFieldLength(model,'sympar') ;
    counter = 0 ;
    
    for i = 1:number_of_variables
        default_value = model.sympar_default{i} ;
        if isempty(default_value)
            counter = counter + 1 ;
        end
    end
    
    
function counter = count_system_inputs(model)
    number_of_variables = mttGetFieldLength(model,'input') ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_inputs(object) ;
        elseif ~isempty(object.cr)
            additional_variables = count_system_inputs(object.cr) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;
    
    
function counter = count_system_invars(model,root,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        root = model ;
        env = model.env ;
    end
    
    number_of_variables = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if ~inbond.effort
                    if ~strcmp(object.class,'Df')
                        covar = covariables.effort ;
                    end
                elseif inbond.flow
                    if ~strcmp(object.class,'De')
                        covar = covariables.flow ;
                    end
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if outbond.effort
                    covar = covariables.effort ;
                elseif ~outbond.flow
                    covar = covariables.flow ;
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
        end
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_invars(object,root,env) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;
    
    
function counter = count_system_outvars(model,root,env)
    is_root_model = nargin==1 ;
    
    if is_root_model
        root = model ;
        env = model.env ;
    end

    number_of_variables = 0 ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        switch object.class
        case {'SS','Se','Sf','De','Df'}
            inbond_number = object.interface.in ;
            outbond_number = object.interface.out ;
            
            inbond = model.bond(inbond_number) ;
            outbond = model.bond(outbond_number) ;
            
            if ~isempty(inbond)
                covariables = mttGetCovariables(env,inbond.domain,inbond.domain_item) ;
                covar = [] ;
                
                if inbond.effort
                    covar = covariables.effort ;
                elseif ~inbond.flow
                    covar = covariables.flow ;
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
            
            if ~isempty(outbond)
                covariables = mttGetCovariables(env,outbond.domain,outbond.domain_item) ;
                covar = [] ;
                
                if ~outbond.effort
                    if ~strcmp(object.class,'Sf')
                        covar = covariables.effort ;
                    end
                elseif outbond.flow
                    if ~strcmp(object.class,'Se')
                        covar = covariables.flow ;
                    end
                end
                
                number_of_variables = number_of_variables + length(covar) ;
            end
        end
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_outvars(object,root,env) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;
    
    
function counter = count_system_states(model)
    number_of_variables = mttGetFieldLength(model,'state') ;
    
    objects = mttGetFieldNames(model,'obj') ;
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        additional_variables = 0 ;
        if ~isempty(object.abg)
            additional_variables = count_system_states(object) ;
        elseif ~isempty(object.cr)
            additional_variables = count_system_states(object.cr) ;
        end
        
        number_of_variables = number_of_variables + additional_variables ;
    end
    
    counter = number_of_variables ;

Added ntt/bin/trans/mttCreateAlternativeEquations.m version [8fa9da4786].




















































































































































































































































































































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function ese = mttCreateAlternativeEquations(model)

ese = write_equations(model) ;
ese = ese' ;

filename = [model.source,'_ese.txt'] ;
fid = fopen(filename,'w') ;

fprintf(fid,['// Elementary System Equations\n']) ;
fprintf(fid,'\n') ;
fprintf(fid,['// file: ',filename,'\n']) ;
fprintf(fid,['// written by MTT on ',datestr(now),'\n']) ;
fprintf(fid,'\n\n') ;

fprintf(fid,['ese ',mttDetachText(model.source,'/'),' {']) ;
fprintf(fid,'\n') ;

tab = char(32*ones(1,3)) ;

for i = 1:length(ese)
    fprintf(fid,[tab,ese{i},'\n']) ;
end

fprintf(fid,'}') ;

fclose(fid) ;



function ese = write_equations(model,branch)
    is_root_model = (nargin==1) ;

    if is_root_model
        branch = mttDetachText(model.source,'/') ;
    end
    
%    ese{1} = ' ' ;
%    ese{2} = ['// ESE representation for module: ',branch] ;
%    ese{3} = ' ' ;
%    
%    line = 3 ;

    line = 0 ;
    
    indent = char(32*ones(1,6)) ;

    
    objects = mttGetFieldNames(model,'obj') ;
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        switch object.class
        case 'SS',
            
            for j = 1:mttGetFieldLength(object,'interface')
                flow_equation = [] ;
                effort_equation = [] ;
                
                port_name = object.interface(j).name ;
                
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    
                    extern = [branch,'__',object_name,'___flow'] ;
                    intern = [branch,'___f[',num2str(inbond),']'] ;
                    if bond.flow
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    else
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___effort'] ;
                    intern = [branch,'___e[',num2str(inbond),']'] ;
                    if bond.effort
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    else
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
                
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    
                    extern = [branch,'__',object_name,'___flow'] ;
                    intern = [branch,'___f[',num2str(outbond),']'] ;
                    if bond.flow
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    else
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___effort'] ;
                    intern = [branch,'___e[',num2str(outbond),']'] ;
                    if bond.effort
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    else
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
            end
            
        case '0',
            
            imposed_effort = [] ;
            resultant_flow = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort(i),flow(i)] = mttGetBondCausality(model,bond_number(i)) ;
                
                if effort(i)==orientation(i)
                    imposed_effort_bond = bond_number(i) ;
                    imposed_effort = [branch,'___e[',num2str(imposed_effort_bond),']'] ;
                end
                if flow(i)==orientation(i)
                    resultant_flow_bond = bond_number(i) ;
                    resultant_flow = [branch,'___f[',num2str(resultant_flow_bond),']'] ;
                end
            end
            
            
            for i = 1:mttGetFieldLength(object,'interface')
                if bond_number(i)~=imposed_effort_bond
                    line = line + 1 ;
                    derived_effort = [branch,'___e[',num2str(bond_number(i)),']'] ;
                    ese{line} = [derived_effort,' = ',imposed_effort,' ;'] ;
                end
            end
            
            waiting = 1 ;
            offset = char(32*ones(1,length(resultant_flow)+1)) ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                next_flow = [] ;
                
                if bond_number(i)~=resultant_flow_bond
                    next_flow = [branch,'___f[',num2str(bond_number(i)),']'] ;
                    line = line + 1 ;
                    
                    if waiting
                        if orientation(i)
                            ese{line} = [resultant_flow,' = ',next_flow] ;
                        else
                            ese{line} = [resultant_flow,' = -',next_flow] ;
                        end
                        waiting = 0 ;
                    else
                        if orientation(i)
	                        ese{line} = [offset,'+ ',next_flow] ;
                        else
    	                    ese{line} = [offset,'- ',next_flow] ;
                        end
                    end
                end
            end
            ese{line} = [ese{line},' ;'] ;
            
        case '1',
            
            imposed_flow = [] ;
            resultant_effort = [] ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(i).in ;
                outbond = object.interface(i).out ;
                
                if isempty(inbond)
                    bond_number(i) = outbond ;
                    orientation(i) = 0 ;
                else
                    bond_number(i) = inbond ;
                    orientation(i) = 1 ;
                end
                
                [effort(i),flow(i)] = mttGetBondCausality(model,bond_number(i)) ;
                
                if flow(i)~=orientation(i)
                    imposed_flow_bond = bond_number(i) ;
                    imposed_flow = [branch,'___f[',num2str(imposed_flow_bond),']'] ;
                end
                if effort(i)~=orientation(i)
                    resultant_effort_bond = bond_number(i) ;
                    resultant_effort = [branch,'___e[',num2str(resultant_effort_bond),']'] ;
                end
            end
            
            
            for i = 1:mttGetFieldLength(object,'interface')
                if bond_number(i)~=imposed_flow_bond
                    line = line + 1 ;
                    derived_flow = [branch,'___f[',num2str(bond_number(i)),']'] ;
                    ese{line} = [derived_flow,' = ',imposed_flow,' ;'] ;
                end
            end
            
            waiting = 1 ;
            offset = char(32*ones(1,length(resultant_effort)+1)) ;
            
            for i = 1:mttGetFieldLength(object,'interface')
                next_effort = [] ;
                
                if bond_number(i)~=resultant_effort_bond
                    next_effort = [branch,'___e[',num2str(bond_number(i)),']'] ;
                    line = line + 1 ;
                    
                    if waiting
                        if orientation(i)
                            ese{line} = [resultant_effort,' = ',next_effort] ;
                        else
                            ese{line} = [resultant_effort,' = -',next_effort] ;
                        end
                        waiting = 0 ;
                    else
                        if orientation(i)
	                        ese{line} = [offset,'+ ',next_effort] ;
                        else
    	                    ese{line} = [offset,'- ',next_effort] ;
                        end
                    end
                end
            end
            ese{line} = [ese{line},' ;'] ;
            
        otherwise,
            
            if ~isempty(object.cr)
                operators = object.cr.operator ;
                interface = object.cr.interface ;
                port_names = mttGetFieldNames(interface,'port') ;
                
                link_counter = 0 ;
                
                for i = 1:length(port_names)
                    port_name = port_names{i} ;
                    port = getfield(interface,'port',port_name) ;
                    terminal = [branch,'__',object_name,'___',port_name] ;
                    
                    inbond = port.in ;
                    outbond = port.out ;
                    
                    if ~isempty(inbond)
                        bond = model.bond(inbond) ;
                        
                        intern = [branch,'___f[',num2str(inbond),']'] ;
                        if bond.flow
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [intern,' = ',terminal,'___flow_state ;'] ;
                            else
                                flow_equation = [intern,' = ',terminal,'___flow ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [terminal,'___flow_state = ',intern,' ;'] ;
                            else
                                flow_equation = [terminal,'___flow = ',intern,' ;'] ;
                            end
                        end
                        
                        intern = [branch,'___e[',num2str(inbond),']'] ;
                        if bond.effort
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [terminal,'___effort_state = ',intern,' ;'] ;
                            else
                                effort_equation = [terminal,'___effort = ',intern,' ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [intern,' = ',terminal,'___effort_state ;'] ;
                            else
                                effort_equation = [intern,' = ',terminal,'___effort ;'] ;
                            end
                        end
                        
                        line = line + 1 ;
                        ese{line} = flow_equation ;
                        
                        line = line + 1 ;
                        ese{line} = effort_equation ;
                    end                                
                    
                    if ~isempty(outbond)
                        bond = model.bond(outbond) ;
                        
                        intern = [branch,'___f[',num2str(outbond),']'] ;
                        if bond.flow
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [terminal,'___flow_state = ',intern,' ;'] ;
                            else
                                flow_equation = [terminal,'___flow = ',intern,' ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,0,1,port_name,port.is_flow_state) ;
                            
                            if port.is_flow_state
                                flow_equation = [intern,' = ',terminal,'___flow_state ;'] ;
                            else
                                flow_equation = [intern,' = ',terminal,'___flow ;'] ;
                            end
                        end
                        
                        intern = [branch,'___e[',num2str(outbond),']'] ;
                        if bond.effort
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(0,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [intern,' = ',terminal,'___effort_state ;'] ;
                            else
                                effort_equation = [intern,' = ',terminal,'___effort ;'] ;
                            end
                        else
                            link_counter = link_counter + 1 ;
                            link(link_counter) = create_link(1,1,0,port_name,port.is_effort_state) ;
                            
                            if port.is_effort_state
                                effort_equation = [terminal,'___effort_state = ',intern,' ;'] ;
                            else
                                effort_equation = [terminal,'___effort = ',intern,' ;'] ;
                            end
                        end
                        
                        line = line + 1 ;
                        ese{line} = flow_equation ;
                        
                        line = line + 1 ;
                        ese{line} = effort_equation ;
                    end
                end
                
                number_of_operators = length(operators) ;
                op_counter = 1 ;
                
                matching = 1 ;
                while matching
                    operator = operators(op_counter) ;
                    
                    links = length(link) ;
                    op_links = length(operator.link) ;
                    op_linked = zeros(op_links,1) ;
                    
                    for j = 1:op_links
                        for k = 1:links
                            if compare_links(link(k),operator.link(j))
                                op_linked(j) = k ;
                                break ;
                            end
                        end
                    end
                    
                    input_counter = 0 ;
                    output_counter = 0 ;
                    input = [] ;
                    output = [] ;
                    
                    if all(op_linked)
                        for j = 1:op_links
                            current_link = link(op_linked(j)) ;
                            port_name = current_link.name ;
                            
                            if current_link.is_effort
                                if current_link.is_state
                                    link_name = [branch,'__',object_name,'___',port_name,'___effort_state'] ;
                                else
                                    link_name = [branch,'__',object_name,'___',port_name,'___effort'] ;
                                end
                            end
                            if current_link.is_flow
                                if current_link.is_state
                                    link_name = [branch,'__',object_name,'___',port_name,'___flow_state'] ;
                                else
                                    link_name = [branch,'__',object_name,'___',port_name,'___flow'] ;
                                end
                            end
                            if current_link.is_input
                                input_counter = input_counter + 1 ;
                                input{input_counter} = link_name ;
                            else
                                output_counter = output_counter + 1 ;
                                output{output_counter} = link_name ;
                            end
                        end
                        
                        if input_counter>0
                            input_list = ['[',input{1}] ;
                            for j = 2:input_counter
                                input_list = [input_list,',',input{j}] ;
                            end
                            input_list = [input_list,']'] ;
                        end
                        
                        if output_counter>0
                            output_list = ['[',output{1}] ;
                            for j = 2:output_counter
                                output_list = [output_list,',',output{j}] ;
                            end
                            output_list = [output_list,']'] ;
                        end
                        
                        if input_counter>0
                            line = line + 1 ;
                            ese{line} = [output_list,' = '] ;
                        end
                        
                        line = line + 1 ;
                        ese{line} = [indent,branch,'__',object_name,'___',operator.name] ;
                        
                        if output_counter>0                                
                            line = line + 1 ;
                            ese{line} = [indent,indent,input_list,' ;'] ;
                        end
                        
                        link(op_linked) = [] ;
                    end
                    
                    op_counter = op_counter + 1 ;
                    matching = ~isempty(link) & (op_counter<=number_of_operators) ;
                end
                
                mttAssert(isempty(link),...
                    ['Unattached ports in "cr" implementation in ',here]) ;
            end
        end
    end
    
    for i = 1:length(objects)
        object_name = objects{i} ;
        object = getfield(model,'obj',object_name) ;
        
        here = [branch,':',object_name] ;
        
        if ~isempty(object.abg)
            for j = 1:mttGetFieldLength(object,'interface')
                inbond = object.interface(j).in ;
                outbond = object.interface(j).out ;
                inmap = object.interface(j).map.in ;
                outmap = object.interface(j).map.out ;
                
                line = line + 1 ;
                ese{line} = ' ' ;
                
                if ~isempty(inbond)
                    bond = model.bond(inbond) ;
                    
                    extern = [branch,'__',object_name,'___f[',num2str(inmap),']'] ;
                    intern = [branch,'___f[',num2str(inbond),']'] ;
                    if bond.flow
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    else
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___e[',num2str(inmap),']'] ;
                    intern = [branch,'___e[',num2str(inbond),']'] ;
                    if bond.effort
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    else
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
                
                if ~isempty(outbond)
                    bond = model.bond(outbond) ;
                    
                    extern = [branch,'__',object_name,'___f[',num2str(outmap),']'] ;
                    intern = [branch,'___f[',num2str(outbond),']'] ;
                    if bond.flow
                        flow_equation = [extern,' = ',intern,' ;'] ;
                    else
                        flow_equation = [intern,' = ',extern,' ;'] ;
                    end
                    
                    extern = [branch,'__',object_name,'___e[',num2str(outmap),']'] ;
                    intern = [branch,'___e[',num2str(outbond),']'] ;
                    if bond.effort
                        effort_equation = [intern,' = ',extern,' ;'] ;
                    else
                        effort_equation = [extern,' = ',intern,' ;'] ;
                    end
                    
                    line = line + 1 ;
                    ese{line} = flow_equation ;
                    
                    line = line + 1 ;
                    ese{line} = effort_equation ;
                end
            end
            next_branch = [branch,'__',object_name] ;
            
            object_ese = write_equations(object,next_branch) ;
            
            ese = [ese, object_ese] ;
            line = length(ese) ;
        end
    end
    
    
function link = create_link(is_input,is_effort,is_flow,name,is_state)
    link.is_input    = is_input ;
    link.is_effort   = is_effort ;
    link.is_flow     = is_flow ;
    link.name        = name ;
    link.is_state    = is_state ;
    
function boolean = compare_links(actual_link,op_link)
    input_is_same  = actual_link.is_input==op_link.is_input ;
    effort_is_same = actual_link.is_effort==op_link.is_effort ;
    flow_is_same   = actual_link.is_flow==op_link.is_flow ;
    name_is_same   = strcmp(actual_link.name,op_link.name) ;
    
    boolean = input_is_same & effort_is_same & flow_is_same & name_is_same ;
    
    

Added ntt/bin/trans/mttCutText.m version [df536d2c98].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [left,right] = mttCutText(text,delimiter)
    if isempty(text)
	    left = [] ;
    	right = [] ;
    else
	    where = min(findstr(text,delimiter)) ;
        if isempty(where)
            left = mttClipText(text) ;
            right = [] ;
        else
            left = mttClipText(text(1:where-1)) ;
            right = mttClipText(text(where+length(delimiter):length(text))) ;
        end
    end

Added ntt/bin/trans/mttDeleteField.m version [482e247ec2].







1
2
3
4
5
6
+
+
+
+
+
+
function model = mttDeleteField(structure,field_name)
    if isfield(structure,field_name)
        model = rmfield(structure,field_name) ;
    else
        model = structure ;
    end

Added ntt/bin/trans/mttDetachText.m version [3bacd6b720].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [detached_text,preceding_text] = mttDetachText(text,delimiter)
    if isempty(text)
        detached_text = [] ;
        preceding_text = [] ;
    else
	    where = max(findstr(text,delimiter)) ;
        if isempty(where)
            detached_text = [] ;
            preceding_text = mttClipText(text) ;
        else
            detached_text = mttClipText(text(where+length(delimiter):length(text))) ;
            preceding_text = mttClipText(text(1:where-1)) ;
        end
    end

Added ntt/bin/trans/mttElapseTime.m version [5d0d579808].





1
2
3
4
+
+
+
+
function elapsed_time = mttElapseTime(t0)
	current_time = mttGetTime ;
    elapsed_time.cpu = current_time.cpu - t0.cpu ;
    elapsed_time.clock = etime(current_time.clock,t0.clock) ;

Added ntt/bin/trans/mttExtractStatements.m version [62c7b13d82].
























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function statements = mttExtractStatements(content)
	input = 1 ;
    output = 0 ;
    line = [] ;
    
    searching = 0 ;
    processing = 1 ;
    while processing
        line = [line,content{input}] ;
        line = mttCutText(line,'//') ;
        
        if ~isempty(line)
            semicolon = findstr(line,';') ;
            leftbrace = findstr(line,'{') ;
            rightbrace = findstr(line,'}') ;
            terminator = sort([semicolon,leftbrace,rightbrace]) ;
            
            if isempty(terminator)
                searching = 1 ;
            else
                first = 1 ;
                N = length(terminator) ;
                L = length(line) ;
                
                for i = 1:N
                    last = terminator(i) - 1 ;
                    if first<=last
                        output = output + 1 ;
                        statements{output} = mttClipText(line(first:last)) ;
                    end
                    
                    if ismember(line(terminator(i)),{'{','}'})
                        output = output + 1 ;
                        statements{output} = line(terminator(i)) ;
                    end
                    first = last + 2 ;
                end
                
                if terminator(N)==L
                    line = [] ;
                    searching = 0 ;
                else
                    line = mttClipText(line(terminator(N):L)) ;
                end
            end
        end
        input = input + 1 ;
        processing = input<=length(content) ;
        
        if searching
            mttAssert(input<=length(content),...
                'End of file found with an incomplete statement') ;
        end
    end
    

Added ntt/bin/trans/mttExtractText.m version [18e3a1f15b].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
function extracted_text = mttExtractText(text,left,right)
    if isempty(text)
	    extracted_text = [] ;
    else
	    where_left = min(findstr(text,left)) ;
    	where_right = min(findstr(text,right)) ;
    
        if ~isempty(where_left) & ~isempty(where_right)
            extracted_text = mttClipText(text(where_left+length(left):where_right-1)) ;
        else
            extracted_text = [] ;
        end
    end

Added ntt/bin/trans/mttFileExists.m version [88a67661d5].





1
2
3
4
+
+
+
+
function boolean = mttFileExists(filename)

    boolean = exist(filename)==2 ;

Added ntt/bin/trans/mttFindEquationVariables.m version [448d87faf7].




































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [varlist,location] = mttFindEquationVariables(line)
	line = mttClipText(line) ;

	if isempty(line)
        namelist = [] ;
        location = [] ;
    else
        numbers = (line>=48 & line<=57) ;
        letters = (line>=65 & line<=90)|(line>=97 & line<=122) ;
        underscores = (line==95) ;
        dots = (line==46) ;
        apostrophes = (line==39) ;
        
        mask = (numbers|letters|underscores|dots|apostrophes) ;
        
        buffer = line ;
        buffer(~mask) = char(32*ones(1,sum(~mask))) ;
        
        next = 1 ;
        last = length(buffer) ;
        
        counter = 0 ;
        
        finding = any(mask) ;
        while finding
            i = min(find(~isspace(buffer(next:last))))+next-1 ;
            
            if isempty(i)
                finding = 0 ;
            else
                if i>last
                    finding = 0 ;
                else
                    if i==last
                        j = last ;
                    else
                        j = min(find(isspace(buffer(i+1:last))))+i ;
                        
                        if isempty(j)
                            j = last ;
                        else
                            j = j - 1 ;
                        end
                    end
                    
                    if ~mttIsNumericText(buffer(i:j))
                        var_found = 1 ;
                        
                        if j<last
                            jj = min(find(~isspace(line(j+1:last))))+j ;
                            if line(jj)=='('
                                var_found = 0 ;
                            end
                        end
                        if var_found
                            counter = counter + 1 ;
                            varlist{counter} = buffer(i:j) ;
                            location(counter) = i ;
                        end
                    end
                    next = j + 1 ;
                    finding = (next<last) & ~isempty(i) ;
                end
            end
        end
    end
     

Added ntt/bin/trans/mttGetBondCausality.m version [e62609931f].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
function [effort_causality,flow_causality,uni_causality] = mttGetBondCausality(model,bond_number)
    if isempty(bond_number)
        effort_causality = [] ;
        flow_causality = [] ;
        uni_causality = [] ;
    else
        effort_causality = model.bond(bond_number).effort ;
        flow_causality = model.bond(bond_number).flow ;
        uni_causality = model.bond(bond_number).unicausal ;
    end

Added ntt/bin/trans/mttGetBondDomain.m version [b0febc628a].









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
function [domain,domain_item] = mttGetBondDomain(model,bond_number)
    if isempty(bond_number)
        domain = [] ;
        domain_item = [] ;
    else
        domain = model.bond(bond_number).domain ;
        domain_item = model.bond(bond_number).domain_item ;
    end

Added ntt/bin/trans/mttGetCovariables.m version [5ae2548ed6].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
function covariables = mttGetCovariables(env,domain,domain_item)
	if isempty(domain)
        covariables.effort = {'effort'} ;
        covariables.flow = {'flow'} ;
        covariables.effort_default = {[]} ;
        covariables.flow_default = {[]} ;
    else
        covariables = getfield(env,'public_domain',{domain},'item',domain_item) ;
    end
    

Added ntt/bin/trans/mttGetField.m version [93d11ba8da].






1
2
3
4
5
+
+
+
+
+
function field = mttGetField(structure,component)
	field = [] ;
	if isfield(structure,component)
        field = getfield(structure,component) ;
    end

Added ntt/bin/trans/mttGetFieldLength.m version [ffab5c2924].






1
2
3
4
5
+
+
+
+
+
function N = mttGetFieldLength(structure,vector)
    N = 0 ;
    if isfield(structure,vector)
        N = length(getfield(structure,vector)) ;
    end

Added ntt/bin/trans/mttGetFieldNames.m version [371982056a].










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
function namelist = mttGetFieldNames(structure,component)
    namelist = [] ;
    if isfield(structure,component)
        field = getfield(structure,component) ;
        if ~isempty(field)
            namelist = fieldnames(field) ;
        end
    end

Added ntt/bin/trans/mttGetInstanceParameters.m version [12b70a7300].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
function parameters = mttGetInstanceParameters(parameter_list)
    parameters = mttGetItemList(parameter_list) ;

    for n = 1:length(parameters)
        if mttIsNumericText(parameters{n})
            parameters{n} = str2num(parameters{n}) ;
        else
            mttValidateName(parameters{n}) ;
        end
    end

Added ntt/bin/trans/mttGetItemList.m version [52367110b3].






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [items,item_values] = mttGetItemList(text)
    if isempty(text)
	    items = [] ;
        item_values = [] ;
    else
        counter = 0 ;
        fetching_items = 1 ;
        while fetching_items
            counter = counter + 1 ;
            [next_item,text] = mttCutText(text,',') ;
            
            [item_name,item_value] = mttCutText(next_item,'=') ;
            
            items{counter} = item_name ;
            item_values{counter} = item_value ;
            
            if isempty(text)
                fetching_items = 0 ;
            end
        end
    end

Added ntt/bin/trans/mttGetParameters.m version [d7054c9547].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [parameters,default_values] = mttGetParameters(parameter_list)
    [parameters,default_values] = mttGetItemList(parameter_list) ;
    
    for n = 1:length(parameters)
        parameter_name = parameters{n} ;
        mttValidateName(parameter_name) ;
    end
    
    for n = 1:length(default_values)
        default_value = default_values{n} ;
        if ~isempty(default_value)
            mttAssert(mttIsNumericText(default_value),...
                'Parameter list contains non-numeric default value') ;
        end
    end

Added ntt/bin/trans/mttGetTime.m version [db639d211d].




1
2
3
+
+
+
function time = mttGetTime
	time.clock = clock ;
    time.cpu = cputime ;

Added ntt/bin/trans/mttIdentifyImplicitBonds.m version [06bec7e6fc].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function next_next = mttIdentifyImplicitBonds(model,branch,next)
    is_root_model = (nargin==1) ;
    
    if is_root_model
        mttNotify('...following bonds have no explicit domain allocation:') ;
        mttWriteNewLine ;
        
        branch = mttDetachText(model.source,'/') ;
        next = 0 ;
    end

    number_of_bonds = mttGetFieldLength(model,'bond') ;
    for i = 1:number_of_bonds
        if isempty(model.bond(i).domain)
            origin = model.bond(i).from.obj ;
            port = model.bond(i).from.interface ;
            
            if isfield(model.obj,origin)
                origin_class = getfield(model,'obj',origin,'class') ;
                
                switch origin_class
                case {'0','1'},
                    bond_origin = [origin_class,':',origin] ;
                otherwise,
                    origin_port = getfield(model,'obj',origin,'interface',{port},'name') ;
                    bond_origin = [origin_class,':',origin,'[',origin_port,']'] ;
                end
            else
                bond_origin = ['SS:',origin] ;
            end
            
            target = model.bond(i).to.obj ;
            port = model.bond(i).to.interface ;
            
            if isfield(model.obj,target)
                target_class = getfield(model,'obj',target,'class') ;
                
                switch target_class
                case {'0','1'},
                    bond_target = [target_class,':',target] ;
                otherwise,
                    target_port = getfield(model,'obj',target,'interface',{port},'name') ;
                    bond_target = [target_class,':',target,'[',target_port,']'] ;
                end
            else
                bond_target = ['SS:',target] ;
            end
            
            next = next + 1 ;
            descriptor = ['      ',num2str(next),': ',branch,'(',num2str(i),') from: ',...
                bond_origin,' to: ',bond_target] ;
            
            mttNotify(descriptor) ;
            mttWriteNewLine ;
        end
    end
    
    
    next_next = next ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            next_branch = [branch,'/',object_name] ;
            next_next = mttIdentifyImplicitBonds(object,next_branch,next) ;
            next = next_next ;
        end
    end
    

Added ntt/bin/trans/mttIdentifySource.m version [333fd4e482].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function [directory,file] = mttIdentifySource(local_filename)
local_filename
    filename = which(local_filename) 
    backslash = findstr(filename,'\') ;
    filename(backslash) = '/' ;
    
    [file,directory] = mttDetachText(filename,'/') ;

Added ntt/bin/trans/mttIdentifyUndercausalBonds.m version [b4813b7312].











































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function next_next = mttIdentifyUndercausalBonds(model,branch,next)
    is_root_model = (nargin==1) ;
    
    if is_root_model
        mttNotify('...following bonds are under-causal:') ;
        mttWriteNewLine ;
        
        branch = mttDetachText(model.source,'/') ;
        next = 0 ;
    end

    number_of_bonds = mttGetFieldLength(model,'bond') ;
    for i = 1:number_of_bonds
        if isempty(model.bond(i).effort) | isempty(model.bond(i).flow)
            origin = model.bond(i).from.obj ;
            port = model.bond(i).from.interface ;
            
            if isfield(model.obj,origin)
                origin_class = getfield(model,'obj',origin,'class') ;
                
                switch origin_class
                case {'0','1'},
                    bond_origin = [origin_class,':',origin] ;
                otherwise,
                    origin_port = getfield(model,'obj',origin,'interface',{port},'name') ;
                    bond_origin = [origin_class,':',origin,'[',origin_port,']'] ;
                end
            else
                bond_origin = ['SS:',origin] ;
            end
            
            target = model.bond(i).to.obj ;
            port = model.bond(i).to.interface ;
            
            if isfield(model.obj,target)
                target_class = getfield(model,'obj',target,'class') ;
                
                switch target_class
                case {'0','1'},
                    bond_target = [target_class,':',target] ;
                otherwise,
                    target_port = getfield(model,'obj',target,'interface',{port},'name') ;
                    bond_target = [target_class,':',target,'[',target_port,']'] ;
                end
            else
                bond_target = ['SS:',target] ;
            end
            
            next = next + 1 ;
            descriptor = ['      ',num2str(next),': ',branch,'(',num2str(i),') from: ',...
                bond_origin,' to: ',bond_target] ;
            
            mttNotify(descriptor) ;
            mttWriteNewLine ;
        end
    end
    
    
    next_next = next ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        
        if isfield(object,'obj')
            next_branch = [branch,'/',object_name] ;
            next_next = mttIdentifyUndercausalBonds(object,next_branch,next) ;
            next = next_next ;
        end
    end
    

Added ntt/bin/trans/mttIdentifyUserDomain.m version [c4859d1958].








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function user_domain_identification = mttIdentifyUserDomain(environment,domain,domain_item)
    user_domain_identification = [] ;
    
    if ~(isempty(domain) | isempty(domain_item))
        user_domain_names = mttGetFieldNames(environment,'domain') ;
        number_of_user_domains = length(user_domain_names) ;
        
        counter = 0 ;
        
        identifying = 1 ;
        while identifying
            counter = counter + 1 ;
            user_domain_name = user_domain_names{counter} ;
            user_domain = getfield(environment,'domain',user_domain_name) ;
            
            specified_domain = user_domain.dom ;
            specified_domain_item = user_domain.item ;
            
            if domain==specified_domain
                if ~isempty(domain_item)
                    if isempty(specified_domain_item)
                        domain_item_names = mttGetFieldNames(environment.public_domain(domain),'item') ;
                        is_valid_item = ismember(domain_item,domain_item_names) ;
                        if is_valid_item
                            user_domain_identification = [user_domain_name,'__',domain_item] ;
                        end
                    else
                        is_matched_item = strcmp(domain_item,specified_domain_item) ;
                        if is_matched_item
                            user_domain_identification = user_domain_name ;
                        end
                    end
                end
            end
            
            identifying = (counter<number_of_user_domains) & isempty(user_domain_identification) ;
        end
    end
    

Added ntt/bin/trans/mttIsEmptyCellArray.m version [39b20a02b5].











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
function boolean = mttIsEmptyCellArray(cell_array)
    boolean = [] ;
    if iscell(cell_array)
        boolean = 1 ;
        for i = 1:length(cell_array)
            if ~isempty(cell_array{i})
                boolean = 0 ;
            end
        end
    end

Added ntt/bin/trans/mttIsEqual.m version [6c0e6f54d5].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function result = mttIsEqual(left,right)
	if ~isempty(left) & ~isempty(right)
        result = left==right ;
    else
        result = [] ;
    end
    

Added ntt/bin/trans/mttIsFoundationClass.m version [33607d1580].





1
2
3
4
+
+
+
+
function boolean = mttIsFoundationClass(class_name)
    boolean = ismember(class_name,...
        {'R','C','I','TF','GY','AE','AF','SS','Se','Sf','De','Df','0','1'}) ;

Added ntt/bin/trans/mttIsNumericText.m version [8cd049d628].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function boolean = mttIsNumericText(text)

    if any(abs(text)==39)
    % MATLAB doesn't like apostrophes in text
        boolean = 0 ;
    elseif strcmp(text,'flow')
    % MATLAB invokes built-in function "flow" rather than treating it as text in str2num(text) !!!
        boolean = 0 ;
    elseif strcmp(text,'error')
    % MATLAB invokes built-in function "error" rather than treating it as text in str2num(text) !!!
        boolean = 0 ;
    else
        num = str2num(text) ;
        if isempty(num)
            boolean = 0 ;
            % ... contains non-numeric characters other than stand-alone "i" or "j"
        else
            boolean = isreal(num) ;
            % ... doesn't contain stand-alone "i" or "j"
        end
    end
    

Added ntt/bin/trans/mttIsPassiveClass.m version [e8bd676573].



1
2
+
+
function boolean = mttIsPassiveClass(class_name)
	boolean = ismember(class_name,{'SS','Se','Sf','De','Df','0','1'}) ;

Added ntt/bin/trans/mttIsPortClass.m version [5ddeb3fb33].



1
2
+
+
function boolean = mttIsPortClass(class_name)
	boolean = ismember(class_name,{'SS','Se','Sf','De','Df'}) ;

Added ntt/bin/trans/mttLocateDirectory.m version [4faff0628d].



































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function directory = mttLocateDirectory(working_directory,local_directory)
	if isempty(local_directory)
        directory = working_directory ;
    else
        backslash = findstr(working_directory,'\') ;
        working_directory(backslash) = '/' ;
        
        [working_drive,working_path] = mttCutText(working_directory,':') ;
        if isempty(working_path)
            working_path = working_directory ;
            working_drive = [] ;
        end
        
        [local_drive,local_path] = mttCutText(local_directory,':') ;
        if isempty(local_path)
            local_path = local_directory ;
            local_drive = [] ;
        end
        
        
        if isempty(local_drive)
            if local_path(1)=='/'
                if isempty(working_drive)
                    directory = local_path ;
                else
                    directory = [working_drive,':',local_path] ;
                end
            else
                directory = [working_directory,'/',local_directory] ;
            end
        else
            mttAssert(all(isletter(local_drive)),...
                ['"',local_drive,'" is an invalid drive specifier']) ;
            directory = local_directory ;
        end
        mttAssert(exist(directory,'dir')==7,...
            ['Directory "',directory,'" not found']) ;
        
        locating = 1 ;
        while locating
            [left,right] = mttCutText(directory,'//') ;
            if isempty(right)
                locating = 0 ;
            else
                directory = [left,'/',right] ;
            end
        end
        
        locating = 1 ;
        while locating
            backtrack = findstr(directory,'/..') ;
            if isempty(backtrack)
                locating = 0 ;
            else
                [left,right] = mttCutText(directory,'/..') ;
                if isempty(right)
                    [cancelled,left] = mttDetachText(left,'/') ;
                    directory = left ;
                else
                    [cancelled,left] = mttDetachText(left,'/') ;
                    directory = [left,right] ;
                end
            end
        end
    end
    

Added ntt/bin/trans/mttMeasureCausalCompletion.m version [0f88a2574d].





















































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttMeasureCausalCompletion(model)
    
    number_of_bonds = mttGetFieldLength(model,'bond') ;

    for i = 1:number_of_bonds
        effort_defined(i) = ~isempty(model.bond(i).effort) ;
        flow_defined(i) = ~isempty(model.bond(i).flow) ;
    end
    partly_defined = effort_defined|flow_defined ;
    fully_defined = effort_defined&flow_defined ;
    
    causal_completion.bonds = number_of_bonds ;
    causal_completion.flows = sum(flow_defined) ;
    causal_completion.efforts = sum(effort_defined) ;
    causal_completion.assignments = sum(partly_defined) ;
    
    unicausal_bonds = 0 ;
    causal_bond = model.bond(fully_defined) ;
    for i = 1:length(causal_bond)
        if causal_bond(i).effort==causal_bond(i).flow
            unicausal_bonds = unicausal_bonds + 1 ;
        end
    end
    causal_completion.unicausal = unicausal_bonds ;
    causal_completion.is_unicausal = causal_completion.assignments==causal_completion.unicausal ;
    
    causal_completion.is_causal = (causal_completion.efforts==causal_completion.bonds) ...
                                & (causal_completion.flows==causal_completion.bonds) ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        if ~isempty(object.abg)
            object = mttMeasureCausalCompletion(object) ;
            
            causal_completion.bonds         = causal_completion.bonds        + object.causal_completion.bonds ;
            causal_completion.flows         = causal_completion.flows        + object.causal_completion.flows ;
            causal_completion.efforts       = causal_completion.efforts      + object.causal_completion.efforts ;
            causal_completion.assignments   = causal_completion.assignments  + object.causal_completion.assignments ;
            causal_completion.unicausal     = causal_completion.unicausal    + object.causal_completion.unicausal ;
            
            causal_completion.is_unicausal  = causal_completion.is_unicausal & object.causal_completion.is_unicausal ;
            causal_completion.is_causal     = causal_completion.is_causal    & object.causal_completion.is_causal ;
        end
    end
    
    model.causal_completion = causal_completion ;
    
    

Added ntt/bin/trans/mttMeasureDomainCompletion.m version [ba3a2087d1].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function model = mttMeasureDomainCompletion(model)
    
    number_of_bonds = mttGetFieldLength(model,'bond') ;

    for i = 1:number_of_bonds
        domain_defined(i) = ~isempty(model.bond(i).domain) ;
    end
    
    domain_completion.bonds = number_of_bonds ;
    domain_completion.assignments = sum(domain_defined) ;
    
    domain_completion.is_done = (domain_completion.bonds==domain_completion.assignments) ;
    
    object_names = mttGetFieldNames(model,'obj') ;
    number_of_objects = length(object_names) ;
    
    for i = 1:number_of_objects
        object_name = object_names{i} ;
        object = getfield(model,'obj',object_name) ;
        if ~isempty(object.abg)
            object = mttMeasureDomainCompletion(object) ;
            
            domain_completion.bonds       = domain_completion.bonds       + object.domain_completion.bonds ;
            domain_completion.assignments = domain_completion.assignments + object.domain_completion.assignments ;
            
            domain_completion.is_done     = domain_completion.is_done     & object.domain_completion.is_done ;
        end
    end
    
    model.domain_completion = domain_completion ;
    
    

Added ntt/bin/trans/mttNotify.m version [f0a2b33349].




1
2
3
+
+
+
function mttNotify(msg)
    fprintf(msg) ;
    

Added ntt/bin/trans/mttNotifyCausalCompletion.m version [e3901e9d39].


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttNotifyCausalCompletion(model)
    
	flow = floor(100*model.causal_completion.flows/model.causal_completion.bonds) ;
	effort = floor(100*model.causal_completion.efforts/model.causal_completion.bonds) ;
	unicausal = model.causal_completion.unicausal/model.causal_completion.bonds ;
	
    if model.causal_completion.is_unicausal
	    fprintf(['   ...causality is %i%% complete [%i/%i]: all unicausal\n'],...
            flow,model.causal_completion.assignments,model.causal_completion.bonds) ;
	else
	    fprintf(['   .....flow causality is %i%% complete [%i/%i]\n'],...
            flow,model.causal_completion.flows,model.causal_completion.bonds) ;
	    fprintf(['   ...effort causality is %i%% complete [%i/%i]\n'],...
            effort,model.causal_completion.efforts,model.causal_completion.bonds) ;
	    fprintf(['              => %i bonds are unicausal\n'],...
            model.causal_completion.unicausal) ;
	end

Added ntt/bin/trans/mttNotifyDomainCompletion.m version [532186cac8].







1
2
3
4
5
6
+
+
+
+
+
+
function mttNotifyDomainCompletion(model)
    
	domain = floor(100*model.domain_completion.assignments/model.domain_completion.bonds) ;
	
    fprintf(['   ...domain allocation is %i%% complete [%i/%i]\n'],...
        domain,model.domain_completion.assignments,model.domain_completion.bonds) ;

Added ntt/bin/trans/mttNotifyEquationSort.m version [5bdea2a945].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function is_complete = mttNotifyEquationSort(sort_iteration,...
    number_of_unsorted_equations,number_of_equations,...
    number_of_known_covariables,number_of_covariables,...
    number_of_known_interface_variables,number_of_interface_variables) ;
	
%	number_of_known_covariables = number_of_known_covariables - 1 ;
	number_of_known_interface_variables = number_of_known_interface_variables - 1 ;
    
    number_of_sorted_equations = number_of_equations - number_of_unsorted_equations ;
    
    sorted = floor(100*number_of_sorted_equations/number_of_equations) ;
    covar = floor(100*number_of_known_covariables/number_of_covariables) ;
    interface_var = floor(100*number_of_known_interface_variables/number_of_interface_variables) ;
    
    fprintf(['   ...%i%% complete [%i/%i]\n'],...
        sorted,number_of_sorted_equations,number_of_equations) ;
    fprintf(['          matching %i%% co_variables [%i/%i] and'],...
        covar,number_of_known_covariables,number_of_covariables) ;
    fprintf([' %i%% interface_variables [%i/%i]\n'],...
        interface_var,number_of_known_interface_variables,number_of_interface_variables) ;
    
    is_complete = (sorted==100) & (covar==100) & (interface_var==100) ;
    

Added ntt/bin/trans/mttNotifyEquationSortProblems.m version [422f8ebbc4].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function mttNotifyEquationSortProblems(name_known,namelist)
    fprintf('   ...undetermined interface_variables are:\n') ;
	for i = 2:length(namelist)
        if ~name_known(i)
            fprintf(['         ',namelist{i},'\n']) ;
        end
    end

Added ntt/bin/trans/mttNotifyEquationSummary.m version [a1f8988b05].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
function mttNotifyEquationSummary(number_of_equations,number_of_covariables,number_of_interface_variables)
    mttNotify(['   ...model has ',num2str(number_of_equations),' equations']) ;
    mttWriteNewLine ;
    mttNotify(['      with ',num2str(number_of_covariables),' co_variables']) ;
    mttNotify([' and ',num2str(number_of_interface_variables),' interface_variables']) ;
    mttWriteNewLine ;
    

Added ntt/bin/trans/mttNotifyNumberOfBonds.m version [edfe090ab6].





1
2
3
4
+
+
+
+
function mttNotifyOfBonds(model)
    
	number_of_bonds  = model.causal_completion.bonds ;
    fprintf('   ...model has %i bonds',number_of_bonds) ;

Added ntt/bin/trans/mttNotifyNumberOfObjects.m version [a3f2f2c77b].






1
2
3
4
5
+
+
+
+
+
function mttNotifyOfObjects(model)
    
	number_of_objects = model.count.obj ;
    number_of_crs = model.count.cr ; 
    fprintf('   ...model has %i active objects (%i implemented by CRs)',number_of_objects,number_of_crs) ;

Added ntt/bin/trans/mttReadFile.m version [37968e6d57].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function content = mttReadFile(filename)

file_exists = exist(filename)==2 ;
if file_exists
    fid = fopen(filename,'r') ;
    reading = 1 ;
    
    counter = 0 ;
    while reading
        line = fgetl(fid) ;
        if ~isempty(line)
            if line==-1
                reading = 0 ;
            else
                counter = counter + 1 ;
                content{counter} = line ;
            end
        end
    end    
    fclose(fid) ;
else
    error(['file_not_found[',filename,']'])
end

Added ntt/bin/trans/mttSeparateText.m version [4f00712084].















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [left,right] = mttSeparateText(text)
    if isempty(text)
	    left = [] ;
        right = [] ;
    else
		whitespace = min(find(isspace(text))) ;
        if isempty(whitespace)
            left = text ;
            right = [] ;
        else
            left = text(1:whitespace-1) ;
            right = mttClipText(text(whitespace+1:length(text))) ;
        end
    end

Added ntt/bin/trans/mttSetFieldDefault.m version [5626026953].












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
function structure = mttSetFieldDefault(structure,component,value)
    undefined = 0 ;
    if isfield(structure,component)
        undefined = isempty(getfield(structure,component)) ;
    else
        undefined = 1 ;
    end
        
    if undefined
        structure = setfield(structure,component,value) ;
    end

Added ntt/bin/trans/mttUpdateBondCausality.m version [f0b400b32e].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%function [model,bond_not_failed,diagnostic] = mttUpdateBondCausality(...
%    model,bond_number,effort_causality,flow_causality,uni_causality)
function [model,bond_not_failed] = mttUpdateBondCausality(...
    model,bond_number,effort_causality,flow_causality,uni_causality)
    
    if isempty(bond_number)
        bond_not_failed = 1 ;
%        diagnostic = [] ;
    else
        [model.bond(bond_number).effort,effort_ok] = ...
            update_causality(model.bond(bond_number).effort,effort_causality) ;
        [model.bond(bond_number).flow,flow_ok] = ...
            update_causality(model.bond(bond_number).flow,flow_causality) ;
        [model.bond(bond_number).unicausal,unicausal_ok] = ...
            update_causality(model.bond(bond_number).unicausal,uni_causality) ;
        
        [model.bond(bond_number),unicausal_checked] = ...
            check_unicausal(model.bond(bond_number)) ;
        
        bond_not_failed = effort_ok & flow_ok & unicausal_ok & unicausal_checked ;
%        diagnostic = [effort_ok,flow_ok,unicausal_ok,unicausal_checked] ;
    end
    
    
function [value,ok] = update_causality(value,new_value)
    ok = 1 ;
    
    if ~isempty(new_value)
        if isempty(value)
            value = new_value ;
        else
            ok = value==new_value ;
        end
    end
    
function [bond,ok] = check_unicausal(bond)
    unicausal_defined = ~isempty(bond.unicausal) ;
    effort_defined = ~isempty(bond.effort) ;
    flow_defined = ~isempty(bond.flow) ;
    
    ok = 1 ;
    
    if unicausal_defined
        switch bond.unicausal
        case 0,
            if effort_defined & flow_defined
                ok = bond.effort==~bond.flow ;
            elseif effort_defined & ~flow_defined
                bond.flow = ~bond.effort ;
            elseif flow_defined & ~effort_defined
                bond.effort = ~bond.flow ;
            end
        case 1,
            if effort_defined & flow_defined
                ok = bond.effort==bond.flow ;
            elseif effort_defined & ~flow_defined
                bond.flow = bond.effort ;
            elseif flow_defined & ~effort_defined
                bond.effort = bond.flow ;
            end
        end
    end        
     

Added ntt/bin/trans/mttUpdateBondDomain.m version [04cf4f8e59].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function [model,bond_not_failed] = mttUpdateBondDomain(...
    model,bond_number,imposed_domain,imposed_domain_item)
    
    if isempty(bond_number)
        bond_not_failed = 1 ;
    else
        [model.bond(bond_number).domain,domain_ok] = ...
            update_domain(model.bond(bond_number).domain,imposed_domain) ;
        if domain_ok
            [model.bond(bond_number).domain_item,domain_item_ok] = ...
                update_domain_item(model.bond(bond_number).domain_item,imposed_domain_item) ;
        else
            domain_item_ok = 0 ;
        end
        
        bond_not_failed = domain_ok & domain_item_ok ;
    end
    
    
function [value,ok] = update_domain(value,new_value)
    ok = 1 ;
    
    if ~isempty(new_value)
        if isempty(value)
            value = new_value ;
        else
            ok = value==new_value ;
        end
    end
    
function [value,ok] = update_domain_item(value,new_value)
    ok = 1 ;
    
    if ~isempty(new_value)
        if isempty(value)
            value = new_value ;
        else
            ok = strcmp(value,new_value) ;
        end
    end
    

Added ntt/bin/trans/mttValidateName.m version [b841cdc721].



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function mttValidateName(name)
    mttAssert(~isempty(name),'Empty name') ;
    
    numbers = (name>=48 & name<=57) ;
    letters = (name>=65 & name<=90)|(name>=97 & name<=122) ;
    underscores = (name==95) ;
    
    is_alphanumeric = all(numbers|letters|underscores) ;
    starts_with_letter = isletter(name(1)) ;
    
    valid_name = is_alphanumeric & starts_with_letter ;
%    mtt_prefix = strncmp(name,'mtt_',4) ;
    mtt_delimiter = ~isempty(findstr(name,'__')) ;
    
%    mttAssert(~mtt_prefix,['"',name,'" must not contain "mtt_" prefix']) ;
    mttAssert(~mtt_delimiter,['"',name,'" must not contain contiguous "_" delimiters']) ;
    mttAssert(valid_name,['"',name,'" is not a valid name']) ;
    mttAssert(length(name)<32,['"',name,'" must be shortened to less than 32 characters']) ;

Added ntt/bin/trans/mttVerifyAlternativeEquations.m version [c872db1223].










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function delta = mttVerifyEquations(primary,secondary)
    searching = 1 ;
    
    length_primary = length(primary) ;
    length_secondary = length(secondary) ;
    
    i = 1 ;
    j = 1 ;
    k = 1 ;
    fprintf('k=%i: i=%i j=%i L=%i\n',k,i,j,length_secondary) ;            

    while searching
        k = k + 1 ;
        if strcmp(primary(i),secondary(j))
            secondary(j) = [] ;
            length_secondary = length_secondary - 1 ;
            fprintf('k=%i: i=%i j=%i L=%i\n',k,i,j,length_secondary) ;            
            
            i = i + 1;
            j = 1 ;
        else
            j = j + 1 ;
        end
        
        if length_secondary<1
            searching = 0 ;
        elseif j>length_secondary
            i = i + 1 ;
            j = 1 ;
        end
        
        if i>length_primary
            searching = 0 ;
        end
    end
            
    delta = secondary ;

    fprintf('Verification complete after %i iterations\n',k) ;            
    fprintf('...%i new records found\n',length(delta)) ;
    

Added ntt/bin/trans/mttWriteNewLine.m version [252139e429].




1
2
3
+
+
+
function mttWriteNewLine
	fprintf('\n') ;

Added patches/p2c/p2c-1.21alpha2/lex.c.diff version [7c654e3c9b].
































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
*** p2c-1.22/src/lex.c	Tue Mar 16 09:28:20 1999
--- p2c-1.22-dev/src/lex.c	Tue Jan 30 16:57:23 2001
*************** Static int skipflag;
*** 38,44 ****
  Static char modulenotation;
  Static short inputkind;
  Static Strlist *instrlist;
! Static char inbuf[300];
  Static char *oldinfname, *oldctxname;
  Static Strlist *endnotelist;
  
--- 38,44 ----
  Static char modulenotation;
  Static short inputkind;
  Static Strlist *instrlist;
! Static char *inbuf;
  Static char *oldinfname, *oldctxname;
  Static Strlist *endnotelist;
  
*************** void init_lex()
*** 411,416 ****
--- 411,417 ----
      inputkind = INP_FILE;
      inf_lnum = 0;
      inf_ltotal = 0;
+     inbuf = ALLOC(buffersize, char, strings); /* strings ? */
      *inbuf = 0;
      inbufptr = inbuf;
      keepingstrlist = NULL;
*************** void getline()
*** 1055,1061 ****
          case INP_INCFILE:
              inf_lnum++;
  	    inf_ltotal++;
!             if (fgets(inbuf, 300, inf)) {
                  cp = inbuf + strlen(inbuf);
                  if (*inbuf && cp[-1] == '\n')
                      cp[-1] = 0;
--- 1056,1062 ----
          case INP_INCFILE:
              inf_lnum++;
  	    inf_ltotal++;
!             if (fgets(inbuf, buffersize, inf)) {
                  cp = inbuf + strlen(inbuf);
                  if (*inbuf && cp[-1] == '\n')
                      cp[-1] = 0;
*************** int p2c_only, starparen;
*** 1889,1895 ****
      }
      if (!isalpha(*cp))
          return 0;
!     while ((isalnum(*cp) || *cp == '_') && cp2 < namebuf+300)
          *cp2++ = toupper(*cp++);
      if (cp[0] == '+' && cp[1] == '+' &&
  	cp == inbufptr+1 && toupper(cp[-1]) == 'C')
--- 1890,1896 ----
      }
      if (!isalpha(*cp))
          return 0;
!     while ((isalnum(*cp) || *cp == '_') && cp2 < namebuf+buffersize)
          *cp2++ = toupper(*cp++);
      if (cp[0] == '+' && cp[1] == '+' &&
  	cp == inbufptr+1 && toupper(cp[-1]) == 'C')

Added patches/p2c/p2c-1.21alpha2/loc.p2crc version [73e4cd2acc].













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+

# Store public p2crc commands local to your system here, so that
# you can grab a new version of sys.p2crc without losing your changes.

BufferSize=1000000.

LineWidth=1000000.
MaxLineWidth=1000000.

OverWidePenalty=0.
OverWideExtraPenalty=0.

Added patches/p2c/p2c-1.21alpha2/parse.c.diff version [305c42d48a].




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
*** p2c-1.22/src/parse.c	Tue Mar 16 09:28:20 1999
--- p2c-1.22-dev/src/parse.c	Tue Jan 30 16:30:40 2001
*************** int p_search(fname, ext, need)
*** 5477,5483 ****
  char *fname, *ext;
  int need;
  {
!     char infnbuf[300];
      FILE *fp;
      Meaning *mod;
      int savesysprog, savecopysource;
--- 5477,5483 ----
  char *fname, *ext;
  int need;
  {
!     char infnbuf[buffersize];
      FILE *fp;
      Meaning *mod;
      int savesysprog, savecopysource;

Added patches/p2c/p2c-1.21alpha2/sys.p2crc.diff version [189e9e035c].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
*** p2c-1.22/src/sys.p2crc	Tue Mar 16 09:28:20 1999
--- p2c-1.22-dev/src/sys.p2crc	Tue Jan 30 17:01:14 2001
*************** MinSpacingThresh                # If spe
*** 455,460 ****
--- 455,462 ----
  
  # LINE BREAKING
  
+ BufferSize			# Maximum input line length; default=300.
+ 
  LineWidth                       # Target max output line width; default=78.
  
  MaxLineWidth                    # Absolute max output line width; default=90.

Added patches/p2c/p2c-1.21alpha2/trans.h.diff version [e99f32563f].























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
*** p2c-1.22/src/trans.h	Tue Mar 16 09:28:21 1999
--- p2c-1.22-dev/src/trans.h	Tue Jan 30 17:25:33 2001
*************** extern int sizeof_char, sizeof_short, si
*** 1133,1138 ****
--- 1133,1139 ----
  extern short size_t_long;
  extern int setbits, defaultsetsize, seek_base, integerwidth, realwidth;
  extern short quoteincludes, expandincludes, collectnest;
+ extern const int buffersize;
  extern int phystabsize, intabsize, linewidth, maxlinewidth;
  extern int majorspace, minorspace, declspace, functionspace, minfuncspace;
  extern int casespacing, caselimit;
*************** struct rcstruct {
*** 1351,1356 ****
--- 1352,1358 ----
      'I', 'R', "MINSPACINGTHRESH",(anyptr) &minspacingthresh, -1,
  
  /* LINE BREAKING */
+     'I', 'R', "BUFFERSIZE",	(anyptr) &buffersize,	300,
      'I', 'R', "LINEWIDTH",       (anyptr) &linewidth,        78,
      'I', 'R', "MAXLINEWIDTH",    (anyptr) &maxlinewidth,     90,
      'R', 'V', "OVERWIDEPENALTY",       (anyptr) &overwidepenalty,         2500,


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]